refactor: 入库计划列表,根据创建时间倒序

This commit is contained in:
LJW 2024-11-05 10:58:29 +08:00
parent fe1aa26549
commit b4566baedc

View File

@ -1,107 +1,180 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ktg.mes.wm.mapper.WmsInPlanMapper">
<resultMap type="WmsInPlan" id="WmsInPlanResult">
<result property="planId" column="PLAN_ID" />
<result property="state" column="STATE" />
<result property="sourceType" column="SOURCE_TYPE" />
<result property="wareId" column="WARE_ID" />
<result property="cellCode" column="CELL_CODE" />
<result property="workOrderCode" column="WORK_ORDER_CODE" />
<result property="expectDate" column="EXPECT_DATE" />
<result property="publishName" column="PUBLISH_NAME" />
<result property="publishTime" column="PUBLISH_TIME" />
<result property="closerId" column="CLOSER_ID" />
<result property="closeTime" column="CLOSE_TIME" />
<result property="relBillCode" column="REL_BILL_CODE" />
<result property="createBy" column="CREATE_BY" />
<result property="createTime" column="CREATE_TIME" />
<result property="updateTime" column="UPDATE_TIME" />
<result property="updateBy" column="UPDATE_BY" />
<result property="remark" column="REMARK" />
<result property="customerId" column="CUSTOMER_ID" />
<result property="poCode" column="PO_CODE" />
<result property="departmentId" column="DEPARTMENT_ID" />
<result property="contractNo" column="CONTRACT_NO" />
<result property="supplierId" column="SUPPLIER_ID" />
<result property="businessTypeId" column="BUSINESS_TYPE_ID" />
<result property="srcOutTaskId" column="SRC_OUT_TASK_ID" />
<result property="isActive" column="IS_ACTIVE" />
<result property="isDelete" column="IS_DELETE" />
<result property="planCode" column="PLAN_CODE" />
<result property="planTypeId" column="PLAN_TYPE_ID" />
<result property="planId" column="PLAN_ID"/>
<result property="state" column="STATE"/>
<result property="sourceType" column="SOURCE_TYPE"/>
<result property="wareId" column="WARE_ID"/>
<result property="cellCode" column="CELL_CODE"/>
<result property="workOrderCode" column="WORK_ORDER_CODE"/>
<result property="expectDate" column="EXPECT_DATE"/>
<result property="publishName" column="PUBLISH_NAME"/>
<result property="publishTime" column="PUBLISH_TIME"/>
<result property="closerId" column="CLOSER_ID"/>
<result property="closeTime" column="CLOSE_TIME"/>
<result property="relBillCode" column="REL_BILL_CODE"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="remark" column="REMARK"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="poCode" column="PO_CODE"/>
<result property="departmentId" column="DEPARTMENT_ID"/>
<result property="contractNo" column="CONTRACT_NO"/>
<result property="supplierId" column="SUPPLIER_ID"/>
<result property="businessTypeId" column="BUSINESS_TYPE_ID"/>
<result property="srcOutTaskId" column="SRC_OUT_TASK_ID"/>
<result property="isActive" column="IS_ACTIVE"/>
<result property="isDelete" column="IS_DELETE"/>
<result property="planCode" column="PLAN_CODE"/>
<result property="planTypeId" column="PLAN_TYPE_ID"/>
</resultMap>
<resultMap id="WmsInPlanWmsInPlanDetailsResult" type="WmsInPlan" extends="WmsInPlanResult">
<collection property="wmsInPlanDetailsList" notNullColumn="sub_DETAILS_ID" javaType="java.util.List" resultMap="WmsInPlanDetailsResult" />
<collection property="wmsInPlanDetailsList" notNullColumn="sub_DETAILS_ID" javaType="java.util.List"
resultMap="WmsInPlanDetailsResult"/>
</resultMap>
<resultMap type="WmsInPlanDetails" id="WmsInPlanDetailsResult">
<result property="detailsId" column="sub_DETAILS_ID" />
<result property="planId" column="sub_PLAN_ID" />
<result property="materialId" column="sub_MATERIAL_ID" />
<result property="batch" column="sub_BATCH" />
<result property="cellId" column="sub_CELL_ID" />
<result property="quantity" column="sub_QUANTITY" />
<result property="quantityIn" column="sub_QUANTITY_IN" />
<result property="planInStatus" column="sub_PLAN_IN_STATUS" />
<result property="remark" column="sub_REMARK" />
<result property="createBy" column="sub_CREATE_BY" />
<result property="createTime" column="sub_CREATE_TIME" />
<result property="updateBy" column="sub_UPDATE_BY" />
<result property="updateTime" column="sub_UPDATE_TIME" />
<result property="isActivy" column="sub_IS_ACTIVY" />
<result property="isDelete" column="sub_IS_DELETE" />
<result property="detailsId" column="sub_DETAILS_ID"/>
<result property="planId" column="sub_PLAN_ID"/>
<result property="materialId" column="sub_MATERIAL_ID"/>
<result property="batch" column="sub_BATCH"/>
<result property="cellId" column="sub_CELL_ID"/>
<result property="quantity" column="sub_QUANTITY"/>
<result property="quantityIn" column="sub_QUANTITY_IN"/>
<result property="planInStatus" column="sub_PLAN_IN_STATUS"/>
<result property="remark" column="sub_REMARK"/>
<result property="createBy" column="sub_CREATE_BY"/>
<result property="createTime" column="sub_CREATE_TIME"/>
<result property="updateBy" column="sub_UPDATE_BY"/>
<result property="updateTime" column="sub_UPDATE_TIME"/>
<result property="isActivy" column="sub_IS_ACTIVY"/>
<result property="isDelete" column="sub_IS_DELETE"/>
</resultMap>
<sql id="selectWmsInPlanVo">
select PLAN_ID, STATE, SOURCE_TYPE, WARE_ID, CELL_CODE, WORK_ORDER_CODE, EXPECT_DATE, PUBLISH_NAME, PUBLISH_TIME, CLOSER_ID, CLOSE_TIME, REL_BILL_CODE, CREATE_BY, CREATE_TIME, UPDATE_TIME, UPDATE_BY, REMARK, CUSTOMER_ID, PO_CODE, DEPARTMENT_ID, CONTRACT_NO, SUPPLIER_ID, BUSINESS_TYPE_ID, SRC_OUT_TASK_ID, IS_ACTIVE, IS_DELETE, PLAN_CODE, PLAN_TYPE_ID from WMS_IN_PLAN
select PLAN_ID,
STATE,
SOURCE_TYPE,
WARE_ID,
CELL_CODE,
WORK_ORDER_CODE,
EXPECT_DATE,
PUBLISH_NAME,
PUBLISH_TIME,
CLOSER_ID,
CLOSE_TIME,
REL_BILL_CODE,
CREATE_BY,
CREATE_TIME,
UPDATE_TIME,
UPDATE_BY,
REMARK,
CUSTOMER_ID,
PO_CODE,
DEPARTMENT_ID,
CONTRACT_NO,
SUPPLIER_ID,
BUSINESS_TYPE_ID,
SRC_OUT_TASK_ID,
IS_ACTIVE,
IS_DELETE,
PLAN_CODE,
PLAN_TYPE_ID
from WMS_IN_PLAN
order by CREATE_TIME desc
</sql>
<select id="selectWmsInPlanList" parameterType="WmsInPlan" resultMap="WmsInPlanResult">
<include refid="selectWmsInPlanVo"/>
<where>
<if test="state != null and state != ''"> and STATE = #{state}</if>
<if test="sourceType != null and sourceType != ''"> and SOURCE_TYPE = #{sourceType}</if>
<if test="wareId != null and wareId != ''"> and WARE_ID = #{wareId}</if>
<if test="cellCode != null and cellCode != ''"> and CELL_CODE = #{cellCode}</if>
<if test="workOrderCode != null and workOrderCode != ''"> and WORK_ORDER_CODE = #{workOrderCode}</if>
<if test="expectDate != null and expectDate != ''"> and EXPECT_DATE = #{expectDate}</if>
<if test="publishName != null and publishName != ''"> and PUBLISH_NAME like concat('%', #{publishName}, '%')</if>
<if test="publishTime != null and publishTime != ''"> and PUBLISH_TIME = #{publishTime}</if>
<if test="closerId != null and closerId != ''"> and CLOSER_ID = #{closerId}</if>
<if test="closeTime != null and closeTime != ''"> and CLOSE_TIME = #{closeTime}</if>
<if test="relBillCode != null and relBillCode != ''"> and REL_BILL_CODE = #{relBillCode}</if>
<if test="createBy != null and createBy != ''"> and CREATE_BY = #{createBy}</if>
<if test="createTime != null and createTime != ''"> and CREATE_TIME = #{createTime}</if>
<if test="updateTime != null and updateTime != ''"> and UPDATE_TIME = #{updateTime}</if>
<if test="updateBy != null and updateBy != ''"> and UPDATE_BY = #{updateBy}</if>
<if test="remark != null and remark != ''"> and REMARK = #{remark}</if>
<if test="customerId != null and customerId != ''"> and CUSTOMER_ID = #{customerId}</if>
<if test="poCode != null and poCode != ''"> and PO_CODE = #{poCode}</if>
<if test="departmentId != null and departmentId != ''"> and DEPARTMENT_ID = #{departmentId}</if>
<if test="contractNo != null and contractNo != ''"> and CONTRACT_NO = #{contractNo}</if>
<if test="supplierId != null and supplierId != ''"> and SUPPLIER_ID = #{supplierId}</if>
<if test="businessTypeId != null and businessTypeId != ''"> and BUSINESS_TYPE_ID = #{businessTypeId}</if>
<if test="srcOutTaskId != null and srcOutTaskId != ''"> and SRC_OUT_TASK_ID = #{srcOutTaskId}</if>
<if test="isActive != null and isActive != ''"> and IS_ACTIVE = #{isActive}</if>
<if test="isDelete != null and isDelete != ''"> and IS_DELETE = #{isDelete}</if>
<if test="planCode != null and planCode != ''"> and PLAN_CODE = #{planCode}</if>
<if test="planTypeId != null and planTypeId != ''"> and PLAN_TYPE_ID = #{planTypeId}</if>
<where>
<if test="state != null and state != ''">and STATE = #{state}</if>
<if test="sourceType != null and sourceType != ''">and SOURCE_TYPE = #{sourceType}</if>
<if test="wareId != null and wareId != ''">and WARE_ID = #{wareId}</if>
<if test="cellCode != null and cellCode != ''">and CELL_CODE = #{cellCode}</if>
<if test="workOrderCode != null and workOrderCode != ''">and WORK_ORDER_CODE = #{workOrderCode}</if>
<if test="expectDate != null and expectDate != ''">and EXPECT_DATE = #{expectDate}</if>
<if test="publishName != null and publishName != ''">and PUBLISH_NAME like concat('%', #{publishName},
'%')
</if>
<if test="publishTime != null and publishTime != ''">and PUBLISH_TIME = #{publishTime}</if>
<if test="closerId != null and closerId != ''">and CLOSER_ID = #{closerId}</if>
<if test="closeTime != null and closeTime != ''">and CLOSE_TIME = #{closeTime}</if>
<if test="relBillCode != null and relBillCode != ''">and REL_BILL_CODE = #{relBillCode}</if>
<if test="createBy != null and createBy != ''">and CREATE_BY = #{createBy}</if>
<if test="createTime != null and createTime != ''">and CREATE_TIME = #{createTime}</if>
<if test="updateTime != null and updateTime != ''">and UPDATE_TIME = #{updateTime}</if>
<if test="updateBy != null and updateBy != ''">and UPDATE_BY = #{updateBy}</if>
<if test="remark != null and remark != ''">and REMARK = #{remark}</if>
<if test="customerId != null and customerId != ''">and CUSTOMER_ID = #{customerId}</if>
<if test="poCode != null and poCode != ''">and PO_CODE = #{poCode}</if>
<if test="departmentId != null and departmentId != ''">and DEPARTMENT_ID = #{departmentId}</if>
<if test="contractNo != null and contractNo != ''">and CONTRACT_NO = #{contractNo}</if>
<if test="supplierId != null and supplierId != ''">and SUPPLIER_ID = #{supplierId}</if>
<if test="businessTypeId != null and businessTypeId != ''">and BUSINESS_TYPE_ID = #{businessTypeId}</if>
<if test="srcOutTaskId != null and srcOutTaskId != ''">and SRC_OUT_TASK_ID = #{srcOutTaskId}</if>
<if test="isActive != null and isActive != ''">and IS_ACTIVE = #{isActive}</if>
<if test="isDelete != null and isDelete != ''">and IS_DELETE = #{isDelete}</if>
<if test="planCode != null and planCode != ''">and PLAN_CODE = #{planCode}</if>
<if test="planTypeId != null and planTypeId != ''">and PLAN_TYPE_ID = #{planTypeId}</if>
</where>
</select>
<select id="selectWmsInPlanByPlanId" parameterType="String" resultMap="WmsInPlanWmsInPlanDetailsResult">
select a.PLAN_ID, a.STATE, a.SOURCE_TYPE, a.WARE_ID, a.CELL_CODE, a.WORK_ORDER_CODE, a.EXPECT_DATE, a.PUBLISH_NAME, a.PUBLISH_TIME, a.CLOSER_ID, a.CLOSE_TIME, a.REL_BILL_CODE, a.CREATE_BY, a.CREATE_TIME, a.UPDATE_TIME, a.UPDATE_BY, a.REMARK, a.CUSTOMER_ID, a.PO_CODE, a.DEPARTMENT_ID, a.CONTRACT_NO, a.SUPPLIER_ID, a.BUSINESS_TYPE_ID, a.SRC_OUT_TASK_ID, a.IS_ACTIVE, a.IS_DELETE, a.PLAN_CODE, a.PLAN_TYPE_ID,
b.DETAILS_ID as sub_DETAILS_ID, b.PLAN_ID as sub_PLAN_ID, b.MATERIAL_ID as sub_MATERIAL_ID, b.BATCH as sub_BATCH, b.CELL_ID as sub_CELL_ID, b.QUANTITY as sub_QUANTITY, b.QUANTITY_IN as sub_QUANTITY_IN, b.PLAN_IN_STATUS as sub_PLAN_IN_STATUS, b.REMARK as sub_REMARK, b.CREATE_BY as sub_CREATE_BY, b.CREATE_TIME as sub_CREATE_TIME, b.UPDATE_BY as sub_UPDATE_BY, b.UPDATE_TIME as sub_UPDATE_TIME, b.IS_ACTIVY as sub_IS_ACTIVY, b.IS_DELETE as sub_IS_DELETE
select a.PLAN_ID,
a.STATE,
a.SOURCE_TYPE,
a.WARE_ID,
a.CELL_CODE,
a.WORK_ORDER_CODE,
a.EXPECT_DATE,
a.PUBLISH_NAME,
a.PUBLISH_TIME,
a.CLOSER_ID,
a.CLOSE_TIME,
a.REL_BILL_CODE,
a.CREATE_BY,
a.CREATE_TIME,
a.UPDATE_TIME,
a.UPDATE_BY,
a.REMARK,
a.CUSTOMER_ID,
a.PO_CODE,
a.DEPARTMENT_ID,
a.CONTRACT_NO,
a.SUPPLIER_ID,
a.BUSINESS_TYPE_ID,
a.SRC_OUT_TASK_ID,
a.IS_ACTIVE,
a.IS_DELETE,
a.PLAN_CODE,
a.PLAN_TYPE_ID,
b.DETAILS_ID as sub_DETAILS_ID,
b.PLAN_ID as sub_PLAN_ID,
b.MATERIAL_ID as sub_MATERIAL_ID,
b.BATCH as sub_BATCH,
b.CELL_ID as sub_CELL_ID,
b.QUANTITY as sub_QUANTITY,
b.QUANTITY_IN as sub_QUANTITY_IN,
b.PLAN_IN_STATUS as sub_PLAN_IN_STATUS,
b.REMARK as sub_REMARK,
b.CREATE_BY as sub_CREATE_BY,
b.CREATE_TIME as sub_CREATE_TIME,
b.UPDATE_BY as sub_UPDATE_BY,
b.UPDATE_TIME as sub_UPDATE_TIME,
b.IS_ACTIVY as sub_IS_ACTIVY,
b.IS_DELETE as sub_IS_DELETE
from WMS_IN_PLAN a
left join WMS_IN_PLAN_DETAILS b on b.PLAN_ID = a.PLAN_ID
left join WMS_IN_PLAN_DETAILS b on b.PLAN_ID = a.PLAN_ID
where a.PLAN_ID = #{planId}
</select>
<insert id="insertWmsInPlan" parameterType="WmsInPlan" useGeneratedKeys="true" keyProperty="planId">
insert into WMS_IN_PLAN
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -132,7 +205,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isDelete != null">IS_DELETE,</if>
<if test="planCode != null">PLAN_CODE,</if>
<if test="planTypeId != null">PLAN_TYPE_ID,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="state != null">#{state},</if>
<if test="sourceType != null">#{sourceType},</if>
@ -161,7 +234,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isDelete != null">#{isDelete},</if>
<if test="planCode != null">#{planCode},</if>
<if test="planTypeId != null">#{planTypeId},</if>
</trim>
</trim>
</insert>
<update id="updateWmsInPlan" parameterType="WmsInPlan">
@ -199,31 +272,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteWmsInPlanByPlanId" parameterType="String">
delete from WMS_IN_PLAN where PLAN_ID = #{planId}
delete
from WMS_IN_PLAN
where PLAN_ID = #{planId}
</delete>
<delete id="deleteWmsInPlanByPlanIds" parameterType="String">
delete from WMS_IN_PLAN where PLAN_ID in
delete from WMS_IN_PLAN where PLAN_ID in
<foreach item="planId" collection="array" open="(" separator="," close=")">
#{planId}
</foreach>
</delete>
<delete id="deleteWmsInPlanDetailsByPlanIds" parameterType="String">
delete from WMS_IN_PLAN_DETAILS where PLAN_ID in
delete from WMS_IN_PLAN_DETAILS where PLAN_ID in
<foreach item="planId" collection="array" open="(" separator="," close=")">
#{planId}
</foreach>
</delete>
<delete id="deleteWmsInPlanDetailsByPlanId" parameterType="String">
delete from WMS_IN_PLAN_DETAILS where PLAN_ID = #{planId}
delete
from WMS_IN_PLAN_DETAILS
where PLAN_ID = #{planId}
</delete>
<insert id="batchWmsInPlanDetails">
insert into WMS_IN_PLAN_DETAILS( PLAN_ID, MATERIAL_ID, BATCH, CELL_ID, QUANTITY, QUANTITY_IN, PLAN_IN_STATUS, REMARK, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, IS_ACTIVY, IS_DELETE) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.planId}, #{item.materialId}, #{item.batch}, #{item.cellId}, #{item.quantity}, #{item.quantityIn}, #{item.planInStatus}, #{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.isActivy}, #{item.isDelete})
insert into WMS_IN_PLAN_DETAILS( PLAN_ID, MATERIAL_ID, BATCH, CELL_ID, QUANTITY, QUANTITY_IN, PLAN_IN_STATUS,
REMARK, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, IS_ACTIVY, IS_DELETE) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.planId}, #{item.materialId}, #{item.batch}, #{item.cellId}, #{item.quantity}, #{item.quantityIn},
#{item.planInStatus}, #{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy},
#{item.updateTime}, #{item.isActivy}, #{item.isDelete})
</foreach>
</insert>
</mapper>