This commit is contained in:
2022-10-20 19:56:12 +08:00
parent c460827f28
commit 88e0fded15
3 changed files with 57 additions and 27 deletions

View File

@@ -115,7 +115,7 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
//1、库存现存量现有库存 - 开单领料重量
JSONObject mater_ivt = WQL.getWO("statistical_report_query_01").addParam("flag", "4").addParam("material_id", material_id).process().uniqueResult(0);
//查询开单领料重量
JSONObject form_qty = WQL.getWO("statistical_report_query_01").addParam("flag", "5").addParam("material_id", material_id).addParam("begin_time",begin_time).addParam("end_time",end_time).process().uniqueResult(0);
JSONObject form_qty = WQL.getWO("statistical_report_query_01").addParam("flag", "5").addParam("material_id", material_id).process().uniqueResult(0);
double now_ivt = 0;
double need_qty = 0;
@@ -126,15 +126,15 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
need_qty = form_qty.getDoubleValue("qty");
}
BigDecimal canuse_num = NumberUtil.sub(now_ivt - need_qty);
jo1.put(material_id, String.format("%.3f",canuse_num));
jo1.put(material_id, String.format("%.3f", canuse_num));
//2、排产需求量(未开单的工令重量+排产未生成工令日计划重量)根据bom计算需要多少原料库存重量
JSONObject nedd_mater = WQL.getWO("statistical_report_query_01").addParam("flag", "6").addParam("material_id", material_id).addParam("begin_time",begin_time).addParam("end_time",end_time).process().uniqueResult(0);
JSONObject nedd_mater = WQL.getWO("statistical_report_query_01").addParam("flag", "6").addParam("material_id", material_id).addParam("begin_time", begin_time).addParam("end_time", end_time).process().uniqueResult(0);
double bom_qty = 0;
if (ObjectUtil.isNotEmpty(nedd_mater)) {
bom_qty = nedd_mater.getDoubleValue("qty");
}
jo2.put(material_id, String.format("%.3f",bom_qty));
jo2.put(material_id, String.format("%.3f", bom_qty));
//3、待检入库量sum(此物料未确认的到货单的单据数-入库数)
JSONObject num_jo = WQL.getWO("statistical_report_query_01").addParam("flag", "7").addParam("material_id", material_id).process().uniqueResult(0);
@@ -158,13 +158,13 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
notqty = 0;
}
}
jo4.put(material_id, String.format("%.3f",noin_qty));
jo4.put(material_id, String.format("%.3f", noin_qty));
//4、合同在途订单量-到货量
jo6.put(material_id, String.format("%.3f",notqty));
jo6.put(material_id, String.format("%.3f", notqty));
//5、库/需差额量 :库存现存量-排产需求量
jo3.put(material_id, String.format("%.3f",(Double.parseDouble(canuse_num + "") - bom_qty)));
jo3.put(material_id, String.format("%.3f", (Double.parseDouble(canuse_num + "") - bom_qty)));
//7、最低储备定额物料的安全库存量下限
JSONObject safe_jo = WQLObject.getWQLObject("ST_IVT_MaterialSafeIvt").query("material_id = '" + material_id + "'").uniqueResult(0);
@@ -172,29 +172,29 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
if (ObjectUtil.isNotEmpty(safe_jo)) {
safe_qty = safe_jo.getDoubleValue("safe_ivt_down");
}
jo7.put(material_id, String.format("%.3f",safe_qty));
jo7.put(material_id, String.format("%.3f", safe_qty));
//8、采购缺口库存+待检+在途+最低储备-排产量
double buy_qty = bom_qty - (now_ivt + noin_qty + notqty + safe_qty);
jo8.put(material_id, String.format("%.3f",buy_qty));
double buy_qty = bom_qty + safe_qty - (canuse_num.doubleValue() + noin_qty + notqty);
jo8.put(material_id, String.format("%.3f", buy_qty));
//6、覆盖日期物料库存可坚持到哪一天库存现存量减每天需求量哪天<0,取前一天
for (int j = 1; j <= betweenDay; j++) {
DateTime newDate = DateUtil.offsetDay(date1, j);
//查询该物料当天的需求量
JSONObject today_qty = WQL.getWO("statistical_report_query_01").addParam("flag", "8").addParam("material_id", material_id).addParam("begin_time",newDate).process().uniqueResult(0);
JSONObject today_qty = WQL.getWO("statistical_report_query_01").addParam("flag", "8").addParam("material_id", material_id).addParam("begin_time", newDate.toString().substring(0, 10) + "%").process().uniqueResult(0);
double need_weight = 0;
if (ObjectUtil.isNotEmpty(today_qty)){
if (ObjectUtil.isNotEmpty(today_qty)) {
need_weight = today_qty.getDoubleValue("qty");
}
if (now_ivt<need_weight){
jo5.put(material_id,DateUtil.offsetDay(newDate, -1).toString().substring(0,10));
if (now_ivt < need_weight) {
jo5.put(material_id, DateUtil.offsetDay(newDate, -1).toString().substring(0, 10));
break;
}else {
} else {
now_ivt -= need_weight;
}
if (j==betweenDay){
jo5.put(material_id,end_time.substring(0,10));
if (j == betweenDay) {
jo5.put(material_id, end_time.substring(0, 10));
}
}
}
@@ -207,26 +207,27 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
public Map<String, Object> materPlanDtlQuery(Map whereJson) {
String begin_time = MapUtil.getStr(whereJson, "begin_time");
String end_time = MapUtil.getStr(whereJson, "end_time");
String org_id = MapUtil.getStr(whereJson, "org_id");
//查询日期内的排产日计划物料信息
JSONArray jsonArr = WQL.getWO("statistical_report_query_01").addParam("flag", "9").addParam("begin_time",begin_time).addParam("end_time",end_time).process().getResultJSONArray(0);
JSONArray jsonArr = WQL.getWO("statistical_report_query_01").addParam("flag", "9").addParam("begin_time", begin_time).addParam("end_time", end_time).addParam("org_id", org_id).process().getResultJSONArray(0);
JSONArray rows = new JSONArray();
for (int i = 0; i < jsonArr.size(); i++) {
JSONObject row = jsonArr.getJSONObject(i);
String material_code = row.getString("material_code");
JSONObject bom = WQLObject.getWQLObject("md_pd_productbom").query("material_id = '"+row.get("material_id")+"'").uniqueResult(0);
if (ObjectUtil.isEmpty(bom)){
throw new BadRequestException("未查询到该产品 "+material_code+" 对应BOM信息");
JSONObject bom = WQLObject.getWQLObject("md_pd_productbom").query("material_id = '" + row.get("material_id") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(bom)) {
throw new BadRequestException("未查询到该产品 " + material_code + " 对应BOM信息");
}
row.put("1",row.getString("planstart_date"));
row.put("2",row.getString("old_mark"));
row.put("3",row.getString("product_num"));
row.put("1", row.getString("planstart_date"));
row.put("2", row.getString("old_mark"));
row.put("3", row.getString("product_num"));
//查询该物料对应的bom明细
JSONArray bom_dtl = WQLObject.getWQLObject("md_pd_productbomdtl").query("bom_id = '"+bom.getString("bom_id")+"'").getResultJSONArray(0);
JSONArray bom_dtl = WQLObject.getWQLObject("md_pd_productbomdtl").query("bom_id = '" + bom.getString("bom_id") + "'").getResultJSONArray(0);
for (int j = 0; j < bom_dtl.size(); j++) {
JSONObject dtl = bom_dtl.getJSONObject(j);
double standard_rate = dtl.getDoubleValue("standard_rate");
double qty = standard_rate * row.getDoubleValue("product_weight") * 0.01;
row.put(dtl.getString("material_id"),String.format("%.3f",qty));
row.put(dtl.getString("material_id"), String.format("%.3f", qty));
}
rows.add(row);
}

View File

@@ -27,6 +27,7 @@
输入.create_mode TYPEAS s_string
输入.bill_status TYPEAS s_string
输入.material_id TYPEAS s_string
输入.org_id TYPEAS s_string
[临时表]
@@ -474,6 +475,7 @@
mps_bd_productdailyplan plan
LEFT JOIN md_me_producmaterialext ext ON ext.material_id = plan.material_id
LEFT JOIN md_me_materialbase materialbase ON materialbase.material_id = plan.material_id
LEFT JOIN sys_dept dept ON dept.`code` = plan.plan_org_code
WHERE
plan.status = '01'
OPTION 输入.begin_time <> ""
@@ -482,6 +484,9 @@
OPTION 输入.end_time <> ""
plan.planstart_date <= 输入.end_time
ENDOPTION
OPTION 输入.org_id <> ""
dept.dept_id = 输入.org_id
ENDOPTION
UNION ALL
@@ -505,6 +510,9 @@
ENDOPTION
OPTION 输入.end_time <> ""
wo.planstart_time <= 输入.end_time
ENDOPTION
OPTION 输入.org_id <> ""
wo.org_id = 输入.org_id
ENDOPTION
GROUP BY
planstart_time,wo.material_id

View File

@@ -14,6 +14,23 @@
<el-form-item label="统计日期">
<date-range-picker v-model="query.createTime" class="date-item"/>
</el-form-item>
<el-form-item label="所属组织">
<el-select
v-model="query.org_id"
clearable
size="mini"
placeholder="所属组织"
class="filter-item"
@change="crud.toQuery"
>
<el-option
v-for="item in Depts"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<rrOperation/>
</el-form>
</div>
@@ -69,6 +86,7 @@ import crudInspectionsheetmst from '@/api/wms/ql/inspectionsheetmst'
import { download } from '@/api/data'
import { downloadFile } from '@/utils'
import Date from '@/utils/datetime'
import workorder from '@/api/wms/pdm/workorder'
const start = new Date()
export default {
@@ -98,6 +116,7 @@ export default {
cols: [],
cols2: [],
dtlList: [],
Depts: [],
statusList: [],
permission: {},
rules: {}
@@ -106,7 +125,9 @@ export default {
beforeCreate() {
},
created() {
workorder.getDepts().then(res => {
this.Depts = res
})
},
methods: {
// 钩子在获取表格数据之前执行false 则代表不获取数据