优化报表,增加条码查询

This commit is contained in:
季圣华 2021-07-16 00:49:14 +08:00
parent 7e3f70f292
commit ce7a6ff343
6 changed files with 88 additions and 39 deletions

View File

@ -282,6 +282,7 @@ public class DepotItemController {
for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject();
Long mId = diEx.getMId();
item.put("barCode", diEx.getBarCode());
item.put("materialName", diEx.getMName());
item.put("materialModel", diEx.getMModel());
item.put("materialStandard", diEx.getMStandard());
@ -339,24 +340,25 @@ public class DepotItemController {
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
timeB, null, null);
//存放数据json数组
String[] names = {"名称", "规格", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"};
String[] names = {"条码", "名称", "规格", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"};
String title = "库存报表";
List<String[]> objects = new ArrayList<String[]>();
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
Long mId = diEx.getMId();
String[] objs = new String[10];
objs[0] = diEx.getMName();
objs[1] = diEx.getMStandard();
objs[2] = diEx.getMModel();
objs[3] = diEx.getMaterialUnit();
objs[4] = diEx.getPurchaseDecimal().toString();
objs[5] = depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId).toString();
objs[6] = depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
objs[7] = depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
String[] objs = new String[11];
objs[0] = diEx.getBarCode();
objs[1] = diEx.getMName();
objs[2] = diEx.getMStandard();
objs[3] = diEx.getMModel();
objs[4] = diEx.getMaterialUnit();
objs[5] = diEx.getPurchaseDecimal().toString();
objs[6] = depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId).toString();
objs[7] = depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
objs[8] = depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,timeB,tenantId);
objs[8] = thisSum.toString();
objs[9] = thisSum.multiply(diEx.getPurchaseDecimal()).toString();
objs[9] = thisSum.toString();
objs[10] = thisSum.multiply(diEx.getPurchaseDecimal()).toString();
objects.add(objs);
}
}
@ -445,6 +447,7 @@ public class DepotItemController {
BigDecimal OutSum = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), monthTime, "number");
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), monthTime, "price");
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), monthTime, "price");
item.put("barCode", diEx.getBarCode());
item.put("materialName", diEx.getMName());
item.put("materialModel", diEx.getMModel());
item.put("materialStandard", diEx.getMStandard());
@ -512,6 +515,7 @@ public class DepotItemController {
BigDecimal InSumRetailPrice = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), monthTime,"price");
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), monthTime,"price");
BigDecimal OutInSumPrice = (OutSumRetailPrice.add(OutSumPrice)).subtract(InSumRetailPrice.add(InSumPrice));
item.put("barCode", diEx.getBarCode());
item.put("materialName", diEx.getMName());
item.put("materialModel", diEx.getMModel());
item.put("materialStandard", diEx.getMStandard());
@ -618,7 +622,7 @@ public class DepotItemController {
List<DepotItemStockWarningCount> dataList = depotItemService.findStockWarningCount(null, null, materialParam, depotId);
//存放数据json数组
Long pid = depotId;
String[] names = {"名称", "规格", "型号", "扩展信息", "单位", "安全存量", "当前库存", "建议入库量"};
String[] names = {"条码", "名称", "规格", "型号", "扩展信息", "单位", "安全存量", "当前库存", "建议入库量"};
String title = "库存预警报表";
List<String[]> objects = new ArrayList<String[]>();
if (null != dataList) {
@ -630,15 +634,16 @@ public class DepotItemController {
diVI.setMOtherField3(diEx.getMOtherField3());
String materialOther = getOtherInfo(mpArr, diVI);
String unitName = getUName(diEx.getMaterialUnit(), diEx.getUnitName());
String[] objs = new String[8];
objs[0] = diEx.getMName();
objs[1] = diEx.getMStandard();
objs[2] = diEx.getMModel();
objs[3] = materialOther;
objs[4] = unitName;
objs[5] = diEx.getSafetystock() == null ? "0" : diEx.getSafetystock().toString();
objs[6] = diEx.getCurrentNumber() == null ? "0" : diEx.getCurrentNumber().toString();
objs[7] = diEx.getLinjieNumber() == null ? "0" : diEx.getLinjieNumber().toString();
String[] objs = new String[9];
objs[0] = diEx.getBarCode();
objs[1] = diEx.getMName();
objs[2] = diEx.getMStandard();
objs[3] = diEx.getMModel();
objs[4] = materialOther;
objs[5] = unitName;
objs[6] = diEx.getSafetystock() == null ? "0" : diEx.getSafetystock().toString();
objs[7] = diEx.getCurrentNumber() == null ? "0" : diEx.getCurrentNumber().toString();
objs[8] = diEx.getLinjieNumber() == null ? "0" : diEx.getLinjieNumber().toString();
objects.add(objs);
}
}

View File

@ -8,6 +8,8 @@ public class DepotHeadVo4InDetail {
private String Number;
private String barCode;
private String MName;
private String Model;
@ -38,6 +40,14 @@ public class DepotHeadVo4InDetail {
Number = number;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public String getMName() {
return MName;
}

View File

@ -7,6 +7,8 @@ public class DepotHeadVo4InOutMCount {
private Long MaterialId;
private String barCode;
private String mName;
private String Model;
@ -29,6 +31,14 @@ public class DepotHeadVo4InOutMCount {
MaterialId = materialId;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public String getmName() {
return mName;
}

View File

@ -7,6 +7,8 @@ public class DepotItemStockWarningCount {
private Long MId;
private String barCode;
private String MName;
private String MModel;
@ -43,6 +45,14 @@ public class DepotItemStockWarningCount {
this.MId = MId;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public String getMName() {
return MName;
}

View File

@ -10,6 +10,7 @@
<resultMap id="ResultWithInfoExMap" type="com.jsh.erp.datasource.vo.DepotHeadVo4InDetail">
<result column="Number" jdbcType="VARCHAR" property="Number" />
<result column="bar_code" jdbcType="VARCHAR" property="barCode" />
<result column="MName" jdbcType="VARCHAR" property="MName" />
<result column="Model" jdbcType="VARCHAR" property="Model" />
<result column="standard" jdbcType="VARCHAR" property="standard" />
@ -24,6 +25,7 @@
<resultMap id="ResultInOutMaterialCount" type="com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount">
<result column="MaterialId" jdbcType="BIGINT" property="MaterialId" />
<result column="bar_code" jdbcType="VARCHAR" property="barCode" />
<result column="mName" jdbcType="VARCHAR" property="mName" />
<result column="Model" jdbcType="VARCHAR" property="Model" />
<result column="standard" jdbcType="VARCHAR" property="standard" />
@ -170,11 +172,12 @@
</select>
<select id="findByAll" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
select dh.number,m.`name` MName,m.model,m.standard,di.unit_price,di.oper_number,di.all_price,s.supplier SName,d.dName DName,
select dh.number,me.bar_code, m.`name` MName,m.model,m.standard,di.unit_price,di.oper_number,di.all_price,s.supplier SName,d.dName DName,
date_format(dh.oper_time, '%Y-%m-%d') OperTime, concat(dh.sub_type,dh.type) as NewType
from jsh_depot_head dh
inner join jsh_depot_item di on di.header_id=dh.id and ifnull(di.delete_flag,'0') !='1'
inner 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.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
inner join jsh_supplier s on s.id=dh.organ_id and ifnull(s.delete_Flag,'0') !='1'
inner join (select id,name as dName,delete_Flag from jsh_depot ) d on d.id=di.depot_id and ifnull(d.delete_Flag,'0') !='1'
where dh.oper_time >=#{beginTime} and dh.oper_time &lt;=#{endTime}
@ -189,7 +192,7 @@
</if>
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
and ifnull(dh.delete_flag,'0') !='1'
ORDER BY oper_time DESC,number desc
@ -203,6 +206,7 @@
from jsh_depot_head dh
inner join jsh_depot_item di on di.header_id=dh.id and ifnull(di.delete_flag,'0') !='1'
inner 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.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
inner join jsh_supplier s on s.id=dh.organ_id and ifnull(s.delete_Flag,'0') !='1'
inner join (select id,name as dName,delete_Flag from jsh_depot) d on d.id=di.depot_id and ifnull(d.delete_Flag,'0') !='1'
where dh.oper_time >=#{beginTime} and dh.oper_time &lt;=#{endTime}
@ -217,14 +221,14 @@
</if>
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
and ifnull(dh.delete_flag,'0') !='1'
ORDER BY oper_time DESC,number desc
</select>
<select id="findInOutMaterialCount" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultInOutMaterialCount">
select di.material_id, m.mName,m.Model,m.standard,m.categoryName,
select di.material_id, m.bar_code, m.mName,m.Model,m.standard,m.categoryName,
(select sum(jdi.basic_number) numSum from jsh_depot_head jdh
INNER JOIN jsh_depot_item jdi on jdh.id=jdi.header_id and ifnull(jdi.delete_flag,'0') !='1'
where jdi.material_id=di.material_id
@ -251,10 +255,11 @@
) priceSum
from jsh_depot_head dh
INNER JOIN jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
INNER JOIN (SELECT jsh_material.id,jsh_material.name mName, Model, standard, jsh_material_category.`Name` categoryName
INNER JOIN (SELECT jsh_material.id,jsh_material.name mName, me.bar_code, Model, standard, jsh_material_category.`Name` categoryName
from jsh_material
left join jsh_material_extend me on me.material_id=jsh_material.id and ifnull(me.delete_Flag,'0') !='1'
LEFT JOIN jsh_material_category on jsh_material.category_id=jsh_material_category.Id and ifnull(jsh_material_category.delete_flag,'0') !='1'
where ifnull(jsh_material.delete_Flag,'0') !='1'
where me.default_flag=1 and ifnull(jsh_material.delete_Flag,'0') !='1'
) m
on m.Id=di.material_id where dh.type=#{type} and dh.oper_time >=#{beginTime} and dh.oper_time &lt;=#{endTime}
<if test="oId != null">
@ -265,7 +270,7 @@
</if>
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (m.mName like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
and (m.bar_code like #{bindKey} or m.mName like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
and ifnull(dh.delete_flag,'0') !='1'
GROUP BY di.material_id,m.mName,m.Model,m.standard,m.categoryName
@ -276,12 +281,13 @@
<select id="findInOutMaterialCountTotal" resultType="java.lang.Integer">
select count(1) from
(select di.material_id, m.mName,m.Model,m.standard,m.categoryName from jsh_depot_head dh
(select di.material_id, m.mName,m.bar_code,m.Model,m.standard,m.categoryName from jsh_depot_head dh
INNER JOIN jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
INNER JOIN (SELECT jsh_material.id,jsh_material.name mName, Model,standard,jsh_material_category.`Name` categoryName
INNER JOIN (SELECT jsh_material.id,jsh_material.name mName, me.bar_code, Model,standard,jsh_material_category.`Name` categoryName
from jsh_material
left join jsh_material_extend me on me.material_id=jsh_material.id and ifnull(me.delete_Flag,'0') !='1'
LEFT JOIN jsh_material_category on jsh_material.category_id=jsh_material_category.Id and ifnull(jsh_material_category.delete_flag,'0') !='1'
where ifnull(jsh_material.delete_Flag,'0') !='1'
where me.default_flag=1 and ifnull(jsh_material.delete_Flag,'0') !='1'
) m on m.Id=di.material_id where dh.type=#{type} and dh.oper_time >=#{beginTime} and dh.oper_time &lt;=#{endTime}
<if test="oId != null">
and dh.organ_id = #{oId}
@ -291,7 +297,7 @@
</if>
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (m.mName like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
and (m.bar_code like #{bindKey} or m.mName like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
and ifnull(dh.delete_flag,'0') !='1'
GROUP BY di.material_id,m.mName,m.Model,m.standard,m.categoryName) a

View File

@ -37,6 +37,7 @@
<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" />
<result column="bar_code" jdbcType="VARCHAR" property="barCode" />
<result column="MName" jdbcType="VARCHAR" property="MName" />
<result column="MMfrs" jdbcType="VARCHAR" property="MMfrs" />
<result column="MModel" jdbcType="VARCHAR" property="MModel" />
@ -52,6 +53,7 @@
<resultMap id="ResultStockWarningCount" type="com.jsh.erp.datasource.vo.DepotItemStockWarningCount">
<result column="MId" jdbcType="VARCHAR" property="MId" />
<result column="bar_code" jdbcType="VARCHAR" property="barCode" />
<result column="MName" jdbcType="VARCHAR" property="MName" />
<result column="MMfrs" jdbcType="VARCHAR" property="MMfrs" />
<result column="MModel" jdbcType="VARCHAR" property="MModel" />
@ -168,7 +170,7 @@
</select>
<select id="findByAll" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultByMaterial">
select m.id MId, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,
select m.id MId, me.bar_code, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
m.unit MaterialUnit, m.color MColor, u.name unit_name,
(select purchase_decimal from jsh_material_extend me
@ -176,12 +178,13 @@
purchase_decimal
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
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
<if test="endTime != null">
and dh.oper_time &lt;= #{endTime}
@ -198,11 +201,12 @@
select count(1) from (select m.id
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
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
<if test="endTime != null">
and dh.oper_time &lt;= #{endTime}
@ -373,21 +377,23 @@
</select>
<select id="findStockWarningCount" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultStockWarningCount">
select m.id MId, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,m.color MColor,
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(m.safety_stock,0) safetystock,
(ifnull(m.safety_stock,0)-mcs.current_number) linjieNumber
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_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'
where 1=1
and me.default_flag=1
and ifnull(m.delete_flag,'0') !='1'
and ifnull(m.safety_stock,0) > mcs.current_number
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
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}
@ -403,16 +409,18 @@
select count(1) from
(select m.id
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_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'
where 1=1
and me.default_flag=1
and ifnull(m.delete_flag,'0') !='1'
and ifnull(m.safety_stock,0) > mcs.current_number
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
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}