<?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" >
<mapper namespace= "com.glxp.api.admin.dao.business.StockOrderDao" >
<select id= "listStockOrder" parameterType= "com.glxp.api.admin.req.business.StockOrderQueryRequest"
resultType="com.glxp.api.admin.entity.business.StockOrderEntity">
SELECT *
FROM stock_order
INNER JOIN inv_warehouse_user on stock_order.locStorageCode = inv_warehouse_user.`code`
where status = 'success'
group by stock_order.id
</select>
<select id= "listStockOrderNoDealWith" parameterType= "com.glxp.api.admin.req.business.StockOrderQueryRequest"
resultType="com.glxp.api.admin.entity.business.StockOrderEntity">
select *
from stock_order
INNER JOIN inv_warehouse_user on stock_order.locStorageCode = inv_warehouse_user.`code`
where `status` = '101'
group by stock_order.id
ORDER BY id DESC
</select>
<insert id= "insertStockOrder" useGeneratedKeys= "true" keyProperty= "id"
parameterType="com.glxp.api.admin.entity.business.StockOrderEntity">
insert INTO stock_order(id, billNo, billdate, corpId, corpName, billType, billFlag,
thirdSysFk, status, statusInfo, type, sourceType,
printStatus, unitIdFk, customerId, thirdOrderFk, orderIdFk,
totalPrice, locStorageCode, supplementNo, createUser, reviewUser, entrustEnd, auditTime,
updateTime, invWarehouseCode, fromSubInvCode,dept)
values (#{id},
#{billNo},
#{billdate},
#{corpId},
#{corpName},
#{billType},
#{billFlag},
#{thirdSysFk},
#{status},
#{statusInfo},
#{type},
#{sourceType},
#{printStatus}, #{unitIdFk}, #{customerId}, #{thirdOrderFk}, #{orderIdFk}, #{totalPrice},
#{locStorageCode}, #{supplementNo}, #{createUser}, #{reviewUser}, #{entrustEnd}, #{auditTime},
#{updateTime}, #{invWarehouseCode}, #{fromSubInvCode},#{dept})
</insert>
<update id= "updateById" parameterType= "com.glxp.api.admin.entity.business.StockOrderEntity" >
UPDATE stock_order
<trim prefix= "set" suffixOverrides= "," >
<if test= "billNo != null" > billNo=#{billNo},</if>
<if test= "billdate != null" > billdate=#{billdate},</if>
<if test= "corpId != null" > corpId=#{corpId},</if>
<if test= "corpName != null" > corpName=#{corpName},</if>
<if test= "billType != null" > billType=#{billType},</if>
<if test= "billFlag != null" > billFlag=#{billFlag},</if>
<if test= "thirdSysFk != null" > thirdSysFk=#{thirdSysFk},</if>
<if test= "status != null" > status=#{status},</if>
<if test= "statusInfo != null" > statusInfo=#{statusInfo},</if>
<if test= "type != null" > type=#{type},</if>
<if test= "sourceType != null" > sourceType=#{sourceType},</if>
<if test= "printStatus != null" > printStatus=#{printStatus},</if>
<if test= "unitIdFk != null" > unitIdFk=#{unitIdFk},</if>
<if test= "customerId != null" > customerId=#{customerId},</if>
<if test= "thirdOrderFk != null" > thirdOrderFk=#{thirdOrderFk},</if>
<if test= "orderIdFk != null" > orderIdFk=#{orderIdFk},</if>
<if test= "totalPrice != null" > totalPrice=#{totalPrice},</if>
<if test= "locStorageCode != null" > locStorageCode=#{locStorageCode},</if>
<if test= "supplementNo != null" > supplementNo=#{supplementNo},</if>
<if test= "createUser != null" > createUser=#{createUser},</if>
<if test= "reviewUser != null" > reviewUser=#{reviewUser},</if>
<if test= "entrustEnd != null" > entrustEnd=#{entrustEnd},</if>
<if test= "auditTime != null" > auditTime=#{auditTime},</if>
<if test= "updateTime != null" > updateTime=#{updateTime},</if>
<if test= "invWarehouseCode != null" > invWarehouseCode=#{invWarehouseCode},</if>
<if test= "fromSubInvCode != null" > fromSubInvCode=#{fromSubInvCode},</if>
<if test= "dept != null" > dept=#{dept},</if>
</trim>
WHERE id = #{id}
</update>
<delete id= "deleteByOrderId" parameterType= "Map" >
DELETE
FROM stock_order
WHERE id = #{orderId}
</delete>
<delete id= "deleteById" parameterType= "Map" >
DELETE
FROM stock_order
WHERE id = #{id}
</delete>
<update id= "updateByStatus" parameterType= "Map" >
UPDATE stock_order
SET `status` = #{status}
where id = #{orderId}
</update>
<update id= "updateSupplementNoByBillNo" >
update stock_order
set supplementNo = #{supplementOrderNo}
where billNo = #{billNo}
</update>
<select id= "filterListOr" parameterType= "com.glxp.api.admin.req.business.StockOrderFilterRequest"
resultType="com.glxp.api.admin.entity.business.StockOrderEntity">
SELECT stock_order.* ,inv_warehouse.name invName, iws.name subInvName ,basic_bustype_local.name billTypeName,iws2.name fromSubInvName,auth_dept.name deptName FROM stock_order
left join basic_bustype_local on stock_order.billType = basic_bustype_local.action
LEFT JOIN inv_warehouse ON stock_order.locStorageCode = inv_warehouse.`code`
LEFT JOIN inv_warehouse_sub ON stock_order.locStorageCode = inv_warehouse.`code`
LEFT JOIN inv_warehouse_sub iws ON stock_order.invWarehouseCode = iws.`code`
LEFT JOIN inv_warehouse_sub iws2 ON stock_order.fromSubInvCode = iws2.`code`
LEFT JOIN inv_warehouse_user on inv_warehouse_sub.code = inv_warehouse_user.`code`
left join auth_dept on stock_order.dept =auth_dept.code
<where >
<if test= "id != '' and id!=null" >
and stock_order.id =#{id}
</if>
<if test= "billNo != '' and billNo!=null" >
and billNo LIKE concat('%',#{billNo},'%')
</if>
<if test= "billdate != '' and billdate!=null" >
and billdate = #{billdate}
</if>
<if test= "startDate != '' and startDate != null" >
and billdate >= #{startDate}
</if>
<if test= "endDate != '' and endDate != null" >
and billdate <![CDATA[ <= ]]> #{endDate}
</if>
<if test= "corpId != '' and corpId!=null" >
and corpId = #{corpId}
</if>
<if test= "corpName != '' and corpName!=null" >
and corpName LIKE concat('%',#{corpName},'%')
</if>
<if test= "billType != '' and billType!=null" >
and billType = #{billType}
</if>
<if test= "billFlag != '' and billFlag!=null" >
and billFlag = #{billFlag}
</if>
<if test= "thirdSysFk != '' and thirdSysFk!=null" >
and thirdSysFk = #{thirdSysFk}
</if>
<if test= "status != '' and status!=null" >
and stock_order.status = #{status}
</if>
<if test= "statusInfo != '' and statusInfo!=null" >
and statusInfo = #{statusInfo}
</if>
<if test= "type != '' and type!=null" >
and stock_order.type = #{type}
</if>
<if test= "sourceType != '' and sourceType!=null" >
and sourceType = #{sourceType}
</if>
<if test= "printStatus != '' and printStatus!=null" >
and printStatus = #{printStatus}
</if>
<if test= "unitIdFk != '' and unitIdFk!=null" >
and unitIdFk = #{unitIdFk}
</if>
<if test= "localAction != '' and localAction!=null" >
and billType = #{localAction}
</if>
<if test= "userId!=null" >
and (invWarehouseCode in (select code from inv_warehouse_user WHERE userId =#{userId}) or
invWarehouseCode is null or invWarehouseCode='')
</if>
<if test= "customerId != '' and customerId!=null" >
and customerId = #{customerId}
</if>
<if test= "thirdOrderFk != '' and thirdOrderFk!=null" >
and thirdOrderFk = #{thirdOrderFk}
</if>
<if test= "orderIdFk != '' and orderIdFk!=null" >
and orderIdFk = #{orderIdFk}
</if>
<if test= "totalPrice != '' and totalPrice!=null" >
and totalPrice = #{totalPrice}
</if>
<if test= "locStorageCode != '' and locStorageCode!=null" >
and locStorageCode = #{locStorageCode}
</if>
<if test= "invWarehouseCode != '' and invWarehouseCode!=null" >
and invWarehouseCode = #{invWarehouseCode}
</if>
<if test= "createUser!=null" >
and createUser = #{createUser}
</if>
<if test= "reviewUser!=null" >
and reviewUser = #{reviewUser}
</if>
<if test= "startTime!=null and startTime!=''" >
<![CDATA[ and DATE_FORMAT(billdate, '%Y-%m-%d')>= DATE_FORMAT(#{startTime}, '%Y-%m-%d') ]]>
</if>
<if test= "endTime!=null and endTime!=''" >
<![CDATA[ and DATE_FORMAT(billdate, '%Y-%m-%d') <= DATE_FORMAT(#{endTime}, '%Y-%m-%d') ]]>
</if>
<if test= "startDate!=null and startDate!=''" >
<![CDATA[ and DATE_FORMAT(billdate, '%Y-%m-%d')>= DATE_FORMAT(#{startDate}, '%Y-%m-%d') ]]>
</if>
<if test= "endDate!=null and endDate!=''" >
<![CDATA[ and DATE_FORMAT(billdate, '%Y-%m-%d') <= DATE_FORMAT(#{endDate}, '%Y-%m-%d') ]]>
</if>
<if test= "userId!=null" >
and inv_warehouse_user.userId =#{userId}
</if>
</where>
group by stock_order.id
ORDER BY id DESC
</select>
<select id= "filterEntrust" parameterType= "com.glxp.api.admin.req.business.StockOrderFilterRequest"
resultType="com.glxp.api.admin.entity.business.StockOrderEntity">
SELECT stock_order.* FROM stock_order
INNER JOIN basic_entrust_accept on locStorageCode = basic_entrust_accept.curInv
<where >
<if test= "status != '' and status!=null" >
and status = #{status}
</if>
<if test= "locStorageCode != '' and locStorageCode!=null" >
and locStorageCode = #{locStorageCode}
</if>
<if test= "entrustUser != '' and entrustUser!=null" >
and basic_entrust_accept.entrustUser = #{entrustUser}
</if>
</where>
group by stock_order.id
ORDER BY id DESC
</select>
<select id= "findOne" parameterType= "com.glxp.api.admin.req.business.StockOrderFilterRequest"
resultType="com.glxp.api.admin.entity.business.StockOrderEntity">
SELECT * FROM stock_order
<where >
<if test= "id != '' and id!=null" >
and id =#{id}
</if>
<if test= "corpId != '' and corpId !=null" >
and corpId =#{corpId}
</if>
<if test= "billNo != '' and billNo !=null" >
and billNo =#{billNo}
</if>
<if test= "billType != '' and billType !=null" >
and billType =#{billType}
</if>
<if test= "customerId != '' and customerId !=null" >
and customerId =#{customerId}
</if>
<if test= "thirdOrderFk != '' and thirdOrderFk !=null" >
and thirdOrderFk =#{thirdOrderFk}
</if>
<if test= "orderIdFk != '' and orderIdFk !=null" >
and orderIdFk =#{orderIdFk}
</if>
<if test= "createUser!=null" >
and createUser = #{createUser}
</if>
<if test= "reviewUser!=null" >
and reviewUser = #{reviewUser}
</if>
<if test= "invWarehouseCode != '' and invWarehouseCode!=null" >
and invWarehouseCode = #{invWarehouseCode}
</if>
</where>
limit 1
</select>
<select id= "listOrderPrint" parameterType= "com.glxp.api.admin.req.business.StockOrderFilterRequest"
resultType="com.glxp.api.admin.entity.business.StockOrderPrintEntity">
SELECT stock_order.*, stock_order_detail.productId, stock_order_detail.productName,
stock_order_detail.spec, stock_order_detail.batchNo, stock_order_detail.productDate,
stock_order_detail.expireDate, stock_order_detail.count, stock_order_detail.sweepCount,
stock_order_detail.ylqxzcrbarmc,stock_order_detail.manufactory, stock_order_detail.zczbhhzbapzbh,
stock_order_detail.price,inv_warehouse.name locInv,basic_products.spmc,
basic_products.cpms,basic_udirel.measname,auth_dept.`name` deptName
FROM stock_order
INNER JOIN stock_order_detail on stock_order.id = stock_order_detail.orderIdFk
LEFT JOIN inv_warehouse ON stock_order.locStorageCode = inv_warehouse.`code`
LEFT JOIN inv_warehouse_sub ON inv_warehouse_sub.parentId = inv_warehouse.`code`
LEFT JOIN inv_warehouse_user on inv_warehouse_sub.code = inv_warehouse_user.`code`
left join basic_udirel on stock_order_detail.productId = basic_udirel.id
left JOIN basic_products on basic_products.uuid = basic_udirel.uuid
left join auth_dept on stock_order.dept = auth_dept.`code`
<where >
<if test= "id != '' and id!=null" >
and stock_order.id =#{id}
</if>
<if test= "corpId != '' and corpId !=null" >
and stock_order.corpId =#{corpId}
</if>
<if test= "billNo != '' and billNo !=null" >
and stock_order.billNo =#{billNo}
</if>
<if test= "customerId != '' and customerId !=null" >
and stock_order.customerId =#{customerId}
</if>
<if test= "invWarehouseCode != '' and invWarehouseCode!=null" >
and invWarehouseCode = #{invWarehouseCode}
</if>
<if test= "userId!=null" >
and (invWarehouseCode in (select code from inv_warehouse_user WHERE userId =#{userId}) or
invWarehouseCode is null or
invWarehouseCode ='')
</if>
</where>
group by stock_order_detail.id
</select>
<select id= "listCodePrint" parameterType= "com.glxp.api.admin.req.business.StockOrderFilterRequest"
resultType="com.glxp.api.admin.entity.business.StockOrderPrintEntity">
select io_codes.code udiCode,basic_udirel.id productId,basic_products.cpmctymc productName,basic_products.ggxh
spec,io_codes.batchNo,io_codes.produceDate productDate,io_codes.expireDate ,io_codes.serialNo,io_codes.count,
basic_products.ylqxzcrbarmc,basic_udirel.manufactory,basic_udirel.measname,basic_products.zczbhhzbapzbh,
inv_warehouse.name locInv, inv_warehouse_sub.name subInv, basic_products.spmc,
basic_products.cpms,io_codes.nameCode,io_codes.relId
from io_codes
INNER JOIN basic_udirel on io_codes.relId = basic_udirel.id
INNER JOIN basic_products on basic_products.uuid = basic_udirel.uuid
LEFT JOIN inv_warehouse ON io_codes.locStorageCode = inv_warehouse.`code`
left join inv_warehouse_sub on io_codes.invWarehouseCode = inv_warehouse_sub.code
<where >
<if test= "orderId != '' and orderId !=null" >
and io_codes.orderId =#{orderId}
</if>
</where>
group by io_codes.id
</select>
<select id= "selectSupplementOrderList" resultType= "com.glxp.api.admin.entity.business.StockOrderEntity" >
SELECT
billNo, orderIdFk, `status`
FROM
stock_order
WHERE
( supplementNo IS NULL OR supplementNo = '' )
AND billType IN (
SELECT
localAction
FROM
basic_bussiness_type
WHERE
supplementOrderType IS NOT NULL
OR supplementOrderType != '')
</select>
<select id= "findById" resultType= "com.glxp.api.admin.entity.business.StockOrderEntity" >
select *
from stock_order
where id = #{id}
</select>
<select id= "selectById" resultType= "com.glxp.api.admin.entity.business.StockOrderEntity" >
select *
from stock_order
where id = #{id}
</select>
<delete id= "deleteByOrderIdFk" >
delete
from stock_order
where orderIdFk = #{orderIdFk}
</delete>
<select id= "selectWaitSubmitOrders" resultType= "java.lang.String" >
select id
from stock_order
where billNo in (
select erpFk
from io_order
where erpFk in
(select billNo
from stock_order
where stock_order.billType in (select code from basic_third_sys_bus_api))
and exportStatus = 0
)
</select>
<select id= "selectIdByOrderIdFk" resultType= "java.lang.Integer" >
select id
from stock_order
where orderIdFk = #{orderIdFk}
</select>
<select id= "selectUploadList" resultType= "com.glxp.api.admin.entity.business.StockOrderEntity" >
select t1.* from stock_order t1 left join io_order t2 on t1.billNo = t2.erpFk
<where >
t2.erpFk is not null
<if test= "request.billNo != null and request.billNo != ''" >
AND ((t1.billNo like concat('%', #{request.billNo}, '%') and t2.erpFk like concat('%', #{request.billNo}, '%')) or t2.thirdBillNo like concat('%',#{request.billNo},'%'))
</if>
<if test= "request.submitStatus != null" >
AND t2.exportStatus = #{request.submitStatus}
</if>
<if test= "request.orderStatus != null" >
AND t1.status = #{request.orderStatus} and t1.status != 1
</if>
<if test= "request.billType != null and request.billType != ''" >
AND t1.billType = #{request.billType}
</if>
<if test= "request.billTypes != null and request.billTypes.size() != 0" >
AND t1.billType in
<foreach collection= "request.billTypes" index= "index" item= "item" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
<if test= "request.corpName != null and request.corpName != ''" >
AND t1.corpName like concat('%',#{request.corpName},'%')
</if>
<if test= "request.startTime!=null and request.startTime!=''" >
<![CDATA[ and DATE_FORMAT(t1.billdate, '%Y-%m-%d')>= DATE_FORMAT(#{request.startTime}, '%Y-%m-%d') ]]>
</if>
<if test= "request.endTime!=null and request.endTime!=''" >
<![CDATA[ and DATE_FORMAT(t1.billdate, '%Y-%m-%d') <= DATE_FORMAT(#{request.endTime}, '%Y-%m-%d') ]]>
</if>
</where>
order by t1.billdate desc
</select>
<select id= "findBillTypeById" resultType= "java.lang.String" >
select billType from stock_order where id = #{id}
</select>
</mapper>