Browse Source

BOM资料删除增加限制

chenw 7 years ago
parent
commit
347bc22dc9

+ 3 - 3
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Bom.java

@@ -7,7 +7,7 @@ import java.io.Serializable;
 import java.util.Date;
 import java.util.Date;
 
 
 public class Bom extends CommonBaseEntity implements Serializable {
 public class Bom extends CommonBaseEntity implements Serializable {
-    private Integer bo_motherid;
+    private Long bo_motherid;
 
 
     private String bo_mothercode;
     private String bo_mothercode;
 
 
@@ -75,11 +75,11 @@ public class Bom extends CommonBaseEntity implements Serializable {
         this.pr_orispeccode = pr_orispeccode;
         this.pr_orispeccode = pr_orispeccode;
     }
     }
 
 
-    public Integer getBo_motherid() {
+    public Long getBo_motherid() {
         return bo_motherid;
         return bo_motherid;
     }
     }
 
 
-    public void setBo_motherid(Integer bo_motherid) {
+    public void setBo_motherid(Long bo_motherid) {
         this.bo_motherid = bo_motherid;
         this.bo_motherid = bo_motherid;
     }
     }
 
 

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BomMapper.java

@@ -26,4 +26,6 @@ public interface BomMapper extends CommonBaseMapper<Bom> {
     int validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long company);
     int validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long company);
 
 
     List<Bom> getListData(@Param("condition") String condition, @Param("companyId") Long companyId);
     List<Bom> getListData(@Param("condition") String condition, @Param("companyId") Long companyId);
+
+    int getCountFromMake(Long id);
 }
 }

+ 16 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BomServiceImpl.java

@@ -112,9 +112,17 @@ public class BomServiceImpl extends CommonBaseServiceImpl<BomMapper, Bom> implem
         if(id == null || id <= 0){
         if(id == null || id <= 0){
             throw new BizException(BizExceptionCode.ILLEGAL_ID);
             throw new BizException(BizExceptionCode.ILLEGAL_ID);
         }
         }
+        //校验BOM资料是否已被使用
+        Long prodId = getMapper().selectByPrimaryKey(id).getBo_motherid();
+        int count = getMapper().getCountFromMake(prodId);
+        if (count > 0){
+            throw new BizException(BizExceptionCode.BIZ_RELDELETE);
+        }
+
         String code = getMapper().selectByPrimaryKey(id).getBo_mothercode();
         String code = getMapper().selectByPrimaryKey(id).getBo_mothercode();
-        getMapper().deleteByPrimaryKey(id);
         bomDetailMapper.deleteByFK(id);
         bomDetailMapper.deleteByFK(id);
+        getMapper().deleteByPrimaryKey(id);
+
         //记录LOG
         //记录LOG
         messageLogService.delete(generateMsgObj(id, code));
         messageLogService.delete(generateMsgObj(id, code));
     }
     }
@@ -174,6 +182,13 @@ public class BomServiceImpl extends CommonBaseServiceImpl<BomMapper, Bom> implem
     @Override
     @Override
     public DocBaseDTO close(Long id) {
     public DocBaseDTO close(Long id) {
         if(id != null && id > 0){
         if(id != null && id > 0){
+            //校验BOM资料是否已被使用
+            Long prodId = getMapper().selectByPrimaryKey(id).getBo_motherid();
+            int count = getMapper().getCountFromMake(prodId);
+            if (count > 0){
+                throw new BizException(BizExceptionCode.BIZ_RELDELETE);
+            }
+
             Bom bom = new Bom();
             Bom bom = new Bom();
             bom.setId(id);
             bom.setId(id);
             bom.setBo_status(Status.CLOSE.getDisplay());
             bom.setBo_status(Status.CLOSE.getDisplay());

+ 3 - 0
applications/document/document-server/src/main/resources/mapper/BomMapper.xml

@@ -273,4 +273,7 @@
     </where>
     </where>
     ORDER BY BO_ID DESC
     ORDER BY BO_ID DESC
   </select>
   </select>
+    <select id="getCountFromMake" parameterType="java.lang.Long">
+        SELECT COUNT(*) FROM MAKE WHERE MA_PRODID = #{id}
+    </select>
 </mapper>
 </mapper>