Browse Source

读取收入表

master
zy_Java 5 years ago
parent
commit
329cde8ef1
  1. 36
      ht/src/main/resources/application-prod.yml
  2. 4
      ht/src/main/resources/application.yml
  3. 12
      pims/src/main/java/com/ccsens/pims/api/ReadController.java
  4. 37
      pims/src/main/java/com/ccsens/pims/bean/vo/CompanyVo.java
  5. 6
      pims/src/main/java/com/ccsens/pims/service/IRealExcelService.java
  6. 25
      pims/src/main/java/com/ccsens/pims/service/RealExcelService.java
  7. 50
      pims/src/main/java/com/ccsens/pims/service/ReportService.java
  8. 4
      pims/src/main/resources/logback-spring.xml
  9. 16
      pims/src/main/resources/mapper_dao/ProducrDao.xml
  10. 6
      tall/src/main/resources/application-prod.yml
  11. 4
      tall/src/main/resources/application.yml
  12. 8
      util/src/test/java/com/ccsens/util/Base64Test.java

36
ht/src/main/resources/application-prod.yml

@ -7,23 +7,23 @@ spring:
name: ht name: ht
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
rabbitmq: rabbitmq:
host: api.ccsens.com host: 127.0.0.1
password: 111111 password: 111111
port: 5672 port: 5672
username: admin username: admin
redis: redis:
database: 0 database: 0
host: 127.0.0.1 host: 127.0.0.1
jedis: jedis:
pool: pool:
max-active: 200 max-active: 200
max-idle: 10 max-idle: 10
max-wait: -1ms max-wait: -1ms
min-idle: 0 min-idle: 0
password: 'areowqr!@43ef' password: 'areowqr!@43ef'
port: 6379 port: 6379
timeout: 1000ms timeout: 1000ms
swagger: swagger:
@ -37,4 +37,4 @@ ht:
name: 认知功能评测云平台系统 name: 认知功能评测云平台系统
eureka: eureka:
instance: instance:
ip-address: 140.143.228.3 ip-address: 71.80.54.64

4
ht/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring: spring:
profiles: profiles:
active: test active: prod
include: common, util-test include: common, util-prod

12
pims/src/main/java/com/ccsens/pims/api/ReadController.java

@ -35,12 +35,20 @@ public class ReadController {
return JsonResponse.newInstance().ok(); return JsonResponse.newInstance().ok();
} }
@ApiOperation(value = "读取产品价格依据表", notes = "") @ApiOperation(value = "读取产值及附加估算表", notes = "")
@RequestMapping(value = "/production", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "/production", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse realProduction(@Validated @RequestBody CompanyDto.Async async) throws Exception { public JsonResponse realProduction(@Validated @RequestBody CompanyDto.Async async) throws Exception {
log.info("读取产品价格依据表:{}",async.toString()); log.info("读取产值及附加估算表:{}",async.toString());
realExcelService.realProduction(async); realExcelService.realProduction(async);
return JsonResponse.newInstance().ok(); return JsonResponse.newInstance().ok();
} }
@ApiOperation(value = "读取总成本费用估算表", notes = "")
@RequestMapping(value = "/cost", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse realCost(@Validated @RequestBody CompanyDto.Async async) throws Exception {
log.info("读取总成本费用估算表:{}",async.toString());
realExcelService.realCost(async);
return JsonResponse.newInstance().ok();
}
} }

37
pims/src/main/java/com/ccsens/pims/bean/vo/CompanyVo.java

@ -1,6 +1,5 @@
package com.ccsens.pims.bean.vo; package com.ccsens.pims.bean.vo;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -82,29 +81,29 @@ public class CompanyVo {
private Long incomeId; private Long incomeId;
@ApiModelProperty("月份") @ApiModelProperty("月份")
private String month; private String month;
@JsonIgnore // @JsonIgnore
private Long predictIncomeLong; // private Long predictIncomeLong;
@ApiModelProperty("预计收入") @ApiModelProperty("预计收入")
private BigDecimal predictIncome; private BigDecimal predictIncome;
@JsonIgnore // @JsonIgnore
private Long realIncomeLong; // private Long realIncomeLong;
@ApiModelProperty("预计收入") @ApiModelProperty("预计收入")
private BigDecimal realIncome; private BigDecimal realIncome;
public BigDecimal getPredictIncome(){ // public BigDecimal getPredictIncome(){
BigDecimal pr = BigDecimal.valueOf(0); // BigDecimal pr = BigDecimal.valueOf(0);
if(ObjectUtil.isNotNull(predictIncomeLong)){ // if(ObjectUtil.isNotNull(predictIncomeLong)){
pr = BigDecimal.valueOf(predictIncomeLong).divide(BigDecimal.valueOf(100),2,BigDecimal.ROUND_HALF_UP); // pr = BigDecimal.valueOf(predictIncomeLong).divide(BigDecimal.valueOf(100),2,BigDecimal.ROUND_HALF_UP);
} // }
return pr; // return pr;
} // }
public BigDecimal getRealIncome(){ // public BigDecimal getRealIncome(){
BigDecimal pr = BigDecimal.valueOf(0); // BigDecimal pr = BigDecimal.valueOf(0);
if(ObjectUtil.isNotNull(realIncomeLong)){ // if(ObjectUtil.isNotNull(realIncomeLong)){
pr = BigDecimal.valueOf(realIncomeLong).divide(BigDecimal.valueOf(100),2,BigDecimal.ROUND_HALF_UP); // pr = BigDecimal.valueOf(realIncomeLong).divide(BigDecimal.valueOf(100),2,BigDecimal.ROUND_HALF_UP);
} // }
return pr; // return pr;
} // }
} }
@Data @Data

6
pims/src/main/java/com/ccsens/pims/service/IRealExcelService.java

@ -14,4 +14,10 @@ public interface IRealExcelService {
* @param async wps文件id * @param async wps文件id
*/ */
void realProduction(CompanyDto.Async async)throws Exception ; void realProduction(CompanyDto.Async async)throws Exception ;
/**
* 读取成本表
* @param async wps文件id
*/
void realCost(CompanyDto.Async async)throws Exception;
} }

25
pims/src/main/java/com/ccsens/pims/service/RealExcelService.java

@ -166,20 +166,24 @@ public class RealExcelService implements IRealExcelService {
long projectId = fileIdAndPath.getBusinessId(); long projectId = fileIdAndPath.getBusinessId();
//文件路径 //文件路径
String path = fileIdAndPath.getFilePath(); String path = fileIdAndPath.getFilePath();
// long projectId = 1289087369240252416L;
// String path = "F:\\home\\cloud\\tall\\uploads\\pims\\2020-08-04\\1596521696305.xlsx";
//获取excel文件 //获取excel文件
InputStream is = new FileInputStream(path); InputStream is = new FileInputStream(path);
XSSFWorkbook wb = new XSSFWorkbook(is); XSSFWorkbook wb = new XSSFWorkbook(is);
if (ObjectUtil.isNull(wb)) {return;} if (ObjectUtil.isNull(wb)) {return;}
XSSFSheet sheet = wb.getSheetAt(0); XSSFSheet sheet = wb.getSheetAt(0);
if (ObjectUtil.isNull(sheet)) { return; } if (ObjectUtil.isNull(sheet)) { return; }
for (int i = 2; i <= sheet.getLastRowNum(); i+=2){ long productTypeId = 0;
for (int i = 2; i <= sheet.getLastRowNum(); i+=3){
XSSFRow row = sheet.getRow(i); XSSFRow row = sheet.getRow(i);
if (ObjectUtil.isNull(row)) { continue; } if (ObjectUtil.isNull(row)) { continue; }
String productTypeCell = ExcelUtil.getCellValue(row.getCell(0)); String productTypeCell = ExcelUtil.getCellValue(row.getCell(0));
String productNameCell = ExcelUtil.getCellValue(row.getCell(1)); String productNameCell = ExcelUtil.getCellValue(row.getCell(1));
//产品类型 //产品类型
Long productTypeId = null;
if(StrUtil.isNotEmpty(productTypeCell)){ if(StrUtil.isNotEmpty(productTypeCell)){
if("收入".equalsIgnoreCase(productTypeCell)){ return; } if("收入".equalsIgnoreCase(productTypeCell)){ return; }
ProductTypeExample productTypeExample = new ProductTypeExample(); ProductTypeExample productTypeExample = new ProductTypeExample();
@ -210,11 +214,18 @@ public class RealExcelService implements IRealExcelService {
} }
int month = 1; int month = 1;
for(int a = 3; a < 15; a++){ for(int a = 3; a < 15; a++){
Long predictIncome = new BigDecimal(ExcelUtil.getCellValue(row.getCell(a))).multiply(BigDecimal.valueOf(100)).longValue(); String predictIncomeCell = ExcelUtil.getCellValue(row.getCell(a));
Long realIncome = null; long predictIncome = 0;
if(StrUtil.isNotEmpty(predictIncomeCell)){
predictIncome = new BigDecimal(predictIncomeCell).multiply(BigDecimal.valueOf(100)).longValue();
}
long realIncome = 0;
XSSFRow realRow = sheet.getRow(i); XSSFRow realRow = sheet.getRow(i);
if(ObjectUtil.isNotNull(realRow)){ if(ObjectUtil.isNotNull(realRow)){
realIncome = new BigDecimal(ExcelUtil.getCellValue(realRow.getCell(a))).multiply(BigDecimal.valueOf(100)).longValue(); String realIncomeCell = ExcelUtil.getCellValue(realRow.getCell(a));
if(StrUtil.isNotEmpty(realIncomeCell)) {
realIncome = new BigDecimal(realIncomeCell).multiply(BigDecimal.valueOf(100)).longValue();
}
} }
//添加产品收入 //添加产品收入
ProductIncome productIncome = new ProductIncome(); ProductIncome productIncome = new ProductIncome();
@ -231,4 +242,8 @@ public class RealExcelService implements IRealExcelService {
} }
} }
@Override
public void realCost(CompanyDto.Async async) throws Exception {
}
} }

50
pims/src/main/java/com/ccsens/pims/service/ReportService.java

@ -300,13 +300,13 @@ public class ReportService implements IReportService {
//循环产品信息 //循环产品信息
for (int i = 0; i < productIncome.getProductIncomeAllList().size(); i++) { for (int i = 0; i < productIncome.getProductIncomeAllList().size(); i++) {
//生成每个产品信息需要的三行 //生成每个产品信息需要的三行
CompanyVo.ProductIncomeAll productIncomeAll = productIncome.getProductIncomeAllList().get(0); CompanyVo.ProductIncomeAll productIncomeAll = productIncome.getProductIncomeAllList().get(i);
List<PoiUtil.PoiUtilCell> product1 = new ArrayList<>(); List<PoiUtil.PoiUtilCell> product1 = new ArrayList<>();
List<PoiUtil.PoiUtilCell> product2 = new ArrayList<>(); List<PoiUtil.PoiUtilCell> product2 = new ArrayList<>();
List<PoiUtil.PoiUtilCell> product3 = new ArrayList<>(); List<PoiUtil.PoiUtilCell> product3 = new ArrayList<>();
if (i == 0) { if (i == 0) {
//每个类型的第一行有内容,其他的为空 //每个类型的第一行有内容,其他的为空
product1.add(new PoiUtil.PoiUtilCell(productIncomeAll.getProductName(), 1, productIncome.getProductIncomeAllList().size() * 3)); product1.add(new PoiUtil.PoiUtilCell(productIncome.getProductTypeName(), 1, productIncome.getProductIncomeAllList().size() * 3));
product2.add(new PoiUtil.PoiUtilCell()); product2.add(new PoiUtil.PoiUtilCell());
product3.add(new PoiUtil.PoiUtilCell()); product3.add(new PoiUtil.PoiUtilCell());
} else { } else {
@ -325,23 +325,51 @@ public class ReportService implements IReportService {
//循环每月的收入 //循环每月的收入
BigDecimal totalProductIncome = BigDecimal.valueOf(0); BigDecimal totalProductIncome = BigDecimal.valueOf(0);
BigDecimal totalRealIncome = BigDecimal.valueOf(0); BigDecimal totalRealIncome = BigDecimal.valueOf(0);
if (CollectionUtil.isNotEmpty(productIncomeAll.getProductIncomeList())) { for (int a = 0; a < 12; a++){
for (CompanyVo.ProductIncome income : productIncomeAll.getProductIncomeList()) { if (a < productIncomeAll.getProductIncomeList().size()) {
CompanyVo.ProductIncome income = productIncomeAll.getProductIncomeList().get(a);
product1.add(new PoiUtil.PoiUtilCell(income.getPredictIncome().toString())); product1.add(new PoiUtil.PoiUtilCell(income.getPredictIncome().toString()));
product2.add(new PoiUtil.PoiUtilCell(income.getRealIncome().toString())); product2.add(new PoiUtil.PoiUtilCell(income.getRealIncome().toString()));
BigDecimal bias = income.getRealIncome().subtract(income.getPredictIncome()).
divide(income.getPredictIncome(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)); if(income.getPredictIncome().multiply(BigDecimal.valueOf(100)).intValue() != 0) {
product3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%")); BigDecimal bias = income.getRealIncome().subtract(income.getPredictIncome()).
divide(income.getPredictIncome(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
product3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
product3.add(new PoiUtil.PoiUtilCell());
}
totalProductIncome = totalProductIncome.add(income.getPredictIncome()); totalProductIncome = totalProductIncome.add(income.getPredictIncome());
totalRealIncome = totalRealIncome.add(income.getRealIncome()); totalRealIncome = totalRealIncome.add(income.getRealIncome());
}else {
product1.add(new PoiUtil.PoiUtilCell());
product2.add(new PoiUtil.PoiUtilCell());
product3.add(new PoiUtil.PoiUtilCell());
} }
} }
// if (CollectionUtil.isNotEmpty(productIncomeAll.getProductIncomeList())) {
// for (CompanyVo.ProductIncome income : productIncomeAll.getProductIncomeList()) {
// product1.add(new PoiUtil.PoiUtilCell(income.getPredictIncome().toString()));
// product2.add(new PoiUtil.PoiUtilCell(income.getRealIncome().toString()));
// BigDecimal bias = income.getRealIncome().subtract(income.getPredictIncome()).
// divide(income.getPredictIncome(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
// product3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
// totalProductIncome = totalProductIncome.add(income.getPredictIncome());
// totalRealIncome = totalRealIncome.add(income.getRealIncome());
// }
// }else {
// product1.add(new PoiUtil.PoiUtilCell());
// product2.add(new PoiUtil.PoiUtilCell());
// product3.add(new PoiUtil.PoiUtilCell());
// }
product1.add(new PoiUtil.PoiUtilCell(totalProductIncome.toString())); product1.add(new PoiUtil.PoiUtilCell(totalProductIncome.toString()));
product2.add(new PoiUtil.PoiUtilCell(totalRealIncome.toString())); product2.add(new PoiUtil.PoiUtilCell(totalRealIncome.toString()));
BigDecimal bias = totalRealIncome.subtract(totalProductIncome). if(totalProductIncome.multiply(BigDecimal.valueOf(100)).intValue() != 0){
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)); BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
product3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%")); divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
product3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
product3.add(new PoiUtil.PoiUtilCell());
}
product1.add(new PoiUtil.PoiUtilCell()); product1.add(new PoiUtil.PoiUtilCell());
product2.add(new PoiUtil.PoiUtilCell()); product2.add(new PoiUtil.PoiUtilCell());
product3.add(new PoiUtil.PoiUtilCell()); product3.add(new PoiUtil.PoiUtilCell());

4
pims/src/main/resources/logback-spring.xml

@ -9,7 +9,7 @@
<contextName>logback</contextName> <contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 --> <!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="log.path" value="/home/cloud/ct/log/" /> <property name="log.path" value="/home/cloud/pims/log/" />
<!-- 彩色日志 --> <!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 --> <!-- 彩色日志依赖的渲染类 -->
@ -171,7 +171,7 @@
<!--开发环境:打印控制台--> <!--开发环境:打印控制台-->
<springProfile name="dev"> <springProfile name="dev">
<logger name="com.ccsens.ptpro.persist.*" level="debug"/> <logger name="com.ccsens.pims.persist.*" level="debug"/>
</springProfile> </springProfile>
<root level="info"> <root level="info">

16
pims/src/main/resources/mapper_dao/ProducrDao.xml

@ -25,8 +25,8 @@
<collection property="productIncomeList" ofType="com.ccsens.pims.bean.vo.CompanyVo$ProductIncome"> <collection property="productIncomeList" ofType="com.ccsens.pims.bean.vo.CompanyVo$ProductIncome">
<id column="incomeId" property="incomeId"/> <id column="incomeId" property="incomeId"/>
<result column="month" property="month"/> <result column="month" property="month"/>
<result column="predictIncome" property="predictIncomeLong"/> <result column="predictIncome" property="predictIncome"/>
<result column="realIncome" property="realIncomeLong"/> <result column="realIncome" property="realIncome"/>
</collection> </collection>
</collection> </collection>
</resultMap> </resultMap>
@ -274,8 +274,8 @@
<select id="getProductIncome" parameterType="java.util.Map" resultType="com.ccsens.pims.bean.vo.CompanyVo$ProductIncome"> <select id="getProductIncome" parameterType="java.util.Map" resultType="com.ccsens.pims.bean.vo.CompanyVo$ProductIncome">
select select
month_time as `month`, month_time as `month`,
predict_income as predictIncomeLong, predict_income/100 as predictIncome,
real_income as realIncomeLong real_income/100 as realIncome
from from
t_product_income t_product_income
where where
@ -290,14 +290,14 @@
p.`name` as productName, p.`name` as productName,
pi.id as incomeId, pi.id as incomeId,
pi.month_time as `month`, pi.month_time as `month`,
pi.predict_income as predictIncome, pi.predict_income/100 as predictIncome,
pi.real_income as realIncome pi.real_income/100 as realIncome
from from
t_product_type pt LEFT JOIN t_product p on pt.id = p.product_type_id Left join t_product_income pi on p.id = pi.product_id t_product_type pt LEFT JOIN t_product p on pt.id = p.product_type_id Left join t_product_income pi on p.id = pi.product_id
where where
pt.rec_status = 0 pt.rec_status = 0
and and
pi.rec_status = 0 (pi.rec_status = 0 or pi.rec_status is null)
AND AND
p.rec_status = 0 p.rec_status = 0
and and
@ -384,7 +384,7 @@
FROM FROM
t_product p LEFT JOIN t_product_income i on i.product_id = p.id t_product p LEFT JOIN t_product_income i on i.product_id = p.id
WHERE WHERE
i.rec_status = 0 (i.rec_status = 0 or i.rec_status is null)
AND AND
p.rec_status = 0 p.rec_status = 0
AND AND

6
tall/src/main/resources/application-prod.yml

@ -11,13 +11,13 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
rabbitmq: rabbitmq:
host: api.ccsens.com host: 127.0.0.1
password: 111111 password: 111111
port: 5672 port: 5672
username: admin username: admin
redis: redis:
database: 0 database: 0
host: www.tall.wiki host: 127.0.0.1
jedis: jedis:
pool: pool:
max-active: 200 max-active: 200
@ -33,7 +33,7 @@ eureka:
instance: instance:
# www.tall.wiki # www.tall.wiki
# ip-address: 140.143.228.3 # ip-address: 140.143.228.3
ip-address: 192.144.182.42 ip-address: 81.70.54.64
gatewayUrl: https://www.tall.wiki/gateway/ gatewayUrl: https://www.tall.wiki/gateway/
notGatewayUrl: https://www.tall.wiki/ notGatewayUrl: https://www.tall.wiki/

4
tall/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring: spring:
profiles: profiles:
active: test active: prod
include: util-test,common include: util-prod,common

8
util/src/test/java/com/ccsens/util/Base64Test.java

@ -1,11 +1,6 @@
package com.ccsens.util; package com.ccsens.util;
import cn.hutool.core.codec.Base64; import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Test; import org.junit.Test;
@ -39,7 +34,10 @@ public class Base64Test {
@Test @Test
public void test02() throws Exception { public void test02() throws Exception {
BigDecimal a = new BigDecimal(0.00);
BigDecimal b = new BigDecimal(0);
System.out.println(a.equals(b));
} }

Loading…
Cancel
Save