Kaynağa Gözat

BOM删除,关闭。以编号+版本为限制判断条件

zhoudw 7 yıl önce
ebeveyn
işleme
3ef55a7234

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

@@ -23,14 +23,13 @@ public interface BomMapper extends CommonBaseMapper<Bom> {
 
     int validCodeAndVersionWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("version") String version, @Param("companyId") Long companyId);
 
-
     int validateCodeWhenInsert(@Param("code") String code, @Param("companyId") Long companyId);
 
     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);
 
-    int getCountFromMake(Long id);
+    int getCountFromMake(@Param("code") String code,@Param("version") String version);
 
     void updateCreator(@Param("userId") Long userId,@Param("userName") String userName,@Param("id") Long id);
 }

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

@@ -124,7 +124,8 @@ public class BomServiceImpl extends CommonBaseServiceImpl<BomMapper, Bom> implem
         }
         //校验BOM资料是否已被使用
         Long prodId = getMapper().selectByPrimaryKey(id).getBo_motherid();
-        int count = getMapper().getCountFromMake(prodId);
+        Bom bom = getMapper().selectByPrimaryKey(id);
+        int count = getMapper().getCountFromMake(bom.getBo_mothercode(),bom.getBo_version());
         if (count > 0){
             throw new BizException(BizExceptionCode.BIZ_RELDELETE);
         }
@@ -194,12 +195,13 @@ public class BomServiceImpl extends CommonBaseServiceImpl<BomMapper, Bom> implem
         if(id != null && id > 0){
             //校验BOM资料是否已被使用
             Long prodId = getMapper().selectByPrimaryKey(id).getBo_motherid();
-            int count = getMapper().getCountFromMake(prodId);
+            Bom bom = getMapper().selectByPrimaryKey(id);
+            int count = getMapper().getCountFromMake(bom.getBo_mothercode(),bom.getBo_version());
             if (count > 0){
                 throw new BizException(BizExceptionCode.BIZ_RELCLOSE);
             }
 
-            Bom bom = new Bom();
+            bom = new Bom();
             bom.setId(id);
             bom.setBo_status(Status.CLOSE.getDisplay());
             bom.setBo_statuscode(Status.CLOSE.name());
@@ -232,7 +234,6 @@ public class BomServiceImpl extends CommonBaseServiceImpl<BomMapper, Bom> implem
                 bom.setBo_status(Status.OPEN.getDisplay());
                 bom.setUpdateTime(new Date());
                 bom.setUpdaterId(BaseContextHolder.getUserId());
-
                 getMapper().updateByPrimaryKeySelective(bom);
                 //记录LOG
                 DocBaseDTO docBaseDTO = generateMsgObj(id, code);

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

@@ -295,8 +295,8 @@
     </where>
     ORDER BY BO_ID DESC
   </select>
-  <select id="getCountFromMake" parameterType="java.lang.Long" resultType="int">
-      SELECT COUNT(*) FROM MAKE WHERE MA_PRODID = #{id}
+  <select id="getCountFromMake" resultType="int">
+      SELECT COUNT(*) FROM MAKE WHERE  ma_prodcode = #{code} and ma_version = #{version}
   </select>
 
   <update id="updateCreator">