ソースを参照

Merge remote-tracking branch 'origin/master'

zhuang 5 ヶ月 前
コミット
561ffd48ad

+ 16 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxCommissionCheckBaseInfoDao.java

@@ -0,0 +1,16 @@
+package com.rongwei.bscommon.sys.dao;
+
+import com.rongwei.bsentity.domain.ZhcxCommissionCheckBaseInfoDo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 试车检查标准库 Mapper 接口
+ * </p>
+ *
+ * @author xuan
+ * @since 2025-02-06
+ */
+public interface ZhcxCommissionCheckBaseInfoDao extends BaseMapper<ZhcxCommissionCheckBaseInfoDo> {
+
+}

+ 12 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxCommissionCheckDao.java

@@ -83,4 +83,16 @@ public interface ZhcxCommissionCheckDao extends BaseMapper<ZhcxCommissionCheckDo
      * @return
      */
     List<LargeScreenCheckVo> getLargeScreenData(Map<String, Object> map);
+
+    /**
+     * 删除标准库子表数据(伪删)
+     * @param pid 父id
+     */
+    void deleteBaseInfoDetailByPid(@Param("pid") String pid);
+
+    /**
+     * 删除标准库子表数据(伪删)
+     * @param pid 父id
+     */
+    void deleteBaseInfoTreeByPid(@Param("pid") String pid);
 }

+ 16 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxCommissionCheckBaseInfoService.java

@@ -0,0 +1,16 @@
+package com.rongwei.bscommon.sys.service;
+
+import com.rongwei.bsentity.domain.ZhcxCommissionCheckBaseInfoDo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 试车检查标准库 服务类
+ * </p>
+ *
+ * @author xuan
+ * @since 2025-02-06
+ */
+public interface ZhcxCommissionCheckBaseInfoService extends IService<ZhcxCommissionCheckBaseInfoDo> {
+
+}

+ 7 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxCommissionCheckService.java

@@ -103,4 +103,11 @@ public interface ZhcxCommissionCheckService extends IService<ZhcxCommissionCheck
      * 大屏数据源(试车)
      */
     void largeScreenData(Map<String,Object> map);
+
+    /**
+     * 试车检查报告生成标准库
+      * @param checkId 试车检查报告主表id
+     * @return
+     */
+    R generateStandardLibrary(String checkId);
 }

+ 20 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxCommissionCheckBaseInfoServiceImpl.java

@@ -0,0 +1,20 @@
+package com.rongwei.bscommon.sys.service.impl;
+
+import com.rongwei.bsentity.domain.ZhcxCommissionCheckBaseInfoDo;
+import com.rongwei.bscommon.sys.dao.ZhcxCommissionCheckBaseInfoDao;
+import com.rongwei.bscommon.sys.service.ZhcxCommissionCheckBaseInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 试车检查标准库 服务实现类
+ * </p>
+ *
+ * @author xuan
+ * @since 2025-02-06
+ */
+@Service
+public class ZhcxCommissionCheckBaseInfoServiceImpl extends ServiceImpl<ZhcxCommissionCheckBaseInfoDao, ZhcxCommissionCheckBaseInfoDo> implements ZhcxCommissionCheckBaseInfoService {
+
+}

+ 137 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxCommissionCheckServiceImpl.java

@@ -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("操作成功");
+    }
 }

+ 9 - 1
business-common/src/main/resources/mybatis/business/ZhcxCommissionCheckDao.xml

@@ -4,13 +4,21 @@
 <mapper namespace="com.rongwei.bscommon.sys.dao.ZhcxCommissionCheckDao">
 
     <update id="deleteCheckDetailByPid" >
-        UPDATE ZHCX_COMMISSION_CHECK_DETAIL SET DELETED = '1' WHERE PID = #{pid}
+        UPDATE ZHCX_COMMISSION_CHECK_DETAIL SET DELETED = '1' WHERE PID = #{pid} and DELETED = '0'
     </update>
 
     <delete id="deleteTreeByPid">
         DELETE FROM INCONTROL.ZHCX_COMMISSION_CHECK_DETAIL_TREE WHERE BASEINFOID = #{pid}
     </delete>
 
+    <delete id="deleteBaseInfoTreeByPid">
+        DELETE FROM ZHCX_COMMISSION_CHECK_BASE_INFO_TREE  WHERE BASEINFOID = #{pid} and DELETED = '0'
+    </delete>
+
+    <delete id="deleteBaseInfoDetailByPid">
+        DELETE FROM ZHCX_COMMISSION_CHECK_BASE_INFO_DETAIL  WHERE PID = #{pid} and DELETED = '0'
+    </delete>
+
     <select id="checkedShippedByMasterId" resultType="java.lang.Integer">
         SELECT COUNT(*) AS count
         FROM INCONTROL.ZHCX_PROJECT_MANAGE_RECTIFY_BATCH t1

+ 61 - 0
business-entity/src/main/java/com/rongwei/bsentity/domain/ZhcxCommissionCheckBaseInfoDo.java

@@ -0,0 +1,61 @@
+package com.rongwei.bsentity.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.rongwei.rwcommon.base.BaseDo;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 试车检查标准库
+ * </p>
+ *
+ * @author xuan
+ * @since 2025-02-06
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@TableName("ZHCX_COMMISSION_CHECK_BASE_INFO")
+public class ZhcxCommissionCheckBaseInfoDo extends BaseDo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 主键
+     */
+    @TableField("ID")
+    private String id;
+    /**
+     * 租户id
+     */
+    @TableField("TENANTID")
+    private String tenantid;
+    /**
+     * 扩展json格式配置
+     */
+    @TableField("ROPTION")
+    private String roption;
+    /**
+     * 产品类型
+     */
+    @TableField("PRODUCTTYPE")
+    private String producttype;
+    /**
+     * 状态
+     */
+    @TableField("STATUS")
+    private String status;
+    /**
+     * 备注
+     */
+    @TableField("NOTES")
+    private String notes;
+
+
+}

+ 20 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxCommissionCheckBaseInfoController.java

@@ -0,0 +1,20 @@
+package com.rongwei.bsserver.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 试车检查标准库 前端控制器
+ * </p>
+ *
+ * @author xuan
+ * @since 2025-02-06
+ */
+@RestController
+@RequestMapping("/zhcxCommissionCheckBaseInfo")
+public class ZhcxCommissionCheckBaseInfoController {
+
+}
+

+ 36 - 18
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxCommissionCheckController.java

@@ -17,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * <p>
@@ -39,11 +40,12 @@ public class ZhcxCommissionCheckController {
 
     /**
      * 试车报告新增
+     *
      * @param checkDTO 参数
      * @return 响应状态
      */
     @PostMapping("/commissionCheckAdd")
-    public R commissionCheckAdd(@RequestBody CommissionCheckDTO checkDTO){
+    public R commissionCheckAdd(@RequestBody CommissionCheckDTO checkDTO) {
         try {
             log.info("进入接口:/zhcxCommissionCheck/commissionCheckAdd,入参:{}", checkDTO);
             return commissionCheckService.commissionCheckAdd(checkDTO);
@@ -55,11 +57,12 @@ public class ZhcxCommissionCheckController {
 
     /**
      * 试车报告子表同步更新其他机台
+     *
      * @param detailDTO 参数
      * @return 响应状态
      */
     @PostMapping("/updateSynchronizationDetail")
-    public R updateSynchronizationDetail(@RequestBody CheckDetailDTO detailDTO){
+    public R updateSynchronizationDetail(@RequestBody CheckDetailDTO detailDTO) {
         try {
             log.info("进入接口:/zhcxCommissionCheck/updateSynchronizationDetail,入参:{}", detailDTO);
             return commissionCheckService.updateSynchronizationDetail(detailDTO);
@@ -71,33 +74,33 @@ public class ZhcxCommissionCheckController {
 
     @PostMapping("wordExport")
     @ApiOperation("试车检查报告word导出/预览")
-    public R wordExport(@RequestBody Map<String,Object> map, HttpServletResponse response) throws Exception {
+    public R wordExport(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
         try {
-            return commissionCheckService.exportFile(map,response);
+            return commissionCheckService.exportFile(map, response);
         } catch (Exception e) {
-            ExceptionUtils.printExceptionDetail(e,"试车报告导出/预览异常");
+            ExceptionUtils.printExceptionDetail(e, "试车报告导出/预览异常");
             return R.error("试车报告导出/预览异常");
         }
     }
 
     @PostMapping("wordExportPrj")
     @ApiOperation("试车检查报告word导出")
-    public R wordExportPrj(@RequestBody Map<String,Object> map, HttpServletResponse response) throws Exception {
+    public R wordExportPrj(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
         try {
-            return commissionCheckService.wordExportPrj(map,response);
+            return commissionCheckService.wordExportPrj(map, response);
         } catch (Exception e) {
-            ExceptionUtils.printExceptionDetail(e,"试车报告导出异常");
+            ExceptionUtils.printExceptionDetail(e, "试车报告导出异常");
             return R.error("试车报告导出异常");
         }
     }
 
     @PostMapping("wordExportStandard")
     @ApiOperation("试车标准库word导出")
-    public R wordExportStandard(@RequestBody Map<String,Object> map, HttpServletResponse response) throws Exception {
+    public R wordExportStandard(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
         try {
-            return commissionCheckService.wordExportStandard(map,response);
+            return commissionCheckService.wordExportStandard(map, response);
         } catch (Exception e) {
-            ExceptionUtils.printExceptionDetail(e,"试车报告标准库导出异常");
+            ExceptionUtils.printExceptionDetail(e, "试车报告标准库导出异常");
             return R.error("试车报告标准库导出异常");
         }
     }
@@ -118,27 +121,42 @@ public class ZhcxCommissionCheckController {
 
     @RequestMapping("importStandard")
     @ResponseBody
-    public R importStandard(@RequestParam MultipartFile file,String mainId) {
-        if (file == null){
+    public R importStandard(@RequestParam MultipartFile file, String mainId) {
+        if (file == null) {
             return R.error("文件解析失败");
         }
-        String errorMsg = fileCheckDetail.fileCheckDetail(file,"23621496edbd4c7faf69401ddee6156e");
-        if (StringUtils.isNotBlank(errorMsg)){
+        String errorMsg = fileCheckDetail.fileCheckDetail(file, "23621496edbd4c7faf69401ddee6156e");
+        if (StringUtils.isNotBlank(errorMsg)) {
             return R.error(errorMsg);
         }
         try {
-            return commissionCheckService.importStandard(file,mainId);
+            return commissionCheckService.importStandard(file, mainId);
         } catch (Exception e) {
-            ExceptionUtils.printExceptionDetail(e,"标准库导入异常");
+            ExceptionUtils.printExceptionDetail(e, "标准库导入异常");
             return R.error("标准库导入异常");
         }
     }
 
     @RequestMapping("largeScreenData")
     @ApiOperation("大屏数据源(试车)")
-    public R largeScreenData(@RequestBody Map<String,Object> map) {
+    public R largeScreenData(@RequestBody Map<String, Object> map) {
         commissionCheckService.largeScreenData(map);
         return R.ok();
     }
+
+    @RequestMapping("generateStandardLibrary")
+    @ApiOperation("试车检查报告生成标准库")
+    public R generateStandardLibrary(@RequestBody Map<String, Object> map) {
+        Object checkId = map.get("checkId");
+        if (Objects.isNull(checkId)) {
+            return R.error("数据异常,请联系管理员");
+        }
+        try {
+            return commissionCheckService.generateStandardLibrary((String) checkId);
+        } catch (Exception e) {
+            ExceptionUtils.printExceptionDetail(e, "生成标准库异常");
+            return R.error("生成标准库异常");
+        }
+    }
 }