修改sql语句

This commit is contained in:
马三炮 2026-01-23 10:17:18 +08:00
parent d21636425e
commit bb2d49e944
1 changed files with 23 additions and 23 deletions

View File

@ -2,24 +2,24 @@
<!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.bonus.ma.dao.DisassemblyManagementDao"> <mapper namespace="com.bonus.ma.dao.DisassemblyManagementDao">
<resultMap id="disassem" type="com.bonus.ma.beans.DisassemblyManagementBean"></resultMap> <resultMap id="disassem" type="com.bonus.ma.beans.DisassemblyManagementBean"></resultMap>
<select id="findByPage" parameterType="com.bonus.ma.beans.DisassemblyManagementBean" resultMap="disassem"> <select id="findByPage" parameterType="com.bonus.ma.beans.DisassemblyManagementBean" resultMap="disassem">
select distinct mam.ID,matt.ID as tyoeId0,matt.`NAME` as typeName,mat.ID as tyoeId,mat.`NAME` as type,mav.ID as verderId,mav.`NAME` as venderName, select distinct mam.ID,matt.ID as tyoeId0,matt.`NAME` as typeName,mat.ID as tyoeId,mat.`NAME` as type,mav.ID as verderId,mav.`NAME` as venderName,
mam.OUT_FAC_TIME as outFactortTime,mam.DEVICE_CODE as deviceCode,mam.OUT_FAC_NUM as outFactortNum,ROUND(mat.BUY_PRICE) as buyPrice,mam.PIC_URL as picUrl, mam.OUT_FAC_TIME as outFactortTime,mam.DEVICE_CODE as deviceCode,mam.OUT_FAC_NUM as outFactortNum,ROUND(mat.BUY_PRICE) as buyPrice,mam.PIC_URL as picUrl,
mam.IS_FIXED_ASSETS as isFixedAssets,mat.LEASE_PRICE as leasePrice,ROUND(mat.PAY_PRICE) as payPrice, mam.ASSETS_NUM as assetNum,mam.CYCLE_NUM as outInNum, mam.IS_FIXED_ASSETS as isFixedAssets,mat.LEASE_PRICE as leasePrice,ROUND(mat.PAY_PRICE) as payPrice, mam.ASSETS_NUM as assetNum,mam.CYCLE_NUM as outInNum,
mam.REMARK as remarks,mam.PROPERTY_DEPARTMENT as propertyDepartment,mam.USE_DEPARTMENT as useDepartment,mam.SERVICE_LIFE as serviceLife, mam.REMARK as remarks,mam.PROPERTY_DEPARTMENT as propertyDepartment,mam.USE_DEPARTMENT as useDepartment,mam.SERVICE_LIFE as serviceLife,
mam.BATCH_STATUS as batchStatus,mam.GPS_CODE as gpsCode,mam.MAKE_ORDER_DATE as makeOrderDate,mam.INVOICE_DATE as invoiceDate,mam.QRCODE as qrcode mam.BATCH_STATUS as batchStatus,mam.GPS_CODE as gpsCode,mam.MAKE_ORDER_DATE as makeOrderDate,mam.INVOICE_DATE as invoiceDate,mam.QRCODE as qrcode
,org.NAME companyName,mam.ORIGIN_NUM originNum,rel.ORG_ID orgId ,org.NAME companyName,mam.ORIGIN_NUM originNum,rel.ORG_ID orgId
from mm_machines mam from mm_machines mam
LEFT JOIN ma_status mas on mam.BATCH_STATUS = mas.BATCH_STATUS LEFT JOIN ma_status mas on mam.BATCH_STATUS = mas.BATCH_STATUS
LEFT JOIN mm_type mat on mam.TYPE = mat.ID LEFT JOIN mm_type mat on mam.TYPE = mat.ID
LEFT JOIN mm_type matt on matt.ID = mat.PARENT_ID LEFT JOIN mm_type matt on matt.ID = mat.PARENT_ID
LEFT JOIN mm_vender mav on mav.ID = mam.VENDER_ID LEFT JOIN mm_vender mav on mav.ID = mam.VENDER_ID
LEFT JOIN ma_org_relation rel on rel.TYPE_ID=mat.ID LEFT JOIN ma_org_relation rel on rel.TYPE_ID=mat.ID
LEFT JOIN pm_organization org on org.ID=rel.ORG_ID LEFT JOIN pm_organization org on org.ID=rel.ORG_ID
where 1=1 and mam.DEVICE_CODE is not null where 1=1 and mam.DEVICE_CODE is not null
<if test='param.orgId !=null and param.orgId!="" and param.orgId !="1" '> <if test='param.orgId !=null and param.orgId!="" and param.orgId !="1" '>
and rel.ORG_ID=#{param.orgId} and rel.ORG_ID=#{param.orgId}
</if> </if>
@ -51,8 +51,8 @@
mam.IS_FIXED_ASSETS as isFixedAssets,mat.LEASE_PRICE as leasePrice,ROUND(mat.PAY_PRICE) as payPrice, mam.ASSETS_NUM as assetNum,mam.CYCLE_NUM as outInNum, mam.IS_FIXED_ASSETS as isFixedAssets,mat.LEASE_PRICE as leasePrice,ROUND(mat.PAY_PRICE) as payPrice, mam.ASSETS_NUM as assetNum,mam.CYCLE_NUM as outInNum,
mam.REMARK as remarks,mam.PROPERTY_DEPARTMENT as propertyDepartment,mam.USE_DEPARTMENT as useDepartment,mam.SERVICE_LIFE as serviceLife, mam.REMARK as remarks,mam.PROPERTY_DEPARTMENT as propertyDepartment,mam.USE_DEPARTMENT as useDepartment,mam.SERVICE_LIFE as serviceLife,
mam.BATCH_STATUS as batchStatus,mam.GPS_CODE as gpsCode,mam.MAKE_ORDER_DATE as makeOrderDate,mam.INVOICE_DATE as invoiceDate,mam.QRCODE as qrcode mam.BATCH_STATUS as batchStatus,mam.GPS_CODE as gpsCode,mam.MAKE_ORDER_DATE as makeOrderDate,mam.INVOICE_DATE as invoiceDate,mam.QRCODE as qrcode
,org.NAME companyName,mam.ORIGIN_NUM originNum,rel.ORG_ID orgId ,org.NAME companyName,mam.ORIGIN_NUM originNum,rel.ORG_ID orgId
from mm_machines mam from mm_machines mam
LEFT JOIN ma_status mas on mam.BATCH_STATUS = mas.BATCH_STATUS LEFT JOIN ma_status mas on mam.BATCH_STATUS = mas.BATCH_STATUS
LEFT JOIN mm_type mat on mam.TYPE = mat.ID LEFT JOIN mm_type mat on mam.TYPE = mat.ID
LEFT JOIN mm_type matt on matt.ID = mat.PARENT_ID LEFT JOIN mm_type matt on matt.ID = mat.PARENT_ID
@ -67,8 +67,8 @@
mam.IS_FIXED_ASSETS as isFixedAssets,mat.LEASE_PRICE as leasePrice,ROUND(mat.PAY_PRICE) as payPrice, mam.ASSETS_NUM as assetNum,mam.CYCLE_NUM as outInNum, mam.IS_FIXED_ASSETS as isFixedAssets,mat.LEASE_PRICE as leasePrice,ROUND(mat.PAY_PRICE) as payPrice, mam.ASSETS_NUM as assetNum,mam.CYCLE_NUM as outInNum,
mam.REMARK as remarks,mam.PROPERTY_DEPARTMENT as propertyDepartment,mam.USE_DEPARTMENT as useDepartment,mam.SERVICE_LIFE as serviceLife, mam.REMARK as remarks,mam.PROPERTY_DEPARTMENT as propertyDepartment,mam.USE_DEPARTMENT as useDepartment,mam.SERVICE_LIFE as serviceLife,
mam.BATCH_STATUS as batchStatus,mam.GPS_CODE as gpsCode,mam.MAKE_ORDER_DATE as makeOrderDate,mam.INVOICE_DATE as invoiceDate,mam.QRCODE as qrcode mam.BATCH_STATUS as batchStatus,mam.GPS_CODE as gpsCode,mam.MAKE_ORDER_DATE as makeOrderDate,mam.INVOICE_DATE as invoiceDate,mam.QRCODE as qrcode
,org.NAME companyName,mam.ORIGIN_NUM originNum,rel.ORG_ID orgId ,org.NAME companyName,mam.ORIGIN_NUM originNum,rel.ORG_ID orgId
from mm_machines mam from mm_machines mam
LEFT JOIN ma_status mas on mam.BATCH_STATUS = mas.BATCH_STATUS LEFT JOIN ma_status mas on mam.BATCH_STATUS = mas.BATCH_STATUS
LEFT JOIN mm_type mat on mam.TYPE = mat.ID LEFT JOIN mm_type mat on mam.TYPE = mat.ID
LEFT JOIN mm_type matt on matt.ID = mat.PARENT_ID LEFT JOIN mm_type matt on matt.ID = mat.PARENT_ID
@ -109,11 +109,11 @@
</select> </select>
<update id="updaDataeRelationNum" parameterType="com.bonus.ma.beans.MachineBean"> <update id="updaDataeRelationNum" parameterType="com.bonus.ma.beans.MachineBean">
update ma_org_relation set NUM=#{num} where TYPE_ID=#{typeId} and ORG_ID=#{orgId} update ma_org_relation set NUM=#{num} where TYPE_ID=#{typeId} and ORG_ID=#{orgId}
</update> </update>
<select id="getInitSelect" parameterType="com.bonus.ma.beans.DisassemblyManagementBean" resultType="com.bonus.ma.beans.DisassemblyManagementBean"> <select id="getInitSelect" parameterType="com.bonus.ma.beans.DisassemblyManagementBean" resultType="com.bonus.ma.beans.DisassemblyManagementBean">
SELECT ID,`NAME` FROM SELECT ID,`NAME` FROM
mm_type mm_type
where 1=1 where 1=1
<if test="level!=null and level!='' "> <if test="level!=null and level!='' ">
and LEVEL=#{level} and LEVEL=#{level}
@ -121,32 +121,32 @@
<if test="parentId !=null and parentId !='' "> <if test="parentId !=null and parentId !='' ">
and PARENT_ID=#{parentId} and PARENT_ID=#{parentId}
</if> </if>
</select> </select>
<select id="findByPageTwo" parameterType="com.bonus.ma.beans.DisassemblyManagementBean" resultMap="disassem"> <select id="findByPageTwo" parameterType="com.bonus.ma.beans.DisassemblyManagementBean" resultMap="disassem">
SELECT b.ID,B.OPT_TIME optTime,b.OPTER,b.TYPE_ID,b.OLD_DEVICE_CODE oldCode,b.DEVICE_CODE deviceCode,b.NEW_DEVICE_CODE newCode,org.NAME companyName, SELECT b.ID,b.OPT_TIME optTime,b.OPTER,b.TYPE_ID,b.OLD_DEVICE_CODE oldCode,b.DEVICE_CODE deviceCode,b.NEW_DEVICE_CODE newCode,org.NAME companyName,
mat.`NAME` typeName,matt.`NAME` name ,user.`NAME` userNAME ,b.TYPE,b.orgId as orgId mat.`NAME` typeName,matt.`NAME` name ,user.`NAME` userNAME ,b.TYPE,b.orgId as orgId
FROM ( FROM (
SELECT DISTINCT SELECT DISTINCT
TASK.ID ID,task.TYPE,task.OPT_TIME,task.OPTER,oldRecode.TYPE_ID,'' AS OLD_DEVICE_CODE, task.ID ID,task.TYPE,task.OPT_TIME,task.OPTER,oldRecode.TYPE_ID,'' AS OLD_DEVICE_CODE,
oldRecode.DEVICE_CODE,oldRecode.NEW_DEVICE_CODE, MA_ID,'老设备' ,task.ORG_ID as orgId oldRecode.DEVICE_CODE,oldRecode.NEW_DEVICE_CODE, MA_ID,'老设备' ,task.ORG_ID as orgId
FROM FROM
mm_disassembly task mm_disassembly task
LEFT JOIN mm_disold_record oldRecode ON task.ID = oldRecode.TASK_ID LEFT JOIN mm_disold_record oldRecode ON task.ID = oldRecode.TASK_ID
UNION UNION
SELECT DISTINCT SELECT DISTINCT
TASK.ID,task.TYPE,task.OPT_TIME,task.OPTER,newRecode.TYPE_ID,newRecode.DEVICE_CODE OLD_DEVICE_CODE,newRecode.NEW_DEVICE_CODE DEVICE_CODE, task.ID,task.TYPE,task.OPT_TIME,task.OPTER,newRecode.TYPE_ID,newRecode.DEVICE_CODE OLD_DEVICE_CODE,newRecode.NEW_DEVICE_CODE DEVICE_CODE,
'' AS NEW_DEVICE_CODE, MA_ID, '新设备' ,task.ORG_ID '' AS NEW_DEVICE_CODE, MA_ID, '新设备' ,task.ORG_ID
FROM FROM
mm_disassembly task mm_disassembly task
LEFT JOIN mm_disnew_record newRecode ON task.ID = newRecode.TASK_ID LEFT JOIN mm_disnew_record newRecode ON task.ID = newRecode.TASK_ID
)b )b
LEFT JOIN mm_type mat on b.TYPE_ID = mat.ID LEFT JOIN mm_type mat on b.TYPE_ID = mat.ID
LEFT JOIN mm_type matt on matt.ID = mat.PARENT_ID LEFT JOIN mm_type matt on matt.ID = mat.PARENT_ID
LEFT JOIN ma_org_relation rel on rel.TYPE_ID=mat.ID LEFT JOIN ma_org_relation rel on rel.TYPE_ID=mat.ID
LEFT JOIN pm_organization org on org.ID=rel.ORG_ID LEFT JOIN pm_organization org on org.ID=rel.ORG_ID
LEFT JOIN pm_user user on user.ID=b.OPTER LEFT JOIN pm_user user on user.ID=b.OPTER
where 1=1 where 1=1
<if test='param.orgId !=null and param.orgId!="" and param.orgId !="1" and param.orgId !=1'> <if test='param.orgId !=null and param.orgId!="" and param.orgId !="1" and param.orgId !=1'>
and b.orgId=#{param.orgId} and b.orgId=#{param.orgId}
</if> </if>
@ -169,6 +169,6 @@
b.`OLD_DEVICE_CODE` LIKE CONCAT('%',#{param.keyWord},'%') b.`OLD_DEVICE_CODE` LIKE CONCAT('%',#{param.keyWord},'%')
) )
</if> </if>
ORDER BY OPT_TIME desc ORDER BY OPT_TIME desc
</select> </select>
</mapper> </mapper>