feat: 代码优化

dev_drug_dm
chenhc 1 month ago
parent 020d255254
commit 598d34894f

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

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

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

Loading…
Cancel
Save