|
@@ -9,16 +9,15 @@ import com.dayou.common.BaseEntity;
|
|
|
import com.dayou.common.CalculateFormula;
|
|
|
import com.dayou.config.FileNetConfig;
|
|
|
import com.dayou.dto.calculate.equipment.EquipmentBaseInfoDTO;
|
|
|
-import com.dayou.entity.AssetsCalculate;
|
|
|
-import com.dayou.entity.AssetsCalculateEqptData;
|
|
|
-import com.dayou.entity.TmplAssetCalculate;
|
|
|
-import com.dayou.entity.TmplAssetCalculateSection;
|
|
|
+import com.dayou.entity.*;
|
|
|
+import com.dayou.enums.BusinessEnum;
|
|
|
import com.dayou.mapper.AssetsCalculateMapper;
|
|
|
import com.dayou.mapper.TmplAssetCalculateMapper;
|
|
|
import com.dayou.mapper.TmplAssetCalculateSectionMapper;
|
|
|
import com.dayou.service.AssetsCalculateEqptDataService;
|
|
|
import com.dayou.service.AssetsCalculateService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.dayou.service.DocumentProductionService;
|
|
|
import com.dayou.utils.EasyExcelUtil;
|
|
|
import com.dayou.vo.AssetsCalculateEqptImpDataVO;
|
|
|
import com.dayou.vo.AssetsCalculateEqptNonsDataVO;
|
|
@@ -45,6 +44,7 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static com.dayou.common.CalculateFormula.*;
|
|
|
+import static com.dayou.enums.DocumentType.EQPT_CALCULATE;
|
|
|
import static com.dayou.enums.EquipmentTmplCode.*;
|
|
|
|
|
|
/**
|
|
@@ -71,10 +71,14 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
private TmplAssetCalculateSectionMapper calculateSectionMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ private DocumentProductionService documentProductionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private FileNetConfig fileNetConfig;
|
|
|
|
|
|
/**
|
|
|
* 根据项目id查询所有测算表信息
|
|
|
+ *
|
|
|
* @param projectId 项目id
|
|
|
* @return List<AssetsCalculateVO>
|
|
|
*/
|
|
@@ -84,29 +88,39 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AssetsCalculate detail(Long id){
|
|
|
+ public AssetsCalculate detail(Long id) {
|
|
|
return this.getById(id);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 新增或修改测算表信息
|
|
|
+ * @param assetsCalculate 测算表信息
|
|
|
+ * @return Boolean
|
|
|
+ */
|
|
|
@Override
|
|
|
- public Boolean add(AssetsCalculate assetsCalculate){
|
|
|
+ public Boolean add(AssetsCalculate assetsCalculate) {
|
|
|
assetsCalculate.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
- return this.save(assetsCalculate);
|
|
|
+ if (ObjectUtil.isNull(assetsCalculate.getId())) {
|
|
|
+ return this.save(assetsCalculate);
|
|
|
+ }else {
|
|
|
+ return this.updateById(assetsCalculate);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean update(AssetsCalculate assetsCalculate){
|
|
|
- return this.updateById(assetsCalculate);
|
|
|
+ public Boolean update(AssetsCalculate assetsCalculate) {
|
|
|
+ return this.updateById(assetsCalculate);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean delete(Long id){
|
|
|
+ public Boolean delete(Long id) {
|
|
|
//逻辑删除
|
|
|
return this.removeById(id);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据项目id获取未完成测算表的进度信息
|
|
|
+ *
|
|
|
* @param projectId 项目id
|
|
|
* @return AssetsCalculateStepBaseVO
|
|
|
*/
|
|
@@ -117,8 +131,9 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
|
|
|
/**
|
|
|
* 导入保存机器设备基础信息
|
|
|
+ *
|
|
|
* @param multipartFile Excel文件
|
|
|
- * @param calculateId 测算表id
|
|
|
+ * @param calculateId 测算表id
|
|
|
* @return Boolean
|
|
|
*/
|
|
|
@Override
|
|
@@ -134,24 +149,28 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
// 批量保存
|
|
|
dataService.saveBatch(dataList);
|
|
|
}, 1000)).sheet().doRead();
|
|
|
+ // 更新测算表进度
|
|
|
+ assetsCalculateMapper.updateCalculateProgress(calculateId, "GENERATE");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新测算表基础测算信息
|
|
|
+ *
|
|
|
* @param calculateId id
|
|
|
- * @param baseInfo 基础信息json字符串
|
|
|
+ * @param baseInfo 基础信息json字符串
|
|
|
* @return Boolean
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean updateCalculateBaseInfo(Long calculateId, String baseInfo) {
|
|
|
// 更新测算表进度
|
|
|
- assetsCalculateMapper.updateCalculateProgress(calculateId,"GENERATE");
|
|
|
+ assetsCalculateMapper.updateCalculateProgress(calculateId, "IMPORT");
|
|
|
return assetsCalculateMapper.updateCalculateBaseInfo(calculateId, baseInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成机器设备测算表excel文件
|
|
|
+ *
|
|
|
* @param calculateId 测算表id
|
|
|
* @return Boolean
|
|
|
*/
|
|
@@ -204,14 +223,14 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
for (int i = 4; i <= sheet.getLastRowNum(); i++) {
|
|
|
Row row = sheet.getRow(i);
|
|
|
// 循环设置公式
|
|
|
- for (CalculateFormula.EquipmentMainFormula formula: EQUIPMENT_MAIN_FORMULA) {
|
|
|
+ for (CalculateFormula.EquipmentMainFormula formula : EQUIPMENT_MAIN_FORMULA) {
|
|
|
Cell cell = row.getCell(formula.getColumn() - 1);
|
|
|
// 如果该单元格不存在,则创建一个
|
|
|
if (cell == null) {
|
|
|
cell = row.createCell(formula.getColumn() - 1);
|
|
|
}
|
|
|
// 设置公式
|
|
|
- cell.setCellFormula(MessageFormat.format(formula.getFormula(),(row.getRowNum() + 1)));
|
|
|
+ cell.setCellFormula(MessageFormat.format(formula.getFormula(), (row.getRowNum() + 1)));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -237,14 +256,14 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
for (int i = 2; i <= importedSheet.getLastRowNum(); i++) { // 跳过前两行
|
|
|
Row row = importedSheet.getRow(i);
|
|
|
// 循环设置公式
|
|
|
- for (CalculateFormula.EquipmentImportedFormula formula: EQUIPMENT_IMPORTED_FORMULA) {
|
|
|
+ for (CalculateFormula.EquipmentImportedFormula formula : EQUIPMENT_IMPORTED_FORMULA) {
|
|
|
Cell cell = row.getCell(formula.getColumn() - 1);
|
|
|
// 如果该单元格不存在,则创建一个
|
|
|
if (cell == null) {
|
|
|
cell = row.createCell(formula.getColumn() - 1);
|
|
|
}
|
|
|
// 设置公式
|
|
|
- cell.setCellFormula(MessageFormat.format(formula.getFormula(),(row.getRowNum() + 1)));
|
|
|
+ cell.setCellFormula(MessageFormat.format(formula.getFormula(), (row.getRowNum() + 1)));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -260,7 +279,7 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
// 判断主表的序号和进口设备的序号是否相等
|
|
|
if (importedCell != null && row.getCell(0).getNumericCellValue() == importedCell.getNumericCellValue()) {
|
|
|
importedRowNum = importedCell.getRowIndex() + 1; // +1是因为代码中下标从0开始,但是excel是从1开始
|
|
|
- priceCell.setCellFormula(MessageFormat.format("进口设备!Y{0}",importedRowNum));
|
|
|
+ priceCell.setCellFormula(MessageFormat.format("进口设备!Y{0}", importedRowNum));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -268,7 +287,7 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 第五步:设置进口设备的测算表
|
|
|
+ // 第六步:设置非标设备的测算表
|
|
|
List<AssetsCalculateEqptNonsDataVO> nonsEqptData = dataService.getNonSDataList(calculateId);
|
|
|
if (ObjectUtil.isNotNull(nonsEqptData)) {
|
|
|
// 获取模板
|
|
@@ -290,14 +309,14 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
for (int i = 2; i <= nonstandardSheet.getLastRowNum(); i++) { // 跳过前两行
|
|
|
Row row = nonstandardSheet.getRow(i);
|
|
|
// 循环设置公式
|
|
|
- for (CalculateFormula.EquipmentNonStandardFormula formula: EQUIPMENT_NONSTANDARD_FORMULA) {
|
|
|
+ for (CalculateFormula.EquipmentNonStandardFormula formula : EQUIPMENT_NONSTANDARD_FORMULA) {
|
|
|
Cell cell = row.getCell(formula.getColumn() - 1);
|
|
|
// 如果该单元格不存在,则创建一个
|
|
|
if (cell == null) {
|
|
|
cell = row.createCell(formula.getColumn() - 1);
|
|
|
}
|
|
|
// 设置公式
|
|
|
- cell.setCellFormula(MessageFormat.format(formula.getFormula(),(row.getRowNum() + 1)));
|
|
|
+ cell.setCellFormula(MessageFormat.format(formula.getFormula(), (row.getRowNum() + 1)));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -313,7 +332,7 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
// 判断主表的序号和进口设备的序号是否相等
|
|
|
if (importedCell != null && row.getCell(0).getNumericCellValue() == importedCell.getNumericCellValue()) {
|
|
|
importedRowNum = importedCell.getRowIndex() + 1; // +1是因为代码中下标从0开始,但是excel是从1开始
|
|
|
- priceCell.setCellFormula(MessageFormat.format("非标设备!W{0}",importedRowNum));
|
|
|
+ priceCell.setCellFormula(MessageFormat.format("非标设备!W{0}", importedRowNum));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -329,25 +348,44 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
// 关闭流
|
|
|
workbook.close();
|
|
|
outputStream.close();
|
|
|
- return null;
|
|
|
+
|
|
|
+ // 更新测算表进度
|
|
|
+ assetsCalculateMapper.updateCalculateProgress(calculateId, "FINISHED");
|
|
|
+
|
|
|
+ // 保存文档信息到数据库
|
|
|
+ AssetsCalculateVO assetsCalculateVO = assetsCalculateMapper.getCalculateInfoForDoc(calculateId);
|
|
|
+ DocumentProduction documentProduction = new DocumentProduction()
|
|
|
+ .setBusinessType("ASSETS")
|
|
|
+ .setBusinessId(assetsCalculateVO.getProjectId())
|
|
|
+ .setDocType(EQPT_CALCULATE.getName())
|
|
|
+ .setDocName(assetsCalculateVO.getCalculateName() + ".xlsx")
|
|
|
+ .setConsignor(assetsCalculateVO.getPrincipal())
|
|
|
+ .setDocUrl(mainMergePath)
|
|
|
+ .setCreateUserId(StpUtil.getLoginIdAsLong())
|
|
|
+ .setBusinessCate(assetsCalculateVO.getProjectTypeName())
|
|
|
+ .setDocNo("")
|
|
|
+ .setBusinessSubId(calculateId);
|
|
|
+ return documentProductionService.addDocumentProduction(documentProduction);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据测算表id获取基础测算信息
|
|
|
+ *
|
|
|
* @param calculateId 测算表id
|
|
|
* @return String
|
|
|
*/
|
|
|
@Override
|
|
|
public String getCalculateBaseInfo(Long calculateId) {
|
|
|
return assetsCalculateMapper.selectOne(new LambdaQueryWrapper<AssetsCalculate>()
|
|
|
- .select(AssetsCalculate::getBaseInfo)
|
|
|
- .eq(BaseEntity::getId, calculateId)
|
|
|
- .eq(BaseEntity::getDeleteStatus, 0))
|
|
|
+ .select(AssetsCalculate::getBaseInfo)
|
|
|
+ .eq(BaseEntity::getId, calculateId)
|
|
|
+ .eq(BaseEntity::getDeleteStatus, 0))
|
|
|
.getBaseInfo();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据测算表id获取评估基准日
|
|
|
+ *
|
|
|
* @param calculateId 测算表id
|
|
|
* @return String
|
|
|
*/
|