优化
This commit is contained in:
@@ -113,21 +113,26 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
|
||||
jo8.put("1", "采购缺口");
|
||||
rows.add(jo8);
|
||||
|
||||
//汇总所有配方明细物料
|
||||
HashMap<String,Double> dtlJa_map = new HashMap<String,Double>();
|
||||
JSONArray dtlJa = WQL.getWO("statistical_report_query_01").addParam("flag", "5").process().getResultJSONArray(0);
|
||||
for (int i = 0; i < dtlJa.size(); i++) {
|
||||
JSONObject form_qty = dtlJa.getJSONObject(i);
|
||||
dtlJa_map.put(form_qty.getString("material_id"),form_qty.getDouble("qty"));
|
||||
}
|
||||
for (int i = 0; i < mater_rows.size(); i++) {
|
||||
JSONObject mater = mater_rows.getJSONObject(i);
|
||||
String material_id = mater.getString("material_id");
|
||||
//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).process().uniqueResult(0);
|
||||
|
||||
double now_ivt = 0;
|
||||
double need_qty = 0;
|
||||
if (ObjectUtil.isNotEmpty(mater_ivt)) {
|
||||
now_ivt = mater_ivt.getDoubleValue("qty");
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(form_qty)) {
|
||||
need_qty = form_qty.getDoubleValue("qty");
|
||||
if (dtlJa_map.containsKey(material_id)) {
|
||||
need_qty = dtlJa_map.get(material_id);
|
||||
}
|
||||
double canuse_num = NumberUtil.sub(now_ivt - need_qty).doubleValue();
|
||||
jo1.put(material_id, String.format("%.3f", canuse_num));
|
||||
|
||||
@@ -245,43 +245,40 @@
|
||||
|
||||
IF 输入.flag = "5"
|
||||
QUERY
|
||||
SELECT
|
||||
dtl.material_id,
|
||||
SUM(ROUND((b.qty*dtl.standard_rate*0.01),3)) AS qty
|
||||
SELECT
|
||||
FormulaDtl.material_id,
|
||||
SUM( FormulaDtl.formula_qty ) AS qty
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
material_id,
|
||||
SUM( qty ) AS qty
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
material_id,
|
||||
workorder_qty AS qty
|
||||
SELECT
|
||||
wo.workorder_id
|
||||
FROM
|
||||
pdm_bi_workorder wo
|
||||
WHERE
|
||||
wo.`status` = '40'
|
||||
AND is_delete = '0'
|
||||
OPTION 输入.begin_time <> ""
|
||||
wo.planstart_time >= 输入.begin_time
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
wo.planstart_time <= 输入.end_time
|
||||
ENDOPTION
|
||||
AND wo.is_delete = '0'
|
||||
UNION ALL
|
||||
SELECT
|
||||
workorder.workorder_id
|
||||
FROM
|
||||
pdm_bi_workorder workorder
|
||||
INNER JOIN PDM_BI_WorkTask WorkTask ON WorkTask.workorder_id = workorder.workorder_id
|
||||
WHERE
|
||||
workorder.`status` IN ( '50', '69', '97', '98' )
|
||||
AND workorder.is_delete = '0'
|
||||
AND WorkTask.STATUS <> '99'
|
||||
) a
|
||||
GROUP BY
|
||||
a.material_id
|
||||
) b
|
||||
LEFT JOIN md_pd_productbom mst ON mst.material_id = b.material_id
|
||||
LEFT JOIN md_pd_productbomdtl dtl ON mst.bom_id = dtl.bom_id
|
||||
WHERE
|
||||
LEFT JOIN PDM_BI_Formula Formula ON Formula.workorder_id = a.workorder_id
|
||||
LEFT JOIN PDM_BI_FormulaDtl FormulaDtl ON FormulaDtl.formula_id = Formula.formula_id and FormulaDtl.status<>'99'
|
||||
where
|
||||
1=1
|
||||
OPTION 输入.material_id <> ""
|
||||
dtl.material_id = 输入.material_id
|
||||
ENDOPTION
|
||||
GROUP BY
|
||||
dtl.material_id
|
||||
and Formula.is_delete='0'
|
||||
and Formula.status<>'99'
|
||||
OPTION 输入.material_id <> ""
|
||||
FormulaDtl.material_id = 输入.material_id
|
||||
ENDOPTION
|
||||
GROUP BY
|
||||
FormulaDtl.material_id
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
Reference in New Issue
Block a user