Browse Source

编号BUG处理

guq 7 years ago
parent
commit
88ac3169f1

+ 2 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/MaxnumbersdetailMapper.java

@@ -29,4 +29,6 @@ public interface MaxnumbersdetailMapper {
     int updateByPrimaryKeySelective(Maxnumbersdetail record);
 
     int updateByPrimaryKey(Maxnumbersdetail record);
+
+    void updateMaxno(@Param("id") Long id, @Param("serialNum") Integer serialNum, @Param("companyId") Long companyId);
 }

+ 6 - 4
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/MaxnumberServiceImpl.java

@@ -90,10 +90,11 @@ public class MaxnumberServiceImpl extends CommonBaseServiceImpl<MaxnumbersMapper
             maxcode = rulecode + createSerialNum(length, maxno);
             //如果以更新方式取编号
             if (update) {
-                detail.setUpdateTime(new Date());
+                /*detail.setUpdateTime(new Date());
                 detail.setUpdaterId(userId);
                 detail.setMd_maxno(maxno);
-                maxnumbersdetailMapper.updateByPrimaryKeySelective(detail);
+                maxnumbersdetailMapper.updateByPrimaryKeySelective(detail);*/
+                maxnumbersdetailMapper.updateMaxno(detail.getId(), maxno, BaseContextHolder.getCompanyId());
             }
         }
         return maxcode;
@@ -143,10 +144,11 @@ public class MaxnumberServiceImpl extends CommonBaseServiceImpl<MaxnumbersMapper
             length = maxnumbers.getMn_number();
             Integer serialNum = praseSerialNum(maxcode, length);
             if (null != serialNum) {
-                detail.setMd_maxno(serialNum);
+                /*detail.setMd_maxno(serialNum);
                 detail.setUpdaterId(userId);
                 detail.setUpdateTime(new Date());
-                maxnumbersdetailMapper.updateByPrimaryKeySelective(detail);
+                maxnumbersdetailMapper.updateByPrimaryKeySelective(detail);*/
+                maxnumbersdetailMapper.updateMaxno(detail.getId(), serialNum, BaseContextHolder.getCompanyId());
             }
 
         }

+ 6 - 0
applications/commons/commons-server/src/main/resources/mapper/MaxnumbersdetailMapper.xml

@@ -273,4 +273,10 @@
       updaterId = #{updaterId,jdbcType=INTEGER}
     where md_id = #{id,jdbcType=INTEGER}
   </update>
+
+  <update id="updateMaxno">
+    update maxnumbersdetail
+    set md_maxno = #{serialNum}
+    where md_id = #{id} and  companyId=#{companyId} and  md_maxno &lt; #{serialNum}
+  </update>
 </mapper>