2021-04-07 23:53:57 +08:00
<?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.jsh.erp.datasource.mappers.DepotItemMapperEx" >
<resultMap id= "DetailByTypeAndMIdResultMap" type= "com.jsh.erp.datasource.entities.DepotItemVo4DetailByTypeAndMId" >
<result column= "number" jdbcType= "VARCHAR" property= "number" />
2021-09-12 23:35:24 +08:00
<result column= "bar_code" jdbcType= "VARCHAR" property= "barCode" />
<result column= "material_name" jdbcType= "VARCHAR" property= "materialName" />
2021-04-07 23:53:57 +08:00
<result column= "type" jdbcType= "VARCHAR" property= "type" />
<result column= "sub_type" jdbcType= "VARCHAR" property= "subType" />
2024-05-21 00:43:54 +08:00
<result column= "b_num" jdbcType= "DECIMAL" property= "bnum" />
<result column= "unit_price" jdbcType= "DECIMAL" property= "unitPrice" />
<result column= "all_price" jdbcType= "DECIMAL" property= "allPrice" />
2024-09-21 00:53:16 +08:00
<result column= "material_unit" jdbcType= "VARCHAR" property= "materialUnit" />
2021-04-07 23:53:57 +08:00
<result column= "depotName" jdbcType= "VARCHAR" property= "depotName" />
<result column= "oTime" jdbcType= "TIMESTAMP" property= "otime" />
</resultMap>
<resultMap extends= "com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap" id= "ResultAndMaterialMap" type= "com.jsh.erp.datasource.entities.DepotItemVo4Material" >
<result column= "mName" jdbcType= "VARCHAR" property= "mname" />
<result column= "mModel" jdbcType= "VARCHAR" property= "mmodel" />
</resultMap>
<resultMap extends= "com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap" id= "ResultWithInfoExMap" type= "com.jsh.erp.datasource.entities.DepotItemVo4WithInfoEx" >
<result column= "MName" jdbcType= "VARCHAR" property= "MName" />
<result column= "MModel" jdbcType= "VARCHAR" property= "MModel" />
<result column= "MaterialUnit" jdbcType= "VARCHAR" property= "MaterialUnit" />
<result column= "MColor" jdbcType= "VARCHAR" property= "MColor" />
<result column= "MStandard" jdbcType= "VARCHAR" property= "MStandard" />
<result column= "MMfrs" jdbcType= "VARCHAR" property= "MMfrs" />
2023-02-09 22:13:36 +08:00
<result column= "weight" jdbcType= "VARCHAR" property= "weight" />
2024-02-03 15:06:09 +08:00
<result column= "position" jdbcType= "VARCHAR" property= "position" />
2023-07-05 23:59:55 +08:00
<result column= "img_name" jdbcType= "VARCHAR" property= "imgName" />
2021-04-07 23:53:57 +08:00
<result column= "MOtherField1" jdbcType= "VARCHAR" property= "MOtherField1" />
<result column= "MOtherField2" jdbcType= "VARCHAR" property= "MOtherField2" />
<result column= "MOtherField3" jdbcType= "VARCHAR" property= "MOtherField3" />
2021-10-10 18:00:42 +08:00
<result column= "enable_serial_number" jdbcType= "VARCHAR" property= "enableSerialNumber" />
<result column= "enable_batch_number" jdbcType= "VARCHAR" property= "enableBatchNumber" />
2024-10-06 00:45:39 +08:00
<result column= "brand" jdbcType= "VARCHAR" property= "brand" />
2021-04-07 23:53:57 +08:00
<result column= "DepotName" jdbcType= "VARCHAR" property= "DepotName" />
<result column= "AnotherDepotName" jdbcType= "VARCHAR" property= "AnotherDepotName" />
<result column= "barCode" jdbcType= "VARCHAR" property= "barCode" />
2022-05-26 21:35:30 +08:00
<result column= "purchase_decimal" jdbcType= "DECIMAL" property= "purchaseDecimal" />
2021-04-07 23:53:57 +08:00
</resultMap>
<resultMap extends= "com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap" id= "ResultByMaterial" type= "com.jsh.erp.datasource.entities.DepotItemVo4WithInfoEx" >
<result column= "MId" jdbcType= "VARCHAR" property= "MId" />
2021-07-16 00:49:14 +08:00
<result column= "bar_code" jdbcType= "VARCHAR" property= "barCode" />
2021-04-07 23:53:57 +08:00
<result column= "MName" jdbcType= "VARCHAR" property= "MName" />
<result column= "MMfrs" jdbcType= "VARCHAR" property= "MMfrs" />
<result column= "MModel" jdbcType= "VARCHAR" property= "MModel" />
<result column= "MStandard" jdbcType= "VARCHAR" property= "MStandard" />
<result column= "MaterialUnit" jdbcType= "VARCHAR" property= "MaterialUnit" />
<result column= "MOtherField1" jdbcType= "VARCHAR" property= "MOtherField1" />
<result column= "MOtherField2" jdbcType= "VARCHAR" property= "MOtherField2" />
<result column= "MOtherField3" jdbcType= "VARCHAR" property= "MOtherField3" />
2022-11-18 23:30:10 +08:00
<result column= "unit_id" jdbcType= "BIGINT" property= "unitId" />
2021-04-07 23:53:57 +08:00
<result column= "unit_name" jdbcType= "VARCHAR" property= "unitName" />
<result column= "MColor" jdbcType= "VARCHAR" property= "MColor" />
2024-10-09 00:48:34 +08:00
<result column= "brand" jdbcType= "VARCHAR" property= "brand" />
2021-04-07 23:53:57 +08:00
<result column= "purchase_decimal" jdbcType= "DECIMAL" property= "purchaseDecimal" />
2024-05-24 01:22:32 +08:00
<result column= "currentUnitPrice" jdbcType= "DECIMAL" property= "currentUnitPrice" />
2021-04-07 23:53:57 +08:00
</resultMap>
<resultMap id= "ResultStockWarningCount" type= "com.jsh.erp.datasource.vo.DepotItemStockWarningCount" >
<result column= "MId" jdbcType= "VARCHAR" property= "MId" />
2021-07-16 00:49:14 +08:00
<result column= "bar_code" jdbcType= "VARCHAR" property= "barCode" />
2021-04-07 23:53:57 +08:00
<result column= "MName" jdbcType= "VARCHAR" property= "MName" />
<result column= "MMfrs" jdbcType= "VARCHAR" property= "MMfrs" />
<result column= "MModel" jdbcType= "VARCHAR" property= "MModel" />
<result column= "MStandard" jdbcType= "VARCHAR" property= "MStandard" />
2024-10-09 00:48:34 +08:00
<result column= "MColor" jdbcType= "VARCHAR" property= "MColor" />
<result column= "brand" jdbcType= "VARCHAR" property= "brand" />
2021-04-07 23:53:57 +08:00
<result column= "MaterialUnit" jdbcType= "VARCHAR" property= "MaterialUnit" />
<result column= "MOtherField1" jdbcType= "VARCHAR" property= "MOtherField1" />
<result column= "MOtherField2" jdbcType= "VARCHAR" property= "MOtherField2" />
<result column= "MOtherField3" jdbcType= "VARCHAR" property= "MOtherField3" />
<result column= "unit_name" jdbcType= "VARCHAR" property= "unitName" />
<result column= "current_number" jdbcType= "DECIMAL" property= "currentNumber" />
2021-10-31 23:46:10 +08:00
<result column= "low_safe_stock" jdbcType= "DECIMAL" property= "lowSafeStock" />
<result column= "high_safe_stock" jdbcType= "DECIMAL" property= "highSafeStock" />
2021-04-07 23:53:57 +08:00
</resultMap>
2021-07-28 23:13:37 +08:00
<resultMap id= "stockMap" type= "com.jsh.erp.datasource.vo.DepotItemVo4Stock" >
<result column= "inTotal" jdbcType= "DECIMAL" property= "inTotal" />
<result column= "outTotal" jdbcType= "DECIMAL" property= "outTotal" />
<result column= "transfInTotal" jdbcType= "DECIMAL" property= "transfInTotal" />
<result column= "transfOutTotal" jdbcType= "DECIMAL" property= "transfOutTotal" />
<result column= "assemInTotal" jdbcType= "DECIMAL" property= "assemInTotal" />
<result column= "assemOutTotal" jdbcType= "DECIMAL" property= "assemOutTotal" />
<result column= "disAssemInTotal" jdbcType= "DECIMAL" property= "disAssemInTotal" />
<result column= "disAssemOutTotal" jdbcType= "DECIMAL" property= "disAssemOutTotal" />
2021-04-07 23:53:57 +08:00
</resultMap>
2021-09-29 01:17:20 +08:00
<resultMap id= "batchNumberListMap" type= "com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList" >
<result column= "id" jdbcType= "VARCHAR" property= "id" />
<result column= "bar_code" jdbcType= "VARCHAR" property= "barCode" />
<result column= "name" jdbcType= "VARCHAR" property= "name" />
<result column= "standard" jdbcType= "VARCHAR" property= "standard" />
<result column= "model" jdbcType= "VARCHAR" property= "model" />
2023-04-01 23:26:07 +08:00
<result column= "unit_id" jdbcType= "BIGINT" property= "unitId" />
<result column= "commodity_unit" jdbcType= "VARCHAR" property= "commodityUnit" />
2021-09-29 01:17:20 +08:00
<result column= "batch_number" jdbcType= "VARCHAR" property= "batchNumber" />
<result column= "expiration_date" jdbcType= "TIMESTAMP" property= "expirationDate" />
<result column= "total_num" jdbcType= "VARCHAR" property= "totalNum" />
</resultMap>
2022-05-17 00:04:35 +08:00
<resultMap id= "materialSumMap" type= "com.jsh.erp.datasource.entities.DepotItemVo4MaterialAndSum" >
<result column= "material_extend_id" jdbcType= "VARCHAR" property= "materialExtendId" />
<result column= "oper_number" jdbcType= "VARCHAR" property= "operNumber" />
</resultMap>
2021-04-07 23:53:57 +08:00
<select id= "selectByConditionDepotItem" parameterType= "com.jsh.erp.datasource.entities.DepotItemExample" resultMap= "com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap" >
select *
FROM jsh_depot_item
where 1=1
<if test= "name != null" >
2021-06-09 20:29:36 +08:00
<bind name= "bindName" value= "'%'+name+'%'" />
and name like #{bindName}
2021-04-07 23:53:57 +08:00
</if>
<if test= "type != null" >
2021-06-09 20:29:36 +08:00
and type = #{type}
2021-04-07 23:53:57 +08:00
</if>
<if test= "remark != null" >
2021-06-09 20:29:36 +08:00
<bind name= "bindRemark" value= "'%'+remark+'%'" />
and remark like #{bindRemark}
2021-04-07 23:53:57 +08:00
</if>
and ifnull(delete_flag,'0') !='1'
<if test= "offset != null and rows != null" >
limit #{offset},#{rows}
</if>
</select>
<select id= "countsByDepotItem" resultType= "java.lang.Long" >
SELECT
COUNT(id)
FROM jsh_depot_item
WHERE 1=1
<if test= "name != null" >
2021-06-09 20:29:36 +08:00
<bind name= "bindName" value= "'%'+name+'%'" />
and name like #{bindName}
2021-04-07 23:53:57 +08:00
</if>
<if test= "type != null" >
2021-06-09 20:29:36 +08:00
and type = #{type}
2021-04-07 23:53:57 +08:00
</if>
<if test= "remark != null" >
2021-06-09 20:29:36 +08:00
<bind name= "bindRemark" value= "'%'+remark+'%'" />
and remark like #{bindRemark}
2021-04-07 23:53:57 +08:00
</if>
and ifnull(delete_flag,'0') !='1'
</select>
2022-05-28 17:27:57 +08:00
<select id= "findDetailByDepotIdsAndMaterialIdList" parameterType= "com.jsh.erp.datasource.entities.DepotItemExample" resultMap= "DetailByTypeAndMIdResultMap" >
2024-05-23 23:29:32 +08:00
select tb.number, tb.bar_code, tb.material_name, tb.type, tb.sub_type, tb.b_num, tb.unit_price,
2024-09-21 00:53:16 +08:00
ifnull(tb.b_num*tb.unit_price,0) as all_price, tb.material_unit, tb.depotName, tb.oTime from
2022-05-28 17:27:57 +08:00
(select dh.number,me.bar_code,m.name material_name,dh.type,dh.sub_type,
2021-04-07 23:53:57 +08:00
case
when type='入库' then ifnull(di.basic_number,0)
2024-06-06 23:29:43 +08:00
when type='出库' then 0-ifnull(di.basic_number,0)
2021-04-07 23:53:57 +08:00
when dh.sub_type='组装单' and di.material_type='组合件' then ifnull(di.basic_number,0)
2024-06-06 23:29:43 +08:00
when dh.sub_type='组装单' and di.material_type='普通子件' then 0-ifnull(di.basic_number,0)
2021-04-07 23:53:57 +08:00
when dh.sub_type='拆卸单' and di.material_type='普通子件' then ifnull(di.basic_number,0)
2024-06-06 23:29:43 +08:00
when dh.sub_type='拆卸单' and di.material_type='组合件' then 0-ifnull(di.basic_number,0)
2021-04-07 23:53:57 +08:00
when dh.sub_type='盘点复盘' then ifnull(di.basic_number,0)
else 0
end
2024-09-21 00:53:16 +08:00
as b_num, di.unit_price, di.material_unit,
2021-04-07 23:53:57 +08:00
(select name from jsh_depot d where d.id=di.depot_id and ifnull(d.delete_flag,'0') !='1') as depotName,
date_format(dh.oper_time,'%Y-%m-%d %H:%i:%S') as oTime
from jsh_depot_head dh
2021-09-12 23:35:24 +08:00
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
2022-05-28 17:27:57 +08:00
where (dh.type!='其它'
2021-04-07 23:53:57 +08:00
or (dh.type='其它' and dh.sub_type='组装单')
or (dh.type='其它' and dh.sub_type='拆卸单')
2022-05-28 13:32:09 +08:00
or (dh.type='其它' and dh.sub_type='盘点复盘'))
2023-12-11 00:18:26 +08:00
<if test= "inOutManageFlag" >
and (dh.sub_type!='采购' and dh.sub_type!='采购退货' and dh.sub_type!='销售' and dh.sub_type!='销售退货')
</if>
2024-05-26 13:51:42 +08:00
<if test= "depotIdArray != null and depotIdArray.length>0" >
2022-05-28 17:27:57 +08:00
and di.depot_id in (
<foreach collection= "depotIdArray" item= "depotId" separator= "," > #{depotId}</foreach>
)
</if>
2023-03-17 23:50:51 +08:00
<if test= "forceFlag" >
and dh.status = '1'
</if>
2022-06-13 00:04:35 +08:00
<if test= "sku != null and sku !=''" >
and di.sku = #{sku}
</if>
2023-02-22 22:36:58 +08:00
<if test= "batchNumber != null and batchNumber !=''" >
and di.batch_number = #{batchNumber}
</if>
<if test= "number != null and number !=''" >
<bind name= "bindNumber" value= "'%'+number+'%'" />
and dh.number like #{bindNumber}
</if>
<if test= "beginTime != null and beginTime !=''" >
and dh.oper_time >= #{beginTime}
</if>
<if test= "endTime != null and endTime !=''" >
and dh.oper_time < = #{endTime}
</if>
2021-06-09 20:29:36 +08:00
and di.material_id = #{mId}
2021-04-07 23:53:57 +08:00
and ifnull(dh.delete_flag,'0') !='1'
2022-05-28 17:27:57 +08:00
union all
--单独构造记录:调拨入库
select dh.number,me.bar_code,m.name material_name,dh.type,dh.sub_type,
2024-09-21 00:53:16 +08:00
ifnull(di.basic_number,0) as b_num, di.unit_price, di.material_unit,
2022-05-28 17:27:57 +08:00
(select concat(name,'[调入]') from jsh_depot d where d.id=di.another_depot_id and ifnull(d.delete_flag,'0') !='1') as depotName,
date_format(dh.oper_time,'%Y-%m-%d %H:%i:%S') as oTime
from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
where dh.type='出库' and dh.sub_type='调拨'
2024-05-26 13:51:42 +08:00
<if test= "depotIdArray != null and depotIdArray.length>0" >
2022-05-28 17:27:57 +08:00
and di.another_depot_id in (
<foreach collection= "depotIdArray" item= "depotId" separator= "," > #{depotId}</foreach>
)
</if>
2023-03-17 23:50:51 +08:00
<if test= "forceFlag" >
and dh.status = '1'
</if>
2022-06-13 00:04:35 +08:00
<if test= "sku != null and sku !=''" >
and di.sku = #{sku}
</if>
2023-02-22 22:36:58 +08:00
<if test= "batchNumber != null and batchNumber !=''" >
and di.batch_number = #{batchNumber}
</if>
<if test= "number != null and number !=''" >
<bind name= "bindNumber" value= "'%'+number+'%'" />
and dh.number like #{bindNumber}
</if>
<if test= "beginTime != null and beginTime !=''" >
and dh.oper_time >= #{beginTime}
</if>
<if test= "endTime != null and endTime !=''" >
and dh.oper_time < = #{endTime}
</if>
2022-05-28 17:27:57 +08:00
and di.material_id = #{mId}
and ifnull(dh.delete_flag,'0') !='1') tb
order by tb.oTime desc
2021-04-07 23:53:57 +08:00
<if test= "offset != null and rows != null" >
limit #{offset},#{rows}
</if>
</select>
2022-05-28 17:27:57 +08:00
<select id= "findDetailByDepotIdsAndMaterialIdCount" resultType= "java.lang.Long" >
select count(tb.number) from
(select dh.number from jsh_depot_head dh
2021-09-22 00:18:42 +08:00
left JOIN jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
2022-05-28 17:27:57 +08:00
where (dh.type!='其它'
2021-04-07 23:53:57 +08:00
or (dh.type='其它' and dh.sub_type='组装单')
or (dh.type='其它' and dh.sub_type='拆卸单')
2022-05-28 13:32:09 +08:00
or (dh.type='其它' and dh.sub_type='盘点复盘'))
2023-12-11 00:18:26 +08:00
<if test= "inOutManageFlag" >
and (dh.sub_type!='采购' and dh.sub_type!='采购退货' and dh.sub_type!='销售' and dh.sub_type!='销售退货')
</if>
2024-09-04 22:42:55 +08:00
<if test= "depotIdArray != null and depotIdArray.length>0" >
2022-05-28 17:27:57 +08:00
and di.depot_id in (
<foreach collection= "depotIdArray" item= "depotId" separator= "," > #{depotId}</foreach>
)
</if>
2023-03-17 23:50:51 +08:00
<if test= "forceFlag" >
and dh.status = '1'
</if>
2022-06-13 00:04:35 +08:00
<if test= "sku != null and sku !=''" >
and di.sku = #{sku}
</if>
2023-02-22 22:36:58 +08:00
<if test= "batchNumber != null and batchNumber !=''" >
and di.batch_number = #{batchNumber}
</if>
<if test= "number != null and number !=''" >
<bind name= "bindNumber" value= "'%'+number+'%'" />
and dh.number like #{bindNumber}
</if>
<if test= "beginTime != null and beginTime !=''" >
and dh.oper_time >= #{beginTime}
</if>
<if test= "endTime != null and endTime !=''" >
and dh.oper_time < = #{endTime}
</if>
2021-06-09 20:29:36 +08:00
and di.material_id =#{mId}
2021-04-07 23:53:57 +08:00
and ifnull(dh.delete_flag,'0') !='1'
2022-05-28 17:27:57 +08:00
union all
--单独构造记录:调拨入库
select dh.number from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where dh.type='出库' and dh.sub_type='调拨'
2024-09-04 22:42:55 +08:00
<if test= "depotIdArray != null and depotIdArray.length>0" >
2022-05-28 17:27:57 +08:00
and di.another_depot_id in (
<foreach collection= "depotIdArray" item= "depotId" separator= "," > #{depotId}</foreach>
)
</if>
2023-03-17 23:50:51 +08:00
<if test= "forceFlag" >
and dh.status = '1'
</if>
2022-06-13 00:04:35 +08:00
<if test= "sku != null and sku !=''" >
and di.sku = #{sku}
</if>
2023-02-22 22:36:58 +08:00
<if test= "batchNumber != null and batchNumber !=''" >
and di.batch_number = #{batchNumber}
</if>
<if test= "number != null and number !=''" >
<bind name= "bindNumber" value= "'%'+number+'%'" />
and dh.number like #{bindNumber}
</if>
<if test= "beginTime != null and beginTime !=''" >
and dh.oper_time >= #{beginTime}
</if>
<if test= "endTime != null and endTime !=''" >
and dh.oper_time < = #{endTime}
</if>
2022-05-28 17:27:57 +08:00
and di.material_id = #{mId}
and ifnull(dh.delete_flag,'0') !='1') tb
2021-04-07 23:53:57 +08:00
</select>
<select id= "getDetailList" parameterType= "com.jsh.erp.datasource.entities.DepotItemExample" resultMap= "ResultWithInfoExMap" >
2024-02-03 15:06:09 +08:00
select di.*,m.name MName,m.model MModel,m.unit MaterialUnit,m.color MColor,m.standard MStandard,m.mfrs MMfrs,m.weight, m.position, m.img_name,
2021-10-10 18:00:42 +08:00
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,m.enable_serial_number, m.enable_batch_number,
2024-10-06 00:45:39 +08:00
m.brand, dp1.name DepotName,dp2.name AnotherDepotName, me.bar_code barCode, me.purchase_decimal
2021-04-07 23:53:57 +08:00
from jsh_depot_item di
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot dp1 on di.depot_id=dp1.id and ifnull(dp1.delete_Flag,'0') !='1'
left join jsh_depot dp2 on di.another_depot_id=dp2.id and ifnull(dp2.delete_Flag,'0') !='1'
2021-06-09 20:29:36 +08:00
where di.header_id = #{headerId}
2021-04-07 23:53:57 +08:00
and ifnull(di.delete_flag,'0') !='1'
order by di.id asc
</select>
2023-10-15 23:24:46 +08:00
<select id= "getBillDetailListByIds" resultType= "com.jsh.erp.datasource.entities.DepotItemVo4WithInfoEx" >
2024-02-03 15:06:09 +08:00
select di.*,m.name MName,m.model MModel,m.unit MaterialUnit,m.color MColor,m.standard MStandard,m.mfrs MMfrs,m.weight, m.position, m.img_name,
2023-10-15 23:24:46 +08:00
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,m.enable_serial_number, m.enable_batch_number,
2024-10-06 00:45:39 +08:00
m.brand, dp1.name DepotName,dp2.name AnotherDepotName, me.bar_code barCode, me.purchase_decimal
2023-10-15 23:24:46 +08:00
from jsh_depot_item di
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot dp1 on di.depot_id=dp1.id and ifnull(dp1.delete_Flag,'0') !='1'
left join jsh_depot dp2 on di.another_depot_id=dp2.id and ifnull(dp2.delete_Flag,'0') !='1'
where ifnull(di.delete_flag,'0') !='1'
and di.header_id in
<foreach collection= "idList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
order by di.header_id desc, di.id asc
</select>
2024-07-14 23:14:13 +08:00
<select id= "getInOutStock" parameterType= "com.jsh.erp.datasource.entities.DepotItemExample" resultMap= "ResultByMaterial" >
2024-10-09 00:48:34 +08:00
select m.id MId, me.bar_code, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard, m.brand,
2021-04-07 23:53:57 +08:00
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
2024-05-24 01:22:32 +08:00
concat_ws('', m.unit, u.basic_unit) MaterialUnit, m.color MColor, m.unit_id, u.name unit_name,
ifnull(me.purchase_decimal,0) purchase_decimal, ifnull(mcs.current_unit_price,0) currentUnitPrice
2021-04-07 23:53:57 +08:00
from jsh_material m
2022-05-30 23:03:06 +08:00
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
2024-05-24 01:22:32 +08:00
left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
2022-05-30 23:03:06 +08:00
left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
2021-04-07 23:53:57 +08:00
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
2022-05-30 23:03:06 +08:00
where 1=1 and me.default_flag=1
2021-04-07 23:53:57 +08:00
<if test= "materialParam != null and materialParam !=''" >
<bind name= "bindKey" value= "'%'+materialParam+'%'" />
2024-10-07 01:12:38 +08:00
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
2021-04-07 23:53:57 +08:00
</if>
2023-05-14 18:05:28 +08:00
<if test= "categoryIdList.size()>0" >
and m.category_id in
<foreach collection= "categoryIdList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2021-04-07 23:53:57 +08:00
<if test= "endTime != null" >
2021-06-09 20:29:36 +08:00
and dh.oper_time < = #{endTime}
2021-04-07 23:53:57 +08:00
</if>
and ifnull(m.delete_flag,'0') !='1'
2025-03-08 23:15:51 +08:00
group by m.id, me.bar_code, m.name, m.mfrs, m.model, m.standard, m.brand,
m.other_field1,m.other_field2,m.other_field3,m.unit, u.basic_unit, m.color, m.unit_id, u.name,
me.purchase_decimal, mcs.current_unit_price
2021-07-09 00:09:09 +08:00
order by m.id desc
2021-04-07 23:53:57 +08:00
<if test= "offset != null and rows != null" >
limit #{offset},#{rows}
</if>
</select>
2024-07-14 23:14:13 +08:00
<select id= "getInOutStockCount" resultType= "java.lang.Integer" >
2021-04-07 23:53:57 +08:00
select count(1) from (select m.id
from jsh_material m
2022-05-30 23:03:06 +08:00
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where 1=1 and me.default_flag=1
2021-04-07 23:53:57 +08:00
<if test= "materialParam != null and materialParam !=''" >
<bind name= "bindKey" value= "'%'+materialParam+'%'" />
2024-10-07 01:12:38 +08:00
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
2021-04-07 23:53:57 +08:00
</if>
2023-05-14 18:05:28 +08:00
<if test= "categoryIdList.size()>0" >
and m.category_id in
<foreach collection= "categoryIdList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2021-04-07 23:53:57 +08:00
<if test= "endTime != null" >
2021-06-09 20:29:36 +08:00
and dh.oper_time < = #{endTime}
2021-04-07 23:53:57 +08:00
</if>
2022-05-30 23:03:06 +08:00
and ifnull(m.delete_flag,'0') !='1'
2021-04-07 23:53:57 +08:00
group by m.id) cc
</select>
2024-10-09 00:48:34 +08:00
<select id= "getListWithBuyOrSale" parameterType= "com.jsh.erp.datasource.entities.DepotItemExample" resultMap= "ResultByMaterial" >
2025-04-01 15:54:01 +08:00
select m.id MId, di.material_extend_id, me.bar_code, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,
2022-05-04 21:50:24 +08:00
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
2024-10-09 00:48:34 +08:00
concat_ws('', m.unit, u.basic_unit) MaterialUnit, m.color MColor, m.brand, u.name unit_name
2022-05-04 21:50:24 +08:00
from jsh_material m
left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
where 1=1
2025-01-14 00:18:33 +08:00
<if test= "categoryList.size()>0" >
and m.category_id in
<foreach collection= "categoryList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2022-05-04 21:50:24 +08:00
<if test= "materialParam != null and materialParam !=''" >
<bind name= "bindKey" value= "'%'+materialParam+'%'" />
2024-10-07 01:12:38 +08:00
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
2022-05-04 21:50:24 +08:00
</if>
<if test= "billType =='buy'" >
and (dh.sub_type = '采购' or dh.sub_type = '采购退货')
</if>
<if test= "billType =='sale'" >
2024-03-01 10:34:37 +08:00
and (dh.sub_type = '销售' or dh.sub_type = '销售退货')
</if>
<if test= "billType =='retail'" >
and (dh.sub_type = '零售' or dh.sub_type = '零售退货')
2022-05-04 21:50:24 +08:00
</if>
<if test= "beginTime != null" >
and dh.oper_time >= #{beginTime}
</if>
<if test= "endTime != null" >
and dh.oper_time < = #{endTime}
</if>
2022-08-08 23:55:56 +08:00
<if test= "creatorArray != null" >
and dh.creator in (
<foreach collection= "creatorArray" item= "creator" separator= "," >
#{creator}
</foreach>
)
</if>
2023-04-10 23:37:49 +08:00
<if test= "organId != null" >
and dh.organ_id = #{organId}
</if>
2023-03-09 22:53:56 +08:00
<if test= "organArray != null and organArray !=''" >
and dh.organ_id in (
<foreach collection= "organArray" item= "organId" separator= "," >
#{organId}
</foreach>
)
</if>
2023-03-09 21:37:13 +08:00
<if test= "depotList.size()>0" >
and di.depot_id in
<foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2023-03-17 23:05:03 +08:00
<if test= "forceFlag" >
2024-01-03 17:34:20 +08:00
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
2023-03-09 00:01:50 +08:00
</if>
2022-05-04 21:50:24 +08:00
and ifnull(m.delete_flag,'0') !='1'
2025-04-01 15:54:01 +08:00
group by m.id, di.material_extend_id, me.bar_code, m.name, m.mfrs, m.model, m.standard,
2025-03-08 23:15:51 +08:00
m.other_field1,m.other_field2,m.other_field3, m.unit, u.basic_unit, m.color, m.brand, u.name
2022-05-04 21:50:24 +08:00
order by m.id desc
<if test= "offset != null and rows != null" >
limit #{offset},#{rows}
</if>
</select>
2024-10-09 00:48:34 +08:00
<select id= "getListWithBuyOrSaleCount" resultType= "java.lang.Integer" >
2025-04-01 15:54:01 +08:00
select count(1) from (select m.id, di.material_extend_id
2022-05-04 21:50:24 +08:00
from jsh_material m
left join jsh_depot_item di on di.material_id=m.id and ifnull(m.delete_Flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where 1=1
2025-01-14 00:18:33 +08:00
<if test= "categoryList.size()>0" >
and m.category_id in
<foreach collection= "categoryList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2022-05-04 21:50:24 +08:00
<if test= "materialParam != null and materialParam !=''" >
<bind name= "bindKey" value= "'%'+materialParam+'%'" />
2024-10-07 01:12:38 +08:00
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
2022-05-04 21:50:24 +08:00
</if>
<if test= "billType =='buy'" >
and (dh.sub_type = '采购' or dh.sub_type = '采购退货')
</if>
<if test= "billType =='sale'" >
2024-04-02 14:28:37 +08:00
and (dh.sub_type = '销售' or dh.sub_type = '销售退货')
</if>
<if test= "billType =='retail'" >
and (dh.sub_type = '零售' or dh.sub_type = '零售退货')
2022-05-04 21:50:24 +08:00
</if>
<if test= "beginTime != null" >
and dh.oper_time >= #{beginTime}
</if>
<if test= "endTime != null" >
and dh.oper_time < = #{endTime}
</if>
2022-08-08 23:55:56 +08:00
<if test= "creatorArray != null" >
and dh.creator in (
<foreach collection= "creatorArray" item= "creator" separator= "," >
#{creator}
</foreach>
)
</if>
2023-04-10 23:37:49 +08:00
<if test= "organId != null" >
and dh.organ_id = #{organId}
</if>
2023-03-09 22:53:56 +08:00
<if test= "organArray != null and organArray !=''" >
and dh.organ_id in (
<foreach collection= "organArray" item= "organId" separator= "," >
#{organId}
</foreach>
)
</if>
2023-03-09 21:37:13 +08:00
<if test= "depotList.size()>0" >
and di.depot_id in
<foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2023-03-17 23:05:03 +08:00
<if test= "forceFlag" >
2024-01-03 17:34:20 +08:00
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
2023-03-09 00:01:50 +08:00
</if>
2022-05-04 21:50:24 +08:00
and ifnull(di.delete_flag,'0') !='1'
2025-04-01 15:54:01 +08:00
group by m.id, di.material_extend_id) cc
2022-05-04 21:50:24 +08:00
</select>
2021-04-07 23:53:57 +08:00
<select id= "buyOrSaleNumber" resultType= "java.math.BigDecimal" >
select ifnull(sum(basic_number),0) as BasicNumber from jsh_depot_item di,jsh_depot_head dh
where di.header_id = dh.id
2021-06-09 20:29:36 +08:00
and dh.type=#{type} and dh.sub_type=#{subType}
2021-06-08 22:00:51 +08:00
and dh.oper_time > = #{beginTime}
and dh.oper_time < = #{endTime}
2025-04-01 15:54:01 +08:00
and di.material_extend_id =#{meId}
2022-08-08 23:55:56 +08:00
<if test= "creatorArray != null" >
and dh.creator in (
<foreach collection= "creatorArray" item= "creator" separator= "," >
#{creator}
</foreach>
)
</if>
2023-04-10 23:37:49 +08:00
<if test= "organId != null" >
and dh.organ_id = #{organId}
</if>
2023-03-09 22:53:56 +08:00
<if test= "organArray != null and organArray !=''" >
and dh.organ_id in (
<foreach collection= "organArray" item= "organId" separator= "," >
#{organId}
</foreach>
)
</if>
2023-03-09 21:37:13 +08:00
<if test= "depotList.size()>0" >
and di.depot_id in
<foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2023-03-17 23:21:27 +08:00
<if test= "forceFlag" >
2024-01-03 17:34:20 +08:00
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
2023-03-17 23:21:27 +08:00
</if>
2021-04-07 23:53:57 +08:00
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1'
</select>
<select id= "buyOrSalePrice" resultType= "java.math.BigDecimal" >
select ifnull(sum(all_price),0) as AllPrice from jsh_depot_item di,jsh_depot_head dh
where di.header_id = dh.id
2021-06-09 20:29:36 +08:00
and dh.type=#{type} and dh.sub_type=#{subType}
2021-06-08 22:00:51 +08:00
and dh.oper_time > = #{beginTime}
and dh.oper_time < = #{endTime}
2025-04-01 15:54:01 +08:00
<if test= "meId != null" >
and di.material_extend_id =#{meId}
2023-03-30 23:36:03 +08:00
</if>
2022-08-08 23:55:56 +08:00
<if test= "creatorArray != null" >
and dh.creator in (
<foreach collection= "creatorArray" item= "creator" separator= "," >
#{creator}
</foreach>
)
</if>
2023-04-10 23:37:49 +08:00
<if test= "organId != null" >
and dh.organ_id = #{organId}
</if>
2023-03-09 22:53:56 +08:00
<if test= "organArray != null and organArray !=''" >
and dh.organ_id in (
<foreach collection= "organArray" item= "organId" separator= "," >
#{organId}
</foreach>
)
</if>
2023-03-09 21:37:13 +08:00
<if test= "depotList.size()>0" >
and di.depot_id in
<foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2023-03-17 23:21:27 +08:00
<if test= "forceFlag" >
2024-01-03 17:34:20 +08:00
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
2023-03-17 23:21:27 +08:00
</if>
2021-04-07 23:53:57 +08:00
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1'
</select>
2024-04-15 13:52:58 +08:00
<select id= "buyOrSalePriceTotal" resultType= "java.math.BigDecimal" >
select ifnull(sum(di.all_price),0) as AllPrice
from jsh_depot_item di
left join jsh_depot_head dh on dh.id=di.header_id and ifnull(dh.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_Flag,'0') !='1'
where ifnull(di.delete_flag,'0') !='1'
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time > = #{beginTime}
and dh.oper_time < = #{endTime}
2025-01-14 00:18:33 +08:00
<if test= "categoryList.size()>0" >
and m.category_id in
<foreach collection= "categoryList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2024-04-15 13:52:58 +08:00
<if test= "materialParam != null and materialParam !=''" >
<bind name= "bindKey" value= "'%'+materialParam+'%'" />
2024-11-13 22:16:57 +08:00
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
2024-04-15 13:52:58 +08:00
</if>
<if test= "creatorArray != null" >
and dh.creator in (
<foreach collection= "creatorArray" item= "creator" separator= "," >
#{creator}
</foreach>
)
</if>
<if test= "organId != null" >
and dh.organ_id = #{organId}
</if>
<if test= "organArray != null and organArray !=''" >
and dh.organ_id in (
<foreach collection= "organArray" item= "organId" separator= "," >
#{organId}
</foreach>
)
</if>
<if test= "depotList.size()>0" >
and di.depot_id in
<foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
<if test= "forceFlag" >
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
</if>
</select>
2024-04-27 00:58:11 +08:00
<select id= "inOrOutPriceList" resultType= "com.jsh.erp.datasource.vo.InOutPriceVo" >
select distinct dh.id, dh.discount_last_money, dh.total_price, dh.type, dh.sub_type, dh.oper_time
2023-03-02 21:10:53 +08:00
from jsh_depot_head dh
2024-04-27 00:58:11 +08:00
left join jsh_depot_item di on dh.id = di.header_id and ifnull(di.delete_flag,'0') != '1'
where di.id is not null
and (dh.type='入库' or dh.type='出库')
2022-08-08 22:46:49 +08:00
and dh.oper_time > = #{beginTime}
and dh.oper_time < = #{endTime}
2023-03-17 23:05:03 +08:00
<if test= "forceFlag" >
2024-01-03 17:34:20 +08:00
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
2023-03-09 00:01:50 +08:00
</if>
2022-08-08 22:46:49 +08:00
<if test= "creatorArray != null" >
and dh.creator in (
<foreach collection= "creatorArray" item= "creator" separator= "," >
#{creator}
</foreach>
)
</if>
2024-04-27 00:58:11 +08:00
and ifnull(dh.delete_flag,'0') != '1'
2021-11-09 00:35:48 +08:00
</select>
2023-05-22 22:25:46 +08:00
<select id= "getSkuStockCheckSumByDepotList" resultType= "java.math.BigDecimal" >
select ifnull(sum(di.basic_number),0) stockCheckSum from jsh_depot_head dh
left JOIN jsh_depot_item di on dh.id=di.header_id
where 1=1
<if test= "meId != null" >
and di.material_extend_id=#{meId}
</if>
and dh.sub_type='盘点复盘'
<if test= "depotList.size()>0" >
and di.depot_id in
<foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
<if test= "forceFlag" >
and dh.status = '1'
</if>
<if test= "beginTime != null" >
and dh.oper_time > = #{beginTime}
</if>
<if test= "endTime != null" >
and dh.oper_time < = #{endTime}
</if>
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1'
</select>
2021-12-07 00:26:08 +08:00
<select id= "getStockCheckSumByDepotList" resultType= "java.math.BigDecimal" >
2021-04-07 23:53:57 +08:00
select ifnull(sum(di.basic_number),0) stockCheckSum from jsh_depot_head dh
2021-09-22 00:18:42 +08:00
left JOIN jsh_depot_item di on dh.id=di.header_id
2021-04-07 23:53:57 +08:00
where 1=1
<if test= "mId != null" >
and di.material_id=#{mId}
</if>
2021-08-23 00:18:43 +08:00
and dh.sub_type='盘点复盘'
2021-12-07 00:26:08 +08:00
<if test= "depotList.size()>0" >
and di.depot_id in
<foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
2021-04-07 23:53:57 +08:00
</if>
2023-03-17 23:05:03 +08:00
<if test= "forceFlag" >
2023-03-16 22:41:07 +08:00
and dh.status = '1'
</if>
2021-04-07 23:53:57 +08:00
<if test= "beginTime != null" >
2021-06-09 20:29:36 +08:00
and dh.oper_time > = #{beginTime}
2021-04-07 23:53:57 +08:00
</if>
<if test= "endTime != null" >
2021-06-09 20:29:36 +08:00
and dh.oper_time < = #{endTime}
2021-04-07 23:53:57 +08:00
</if>
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1'
</select>
2023-03-07 22:06:10 +08:00
<select id= "getSkuStockByParamWithDepotList" resultMap= "stockMap" >
2021-07-28 23:13:37 +08:00
select
2023-12-06 00:31:53 +08:00
sum(case when dh.type='入库' <include refid= "inOutManageParam" /> <include refid= "depotParam" /> then di.basic_number else 0 end) as inTotal,
sum(case when dh.type='出库' and dh.sub_type!='调拨' <include refid= "inOutManageParam" /> <include refid= "depotParam" /> then di.basic_number else 0 end) as outTotal,
2023-03-07 22:06:10 +08:00
sum(case when dh.sub_type='调拨' <include refid= "anotherDepotParam" /> then di.basic_number else 0 end) as transfInTotal,
sum(case when dh.sub_type='调拨' <include refid= "depotParam" /> then di.basic_number else 0 end) as transfOutTotal,
sum(case when dh.sub_type='组装单' and di.material_type='组合件' <include refid= "depotParam" /> then di.basic_number else 0 end) as assemInTotal,
sum(case when dh.sub_type='组装单' and di.material_type='普通子件' <include refid= "depotParam" /> then di.basic_number else 0 end) as assemOutTotal,
sum(case when dh.sub_type='拆卸单' and di.material_type='普通子件' <include refid= "depotParam" /> then di.basic_number else 0 end) as disAssemInTotal,
sum(case when dh.sub_type='拆卸单' and di.material_type='组合件' <include refid= "depotParam" /> then di.basic_number else 0 end) as disAssemOutTotal
2021-04-07 23:53:57 +08:00
from
2021-07-28 23:13:37 +08:00
jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where 1=1
and ifnull(dh.delete_flag,'0') !='1'
and di.material_extend_id=#{meId}
and ifnull(di.sku,'') !=''
2023-03-17 23:05:03 +08:00
<if test= "forceFlag" >
2023-03-16 22:41:07 +08:00
and dh.status = '1'
</if>
2021-07-28 23:13:37 +08:00
<if test= "beginTime != null" >
and dh.oper_time > = #{beginTime}
</if>
<if test= "endTime != null" >
and dh.oper_time < = #{endTime}
</if>
</select>
2021-12-07 00:26:08 +08:00
<select id= "getStockByParamWithDepotList" resultMap= "stockMap" >
2021-07-28 23:13:37 +08:00
select
2023-12-06 00:31:53 +08:00
sum(case when dh.type='入库' <include refid= "inOutManageParam" /> <include refid= "depotParam" /> then di.basic_number else 0 end) as inTotal,
sum(case when dh.type='出库' and dh.sub_type!='调拨' <include refid= "inOutManageParam" /> <include refid= "depotParam" /> then di.basic_number else 0 end) as outTotal,
2021-12-08 01:10:15 +08:00
sum(case when dh.sub_type='调拨' <include refid= "anotherDepotParam" /> then di.basic_number else 0 end) as transfInTotal,
2021-12-07 00:26:08 +08:00
sum(case when dh.sub_type='调拨' <include refid= "depotParam" /> then di.basic_number else 0 end) as transfOutTotal,
sum(case when dh.sub_type='组装单' and di.material_type='组合件' <include refid= "depotParam" /> then di.basic_number else 0 end) as assemInTotal,
sum(case when dh.sub_type='组装单' and di.material_type='普通子件' <include refid= "depotParam" /> then di.basic_number else 0 end) as assemOutTotal,
sum(case when dh.sub_type='拆卸单' and di.material_type='普通子件' <include refid= "depotParam" /> then di.basic_number else 0 end) as disAssemInTotal,
sum(case when dh.sub_type='拆卸单' and di.material_type='组合件' <include refid= "depotParam" /> then di.basic_number else 0 end) as disAssemOutTotal
2021-04-07 23:53:57 +08:00
from
2021-07-28 23:13:37 +08:00
jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
2021-04-07 23:53:57 +08:00
where 1=1
2021-07-28 23:13:37 +08:00
and ifnull(dh.delete_flag,'0') !='1'
2021-04-07 23:53:57 +08:00
and di.material_id=#{mId}
2023-03-17 23:05:03 +08:00
<if test= "forceFlag" >
2023-03-16 22:41:07 +08:00
and dh.status = '1'
</if>
2021-04-07 23:53:57 +08:00
<if test= "beginTime != null" >
2021-06-09 20:29:36 +08:00
and dh.oper_time > = #{beginTime}
2021-04-07 23:53:57 +08:00
</if>
<if test= "endTime != null" >
2021-06-09 20:29:36 +08:00
and dh.oper_time < = #{endTime}
2021-04-07 23:53:57 +08:00
</if>
</select>
2023-12-06 00:31:53 +08:00
<sql id= "inOutManageParam" >
<if test= "inOutManageFlag" >
and (dh.sub_type!='采购' and dh.sub_type!='采购退货' and dh.sub_type!='销售' and dh.sub_type!='销售退货')
</if>
</sql>
2023-03-07 22:06:10 +08:00
<sql id= "depotParam" >
<if test= "depotList.size()>0" >
and di.depot_id in <foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" > #{item}</foreach>
</if>
</sql>
<sql id= "anotherDepotParam" >
<if test= "depotList.size()>0" >
and di.another_depot_id in <foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" > #{item}</foreach>
</if>
</sql>
2021-04-07 23:53:57 +08:00
<select id= "findDepotItemListBydepotheadId" resultType= "com.jsh.erp.datasource.entities.DepotItem" >
select
dep.id,dep.header_id,dep.material_id,dep.material_unit,dep.oper_number,
dep.basic_number,dep.unit_price,dep.tax_unit_price,dep.all_price,dep.remark,
2021-07-28 23:41:56 +08:00
dep.depot_id,dep.another_depot_id,dep.tax_rate,
dep.tax_money,dep.tax_last_money,dep.material_type
2021-04-07 23:53:57 +08:00
from jsh_depot_item dep,jsh_material mat
where 1=1
<if test= "depotheadId != null" >
and dep.header_id = #{depotheadId}
</if>
and dep.material_id=mat.id
<if test= "enableSerialNumber != null" >
and mat.enable_serial_number = #{enableSerialNumber}
</if>
and ifnull(dep.delete_flag,'0') !='1'
and ifnull(mat.delete_flag,'0') !='1'
</select>
<update id= "batchDeleteDepotItemByDepotHeadIds" >
update jsh_depot_item
set delete_flag='1'
where 1=1
and header_id in
(
<foreach collection= "depotheadIds" item= "depotheadId" separator= "," >
#{depotheadId}
</foreach>
)
</update>
<update id= "batchDeleteDepotItemByIds" >
update jsh_depot_item
set delete_flag='1'
where 1=1
and id in (
<foreach collection= "ids" item= "id" separator= "," >
#{id}
</foreach>
)
</update>
<select id= "getDepotItemListListByDepotIds" resultMap= "com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap" >
select
<include refid= "com.jsh.erp.datasource.mappers.DepotItemMapper.Base_Column_List" />
from jsh_depot_item
where 1=1
and depot_id in (
<foreach collection= "depotIds" item= "depotId" separator= "," >
#{depotId}
</foreach>
)
and ifnull(delete_flag,'0') !='1'
</select>
<select id= "getDepotItemListListByMaterialIds" resultMap= "com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap" >
select
<include refid= "com.jsh.erp.datasource.mappers.DepotItemMapper.Base_Column_List" />
from jsh_depot_item
where 1=1
and material_id in (
<foreach collection= "materialIds" item= "materialId" separator= "," >
#{materialId}
</foreach>
)
and ifnull(delete_flag,'0') !='1'
</select>
<select id= "findStockWarningCount" parameterType= "com.jsh.erp.datasource.entities.DepotItemExample" resultMap= "ResultStockWarningCount" >
2024-10-09 00:48:34 +08:00
select m.id MId, m.name MName, me.bar_code, m.mfrs MMfrs, m.model MModel, m.standard MStandard,m.color MColor, m.brand,
2021-10-31 23:46:10 +08:00
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,d.name depotName,
2021-12-03 23:46:50 +08:00
m.unit MaterialUnit, u.basic_unit unit_name,mcs.current_number,
2022-11-03 00:03:53 +08:00
mis.low_safe_stock, mis.high_safe_stock
2021-04-07 23:53:57 +08:00
from jsh_material m
2021-07-16 00:49:14 +08:00
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
2021-10-29 19:52:20 +08:00
left join jsh_material_initial_stock mis on mis.material_id=m.id and ifnull(mis.delete_Flag,'0') !='1'
2021-04-07 23:53:57 +08:00
left join jsh_material_current_stock mcs on mcs.material_id=m.id and ifnull(mcs.delete_Flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
2021-10-31 23:46:10 +08:00
left join jsh_depot d on d.id=mis.depot_id and ifnull(u.delete_flag,'0') !='1'
2021-04-07 23:53:57 +08:00
where 1=1
2021-07-16 00:49:14 +08:00
and me.default_flag=1
2021-04-07 23:53:57 +08:00
and ifnull(m.delete_flag,'0') !='1'
2021-10-31 23:46:10 +08:00
and mis.depot_id=mcs.depot_id
2021-12-05 22:52:31 +08:00
and ((ifnull(mis.low_safe_stock,0)!=0 and mcs.current_number < ifnull(mis.low_safe_stock,0))
2022-11-03 21:02:54 +08:00
or (ifnull(mis.high_safe_stock,0)!=0 and mcs.current_number > ifnull(mis.high_safe_stock,0)))
2021-04-07 23:53:57 +08:00
<if test= "materialParam != null and materialParam !=''" >
<bind name= "bindKey" value= "'%'+materialParam+'%'" />
2024-10-07 01:12:38 +08:00
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
2021-04-07 23:53:57 +08:00
</if>
2021-12-07 23:58:21 +08:00
<if test= "depotList.size()>0" >
and mis.depot_id in
<foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
2021-04-07 23:53:57 +08:00
</if>
2025-01-14 00:18:33 +08:00
<if test= "categoryList.size()>0" >
and m.category_id in
<foreach collection= "categoryList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2021-10-31 23:46:10 +08:00
order by depotName asc
2021-04-07 23:53:57 +08:00
<if test= "offset != null and rows != null" >
limit #{offset},#{rows}
</if>
</select>
<select id= "findStockWarningCountTotal" resultType= "java.lang.Integer" >
select count(1) from
(select m.id
from jsh_material m
2021-07-16 00:49:14 +08:00
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
2021-10-29 19:52:20 +08:00
left join jsh_material_initial_stock mis on mis.material_id=m.id and ifnull(mis.delete_Flag,'0') !='1'
2021-04-07 23:53:57 +08:00
left join jsh_material_current_stock mcs on mcs.material_id=m.id and ifnull(mcs.delete_Flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
2021-10-31 23:46:10 +08:00
left join jsh_depot d on d.id=mis.depot_id and ifnull(u.delete_flag,'0') !='1'
2021-04-07 23:53:57 +08:00
where 1=1
2021-07-16 00:49:14 +08:00
and me.default_flag=1
2021-04-07 23:53:57 +08:00
and ifnull(m.delete_flag,'0') !='1'
2021-10-31 23:46:10 +08:00
and mis.depot_id=mcs.depot_id
2021-12-05 22:52:31 +08:00
and ((ifnull(mis.low_safe_stock,0)!=0 and mcs.current_number < ifnull(mis.low_safe_stock,0))
2023-04-23 23:29:16 +08:00
or (ifnull(mis.high_safe_stock,0)!=0 and mcs.current_number > ifnull(mis.high_safe_stock,0)))
2021-04-07 23:53:57 +08:00
<if test= "materialParam != null and materialParam !=''" >
<bind name= "bindKey" value= "'%'+materialParam+'%'" />
2024-10-07 01:12:38 +08:00
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
2021-04-07 23:53:57 +08:00
</if>
2021-12-07 23:58:21 +08:00
<if test= "depotList.size()>0" >
and mis.depot_id in
<foreach collection= "depotList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
2021-04-07 23:53:57 +08:00
</if>
2025-01-14 00:18:33 +08:00
<if test= "categoryList.size()>0" >
and m.category_id in
<foreach collection= "categoryList" item= "item" index= "index" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2021-10-31 23:46:10 +08:00
) tb
2021-04-07 23:53:57 +08:00
</select>
2021-09-25 22:09:36 +08:00
<select id= "getFinishNumber" resultType= "java.math.BigDecimal" >
select ifnull(sum(di.basic_number),0) from jsh_depot_item di
2022-05-07 18:23:43 +08:00
where di.material_extend_id=#{meId}
2022-05-28 22:36:33 +08:00
and di.link_id=#{linkId}
2021-09-25 22:09:36 +08:00
and ifnull(di.delete_flag,'0') !='1'
and di.header_id
in
(
select dh.id from jsh_depot_head dh
2024-04-23 00:44:25 +08:00
where 1=1
<if test= "noType == 'normal'" >
and dh.link_number=#{linkStr}
</if>
<if test= "noType == 'apply'" >
and dh.link_apply=#{linkStr}
</if>
2021-09-25 22:09:36 +08:00
and ifnull(dh.delete_flag,'0') !='1'
2022-05-07 18:23:43 +08:00
<if test= "goToType != null and goToType !=''" >
and dh.sub_type=#{goToType}
</if>
)
</select>
<select id= "getRealFinishNumber" resultType= "java.math.BigDecimal" >
select ifnull(sum(di.basic_number),0) from jsh_depot_item di
where di.material_extend_id=#{meId}
2022-05-28 22:36:33 +08:00
and di.link_id=#{linkId}
2022-05-07 18:23:43 +08:00
and ifnull(di.delete_flag,'0') !='1'
and di.header_id
in
(
select dh.id from jsh_depot_head dh
where
2024-04-23 00:44:25 +08:00
dh.id!=#{currentHeaderId}
<if test= "linkType == 'normal'" >
and dh.link_number=#{linkStr}
</if>
<if test= "linkType == 'apply'" >
and dh.link_apply=#{linkStr}
</if>
2022-05-07 18:23:43 +08:00
and ifnull(dh.delete_flag,'0') !='1'
<if test= "goToType != null and goToType !=''" >
2021-09-25 22:09:36 +08:00
and dh.sub_type=#{goToType}
</if>
)
</select>
2021-09-29 01:17:20 +08:00
<select id= "getBatchNumberList" resultMap= "batchNumberListMap" >
2023-04-01 23:26:07 +08:00
select id, bar_code, name, standard, model, unit_id,
commodity_unit, batch_number, expiration_date, sum(basic_number) total_num from
(select di.batch_number id, me.bar_code, m.name, m.standard, m.model, m.unit_id,
me.commodity_unit, di.batch_number,di.expiration_date,
di.basic_number*(case dh.type when '入库' then 1 when '出库' then -1 end) as basic_number
2022-09-09 00:25:03 +08:00
from jsh_depot_head dh
2021-09-29 01:17:20 +08:00
left join jsh_depot_item di on dh.id=di.header_id
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_flag, '0') != '1'
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_flag,'0') !='1'
2023-04-01 23:26:07 +08:00
where me.bar_code= #{barCode}
2021-09-29 01:17:20 +08:00
<if test= "name != null" >
<bind name= "bindName" value= "'%'+name+'%'" />
and di.batch_number like #{bindName}
</if>
<if test= "depotId != null" >
and di.depot_id= #{depotId}
</if>
<if test= "batchNumber != null" >
and di.batch_number= #{batchNumber}
</if>
2022-09-09 00:25:03 +08:00
<if test= "number != null" >
and dh.number!= #{number}
</if>
2023-12-15 00:11:56 +08:00
<if test= "forceFlag" >
and dh.status = '1'
</if>
<if test= "inOutManageFlag" >
and (dh.sub_type!='采购' and dh.sub_type!='采购退货' and dh.sub_type!='销售' and dh.sub_type!='销售退货')
</if>
2021-09-29 01:17:20 +08:00
and m.enable_batch_number =1
and di.delete_flag!=1) tb
2025-03-25 09:32:47 +08:00
group by id, bar_code, name, standard, model, unit_id,
commodity_unit, batch_number, expiration_date
2021-09-29 01:17:20 +08:00
order by expiration_date asc
</select>
2022-05-13 18:25:57 +08:00
<select id= "getCountByMaterialAndDepot" resultType= "java.lang.Long" >
select count(1) from jsh_depot_item di
where di.material_id=#{mId} and di.depot_id=#{depotId}
and ifnull(di.delete_flag,'0') !='1'
</select>
2022-05-17 00:04:35 +08:00
<select id= "getLinkBillDetailMaterialSum" resultMap= "materialSumMap" >
select di.material_extend_id, sum(di.oper_number) oper_number from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
2024-04-23 00:44:25 +08:00
where dh.number=#{linkStr}
2022-05-17 00:04:35 +08:00
and ifnull(dh.delete_flag,'0') !='1'
group by di.material_extend_id
</select>
<select id= "getBatchBillDetailMaterialSum" resultMap= "materialSumMap" >
select di.material_extend_id, sum(di.oper_number) oper_number from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
2024-04-23 00:44:25 +08:00
where dh.type=#{type}
<if test= "linkType == 'normal'" >
and dh.link_number=#{linkStr}
</if>
<if test= "linkType == 'apply'" >
and dh.link_apply=#{linkStr}
</if>
and ifnull(dh.delete_flag,'0') !='1'
2022-05-17 00:04:35 +08:00
group by di.material_extend_id
</select>
2022-05-22 23:13:57 +08:00
<select id= "getCountByMaterialAndBatchNumber" resultType= "java.lang.Long" >
select count(di.id) from
jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where 1=1
and ifnull(dh.delete_flag,'0') !='1'
and di.material_extend_id=#{meId}
and di.batch_number=#{batchNumber}
</select>
2022-10-07 19:13:22 +08:00
<select id= "getDepotItemByBatchNumber" resultType= "com.jsh.erp.datasource.entities.DepotItem" >
select di.* from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where 1=1
and ifnull(dh.delete_flag,'0') !='1'
2024-04-07 15:20:57 +08:00
and di.material_extend_id = #{materialExtendId}
2022-10-07 19:13:22 +08:00
and di.batch_number = #{batchNumber}
and dh.type = '入库'
</select>
2023-05-12 00:47:49 +08:00
<select id= "getBillItemByParam" resultType= "com.jsh.erp.datasource.entities.MaterialVo4Unit" >
select m.id, m.name, m.standard, m.model, me.id meId,me.commodity_unit commodityUnit,
2023-05-23 22:03:01 +08:00
me.purchase_decimal purchaseDecimal, me.wholesale_decimal wholesaleDecimal, me.bar_code mBarCode, me.sku
2023-05-12 00:47:49 +08:00
from jsh_material m
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
where 1=1
<if test= "barCodes != null" >
and me.bar_code in (${barCodes})
</if>
and ifnull(m.delete_flag,'0') !='1'
order by m.id desc
</select>
<select id= "getCurrentStockByParam" resultType= "java.math.BigDecimal" >
select sum(ifnull(current_number,0))
from jsh_material_current_stock
where 1=1
<if test= "depotId != null" >
and depot_id = ${depotId}
</if>
<if test= "mId != null" >
and material_id = ${mId}
</if>
and ifnull(delete_flag,'0') !='1'
</select>
2023-06-11 18:47:07 +08:00
<select id= "getLastUnitPriceByParam" resultType= "java.math.BigDecimal" >
select di.unit_price from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where dh.organ_id = #{organId}
and di.material_extend_id = #{meId}
and dh.type = #{type} and dh.sub_type = #{subType}
and ifnull(dh.delete_flag,'0') !='1'
order by dh.id desc, di.id desc
limit 0,1
</select>
2024-04-27 00:58:11 +08:00
2021-04-07 23:53:57 +08:00
</mapper>