优化库存预警报表

This commit is contained in:
季圣华
2020-12-27 17:46:59 +08:00
parent c4db070541
commit 8d85df5dbd
4 changed files with 109 additions and 159 deletions

View File

@@ -202,16 +202,14 @@
pageSize: 10, pageSize: 10,
pageList: [10, 50, 100], pageList: [10, 50, 100],
columns: [[ columns: [[
{title: '名称', field: 'materialName', width: 160}, {title: '名称', field: 'mname', width: 160},
{title: '规格', field: 'materialStandard', width: 80}, {title: '规格', field: 'mstandard', width: 80},
{title: '型号', field: 'materialModel', width: 80}, {title: '型号', field: 'mmodel', width: 80},
{title: '扩展信息', field: 'materialOther', width: 150}, {title: '扩展信息', field: 'materialOther', width: 150},
{title: '单位', field: 'materialUnit', width: 80}, {title: '单位', field: 'materialUnit', width: 80},
{title: '入库数量', field: 'basicInNumber', width: 80}, {title: '安全存量', field: 'safetystock', width: 80},
{title: '出库数量', field: 'basicOutNumber', width: 80}, {title: '当前库存', field: 'currentNumber', width: 80},
{title: '库存数量', field: 'basicNumber', width: 80}, {title: '建议入库量', field: 'linjieNumber', width: 80}
{title: '安全库存量', field: 'safetystock', width: 80},
{title: '临界库存量', field: 'basicLinjieNumber', width: 80}
]], ]],
onLoadError: function () { onLoadError: function () {
$.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error'); $.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error');

View File

@@ -591,6 +591,7 @@ public class DepotItemController {
diEx.setMOtherField2(disw.getMOtherField2()); diEx.setMOtherField2(disw.getMOtherField2());
diEx.setMOtherField3(disw.getMOtherField3()); diEx.setMOtherField3(disw.getMOtherField3());
disw.setMaterialOther(getOtherInfo(mpArr, diEx)); disw.setMaterialOther(getOtherInfo(mpArr, diEx));
disw.setMaterialUnit(getUName(disw.getMaterialUnit(), disw.getUnitName()));
} }
} }
int total = depotItemService.findStockWarningCountTotal(pid); int total = depotItemService.findStockWarningCountTotal(pid);
@@ -628,7 +629,7 @@ public class DepotItemController {
List<DepotItemStockWarningCount> dataList = depotItemService.findStockWarningCount((currentPage - 1) * pageSize, pageSize, projectId); List<DepotItemStockWarningCount> dataList = depotItemService.findStockWarningCount((currentPage - 1) * pageSize, pageSize, projectId);
//存放数据json数组 //存放数据json数组
Integer pid = projectId; Integer pid = projectId;
String[] names = {"名称", "规格", "型号", "扩展信息", "单位", "入库数量", "出库数量", "库存数", "安全库存", "临界库存"}; String[] names = {"名称", "规格", "型号", "扩展信息", "单位", "安全存", "当前库存", "建议入库"};
String title = "库存预警报表"; String title = "库存预警报表";
List<String[]> objects = new ArrayList<String[]>(); List<String[]> objects = new ArrayList<String[]>();
if (null != dataList) { if (null != dataList) {
@@ -639,17 +640,16 @@ public class DepotItemController {
diVI.setMOtherField2(diEx.getMOtherField2()); diVI.setMOtherField2(diEx.getMOtherField2());
diVI.setMOtherField3(diEx.getMOtherField3()); diVI.setMOtherField3(diEx.getMOtherField3());
String materialOther = getOtherInfo(mpArr, diVI); String materialOther = getOtherInfo(mpArr, diVI);
String[] objs = new String[10]; String unitName = getUName(diEx.getMaterialUnit(), diEx.getUnitName());
objs[0] = diEx.getMaterialName(); String[] objs = new String[8];
objs[1] = diEx.getMaterialStandard(); objs[0] = diEx.getMName();
objs[2] = diEx.getMaterialModel(); objs[1] = diEx.getMStandard();
objs[2] = diEx.getMModel();
objs[3] = materialOther; objs[3] = materialOther;
objs[4] = diEx.getMaterialUnit(); objs[4] = unitName;
objs[5] = diEx.getBasicInNumber().toString(); objs[5] = diEx.getSafetystock() == null ? "0" : diEx.getSafetystock().toString();
objs[6] = diEx.getBasicOutNumber() == null ? "0" : diEx.getBasicOutNumber().toString(); objs[6] = diEx.getCurrentNumber() == null ? "0" : diEx.getCurrentNumber().toString();
objs[7] = diEx.getBasicNumber() == null ? "0" : diEx.getBasicNumber().toString(); objs[7] = diEx.getLinjieNumber() == null ? "0" : diEx.getLinjieNumber().toString();
objs[8] = diEx.getSafetystock() == null ? "0" : diEx.getSafetystock().toString();
objs[9] = diEx.getBasicLinjieNumber() == null ? "0" : diEx.getBasicLinjieNumber().toString();
objects.add(objs); objects.add(objs);
} }
} }

View File

@@ -5,15 +5,21 @@ import java.math.BigDecimal;
public class DepotItemStockWarningCount { public class DepotItemStockWarningCount {
private String MaterialName; private Long MId;
private String MaterialModel; private String MName;
private String MaterialStandard; private String MModel;
private String MaterialUnit;
private String MColor;
private String MStandard;
private String MMfrs; private String MMfrs;
private String categoryName; private String unitName;
private String MaterialOther; private String MaterialOther;
@@ -23,41 +29,58 @@ public class DepotItemStockWarningCount {
private String MOtherField3; private String MOtherField3;
private String MaterialUnit;
private BigDecimal safetystock;//安全库存量 private BigDecimal safetystock;//安全库存量
private BigDecimal BasicInNumber;//入库量 private BigDecimal currentNumber;//库存
private BigDecimal BasicOutNumber;//出库量 private BigDecimal linjieNumber;//临界库存
public Long getMId() {
private BigDecimal BasicNumber;//库存 return MId;
private BigDecimal BasicLinjieNumber;//临界库存
public String getMaterialName() {
return MaterialName;
} }
public void setMaterialName(String materialName) { public void setMId(Long MId) {
MaterialName = materialName; this.MId = MId;
} }
public String getMaterialModel() { public String getMName() {
return MaterialModel; return MName;
} }
public void setMaterialModel(String materialModel) { public void setMName(String MName) {
MaterialModel = materialModel; this.MName = MName;
} }
public String getMaterialStandard() { public String getMModel() {
return MaterialStandard; return MModel;
} }
public void setMaterialStandard(String materialStandard) { public void setMModel(String MModel) {
MaterialStandard = materialStandard; this.MModel = MModel;
}
public String getMaterialUnit() {
return MaterialUnit;
}
public void setMaterialUnit(String materialUnit) {
MaterialUnit = materialUnit;
}
public String getMColor() {
return MColor;
}
public void setMColor(String MColor) {
this.MColor = MColor;
}
public String getMStandard() {
return MStandard;
}
public void setMStandard(String MStandard) {
this.MStandard = MStandard;
} }
public String getMMfrs() { public String getMMfrs() {
@@ -68,12 +91,12 @@ public class DepotItemStockWarningCount {
this.MMfrs = MMfrs; this.MMfrs = MMfrs;
} }
public String getCategoryName() { public String getUnitName() {
return categoryName; return unitName;
} }
public void setCategoryName(String categoryName) { public void setUnitName(String unitName) {
this.categoryName = categoryName; this.unitName = unitName;
} }
public String getMaterialOther() { public String getMaterialOther() {
@@ -108,14 +131,6 @@ public class DepotItemStockWarningCount {
this.MOtherField3 = MOtherField3; this.MOtherField3 = MOtherField3;
} }
public String getMaterialUnit() {
return MaterialUnit;
}
public void setMaterialUnit(String materialUnit) {
MaterialUnit = materialUnit;
}
public BigDecimal getSafetystock() { public BigDecimal getSafetystock() {
return safetystock; return safetystock;
} }
@@ -124,35 +139,19 @@ public class DepotItemStockWarningCount {
this.safetystock = safetystock; this.safetystock = safetystock;
} }
public BigDecimal getBasicInNumber() { public BigDecimal getCurrentNumber() {
return BasicInNumber; return currentNumber;
} }
public void setBasicInNumber(BigDecimal basicInNumber) { public void setCurrentNumber(BigDecimal currentNumber) {
BasicInNumber = basicInNumber; this.currentNumber = currentNumber;
} }
public BigDecimal getBasicOutNumber() { public BigDecimal getLinjieNumber() {
return BasicOutNumber; return linjieNumber;
} }
public void setBasicOutNumber(BigDecimal basicOutNumber) { public void setLinjieNumber(BigDecimal linjieNumber) {
BasicOutNumber = basicOutNumber; this.linjieNumber = linjieNumber;
}
public BigDecimal getBasicNumber() {
return BasicNumber;
}
public void setBasicNumber(BigDecimal basicNumber) {
BasicNumber = basicNumber;
}
public BigDecimal getBasicLinjieNumber() {
return BasicLinjieNumber;
}
public void setBasicLinjieNumber(BigDecimal basicLinjieNumber) {
BasicLinjieNumber = basicLinjieNumber;
} }
} }

View File

@@ -50,20 +50,19 @@
</resultMap> </resultMap>
<resultMap id="ResultStockWarningCount" type="com.jsh.erp.datasource.vo.DepotItemStockWarningCount"> <resultMap id="ResultStockWarningCount" type="com.jsh.erp.datasource.vo.DepotItemStockWarningCount">
<result column="MaterialName" jdbcType="VARCHAR" property="MaterialName" /> <result column="MId" jdbcType="VARCHAR" property="MId" />
<result column="MaterialModel" jdbcType="VARCHAR" property="MaterialModel" /> <result column="MName" jdbcType="VARCHAR" property="MName" />
<result column="MaterialStandard" jdbcType="VARCHAR" property="MaterialStandard" />
<result column="MMfrs" jdbcType="VARCHAR" property="MMfrs" /> <result column="MMfrs" jdbcType="VARCHAR" property="MMfrs" />
<result column="categoryName" jdbcType="VARCHAR" property="categoryName" /> <result column="MModel" jdbcType="VARCHAR" property="MModel" />
<result column="MStandard" jdbcType="VARCHAR" property="MStandard" />
<result column="MaterialUnit" jdbcType="VARCHAR" property="MaterialUnit" /> <result column="MaterialUnit" jdbcType="VARCHAR" property="MaterialUnit" />
<result column="MOtherField1" jdbcType="VARCHAR" property="MOtherField1" /> <result column="MOtherField1" jdbcType="VARCHAR" property="MOtherField1" />
<result column="MOtherField2" jdbcType="VARCHAR" property="MOtherField2" /> <result column="MOtherField2" jdbcType="VARCHAR" property="MOtherField2" />
<result column="MOtherField3" jdbcType="VARCHAR" property="MOtherField3" /> <result column="MOtherField3" jdbcType="VARCHAR" property="MOtherField3" />
<result column="unit_name" jdbcType="VARCHAR" property="unitName" />
<result column="safetystock" jdbcType="DECIMAL" property="safetystock" /> <result column="safetystock" jdbcType="DECIMAL" property="safetystock" />
<result column="BasicInNumber" jdbcType="DECIMAL" property="BasicInNumber" /> <result column="current_number" jdbcType="DECIMAL" property="currentNumber" />
<result column="BasicOutNumber" jdbcType="DECIMAL" property="BasicOutNumber" /> <result column="linjieNumber" jdbcType="DECIMAL" property="linjieNumber" />
<result column="BasicNumber" jdbcType="DECIMAL" property="BasicNumber" />
<result column="BasicLinjieNumber" jdbcType="DECIMAL" property="BasicLinjieNumber" />
</resultMap> </resultMap>
<resultMap id="StockMap" type="com.jsh.erp.datasource.vo.DepotItemVo4Stock"> <resultMap id="StockMap" type="com.jsh.erp.datasource.vo.DepotItemVo4Stock">
@@ -372,61 +371,23 @@
</select> </select>
<select id="findStockWarningCount" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultStockWarningCount"> <select id="findStockWarningCount" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultStockWarningCount">
SELECT select m.id MId, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,m.color MColor,
m.name MaterialName,
m.model MaterialModel,
m.standard MaterialStandard,
m.mfrs MMfrs,
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3, m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
mc.`Name` categoryName, m.unit MaterialUnit, u.name unit_name,mcs.current_number,ifnull(m.safety_stock,0) safetystock,
m.unit MaterialUnit, (ifnull(m.safety_stock,0)-mcs.current_number) linjieNumber
ifnull(m.safety_stock,0) safetystock, from jsh_material m
IFNULL(intype.BasicInNumber ,0) BasicInNumber, left join jsh_material_current_stock mcs on mcs.material_id=m.id and ifnull(mcs.delete_Flag,'0') !='1'
IFNULL(outtype.BasicOutNumber ,0) BasicOutNumber, 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'
IFNULL(intype.BasicInNumber ,0) - IFNULL(outtype.BasicOutNumber ,0) left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
) BasicNumber, where 1=1
(IFNULL(intype.BasicInNumber ,0) - IFNULL(outtype.BasicOutNumber ,0) - ifnull(m.safety_stock,0)) BasicLinjieNumber and ifnull(m.delete_flag,'0') !='1'
FROM and ifnull(m.safety_stock,0) > mcs.current_number
jsh_material m
LEFT JOIN jsh_material_category mc ON mc.id = m.category_id
LEFT JOIN (
SELECT
di.material_id,
ifnull(sum(basic_number), 0) AS BasicInNumber
FROM
jsh_depot_head dh
INNER JOIN jsh_depot_item di ON dh.id = di.header_id
AND ifnull(di.delete_flag, '0') != '1'
WHERE
dh.type = '入库'
<if test="pid != null"> <if test="pid != null">
and di.depot_id= ${pid} and mcs.depot_id= ${pid}
</if> </if>
AND ifnull(dh.delete_flag, '0') != '1' group by di.material_id group by m.id,m.name, m.model, m.unit, m.color, u.name
) intype ON intype.material_id = m.id order by linjieNumber desc
LEFT JOIN (
SELECT
di.material_id,
ifnull(sum(basic_number), 0) AS BasicOutNumber
FROM
jsh_depot_head dh
INNER 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 != '调拨'
<if test="pid != null">
and di.depot_id= ${pid}
</if>
AND ifnull(dh.delete_flag, '0') != '1' group by di.material_id
) outtype ON outtype.material_id = m.id
WHERE
1 = 1
AND ifnull(m.delete_flag, '0') != '1'
AND intype.BasicInNumber > 0
ORDER BY
(IFNULL(intype.BasicInNumber ,0) - IFNULL(outtype.BasicOutNumber ,0) - ifnull(m.safety_stock,0))
<if test="offset != null and rows != null"> <if test="offset != null and rows != null">
limit #{offset},#{rows} limit #{offset},#{rows}
</if> </if>
@@ -434,26 +395,18 @@
<select id="findStockWarningCountTotal" resultType="java.lang.Integer"> <select id="findStockWarningCountTotal" resultType="java.lang.Integer">
select count(1) from select count(1) from
jsh_material m (select m.id
LEFT JOIN ( from jsh_material m
SELECT left join jsh_material_current_stock mcs on mcs.material_id=m.id and ifnull(mcs.delete_Flag,'0') !='1'
di.material_id, left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
ifnull(sum(basic_number), 0) AS BasicInNumber left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
FROM left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
jsh_depot_head dh where 1=1
INNER JOIN jsh_depot_item di ON dh.id = di.header_id and ifnull(m.delete_flag,'0') !='1'
AND ifnull(di.delete_flag, '0') != '1' and ifnull(m.safety_stock,0) > mcs.current_number
WHERE
dh.type = '入库'
<if test="pid != null"> <if test="pid != null">
and di.depot_id= ${pid} and mcs.depot_id= ${pid}
</if> </if>
AND ifnull(dh.delete_flag, '0') != '1' group by di.material_id group by m.id,m.name, m.model, m.unit, m.color, u.name) tb
) intype ON intype.material_id = m.id
WHERE
1 = 1
AND ifnull(m.delete_Flag, '0') != '1'
AND intype.BasicInNumber > 0
</select> </select>
</mapper> </mapper>