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,34 +2,38 @@
<!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.relId, irm.id,
irm.batchNo, irm.relId,
irm.productionDate, irm.batchNo,
irm.expireDate, irm.productionDate,
irm.deptCode, irm.expireDate,
irm.invCode, irm.deptCode,
irm.invSpaceCode, irm.invCode,
irm.inCount, irm.invSpaceCode,
irm.outCount, irm.inCount,
irm.reCount, irm.outCount,
irm.status, irm.reCount,
irm.ignoreStatus, irm.status,
irm.type, irm.ignoreStatus,
irm.msg, irm.type,
irm.handleMsg, irm.msg,
irm.remark, irm.handleMsg,
irm.remindCount, irm.remark,
bp.ggxh, irm.remindCount,
bp.manufactory, bp.ggxh,
bp.zczbhhzbapzbh, bp.manufactory,
bp.cpmctymc productName, bp.zczbhhzbapzbh,
(select `name` from auth_warehouse where `code` = irm.invCode) invName, bp.cpmctymc AS productName,
(select `name` from auth_space where `code` = irm.invSpaceCode and invCode = irm.invCode) invSpaceName, aw.name AS invName,
(select `name` from basic_corp where erpId = irm.supId) supName aspc.name AS invSpaceName,
from inv_remind_msg irm bc.name AS supName
left join basic_udirel bu on bu.id = irm.relId FROM inv_remind_msg AS irm
left join basic_products bp on bp.uuid = bu.uuid 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> <where>
<if test="relId != null and relId != ''"> <if test="relId != null and relId != ''">
AND irm.relId = #{relId} AND irm.relId = #{relId}

@ -2,29 +2,32 @@
<!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.relId, irs.id,
irs.deptCode, irs.relId,
irs.invCode, irs.deptCode,
irs.invSpaceCode, irs.invCode,
irs.lowStock, irs.invSpaceCode,
irs.lackStock, irs.lowStock,
irs.overStock, irs.lackStock,
irs.expireDate, irs.overStock,
irs.recentDate, irs.expireDate,
irs.remark, irs.recentDate,
bu.lowStockNum, irs.remark,
bu.overStockNum, bu.lowStockNum,
bu.recentDateTime, bu.overStockNum,
bu.useExpireTime, bu.recentDateTime,
bu.isDateBy, bu.useExpireTime,
bp.cpmctymc productName, bu.isDateBy,
bp.ggxh, bp.cpmctymc AS productName,
(select `name` from auth_warehouse where `code` = irs.invCode) invName, bp.ggxh,
(select `name` from auth_space where `code` = irs.invSpaceCode and invCode = irs.invCode) invSpaceName aw.name AS invName,
from inv_remind_set irs aspc.name AS invSpaceName
left join basic_udirel bu on bu.id = irs.relId FROM inv_remind_set AS irs
left join basic_products bp on bp.uuid = bu.uuid 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> <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.deptCode, ip.relIdFk AS relId,
ip.invCode, ip.deptCode,
ipd.invSpaceCode, ip.invCode,
(select `name` from auth_warehouse where code = ip.invCode) invName, ipd.invSpaceCode,
(select `name` aw.name AS invName,
from auth_space aspc.name AS invSpaceName,
where code = ipd.invSpaceCode and invWarehouseCode = ip.invCode) invSpaceName, bp.ggxh,
bp.ggxh, bp.cpmctymc AS productName,
bp.cpmctymc productName, bu.lowStockNum,
bu.lowStockNum, bu.overStockNum,
bu.overStockNum, bu.recentDateTime,
bu.recentDateTime, bu.isDateBy
bu.isDateBy FROM inv_product AS ip
from inv_product ip LEFT JOIN basic_udirel AS bu ON ip.relIdFk = bu.id
left join basic_udirel bu on ip.relIdFk = bu.id LEFT JOIN basic_products AS bp ON bu.uuid = bp.uuid
left join basic_products 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 inv_product_detail ipd LEFT JOIN auth_warehouse AS aw ON aw.code = ip.invCode
on ip.relIdFk = ipd.relId and IFNULL(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty') LEFT JOIN auth_space AS aspc ON aspc.code = ipd.invSpaceCode AND aspc.invWarehouseCode = ip.invCode
and ip.invCode = ipd.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