代码更新

This commit is contained in:
2022-09-06 18:23:48 +08:00
parent e44ff3bc67
commit 362ba7e368
5 changed files with 377 additions and 151 deletions

View File

@@ -35,10 +35,4 @@ public class StifleQueryController {
return new ResponseEntity<>(stifleQueryService.queryAll(whereJson, page), HttpStatus.OK);
}
@GetMapping("/getHeader")
@Log("获取表头")
@ApiOperation("获取表头")
public ResponseEntity<Object> getHeader() {
return new ResponseEntity<>(stifleQueryService.getHeader(), HttpStatus.OK);
}
}

View File

@@ -20,8 +20,4 @@ public interface StifleQueryService {
*/
Map<String, Object> queryAll(Map whereJson, Pageable page);
/**
* 获取表头
*/
JSONArray getHeader();
}

View File

@@ -1,6 +1,7 @@
package org.nl.wms.statistics.service.impl;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
@@ -16,6 +17,7 @@ import org.nl.wql.util.WqlUtil;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
@@ -30,107 +32,237 @@ public class StifleQueryServiceImpl implements StifleQueryService {
map.put("flag", "1");
map.put("begin_time", MapUtil.getStr(whereJson,"begin_time"));
map.put("end_time", MapUtil.getStr(whereJson,"end_time"));
map.put("inspection_code", MapUtil.getStr(whereJson,"inspection_code"));
map.put("pcsn", MapUtil.getStr(whereJson,"pcsn"));
map.put("other_device_no", MapUtil.getStr(whereJson,"other_device_no"));
map.put("bill_status", MapUtil.getStr(whereJson,"bill_status"));
if (!StrUtil.isEmpty(material_code)) {
//处理转义字符
if (material_code.contains("\\")) material_code = material_code.replace("\\", "\\\\\\");
map.put("material_code", "%" + material_code + "%");
}
WQLObject workTab = WQLObject.getWQLObject("QL_TEST_WorkProcedureMst"); // 工序质检单主表
WQLObject stanTab = WQLObject.getWQLObject("QL_TEST_InspectionSchemeDtlProductStandard"); // 产品检验方案标准表
JSONObject json = WQL.getWO("stifle_query_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "mst.input_time desc");
JSONArray contentArr = json.getJSONArray("content");
JSONArray jsonResultArr = new JSONArray();
json.put("content",jsonResultArr);
return json;
}
/*
* 1.根据物料批次分组查询 工序是压团制粒的工序
* 2.根据分组后的物料批次查出所有此物料批次的喷雾工序质检单
* 3.松比:根据桶序号一一找出对应的值
* 4.流动性:根据桶序号一一找出对应的值
* 5.筛分:抽一桶?
*/
JSONObject result = WQL.getWO("stifle_query_01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "biz_date desc");
JSONArray contentArr = result.getJSONArray("content");
@Override
public JSONArray getHeader() {
JSONArray jsonResultArr = new JSONArray();
JSONObject jsonResult1 = new JSONObject();
jsonResult1.put("prop", "1");
jsonResult1.put("label", "日期");
JSONObject jsonResult2 = new JSONObject();
jsonResult2.put("prop", "2");
jsonResult2.put("label", "物料编码");
JSONObject jsonResult3 = new JSONObject();
jsonResult3.put("prop", "3");
jsonResult3.put("label", "批次");
JSONObject jsonResult4 = new JSONObject();
jsonResult4.put("prop", "4");
jsonResult4.put("label", "1");
JSONObject jsonResult5 = new JSONObject();
jsonResult5.put("prop", "5");
jsonResult5.put("label", "3");
JSONObject jsonResult6 = new JSONObject();
jsonResult6.put("prop", "6");
jsonResult6.put("label", "5");
JSONObject jsonResult7 = new JSONObject();
jsonResult7.put("prop", "7");
jsonResult7.put("label", "7");
JSONObject jsonResult8 = new JSONObject();
jsonResult8.put("prop", "8");
jsonResult8.put("label", "10");
JSONObject jsonResult9 = new JSONObject();
jsonResult9.put("prop", "9");
jsonResult9.put("label", "平均");
JSONObject jsonResult10 = new JSONObject();
jsonResult10.put("prop", "10");
jsonResult10.put("label", "极差");
JSONObject jsonResult11 = new JSONObject();
jsonResult11.put("prop", "11");
jsonResult11.put("label", "标准");
JSONObject jsonResult12 = new JSONObject();
jsonResult12.put("prop", "12");
jsonResult12.put("label", "结论");
JSONObject jsonResult13 = new JSONObject();
jsonResult13.put("prop", "13");
jsonResult13.put("label", "1");
JSONObject jsonResult14 = new JSONObject();
jsonResult14.put("prop", "14");
jsonResult14.put("label", "3");
JSONObject jsonResult15 = new JSONObject();
jsonResult15.put("prop", "15");
jsonResult15.put("label", "5");
JSONObject jsonResult16 = new JSONObject();
jsonResult16.put("prop", "16");
jsonResult16.put("label", "7");
JSONObject jsonResult17 = new JSONObject();
jsonResult17.put("prop", "17");
jsonResult17.put("label", "10");
JSONObject jsonResult18 = new JSONObject();
jsonResult18.put("prop", "18");
jsonResult18.put("label", "平均");
JSONObject jsonResult19 = new JSONObject();
jsonResult19.put("prop", "19");
jsonResult19.put("label", "标准");
JSONObject jsonResult20 = new JSONObject();
jsonResult20.put("prop", "20");
jsonResult20.put("label", "结论");
jsonResultArr.add(jsonResult1);
jsonResultArr.add(jsonResult2);
jsonResultArr.add(jsonResult3);
jsonResultArr.add(jsonResult4);
jsonResultArr.add(jsonResult5);
jsonResultArr.add(jsonResult6);
jsonResultArr.add(jsonResult7);
jsonResultArr.add(jsonResult8);
jsonResultArr.add(jsonResult9);
jsonResultArr.add(jsonResult10);
jsonResultArr.add(jsonResult11);
jsonResultArr.add(jsonResult12);
jsonResultArr.add(jsonResult13);
jsonResultArr.add(jsonResult14);
jsonResultArr.add(jsonResult15);
jsonResultArr.add(jsonResult16);
jsonResultArr.add(jsonResult17);
jsonResultArr.add(jsonResult18);
jsonResultArr.add(jsonResult19);
jsonResultArr.add(jsonResult20);
return jsonResultArr;
/*
* 松比:
* 1.根据物料、批次查询1-12的桶号对应明细中项点为松比的值
* 2.平均值计算
* 3.极差值计算x = max - min
* 4.标准值:查询此物料的检测方案标准维护中的项点 下限值与上限值
* 5.结论:平均值在合格范围内认为合格
*/
for (int i = 0; i < contentArr.size(); i++) {
JSONObject json = contentArr.getJSONObject(i);
String material_id = json.getString("material_id");
String pcsn = json.getString("pcsn");
// 1.根据物料、批次查询所有喷雾工序的数据
JSONArray workArr = workTab.query("material_id = '" + material_id + "' and pcsn = '" + pcsn + "' and is_delete = '0' and workprocedure_code = 'GX003' order by record_order ASC").getResultJSONArray(0);
String all_value = "0"; // 总值
String all_num = "0"; // 总桶数
for (int j = 0; j < workArr.size(); j++) {
JSONObject jsonWorkMst = workArr.getJSONObject(j);
String inspection_id = jsonWorkMst.getString("inspection_id");
// 2.根据主表查询对应明细表:松比项点为 = GXZJ00003
map.put("flag","2");
map.put("inspection_id",inspection_id);
map.put("inspection_item_code","GXZJ00003");
JSONObject jsonWorkDtl = WQL.getWO("stifle_query_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonWorkDtl)) {
// 3.不为空则累加总值 和 总桶数
all_value = NumberUtil.add(all_value,jsonWorkDtl.getString("value_review")).toString();
all_num = NumberUtil.add(all_num,"1").toString();
// 4.put松比值
String record_order = jsonWorkMst.getString("record_order"); // 桶顺序号
json.put("sb_"+record_order,jsonWorkDtl.getString("value_review"));
}
}
// 5.松比平均值
if ((!StrUtil.equals(all_value,"0")) && (!StrUtil.equals(all_num,"0"))) {
json.put("sb_div", NumberUtil.round(NumberUtil.div(all_value, all_num).toString(), 2));
}
// 6.松比极差值
map.put("flag", "3");
map.put("material_id",material_id);
map.put("pcsn",pcsn);
JSONObject jsonMax = WQL.getWO("stifle_query_01").addParamMap(map).process().uniqueResult(0);
map.put("flag", "4");
JSONObject jsonMin = WQL.getWO("stifle_query_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonMax) && ObjectUtil.isNotEmpty(jsonMin)) {
BigDecimal sub = NumberUtil.sub(jsonMax.getString("value_review"), jsonMin.getString("value_review"));
json.put("sb_sub",NumberUtil.round(sub.toString(), 2));
}
// 7.松比密度标准值 GXZJ00003
JSONObject jsonStanSb = stanTab.query("material_uuid = '" + material_id + "' and inspection_item_code = 'GXZJ00003' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonStanSb)) {
double down_limit_sb = jsonStanSb.getDoubleValue("down_limit");
double up_limit_sb = jsonStanSb.getDoubleValue("up_limit");
json.put("sb_standard",String.valueOf(down_limit_sb) +"-"+ String.valueOf(up_limit_sb));
// 8.结论:平均值在合格范围内认为合格否则不合格
if (ObjectUtil.isNotEmpty(json.getString("sb_div"))) {
double sb_div = json.getDoubleValue("sb_div");
if ((down_limit_sb <= sb_div) && (sb_div <= up_limit_sb)) {
json.put("sb_result", "合格");
} else {
json.put("sb_result", "不合格");
}
}
}
/*
* 流动性:
* 1.根据物料、批次查询1-12的桶号对应明细中项点为流动性的值
* 2.平均值计算
* 3.极差值计算x = max - min
* 4.标准值:查询此物料的检测方案标准维护中的项点 下限值与上限值
* 5.结论:平均值在合格范围内认为合格
*/
String all_value_2 = "0"; // 总值
String all_num_2 = "0"; // 总桶数
for (int k = 0; k < workArr.size(); k++) {
JSONObject jsonWorkMst = workArr.getJSONObject(k);
String inspection_id = jsonWorkMst.getString("inspection_id");
// 2.根据主表查询对应明细表:流动性项点为 = GXZJ00004
map.put("flag","2");
map.put("inspection_id",inspection_id);
map.put("inspection_item_code","GXZJ00004");
JSONObject jsonWorkDtl = WQL.getWO("stifle_query_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonWorkDtl)) {
// 3.不为空则累加总值 和 总桶数
all_value_2 = NumberUtil.add(all_value_2,jsonWorkDtl.getString("value_review")).toString();
all_num_2 = NumberUtil.add(all_num_2,"1").toString();
// 4.put松比值
String record_order = jsonWorkMst.getString("record_order"); // 桶顺序号
json.put("ldx_"+record_order,jsonWorkDtl.getString("value_review"));
}
}
// 5.流动性平均值
if ((!StrUtil.equals(all_value_2,"0")) && (!StrUtil.equals(all_num_2,"0"))) {
json.put("ldx_div", NumberUtil.round(NumberUtil.div(all_value_2, all_num_2).toString(), 2));
}
// 6.松比极差值
map.put("flag", "3");
map.put("material_id",material_id);
map.put("pcsn",pcsn);
JSONObject jsonMax_ldx = WQL.getWO("stifle_query_01").addParamMap(map).process().uniqueResult(0);
map.put("flag", "4");
JSONObject jsonMin_ldx = WQL.getWO("stifle_query_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonMax_ldx) && ObjectUtil.isNotEmpty(jsonMin_ldx)) {
BigDecimal sub = NumberUtil.sub(jsonMax_ldx.getString("value_review"), jsonMin_ldx.getString("value_review"));
json.put("ldx_sub",NumberUtil.round(sub.toString(),2));
}
// 7.流动性标准值 GXZJ00004
JSONObject jsonStanLdx = stanTab.query("material_uuid = '" + material_id + "' and inspection_item_code = 'GXZJ00004' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonStanLdx)) {
double down_limit_ldx = jsonStanLdx.getDoubleValue("down_limit");
double up_limit_ldx = jsonStanLdx.getDoubleValue("up_limit");
json.put("ldx_standard",String.valueOf(down_limit_ldx) +"-"+ String.valueOf(up_limit_ldx));
// 8.结论:平均值在合格范围内认为合格否则不合格
if (ObjectUtil.isNotEmpty(json.getString("ldx_div"))) {
double ldx_div = json.getDoubleValue("ldx_div");
if ((down_limit_ldx <= ldx_div) && (ldx_div <= up_limit_ldx)) {
json.put("ldx_result", "合格");
} else {
json.put("ldx_result", "不合格");
}
}
}
/*
* 筛分:抽一桶进行显示
* 1.查出筛分相关项点GXZJ00006、GXZJ00007、GXZJ00008、GXZJ00009、GXZJ00010、GXZJ00011、GXZJ00012
* 2.占比计算前5项和/所有项和 x 100
*/
if (ObjectUtil.isNotEmpty(workArr)) {
JSONObject jsonSf = workArr.getJSONObject(0);
JSONObject map_sf = new JSONObject();
map_sf.put("flag","2");
map_sf.put("inspection_id",jsonSf.getString("inspection_id"));
map_sf.put("inspection_item_code","GXZJ00006");
JSONObject jsonSf_1 = WQL.getWO("stifle_query_01").addParamMap(map_sf).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonSf_1)) {
json.put("sf_1", jsonSf_1.getString("value_review"));
} else {
json.put("sf_1", "0");
}
map_sf.put("inspection_item_code","GXZJ00007");
JSONObject jsonSf_2 = WQL.getWO("stifle_query_01").addParamMap(map_sf).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonSf_2)) {
json.put("sf_2", jsonSf_2.getString("value_review"));
} else {
json.put("sf_2", "0");
}
map_sf.put("inspection_item_code","GXZJ00008");
JSONObject jsonSf_3 = WQL.getWO("stifle_query_01").addParamMap(map_sf).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonSf_3)) {
json.put("sf_3", jsonSf_3.getString("value_review"));
} else {
json.put("sf_3", "0");
}
map_sf.put("inspection_item_code","GXZJ00009");
JSONObject jsonSf_4 = WQL.getWO("stifle_query_01").addParamMap(map_sf).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonSf_4)) {
json.put("sf_4", jsonSf_4.getString("value_review"));
} else {
json.put("sf_4", "0");
}
map_sf.put("inspection_item_code","GXZJ00010");
JSONObject jsonSf_5 = WQL.getWO("stifle_query_01").addParamMap(map_sf).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonSf_5)) {
json.put("sf_5", jsonSf_5.getString("value_review"));
} else {
json.put("sf_5", "0");
}
map_sf.put("inspection_item_code","GXZJ00011");
JSONObject jsonSf_6 = WQL.getWO("stifle_query_01").addParamMap(map_sf).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonSf_6)) {
json.put("sf_6", jsonSf_6.getString("value_review"));
} else {
json.put("sf_6", "0");
}
map_sf.put("inspection_item_code","GXZJ00012");
JSONObject jsonSf_7 = WQL.getWO("stifle_query_01").addParamMap(map_sf).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonSf_7)) {
json.put("sf_7", jsonSf_7.getString("value_review"));
} else {
json.put("sf_7", "0");
}
// 占比计算
String add_5 = NumberUtil.add(json.getString("sf_1"), json.getString("sf_2"), json.getString("sf_3"), json.getString("sf_4"), json.getString("sf_5")).toString();
String add_7 = NumberUtil.add(add_5, json.getString("sf_6"), json.getString("sf_7")).toString();
if (!StrUtil.equals(add_7, "0")) {
String sf_div = NumberUtil.div(add_5, add_7).toString();
json.put("sf_zb", NumberUtil.round(NumberUtil.mul(sf_div,"100").toString(), 2));
}
// 备注
json.put("remark", jsonSf.getString("remark"));
}
}
return result;
}
}

View File

@@ -16,12 +16,10 @@
输入.flag TYPEAS s_string
输入.begin_time TYPEAS s_string
输入.end_time TYPEAS s_string
输入.inspection_code TYPEAS s_string
输入.pcsn TYPEAS s_string
输入.other_device_no TYPEAS s_string
输入.bill_status TYPEAS s_string
输入.material_code TYPEAS s_string
输入.material_id TYPEAS s_string
输入.inspection_id TYPEAS s_string
输入.inspection_item_code TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -48,14 +46,20 @@
IF 输入.flag = "1"
PAGEQUERY
SELECT
mst.*,
mater.material_code
sum(mst.total_qty) AS total_qty,
max(mst.biz_date) AS biz_date,
mst.material_id,
mst.pcsn,
mater.material_code,
max(ext.standard_mark) AS standard_mark
FROM
QL_TEST_WorkProcedureMst mst
LEFT JOIN md_me_materialbase mater ON mater.material_id = mst.material_id
LEFT JOIN MD_ME_ProducMaterialExt ext ON ext.material_id = mater.material_id
WHERE
mst.is_delete= '0'
AND mst.workprocedure_code = 'GX008'
OPTION 输入.begin_time <> ""
mst.input_time >= 输入.begin_time
@@ -65,27 +69,88 @@
mst.input_time <= 输入.end_time
ENDOPTION
OPTION 输入.inspection_code <> ""
mst.inspection_code = 输入.inspection_code
OPTION 输入.pcsn <> ""
mst.pcsn = 输入.pcsn
ENDOPTION
OPTION 输入.material_code <> ""
(mater.material_code like 输入.material_code or
mater.material_name like 输入.material_code)
ENDOPTION
group by mst.pcsn,mst.material_id
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT
dtl.*
FROM
QL_TEST_WorkProcedureDtl dtl
LEFT JOIN QL_TEST_InspectionItemPoint point ON point.inspection_item_id = dtl.inspection_item_id
WHERE
point.inspection_item_code = 输入.inspection_item_code
OPTION 输入.inspection_id <> ""
dtl.inspection_id = 输入.inspection_id
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
dtl.*
FROM
QL_TEST_WorkProcedureMst mst
LEFT JOIN QL_TEST_WorkProcedureDtl dtl ON mst.inspection_id = dtl.inspection_id
LEFT JOIN QL_TEST_InspectionItemPoint point ON point.inspection_item_id = dtl.inspection_item_id
WHERE
point.inspection_item_code = 输入.inspection_item_code
OPTION 输入.material_id <> ""
mst.material_id = 输入.material_id
ENDOPTION
OPTION 输入.pcsn <> ""
mst.pcsn = 输入.pcsn
ENDOPTION
OPTION 输入.other_device_no <> ""
mst.other_device_no = 输入.other_device_no
ENDOPTION
OPTION 输入.bill_status <> ""
mst.bill_status = 输入.bill_status
ENDOPTION
OPTION 输入.material_code <> ""
(mater.material_code like 输入.material_code or
mater.material_name like 输入.material_code)
ENDOPTION
order by dtl.value_review DESC
ENDSELECT
ENDPAGEQUERY
ENDQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
dtl.*
FROM
QL_TEST_WorkProcedureMst mst
LEFT JOIN QL_TEST_WorkProcedureDtl dtl ON mst.inspection_id = dtl.inspection_id
LEFT JOIN QL_TEST_InspectionItemPoint point ON point.inspection_item_id = dtl.inspection_item_id
WHERE
point.inspection_item_code = 输入.inspection_item_code
OPTION 输入.material_id <> ""
mst.material_id = 输入.material_id
ENDOPTION
OPTION 输入.pcsn <> ""
mst.pcsn = 输入.pcsn
ENDOPTION
order by dtl.value_review ASC
ENDSELECT
ENDQUERY
ENDIF