|
@@ -14,23 +14,27 @@ import io.swagger.annotations.ApiOperation;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springblade.business.entity.FixedFlowLink;
|
|
import org.springblade.business.entity.FixedFlowLink;
|
|
import org.springblade.business.entity.Task;
|
|
import org.springblade.business.entity.Task;
|
|
import org.springblade.business.entity.TaskParallel;
|
|
import org.springblade.business.entity.TaskParallel;
|
|
import org.springblade.business.feign.TaskClient;
|
|
import org.springblade.business.feign.TaskClient;
|
|
import org.springblade.common.constant.ClientIdConstant;
|
|
import org.springblade.common.constant.ClientIdConstant;
|
|
|
|
+import org.springblade.common.utils.CommonUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.mp.base.BaseService;
|
|
import org.springblade.core.mp.base.BaseService;
|
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
import org.springblade.core.redis.cache.BladeRedis;
|
|
import org.springblade.core.redis.cache.BladeRedis;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
-import org.springblade.core.tool.utils.BeanUtil;
|
|
|
|
-import org.springblade.core.tool.utils.DateUtil;
|
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
|
-import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
|
|
|
+import org.springblade.core.tool.utils.*;
|
|
import org.springblade.feign.ArchiveFileTaskClient;
|
|
import org.springblade.feign.ArchiveFileTaskClient;
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
import org.springblade.manager.entity.ContractRelationJlyz;
|
|
import org.springblade.manager.entity.ContractRelationJlyz;
|
|
@@ -41,15 +45,17 @@ import org.springblade.meter.dto.*;
|
|
import org.springblade.meter.entity.*;
|
|
import org.springblade.meter.entity.*;
|
|
import org.springblade.meter.mapper.MiddleMeterApplyMapper;
|
|
import org.springblade.meter.mapper.MiddleMeterApplyMapper;
|
|
import org.springblade.meter.service.impl.*;
|
|
import org.springblade.meter.service.impl.*;
|
|
|
|
+import org.springblade.meter.utils.CollectionUtils;
|
|
import org.springblade.meter.vo.*;
|
|
import org.springblade.meter.vo.*;
|
|
import org.springblade.producer.bean.PushMessage;
|
|
import org.springblade.producer.bean.PushMessage;
|
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
|
+import java.io.*;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -95,6 +101,9 @@ public class TaskController extends BladeController {
|
|
// 计量公式入口
|
|
// 计量公式入口
|
|
private final FormulaClient formulaClient;
|
|
private final FormulaClient formulaClient;
|
|
|
|
|
|
|
|
+ // oss
|
|
|
|
+ private final NewIOSSClient newIOSSClient;
|
|
|
|
+
|
|
@GetMapping("/name")
|
|
@GetMapping("/name")
|
|
@ApiOperationSupport(order = 1)
|
|
@ApiOperationSupport(order = 1)
|
|
@ApiOperation(value = "获取任务名称", notes = "传入合同段contractId、期数id(变更令传勾选的id字符串英文逗号拼接)、type=1(中间计量申请)、=2(材料计量单)、3=(开工预付款计量单)、=4(变更令)")
|
|
@ApiOperation(value = "获取任务名称", notes = "传入合同段contractId、期数id(变更令传勾选的id字符串英文逗号拼接)、type=1(中间计量申请)、=2(材料计量单)、3=(开工预付款计量单)、=4(变更令)")
|
|
@@ -2432,4 +2441,113 @@ public class TaskController extends BladeController {
|
|
return R.fail("操作失败");
|
|
return R.fail("操作失败");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/meterPdfInfo22")
|
|
|
|
+ @ApiOperationSupport(order = 20)
|
|
|
|
+ @ApiOperation(value = "计量生成Pdf", notes = "计量生成Pdf")
|
|
|
|
+ public R meterPdfInfo22(@RequestParam String ContractId,@RequestParam String FormDataId,@RequestParam Integer type){
|
|
|
|
+ String file_path = CollectionUtils.getSysLocalFileUrl();
|
|
|
|
+ // 材料生成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")+"";
|
|
|
|
+
|
|
|
|
+ File tabPdf = null;
|
|
|
|
+ try {
|
|
|
|
+ tabPdf = ResourceUtil.getFile(pdfPath);
|
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ if (tabPdf.exists()) {
|
|
|
|
+ tabPdf.delete();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //输出流
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.success("1234");
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|