|
@@ -19,6 +19,7 @@ import com.dayou.service.AssetsCalculateEqptDataService;
|
|
|
import com.dayou.service.AssetsCalculateService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.dayou.utils.EasyExcelUtil;
|
|
|
+import com.dayou.vo.AssetsCalculateVO;
|
|
|
import com.dayou.vo.calculate.AssetsCalculateProgressVO;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@@ -37,6 +38,7 @@ import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.text.MessageFormat;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import static com.dayou.common.CalculateFormula.EQUIPMENT_MAIN_FORMULA;
|
|
|
|
|
@@ -66,13 +68,16 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
@Autowired
|
|
|
private FileNetConfig fileNetConfig;
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据项目id查询所有测算表信息
|
|
|
+ * @param projectId 项目id
|
|
|
+ * @return List<AssetsCalculateVO>
|
|
|
+ */
|
|
|
@Override
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- public Page<AssetsCalculate> selectPage(Page page,AssetsCalculate assetsCalculate){
|
|
|
- return this.page(page, new QueryWrapper<AssetsCalculate>(assetsCalculate));
|
|
|
+ public List<AssetsCalculateVO> listAllByProjectId(Long projectId) {
|
|
|
+ return assetsCalculateMapper.listAllByProjectId(projectId);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public AssetsCalculate detail(Long id){
|
|
|
return this.getById(id);
|
|
@@ -150,24 +155,24 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
|
|
|
// 第一步:写入数据到 机器设备-主模板-设备信息-段落模板
|
|
|
// 获取模板
|
|
|
- TmplAssetCalculateSection calculateSection = calculateSectionMapper.getByTmplCode("MAIN_DETAIL");
|
|
|
+ TmplAssetCalculateSection mainDetail = calculateSectionMapper.getByTmplCode("MAIN_DETAIL");
|
|
|
// 生成后文件的位置
|
|
|
String mainDetailPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputCalculatePath() + System.currentTimeMillis() + "_MAIN_DETAIL.xlsx";
|
|
|
// 模板文件的位置
|
|
|
- String mainDetailTMplPath = fileNetConfig.getBaseDir() + calculateSection.getSectionFileUrl() + calculateSection.getSectionFileName();
|
|
|
+ String mainDetailTMplPath = fileNetConfig.getBaseDir() + mainDetail.getSectionFileUrl() + mainDetail.getSectionFileName();
|
|
|
// 写入
|
|
|
EasyExcel.write(mainDetailPath)
|
|
|
.withTemplate(mainDetailTMplPath)
|
|
|
.sheet()
|
|
|
- .doFill(assetsCalculateEqptDataService.getAllByAssetsCalculateId(calculateId));
|
|
|
+ .doFill(assetsCalculateEqptDataService.getAllByAssetsCalculateId(calculateId, null));
|
|
|
|
|
|
// 第二步:写入数据到 机器设备-主模板
|
|
|
// 获取模板
|
|
|
- TmplAssetCalculate calculate = tmplAssetCalculateMapper.getCalculateTmplByCode("MAIN");
|
|
|
+ TmplAssetCalculate main = tmplAssetCalculateMapper.getCalculateTmplByCode("MAIN");
|
|
|
// 生成后文件的位置
|
|
|
String mainPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputCalculatePath() + System.currentTimeMillis() + "_MAIN.xlsx";
|
|
|
// 模板文件的位置
|
|
|
- String mainTmplPath = fileNetConfig.getBaseDir() + calculate.getFileUrl() + calculate.getFileName();
|
|
|
+ String mainTmplPath = fileNetConfig.getBaseDir() + main.getFileUrl() + main.getFileName();
|
|
|
// 获取基础测算信息
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
EquipmentBaseInfoDTO baseInfoDTO = objectMapper.readValue(getCalculateBaseInfo(calculateId), EquipmentBaseInfoDTO.class);
|
|
@@ -204,6 +209,18 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
|
|
|
cell.setCellFormula(MessageFormat.format(formula.getFormula(),(row.getRowNum() + 1)));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 第五步:设置进口设备的测算表
|
|
|
+ List<AssetsCalculateEqptData> importedEqptData = assetsCalculateEqptDataService.getAllByAssetsCalculateId(calculateId, "进口设备");
|
|
|
+ if (!importedEqptData.isEmpty()) {
|
|
|
+ // 获取模板
|
|
|
+ TmplAssetCalculate imported = tmplAssetCalculateMapper.getCalculateTmplByCode("IMPORTED");
|
|
|
+ // 生成后文件的位置
|
|
|
+ String importedPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputCalculatePath() + System.currentTimeMillis() + "_MAIN.xlsx";
|
|
|
+ // 模板文件的位置
|
|
|
+ String importedTmplPath = fileNetConfig.getBaseDir() + main.getFileUrl() + main.getFileName();
|
|
|
+ }
|
|
|
+
|
|
|
// 强制计算公式
|
|
|
workbook.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
|
|
|