@ -3,62 +3,47 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace= "com.ruoyi.purchase.mapper.PurchasePlanChildMapper" >
<resultMap type= "PurchasePlanChild" id= "PurchasePlanChildResult" >
<result property= "purchasePlanChildId" column= "purchase_plan_child_id" />
<result property= "purchasePlanCode" column= "purchase_plan_code" />
<result property= "materialId" column= "material_id" />
<result property= "materialCode" column= "material_code" />
<result property= "purchasePlanStatus" column= "purchase_plan_status" />
<result property= "correlationCode" column= "correlation_code" />
<result property= "purchasePlanType" column= "purchase_plan_type" />
<result property= "materialNo" column= "material_no" />
<result property= "materialName" column= "material_name" />
<result property= "materialType" column= "material_type" />
<result property= "processMethod" column= "process_method" />
<result property= "unit" column= "unit" />
<result property= "brand" column= "brand" />
<result property= "photoUrl" column= "photoUrl" />
<result property= "describe" column= "describe" />
<result property= "warehouseDept" column= "warehouseDept" />
<result property= "materialNum" column= "material_num" />
<result property= "materialSole" column= "material_sole" />
<result property= "materialRmb" column= "material_rmb" />
<result property= "materialNoRmb" column= "material_noRmb" />
<result property= "supplierCode" column= "supplier_code" />
<result property= "supplierCodes" column= "supplier_codes" />
<result property= "planCodes" column= "purchase_plan_codes" />
<result property= "correlationCodes" column= "correlation_codes" />
<result property= "supplierName" column= "supplier_name" />
<result property= "materialPhotourl" column= "material_photoUrl" />
<result property= "materialBrand" column= "material_brand" />
<result property= "materialUnit" column= "material_unit" />
<result property= "materialDescribe" column= "material_describe" />
<result property= "materialProcessMethod" column= "material_process_method" />
<result property= "materialModel" column= "material_model" />
<result property= "warehouseDept" column= "warehouse_dept" />
<result property= "materialNormbSum" column= "material_noRmb_sum" />
<result property= "materialRmbSum" column= "material_rmb_sum" />
<result property= "planPurchaseNum" column= "plan_purchase_num" />
<result property= "purchaseNum" column= "purchase_num" />
<result property= "actualPurchaseNum" column= "actual_purchase_num" />
<result property= "sharedInventoryOccupancyNum" column= "shared_inventory_occupancy_num" />
<result property= "cancelNum" column= "cancel_num" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "remark" column= "remark" />
<result property= "useStatus" column= "use_status" />
<result property= "auditStatus" column= "audit_status" />
<result property= "delFlag" column= "del_flag" />
</resultMap>
<sql id= "selectPurchasePlanChildVo" >
select purchase_plan_child_id, purchase_plan_code, material_id,
material_code, material_name, material_type, process_method, brand,unit,
photoUrl, `describe`, warehouseDept,material_num, material_sole, material_rmb,supplier_code,supplier_name,
material_noRmb, create_by, create_time, update_by, update_time, remark,
use_status, audit_status, del_flag from purchase_plan_child
select purchase_plan_child_id, purchase_plan_code, purchase_plan_status, correlation_code, purchase_plan_type, material_no, material_name, material_type, material_photoUrl, material_brand, material_unit, material_describe, material_process_method, material_model, warehouse_dept, material_noRmb_sum, material_rmb_sum, plan_purchase_num, purchase_num, actual_purchase_num, shared_inventory_occupancy_num, cancel_num, create_by, create_time, update_by, update_time, remark, del_flag from purchase_plan_child
</sql>
<select id= "selectPurchasePlanChildList" parameterType= "PurchasePlanChild" resultMap= "PurchasePlanChildResult" >
<include refid= "selectPurchasePlanChildVo" />
<where >
<if test= "purchasePlanChildId != null " > and purchase_plan_child_id = #{purchasePlanChildId}</if>
<if test= "purchasePlanCode != null and purchasePlanCode != ''" > and purchase_plan_code = #{purchasePlanCode}</if>
<if test= "materialId != null " > and material_id = #{materialId}</if>
<if test= "materialCode != null and materialCode != ''" > and material_code = #{materialCode}</if>
<if test= "materialName != null and materialName != ''" > and material_name = #{materialName}</if>
<if test= "materialType != null and materialType != ''" > and material_type = #{materialType}</if>
<if test= "processMethod != null and processMethod != ''" > and process_method = #{processMethod}</if>
<if test= "brand != null and brand != ''" > and brand = #{brand}</if>
<if test= "warehouseDept != null and warehouseDept != ''" > and warehouseDept = #{warehouseDept}</if>
<if test= "useStatus != null and useStatus != ''" > and use_status = #{useStatus}</if>
<if test= "auditStatus != null and auditStatus != ''" > and audit_status = #{auditStatus}</if>
<if test= "purchasePlanCode != null" > and purchase_plan_code = #{purchasePlanCode}</if>
</where>
order by create_time desc
</select>
<select id= "selectPurchasePlanChildById" parameterType= "Long" resultMap= "PurchasePlanChildResult" >
@ -66,153 +51,97 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where purchase_plan_child_id = #{purchasePlanChildId}
</select>
<select id= "selectPurchasePlanChildListByPlanCodes" resultMap= "PurchasePlanChildResult" >
<include refid= "selectPurchasePlanChildVo" />
where purchase_plan_code in
<foreach item= "purchasePlanCode" collection= "array" open= "(" separator= "," close= ")" >
#{purchasePlanCode}
</foreach>
</select>
<select id= "selectPurchasePlanChildByCodeAndNo" parameterType= "PurchasePlanChild" resultMap= "PurchasePlanChildResult" >
<include refid= "selectPurchasePlanChildVo" />
where purchase_plan_code = #{purchasePlanCode}
and material_code = #{materialCode}
</select>
<insert id= "insertPurchasePlanChild" parameterType= "PurchasePlanChild" useGeneratedKeys= "true" keyProperty= "purchasePlanChildId" >
insert into purchase_plan_child
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "purchasePlanCode != null" > purchase_plan_code,</if>
<if test= "materialId != null" > material_id,</if>
<if test= "materialCode != null" > material_code,</if>
<if test= "purchasePlanStatus != null" > purchase_plan_status,</if>
<if test= "correlationCode != null" > correlation_code,</if>
<if test= "purchasePlanType != null" > purchase_plan_type,</if>
<if test= "materialNo != null" > material_no,</if>
<if test= "materialName != null" > material_name,</if>
<if test= "materialType != null" > material_type,</if>
<if test= "processMethod != null" > process_method,</if>
<if test= "brand != null" > brand,</if>
<if test= "photoUrl != null" > photoUrl,</if>
<if test= "describe != null" > `describe`,</if>
<if test= "unit != null" > unit,</if>
<if test= "warehouseDept != null" > warehouseDept,</if>
<if test= "materialNum != null" > material_num,</if>
<if test= "materialSole != null" > material_sole,</if>
<if test= "materialRmb != null" > material_rmb,</if>
<if test= "materialNoRmb != null" > material_noRmb,</if>
<if test= "materialPhotourl != null" > material_photoUrl,</if>
<if test= "materialBrand != null" > material_brand,</if>
<if test= "materialUnit != null" > material_unit,</if>
<if test= "materialDescribe != null" > material_describe,</if>
<if test= "materialProcessMethod != null" > material_process_method,</if>
<if test= "materialModel != null" > material_model,</if>
<if test= "warehouseDept != null" > warehouse_dept,</if>
<if test= "materialNormbSum != null" > material_noRmb_sum,</if>
<if test= "materialRmbSum != null" > material_rmb_sum,</if>
<if test= "planPurchaseNum != null" > plan_purchase_num,</if>
<if test= "purchaseNum != null" > purchase_num,</if>
<if test= "actualPurchaseNum != null" > actual_purchase_num,</if>
<if test= "sharedInventoryOccupancyNum != null" > shared_inventory_occupancy_num,</if>
<if test= "cancelNum != null" > cancel_num,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
<if test= "remark != null" > remark,</if>
<if test= "useStatus != null" > use_status,</if>
<if test= "auditStatus != null" > audit_status,</if>
<if test= "delFlag != null" > del_flag,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "purchasePlanCode != null" > #{purchasePlanCode},</if>
<if test= "materialId != null" > #{materialId},</if>
<if test= "materialCode != null" > #{materialCode},</if>
<if test= "purchasePlanStatus != null" > #{purchasePlanStatus},</if>
<if test= "correlationCode != null" > #{correlationCode},</if>
<if test= "purchasePlanType != null" > #{purchasePlanType},</if>
<if test= "materialNo != null" > #{materialNo},</if>
<if test= "materialName != null" > #{materialName},</if>
<if test= "materialType != null" > #{materialType},</if>
<if test= "processMethod != null" > #{processMethod},</if>
<if test= "brand != null" > #{brand},</if>
<if test= "photoUrl != null" > #{photoUrl},</if>
<if test= "describe != null" > #{describe},</if>
<if test= "unit != null" > #{unit},</if>
<if test= "materialPhotourl != null" > #{materialPhotourl},</if>
<if test= "materialBrand != null" > #{materialBrand},</if>
<if test= "materialUnit != null" > #{materialUnit},</if>
<if test= "materialDescribe != null" > #{materialDescribe},</if>
<if test= "materialProcessMethod != null" > #{materialProcessMethod},</if>
<if test= "materialModel != null" > #{materialModel},</if>
<if test= "warehouseDept != null" > #{warehouseDept},</if>
<if test= "materialNum != null" > #{materialNum},</if>
<if test= "materialSole != null" > #{materialSole},</if>
<if test= "materialRmb != null" > #{materialRmb},</if>
<if test= "materialNoRmb != null" > #{materialNoRmb},</if>
<if test= "materialNormbSum != null" > #{materialNormbSum},</if>
<if test= "materialRmbSum != null" > #{materialRmbSum},</if>
<if test= "planPurchaseNum != null" > #{planPurchaseNum},</if>
<if test= "purchaseNum != null" > #{purchaseNum},</if>
<if test= "actualPurchaseNum != null" > #{actualPurchaseNum},</if>
<if test= "sharedInventoryOccupancyNum != null" > #{sharedInventoryOccupancyNum},</if>
<if test= "cancelNum != null" > #{cancelNum},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
<if test= "remark != null" > #{remark},</if>
<if test= "useStatus != null" > #{useStatus},</if>
<if test= "auditStatus != null" > #{auditStatus},</if>
<if test= "delFlag != null" > #{delFlag},</if>
</trim>
</insert>
<insert id= "batchInsertPurchasePlanChild" parameterType= "java.util.List" useGeneratedKeys= "true" keyProperty= "purchasePlanChildId" >
insert into purchase_plan_child
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "item.purchasePlanCode != null" > purchase_plan_code,</if>
<if test= "item.materialCode != null" > material_code,</if>
<if test= "item.materialName != null" > material_name,</if>
<if test= "item.materialType != null" > material_type,</if>
<if test= "item.processMethod != null" > process_method,</if>
<if test= "item.brand != null" > brand,</if>
<if test= "item.describe != null" > `describe`,</if>
<if test= "item.unit != null" > unit,</if>
<if test= "item.warehouseDept != null" > warehouse_dept,</if>
<if test= "item.materialNum != null" > material_num,</if>
<if test= "item.createBy != null" > create_by,</if>
<if test= "item.createTime != null" > create_time,</if>
<if test= "item.updateBy != null" > update_by,</if>
<if test= "item.updateTime != null" > update_time,</if>
<if test= "item.remark != null" > remark,</if>
<if test= "item.useStatus != null" > use_status,</if>
<if test= "item.auditStatus != null" > audit_status,</if>
<if test= "item.delFlag != null" > del_flag,</if>
</trim>
<foreach collection= "list" item= "item" index= "index" separator= "," >
values
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "item.purchasePlanCode != null" > #{item.purchasePlanCode},</if>
<if test= "item.materialCode != null" > #{item.materialCode},</if>
<if test= "item.materialName != null" > #{item.materialName},</if>
<if test= "item.materialType != null" > #{item.materialType},</if>
<if test= "item.processMethod != null" > #{item.processMethod},</if>
<if test= "item.brand != null" > #{item.brand},</if>
<if test= "item.describe != null" > #{item.describe},</if>
<if test= "item.unit != null" > #{item.unit},</if>
<if test= "item.warehouseDept != null" > #{item.warehouseDept},</if>
<if test= "item.materialNum != null" > #{item.materialNum},</if>
<if test= "item.createBy != null" > #{item.createBy},</if>
<if test= "item.createTime != null" > #{item.createTime},</if>
<if test= "item.updateBy != null" > #{item.updateBy},</if>
<if test= "item.updateTime != null" > #{item.updateTime},</if>
<if test= "item.remark != null" > #{item.remark},</if>
<if test= "item.useStatus != null" > #{item.useStatus},</if>
<if test= "item.auditStatus != null" > #{item.auditStatus},</if>
<if test= "item.delFlag != null" > #{item.delFlag}</if>
</trim>
</foreach>
</insert>
<update id= "updatePurchasePlanChild" parameterType= "PurchasePlanChild" >
update purchase_plan_child
<trim prefix= "SET" suffixOverrides= "," >
<if test= "purchasePlanCode != null" > purchase_plan_code = #{purchasePlanCode},</if>
<if test= "materialId != null" > material_id = #{materialId},</if>
<if test= "materialCode != null" > material_code = #{materialCode},</if>
<if test= "purchasePlanStatus != null" > purchase_plan_status = #{purchasePlanStatus},</if>
<if test= "correlationCode != null" > correlation_code = #{correlationCode},</if>
<if test= "purchasePlanType != null" > purchase_plan_type = #{purchasePlanType},</if>
<if test= "materialNo != null" > material_no = #{materialNo},</if>
<if test= "materialName != null" > material_name = #{materialName},</if>
<if test= "materialType != null" > material_type = #{materialType},</if>
<if test= "processMethod != null" > process_method = #{processMethod},</if>
<if test= "brand != null" > brand = #{brand},</if>
<if test= "photoUrl != null" > photoUrl = #{photoUrl},</if>
<if test= "describe != null" > `describe` = #{describe},</if>
<if test= "unit != null" > unit = #{unit},</if>
<if test= "warehouseDept != null" > warehouseDept = #{warehouseDept},</if>
<if test= "materialNum != null" > material_num = #{materialNum},</if>
<if test= "materialSole != null" > material_sole = #{materialSole},</if>
<if test= "materialRmb != null" > material_rmb = #{materialRmb},</if>
<if test= "materialNoRmb != null" > material_noRmb = #{materialNoRmb},</if>
<if test= "materialPhotourl != null" > material_photoUrl = #{materialPhotourl},</if>
<if test= "materialBrand != null" > material_brand = #{materialBrand},</if>
<if test= "materialUnit != null" > material_unit = #{materialUnit},</if>
<if test= "materialDescribe != null" > material_describe = #{materialDescribe},</if>
<if test= "materialProcessMethod != null" > material_process_method = #{materialProcessMethod},</if>
<if test= "materialModel != null" > material_model = #{materialModel},</if>
<if test= "warehouseDept != null" > warehouse_dept = #{warehouseDept},</if>
<if test= "materialNormbSum != null" > material_noRmb_sum = #{materialNormbSum},</if>
<if test= "materialRmbSum != null" > material_rmb_sum = #{materialRmbSum},</if>
<if test= "planPurchaseNum != null" > plan_purchase_num = #{planPurchaseNum},</if>
<if test= "purchaseNum != null" > purchase_num = #{purchaseNum},</if>
<if test= "actualPurchaseNum != null" > actual_purchase_num = #{actualPurchaseNum},</if>
<if test= "sharedInventoryOccupancyNum != null" > shared_inventory_occupancy_num = #{sharedInventoryOccupancyNum},</if>
<if test= "cancelNum != null" > cancel_num = #{cancelNum},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "useStatus != null" > use_status = #{useStatus},</if>
<if test= "auditStatus != null" > audit_status = #{auditStatus},</if>
<if test= "delFlag != null" > del_flag = #{delFlag},</if>
</trim>
where purchase_plan_child_id = #{purchasePlanChildId}
@ -236,63 +165,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id= "restorePurchasePlanChildById" parameterType= "Long" >
update purchase_plan_child set del_flag = '0' where purchase_plan_child_id = #{purchasePlanChildId}
</update>
<select id= "getPurchasePlanChildByPlanCodes" parameterType= "String" resultMap= "PurchasePlanChildResult" >
<!-- SELECT -->
<!-- GROUP_CONCAT(DISTINCT plan.purchase_plan_code ORDER BY plan.purchase_plan_code) AS purchase_plan_codes, -->
<!-- GROUP_CONCAT(DISTINCT planOrder.correlation_code ORDER BY planOrder.correlation_code) AS correlation_codes, -->
<!-- GROUP_CONCAT(DISTINCT CONCAT(quote.material_code,'|',quote.purchase_quote_code , '|' ,quote.supplier_code,'|', -->
<!-- quote.supplier_name,'|',quote.material_name,'|',quote.material_noRmb,'|',quote.material_rmb, '|', -->
<!-- plan.purchase_plan_code,'|',planOrder.correlation_code) -->
<!-- ORDER BY quote.supplier_code) AS supplier_codes, -->
<!-- plan.material_code, -->
<!-- plan.material_name, -->
<!-- plan.material_type, -->
<!-- plan.process_method, -->
<!-- plan.brand, -->
<!-- plan.photoUrl, -->
<!-- plan.material_num -->
<!-- FROM -->
<!-- purchase_plan_child AS plan -->
<!-- LEFT JOIN purchase_plan AS planOrder -->
<!-- ON plan.purchase_plan_code = planOrder.purchase_plan_code -->
<!-- AND planOrder.del_flag = '0' and planOrder.use_status = '1' and planOrder.audit_status = '1' -->
<!-- LEFT JOIN ( -->
<!-- SELECT material_code, MAX(create_time) AS max_create_time -->
<!-- FROM purchase_quote_child -->
<!-- WHERE del_flag = '0' -->
<!-- GROUP BY material_code -->
<!-- ) AS quoteLatestTime -->
<!-- ON quoteLatestTime.material_code = plan.material_code -->
<!-- LEFT JOIN purchase_quote_child AS quote -->
<!-- ON quoteLatestTime.material_code = quote.material_code -->
<!-- AND quote.create_time = quoteLatestTime.max_create_time -->
<!-- AND quote.del_flag = '0' -->
<!-- WHERE -->
<!-- plan.purchase_plan_code IN -->
<!-- <foreach item="purchasePlanCode" collection="array" open="(" separator="," close=")"> -->
<!-- #{purchasePlanCode} -->
<!-- </foreach> -->
<!-- AND plan.del_flag = '0' -->
<!-- GROUP BY -->
<!-- plan.material_code; -->
select
planChild.material_code,
planChild.material_name,
planChild.material_type,
planChild.process_method,
planChild.brand,
planChild.photoUrl,
planChild.unit,
planChild.warehouseDept,
sum(planChild.material_num) as material_num,
GROUP_CONCAT(DISTINCT plan.correlation_code ORDER BY plan.correlation_code) AS correlation_codes,
GROUP_CONCAT(DISTINCT plan.purchase_plan_code ORDER BY plan.purchase_plan_code) AS purchase_plan_codes
from purchase_plan_child as planChild
left join purchase_plan as plan on plan.purchase_plan_code = planChild.purchase_plan_code
where plan.purchase_plan_code IN
<foreach item= "purchasePlanCode" collection= "array" open= "(" separator= "," close= ")" >
#{purchasePlanCode}
</foreach>
group by material_code
</select>
</mapper>