Browse Source

pime读取excel信息

master
zy_Java 5 years ago
parent
commit
4feafe574f
  1. 16
      pims/src/main/java/com/ccsens/pims/api/ReadController.java
  2. 8
      pims/src/main/java/com/ccsens/pims/persist/dao/CostLogDao.java
  3. 8
      pims/src/main/java/com/ccsens/pims/persist/dao/CostTypeDao.java
  4. 8
      pims/src/main/java/com/ccsens/pims/persist/dao/IncomeStatementsDao.java
  5. 8
      pims/src/main/java/com/ccsens/pims/persist/dao/IncomeStatementsLogDao.java
  6. 8
      pims/src/main/java/com/ccsens/pims/persist/dao/MoneyFlowDao.java
  7. 8
      pims/src/main/java/com/ccsens/pims/persist/dao/MoneyFlowLogDao.java
  8. 13
      pims/src/main/java/com/ccsens/pims/service/IRealExcelService.java
  9. 264
      pims/src/main/java/com/ccsens/pims/service/RealExcelService.java
  10. 276
      pims/src/main/java/com/ccsens/pims/service/ReportService.java
  11. 4
      pims/src/main/resources/application.yml
  12. 8
      pims/src/main/resources/mapper_dao/ProducrDao.xml
  13. 10
      tall/src/main/java/com/ccsens/tall/bean/vo/PluginVo.java
  14. 8
      tall/src/main/java/com/ccsens/tall/persist/dao/ProProjectFileDao.java
  15. 3
      tall/src/main/java/com/ccsens/tall/service/ITaskPluginService.java
  16. 55
      tall/src/main/java/com/ccsens/tall/service/TaskPluginService.java
  17. 8
      tall/src/main/java/com/ccsens/tall/web/PluginController.java
  18. 4
      tall/src/main/resources/application.yml
  19. 7
      util/src/main/java/com/ccsens/util/PoiUtil.java
  20. 7
      util/src/test/java/com/ccsens/util/Base64Test.java

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

@ -51,4 +51,20 @@ public class ReadController {
return JsonResponse.newInstance().ok();
}
@ApiOperation(value = "读取损益表表", notes = "")
@RequestMapping(value = "/income", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse realIncome(@Validated @RequestBody CompanyDto.Async async) throws Exception {
log.info("读取损益表表:{}",async.toString());
realExcelService.realIncome(async);
return JsonResponse.newInstance().ok();
}
@ApiOperation(value = "读取现金流表", notes = "")
@RequestMapping(value = "/money", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse realMoney(@Validated @RequestBody CompanyDto.Async async) throws Exception {
log.info("读取现金流表:{}",async.toString());
realExcelService.realMoney(async);
return JsonResponse.newInstance().ok();
}
}

8
pims/src/main/java/com/ccsens/pims/persist/dao/CostLogDao.java

@ -0,0 +1,8 @@
package com.ccsens.pims.persist.dao;
import com.ccsens.pims.persist.mapper.CostLogMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface CostLogDao extends CostLogMapper {
}

8
pims/src/main/java/com/ccsens/pims/persist/dao/CostTypeDao.java

@ -0,0 +1,8 @@
package com.ccsens.pims.persist.dao;
import com.ccsens.pims.persist.mapper.CostTypeMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface CostTypeDao extends CostTypeMapper {
}

8
pims/src/main/java/com/ccsens/pims/persist/dao/IncomeStatementsDao.java

@ -0,0 +1,8 @@
package com.ccsens.pims.persist.dao;
import com.ccsens.pims.persist.mapper.IncomeStatementsMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface IncomeStatementsDao extends IncomeStatementsMapper {
}

8
pims/src/main/java/com/ccsens/pims/persist/dao/IncomeStatementsLogDao.java

@ -0,0 +1,8 @@
package com.ccsens.pims.persist.dao;
import com.ccsens.pims.persist.mapper.IncomeStatementsLogMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface IncomeStatementsLogDao extends IncomeStatementsLogMapper {
}

8
pims/src/main/java/com/ccsens/pims/persist/dao/MoneyFlowDao.java

@ -0,0 +1,8 @@
package com.ccsens.pims.persist.dao;
import com.ccsens.pims.persist.mapper.MoneyFlowMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface MoneyFlowDao extends MoneyFlowMapper {
}

8
pims/src/main/java/com/ccsens/pims/persist/dao/MoneyFlowLogDao.java

@ -0,0 +1,8 @@
package com.ccsens.pims.persist.dao;
import com.ccsens.pims.persist.mapper.MoneyFlowLogMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface MoneyFlowLogDao extends MoneyFlowLogMapper {
}

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

@ -20,4 +20,17 @@ public interface IRealExcelService {
* @param async wps文件id
*/
void realCost(CompanyDto.Async async)throws Exception;
/**
* 读取损益表
* @param async wps文件id
* @throws Exception
*/
void realIncome(CompanyDto.Async async)throws Exception;
/**
* 读取现金流表
* @param async wps文件id
*/
void realMoney(CompanyDto.Async async)throws Exception;
}

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

@ -8,9 +8,7 @@ import com.ccsens.cloudutil.bean.tall.vo.WpsVo;
import com.ccsens.cloudutil.feign.TallFeignClient;
import com.ccsens.pims.bean.dto.CompanyDto;
import com.ccsens.pims.bean.po.*;
import com.ccsens.pims.persist.dao.ProductDao;
import com.ccsens.pims.persist.dao.ProductIncomeDao;
import com.ccsens.pims.persist.dao.ProductTypeDao;
import com.ccsens.pims.persist.dao.*;
import com.ccsens.util.ExcelUtil;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.exception.BaseException;
@ -45,6 +43,18 @@ public class RealExcelService implements IRealExcelService {
private ProductDao productDao;
@Resource
private ProductIncomeDao productIncomeDao;
@Resource
private CostTypeDao costTypeDao;
@Resource
private CostLogDao costLogDao;
@Resource
private IncomeStatementsDao statementsDao;
@Resource
private IncomeStatementsLogDao statementsLogDao;
@Resource
private MoneyFlowDao moneyFlowDao;
@Resource
private MoneyFlowLogDao moneyFlowLogDao;
@Override
public void realProduct(CompanyDto.Async params) throws Exception {
@ -243,7 +253,253 @@ public class RealExcelService implements IRealExcelService {
}
@Override
public void realCost(CompanyDto.Async async) throws Exception {
public void realCost(CompanyDto.Async params) throws Exception {
// log.info("wps文件id:{}", params.toString());
// Long wpsId = params.getFileId();
// JsonResponse<WpsVo.BusinessFileIdAndPath> businessFileIdAndPath = tallFeignClient.getPathByWpsId(wpsId);
// log.info("获取文件路径和项目id:{}", businessFileIdAndPath.toString());
// if (ObjectUtil.isNull(businessFileIdAndPath)) {return;}
// WpsVo.BusinessFileIdAndPath fileIdAndPath = businessFileIdAndPath.getData();
// if (ObjectUtil.isNull(fileIdAndPath)) {return;}
// //项目id
// long projectId = fileIdAndPath.getBusinessId();
// //文件路径
// String path = fileIdAndPath.getFilePath();
long projectId = 1289087369240252416L;
String path = "C:\\Users\\逗\\Desktop\\产品成本费用估算表.xlsx";
//获取excel文件
InputStream is = new FileInputStream(path);
XSSFWorkbook wb = new XSSFWorkbook(is);
if (ObjectUtil.isNull(wb)) {return;}
log.info("读取到excel文件");
XSSFSheet sheet = wb.getSheetAt(0);
if (ObjectUtil.isNull(sheet)) { return; }
//产品或成本类型的id
long costTypeId = 0;
//产品成本还是,其他成本 1产品成本 0其他成本
int otherType = 0;
for (int i = 2; i <= sheet.getLastRowNum(); i+=3){
XSSFRow row = sheet.getRow(i);
if (ObjectUtil.isNull(row)) { continue; }
String costTypeCell = ExcelUtil.getCellValue(row.getCell(0));
if(StrUtil.isNotEmpty(costTypeCell)){
//根据名字查找产品
ProductExample productExample = new ProductExample();
productExample.createCriteria().andNameEqualTo(costTypeCell).andProjectIdEqualTo(projectId);
List<Product> productList = productDao.selectByExample(productExample);
if(CollectionUtil.isNotEmpty(productList)){
Product product = productList.get(0);
costTypeId = product.getId();
otherType = 1;
//查找所有这个产品的成本,删除
CostLogExample costLogExample = new CostLogExample();
costLogExample.createCriteria().andCostTypeIdEqualTo(costTypeId).andProductCostEqualTo((byte) otherType);
List<CostLog> costLogList = costLogDao.selectByExample(costLogExample);
if(CollectionUtil.isNotEmpty(costLogList)){
costLogList.forEach(costLog -> {
costLog.setRecStatus((byte) 2);
costLogDao.updateByPrimaryKeySelective(costLog);
});
}
}else {
//没有产品则去查询成本类型
CostTypeExample costTypeExample = new CostTypeExample();
costTypeExample.createCriteria().andNameEqualTo(costTypeCell).andProjectIdEqualTo(projectId);
List<CostType> costTypeList = costTypeDao.selectByExample(costTypeExample);
if(CollectionUtil.isEmpty(costTypeList)){
continue;
}
CostType costType = costTypeList.get(0);
costTypeId = costType.getId();
//查找所有这个类型的成本,删除
CostLogExample costLogExample = new CostLogExample();
costLogExample.createCriteria().andCostTypeIdEqualTo(costTypeId).andProductCostEqualTo((byte) otherType);
List<CostLog> costLogList = costLogDao.selectByExample(costLogExample);
if(CollectionUtil.isNotEmpty(costLogList)){
costLogList.forEach(costLog -> {
costLog.setRecStatus((byte) 2);
costLogDao.updateByPrimaryKeySelective(costLog);
});
}
}
int month = 1;
for(int a = 2; a < 14; a++){
String predictcostCell = ExcelUtil.getCellValue(row.getCell(a));
long predictCost = 0;
if(StrUtil.isNotEmpty(predictcostCell)){
predictCost = new BigDecimal(predictcostCell).multiply(BigDecimal.valueOf(100)).longValue();
}
long realCost = 0;
XSSFRow realRow = sheet.getRow(i);
if(ObjectUtil.isNotNull(realRow)){
String realCostCell = ExcelUtil.getCellValue(realRow.getCell(a));
if(StrUtil.isNotEmpty(realCostCell)) {
realCost = new BigDecimal(realCostCell).multiply(BigDecimal.valueOf(100)).longValue();
}
}
//添加成本
CostLog costLog = new CostLog();
costLog.setId(snowflake.nextId());
costLog.setCostTypeId(costTypeId);
costLog.setProductCost((byte) otherType);
costLog.setMonthTime(month);
costLog.setPredictCost(predictCost);
costLog.setRealCost(realCost);
costLogDao.insertSelective(costLog);
month++;
}
}
}
}
@Override
public void realIncome(CompanyDto.Async params) throws Exception {
log.info("wps文件id:{}", params.toString());
Long wpsId = params.getFileId();
JsonResponse<WpsVo.BusinessFileIdAndPath> businessFileIdAndPath = tallFeignClient.getPathByWpsId(wpsId);
log.info("获取文件路径和项目id:{}", businessFileIdAndPath.toString());
if (ObjectUtil.isNull(businessFileIdAndPath)) {return;}
WpsVo.BusinessFileIdAndPath fileIdAndPath = businessFileIdAndPath.getData();
if (ObjectUtil.isNull(fileIdAndPath)) {return;}
//项目id
long projectId = fileIdAndPath.getBusinessId();
//文件路径
String path = fileIdAndPath.getFilePath();
//获取excel文件
InputStream is = new FileInputStream(path);
XSSFWorkbook wb = new XSSFWorkbook(is);
if (ObjectUtil.isNull(wb)) {return;}
XSSFSheet sheet = wb.getSheetAt(0);
if (ObjectUtil.isNull(sheet)) { return; }
//产品或成本类型的id
long incomeId = 0;
for (int i = 2; i <= sheet.getLastRowNum(); i+=3){
XSSFRow row = sheet.getRow(i);
if (ObjectUtil.isNull(row)) { continue; }
String incomeTypeCell = ExcelUtil.getCellValue(row.getCell(0));
if(StrUtil.isNotEmpty(incomeTypeCell)){
//根据名字查找收入类型
IncomeStatementsExample statementsExample = new IncomeStatementsExample();
statementsExample.createCriteria().andNameEqualTo(incomeTypeCell).andProjectIdEqualTo(projectId);
List<IncomeStatements> incomeStatements = statementsDao.selectByExample(statementsExample);
if(CollectionUtil.isEmpty(incomeStatements)){
continue;
}
incomeId = incomeStatements.get(0).getId();
//删除此类型以前所有的收入信息
IncomeStatementsLogExample statementsLogExample = new IncomeStatementsLogExample();
statementsLogExample.createCriteria().andIncomeStatementsIdEqualTo(incomeId);
List<IncomeStatementsLog> statementsLogList = statementsLogDao.selectByExample(statementsLogExample);
if(CollectionUtil.isNotEmpty(statementsLogList)){
statementsLogList.forEach(statementsLog ->{
statementsLog.setRecStatus((byte) 2);
statementsLogDao.updateByPrimaryKeySelective(statementsLog);
});
}
//循环添加新的收入记录
int month = 1;
for(int a = 2; a < 14; a++){
String statementsLogCell = ExcelUtil.getCellValue(row.getCell(a));
long predictIncome = 0;
if(StrUtil.isNotEmpty(statementsLogCell)){
predictIncome = new BigDecimal(statementsLogCell).multiply(BigDecimal.valueOf(100)).longValue();
}
long realIncome = 0;
XSSFRow realRow = sheet.getRow(i);
if(ObjectUtil.isNotNull(realRow)){
String realIncomeCell = ExcelUtil.getCellValue(realRow.getCell(a));
if(StrUtil.isNotEmpty(realIncomeCell)) {
realIncome = new BigDecimal(realIncomeCell).multiply(BigDecimal.valueOf(100)).longValue();
}
}
//添加成本
IncomeStatementsLog statementsLog = new IncomeStatementsLog();
statementsLog.setId(snowflake.nextId());
statementsLog.setProjectId(projectId);
statementsLog.setIncomeStatementsId(incomeId);
statementsLog.setMonthTime(month);
statementsLog.setPredictMoney(predictIncome);
statementsLog.setRealMoney(realIncome);
statementsLogDao.insertSelective(statementsLog);
month++;
}
}
}
}
@Override
public void realMoney(CompanyDto.Async params) throws Exception {
log.info("wps文件id:{}", params.toString());
Long wpsId = params.getFileId();
JsonResponse<WpsVo.BusinessFileIdAndPath> businessFileIdAndPath = tallFeignClient.getPathByWpsId(wpsId);
log.info("获取文件路径和项目id:{}", businessFileIdAndPath.toString());
if (ObjectUtil.isNull(businessFileIdAndPath)) {return;}
WpsVo.BusinessFileIdAndPath fileIdAndPath = businessFileIdAndPath.getData();
if (ObjectUtil.isNull(fileIdAndPath)) {return;}
//项目id
long projectId = fileIdAndPath.getBusinessId();
//文件路径
String path = fileIdAndPath.getFilePath();
//获取excel文件
InputStream is = new FileInputStream(path);
XSSFWorkbook wb = new XSSFWorkbook(is);
if (ObjectUtil.isNull(wb)) {return;}
XSSFSheet sheet = wb.getSheetAt(0);
if (ObjectUtil.isNull(sheet)) { return; }
//现金流动类型的id
long moneyTypeId = 0;
for (int i = 2; i <= sheet.getLastRowNum(); i+=3){
XSSFRow row = sheet.getRow(i);
if (ObjectUtil.isNull(row)) { continue; }
String moneyTypeCell = ExcelUtil.getCellValue(row.getCell(0));
if(StrUtil.isNotEmpty(moneyTypeCell)){
//根据名字查看现金流类型
MoneyFlowExample moneyFlowExample = new MoneyFlowExample();
moneyFlowExample.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo(moneyTypeCell);
List<MoneyFlow> moneyFlowList = moneyFlowDao.selectByExample(moneyFlowExample);
if(CollectionUtil.isEmpty(moneyFlowList)){
continue;
}
moneyTypeId = moneyFlowList.get(0).getId();
//删除之前的现金流信息
MoneyFlowLogExample flowLogExample = new MoneyFlowLogExample();
flowLogExample.createCriteria().andMoneyFlowIdEqualTo(moneyTypeId).andProjectIdEqualTo(projectId);
List<MoneyFlowLog> moneyFlowLogList = moneyFlowLogDao.selectByExample(flowLogExample);
if(CollectionUtil.isNotEmpty(moneyFlowLogList)){
moneyFlowLogList.forEach(moneyFlowLog -> {
moneyFlowLog.setRecStatus((byte) 2);
moneyFlowLogDao.updateByPrimaryKeySelective(moneyFlowLog);
});
}
//添加新的现金流信息
int month = 1;
for(int a = 3; a < 15; a++){
String moeyLogCell = ExcelUtil.getCellValue(row.getCell(a));
long predictMoney = 0;
if(StrUtil.isNotEmpty(moeyLogCell)){
predictMoney = new BigDecimal(moeyLogCell).multiply(BigDecimal.valueOf(100)).longValue();
}
long realMoney = 0;
XSSFRow realRow = sheet.getRow(i);
if(ObjectUtil.isNotNull(realRow)){
String realMoneyCell = ExcelUtil.getCellValue(realRow.getCell(a));
if(StrUtil.isNotEmpty(realMoneyCell)) {
realMoney = new BigDecimal(realMoneyCell).multiply(BigDecimal.valueOf(100)).longValue();
}
}
//添加成本
MoneyFlowLog moneyFlowLog = new MoneyFlowLog();
moneyFlowLog.setId(snowflake.nextId());
moneyFlowLog.setProjectId(projectId);
moneyFlowLog.setMoneyFlowId(moneyTypeId);
moneyFlowLog.setMonthTime(month);
moneyFlowLog.setPredictMoney(predictMoney);
moneyFlowLog.setRealMoney(realMoney);
moneyFlowLogDao.insertSelective(moneyFlowLog);
month++;
}
}
}
}
}

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

@ -103,11 +103,13 @@ public class ReportService implements IReportService {
CompanyDto.Project project = params.getParam();
//查询此任务的报表,有则直接返回
List<String> wpsPath;
Map<String,String> paramsUrl = new HashMap<>();
paramsUrl.put(WebConstant.Wps._W_URL, PropUtil.domain + "read/cost");
WpsDto.VisitWpsUrl visitWpsUrl = new WpsDto.VisitWpsUrl();
visitWpsUrl.setBusinessId(project.getProjectId());
visitWpsUrl.setBusinessType((byte) 5);
visitWpsUrl.setUserId(params.getUserId());
visitWpsUrl.setParams(null);
visitWpsUrl.setParams(paramsUrl);
wpsPath = tallFeignClient.queryVisitUrls(visitWpsUrl);
if (CollectionUtil.isNotEmpty(wpsPath)) {
return wpsPath;
@ -132,11 +134,13 @@ public class ReportService implements IReportService {
CompanyDto.Project project = params.getParam();
//查询此任务的报表,有则直接返回
List<String> wpsPath;
Map<String,String> paramsUrl = new HashMap<>();
paramsUrl.put(WebConstant.Wps._W_URL, PropUtil.domain + "read/income");
WpsDto.VisitWpsUrl visitWpsUrl = new WpsDto.VisitWpsUrl();
visitWpsUrl.setBusinessId(project.getProjectId());
visitWpsUrl.setBusinessType((byte)6);
visitWpsUrl.setUserId(params.getUserId());
visitWpsUrl.setParams(null);
visitWpsUrl.setParams(paramsUrl);
wpsPath = tallFeignClient.queryVisitUrls(visitWpsUrl);
if (CollectionUtil.isNotEmpty(wpsPath)) {
return wpsPath;
@ -158,11 +162,13 @@ public class ReportService implements IReportService {
CompanyDto.Project project = params.getParam();
//查询此任务的报表,有则直接返回
List<String> wpsPath;
Map<String,String> paramsUrl = new HashMap<>();
paramsUrl.put(WebConstant.Wps._W_URL, PropUtil.domain + "read/money");
WpsDto.VisitWpsUrl visitWpsUrl = new WpsDto.VisitWpsUrl();
visitWpsUrl.setBusinessId(project.getProjectId());
visitWpsUrl.setBusinessType((byte) 7);
visitWpsUrl.setUserId(params.getUserId());
visitWpsUrl.setParams(null);
visitWpsUrl.setParams(paramsUrl);
wpsPath = tallFeignClient.queryVisitUrls(visitWpsUrl);
if (CollectionUtil.isNotEmpty(wpsPath)) {
return wpsPath;
@ -429,23 +435,47 @@ public class ReportService implements IReportService {
//循环每月的收入
BigDecimal totalProductIncome = BigDecimal.valueOf(0);
BigDecimal totalRealIncome = BigDecimal.valueOf(0);
if (CollectionUtil.isNotEmpty(moneyFlowType.getMoneyFlowList())) {
for (CompanyVo.MoneyFlow moneyFlow : moneyFlowType.getMoneyFlowList()) {
for (int a = 0; a < 12; a++){
if (a < moneyFlowType.getMoneyFlowList().size()) {
CompanyVo.MoneyFlow moneyFlow = moneyFlowType.getMoneyFlowList().get(a);
income1.add(new PoiUtil.PoiUtilCell(moneyFlow.getPredictMoneyFlow().toString()));
income2.add(new PoiUtil.PoiUtilCell(moneyFlow.getRealMoneyFlow().toString()));
BigDecimal bias = moneyFlow.getRealMoneyFlow().subtract(moneyFlow.getPredictMoneyFlow()).
divide(moneyFlow.getRealMoneyFlow(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
if(moneyFlow.getPredictMoneyFlow().multiply(BigDecimal.valueOf(100)).intValue() != 0) {
BigDecimal bias = moneyFlow.getRealMoneyFlow().subtract(moneyFlow.getPredictMoneyFlow()).
divide(moneyFlow.getPredictMoneyFlow(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
income3.add(new PoiUtil.PoiUtilCell());
}
totalProductIncome = totalProductIncome.add(moneyFlow.getPredictMoneyFlow());
totalRealIncome = totalRealIncome.add(moneyFlow.getRealMoneyFlow());
}else {
income1.add(new PoiUtil.PoiUtilCell());
income2.add(new PoiUtil.PoiUtilCell());
income3.add(new PoiUtil.PoiUtilCell());
}
}
// if (CollectionUtil.isNotEmpty(moneyFlowType.getMoneyFlowList())) {
// for (CompanyVo.MoneyFlow moneyFlow : moneyFlowType.getMoneyFlowList()) {
// income1.add(new PoiUtil.PoiUtilCell(moneyFlow.getPredictMoneyFlow().toString()));
// income2.add(new PoiUtil.PoiUtilCell(moneyFlow.getRealMoneyFlow().toString()));
// BigDecimal bias = moneyFlow.getRealMoneyFlow().subtract(moneyFlow.getPredictMoneyFlow()).
// divide(moneyFlow.getRealMoneyFlow(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
// income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
// totalProductIncome = totalProductIncome.add(moneyFlow.getPredictMoneyFlow());
// totalRealIncome = totalRealIncome.add(moneyFlow.getRealMoneyFlow());
// }
// }
income1.add(new PoiUtil.PoiUtilCell(totalProductIncome.toString()));
income2.add(new PoiUtil.PoiUtilCell(totalRealIncome.toString()));
BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
if(totalProductIncome.multiply(BigDecimal.valueOf(100)).intValue() != 0) {
BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
income3.add(new PoiUtil.PoiUtilCell());
}
list.add(income1);
list.add(income2);
list.add(income3);
@ -486,23 +516,47 @@ public class ReportService implements IReportService {
//循环每月的收入
BigDecimal totalProductIncome = BigDecimal.valueOf(0);
BigDecimal totalRealIncome = BigDecimal.valueOf(0);
if (CollectionUtil.isNotEmpty(moneyFlowType.getMoneyFlowList())) {
for (CompanyVo.MoneyFlow moneyFlow : moneyFlowType.getMoneyFlowList()) {
for (int a = 0; a < 12; a++){
if (a < moneyFlowType.getMoneyFlowList().size()) {
CompanyVo.MoneyFlow moneyFlow = moneyFlowType.getMoneyFlowList().get(a);
income1.add(new PoiUtil.PoiUtilCell(moneyFlow.getPredictMoneyFlow().toString()));
income2.add(new PoiUtil.PoiUtilCell(moneyFlow.getRealMoneyFlow().toString()));
BigDecimal bias = moneyFlow.getRealMoneyFlow().subtract(moneyFlow.getPredictMoneyFlow()).
divide(moneyFlow.getRealMoneyFlow(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
if(moneyFlow.getPredictMoneyFlow().multiply(BigDecimal.valueOf(100)).intValue() != 0) {
BigDecimal bias = moneyFlow.getRealMoneyFlow().subtract(moneyFlow.getPredictMoneyFlow()).
divide(moneyFlow.getPredictMoneyFlow(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
income3.add(new PoiUtil.PoiUtilCell());
}
totalProductIncome = totalProductIncome.add(moneyFlow.getPredictMoneyFlow());
totalRealIncome = totalRealIncome.add(moneyFlow.getRealMoneyFlow());
}else {
income1.add(new PoiUtil.PoiUtilCell());
income2.add(new PoiUtil.PoiUtilCell());
income3.add(new PoiUtil.PoiUtilCell());
}
}
// if (CollectionUtil.isNotEmpty(moneyFlowType.getMoneyFlowList())) {
// for (CompanyVo.MoneyFlow moneyFlow : moneyFlowType.getMoneyFlowList()) {
// income1.add(new PoiUtil.PoiUtilCell(moneyFlow.getPredictMoneyFlow().toString()));
// income2.add(new PoiUtil.PoiUtilCell(moneyFlow.getRealMoneyFlow().toString()));
// BigDecimal bias = moneyFlow.getRealMoneyFlow().subtract(moneyFlow.getPredictMoneyFlow()).
// divide(moneyFlow.getRealMoneyFlow(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
// income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
// totalProductIncome = totalProductIncome.add(moneyFlow.getPredictMoneyFlow());
// totalRealIncome = totalRealIncome.add(moneyFlow.getRealMoneyFlow());
// }
// }
income1.add(new PoiUtil.PoiUtilCell(totalProductIncome.toString()));
income2.add(new PoiUtil.PoiUtilCell(totalRealIncome.toString()));
BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
if(totalProductIncome.multiply(BigDecimal.valueOf(100)).intValue() != 0) {
BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
income3.add(new PoiUtil.PoiUtilCell());
}
list.add(income1);
list.add(income2);
list.add(income3);
@ -541,6 +595,7 @@ public class ReportService implements IReportService {
//表头
List<PoiUtil.PoiUtilCell> header = new ArrayList<>();
header.add(new PoiUtil.PoiUtilCell("", 2, 1));
header.add(new PoiUtil.PoiUtilCell());
for (int i = 1; i < 13; i++) {
header.add(new PoiUtil.PoiUtilCell(i + "月"));
}
@ -562,26 +617,50 @@ public class ReportService implements IReportService {
income2.add(new PoiUtil.PoiUtilCell("实际收入"));
income3.add(new PoiUtil.PoiUtilCell("偏差率"));
//循环每月的收入
//循环每月的损益
BigDecimal totalProductIncome = BigDecimal.valueOf(0);
BigDecimal totalRealIncome = BigDecimal.valueOf(0);
if (CollectionUtil.isNotEmpty(incomeType.getIncomeMonthList())) {
for (CompanyVo.IncomeMonth incomeMonth : incomeType.getIncomeMonthList()) {
for (int a = 0; a < 12; a++){
if (a < incomeType.getIncomeMonthList().size()) {
CompanyVo.IncomeMonth incomeMonth = incomeType.getIncomeMonthList().get(a);
income1.add(new PoiUtil.PoiUtilCell(incomeMonth.getPredictIncome().toString()));
income2.add(new PoiUtil.PoiUtilCell(incomeMonth.getRealIncome().toString()));
BigDecimal bias = incomeMonth.getRealIncome().subtract(incomeMonth.getPredictIncome()).
divide(incomeMonth.getRealIncome(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
if(incomeMonth.getPredictIncome().multiply(BigDecimal.valueOf(100)).intValue() != 0) {
BigDecimal bias = incomeMonth.getRealIncome().subtract(incomeMonth.getPredictIncome()).
divide(incomeMonth.getPredictIncome(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
income3.add(new PoiUtil.PoiUtilCell());
}
totalProductIncome = totalProductIncome.add(incomeMonth.getPredictIncome());
totalRealIncome = totalRealIncome.add(incomeMonth.getRealIncome());
}else {
income1.add(new PoiUtil.PoiUtilCell());
income2.add(new PoiUtil.PoiUtilCell());
income3.add(new PoiUtil.PoiUtilCell());
}
}
// if (CollectionUtil.isNotEmpty(incomeType.getIncomeMonthList())) {
// for (CompanyVo.IncomeMonth incomeMonth : incomeType.getIncomeMonthList()) {
// income1.add(new PoiUtil.PoiUtilCell(incomeMonth.getPredictIncome().toString()));
// income2.add(new PoiUtil.PoiUtilCell(incomeMonth.getRealIncome().toString()));
// BigDecimal bias = incomeMonth.getRealIncome().subtract(incomeMonth.getPredictIncome()).
// divide(incomeMonth.getRealIncome(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
// income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
// totalProductIncome = totalProductIncome.add(incomeMonth.getPredictIncome());
// totalRealIncome = totalRealIncome.add(incomeMonth.getRealIncome());
// }
// }
income1.add(new PoiUtil.PoiUtilCell(totalProductIncome.toString()));
income2.add(new PoiUtil.PoiUtilCell(totalRealIncome.toString()));
BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
if(totalProductIncome.multiply(BigDecimal.valueOf(100)).intValue() != 0){
BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
income3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
income3.add(new PoiUtil.PoiUtilCell());
}
list.add(income1);
list.add(income2);
list.add(income3);
@ -614,9 +693,18 @@ public class ReportService implements IReportService {
header.add(new PoiUtil.PoiUtilCell("合计"));
list.add(header);
//TODO 产品成本
List<PoiUtil.PoiUtilCell> productTotalCost = new ArrayList<>();
productTotalCost.add(new PoiUtil.PoiUtilCell("产品成本"));
list.add(productTotalCost);
List<PoiUtil.PoiUtilCell> productTotalCost1 = new ArrayList<>();
List<PoiUtil.PoiUtilCell> productTotalCost2 = new ArrayList<>();
List<PoiUtil.PoiUtilCell> productTotalCost3 = new ArrayList<>();
productTotalCost1.add(new PoiUtil.PoiUtilCell("产品成本",1,3));
productTotalCost2.add(new PoiUtil.PoiUtilCell());
productTotalCost3.add(new PoiUtil.PoiUtilCell());
productTotalCost1.add(new PoiUtil.PoiUtilCell("预计成本"));
productTotalCost2.add(new PoiUtil.PoiUtilCell("实际成本"));
productTotalCost3.add(new PoiUtil.PoiUtilCell("偏差率"));
list.add(productTotalCost1);
list.add(productTotalCost2);
list.add(productTotalCost3);
if(CollectionUtil.isNotEmpty(costProductTypeList)){
for(CompanyVo.FirstCostType firstCostType : costProductTypeList) {
@ -630,36 +718,68 @@ public class ReportService implements IReportService {
cost2.add(new PoiUtil.PoiUtilCell());
cost3.add(new PoiUtil.PoiUtilCell());
cost1.add(new PoiUtil.PoiUtilCell("预计收入"));
cost2.add(new PoiUtil.PoiUtilCell("实际收入"));
cost1.add(new PoiUtil.PoiUtilCell("预计成本"));
cost2.add(new PoiUtil.PoiUtilCell("实际成本"));
cost3.add(new PoiUtil.PoiUtilCell("偏差率"));
BigDecimal totalProductIncome = BigDecimal.valueOf(0);
BigDecimal totalRealIncome = BigDecimal.valueOf(0);
if (CollectionUtil.isNotEmpty(costType.getCostMonthList())) {
for (CompanyVo.CostMonth costMonth : costType.getCostMonthList()) {
for (int a = 0; a < 12; a++){
if (a < costType.getCostMonthList().size()) {
CompanyVo.CostMonth costMonth = costType.getCostMonthList().get(a);
cost1.add(new PoiUtil.PoiUtilCell(costMonth.getPredictCost().toString()));
cost2.add(new PoiUtil.PoiUtilCell(costMonth.getRealCost().toString()));
BigDecimal bias = costMonth.getRealCost().subtract(costMonth.getPredictCost()).
divide(costMonth.getRealCost(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
cost3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
if(costMonth.getPredictCost().multiply(BigDecimal.valueOf(100)).intValue() != 0) {
BigDecimal bias = costMonth.getRealCost().subtract(costMonth.getPredictCost()).
divide(costMonth.getPredictCost(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
cost3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
cost3.add(new PoiUtil.PoiUtilCell());
}
totalProductIncome = totalProductIncome.add(costMonth.getPredictCost());
totalRealIncome = totalRealIncome.add(costMonth.getRealCost());
}else {
cost1.add(new PoiUtil.PoiUtilCell());
cost2.add(new PoiUtil.PoiUtilCell());
cost3.add(new PoiUtil.PoiUtilCell());
}
}
// if (CollectionUtil.isNotEmpty(costType.getCostMonthList())) {
// for (CompanyVo.CostMonth costMonth : costType.getCostMonthList()) {
// cost1.add(new PoiUtil.PoiUtilCell(costMonth.getPredictCost().toString()));
// cost2.add(new PoiUtil.PoiUtilCell(costMonth.getRealCost().toString()));
// BigDecimal bias = costMonth.getRealCost().subtract(costMonth.getPredictCost()).
// divide(costMonth.getRealCost(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
// cost3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
// totalProductIncome = totalProductIncome.add(costMonth.getPredictCost());
// totalRealIncome = totalRealIncome.add(costMonth.getRealCost());
// }
// }
cost1.add(new PoiUtil.PoiUtilCell(totalProductIncome.toString()));
cost2.add(new PoiUtil.PoiUtilCell(totalRealIncome.toString()));
BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
cost3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
if(totalProductIncome.multiply(BigDecimal.valueOf(100)).intValue() != 0) {
BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
cost3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
cost3.add(new PoiUtil.PoiUtilCell());
}
list.add(cost1);
list.add(cost2);
list.add(cost3);
}
}
List<PoiUtil.PoiUtilCell> productCostType = new ArrayList<>();
productCostType.add(new PoiUtil.PoiUtilCell(firstCostType.getFCostName()));
list.add(productCostType);
List<PoiUtil.PoiUtilCell> productCostType1 = new ArrayList<>();
List<PoiUtil.PoiUtilCell> productCostType2 = new ArrayList<>();
List<PoiUtil.PoiUtilCell> productCostType3 = new ArrayList<>();
productCostType1.add(new PoiUtil.PoiUtilCell(firstCostType.getFCostName(),1,3));
productCostType2.add(new PoiUtil.PoiUtilCell());
productCostType3.add(new PoiUtil.PoiUtilCell());
productCostType1.add(new PoiUtil.PoiUtilCell("预计成本"));
productCostType2.add(new PoiUtil.PoiUtilCell("实际成本"));
productCostType3.add(new PoiUtil.PoiUtilCell("偏差率"));
list.add(productCostType1);
list.add(productCostType2);
list.add(productCostType3);
}
}
@ -675,36 +795,68 @@ public class ReportService implements IReportService {
cost2.add(new PoiUtil.PoiUtilCell());
cost3.add(new PoiUtil.PoiUtilCell());
cost1.add(new PoiUtil.PoiUtilCell("预计收入"));
cost2.add(new PoiUtil.PoiUtilCell("实际收入"));
cost1.add(new PoiUtil.PoiUtilCell("预计成本"));
cost2.add(new PoiUtil.PoiUtilCell("实际成本"));
cost3.add(new PoiUtil.PoiUtilCell("偏差率"));
BigDecimal totalProductIncome = BigDecimal.valueOf(0);
BigDecimal totalRealIncome = BigDecimal.valueOf(0);
if (CollectionUtil.isNotEmpty(costType.getCostMonthList())) {
for (CompanyVo.CostMonth costMonth : costType.getCostMonthList()) {
for (int a = 0; a < 12; a++){
if (a < costType.getCostMonthList().size()) {
CompanyVo.CostMonth costMonth = costType.getCostMonthList().get(a);
cost1.add(new PoiUtil.PoiUtilCell(costMonth.getPredictCost().toString()));
cost2.add(new PoiUtil.PoiUtilCell(costMonth.getRealCost().toString()));
BigDecimal bias = costMonth.getRealCost().subtract(costMonth.getPredictCost()).
divide(costMonth.getRealCost(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
cost3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
if(costMonth.getPredictCost().multiply(BigDecimal.valueOf(100)).intValue() != 0) {
BigDecimal bias = costMonth.getRealCost().subtract(costMonth.getPredictCost()).
divide(costMonth.getPredictCost(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
cost3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
cost3.add(new PoiUtil.PoiUtilCell());
}
totalProductIncome = totalProductIncome.add(costMonth.getPredictCost());
totalRealIncome = totalRealIncome.add(costMonth.getRealCost());
}else {
cost1.add(new PoiUtil.PoiUtilCell());
cost2.add(new PoiUtil.PoiUtilCell());
cost3.add(new PoiUtil.PoiUtilCell());
}
}
// if (CollectionUtil.isNotEmpty(costType.getCostMonthList())) {
// for (CompanyVo.CostMonth costMonth : costType.getCostMonthList()) {
// cost1.add(new PoiUtil.PoiUtilCell(costMonth.getPredictCost().toString()));
// cost2.add(new PoiUtil.PoiUtilCell(costMonth.getRealCost().toString()));
// BigDecimal bias = costMonth.getRealCost().subtract(costMonth.getPredictCost()).
// divide(costMonth.getRealCost(), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
// cost3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
// totalProductIncome = totalProductIncome.add(costMonth.getPredictCost());
// totalRealIncome = totalRealIncome.add(costMonth.getRealCost());
// }
// }
cost1.add(new PoiUtil.PoiUtilCell(totalProductIncome.toString()));
cost2.add(new PoiUtil.PoiUtilCell(totalRealIncome.toString()));
BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
cost3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
if(totalProductIncome.multiply(BigDecimal.valueOf(100)).intValue() != 0) {
BigDecimal bias = totalRealIncome.subtract(totalProductIncome).
divide(totalProductIncome, 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
cost3.add(new PoiUtil.PoiUtilCell(bias.toString() + "%"));
}else {
cost3.add(new PoiUtil.PoiUtilCell());
}
list.add(cost1);
list.add(cost2);
list.add(cost3);
}
}
List<PoiUtil.PoiUtilCell> costType = new ArrayList<>();
costType.add(new PoiUtil.PoiUtilCell(firstCostType.getFCostName()));
list.add(costType);
List<PoiUtil.PoiUtilCell> costType1 = new ArrayList<>();
List<PoiUtil.PoiUtilCell> costType2 = new ArrayList<>();
List<PoiUtil.PoiUtilCell> costType3 = new ArrayList<>();
costType1.add(new PoiUtil.PoiUtilCell(firstCostType.getFCostName(),1,3));
costType2.add(new PoiUtil.PoiUtilCell());
costType3.add(new PoiUtil.PoiUtilCell());
costType1.add(new PoiUtil.PoiUtilCell("预计成本"));
costType2.add(new PoiUtil.PoiUtilCell("实际成本"));
costType3.add(new PoiUtil.PoiUtilCell("偏差率"));
list.add(costType1);
list.add(costType2);
list.add(costType3);
}
}
return list;

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

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

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

@ -146,7 +146,7 @@
WHERE
ct.rec_status = 0
AND
ct.parent_id != 0
(l.rec_status = 0 or l.rec_status is null)
AND
l.product_cost = 0
)a on t.id = a.parentId
@ -165,7 +165,7 @@
p.id as costId,
p.`name` as costName,
l.month_time as `month`,
l.product_cost/100 as predictCost,
l.predict_cost/100 as predictCost,
l.real_cost/100 as realCost
FROM
t_product_type t LEFT JOIN t_product p on p.product_type_id = t.id
@ -176,6 +176,8 @@
p.rec_status = 0
AND
l.product_cost = 1
and
(l.rec_status = 0 or l.rec_status is null)
AND
t.project_id = #{projectId}
</select>
@ -236,7 +238,7 @@
WHERE
ct.rec_status = 0
and
cl.rec_status = 0
(cl.rec_status = 0 or cl.rec_status is null)
and
cl.product_cost = 0
GROUP BY ct.parent_id,cl.month_time

10
tall/src/main/java/com/ccsens/tall/bean/vo/PluginVo.java

@ -3,8 +3,6 @@ package com.ccsens.tall.bean.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Data
public class PluginVo {
@ -83,4 +81,12 @@ public class PluginVo {
private int publicity;
}
@ApiModel("会议记录返回")
@Data
public static class MinutesInfo {
@ApiModelProperty("查看路径")
private String wpsPath;
@ApiModelProperty("下载路径")
private String downloadPath;
}
}

8
tall/src/main/java/com/ccsens/tall/persist/dao/ProProjectFileDao.java

@ -0,0 +1,8 @@
package com.ccsens.tall.persist.dao;
import com.ccsens.tall.persist.mapper.ProProjectFileMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface ProProjectFileDao extends ProProjectFileMapper {
}

3
tall/src/main/java/com/ccsens/tall/service/ITaskPluginService.java

@ -5,7 +5,6 @@ import com.ccsens.tall.bean.po.ProTaskPlugin;
import com.ccsens.tall.bean.vo.PluginVo;
import com.ccsens.tall.bean.vo.TaskVo;
import java.io.FileNotFoundException;
import java.util.List;
/**
@ -54,5 +53,5 @@ public interface ITaskPluginService {
* @param token token
* @return 返回wps里的文件的路径
*/
List<String> saveMinutes(Long currentUserId, Long projectId,Long taskId,String token) throws Exception;
List<PluginVo.MinutesInfo> saveMinutes(Long currentUserId, String domainName,Long projectId,Long taskId,String token) throws Exception;
}

55
tall/src/main/java/com/ccsens/tall/service/TaskPluginService.java

@ -67,6 +67,12 @@ public class TaskPluginService implements ITaskPluginService{
private ProNotesDao proNotesDao;
@Resource
private IWpsService wpsService;
@Resource
private SysDomainDao sysDomainDao;
@Resource
private ProProjectFileDao proProjectFileDao;
@Resource
private WpsFileDao wpsFileDao;
@Override
public void savePlugin(ProTaskPlugin taskPlugin) {
@ -274,13 +280,37 @@ public class TaskPluginService implements ITaskPluginService{
}
@Override
public List<String> saveMinutes(Long currentUserId, Long projectId, Long taskId,String token) throws Exception {
public List<PluginVo.MinutesInfo> saveMinutes(Long currentUserId, String domainName,Long projectId, Long taskId,String token) throws Exception {
//根据域名查找公司logo
String logo = "/home/staticrec/logo.png";
if(StrUtil.isNotEmpty(domainName)) {
SysDomainExample domainExample = new SysDomainExample();
domainExample.createCriteria().andDomainNameEqualTo(domainName);
List<SysDomain> sysDomainList = sysDomainDao.selectByExample(domainExample);
if (CollectionUtil.isNotEmpty(sysDomainList)) {
logo = sysDomainList.get(0).getLogo();
}
}
List<PluginVo.MinutesInfo> minutesInfoList = new ArrayList<>();
Map<String,String> params = new HashMap<>();
params.put(WebConstant.Wps._W_URL,PropUtil.domain + "debug");
List<String> wpsPath = wpsService.queryVisitUrls(taskId,(byte) 2,token,params);
if(CollectionUtil.isNotEmpty(wpsPath)){
return wpsPath;
wpsPath.forEach(wps->{
PluginVo.MinutesInfo minutesInfo = new PluginVo.MinutesInfo();
minutesInfo.setWpsPath(wps);
//获取下载路径
ProProjectFileExample projectFileExample = new ProProjectFileExample();
projectFileExample.createCriteria().andBusinessIdEqualTo(taskId).andBusinessTypeEqualTo((byte) 2);
List<ProProjectFile> projectFileList = proProjectFileDao.selectByExample(projectFileExample);
if(CollectionUtil.isNotEmpty(projectFileList)){
WpsFile wpsFile = wpsFileDao.selectByPrimaryKey(projectFileList.get(0).getWpsFileId());
minutesInfo.setDownloadPath(wpsFile.getDownloadUrl());
}
minutesInfoList.add(minutesInfo);
});
return minutesInfoList;
}
log.info("生成会议记录,项目id:{}",projectId);
SysProject sysProject = sysProjectDao.selectByPrimaryKey(projectId);
@ -304,7 +334,7 @@ public class TaskPluginService implements ITaskPluginService{
// XSSFWorkbook wb = new XSSFWorkbook(is);
Workbook wb = new XSSFWorkbook();
PoiUtil.exportWB("会议记录", minutes, wb);
PoiUtil.setImg(wb,"会议记录","/home/staticrec/pimsLogo.png",0,1,0,1);
PoiUtil.setImg(wb,"会议记录",logo,0,1,0,1);
//生成文件
String name = sysProject.getName() + "会议记录.xlsx";
String fileName = "minutes/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx";
@ -329,7 +359,22 @@ public class TaskPluginService implements ITaskPluginService{
wpsService.saveFile(business);
//获取wps文件的路径并返回
wpsPath = wpsService.queryVisitUrls(taskId,(byte) 2,token,params);
return wpsPath;
if(CollectionUtil.isNotEmpty(wpsPath)){
wpsPath.forEach(wps->{
PluginVo.MinutesInfo minutesInfo = new PluginVo.MinutesInfo();
minutesInfo.setWpsPath(wps);
//获取下载路径
ProProjectFileExample projectFileExample = new ProProjectFileExample();
projectFileExample.createCriteria().andBusinessIdEqualTo(taskId).andBusinessTypeEqualTo((byte) 2);
List<ProProjectFile> projectFileList = proProjectFileDao.selectByExample(projectFileExample);
if(CollectionUtil.isNotEmpty(projectFileList)){
WpsFile wpsFile = wpsFileDao.selectByPrimaryKey(projectFileList.get(0).getWpsFileId());
minutesInfo.setDownloadPath(wpsFile.getDownloadUrl());
}
minutesInfoList.add(minutesInfo);
});
}
return minutesInfoList;
}
/**

8
tall/src/main/java/com/ccsens/tall/web/PluginController.java

@ -1,8 +1,6 @@
package com.ccsens.tall.web;
import com.ccsens.tall.bean.dto.PluginDto;
import com.ccsens.tall.bean.dto.TaskDto;
import com.ccsens.tall.bean.vo.MemberVo;
import com.ccsens.tall.bean.vo.PluginVo;
import com.ccsens.tall.service.ISysPluginService;
import com.ccsens.tall.service.ITaskPluginService;
@ -149,12 +147,12 @@ public class PluginController {
@ApiImplicitParams({
})
@RequestMapping(value = "/minutes", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public JsonResponse<String> saveMinutes(HttpServletRequest request,
@RequestParam(required = true) Long projectId,Long taskId) throws Exception {
public JsonResponse<List<PluginVo.MinutesInfo>> saveMinutes(HttpServletRequest request,
@RequestParam(required = false)String domainName, @RequestParam(required = true)Long projectId,Long taskId) throws Exception {
Long currentUserId = Long.valueOf(((Claims) request.getAttribute(WebConstant.REQUEST_KEY_CLAIMS)).getSubject());
String authHeader = request.getHeader(WebConstant.HEADER_KEY_TOKEN);
String token = authHeader.substring(WebConstant.HEADER_KEY_TOKEN_PREFIX.length());
List<String> wpsPath = taskPluginService.saveMinutes(currentUserId,projectId,taskId,token);
List<PluginVo.MinutesInfo> wpsPath = taskPluginService.saveMinutes(currentUserId,domainName,projectId,taskId,token);
return JsonResponse.newInstance().ok(wpsPath);
}

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

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

7
util/src/main/java/com/ccsens/util/PoiUtil.java

@ -450,7 +450,7 @@ public class PoiUtil {
* @param col2终止列
* @throws IOException
*/
public static Workbook setImg(Workbook wb,String sheetName,String ImgPath,int row1,int row2,int col1,int col2) throws IOException {
public static Workbook setImg(Workbook wb,String sheetName,String imgPath,int row1,int row2,int col1,int col2) throws IOException {
// 第一步,创建一个XSSFWorkbook,对应一个Excel文件
if (wb == null) {
wb = new XSSFWorkbook();
@ -461,7 +461,10 @@ public class PoiUtil {
sheet = wb.createSheet(sheetName);
}
// 插入 PNG 图片至 Excel
InputStream is = new FileInputStream(ImgPath);
InputStream is = new FileInputStream(imgPath);
if(ObjectUtil.isNull(is)){
return wb;
}
byte[] bytes = IOUtils.toByteArray(is);
int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);

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

@ -6,7 +6,6 @@ import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
import java.math.BigDecimal;
/**
* @description:
@ -34,10 +33,10 @@ public class Base64Test {
@Test
public void test02() throws Exception {
BigDecimal a = new BigDecimal(0.00);
BigDecimal b = new BigDecimal(0);
String s = "https://wwo.wps.cn/office/s/1291660455860899840?_w_appid=09d77d2eb919438e8ae4f2a9ec6ec8dd&_w_signature=oFhIjXT7MHYm58jfcbTAO%2Fo9quA%3D&_w_token=eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1OTY3ODY0NjksInN1YiI6IjEyMTc2NDc2ODY1OTgxMzU4MDgiLCJhdXRoSWQiOiIxMTc3MTU4ODQ4ODg1MTY2MDgwIiwiZXhwIjoxNTk2ODcyODY5fQ.-pNqWTas-5Efu1855QzuObqE9y2N9HI-K3MZCKmI6SA&_w_url=https://test.tall.wiki/gateway/pims/read/income";
System.out.println(s);
System.out.println(a.equals(b));
}

Loading…
Cancel
Save