|
@@ -43,7 +43,9 @@ import org.springblade.manager.feign.FormulaClient;
|
|
|
import org.springblade.manager.vo.ReportResult;
|
|
|
import org.springblade.meter.dto.*;
|
|
|
import org.springblade.meter.entity.*;
|
|
|
+import org.springblade.meter.mapper.MaterialStartStatementMapper;
|
|
|
import org.springblade.meter.mapper.MiddleMeterApplyMapper;
|
|
|
+import org.springblade.meter.service.IMaterialStartStatementService;
|
|
|
import org.springblade.meter.service.impl.*;
|
|
|
import org.springblade.meter.utils.CollectionUtils;
|
|
|
import org.springblade.meter.vo.*;
|
|
@@ -98,6 +100,8 @@ public class TaskController extends BladeController {
|
|
|
private final ChangeTokenInventoryServiceImpl changeTokenInventoryService;
|
|
|
private final ChangeTokenInventoryServiceTaskImpl changeTokenInventoryServiceTask;
|
|
|
|
|
|
+ private final IMaterialStartStatementService materialStartStatementService;
|
|
|
+
|
|
|
// 计量公式入口
|
|
|
private final FormulaClient formulaClient;
|
|
|
|
|
@@ -2059,22 +2063,21 @@ public class TaskController extends BladeController {
|
|
|
// pdf 生成
|
|
|
private boolean meterPdfInfo(Task task) {
|
|
|
// 材料生成pdf
|
|
|
- if(task.getType()==2){
|
|
|
+ if (task.getType() == 2) {
|
|
|
// 获取填报数据
|
|
|
|
|
|
// 调用公式
|
|
|
- List<ReportResult> reportResults = formulaClient.formulaExecute3(Long.parseLong(task.getContractId()), Long.parseLong(task.getFormDataId()),1);
|
|
|
+ List<ReportResult> reportResults = formulaClient.formulaExecute3(Long.parseLong(task.getContractId()), Long.parseLong(task.getFormDataId()), 1);
|
|
|
//生成pdf
|
|
|
- String fen ="SELECT * from m_wbs_tree_private WHERE project_id='"+task.getProjectId()+"' and wbs_type=3 and parent_id=(SELECT id from m_wbs_tree_private where project_id='"+task.getProjectId()+"' and is_deleted=0 and type=1 and wbs_type=3 and node_type=31)" +
|
|
|
+ String fen = "SELECT * from m_wbs_tree_private WHERE project_id='" + task.getProjectId() + "' and wbs_type=3 and parent_id=(SELECT id from m_wbs_tree_private where project_id='" + task.getProjectId() + "' and is_deleted=0 and type=1 and wbs_type=3 and node_type=31)" +
|
|
|
"AND type = 2 AND status = 1 and is_deleted= 0 ORDER BY sort";
|
|
|
- WbsTreePrivate wbsTreePrivate = jdbcTemplate.query(fen, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);;
|
|
|
-
|
|
|
+ WbsTreePrivate wbsTreePrivate = jdbcTemplate.query(fen, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
|
|
|
+ ;
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -2442,112 +2445,127 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- @GetMapping("/meterPdfInfo22")
|
|
|
+ @GetMapping("/meterPdfInfo")
|
|
|
@ApiOperationSupport(order = 20)
|
|
|
@ApiOperation(value = "计量生成Pdf", notes = "计量生成Pdf")
|
|
|
- public R meterPdfInfo22(@RequestParam String ContractId,@RequestParam String FormDataId,@RequestParam Integer type){
|
|
|
+ public R meterPdfInfo(@RequestParam String ContractId, @RequestParam String FormDataId, @RequestParam Integer type) {
|
|
|
String file_path = CollectionUtils.getSysLocalFileUrl();
|
|
|
+ String fileUrl = "";
|
|
|
+ Long sid = 0l;
|
|
|
+ MaterialStartStatement materialS = materialStartStatementService.getBaseMapper().selectOne(Wrappers.<MaterialStartStatement>lambdaQuery().eq(MaterialStartStatement::getContractId, ContractId).eq(MaterialStartStatement::getMeterPeriodId, FormDataId).eq(MaterialStartStatement::getType, 1));
|
|
|
+ if (materialS == null || Func.isNull(materialS)) {
|
|
|
+ MeterPeriod me = periodService.getById(FormDataId);
|
|
|
+ MaterialStartStatement data = new MaterialStartStatement();
|
|
|
+ data.setMeterPeriodId(Func.toLong(FormDataId));
|
|
|
+ data.setPrintDate(me.getFormPrintDate());
|
|
|
+ data.setRepaymentCause("材料预付款");
|
|
|
+ data.setStatementName("材料预付款--" + me.getPeriodName());
|
|
|
+ materialStartStatementService.addOrUpdate(data);
|
|
|
+ sid = data.getId();
|
|
|
+ } else {
|
|
|
+ sid = materialS.getId();
|
|
|
+ }
|
|
|
+ List<ReportResult> sul = new ArrayList<>();
|
|
|
// 材料生成pdf
|
|
|
- if(type==2){
|
|
|
- // 获取填报数据
|
|
|
- String sql = "SELECT * FROM s_material_start_statement where contract_id="+ContractId+" and type=1 and meter_period_id="+FormDataId+"";
|
|
|
- Map<String, Object> dataInfo = jdbcTemplate.queryForMap(sql);
|
|
|
- Long sid = Func.toLong(dataInfo.get("id"));
|
|
|
- // 调用公式
|
|
|
- List<ReportResult> sul = formulaClient.formulaExecute3(Long.parseLong(ContractId), sid,1);
|
|
|
- if(sul!=null && sul.size()>=1){
|
|
|
- for(ReportResult data:sul){
|
|
|
- Long excelId = data.getExcelId();
|
|
|
- String exSql = "SELECT * from m_excel_tab where id="+excelId+"";
|
|
|
- Map<String, Object> exMap = jdbcTemplate.queryForMap(exSql);
|
|
|
- if (exMap == null) {
|
|
|
- return R.fail("未获取到该表单的信息");
|
|
|
- }
|
|
|
- if (exMap.get("file_url") == null) {
|
|
|
- return R.fail("htmlUrl is null");
|
|
|
- }
|
|
|
- String pkeyId=sid+""+excelId;
|
|
|
- String pdfPath = file_path + "/pdf//" + pkeyId + ".pdf";
|
|
|
- String excelPath = file_path + "/pdf//" + pkeyId + ".xlsx";
|
|
|
|
|
|
- String excelUrl = exMap.get("file_url")+"";
|
|
|
+ sul = formulaClient.formulaExecute3(Long.parseLong(ContractId), sid, type);
|
|
|
+ // 获取填报数据
|
|
|
+ List<String> dataListPdf = new ArrayList<>();
|
|
|
+
|
|
|
+ if (sul != null && sul.size() >= 1) {
|
|
|
+ for (ReportResult data : sul) {
|
|
|
+ Long excelId = data.getExcelId();
|
|
|
+ String exSql = "SELECT * from m_excel_tab where id=" + excelId + "";
|
|
|
+ Map<String, Object> exMap = jdbcTemplate.queryForMap(exSql);
|
|
|
+ if (exMap == null) {
|
|
|
+ return R.fail("未获取到该表单的信息");
|
|
|
+ }
|
|
|
+ if (exMap.get("file_url") == null) {
|
|
|
+ return R.fail("htmlUrl is null");
|
|
|
+ }
|
|
|
+ String pkeyId = sid + "" + excelId;
|
|
|
+ String pdfPath = file_path + "/pdf//" + pkeyId + ".pdf";
|
|
|
+ String excelPath = file_path + "/pdf//" + pkeyId + ".xlsx";
|
|
|
|
|
|
- File tabPdf = null;
|
|
|
- try {
|
|
|
- tabPdf = ResourceUtil.getFile(pdfPath);
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- if (tabPdf.exists()) {
|
|
|
- tabPdf.delete();
|
|
|
- }
|
|
|
+ String excelUrl = exMap.get("file_url") + "";
|
|
|
|
|
|
- List<Map<String, Object>> data1 = data.getData();
|
|
|
- //获取excel流 和 html流
|
|
|
- try {
|
|
|
- InputStream exceInp = CommonUtil.getOSSInputStream(excelUrl);
|
|
|
- Workbook workbook = null;
|
|
|
- int index = excelUrl.lastIndexOf(".");
|
|
|
- String suffix = excelUrl.substring(index).toLowerCase();
|
|
|
-
|
|
|
- if (".xls".equals(suffix)) {
|
|
|
- workbook = new XSSFWorkbook(exceInp);
|
|
|
- } else if (".xlsx".equals(suffix)) {
|
|
|
- workbook = new XSSFWorkbook(exceInp);
|
|
|
- }
|
|
|
- //获取工作表
|
|
|
- Sheet sheet = workbook.getSheetAt(0);
|
|
|
- sheet.setForceFormulaRecalculation(true);
|
|
|
-
|
|
|
- // 写入数据
|
|
|
- List<Map<String, Object>> dataData = data.getData();
|
|
|
- if(dataData!=null && dataData.size()>=1){
|
|
|
- for(Map<String, Object> dama:dataData){
|
|
|
-
|
|
|
- // 循环Key
|
|
|
- for(String keys:dama.keySet()){
|
|
|
- int y1 = Func.toInt(keys.split("_")[0]);
|
|
|
- int x1 = Func.toInt(keys.split("_")[1]);
|
|
|
- Row row = sheet.getRow(y1 - 1);
|
|
|
- if (row != null) {
|
|
|
- Cell cell = row.getCell(x1 - 1);
|
|
|
- String dataval = dama.get(keys)+"";
|
|
|
- if(dataval.indexOf("第")>=0 && dataval.indexOf("次支付")>=0){
|
|
|
- String datare = dataval.replace("第","").replace("次交付","");
|
|
|
- dataval = datare.replace("次支付","");
|
|
|
- }
|
|
|
- cell.setCellValue(dataval);
|
|
|
+ File tabPdf = null;
|
|
|
+ try {
|
|
|
+ tabPdf = ResourceUtil.getFile(pdfPath);
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ if (tabPdf.exists()) {
|
|
|
+ tabPdf.delete();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获取excel流 和 html流
|
|
|
+ try {
|
|
|
+ InputStream exceInp = CommonUtil.getOSSInputStream(excelUrl);
|
|
|
+ Workbook workbook = null;
|
|
|
+ int index = excelUrl.lastIndexOf(".");
|
|
|
+ String suffix = excelUrl.substring(index).toLowerCase();
|
|
|
+
|
|
|
+ if (".xls".equals(suffix)) {
|
|
|
+ workbook = new XSSFWorkbook(exceInp);
|
|
|
+ } else if (".xlsx".equals(suffix)) {
|
|
|
+ workbook = new XSSFWorkbook(exceInp);
|
|
|
+ }
|
|
|
+ //获取工作表
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
+
|
|
|
+ // 写入数据
|
|
|
+ List<Map<String, Object>> dataData = data.getData();
|
|
|
+ if (dataData != null && dataData.size() >= 1) {
|
|
|
+ for (Map<String, Object> dama : dataData) {
|
|
|
+
|
|
|
+ // 循环Key
|
|
|
+ for (String keys : dama.keySet()) {
|
|
|
+ int y1 = Func.toInt(keys.split("_")[0]);
|
|
|
+ int x1 = Func.toInt(keys.split("_")[1]);
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
+ if (row != null) {
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
+ String dataval = dama.get(keys) + "";
|
|
|
+ if (dataval.indexOf("第") >= 0 && dataval.indexOf("次支付") >= 0) {
|
|
|
+ String datare = dataval.replace("第", "").replace("次交付", "");
|
|
|
+ dataval = datare.replace("次支付", "");
|
|
|
}
|
|
|
+ cell.setCellValue(dataval);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //输出流
|
|
|
- FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
|
- workbook.write(outputStream);
|
|
|
-
|
|
|
- CollectionUtils.excelToPdf(excelPath, pdfPath);
|
|
|
- BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
|
|
|
-
|
|
|
- /*UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.in("p_key_id", pkeyId + "");
|
|
|
- updateWrapper.set("pdf_url", fileUrl);
|
|
|
- updateWrapper.set("real_fill_rate", realFillRate);
|
|
|
- wbsTreeContractService.update(updateWrapper);*/
|
|
|
-
|
|
|
- //关闭流
|
|
|
- IoUtil.closeQuietly(outputStream);
|
|
|
- IoUtil.closeQuietly(exceInp);
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
}
|
|
|
+
|
|
|
+ //输出流
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
|
+ workbook.write(outputStream);
|
|
|
+ CollectionUtils.excelToPdf(excelPath, pdfPath);
|
|
|
+ dataListPdf.add(pdfPath);
|
|
|
+ //关闭流
|
|
|
+ IoUtil.closeQuietly(outputStream);
|
|
|
+ IoUtil.closeQuietly(exceInp);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return R.success("1234");
|
|
|
+ Long dataId = SnowFlakeUtil.getId();
|
|
|
+ String lasPdf = file_path + "/pdf//" + dataId + "_last.pdf";
|
|
|
+
|
|
|
+ if (dataListPdf.size() > 0) {
|
|
|
+ CollectionUtils.mergePdfPublicMethods(dataListPdf, lasPdf);
|
|
|
+ BladeFile bladeFile2 = newIOSSClient.uploadFile(dataId + "_last.pdf", lasPdf);
|
|
|
+ fileUrl = bladeFile2.getLink();
|
|
|
+ }
|
|
|
+
|
|
|
+ String upSql = "update s_material_start_statement set raw_url='" + fileUrl + "' where contract_id=" + ContractId + " and type=1 and meter_period_id=" + FormDataId + "";
|
|
|
+ jdbcTemplate.execute(upSql);
|
|
|
+
|
|
|
+ return R.success(fileUrl);
|
|
|
}
|
|
|
|
|
|
}
|