CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
igds-inout/src/main/resources/mapper/InoutCommonMapper.xml
@@ -42,11 +42,11 @@
    <!-- 根据ip和端口更新出入库设备状态 -->
    <update id="updateInoutConfStatus">
      update D_INOUT_CONF
      set STATUS_ = #{status}
      where IP_ = #{ip}
      and PORT_ = #{port}
   </update>
        update D_INOUT_CONF
        set STATUS_ = #{status}
        where IP_ = #{ip}
          and PORT_ = #{port}
    </update>
    <!-- 根据参数获取往来单位 -->
    <select id="listCustomer" parameterType="com.ld.igds.inout.dto.InoutParam"
@@ -142,11 +142,11 @@
    <!-- 获取编码最大的单位 -->
    <select id="getMaxCustomerId" parameterType="java.lang.String"
            resultType="java.lang.String">
      select ID_ from D_INOUT_CUSTOMER
      where
      COMPANY_ID_ = #{companyId}
      order by ID_ DESC limit 1
   </select>
        select ID_
        from D_INOUT_CUSTOMER
        where COMPANY_ID_ = #{companyId}
        order by ID_ DESC limit 1
    </select>
    <!-- 获取入库通知单信息 -->
    <select id="listNoticeIn" parameterType="com.ld.igds.m.dto.NoticeParam"
@@ -156,7 +156,6 @@
        COMPANY_ID_ as companyId,
        DEPT_ID_ as deptId,
        PLAN_ID_ as planId,
        PLAN_NAME_ as planName,
        CONTRACT_ID_ as contractId,
        CONTRACT_NAME_ as contractName,
        NAME_ as name,
@@ -173,6 +172,7 @@
        CREATE_TIME_ as createTime,
        CREATE_USER_ as createUser,
        COMPLETE_TIME_ as completeTime,
        DEPOT_ID_ as depotId,
        REMARK_ as remark
        from
        D_INOUT_NOTICE_IN
@@ -198,51 +198,47 @@
    <!-- 新增入库通知单 -->
    <insert id="addNoticeIn" parameterType="com.ld.igds.models.InoutNoticeIn">
      insert into
      D_INOUT_NOTICE_IN (
      ID_,
      COMPANY_ID_,
      DEPT_ID_,
      PLAN_ID_,
      CONTRACT_ID_,
      NAME_,
      CUSTOMER_ID_,
      CUSTOMER_NAME_,
      UNIT_NAME_,
      FOOD_VARIETY_,
      YEAR_,
      TARGET_NUMBER_,
      COMPLETE_NUMBER_,
      AUDIT_STATUS_,
      AUDIT_USER_,
      COMPLETE_STATUS_,
      CREATE_TIME_,
      CREATE_USER_,
      UPDATE_TIME_,
      REMARK_
      )values (
      #{param.id},
      #{param.companyId},
      #{param.deptId},
      #{param.planId},
      #{param.contractId},
      #{param.name},
      #{param.customerId},
      #{param.customerName},
      #{param.unitName},
      #{param.foodVariety},
      #{param.year},
      #{param.targetNumber},
      #{param.completeNumber},
      #{param.auditStatus},
      #{param.auditUser},
      #{param.completeStatus},
      #{param.createTime},
      #{param.createUser},
      #{param.updateTime},
      #{param.remark}
      )
   </insert>
        insert into D_INOUT_NOTICE_IN (ID_,
                                       COMPANY_ID_,
                                       DEPT_ID_,
                                       PLAN_ID_,
                                       CONTRACT_ID_,
                                       NAME_,
                                       CUSTOMER_ID_,
                                       CUSTOMER_NAME_,
                                       UNIT_NAME_,
                                       FOOD_VARIETY_,
                                       YEAR_,
                                       TARGET_NUMBER_,
                                       COMPLETE_NUMBER_,
                                       AUDIT_STATUS_,
                                       AUDIT_USER_,
                                       COMPLETE_STATUS_,
                                       CREATE_TIME_,
                                       CREATE_USER_,
                                       UPDATE_TIME_,
                                       REMARK_)
        values (#{param.id},
                #{param.companyId},
                #{param.deptId},
                #{param.planId},
                #{param.contractId},
                #{param.name},
                #{param.customerId},
                #{param.customerName},
                #{param.unitName},
                #{param.foodVariety},
                #{param.year},
                #{param.targetNumber},
                #{param.completeNumber},
                #{param.auditStatus},
                #{param.auditUser},
                #{param.completeStatus},
                #{param.createTime},
                #{param.createUser},
                #{param.updateTime},
                #{param.remark})
    </insert>
    <!--更新入库通知单-->
    <update id="updateNoticeIn" parameterType="com.ld.igds.m.dto.NoticeInData">
@@ -267,18 +263,17 @@
    <!-- 获取所有未完成状态入库通知单 -->
    <select id="getUnComNoticeIn" resultType="com.ld.igds.models.InoutNoticeIn">
      select
      ID_ as id,
      COMPANY_ID_ as companyId,
      DEPT_ID_ as deptId,
      PLAN_ID_ as planId,
      CONTRACT_ID_ as contractId,
      NAME_ as name,
      CUSTOMER_ID_ as customerId,
      CUSTOMER_NAME_ as customerName,
      UNIT_NAME_ as unitName,
      FOOD_VARIETY_ as foodVariety,
      YEAR_ as year,
        select ID_            as id,
               COMPANY_ID_    as companyId,
               DEPT_ID_       as deptId,
               PLAN_ID_       as planId,
               CONTRACT_ID_   as contractId,
               NAME_          as name,
               CUSTOMER_ID_   as customerId,
               CUSTOMER_NAME_ as customerName,
               UNIT_NAME_     as unitName,
               FOOD_VARIETY_  as foodVariety,
               YEAR_ as year,
      TARGET_NUMBER_ as targetNumber,
      COMPLETE_NUMBER_ as completeNumber,
      AUDIT_STATUS_ as auditStatus,
@@ -288,36 +283,34 @@
      CREATE_USER_ as createUser,
      COMPLETE_TIME_ as completeTime,
      REMARK_ as remark
      from
      D_INOUT_NOTICE_IN
      where
      COMPLETE_STATUS_ = 'NONE'
      and COMPANY_ID_ = #{companyId}
   </select>
        from
            D_INOUT_NOTICE_IN
        where
            COMPLETE_STATUS_ = 'NONE'
          and COMPANY_ID_ = #{companyId}
    </select>
    <!-- 重新计算入库通知单完成量 -->
    <update id="reSumNoticeInComplete" parameterType="com.ld.igds.m.dto.NoticeParam">
      update D_INOUT_NOTICE_IN t,(
      SELECT
      r.CUSTOMER_ID_,
      r.FOOD_VARIETY_,
      r.NOTICE_ID_,
      sum(r.RECORD_WEIGHT_) as COMPLETE_NUMBER_
      from d_inout_record r
      where r.COMPANY_ID_ = #{param.companyId}
      and r.DEPT_ID_ = #{param.deptId}
      and r.CUSTOMER_ID_ = #{param.customerId}
      and r.FOOD_VARIETY_ = #{param.foodVariety}
      and r.NOTICE_ID_ = #{param.id}
      and r.RECORD_STATUS_ != 'DEL'
      and r.RECORD_STATUS_ != 'ERROR'
      GROUP BY r.FOOD_VARIETY_
      ) b
      SET t.COMPLETE_NUMBER_ = b.COMPLETE_NUMBER_
      WHERE t.CUSTOMER_ID_ = b.CUSTOMER_ID_
      AND t.FOOD_VARIETY_ = b.FOOD_VARIETY_
      AND t.ID_ = b.NOTICE_ID_
   </update>
        update D_INOUT_NOTICE_IN t,(
            SELECT
            r.FOOD_VARIETY_,
            r.NOTICE_ID_,
            sum(r.RECORD_WEIGHT_) as COMPLETE_NUMBER_
            from d_inout_record r
            where r.COMPANY_ID_ = #{param.companyId}
            and r.DEPT_ID_ = #{param.deptId}
            and r.FOOD_VARIETY_ = #{param.foodVariety}
            and r.NOTICE_ID_ = #{param.id}
            and r.RECORD_STATUS_ != 'DEL'
            and r.RECORD_STATUS_ != 'ERROR'
            GROUP BY r.FOOD_VARIETY_
            ) b
        SET t.COMPLETE_NUMBER_ = b.COMPLETE_NUMBER_
        WHERE
          t.FOOD_VARIETY_ = b.FOOD_VARIETY_
          AND t.ID_ = b.NOTICE_ID_
    </update>
    <!-- 根据参数查询出库通知单 -->
    <select id="queryNoticeOut" resultType="int" parameterType="com.ld.igds.m.dto.NoticeParam">
@@ -387,7 +380,6 @@
        COMPANY_ID_ as companyId,
        DEPT_ID_ as deptId,
        PLAN_ID_ as planId,
        PLAN_NAME_ as planName,
        CONTRACT_ID_ as contractId,
        CONTRACT_NAME_ as contractName,
        NAME_ as name,
@@ -437,21 +429,20 @@
    <!-- 获取所有未完成状态出库通知单 -->
    <select id="getUnComNoticeOut" resultType="com.ld.igds.models.InoutNoticeOut">
      select
      ID_ as id,
      COMPANY_ID_ as companyId,
      DEPT_ID_ as deptId,
      PLAN_ID_ as planId,
      CONTRACT_ID_ as contractId,
      NAME_ as name,
      DEPOT_ID_ as depotId,
      CUSTOMER_ID_ as customerId,
      CUSTOMER_NAME_ as customerName,
      UNIT_NAME_ as unitName,
      FOOD_VARIETY_ as foodVariety,
      FOOD_TYPE_ as foodType,
      FOOD_LEVEL_ as foodLevel,
      YEAR_ as year,
        select ID_            as id,
               COMPANY_ID_    as companyId,
               DEPT_ID_       as deptId,
               PLAN_ID_       as planId,
               CONTRACT_ID_   as contractId,
               NAME_          as name,
               DEPOT_ID_      as depotId,
               CUSTOMER_ID_   as customerId,
               CUSTOMER_NAME_ as customerName,
               UNIT_NAME_     as unitName,
               FOOD_VARIETY_  as foodVariety,
               FOOD_TYPE_     as foodType,
               FOOD_LEVEL_    as foodLevel,
               YEAR_ as year,
      STORAGE_REAL_ as storageReal,
      TARGET_NUMBER_ as targetNumber,
      COMPLETE_NUMBER_ as completeNumber,
@@ -462,37 +453,34 @@
      CREATE_USER_ as createUser,
      COMPLETE_TIME_ as completeTime,
      REMARK_ as remark
      from
      D_INOUT_NOTICE_OUT
      where
      COMPLETE_STATUS_ = 'NONE'
      and COMPANY_ID_ = #{companyId}
   </select>
        from
            D_INOUT_NOTICE_OUT
        where
            COMPLETE_STATUS_ = 'NONE'
          and COMPANY_ID_ = #{companyId}
    </select>
    <!-- 重新计算出库通知单完成量,只根据客户更新 -->
    <update id="reSumNoticeOutComplete" parameterType="com.ld.igds.m.dto.NoticeParam">
      update D_INOUT_NOTICE_OUT t,(
      SELECT
      r.CUSTOMER_ID_,
      r.FOOD_VARIETY_,
      r.DEPOT_ID_,
      r.NOTICE_ID_,
      sum(r.RECORD_WEIGHT_) as COMPLETE_NUMBER_
      from d_inout_record r
      where r.COMPANY_ID_ = #{param.companyId}
      AND r.DEPT_ID_ = #{param.deptId}
      and r.CUSTOMER_ID_ = #{param.customerId}
      and r.DEPOT_ID_ = #{param.depotId}
      and r.FOOD_VARIETY_ = #{param.foodVariety}
      and r.RECORD_STATUS_ != 'DEL'
      and r.RECORD_STATUS_ != 'ERROR'
      GROUP BY r.DEPOT_ID_
      ) b
      SET t.COMPLETE_NUMBER_ = b.COMPLETE_NUMBER_
      WHERE t.CUSTOMER_ID_ = b.CUSTOMER_ID_
      AND t.FOOD_VARIETY_ = b.FOOD_VARIETY_
      AND t.DEPOT_ID_ = b.DEPOT_ID_
      AND t.ID_ = b.NOTICE_ID_
   </update>
        update D_INOUT_NOTICE_OUT t,(
            SELECT
            r.FOOD_VARIETY_,
            r.DEPOT_ID_,
            r.NOTICE_ID_,
            sum(r.RECORD_WEIGHT_) as COMPLETE_NUMBER_
            from d_inout_record r
            where r.COMPANY_ID_ = #{param.companyId}
            AND r.DEPT_ID_ = #{param.deptId}
            and r.DEPOT_ID_ = #{param.depotId}
            and r.FOOD_VARIETY_ = #{param.foodVariety}
            and r.RECORD_STATUS_ != 'DEL'
            and r.RECORD_STATUS_ != 'ERROR'
            GROUP BY r.DEPOT_ID_
            ) b
        SET t.COMPLETE_NUMBER_ = b.COMPLETE_NUMBER_
        WHERE  t.FOOD_VARIETY_ = b.FOOD_VARIETY_
          AND t.DEPOT_ID_ = b.DEPOT_ID_
          AND t.ID_ = b.NOTICE_ID_
    </update>
</mapper>