Browse Source

保存登记

wangming 3 tuần trước cách đây
mục cha
commit
48942b41ae

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

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.service;
 
 import com.rongwei.bsentity.domain.ZchxNdtProjectNdtCheckDo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.dto.ndt.EnrollNdtExecuteRequest;
 
 /**
  * <p>
@@ -13,4 +14,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ZchxNdtProjectNdtCheckService extends IService<ZchxNdtProjectNdtCheckDo> {
 
+    /**
+     * 保存登记
+     *
+     * @param req
+     */
+    void saveEntry(EnrollNdtExecuteRequest req);
 }

+ 17 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZchxNdtProjectNdtCheckWeldSeamService.java

@@ -3,6 +3,8 @@ package com.rongwei.bscommon.sys.service;
 import com.rongwei.bsentity.domain.ZchxNdtProjectNdtCheckWeldSeamDo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * NDT检测-项目NDT单据_焊缝 服务类
@@ -13,4 +15,19 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ZchxNdtProjectNdtCheckWeldSeamService extends IService<ZchxNdtProjectNdtCheckWeldSeamDo> {
 
+    /**
+     * 完成焊缝
+     *
+     * @param checkId
+     * @param completedWeldList
+     */
+    void completeWeld(String checkId, List<String> completedWeldList);
+
+    /**
+     * 获取已完成焊缝数量
+     *
+     * @param libId
+     * @return
+     */
+    int getCompleted(String libId);
 }

+ 6 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZchxNdtProjectNdtLibService.java

@@ -13,4 +13,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ZchxNdtProjectNdtLibService extends IService<ZchxNdtProjectNdtLibDo> {
 
+    /**
+     * 完成焊缝
+     *
+     * @param id
+     */
+    void complete(String id);
 }

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

@@ -1,11 +1,19 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.rongwei.bscommon.sys.service.ZchxNdtProjectNdtCheckWeldSeamService;
+import com.rongwei.bscommon.sys.service.ZchxNdtProjectNdtLibService;
 import com.rongwei.bsentity.domain.ZchxNdtProjectNdtCheckDo;
 import com.rongwei.bscommon.sys.dao.ZchxNdtProjectNdtCheckDao;
 import com.rongwei.bscommon.sys.service.ZchxNdtProjectNdtCheckService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bsentity.dto.ndt.EnrollNdtExecuteRequest;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
+
 /**
  * <p>
  * NDT检测-项目NDT单据 服务实现类
@@ -17,4 +25,32 @@ import org.springframework.stereotype.Service;
 @Service
 public class ZchxNdtProjectNdtCheckServiceImpl extends ServiceImpl<ZchxNdtProjectNdtCheckDao, ZchxNdtProjectNdtCheckDo> implements ZchxNdtProjectNdtCheckService {
 
+
+    @Autowired
+    private ZchxNdtProjectNdtCheckWeldSeamService zchxNdtProjectNdtCheckWeldSeamService;
+    @Autowired
+    private ZchxNdtProjectNdtLibService zchxNdtProjectNdtLibService;
+
+    /**
+     * 保存登记
+     *
+     * @param req
+     */
+    @Override
+    public void saveEntry(EnrollNdtExecuteRequest req) {
+
+        //修改明细状态
+        zchxNdtProjectNdtCheckWeldSeamService.completeWeld(req.getCheckId(), req.getWeldList());
+
+        //修改主表状态
+        final LambdaUpdateWrapper<ZchxNdtProjectNdtCheckDo> updateWrapper = Wrappers.lambdaUpdate();
+        updateWrapper.eq(ZchxNdtProjectNdtCheckDo::getId, req.getCheckId())
+                .set(ZchxNdtProjectNdtCheckDo::getDatastate, "20")
+                .set(ZchxNdtProjectNdtCheckDo::getInspecttime, new Date());
+        update(updateWrapper);
+
+        // 是否已全部完成
+        final ZchxNdtProjectNdtCheckDo checkDo = getById(req.getCheckId()); //申请单
+        zchxNdtProjectNdtLibService.complete(checkDo.getLibid());
+    }
 }

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

@@ -1,11 +1,19 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.rongwei.bsentity.domain.ZchxNdtProjectNdtCheckWeldSeamDo;
 import com.rongwei.bscommon.sys.dao.ZchxNdtProjectNdtCheckWeldSeamDao;
 import com.rongwei.bscommon.sys.service.ZchxNdtProjectNdtCheckWeldSeamService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
 /**
  * <p>
  * NDT检测-项目NDT单据_焊缝 服务实现类
@@ -17,4 +25,43 @@ import org.springframework.stereotype.Service;
 @Service
 public class ZchxNdtProjectNdtCheckWeldSeamServiceImpl extends ServiceImpl<ZchxNdtProjectNdtCheckWeldSeamDao, ZchxNdtProjectNdtCheckWeldSeamDo> implements ZchxNdtProjectNdtCheckWeldSeamService {
 
+    /**
+     * 完成焊缝
+     *
+     * @param checkId
+     * @param completedWeldList
+     */
+    @Override
+    public void completeWeld(String checkId, List<String> completedWeldList) {
+
+        // 所有设值为未完成
+        final LambdaUpdateWrapper<ZchxNdtProjectNdtCheckWeldSeamDo> updateUncomWrapper = Wrappers.lambdaUpdate();
+        updateUncomWrapper.set(ZchxNdtProjectNdtCheckWeldSeamDo::getResult, "20")
+                .notIn(ZchxNdtProjectNdtCheckWeldSeamDo::getWeldcode, completedWeldList)
+                .eq(ZchxNdtProjectNdtCheckWeldSeamDo::getCheckid, checkId);
+        update(updateUncomWrapper);
+
+        // 修改为完成
+        final LambdaUpdateWrapper<ZchxNdtProjectNdtCheckWeldSeamDo> updateComWrapper = Wrappers.lambdaUpdate();
+        updateUncomWrapper.set(ZchxNdtProjectNdtCheckWeldSeamDo::getResult, "10")
+                .in(ZchxNdtProjectNdtCheckWeldSeamDo::getWeldcode, completedWeldList)
+                .eq(ZchxNdtProjectNdtCheckWeldSeamDo::getCheckid, checkId);
+        update(updateComWrapper);
+    }
+
+    /**
+     * 获取已完成焊缝数量
+     *
+     * @param libId
+     * @return
+     */
+    @Override
+    public int getCompleted(String libId) { //查询已完成焊缝
+        final LambdaQueryWrapper<ZchxNdtProjectNdtCheckWeldSeamDo> queryResultComWrapper = Wrappers.lambdaQuery();
+        queryResultComWrapper.eq(ZchxNdtProjectNdtCheckWeldSeamDo::getLibid, libId)
+                .eq(ZchxNdtProjectNdtCheckWeldSeamDo::getResult, "10");
+        final List<ZchxNdtProjectNdtCheckWeldSeamDo> list = list(queryResultComWrapper);
+
+        return (int) list.stream().map(ZchxNdtProjectNdtCheckWeldSeamDo::getWeldcode).distinct().count();
+    }
 }

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

@@ -1,9 +1,16 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.rongwei.bscommon.sys.service.ZchxNdtProjectNdtCheckWeldSeamService;
+import com.rongwei.bscommon.sys.service.ZchxNdtProjectNdtWeldSeamService;
 import com.rongwei.bsentity.domain.ZchxNdtProjectNdtLibDo;
 import com.rongwei.bscommon.sys.dao.ZchxNdtProjectNdtLibDao;
 import com.rongwei.bscommon.sys.service.ZchxNdtProjectNdtLibService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bsentity.domain.ZchxNdtProjectNdtWeldSeamDo;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,4 +24,29 @@ import org.springframework.stereotype.Service;
 @Service
 public class ZchxNdtProjectNdtLibServiceImpl extends ServiceImpl<ZchxNdtProjectNdtLibDao, ZchxNdtProjectNdtLibDo> implements ZchxNdtProjectNdtLibService {
 
+    @Autowired
+    private ZchxNdtProjectNdtCheckWeldSeamService zchxNdtProjectNdtCheckWeldSeamService;
+    @Autowired
+    private ZchxNdtProjectNdtWeldSeamService zchxNdtProjectNdtWeldSeamService;
+
+    /**
+     * 完成焊缝
+     *
+     * @param id
+     */
+    @Override
+    public void complete(String id) {
+
+        final int completedCount = zchxNdtProjectNdtCheckWeldSeamService.getCompleted(id); //已完成数量
+
+        //总数
+        final LambdaQueryWrapper<ZchxNdtProjectNdtWeldSeamDo> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(ZchxNdtProjectNdtWeldSeamDo::getLibid, id);
+        final int count = zchxNdtProjectNdtWeldSeamService.count(queryWrapper);
+
+        final LambdaUpdateWrapper<ZchxNdtProjectNdtLibDo> updateWrapper = Wrappers.lambdaUpdate();
+        updateWrapper.eq(ZchxNdtProjectNdtLibDo::getId, id)
+                .set(ZchxNdtProjectNdtLibDo::getDatastate, completedCount == count ? "20" : "10");
+        update(updateWrapper);
+    }
 }

+ 19 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/ndt/EnrollNdtExecuteRequest.java

@@ -0,0 +1,19 @@
+package com.rongwei.bsentity.dto.ndt;
+
+import lombok.*;
+
+import java.util.List;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class EnrollNdtExecuteRequest {
+
+    /**申请单id*/
+    private String checkId;
+
+    /**焊缝编号列表*/
+    private List<String> weldList;
+}

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

@@ -1,6 +1,12 @@
 package com.rongwei.bsserver.controller;
 
 
+import com.rongwei.bscommon.sys.service.ZchxNdtProjectNdtCheckService;
+import com.rongwei.bsentity.dto.ndt.EnrollNdtExecuteRequest;
+import com.rongwei.rwcommon.base.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -16,5 +22,19 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/zchxNdtProjectNdtCheck")
 public class ZchxNdtProjectNdtCheckController {
 
+    @Autowired
+    private ZchxNdtProjectNdtCheckService service;
+
+    /**
+     * 保存登记
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("saveEntry")
+    public R saveEntry(@RequestBody EnrollNdtExecuteRequest req){
+        service.saveEntry(req);
+        return R.ok();
+    }
 }