Browse Source

制造单新增录入人

zhoudw 7 years ago
parent
commit
d2509a877d

+ 1 - 0
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/mapper/MakeMapper.java

@@ -29,4 +29,5 @@ public interface MakeMapper extends CommonBaseMapper<Make> {
 
     String selectMakeInOutCode(@Param("code") String code, @Param("companyId") Long companyId, @Param("type") String type);
 
+    void updateCreator(@Param("userId") Long userId,@Param("userName") String userName,@Param("id") Long ma_id);
 }

+ 19 - 6
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/MakeServiceImpl.java

@@ -3,6 +3,7 @@ package com.usoftchina.saas.storage.service.impl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
+import com.usoftchina.saas.commons.api.CommonService;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
@@ -48,6 +49,9 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
     private ProdIODetailMapper prodIODetailMapper;
     @Autowired
     private WarehouseApi warehouseApi;
+    @Autowired
+    private CommonService commonService;
+
 
     @Override
     public PageInfo<Make> getList(PageRequest page, ListReqDTO listReqDTO) {
@@ -78,20 +82,29 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
     @Override
     @Transactional
     public DocBaseDTO saveOrUpdate(MakeListDTO makeListDTO) {
+        if (null == makeListDTO || null == makeListDTO.getMain()){
+            throw new BizException(BizExceptionCode.EMPTY_DATA);
+        }
+
+        //公司ID
+        Long companyId = BaseContextHolder.getCompanyId();
+        //人员Id
+        Long userId = BaseContextHolder.getUserId();
+        //人员名称
+        String userName = BaseContextHolder.getUserName();
         Make make = makeListDTO.getMain();
+        Long ma_id = make.getId();
         List<MakeMaterial> makeMaterialList = makeListDTO.getItems();
+        String code = pushMaxnubmer(make.getMa_code(), make.getId());
         DocBaseDTO docBaseDTO = null;
-
         if(make.getId() == 0){
             //保存主表
-            String code = pushMaxnubmer(make.getMa_code(), make.getId());
-            make.setMa_code(code);
             make.setCompanyId(BaseContextHolder.getCompanyId());
-            //make.setCreateTime(new Date());
-            make.setMa_recorddate(make.getCreateTime());
-            make.setCreatorId(BaseContextHolder.getUserId());
 
+            make.setMa_code(code);
             getMapper().insertSelective(make);
+            //录入人
+            getMapper().updateCreator(userId, userName, ma_id);
             if (makeMaterialList.size() > 0) {
                 //保存明细
                 for (MakeMaterial makeMaterial : makeMaterialList) {

+ 96 - 74
applications/storage/storage-server/src/main/resources/mapper/MakeMapper.xml

@@ -26,7 +26,11 @@
     <result column="ma_auditdate" property="ma_auditdate" jdbcType="DOUBLE" />
     <result column="companyId" property="companyId" jdbcType="INTEGER" />
     <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+    <result column="updaterName" property="updaterName" jdbcType="VARCHAR" />
     <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+    <result column="creatorid" property="creatorId" jdbcType="INTEGER"/>
+    <result column="creatorName" property="creatorName" jdbcType="VARCHAR" />
+    <result column="createTime" property="createTime" jdbcType="TIMESTAMP" />
     <result column="ma_text1" property="ma_text1" jdbcType="VARCHAR" />
     <result column="ma_text2" property="ma_text2" jdbcType="VARCHAR" />
     <result column="ma_text3" property="ma_text3" jdbcType="VARCHAR" />
@@ -36,7 +40,7 @@
   <sql id="Base_Column_List" >
     ma_id, ma_code, ma_status, ma_statuscode, ma_type, ma_prodid, ma_prodcode, ma_proddetail, 
     ma_prodspec, ma_version, ma_produnit, ma_qty, ma_whid, ma_whcode, ma_whname, ma_recorddate,
-    ma_recordid, ma_recorder, ma_price, ma_total,ma_auditman,ma_auditdate, companyId, updaterId, updateTime, ma_text1,
+    ma_recordid, ma_recorder, ma_price, ma_total,ma_auditman,ma_auditdate, companyId, updaterId,updaterName,updateTime,creatorid,creatorName,createtime, ma_text1,
     ma_text2, ma_text3, ma_text4, ma_text5
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
@@ -74,192 +78,214 @@
       #{ma_text3,jdbcType=VARCHAR}, #{ma_text4,jdbcType=VARCHAR}, #{ma_text5,jdbcType=VARCHAR}
       )
   </insert>
-  <insert id="insertSelective" parameterType="com.usoftchina.saas.storage.po.Make" >
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.storage.po.Make">
     <selectKey resultType="java.lang.Long" keyProperty="id">
       SELECT LAST_INSERT_ID() AS ID
     </selectKey>
     insert into make
-    <trim prefix="(" suffix=")" suffixOverrides="," >
-      <if test="ma_code != null" >
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+
+      <if test="ma_code != null">
         ma_code,
       </if>
-      <if test="ma_status != null" >
+      <if test="ma_status != null">
         ma_status,
       </if>
-      <if test="ma_statuscode != null" >
+      <if test="ma_statuscode != null">
         ma_statuscode,
       </if>
-      <if test="ma_type != null" >
+      <if test="ma_type != null">
         ma_type,
       </if>
-      <if test="ma_prodid != null" >
+      <if test="ma_prodid != null">
         ma_prodid,
       </if>
-      <if test="ma_prodcode != null" >
+      <if test="ma_prodcode != null">
         ma_prodcode,
       </if>
-      <if test="ma_proddetail != null" >
+      <if test="ma_proddetail != null">
         ma_proddetail,
       </if>
-      <if test="ma_prodspec != null" >
+      <if test="ma_prodspec != null">
         ma_prodspec,
       </if>
-      <if test="ma_version != null" >
+      <if test="ma_version != null">
         ma_version,
       </if>
-      <if test="ma_produnit != null" >
+      <if test="ma_produnit != null">
         ma_produnit,
       </if>
-      <if test="ma_qty != null" >
+      <if test="ma_qty != null">
         ma_qty,
       </if>
-      <if test="ma_whid != null" >
+      <if test="ma_whid != null">
         ma_whid,
       </if>
-      <if test="ma_whcode != null" >
+      <if test="ma_whcode != null">
         ma_whcode,
       </if>
-      <if test="ma_whname != null" >
-          ma_whname,
+      <if test="ma_whname != null">
+        ma_whname,
       </if>
-      <if test="createTime != null" >
+      <if test="ma_recorddate != null">
         ma_recorddate,
       </if>
-      <if test="ma_recordid != null" >
+      <if test="ma_recordid != null">
         ma_recordid,
       </if>
-      <if test="ma_recorder != null" >
+      <if test="ma_recorder != null">
         ma_recorder,
       </if>
-      <if test="ma_price != null" >
+      <if test="ma_price != null">
         ma_price,
       </if>
-      <if test="ma_total != null" >
+      <if test="ma_total != null">
         ma_total,
       </if>
-      <if test="ma_auditman !=null">
+      <if test="ma_auditman != null">
         ma_auditman,
       </if>
-      <if test="ma_auditdate !=null">
+      <if test="ma_auditdate != null">
         ma_auditdate,
       </if>
-      <if test="companyId != null" >
+      <if test="companyId != null">
         companyId,
       </if>
-      <if test="updaterId != null" >
+      <if test="updaterId != null">
         updaterId,
       </if>
-      <if test="updateTime != null" >
+      <if test="updateTime != null">
         updateTime,
       </if>
-      <if test="ma_text1 != null" >
+      <if test="ma_text1 != null">
         ma_text1,
       </if>
-      <if test="ma_text2 != null" >
+      <if test="ma_text2 != null">
         ma_text2,
       </if>
-      <if test="ma_text3 != null" >
+      <if test="ma_text3 != null">
         ma_text3,
       </if>
-      <if test="ma_text4 != null" >
+      <if test="ma_text4 != null">
         ma_text4,
       </if>
-      <if test="ma_text5 != null" >
+      <if test="ma_text5 != null">
         ma_text5,
       </if>
+      <if test="creatorName != null">
+        creatorName,
+      </if>
+      <if test="creatorId != null">
+        creatorId,
+      </if>
+      <if test="createTime != null">
+        createTime,
+      </if>
+      <if test="updaterName != null">
+        updaterName,
+      </if>
     </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides="," >
-      <if test="ma_code != null" >
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+
+      <if test="ma_code != null">
         #{ma_code,jdbcType=VARCHAR},
       </if>
-      <if test="ma_status != null" >
+      <if test="ma_status != null">
         #{ma_status,jdbcType=VARCHAR},
       </if>
-      <if test="ma_statuscode != null" >
+      <if test="ma_statuscode != null">
         #{ma_statuscode,jdbcType=VARCHAR},
       </if>
-      <if test="ma_type != null" >
+      <if test="ma_type != null">
         #{ma_type,jdbcType=VARCHAR},
       </if>
-      <if test="ma_prodid != null" >
+      <if test="ma_prodid != null">
         #{ma_prodid,jdbcType=INTEGER},
       </if>
-      <if test="ma_prodcode != null" >
+      <if test="ma_prodcode != null">
         #{ma_prodcode,jdbcType=VARCHAR},
       </if>
-      <if test="ma_proddetail != null" >
+      <if test="ma_proddetail != null">
         #{ma_proddetail,jdbcType=VARCHAR},
       </if>
-      <if test="ma_prodspec != null" >
+      <if test="ma_prodspec != null">
         #{ma_prodspec,jdbcType=VARCHAR},
       </if>
-      <if test="ma_version != null" >
+      <if test="ma_version != null">
         #{ma_version,jdbcType=VARCHAR},
       </if>
-      <if test="ma_produnit != null" >
+      <if test="ma_produnit != null">
         #{ma_produnit,jdbcType=VARCHAR},
       </if>
-      <if test="ma_qty != null" >
+      <if test="ma_qty != null">
         #{ma_qty,jdbcType=DOUBLE},
       </if>
-      <if test="ma_whid != null" >
+      <if test="ma_whid != null">
         #{ma_whid,jdbcType=INTEGER},
       </if>
-      <if test="ma_whcode != null" >
+      <if test="ma_whcode != null">
         #{ma_whcode,jdbcType=VARCHAR},
       </if>
-      <if test="ma_whname != null" >
-          #{ma_whname,jdbcType=VARCHAR},
+      <if test="ma_whname != null">
+        #{ma_whname,jdbcType=VARCHAR},
       </if>
-      <if test="ma_recorddate != null" >
+      <if test="ma_recorddate != null">
         #{ma_recorddate,jdbcType=TIMESTAMP},
       </if>
-      <if test="ma_recordid != null" >
+      <if test="ma_recordid != null">
         #{ma_recordid,jdbcType=INTEGER},
       </if>
-      <if test="ma_recorder != null" >
+      <if test="ma_recorder != null">
         #{ma_recorder,jdbcType=VARCHAR},
       </if>
-      <if test="ma_price != null" >
+      <if test="ma_price != null">
         #{ma_price,jdbcType=DOUBLE},
       </if>
-      <if test="ma_total != null" >
+      <if test="ma_total != null">
         #{ma_total,jdbcType=DOUBLE},
       </if>
-      <if test="ma_auditman !=null">
+      <if test="ma_auditman != null">
         #{ma_auditman,jdbcType=VARCHAR},
       </if>
-      <if test="ma_auditdate !=null">
+      <if test="ma_auditdate != null">
         #{ma_auditdate,jdbcType=TIMESTAMP},
       </if>
-
-
-
-
-      <if test="companyId != null" >
+      <if test="companyId != null">
         #{companyId,jdbcType=INTEGER},
       </if>
-      <if test="updaterId != null" >
+      <if test="updaterId != null">
         #{updaterId,jdbcType=INTEGER},
       </if>
-      <if test="updateTime != null" >
+      <if test="updateTime != null">
         #{updateTime,jdbcType=TIMESTAMP},
       </if>
-      <if test="ma_text1 != null" >
+      <if test="ma_text1 != null">
         #{ma_text1,jdbcType=VARCHAR},
       </if>
-      <if test="ma_text2 != null" >
+      <if test="ma_text2 != null">
         #{ma_text2,jdbcType=VARCHAR},
       </if>
-      <if test="ma_text3 != null" >
+      <if test="ma_text3 != null">
         #{ma_text3,jdbcType=VARCHAR},
       </if>
-      <if test="ma_text4 != null" >
+      <if test="ma_text4 != null">
         #{ma_text4,jdbcType=VARCHAR},
       </if>
-      <if test="ma_text5 != null" >
+      <if test="ma_text5 != null">
         #{ma_text5,jdbcType=VARCHAR},
       </if>
+      <if test="creatorName != null">
+        #{creatorName,jdbcType=VARCHAR},
+      </if>
+      <if test="creatorId != null">
+        #{creatorId,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updaterName != null">
+        #{updaterName,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.storage.po.Make" >
@@ -417,12 +443,8 @@
         SELECT PI_INOUTNO FROM PRODINOUT WHERE COMPANYID=#{companyId} AND PI_MACODE=#{code} AND PI_CLASS=#{type}
     </select>
 
-  <update id="calcMakePriceAndTotal" parameterType="long" >
-  update makematerial set mm_price = (select pw_avprice from productwh where pw_prodid = mm_prodid and pw_whid = mm_whid) where mm_maid = #{id};
-  update makematerial set mm_amount = round(mm_price*mm_qty,2) where mm_maid = #{id};
-  update make set ma_total = round((select sum(mm_amount) from makematerial where mm_maid = #{id} ),2) where ma_id = #{id};
-  update make set ma_price = ma_total/ma_qty where ma_id = #{id};
+  <update id="updateCreator">
+    update make set creatorId = #{userId} , creatorName=#{userName} where ma_id=#{id}
   </update>
 
-
 </mapper>