|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.spire.xls.*;
|
|
|
+import io.swagger.models.auth.In;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
|
import org.springblade.business.dto.*;
|
|
@@ -345,69 +346,6 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
return recordVO2s;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- @Async
|
|
|
- public boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto, TrialSelfInspectionRecord obj) throws
|
|
|
- FileNotFoundException {
|
|
|
- if (ObjectUtil.isEmpty(dto.getId())) {
|
|
|
- throw new ServiceException("请先保存填报数据后,再关联原材检测报告信息");
|
|
|
- } else {
|
|
|
- if (ObjectUtil.isNotEmpty(obj) && (("已审批").equals(obj.getTaskStatus()) || ("待审批").equals(obj.getTaskStatus()))) {
|
|
|
- throw new ServiceException("当前填报数据已上报,无法进行关联操作");
|
|
|
- }
|
|
|
-
|
|
|
- //新增或编辑
|
|
|
- if (StringUtils.isNotEmpty(dto.getIds())) {
|
|
|
- //当前关联的原材料记录id
|
|
|
- List<String> ids = Func.toStrList(dto.getIds());
|
|
|
-
|
|
|
- //获取原材料的pdf
|
|
|
- List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
|
|
|
- .select(TrialSelfInspectionRecord::getPdfUrl, TrialSelfInspectionRecord::getId)
|
|
|
- .in(TrialSelfInspectionRecord::getId, ids).eq(TrialSelfInspectionRecord::getStatus, 1));
|
|
|
- List<TrialSelfInspectionRecord> recordObjList = recordList.stream().filter(f -> !f.getId().equals(Long.parseLong(dto.getId()))).collect(Collectors.toList());
|
|
|
- List<String> pdfUrlAll = new ArrayList<>();
|
|
|
- if (recordObjList.size() > 0) {
|
|
|
- pdfUrlAll.addAll(recordObjList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList()));
|
|
|
- }
|
|
|
-
|
|
|
- if (pdfUrlAll.size() > 0) {
|
|
|
- String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
- String listPdf = filePath + "/pdf/" + dto.getNodeId() + ".pdf";
|
|
|
- File tabPDF = ResourceUtil.getFile(listPdf);
|
|
|
- if (tabPDF.exists()) {
|
|
|
- tabPDF.delete();
|
|
|
- }
|
|
|
- FileUtils.mergePdfPublicMethods(pdfUrlAll, listPdf);
|
|
|
- BladeFile bladeFile = this.newIOSSClient.uploadFile(dto.getNodeId() + ".pdf", listPdf);
|
|
|
-
|
|
|
- //删除记录关系
|
|
|
- String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
|
|
|
- jdbcTemplate.execute(sql1);
|
|
|
- //新增记录关系
|
|
|
- for (String recordId : ids) {
|
|
|
- if (!recordId.equals(dto.getId())) {
|
|
|
- String sql2 = "insert into u_trial_raw_material_self_record(id,self_record_id,raw_material_record_id,old_pdf_url) values(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + recordId + ",'" + bladeFile.getLink() + "')";
|
|
|
- jdbcTemplate.execute(sql2);
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- //删除全部
|
|
|
- String sql = "select id from u_trial_raw_material_self_record where self_record_id =" + dto.getId();
|
|
|
- List<TrialRawMaterialSelfRecord> recordList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
|
|
|
- if (recordList.size() > 0) {
|
|
|
- String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
|
|
|
- jdbcTemplate.execute(sql1);
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public String selfPrintPdf(String ids) throws FileNotFoundException {
|
|
|
List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, Func.toLongList(ids)).eq(TrialSelfInspectionRecord::getStatus, 1));
|
|
@@ -672,77 +610,119 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
|
|
|
@Override
|
|
|
public String selfSubmit(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
|
|
|
+ //------初始编号信息------
|
|
|
+ this.initBuildNumber(dto);
|
|
|
+
|
|
|
+ //------初始当前填报的表------
|
|
|
+ this.initTrialTabIds(dto);
|
|
|
+
|
|
|
+ //------新增或编辑------
|
|
|
+ this.saveOrUpdate(dto);
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getId())) {
|
|
|
+ //------获取最新试验记录------
|
|
|
+ TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
|
|
|
+
|
|
|
+ //------编辑时生成为Null的记录表编号或报告单编号------
|
|
|
+ this.reBuildNumber(obj, dto);
|
|
|
+
|
|
|
+ //------保存实体表数据、试验记录信息、生成PDF------
|
|
|
+ this.submitTrialData(obj, dto);
|
|
|
+
|
|
|
+ //------关联原材料检测报告------
|
|
|
+ this.rawMaterialSubmitRelation(dto, obj);
|
|
|
+
|
|
|
+ //------关联取样信息------
|
|
|
+ this.recordSampleSubmit(dto, obj);
|
|
|
+
|
|
|
+ //------新增设备使用记录信息------
|
|
|
+ this.trialDeviceUseService.addDeviceUseInfo(dto);
|
|
|
+ }
|
|
|
+ return dto.getId().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initBuildNumber(TrialSelfInspectionRecordDTO dto) {
|
|
|
if (ObjectUtil.isEmpty(dto.getId()) && StringUtils.isNotEmpty(dto.getTableType())) {
|
|
|
//构建记录表编号、报告单编号
|
|
|
this.buildNumber(dto);
|
|
|
-
|
|
|
- //任务流程状态初始化未上报
|
|
|
dto.setTaskStatus("未上报");
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //初始化tabIds
|
|
|
+ private void initTrialTabIds(TrialSelfInspectionRecordDTO dto) {
|
|
|
JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
|
|
|
List<String> tableIds = new ArrayList<>();
|
|
|
for (int i = 0; i < dataArray.size(); i++) {
|
|
|
String pkeyId = dataArray.getJSONObject(i).getString("pkeyId");
|
|
|
tableIds.add(pkeyId);
|
|
|
}
|
|
|
- String join = org.apache.commons.lang.StringUtils.join(tableIds, ",");
|
|
|
+ List<String> ids = tableIds.stream().distinct().collect(Collectors.toList());
|
|
|
+ String join = org.apache.commons.lang.StringUtils.join(ids, ",");
|
|
|
dto.setTableIds(join);
|
|
|
|
|
|
- this.saveOrUpdate(dto);
|
|
|
-
|
|
|
- if (ObjectUtil.isNotEmpty(dto.getId())) {
|
|
|
- //获取当前最新的试验记录信息
|
|
|
- TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
|
|
|
-
|
|
|
- //编辑时生成记录表编号或报告单编号,如果新增时不是两种类型表都填报过,那么有一项编号为Null
|
|
|
- if (StringUtils.isEmpty(obj.getRecordNo()) && dto.getTableType().contains("1")) {
|
|
|
- this.buildNumber(dto);
|
|
|
- this.saveOrUpdate(dto);
|
|
|
- } else if (StringUtils.isEmpty(obj.getReportNo()) && dto.getTableType().contains("2")) {
|
|
|
- this.buildNumber(dto);
|
|
|
- this.saveOrUpdate(dto);
|
|
|
- }
|
|
|
-
|
|
|
- //------保存实体表数据、试验记录信息、生成pdf------
|
|
|
- try {
|
|
|
- String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
|
|
|
- if (StringUtils.isNotEmpty(pdfURL)) {
|
|
|
- //修改合并pdf
|
|
|
- this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).eq(TrialSelfInspectionRecord::getId, dto.getId()));
|
|
|
+ // TODO 如果前端处理了隐藏表入参的情况(即:隐藏表单pKeyId不传),那么接口就不处理
|
|
|
+ /*//获取按钮状态,是否为隐藏表单,移除隐藏表单(编辑时)
|
|
|
+ if (ObjectUtils.isNotEmpty(dto.getId())) {
|
|
|
+ List<TrialSelfDataRecord> tabStatus = jdbcTemplate.query("select is_buss_show,tab_id from u_trial_self_data_record where record_id = " + dto.getId(), new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
|
|
|
+ if (tabStatus.size() > 0) {
|
|
|
+ Map<Long, TrialSelfDataRecord> collect = tabStatus.stream().collect(Collectors.toMap(TrialSelfDataRecord::getTabId, Function.identity()));
|
|
|
+ List<Long> pKeyIds = Func.toLongList(dto.getTableIds());
|
|
|
+ List<Long> addPkeyIds = new ArrayList<>();
|
|
|
+ for (Long pId : pKeyIds) {
|
|
|
+ TrialSelfDataRecord record = collect.get(pId);
|
|
|
+ if (record != null) {
|
|
|
+ //隐藏的不添加
|
|
|
+ if (!new Integer(2).equals(record.getIsBussShow())) {
|
|
|
+ addPkeyIds.add(pId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //未生成记录的添加进去
|
|
|
+ addPkeyIds.add(pId);
|
|
|
+ }
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- throw new ServiceException("保存实体表数据生成pdf时发生异常" + e.getMessage());
|
|
|
+ //重新赋值
|
|
|
+ String joinNew = org.apache.commons.lang.StringUtils.join(addPkeyIds, ",");
|
|
|
+ dto.setTableIds(joinNew);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ //获取按钮状态,是否为隐藏表单,移除隐藏表单(新增时)
|
|
|
+ String tablePkeyIds = dto.getTableIds();
|
|
|
+ List<WbsTreePrivate> tableList = jdbcTemplate.query("select is_buss_show,p_key_id from m_wbs_tree_private where status = 1 and p_key_id in(" + tablePkeyIds + ")", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
+ List<Long> addPkeyIds = tableList.stream().filter(f -> ObjectUtils.isNotEmpty(f.getIsBussShow()) && !(new Integer(2).equals(f.getIsBussShow()))).map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //重新赋值
|
|
|
+ String joinNew = org.apache.commons.lang.StringUtils.join(addPkeyIds, ",");
|
|
|
+ dto.setTableIds(joinNew);
|
|
|
+ }*/
|
|
|
+ }
|
|
|
|
|
|
- //------关联原材料检测报告------
|
|
|
- RawMaterialSubmitRelationDTO relationDTO = new RawMaterialSubmitRelationDTO();
|
|
|
- relationDTO.setId(obj.getId().toString());
|
|
|
- relationDTO.setIds(dto.getRawMaterialIds());
|
|
|
- relationDTO.setNodeId(dto.getNodeId().toString());
|
|
|
- relationDTO.setContractId(dto.getContractId().toString());
|
|
|
- relationDTO.setProjectId(dto.getProjectId());
|
|
|
- relationDTO.setType(dto.getType());
|
|
|
- this.rawMaterialSubmitRelation(relationDTO, obj);
|
|
|
-
|
|
|
- //------关联取样信息------
|
|
|
- RecordSampleSubmitDTO recordSampleSubmitDTO = new RecordSampleSubmitDTO();
|
|
|
- recordSampleSubmitDTO.setId(obj.getId());
|
|
|
- recordSampleSubmitDTO.setSampleIds(dto.getSampleIds());
|
|
|
- this.recordSampleSubmit(recordSampleSubmitDTO);
|
|
|
-
|
|
|
- //------新增设备使用记录信息------
|
|
|
- this.trialDeviceUseService.addDeviceUseInfo(dto);
|
|
|
+ private void reBuildNumber(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) {
|
|
|
+ if (StringUtils.isEmpty(obj.getRecordNo()) && dto.getTableType().contains("1")) {
|
|
|
+ this.buildNumber(dto);
|
|
|
+ this.saveOrUpdate(dto);
|
|
|
+ } else if (StringUtils.isEmpty(obj.getReportNo()) && dto.getTableType().contains("2")) {
|
|
|
+ this.buildNumber(dto);
|
|
|
+ this.saveOrUpdate(dto);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //返回当前记录id
|
|
|
- return dto.getId().toString();
|
|
|
+ @Async
|
|
|
+ public void submitTrialData(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) {
|
|
|
+ try {
|
|
|
+ String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
|
|
|
+ if (StringUtils.isNotEmpty(pdfURL)) {
|
|
|
+ this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).eq(TrialSelfInspectionRecord::getId, dto.getId()));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
@Async
|
|
|
- public boolean recordSampleSubmit(RecordSampleSubmitDTO dto) {
|
|
|
+ public boolean recordSampleSubmit(TrialSelfInspectionRecordDTO dto1, TrialSelfInspectionRecord obj) {
|
|
|
+ RecordSampleSubmitDTO dto = new RecordSampleSubmitDTO();
|
|
|
+ dto.setId(obj.getId());
|
|
|
+ dto.setSampleIds(dto1.getSampleIds());
|
|
|
if (ObjectUtil.isEmpty(dto.getId())) {
|
|
|
throw new ServiceException("请先保存填报数据后,再关联取样信息");
|
|
|
}
|
|
@@ -801,6 +781,74 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Async
|
|
|
+ public boolean rawMaterialSubmitRelation(TrialSelfInspectionRecordDTO dto1, TrialSelfInspectionRecord obj) throws FileNotFoundException {
|
|
|
+ RawMaterialSubmitRelationDTO dto = new RawMaterialSubmitRelationDTO();
|
|
|
+ dto.setId(dto1.getId().toString());
|
|
|
+ dto.setIds(dto1.getRawMaterialIds());
|
|
|
+ dto.setNodeId(dto1.getNodeId().toString());
|
|
|
+ dto.setContractId(dto1.getContractId().toString());
|
|
|
+ dto.setProjectId(dto1.getProjectId());
|
|
|
+ dto.setType(dto1.getType());
|
|
|
+ if (ObjectUtil.isEmpty(dto.getId())) {
|
|
|
+ throw new ServiceException("请先保存填报数据后,再关联原材检测报告信息");
|
|
|
+ } else {
|
|
|
+ if (ObjectUtil.isNotEmpty(obj) && (("已审批").equals(obj.getTaskStatus()) || ("待审批").equals(obj.getTaskStatus()))) {
|
|
|
+ throw new ServiceException("当前填报数据已上报,无法进行关联操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增或编辑
|
|
|
+ if (StringUtils.isNotEmpty(dto.getIds())) {
|
|
|
+ //当前关联的原材料记录id
|
|
|
+ List<String> ids = Func.toStrList(dto.getIds());
|
|
|
+
|
|
|
+ //获取原材料的pdf
|
|
|
+ List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
|
|
|
+ .select(TrialSelfInspectionRecord::getPdfUrl, TrialSelfInspectionRecord::getId)
|
|
|
+ .in(TrialSelfInspectionRecord::getId, ids).eq(TrialSelfInspectionRecord::getStatus, 1));
|
|
|
+ List<TrialSelfInspectionRecord> recordObjList = recordList.stream().filter(f -> !f.getId().equals(Long.parseLong(dto.getId()))).collect(Collectors.toList());
|
|
|
+ List<String> pdfUrlAll = new ArrayList<>();
|
|
|
+ if (recordObjList.size() > 0) {
|
|
|
+ pdfUrlAll.addAll(recordObjList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pdfUrlAll.size() > 0) {
|
|
|
+ String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ String listPdf = filePath + "/pdf/" + dto.getNodeId() + ".pdf";
|
|
|
+ File tabPDF = ResourceUtil.getFile(listPdf);
|
|
|
+ if (tabPDF.exists()) {
|
|
|
+ tabPDF.delete();
|
|
|
+ }
|
|
|
+ FileUtils.mergePdfPublicMethods(pdfUrlAll, listPdf);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(dto.getNodeId() + ".pdf", listPdf);
|
|
|
+
|
|
|
+ //删除记录关系
|
|
|
+ String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
|
|
|
+ jdbcTemplate.execute(sql1);
|
|
|
+ //新增记录关系
|
|
|
+ for (String recordId : ids) {
|
|
|
+ if (!recordId.equals(dto.getId())) {
|
|
|
+ String sql2 = "insert into u_trial_raw_material_self_record(id,self_record_id,raw_material_record_id,old_pdf_url) values(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + recordId + ",'" + bladeFile.getLink() + "')";
|
|
|
+ jdbcTemplate.execute(sql2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //删除全部
|
|
|
+ String sql = "select id from u_trial_raw_material_self_record where self_record_id =" + dto.getId();
|
|
|
+ List<TrialRawMaterialSelfRecord> recordList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
|
|
|
+ if (recordList.size() > 0) {
|
|
|
+ String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
|
|
|
+ jdbcTemplate.execute(sql1);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
private void buildNumber(TrialSelfInspectionRecordDTO dto) {
|
|
|
StringSPUtils spUtils = new StringSPUtils();
|
|
|
List<TrialSelfInspectionRecord> result = baseMapper.selectAll(dto.getNodeId(), dto.getContractId());
|
|
@@ -960,8 +1008,7 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public IPage<TrialSelfInspectionRecordVO> trialDataPage
|
|
|
- (IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) {
|
|
|
+ public IPage<TrialSelfInspectionRecordVO> trialDataPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) {
|
|
|
QueryWrapper<TrialSelfInspectionRecord> queryWrapper = Condition.getQueryWrapper(dto);
|
|
|
if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getStartTime()) && org.apache.commons.lang.StringUtils.isNotEmpty(dto.getEndTime())) {
|
|
|
String endTime = dto.getEndTime();
|