feat: 代码优化

dev_drug_dm
chenhc 1 month ago
parent 020d255254
commit 598d34894f

@ -3,33 +3,42 @@
<mapper namespace="com.glxp.api.dao.inv.InvPreinOrderDao">
<select id="filterList" parameterType="com.glxp.api.req.inv.FilterInvPreinRequest"
resultType="com.glxp.api.res.inv.InvPreinOrderResponse">
select io.*,
(select name from basic_bussiness_type bus where bus.action = io.action) billTypeName,
(select name from auth_dept ad where ad.code = io.deptCode) deptName,
(select name from auth_warehouse aw where aw.code = io.invCode) invName,
(SELECT fromType FROM io_order ior WHERE ior.billNo = io.billNo) orderFromType,
(select employeeName from auth_user au where au.id = io.createUser) createUserName,
(select employeeName from auth_user au2 where au2.id = io.updateUser) updateUserName,
(select employeeName from auth_user au3 where au3.id = io.reviewUser) reviewUserName,
(select employeeName from auth_user au4 where au4.id = io.checkUser) checkUserName,
(select name from basic_corp bc where bc.erpId = io.fromCorp) fromCorpName
from inv_prein_order as io
SELECT io.*,
bus.name AS billTypeName,
ad.name AS deptName,
aw.name AS invName,
ior.fromType AS orderFromType,
au.employeeName AS createUserName,
au2.employeeName AS updateUserName,
au3.employeeName AS reviewUserName,
au4.employeeName AS checkUserName,
bc.name AS fromCorpName
FROM inv_prein_order AS io
LEFT JOIN basic_bussiness_type AS bus ON bus.action = io.action
LEFT JOIN auth_dept AS ad ON ad.code = io.deptCode
LEFT JOIN auth_warehouse AS aw ON aw.code = io.invCode
LEFT JOIN io_order AS ior ON ior.billNo = io.billNo
LEFT JOIN auth_user AS au ON au.id = io.createUser
LEFT JOIN auth_user AS au2 ON au2.id = io.updateUser
LEFT JOIN auth_user AS au3 ON au3.id = io.reviewUser
LEFT JOIN auth_user AS au4 ON au4.id = io.checkUser
LEFT JOIN basic_corp AS bc ON bc.erpId = io.fromCorp
<where>
<if test="billNo != null and billNo != ''">
AND billNo like concat('%', #{billNo}, '%')
AND io.billNo like concat('%', #{billNo}, '%')
</if>
<if test="fromCorp != null and fromCorp != ''">
AND fromCorp = #{fromCorp}
AND io.fromCorp = #{fromCorp}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
AND date_format(io.createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d')
</if>
<if test="startTime != null and startTime != '' and (endTime == null or endTime == '')">
AND date_format(createTime, '%Y-%m-%d') >= date_format(#{startTime}, '%Y-%m-%d')
AND date_format(io.createTime, '%Y-%m-%d') >= date_format(#{startTime}, '%Y-%m-%d')
</if>
<if test="endTime != null and endTime != '' and (startTime == null or startTime == '')">
AND date_format(createTime, '%Y-%m-%d') &lt;= date_format(#{endTime}, '%Y-%m-%d')
AND date_format(io.createTime, '%Y-%m-%d') &lt;= date_format(#{endTime}, '%Y-%m-%d')
</if>
</where>
</select>

@ -2,7 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glxp.api.dao.inv.InvRemindMsgDao">
<select id="filterList" resultType="com.glxp.api.res.inv.InvRemindMsgResponse">
select irm.id,
SELECT
irm.id,
irm.relId,
irm.batchNo,
irm.productionDate,
@ -23,13 +24,16 @@
bp.ggxh,
bp.manufactory,
bp.zczbhhzbapzbh,
bp.cpmctymc productName,
(select `name` from auth_warehouse where `code` = irm.invCode) invName,
(select `name` from auth_space where `code` = irm.invSpaceCode and invCode = irm.invCode) invSpaceName,
(select `name` from basic_corp where erpId = irm.supId) supName
from inv_remind_msg irm
left join basic_udirel bu on bu.id = irm.relId
left join basic_products bp on bp.uuid = bu.uuid
bp.cpmctymc AS productName,
aw.name AS invName,
aspc.name AS invSpaceName,
bc.name AS supName
FROM inv_remind_msg AS irm
LEFT JOIN basic_udirel AS bu ON bu.id = irm.relId
LEFT JOIN basic_products AS bp ON bp.uuid = bu.uuid
LEFT JOIN auth_warehouse AS aw ON aw.code = irm.invCode
LEFT JOIN auth_space AS aspc ON aspc.code = irm.invSpaceCode AND aspc.invWarehouseCode = irm.invCode
LEFT JOIN basic_corp AS bc ON bc.erpId = irm.supId
<where>
<if test="relId != null and relId != ''">
AND irm.relId = #{relId}

@ -2,7 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glxp.api.dao.inv.InvRemindSetDao">
<select id="filterList" resultType="com.glxp.api.res.inv.InvRemindSetResponse">
select irs.id,
SELECT
irs.id,
irs.relId,
irs.deptCode,
irs.invCode,
@ -18,13 +19,15 @@
bu.recentDateTime,
bu.useExpireTime,
bu.isDateBy,
bp.cpmctymc productName,
bp.cpmctymc AS productName,
bp.ggxh,
(select `name` from auth_warehouse where `code` = irs.invCode) invName,
(select `name` from auth_space where `code` = irs.invSpaceCode and invCode = irs.invCode) invSpaceName
from inv_remind_set irs
left join basic_udirel bu on bu.id = irs.relId
left join basic_products bp on bp.uuid = bu.uuid
aw.name AS invName,
aspc.name AS invSpaceName
FROM inv_remind_set AS irs
LEFT JOIN basic_udirel AS bu ON bu.id = irs.relId
LEFT JOIN basic_products AS bp ON bp.uuid = bu.uuid
LEFT JOIN auth_warehouse AS aw ON aw.code = irs.invCode
LEFT JOIN auth_space AS aspc ON aspc.code = irs.invSpaceCode AND aspc.invWarehouseCode = irs.invCode
<where>
<if test="relId != null and relId != ''">
AND irs.relId = #{relId}
@ -43,27 +46,26 @@
</select>
<select id="selectInfoByInvId" resultType="com.glxp.api.res.inv.InvRemindSetResponse">
select ip.relIdFk relId,
SELECT
ip.relIdFk AS relId,
ip.deptCode,
ip.invCode,
ipd.invSpaceCode,
(select `name` from auth_warehouse where code = ip.invCode) invName,
(select `name`
from auth_space
where code = ipd.invSpaceCode and invWarehouseCode = ip.invCode) invSpaceName,
aw.name AS invName,
aspc.name AS invSpaceName,
bp.ggxh,
bp.cpmctymc productName,
bp.cpmctymc AS productName,
bu.lowStockNum,
bu.overStockNum,
bu.recentDateTime,
bu.isDateBy
from inv_product ip
left join basic_udirel bu on ip.relIdFk = bu.id
left join basic_products bp on bu.uuid = bp.uuid
left join inv_product_detail ipd
on ip.relIdFk = ipd.relId and IFNULL(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
and ip.invCode = ipd.invCode
where ip.id = #{invId}
group by ip.id
FROM inv_product AS ip
LEFT JOIN basic_udirel AS bu ON ip.relIdFk = bu.id
LEFT JOIN basic_products AS bp ON bu.uuid = bp.uuid
LEFT JOIN inv_product_detail AS ipd ON ip.relIdFk = ipd.relId AND IFNULL(ip.batchNo, 'empty') = IFNULL(ipd.batchNo, 'empty') AND ip.invCode = ipd.invCode
LEFT JOIN auth_warehouse AS aw ON aw.code = ip.invCode
LEFT JOIN auth_space AS aspc ON aspc.code = ipd.invSpaceCode AND aspc.invWarehouseCode = ip.invCode
WHERE ip.id = #{invId}
GROUP BY ip.id
</select>
</mapper>

@ -16,20 +16,16 @@
<if test="name != null and name != ''">
and product_classify.`name` = #{name}
</if>
<if test="key != null and key != ''">
and
( product_classify.`name` like concat('%',#{key},'%') or product_classify.`code` like concat('%',#{key},'%'))
</if>
<if test="inFilterList!=null">
and product_classify.`code` in
<foreach collection="inFilterList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>

Loading…
Cancel
Save