|
@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUnit;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.unit.DataUnit;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aspose.words.*;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -138,6 +139,9 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
@Autowired
|
|
|
private ZhcxProjectDeviceIndicatorService projectDeviceIndicatorService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ZhcxCommissionCheckBaseInfoService zhcxCommissionCheckBaseInfoService;
|
|
|
+
|
|
|
@PostConstruct
|
|
|
public void info() {
|
|
|
commonFeginClient = autoCommonFeginClient;
|
|
@@ -2290,4 +2294,137 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
}
|
|
|
log.info("大屏数据源(试车)存储结束");
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R generateStandardLibrary(String checkId) {
|
|
|
+ // 试车检查报告主表数据
|
|
|
+ ZhcxCommissionCheckDo commissionCheckDo = this.getById(checkId);
|
|
|
+ if(Objects.isNull(commissionCheckDo)){
|
|
|
+ return R.error("试车检查报告主表数据获取异常");
|
|
|
+ }
|
|
|
+ // 新的产品类型的名称 工号+项目名称+引用的标准库名称
|
|
|
+ String newTypeName = commissionCheckDo.getProjectcode()
|
|
|
+ +commissionCheckDo.getProjectname()
|
|
|
+ +commissionCheckDo.getProductType();
|
|
|
+ // 查询标准库是否已存在
|
|
|
+ LambdaQueryWrapper<ZhcxCommissionCheckBaseInfoDo> infoDoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ infoDoLambdaQueryWrapper.eq(ZhcxCommissionCheckBaseInfoDo::getDeleted,"0")
|
|
|
+ .eq(ZhcxCommissionCheckBaseInfoDo::getProducttype,newTypeName);
|
|
|
+ List<ZhcxCommissionCheckBaseInfoDo> baseInfoDos = zhcxCommissionCheckBaseInfoService.list(infoDoLambdaQueryWrapper);
|
|
|
+
|
|
|
+ // 标准库主表id
|
|
|
+ String newPid = "";
|
|
|
+ if(baseInfoDos.isEmpty()){
|
|
|
+ ZhcxCommissionCheckBaseInfoDo infoDo = new ZhcxCommissionCheckBaseInfoDo();
|
|
|
+ infoDo.setId(SecurityUtil.getUUID());
|
|
|
+ infoDo.setProducttype(newTypeName);
|
|
|
+ infoDo.setStatus("有效");
|
|
|
+ zhcxCommissionCheckBaseInfoService.save(infoDo);
|
|
|
+ newPid = infoDo.getId();
|
|
|
+ }else {
|
|
|
+ newPid = baseInfoDos.get(0).getId();
|
|
|
+ // 去删除原有的树子表数据和子表内容
|
|
|
+ baseMapper.deleteBaseInfoDetailByPid(newPid);
|
|
|
+ baseMapper.deleteBaseInfoTreeByPid(newPid);
|
|
|
+ }
|
|
|
+ // 标准库主表id
|
|
|
+ //String newPid = checkBaseInfoDo.getId();
|
|
|
+ // 生成一个随机的6位数字
|
|
|
+ String randomCode = RandomUtil.randomString(6);
|
|
|
+ // 结果集
|
|
|
+ List<ZhcxCommissionCheckBaseInfoDetailDo> resultBaseInfoList = new ArrayList<>();
|
|
|
+ List<ZhcxCommissionCheckBaseInfoTreeDo> resultBaseTreeList = new ArrayList<>();
|
|
|
+ // 试车检查报告子表/树表
|
|
|
+ LambdaQueryWrapper<ZhcxCommissionCheckDetailTreeDo> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ wrapper1.eq(ZhcxCommissionCheckDetailTreeDo::getBaseinfoid,checkId)
|
|
|
+ .eq(ZhcxCommissionCheckDetailTreeDo::getDeleted,"0");
|
|
|
+ List<ZhcxCommissionCheckDetailTreeDo> treeDoList = zhcxCommissionCheckDetailTreeService.list(wrapper1);
|
|
|
+ if(treeDoList.isEmpty()){
|
|
|
+ return R.error("树数据为空");
|
|
|
+ }
|
|
|
+ for (ZhcxCommissionCheckDetailTreeDo zhcxCommissionCheckDetailTreeDo : treeDoList) {
|
|
|
+ ZhcxCommissionCheckBaseInfoTreeDo baseInfoTreeDo = new ZhcxCommissionCheckBaseInfoTreeDo();
|
|
|
+ baseInfoTreeDo.setId(zhcxCommissionCheckDetailTreeDo.getId().split("_")[0]+randomCode);
|
|
|
+ if(StringUtils.isNotEmpty(zhcxCommissionCheckDetailTreeDo.getPid())){
|
|
|
+ if(zhcxCommissionCheckDetailTreeDo.getPid().equals("-1")){
|
|
|
+ baseInfoTreeDo.setPid("-1");
|
|
|
+ }else {
|
|
|
+ baseInfoTreeDo.setPid(zhcxCommissionCheckDetailTreeDo.getPid().split("_")[0]+randomCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ baseInfoTreeDo.setName(zhcxCommissionCheckDetailTreeDo.getName());
|
|
|
+ baseInfoTreeDo.setSort(zhcxCommissionCheckDetailTreeDo.getSort());
|
|
|
+ baseInfoTreeDo.setBaseinfoid(newPid);
|
|
|
+ // 处理fullpid
|
|
|
+ if(Objects.nonNull(zhcxCommissionCheckDetailTreeDo.getFullpid())){
|
|
|
+ // 分割字符串
|
|
|
+ String[] split = zhcxCommissionCheckDetailTreeDo.getFullpid().split(",");
|
|
|
+ StringBuilder newString = new StringBuilder();
|
|
|
+ // 遍历分割后的数组
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String str = split[i];
|
|
|
+ if (!str.isEmpty()) {
|
|
|
+ newString.append(",").append(str).append(randomCode);
|
|
|
+ } else if (i > 0) {
|
|
|
+ newString.append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //String result = newString.toString().replaceFirst("^,", "");
|
|
|
+ baseInfoTreeDo.setFullpid(newString.toString());
|
|
|
+ }
|
|
|
+ baseInfoTreeDo.setLevel(zhcxCommissionCheckDetailTreeDo.getLevel());
|
|
|
+ baseInfoTreeDo.setTreecode(zhcxCommissionCheckDetailTreeDo.getTreecode());
|
|
|
+ resultBaseTreeList.add(baseInfoTreeDo);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ZhcxCommissionCheckDetailDo> wrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ wrapper2.eq(ZhcxCommissionCheckDetailDo::getPid,checkId)
|
|
|
+ .eq(ZhcxCommissionCheckDetailDo::getDeleted,"0");
|
|
|
+ List<ZhcxCommissionCheckDetailDo> detailDoList = zhcxCommissionCheckDetailService.list(wrapper2);
|
|
|
+ if(detailDoList.isEmpty()){
|
|
|
+ return R.error("试车检查内容为空");
|
|
|
+ }
|
|
|
+ for (ZhcxCommissionCheckDetailDo checkDetailDo : detailDoList) {
|
|
|
+ ZhcxCommissionCheckBaseInfoDetailDo infoDetailDo = new ZhcxCommissionCheckBaseInfoDetailDo();
|
|
|
+ infoDetailDo.setId(SecurityUtil.getUUID());
|
|
|
+ //infoDetailDo.setChapterno(checkDetailDo.getChapterno());
|
|
|
+ infoDetailDo.setClassification(checkDetailDo.getClassification());
|
|
|
+ infoDetailDo.setClassificationtwo(checkDetailDo.getClassificationtwo());
|
|
|
+ infoDetailDo.setChtitle(checkDetailDo.getChtitle());
|
|
|
+ infoDetailDo.setEntitle(checkDetailDo.getEntitle());
|
|
|
+ infoDetailDo.setChtestcontent(checkDetailDo.getChtestcontent());
|
|
|
+ infoDetailDo.setEntestcontent(checkDetailDo.getEntestcontent());
|
|
|
+ infoDetailDo.setTestmethod(checkDetailDo.getTestmethod());
|
|
|
+ if(StringUtils.isNotEmpty(checkDetailDo.getTesttime())){
|
|
|
+ infoDetailDo.setTesttime(new BigDecimal(checkDetailDo.getTesttime()));
|
|
|
+ }
|
|
|
+ infoDetailDo.setStatus(checkDetailDo.getStatus());
|
|
|
+ infoDetailDo.setPid(newPid);
|
|
|
+ // 组装全路径
|
|
|
+ StringBuilder newTreeFullId = new StringBuilder();
|
|
|
+ if(StringUtils.isNotEmpty(checkDetailDo.getOnelevelclassification())){
|
|
|
+ infoDetailDo.setOnelevelclassification(checkDetailDo.getOnelevelclassification()+randomCode);
|
|
|
+ newTreeFullId.append(",").append(infoDetailDo.getOnelevelclassification());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(checkDetailDo.getSecondlevelclassification())){
|
|
|
+ infoDetailDo.setSecondlevelclassification(checkDetailDo.getSecondlevelclassification()+randomCode);
|
|
|
+ newTreeFullId.append(",").append(infoDetailDo.getSecondlevelclassification());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(checkDetailDo.getThreelevelclassification())){
|
|
|
+ infoDetailDo.setThreelevelclassification(checkDetailDo.getThreelevelclassification()+randomCode);
|
|
|
+ newTreeFullId.append(",").append(infoDetailDo.getThreelevelclassification());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(checkDetailDo.getFouronelevelclassification())){
|
|
|
+ infoDetailDo.setFouronelevelclassification(checkDetailDo.getFouronelevelclassification()+randomCode);
|
|
|
+ newTreeFullId.append(",").append(infoDetailDo.getFouronelevelclassification());
|
|
|
+ }
|
|
|
+ infoDetailDo.setTestaddress(checkDetailDo.getTestaddress());
|
|
|
+ infoDetailDo.setTreefullid(newTreeFullId.toString());
|
|
|
+ resultBaseInfoList.add(infoDetailDo);
|
|
|
+ }
|
|
|
+ // 保存结果集
|
|
|
+ zhcxCommissionCheckBaseInfoDetailService.saveBatch(resultBaseInfoList);
|
|
|
+ zhcxCommissionCheckBaseInfoTreeService.saveBatch(resultBaseTreeList);
|
|
|
+ return R.ok("操作成功");
|
|
|
+ }
|
|
|
}
|