This commit is contained in:
2022-07-29 17:26:07 +08:00
4 changed files with 311 additions and 136 deletions

View File

@@ -2,6 +2,7 @@ package org.nl.wms.ext.bigScreen.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
@@ -17,14 +18,10 @@ import java.util.Map;
@RequiredArgsConstructor
@Slf4j
public class ProductServiceImpl implements ProductService {
private String now = "2022-07-26 23:59:59";
private String today = "2022-07-26";
//一个月的开始时间
DateTime beginMonthDateTime = DateUtil.offsetDay(DateUtil.parse(now), 30);
//一天的开始时间
DateTime beginTimeOfDay = DateUtil.beginOfDay(DateUtil.parse(now));
//一天的结束时间
DateTime endTimeOfDay = DateUtil.endOfDay(DateUtil.parseDate(now));
private String now = DateUtil.now();
private String today = DateUtil.today();
//一个月的开始日期
private String beginOfMonth = DateUtil.formatTime(DateUtil.beginOfMonth(DateUtil.parseDate(today)));
@Override
public Map<String, Object> planReached(Map<String, String> param) {
@@ -32,12 +29,33 @@ public class ProductServiceImpl implements ProductService {
//01-弯头工段、02-综合工段、03-成品工段
Map map = new HashMap();
map.put("flag", "1");
map.put("begin_time", beginTimeOfDay);
map.put("end_time", endTimeOfDay);
JSONArray dayResult = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().getResultJSONArray(0);
map.put("produce_date", today);
map.put("worksection_type_scode","01");
JSONObject jo1 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0);
map.put("worksection_type_scode","02");
JSONObject jo2 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0);
map.put("worksection_type_scode","03");
JSONObject jo3 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0);
JSONObject dayResult = new JSONObject();
dayResult.put("jo1",jo1);
dayResult.put("jo2",jo2);
dayResult.put("jo3",jo3);
//计算一个月的计划达成
map.put("begin_time", beginMonthDateTime);
JSONArray monthResult = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().getResultJSONArray(0);
JSONObject monthResult = new JSONObject();
map.put("flag", "14");
map.put("end_produce_date", today);
map.put("begin_produce_date", beginOfMonth);
map.put("worksection_type_scode","01");
JSONObject joo1 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0);
map.put("worksection_type_scode","02");
JSONObject joo2 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0);
map.put("worksection_type_scode","03");
JSONObject joo3 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0);
monthResult.put("joo1",joo1);
monthResult.put("joo2",joo2);
monthResult.put("joo3",joo3);
JSONObject returnjo = new JSONObject();
returnjo.put("code", "1");
returnjo.put("desc", "操作成功!");
@@ -51,8 +69,7 @@ public class ProductServiceImpl implements ProductService {
//今日排产生产进度跟踪
Map map = new HashMap();
map.put("flag", "2");
map.put("begin_time", beginTimeOfDay);
map.put("end_time", endTimeOfDay);
map.put("produce_date", today);
JSONArray result = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().getResultJSONArray(0);
JSONObject returnjo = new JSONObject();
returnjo.put("code", "1");
@@ -67,8 +84,7 @@ public class ProductServiceImpl implements ProductService {
Map map = new HashMap();
// map.put("flag", "3");
map.put("flag", "7");
map.put("begin_time", beginTimeOfDay);
map.put("end_time", endTimeOfDay);
map.put("produce_date", today);
//统计产量方式一: 1 计算工单物料 2 计算每个物料清洗前一个工序 3拿着工序+物料 关联工单表 统计总数
//1激光下料——推弯——清洗
//2旋压-清洗
@@ -83,7 +99,7 @@ public class ProductServiceImpl implements ProductService {
map.put("flag", "4");
int sum_qty = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0).getIntValue("count");
//统计延时工单
map.put("now_time", now);
map.put("product_date",today);
map.put("flag", "5");
int delayed_qty = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0).getIntValue("count");
@@ -105,20 +121,28 @@ public class ProductServiceImpl implements ProductService {
//获取一周的日期
JSONArray dataArr = new JSONArray();
JSONArray results = new JSONArray();
for (int i = 1; i < 9; i++) {
for (int i = 0; i < 7; i++) {
DateTime dateTime = DateUtil.offsetDay(DateUtil.parse(now), -i);
dataArr.add(dateTime.toString().substring(0, 10));
}
for (int i = 0; i < dataArr.size(); i++) {
JSONObject jo = new JSONObject();
JSONObject datejo = dataArr.getJSONObject(i);
String date = datejo.get(i).toString();
jo.put("date", date);
String date = dataArr.get(( dataArr.size()-i-1)).toString();
//01-弯头工段、02-综合工段、03-成品工段
Map map = new HashMap();
map.put("flag", "8");
map.put("flag", "15");
map.put("produce_date", date);
JSONArray arr = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().getResultJSONArray(0);
jo.put("data", arr);
map.put("worksection_type_scode", "01");
int elbow_qty = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0).getIntValue("real_qty");
jo.put("elbow_qty", elbow_qty);
map.put("worksection_type_scode", "02");
int comprehensive_qty = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0).getIntValue("real_qty");
jo.put("comprehensive_qty", comprehensive_qty);
map.put("worksection_type_scode", "03");
int end_product_qty = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0).getIntValue("real_qty");
jo.put("end_product_qty", end_product_qty);
jo.put("date",date.substring(5,date.length()));
results.add(jo);
}
JSONObject returnjo = new JSONObject();
@@ -147,20 +171,24 @@ public class ProductServiceImpl implements ProductService {
//30天产量走势
JSONArray dataArr = new JSONArray();
JSONArray results = new JSONArray();
for (int i = 1; i < 31; i++) {
for (int i = 0; i < 30; i++) {
DateTime dateTime = DateUtil.offsetDay(DateUtil.parse(now), -i);
dataArr.add(dateTime.toString().substring(0, 10));
}
for (int i = 0; i < dataArr.size(); i++) {
JSONObject jo = new JSONObject();
JSONObject datejo = dataArr.getJSONObject(i);
String date = datejo.get(i).toString();
jo.put("date", date);
String date = dataArr.get(dataArr.size()-i-1).toString();
Map map = new HashMap();
map.put("flag", "9");
map.put("produce_date", date);
int real_qty = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0).getIntValue("real_qty");
int real_qty = 0;
JSONObject jsonObject = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonObject)) {
real_qty = jsonObject.getIntValue("real_qty");
}
jo.put("real_qty", real_qty);
jo.put("date", date.substring(5,date.length()));
results.add(jo);
}
JSONObject returnjo = new JSONObject();
@@ -189,6 +217,8 @@ public class ProductServiceImpl implements ProductService {
Map map = new HashMap();
map.put("flag", "12");
map.put("produce_date", today);
map.put("end_produce_date", today);
map.put("begin_produce_date", beginOfMonth);
JSONArray results = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().getResultJSONArray(0);
//计算所有的产能
map.put("flag", "13");
@@ -204,6 +234,7 @@ public class ProductServiceImpl implements ProductService {
if (count_num_flag < sum_count) {
JSONObject joo = new JSONObject();
joo.put("material_name", "其他");
joo.put("material_spec", "其他");
joo.put("real_qty", sum_count - count_num_flag);
results.add(joo);
}

View File

@@ -19,6 +19,9 @@
输入.end_time TYPEAS s_string
输入.now_time TYPEAS s_string
输入.produce_date TYPEAS s_string
输入.end_produce_date TYPEAS s_string
输入.begin_produce_date TYPEAS s_string
输入.worksection_type_scode TYPEAS s_string
@@ -47,7 +50,7 @@
IF 输入.flag = "1"
QUERY
SELECT
workprocedure.worksection_type_scode,
sum( shiftorder.real_qty ) AS real_qty,
sum( shiftorder.plan_qty ) AS plan_qty ,
convert(sum( shiftorder.real_qty )/sum( shiftorder.plan_qty ),DECIMAL(10,2))*100 as finish_rate
@@ -56,18 +59,15 @@
LEFT JOIN pdm_bi_workprocedure workprocedure ON shiftorder.workprocedure_id = workprocedure.workprocedure_id
LEFT JOIN sys_dict_detail sys ON sys.VALUE= workprocedure.worksection_type_scode AND sys.dict_id = '87'
where
1=1
shiftorder.is_delete='0'
OPTION 输入.worksection_type_scode <> ""
workprocedure.worksection_type_scode = 输入.worksection_type_scode
ENDOPTION
OPTION 输入.begin_time <> ""
shiftorder.planproduceend_date >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
shiftorder.planproduceend_date <= 输入.end_time
ENDOPTION
GROUP BY
worksection_type_scode
OPTION 输入.produce_date <> ""
shiftorder.produce_date = 输入.produce_date
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
@@ -79,16 +79,13 @@
shiftorder.plan_qty,
shiftorder.real_qty,
(shiftorder.plan_qty - shiftorder.real_qty) AS gap_qty,
CONVERT ( ( shiftorder.real_qty / shiftorder.plan_qty ), DECIMAL ( 10, 2 ) ) * 100 AS finish_rate
CONVERT ( ( shiftorder.real_qty / shiftorder.plan_qty ), DECIMAL ( 10, 3 ) ) * 100 AS finish_rate
FROM
mps_bd_produceshiftorder shiftorder
where
1=1
OPTION 输入.begin_time <> ""
shiftorder.planproduceend_date >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
shiftorder.planproduceend_date <= 输入.end_time
shiftorder.is_delete='0'
OPTION 输入.produce_date <> ""
shiftorder.produce_date = 输入.produce_date
ENDOPTION
ENDSELECT
ENDQUERY
@@ -101,7 +98,7 @@ IF 输入.flag = "3"
SELECT
sum( shiftorder.real_qty ) AS real_qty,
sum( shiftorder.plan_qty ) AS plan_qty,
CONVERT ( sum( shiftorder.real_qty ) / sum( shiftorder.plan_qty ), DECIMAL ( 10, 2 ) ) * 100 AS finish_rate
CONVERT ( sum( shiftorder.real_qty ) / sum( shiftorder.plan_qty ), DECIMAL ( 10, 3 ) ) * 100 AS finish_rate
FROM
mps_bd_produceshiftorder shiftorder
RIGHT JOIN (
@@ -118,12 +115,9 @@ IF 输入.flag = "3"
AND a.workprocedure_id = shiftorder.workprocedure_id
where
1=1
OPTION 输入.begin_time <> ""
shiftorder.planproduceend_date >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
shiftorder.planproduceend_date <= 输入.end_time
ENDOPTION
OPTION 输入.produce_date <> ""
shiftorder.produce_date = 输入.produce_date
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
@@ -135,13 +129,10 @@ ENDIF
FROM
mps_bd_produceshiftorder shiftorder
where
1=1
OPTION 输入.begin_time <> ""
shiftorder.planproduceend_date >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
shiftorder.planproduceend_date <= 输入.end_time
ENDOPTION
shiftorder.is_delete='0'
OPTION 输入.produce_date <> ""
shiftorder.produce_date = 输入.produce_date
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
@@ -154,12 +145,9 @@ ENDIF
mps_bd_produceshiftorder shiftorder
where
shiftorder.realproduceend_date > shiftorder.planproduceend_date
OPTION 输入.begin_time <> ""
shiftorder.planproduceend_date >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
shiftorder.planproduceend_date <= 输入.end_time
ENDOPTION
OPTION 输入.produce_date <> ""
shiftorder.produce_date = 输入.produce_date
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
@@ -170,18 +158,16 @@ ENDIF
SELECT
sum( real_qty ) AS real_qty,
sum( plan_qty ) AS plan_qty,
CONVERT ( sum( shiftorder.real_qty ) / sum( shiftorder.plan_qty ), DECIMAL ( 10, 2 ) ) * 100 AS finish_rate
CONVERT ( sum( shiftorder.real_qty ) / sum( shiftorder.plan_qty ), DECIMAL ( 10, 3 ) ) * 100 AS finish_rate
FROM
mps_bd_produceshiftorder shiftorder
LEFT JOIN pdm_bi_workprocedure workprocedure ON workprocedure.workprocedure_id = shiftorder.workprocedure_id
WHERE
workprocedure.workprocedure_code IN ( '07', '06', '02' )
OPTION 输入.begin_time <> ""
shiftorder.planproduceend_date >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
shiftorder.planproduceend_date <= 输入.end_time
ENDOPTION
shiftorder.is_delete='0'
and workprocedure.workprocedure_code IN ( '07', '06', '02' )
OPTION 输入.produce_date <> ""
shiftorder.produce_date = 输入.produce_date
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
@@ -193,17 +179,18 @@ IF 输入.flag = "8"
workprocedure.worksection_type_scode,
sum( real_qty ) AS real_qty,
sum( plan_qty ) AS plan_qty,
CONVERT ( sum( shiftorder.real_qty ) / sum( shiftorder.plan_qty ), DECIMAL ( 10, 2 ) ) * 100 AS finish_rate
shiftorder.produce_date as date,
CONVERT ( sum( shiftorder.real_qty ) / sum( shiftorder.plan_qty ), DECIMAL ( 10, 3 ) ) * 100 AS finish_rate
FROM
mps_bd_produceshiftorder shiftorder
LEFT JOIN pdm_bi_workprocedure workprocedure ON shiftorder.workprocedure_id = workprocedure.workprocedure_id
LEFT JOIN sys_dict_detail sys ON sys.VALUE= workprocedure.worksection_type_scode AND sys.dict_id = '87'
WHERE
workprocedure.workprocedure_code IN ( '07', '06', '02' )
shiftorder.is_delete='0'
OPTION 输入.produce_date <> ""
shiftorder.produce_date >= 输入.produce_date
shiftorder.produce_date = 输入.produce_date
ENDOPTION
GROUP BY worksection_type_scode
GROUP BY worksection_type_scode,shiftorder.produce_date
ENDSELECT
ENDQUERY
ENDIF
@@ -217,9 +204,10 @@ IF 输入.flag = "9"
LEFT JOIN pdm_bi_workprocedure workprocedure ON shiftorder.workprocedure_id = workprocedure.workprocedure_id
LEFT JOIN sys_dict_detail sys ON sys.VALUE= workprocedure.worksection_type_scode AND sys.dict_id = '87'
WHERE
workprocedure.workprocedure_code IN ( '07', '06', '02' )
shiftorder.is_delete='0'
and workprocedure.workprocedure_code IN ( '07', '06', '02' )
OPTION 输入.produce_date <> ""
shiftorder.produce_date >= 输入.produce_date
shiftorder.produce_date = 输入.produce_date
ENDOPTION
GROUP BY worksection_type_scode
ENDSELECT
@@ -232,6 +220,7 @@ IF 输入.flag = "10"
shiftorder.material_id,
material.material_code,
material.material_name,
material.material_spec,
sum( real_qty ) AS real_qty
FROM
mps_bd_produceshiftorder shiftorder
@@ -239,14 +228,16 @@ IF 输入.flag = "10"
LEFT JOIN sys_dict_detail sys ON sys.VALUE= workprocedure.worksection_type_scode AND sys.dict_id = '87'
left join md_me_materialbase material on material.material_id =shiftorder.material_id
WHERE
workprocedure.workprocedure_code IN ( '07', '06', '02' )
shiftorder.is_delete='0'
and workprocedure.workprocedure_code IN ( '07', '06', '02' )
OPTION 输入.produce_date <> ""
shiftorder.produce_date >= 输入.produce_date
shiftorder.produce_date = 输入.produce_date
ENDOPTION
GROUP BY
shiftorder.material_id,
material.material_code,
material.material_name
material.material_name,
material.material_spec
ORDER BY real_qty
LIMIT 0,10
ENDSELECT
@@ -265,17 +256,18 @@ IF 输入.flag = "11"
shiftorder. real_qty,
shiftorder.plan_qty,
shiftorder.plan_qty -shiftorder. real_qty as gap_qty,
curdate() as date
shiftorder.produce_date as date
FROM
mps_bd_produceshiftorder shiftorder
LEFT JOIN pdm_bi_workprocedure workprocedure ON shiftorder.workprocedure_id = workprocedure.workprocedure_id
LEFT JOIN sys_dict_detail sys ON sys.VALUE= workprocedure.worksection_type_scode AND sys.dict_id = '87'
left join md_me_materialbase material on material.material_id =shiftorder.material_id
WHERE
workprocedure.workprocedure_code IN ( '07', '06', '02' )
shiftorder.is_delete='0'
and workprocedure.workprocedure_code IN ( '07', '06', '02' )
and shiftorder. real_qty < shiftorder.plan_qty
OPTION 输入.produce_date <> ""
shiftorder.produce_date >= 输入.produce_date
shiftorder.produce_date = 输入.produce_date
ENDOPTION
ENDSELECT
ENDQUERY
@@ -288,6 +280,7 @@ IF 输入.flag = "12"
shiftorder.material_id,
material.material_code,
material.material_name,
material.material_spec,
sum( real_qty ) AS real_qty
FROM
mps_bd_produceshiftorder shiftorder
@@ -295,13 +288,18 @@ IF 输入.flag = "12"
LEFT JOIN sys_dict_detail sys ON sys.VALUE= workprocedure.worksection_type_scode AND sys.dict_id = '87'
left join md_me_materialbase material on material.material_id =shiftorder.material_id
WHERE
workprocedure.workprocedure_code IN ( '07', '06', '02' )
OPTION 输入.produce_date <> ""
shiftorder.produce_date >= 输入.produce_date
ENDOPTION
shiftorder.is_delete='0'
and workprocedure.workprocedure_code IN ( '07', '06', '02' )
OPTION 输入.end_produce_date <> ""
shiftorder.produce_date <= 输入.end_produce_date
ENDOPTION
OPTION 输入.begin_produce_date <> ""
shiftorder.produce_date >= 输入.begin_produce_date
ENDOPTION
GROUP BY
shiftorder.material_id,
material.material_code,
material.material_spec,
material.material_name
ORDER BY real_qty
LIMIT 0,9
@@ -319,11 +317,67 @@ IF 输入.flag = "13"
LEFT JOIN sys_dict_detail sys ON sys.VALUE= workprocedure.worksection_type_scode AND sys.dict_id = '87'
left join md_me_materialbase material on material.material_id =shiftorder.material_id
WHERE
workprocedure.workprocedure_code IN ( '07', '06', '02' )
OPTION 输入.produce_date <> ""
shiftorder.produce_date >= 输入.produce_date
shiftorder.is_delete='0'
and workprocedure.workprocedure_code IN ( '07', '06', '02' )
OPTION 输入.end_produce_date <> ""
shiftorder.produce_date <= 输入.end_produce_date
ENDOPTION
OPTION 输入.begin_produce_date <> ""
shiftorder.produce_date >= 输入.begin_produce_date
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
ENDIF
IF 输入.flag = "14"
QUERY
SELECT
sum( shiftorder.real_qty ) AS real_qty,
sum( shiftorder.plan_qty ) AS plan_qty ,
convert(sum( shiftorder.real_qty )/sum( shiftorder.plan_qty ),DECIMAL(10,2))*100 as finish_rate
FROM
mps_bd_produceshiftorder shiftorder
LEFT JOIN pdm_bi_workprocedure workprocedure ON shiftorder.workprocedure_id = workprocedure.workprocedure_id
LEFT JOIN sys_dict_detail sys ON sys.VALUE= workprocedure.worksection_type_scode AND sys.dict_id = '87'
where
shiftorder.is_delete='0'
OPTION 输入.worksection_type_scode <> ""
workprocedure.worksection_type_scode = 输入.worksection_type_scode
ENDOPTION
OPTION 输入.end_produce_date <> ""
shiftorder.produce_date <= 输入.end_produce_date
ENDOPTION
OPTION 输入.begin_produce_date <> ""
shiftorder.produce_date >= 输入.begin_produce_date
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "15"
QUERY
SELECT
sum( real_qty ) AS real_qty,
sum( plan_qty ) AS plan_qty,
CONVERT ( sum( shiftorder.real_qty ) / sum( shiftorder.plan_qty ), DECIMAL ( 10, 3 ) ) * 100 AS finish_rate
FROM
mps_bd_produceshiftorder shiftorder
LEFT JOIN pdm_bi_workprocedure workprocedure ON shiftorder.workprocedure_id = workprocedure.workprocedure_id
LEFT JOIN sys_dict_detail sys ON sys.VALUE= workprocedure.worksection_type_scode AND sys.dict_id = '87'
WHERE
shiftorder.is_delete='0'
OPTION 输入.produce_date <> ""
shiftorder.produce_date = 输入.produce_date
ENDOPTION
OPTION 输入.worksection_type_scode <> ""
workprocedure.worksection_type_scode = 输入.worksection_type_scode
ENDOPTION
OPTION 输入.produce_date <> ""
shiftorder.produce_date = 输入.produce_date
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF