优化库存预警报表的查询逻辑
This commit is contained in:
parent
1698b1fd8a
commit
c9ac3d2197
@ -554,6 +554,14 @@ public class DepotItemController {
|
||||
diEx.setMOtherField3(disw.getMOtherField3());
|
||||
disw.setMaterialOther(getOtherInfo(mpArr, diEx));
|
||||
disw.setMaterialUnit(getUName(disw.getMaterialUnit(), disw.getUnitName()));
|
||||
if(disw.getCurrentNumber().compareTo(disw.getLowSafeStock())<0) {
|
||||
disw.setLowCritical(disw.getLowSafeStock().subtract(disw.getCurrentNumber()));
|
||||
disw.setHighCritical(BigDecimal.ZERO);
|
||||
}
|
||||
if(disw.getCurrentNumber().compareTo(disw.getHighSafeStock())>0) {
|
||||
disw.setLowCritical(BigDecimal.ZERO);
|
||||
disw.setHighCritical(disw.getCurrentNumber().subtract(disw.getHighSafeStock()));
|
||||
}
|
||||
}
|
||||
}
|
||||
int total = depotItemService.findStockWarningCountTotal(materialParam,depotId);
|
||||
|
||||
@ -31,11 +31,17 @@ public class DepotItemStockWarningCount {
|
||||
|
||||
private String MOtherField3;
|
||||
|
||||
private BigDecimal safetystock;//安全库存量
|
||||
private String depotName;
|
||||
|
||||
private BigDecimal currentNumber;//库存
|
||||
private BigDecimal currentNumber;
|
||||
|
||||
private BigDecimal linjieNumber;//临界库存
|
||||
private BigDecimal lowSafeStock;
|
||||
|
||||
private BigDecimal highSafeStock;
|
||||
|
||||
private BigDecimal lowCritical;
|
||||
|
||||
private BigDecimal highCritical;
|
||||
|
||||
public Long getMId() {
|
||||
return MId;
|
||||
@ -141,12 +147,12 @@ public class DepotItemStockWarningCount {
|
||||
this.MOtherField3 = MOtherField3;
|
||||
}
|
||||
|
||||
public BigDecimal getSafetystock() {
|
||||
return safetystock;
|
||||
public String getDepotName() {
|
||||
return depotName;
|
||||
}
|
||||
|
||||
public void setSafetystock(BigDecimal safetystock) {
|
||||
this.safetystock = safetystock;
|
||||
public void setDepotName(String depotName) {
|
||||
this.depotName = depotName;
|
||||
}
|
||||
|
||||
public BigDecimal getCurrentNumber() {
|
||||
@ -157,11 +163,35 @@ public class DepotItemStockWarningCount {
|
||||
this.currentNumber = currentNumber;
|
||||
}
|
||||
|
||||
public BigDecimal getLinjieNumber() {
|
||||
return linjieNumber;
|
||||
public BigDecimal getLowSafeStock() {
|
||||
return lowSafeStock;
|
||||
}
|
||||
|
||||
public void setLinjieNumber(BigDecimal linjieNumber) {
|
||||
this.linjieNumber = linjieNumber;
|
||||
public void setLowSafeStock(BigDecimal lowSafeStock) {
|
||||
this.lowSafeStock = lowSafeStock;
|
||||
}
|
||||
|
||||
public BigDecimal getHighSafeStock() {
|
||||
return highSafeStock;
|
||||
}
|
||||
|
||||
public void setHighSafeStock(BigDecimal highSafeStock) {
|
||||
this.highSafeStock = highSafeStock;
|
||||
}
|
||||
|
||||
public BigDecimal getLowCritical() {
|
||||
return lowCritical;
|
||||
}
|
||||
|
||||
public void setLowCritical(BigDecimal lowCritical) {
|
||||
this.lowCritical = lowCritical;
|
||||
}
|
||||
|
||||
public BigDecimal getHighCritical() {
|
||||
return highCritical;
|
||||
}
|
||||
|
||||
public void setHighCritical(BigDecimal highCritical) {
|
||||
this.highCritical = highCritical;
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,9 +67,9 @@
|
||||
<result column="MOtherField2" jdbcType="VARCHAR" property="MOtherField2" />
|
||||
<result column="MOtherField3" jdbcType="VARCHAR" property="MOtherField3" />
|
||||
<result column="unit_name" jdbcType="VARCHAR" property="unitName" />
|
||||
<result column="safetystock" jdbcType="DECIMAL" property="safetystock" />
|
||||
<result column="current_number" jdbcType="DECIMAL" property="currentNumber" />
|
||||
<result column="linjieNumber" jdbcType="DECIMAL" property="linjieNumber" />
|
||||
<result column="low_safe_stock" jdbcType="DECIMAL" property="lowSafeStock" />
|
||||
<result column="high_safe_stock" jdbcType="DECIMAL" property="highSafeStock" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="stockMap" type="com.jsh.erp.datasource.vo.DepotItemVo4Stock">
|
||||
@ -420,29 +420,28 @@
|
||||
|
||||
<select id="findStockWarningCount" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultStockWarningCount">
|
||||
select m.id MId, m.name MName, me.bar_code, m.mfrs MMfrs, m.model MModel, m.standard MStandard,m.color MColor,
|
||||
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
|
||||
m.unit MaterialUnit, u.name unit_name,mcs.current_number,ifnull(mis.low_safe_stock,0) safetystock,
|
||||
(ifnull(mis.low_safe_stock,0)-mcs.current_number) linjieNumber
|
||||
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,d.name depotName,
|
||||
m.unit MaterialUnit, u.name unit_name,mcs.current_number,
|
||||
ifnull(mis.low_safe_stock,0) low_safe_stock, ifnull(mis.high_safe_stock,0) high_safe_stock
|
||||
from jsh_material m
|
||||
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
|
||||
left join jsh_material_initial_stock mis on mis.material_id=m.id and ifnull(mis.delete_Flag,'0') !='1'
|
||||
left join jsh_material_current_stock mcs on mcs.material_id=m.id and ifnull(mcs.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'
|
||||
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
|
||||
left join jsh_depot d on d.id=mis.depot_id and ifnull(u.delete_flag,'0') !='1'
|
||||
where 1=1
|
||||
and me.default_flag=1
|
||||
and ifnull(m.delete_flag,'0') !='1'
|
||||
and ifnull(mis.low_safe_stock,0) > mcs.current_number
|
||||
and mis.depot_id=mcs.depot_id
|
||||
and (mcs.current_number < ifnull(mis.low_safe_stock,0) or mcs.current_number > ifnull(mis.high_safe_stock,0))
|
||||
<if test="materialParam != null and materialParam !=''">
|
||||
<bind name="bindKey" value="'%'+materialParam+'%'"/>
|
||||
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
|
||||
</if>
|
||||
<if test="depotId != null">
|
||||
and mcs.depot_id= #{depotId}
|
||||
and mis.depot_id= #{depotId}
|
||||
</if>
|
||||
group by m.id,m.name, m.model, m.unit, m.color, u.name
|
||||
order by linjieNumber desc
|
||||
order by depotName asc
|
||||
<if test="offset != null and rows != null">
|
||||
limit #{offset},#{rows}
|
||||
</if>
|
||||
@ -455,21 +454,21 @@
|
||||
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
|
||||
left join jsh_material_initial_stock mis on mis.material_id=m.id and ifnull(mis.delete_Flag,'0') !='1'
|
||||
left join jsh_material_current_stock mcs on mcs.material_id=m.id and ifnull(mcs.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'
|
||||
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
|
||||
left join jsh_depot d on d.id=mis.depot_id and ifnull(u.delete_flag,'0') !='1'
|
||||
where 1=1
|
||||
and me.default_flag=1
|
||||
and ifnull(m.delete_flag,'0') !='1'
|
||||
and ifnull(mis.low_safe_stock,0) > mcs.current_number
|
||||
and mis.depot_id=mcs.depot_id
|
||||
and (mcs.current_number < ifnull(mis.low_safe_stock,0) or mcs.current_number > ifnull(mis.high_safe_stock,0))
|
||||
<if test="materialParam != null and materialParam !=''">
|
||||
<bind name="bindKey" value="'%'+materialParam+'%'"/>
|
||||
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
|
||||
</if>
|
||||
<if test="depotId != null">
|
||||
and mcs.depot_id= #{depotId}
|
||||
and mis.depot_id= #{depotId}
|
||||
</if>
|
||||
group by m.id,m.name, m.model, m.unit, m.color, u.name) tb
|
||||
) tb
|
||||
</select>
|
||||
|
||||
<select id="getFinishNumber" resultType="java.math.BigDecimal">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user