Merge branch 'master' of http://121.40.234.130:8899/root/lanzhouhailiang_one
# Conflicts: # lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java
This commit is contained in:
Binary file not shown.
@@ -98,4 +98,18 @@ public class LmsToMesController {
|
||||
public ResponseEntity<Object> lmsPackage(@RequestBody JSONObject jo) {
|
||||
return new ResponseEntity<>(lmsToMesService.lmsPackage(jo), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/scrapAudit")
|
||||
@Log("成品报废审核")
|
||||
@ApiOperation("成品报废审核")
|
||||
public ResponseEntity<Object> scrapAudit(@RequestBody JSONObject jo) {
|
||||
return new ResponseEntity<>(lmsToMesService.scrapAudit(jo), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/proudDayData")
|
||||
@Log("成品日报推送")
|
||||
@ApiOperation("成品日报推送")
|
||||
public ResponseEntity<Object> proudDayData(@RequestBody JSONObject jo) {
|
||||
return new ResponseEntity<>(lmsToMesService.proudDayData(jo), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,4 +110,16 @@ public interface LmsToMesService {
|
||||
* }
|
||||
*/
|
||||
JSONObject lmsPackage(JSONObject jo);
|
||||
|
||||
/**
|
||||
* 成品报废审核
|
||||
* 参数:
|
||||
*/
|
||||
JSONObject scrapAudit(JSONObject jo);
|
||||
|
||||
/**
|
||||
* 成品日报推送
|
||||
* 参数:
|
||||
*/
|
||||
JSONObject proudDayData(JSONObject jo);
|
||||
}
|
||||
|
||||
@@ -604,4 +604,78 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject scrapAudit(JSONObject param) {
|
||||
log.info("scrapAudit接口输入参数为:-------------------" + param.toString());
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
if (StrUtil.equals("0", is_connect_mes)) {
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "下发成功,但未连接飞书!");
|
||||
result.put("data", new JSONObject());
|
||||
return result;
|
||||
}
|
||||
|
||||
// String url = acsUrl + api;
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("FEISHU_URL").getValue();
|
||||
String api = "/FeiShuNoticesWebApi/CreateApproval";
|
||||
url = url + api;
|
||||
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(param))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
log.info("scrapAudit接口输出参数为:-------------------" + result.toString());
|
||||
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("飞书提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject proudDayData(JSONObject param) {
|
||||
log.info("proudDayData接口输入参数为:-------------------" + param.toString());
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
if (StrUtil.equals("0", is_connect_mes)) {
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "下发成功,但未连接飞书!");
|
||||
result.put("data", new JSONObject());
|
||||
return result;
|
||||
}
|
||||
|
||||
// String url = acsUrl + api;
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("FEISHU_URL").getValue();
|
||||
String api = "/FeiShuNoticesWebApi/SendCard";
|
||||
url = url + api;
|
||||
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(param))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
log.info("proudDayData接口输出参数为:-------------------" + result.toString());
|
||||
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("飞书提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.nl.wms.pda.mps.service.impl.BakingServiceImpl;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.tasks.CoolCutTask;
|
||||
import org.nl.wms.st.inbill.service.CheckOutBillService;
|
||||
import org.nl.wms.st.instor.service.impl.ProductScrapServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -1358,9 +1359,44 @@ public class MesToLmsServiceImpl implements MesToLmsService {
|
||||
|
||||
@Override
|
||||
public JSONObject sendAuditResult(JSONObject param) {
|
||||
String instance_code = param.getString("instance_code");
|
||||
//0-不通过;1-通过;
|
||||
String result = param.getString("result");
|
||||
return null;
|
||||
log.info("sendAuditResult接口输入参数为:-------------------" + param.toString());
|
||||
|
||||
WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst");
|
||||
JSONObject resultParam = new JSONObject();
|
||||
|
||||
try {
|
||||
String instance_code = param.getString("instance_code");
|
||||
//0-不通过;1-通过;
|
||||
String result = param.getString("result");
|
||||
|
||||
if (ObjectUtil.isEmpty(instance_code)) throw new BadRequestException("参数instance_code不能为空");
|
||||
if (ObjectUtil.isEmpty(result)) throw new BadRequestException("参数result不能为空");
|
||||
|
||||
JSONObject json = mst.query("ext_code = '" + instance_code + "' and bill_status = '20'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(json)) throw new BadRequestException("未找到对应单据或已经完成!");
|
||||
|
||||
// 调用接口
|
||||
ProductScrapServiceImpl bean = SpringContextHolder.getBean(ProductScrapServiceImpl.class);
|
||||
|
||||
if (result.equals("0")) {
|
||||
bean.auditOut(json);
|
||||
} else {
|
||||
bean.auditPass(json);
|
||||
}
|
||||
|
||||
resultParam.put("RTYPE", "S");
|
||||
resultParam.put("Code", "0");
|
||||
resultParam.put("RTMSG", "操作成功!");
|
||||
System.out.println(resultParam);
|
||||
|
||||
} catch (Exception e) {
|
||||
resultParam.put("RTYPE", "E");
|
||||
resultParam.put("Code", "1");
|
||||
resultParam.put("RTMSG", "操作失败!," + e.getMessage());
|
||||
System.out.println(resultParam);
|
||||
}
|
||||
|
||||
log.info("sendAuditResult接口输出参数为:-------------------" + resultParam.toString());
|
||||
return resultParam;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,4 +63,12 @@ public class LmsToBigScreenController {
|
||||
return new ResponseEntity<>(LmsToBigScreenService.getMonthDelivery(jo), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getProudDayData")
|
||||
@Log("成品日报")
|
||||
@ApiOperation("成品日报")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getProudDayData(@RequestBody JSONObject jo) {
|
||||
return new ResponseEntity<>(LmsToBigScreenService.getProudDayData(jo), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,4 +11,6 @@ public interface LmsToBigScreenService {
|
||||
JSONArray getMonthFreight(JSONObject jo);
|
||||
JSONArray getMonthYield(JSONObject jo);
|
||||
JSONArray getMonthDelivery(JSONObject jo);
|
||||
|
||||
JSONObject getProudDayData(JSONObject jo);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.szls.service.LmsToBigScreenService;
|
||||
import org.nl.wms.sch.manage.AutoQueryProudDayData;
|
||||
import org.nl.wms.sch.tasks.URLEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -107,4 +108,9 @@ public class LmsToBigScreenServiceImpl implements LmsToBigScreenService {
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getProudDayData(JSONObject jo) {
|
||||
return SpringContextHolder.getBean(AutoQueryProudDayData.class).data();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,425 @@
|
||||
[交易说明]
|
||||
交易名: 成品日报
|
||||
所属模块:
|
||||
功能简述:
|
||||
版权所有:
|
||||
表引用:
|
||||
版本经历:
|
||||
|
||||
[数据库]
|
||||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||
|
||||
[IO定义]
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.customer_name TYPEAS f_string
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
|
||||
[临时变量]
|
||||
--所有中间过程变量均可在此处定义
|
||||
|
||||
[业务过程]
|
||||
|
||||
##########################################
|
||||
# 1、输入输出检查 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 2、主过程前处理 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 3、业务主过程 #
|
||||
##########################################
|
||||
|
||||
IF 输入.flag = "1"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( ivt.ivt_qty ) / 1000 AS num,
|
||||
attr.stor_id
|
||||
FROM
|
||||
st_ivt_structivt ivt
|
||||
LEFT JOIN st_ivt_structattr attr ON ivt.struct_id = attr.struct_id
|
||||
WHERE
|
||||
ivt.ivt_qty > '0'
|
||||
|
||||
GROUP BY attr.stor_id
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "2"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( ivt.ivt_qty ) / 1000 AS num,
|
||||
attr.stor_id
|
||||
FROM
|
||||
st_ivt_structivt ivt
|
||||
LEFT JOIN st_ivt_structattr attr ON attr.struct_id = ivt.struct_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.package_box_sn = attr.storagevehicle_code
|
||||
AND ivt.pcsn = sub.container_name
|
||||
WHERE
|
||||
DATEDIFF( NOW(), sub.date_of_production ) >= '90'
|
||||
AND ivt.ivt_qty > '0'
|
||||
|
||||
GROUP BY attr.stor_id
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( ivt.ivt_qty ) / 1000 AS num,
|
||||
attr.stor_id
|
||||
FROM
|
||||
st_ivt_structivt ivt
|
||||
LEFT JOIN st_ivt_structattr attr ON attr.struct_id = ivt.struct_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.package_box_sn = attr.storagevehicle_code
|
||||
AND ivt.pcsn = sub.container_name
|
||||
WHERE
|
||||
DATEDIFF( NOW(), sub.date_of_production ) > '60'
|
||||
AND DATEDIFF( NOW(), sub.date_of_production ) <= '90'
|
||||
AND ivt.ivt_qty > '0'
|
||||
|
||||
GROUP BY attr.stor_id
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( ivt.ivt_qty ) / 1000 AS num,
|
||||
attr.stor_id
|
||||
FROM
|
||||
st_ivt_structivt ivt
|
||||
LEFT JOIN st_ivt_structattr attr ON attr.struct_id = ivt.struct_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.package_box_sn = attr.storagevehicle_code
|
||||
AND ivt.pcsn = sub.container_name
|
||||
WHERE
|
||||
DATEDIFF( NOW(), sub.date_of_production ) < '90'
|
||||
AND ivt.ivt_qty > '0'
|
||||
|
||||
GROUP BY attr.stor_id
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "5"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( ivt.ivt_qty ) / 1000 AS num,
|
||||
attr.stor_id
|
||||
FROM
|
||||
st_ivt_structivt ivt
|
||||
LEFT JOIN st_ivt_structattr attr ON attr.struct_id = ivt.struct_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.package_box_sn = attr.storagevehicle_code
|
||||
AND ivt.pcsn = sub.container_name
|
||||
WHERE
|
||||
ivt.ivt_qty > '0'
|
||||
|
||||
OPTION 输入.customer_name <> ""
|
||||
sub.customer_name in 输入.customer_name
|
||||
ENDOPTION
|
||||
|
||||
GROUP BY attr.stor_id
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "6"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( ivt.ivt_qty ) / 1000 AS num,
|
||||
attr.stor_id
|
||||
FROM
|
||||
st_ivt_structivt ivt
|
||||
LEFT JOIN st_ivt_structattr attr ON attr.struct_id = ivt.struct_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.package_box_sn = attr.storagevehicle_code
|
||||
AND ivt.pcsn = sub.container_name
|
||||
WHERE
|
||||
ivt.ivt_qty > '0'
|
||||
|
||||
OPTION 输入.customer_name <> ""
|
||||
sub.customer_name not in 输入.customer_name
|
||||
ENDOPTION
|
||||
|
||||
GROUP BY attr.stor_id
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "7"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
sub.customer_name
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '0'
|
||||
AND mst.bill_status = '99'
|
||||
AND mst.biz_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
|
||||
|
||||
GROUP BY sub.customer_name
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "8"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
sub.customer_name
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '1'
|
||||
AND mst.bill_status = '99'
|
||||
AND mst.biz_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
|
||||
|
||||
GROUP BY sub.customer_name
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "9"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
sub.customer_name
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '0'
|
||||
AND mst.bill_status = '99'
|
||||
AND MONTH(mst.biz_date) = MONTH(CURDATE())
|
||||
AND YEAR(mst.biz_date) = YEAR(CURDATE())
|
||||
|
||||
GROUP BY sub.customer_name
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "10"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
sub.customer_name
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '1'
|
||||
AND mst.bill_status = '99'
|
||||
AND MONTH(mst.biz_date) = MONTH(CURDATE())
|
||||
AND YEAR(mst.biz_date) = YEAR(CURDATE())
|
||||
|
||||
GROUP BY sub.customer_name
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "11"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
LEFT(dis.pcsn,2) AS region_code
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '0'
|
||||
AND mst.bill_status = '99'
|
||||
AND mst.biz_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
|
||||
|
||||
GROUP BY LEFT(dis.pcsn,2)
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "12"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
LEFT(dis.pcsn,2) AS region_code
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '1'
|
||||
AND mst.bill_status = '99'
|
||||
AND mst.biz_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
|
||||
|
||||
GROUP BY LEFT(dis.pcsn,2)
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "13"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
LEFT(dis.pcsn,2) AS region_code,
|
||||
sub.customer_name
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '0'
|
||||
AND mst.bill_status = '99'
|
||||
AND mst.biz_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
|
||||
|
||||
GROUP BY LEFT(dis.pcsn,2),sub.customer_name
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "14"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
LEFT(dis.pcsn,2) AS region_code,
|
||||
sub.customer_name
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '1'
|
||||
AND mst.bill_status = '99'
|
||||
AND mst.biz_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
|
||||
|
||||
GROUP BY LEFT(dis.pcsn,2),sub.customer_name
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "15"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
LEFT(dis.pcsn,2) AS region_code
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '0'
|
||||
AND mst.bill_status = '99'
|
||||
AND MONTH(mst.biz_date) = MONTH(CURDATE())
|
||||
AND YEAR(mst.biz_date) = YEAR(CURDATE())
|
||||
|
||||
GROUP BY LEFT(dis.pcsn,2)
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "16"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
LEFT(dis.pcsn,2) AS region_code
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '1'
|
||||
AND mst.bill_status = '99'
|
||||
AND MONTH(mst.biz_date) = MONTH(CURDATE())
|
||||
AND YEAR(mst.biz_date) = YEAR(CURDATE())
|
||||
|
||||
GROUP BY LEFT(dis.pcsn,2)
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "17"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
LEFT(dis.pcsn,2) AS region_code,
|
||||
sub.customer_name
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '0'
|
||||
AND mst.bill_status = '99'
|
||||
AND MONTH(mst.biz_date) = MONTH(CURDATE())
|
||||
AND YEAR(mst.biz_date) = YEAR(CURDATE())
|
||||
|
||||
GROUP BY LEFT(dis.pcsn,2),sub.customer_name
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "18"
|
||||
QUERY
|
||||
SELECT
|
||||
SUM( dis.plan_qty ) / 1000 AS num,
|
||||
LEFT(dis.pcsn,2) AS region_code,
|
||||
sub.customer_name
|
||||
FROM
|
||||
st_ivt_iostorinvdis dis
|
||||
LEFT JOIN st_ivt_iostorinv mst ON dis.iostorinv_id = mst.iostorinv_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn AND sub.package_box_sn = dis.box_no
|
||||
WHERE
|
||||
mst.is_delete = '0'
|
||||
AND mst.io_type = '1'
|
||||
AND mst.bill_status = '99'
|
||||
AND MONTH(mst.biz_date) = MONTH(CURDATE())
|
||||
AND YEAR(mst.biz_date) = YEAR(CURDATE())
|
||||
|
||||
GROUP BY LEFT(dis.pcsn,2),sub.customer_name
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
@@ -0,0 +1,517 @@
|
||||
package org.nl.wms.sch.manage;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.ext.mes.service.LmsToMesService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AutoQueryProudDayData {
|
||||
|
||||
private final LmsToMesService lmsToMesService;
|
||||
|
||||
public void run() {
|
||||
JSONObject param = new JSONObject();
|
||||
|
||||
JSONArray UserList = new JSONArray();
|
||||
|
||||
String userList = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("USER_LIST_FEISHU").getValue();
|
||||
|
||||
String[] split = userList.split(",");
|
||||
if (split.length > 0) {
|
||||
for (String s : split) {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("User", s);
|
||||
UserList.add(jo);
|
||||
}
|
||||
} else {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("User","");
|
||||
UserList.add(jo);
|
||||
}
|
||||
param.put("UserList", UserList);
|
||||
|
||||
param.put("Code", "ctp_AAVwgNuQOtO0");
|
||||
param.put("card", data());
|
||||
|
||||
// 调用接口
|
||||
lmsToMesService.proudDayData(param);
|
||||
|
||||
}
|
||||
|
||||
public JSONObject data() {
|
||||
WQLObject storTab = WQLObject.getWQLObject("st_ivt_bsrealstorattr"); // 仓库表
|
||||
|
||||
// 查询共多少个仓库
|
||||
String in_stor_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("STOR_CODE_FEISHU").getValue();
|
||||
JSONArray storArr = storTab.query("is_used = '1' and stor_code in"+in_stor_code).getResultJSONArray(0);
|
||||
|
||||
// 客户
|
||||
String custB = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("CUST_B").getValue();
|
||||
String custC = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("CUST_C").getValue();
|
||||
|
||||
JSONObject result = new JSONObject(); // 全部数据
|
||||
result.put("Title", DateUtil.today()+"成品数据(单位:T)");
|
||||
|
||||
/*
|
||||
* 查询各仓库库存
|
||||
*/
|
||||
JSONArray Arrayobject1 = new JSONArray(); // 各仓库库存集合
|
||||
|
||||
// 库存总量集合
|
||||
List<JSONObject> allIvtList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "1").process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 超期库存集合
|
||||
List<JSONObject> sidIvtList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "2").process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 临期库存集合
|
||||
List<JSONObject> faceIvtList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "3").process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 正常库龄
|
||||
List<JSONObject> regIvtList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "4").process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
for (int i = 0; i < storArr.size(); i++) {
|
||||
JSONObject item = storArr.getJSONObject(i);
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("local", item.getString("stor_name")); // 存储地点
|
||||
|
||||
// 库存总量
|
||||
List<JSONObject> collect = allIvtList.stream()
|
||||
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||
.collect(Collectors.toList());
|
||||
json.put("TotalInventory", collect.isEmpty() ? "0" : NumberUtil.round(collect.get(0).getString("num"), 2)+"");
|
||||
|
||||
// 超期库存
|
||||
List<JSONObject> collect2 = sidIvtList.stream()
|
||||
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||
.collect(Collectors.toList());
|
||||
json.put("OverdueInventory", collect2.isEmpty() ? "0" : NumberUtil.round(collect2.get(0).getString("num"),2)+"");
|
||||
|
||||
// 临期库存
|
||||
List<JSONObject> collect3 = faceIvtList.stream()
|
||||
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||
.collect(Collectors.toList());
|
||||
json.put("InterimInventory", collect3.isEmpty() ? "0" : NumberUtil.round(collect3.get(0).getString("num"),2)+"");
|
||||
|
||||
// 正常库存
|
||||
List<JSONObject> collect4 = regIvtList.stream()
|
||||
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||
.collect(Collectors.toList());
|
||||
json.put("NormalStockAge", collect4.isEmpty() ? "0" : NumberUtil.round(collect4.get(0).getString("num"),2)+"");
|
||||
|
||||
Arrayobject1.add(json);
|
||||
}
|
||||
|
||||
// 计算全部
|
||||
JSONObject allIvt = new JSONObject();
|
||||
allIvt.put("local", "全部");
|
||||
allIvt.put("TotalInventory", NumberUtil.round(allIvtList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
allIvt.put("OverdueInventory", NumberUtil.round(sidIvtList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
allIvt.put("InterimInventory", NumberUtil.round(faceIvtList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
allIvt.put("NormalStockAge", NumberUtil.round(regIvtList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
Arrayobject1.add(allIvt);
|
||||
|
||||
result.put("Arrayobject1",Arrayobject1);
|
||||
|
||||
/*
|
||||
* 各客户库存 :
|
||||
* 1.表头
|
||||
* {
|
||||
* B库存:10000708 蕉城时代,10000698 江苏时代,10000779 四川时代,10000561 宁德时代
|
||||
* C库存:10000426 比亚迪,2010 海亮股份
|
||||
* Other库存: 除B、C客户的其他客户
|
||||
* }
|
||||
* 2.数据
|
||||
*/
|
||||
// 1.表头:
|
||||
JSONArray Customernventory = new JSONArray();
|
||||
|
||||
JSONObject custHand = new JSONObject();
|
||||
custHand.put("Customer1", "B库存");
|
||||
custHand.put("Customer2", "C库存");
|
||||
custHand.put("Customer3", "Other库存");
|
||||
Customernventory.add(custHand);
|
||||
result.put("Customernventory",Customernventory);
|
||||
|
||||
// 2.数据
|
||||
JSONArray Arrayobject2 = new JSONArray();
|
||||
|
||||
// B库存集合
|
||||
List<JSONObject> custIvtBList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "5")
|
||||
.addParam("customer_name", "('10000708','10000698','10000779','10000561')")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// C库存集合
|
||||
List<JSONObject> custIvtCList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "5")
|
||||
.addParam("customer_name", "('10000426','2010')")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 其他库存集合
|
||||
List<JSONObject> custIvtOtherList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "6")
|
||||
.addParam("customer_name", "('10000426','2010','10000708','10000698','10000779','10000561')")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
for (int i = 0; i < storArr.size(); i++) {
|
||||
JSONObject item = storArr.getJSONObject(i);
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("Local", item.getString("stor_name"));
|
||||
|
||||
// B库存
|
||||
List<JSONObject> collectB = custIvtBList.stream()
|
||||
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||
.collect(Collectors.toList());
|
||||
json.put("Customernventory1", collectB.isEmpty() ? "0" : NumberUtil.round(collectB.get(0).getString("num"), 2)+"");
|
||||
|
||||
// C库存
|
||||
List<JSONObject> collectC = custIvtCList.stream()
|
||||
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||
.collect(Collectors.toList());
|
||||
json.put("Customernventory2", collectC.isEmpty() ? "0" : NumberUtil.round(collectC.get(0).getString("num"), 2)+"");
|
||||
|
||||
// 其他库存
|
||||
List<JSONObject> collectOthen = custIvtOtherList.stream()
|
||||
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||
.collect(Collectors.toList());
|
||||
json.put("Customernventory3", collectOthen.isEmpty() ? "0" : NumberUtil.round(collectOthen.get(0).getString("num"), 2)+"");
|
||||
|
||||
Arrayobject2.add(json);
|
||||
}
|
||||
|
||||
// 计算全部
|
||||
JSONObject allCustIvt = new JSONObject();
|
||||
allCustIvt.put("Local", "全部");
|
||||
allCustIvt.put("Customernventory1", NumberUtil.round(custIvtBList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
allCustIvt.put("Customernventory2", NumberUtil.round(custIvtCList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
allCustIvt.put("Customernventory3", NumberUtil.round(custIvtOtherList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
Arrayobject2.add(allCustIvt);
|
||||
|
||||
result.put("Arrayobject2", Arrayobject2);
|
||||
|
||||
/*
|
||||
* 库存变化
|
||||
* 1.表头
|
||||
* {
|
||||
* B库存:10000708 蕉城时代,10000698 江苏时代,10000779 四川时代,10000561 宁德时代
|
||||
* C库存:10000426 比亚迪,2010 海亮股份
|
||||
* 汇总: 所有客户
|
||||
* }
|
||||
* 2.数据
|
||||
*/
|
||||
// 1.表头
|
||||
JSONArray Arrayobject3 = new JSONArray();
|
||||
|
||||
JSONObject changeIvt = new JSONObject();
|
||||
changeIvt.put("Customer1", "B客户");
|
||||
changeIvt.put("Customer2", "C客户");
|
||||
changeIvt.put("Customer3", "汇总");
|
||||
Arrayobject3.add(changeIvt);
|
||||
result.put("Arrayobject3", Arrayobject3);
|
||||
|
||||
// 2.数据
|
||||
JSONArray Arrayobject4 = new JSONArray();
|
||||
|
||||
// 所有昨日入库量客户分组集合
|
||||
List<JSONObject> yesterdayInList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "7")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 所有昨日出库量客户分组集合
|
||||
List<JSONObject> yesterdayOutList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "8")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 所有当月入库量客户分组集合
|
||||
List<JSONObject> monthInList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "9")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 所有当月出库量客户分组集合
|
||||
List<JSONObject> monthOutList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "10")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// ---- 昨日入库量 ----
|
||||
JSONObject yesterdayIn = new JSONObject();
|
||||
yesterdayIn.put("Title", "昨日入库量");
|
||||
|
||||
// B客户
|
||||
List<JSONObject> custBList = yesterdayInList.stream()
|
||||
.filter(row -> custB.contains(row.getString("customer_name")))
|
||||
.collect(Collectors.toList());
|
||||
yesterdayIn.put("Customerqty1", NumberUtil.round(custBList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2) +"");
|
||||
|
||||
// C客户
|
||||
List<JSONObject> custCList = yesterdayInList.stream()
|
||||
.filter(row -> custC.contains(row.getString("customer_name")))
|
||||
.collect(Collectors.toList());
|
||||
yesterdayIn.put("Customerqty2", NumberUtil.round(custCList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
|
||||
// 汇总
|
||||
yesterdayIn.put("Customerqty3", NumberUtil.round(yesterdayInList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
Arrayobject4.add(yesterdayIn);
|
||||
|
||||
// ---- 昨日出库量 ----
|
||||
JSONObject yesterdayOut = new JSONObject();
|
||||
yesterdayOut.put("Title", "昨日出库量");
|
||||
|
||||
// B客户
|
||||
List<JSONObject> custBList2 = yesterdayOutList.stream()
|
||||
.filter(row -> custB.contains(row.getString("customer_name")))
|
||||
.collect(Collectors.toList());
|
||||
yesterdayOut.put("Customerqty1", NumberUtil.round(custBList2.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
|
||||
// C客户
|
||||
List<JSONObject> custCList2 = yesterdayOutList.stream()
|
||||
.filter(row -> custC.contains(row.getString("customer_name")))
|
||||
.collect(Collectors.toList());
|
||||
yesterdayOut.put("Customerqty2", NumberUtil.round(custCList2.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
|
||||
// 汇总
|
||||
yesterdayOut.put("Customerqty3", NumberUtil.round(yesterdayOutList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
Arrayobject4.add(yesterdayOut);
|
||||
|
||||
// ---- 当月入库量 ----
|
||||
JSONObject monthdayIn = new JSONObject();
|
||||
monthdayIn.put("Title", "当月入库量");
|
||||
|
||||
// B客户
|
||||
List<JSONObject> custBList3 = monthInList.stream()
|
||||
.filter(row -> custB.contains(row.getString("customer_name")))
|
||||
.collect(Collectors.toList());
|
||||
monthdayIn.put("Customerqty1", NumberUtil.round(custBList3.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
|
||||
// C客户
|
||||
List<JSONObject> custCList3 = monthInList.stream()
|
||||
.filter(row -> custC.contains(row.getString("customer_name")))
|
||||
.collect(Collectors.toList());
|
||||
monthdayIn.put("Customerqty2", NumberUtil.round(custCList3.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
|
||||
// 汇总
|
||||
monthdayIn.put("Customerqty3", NumberUtil.round(monthInList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
Arrayobject4.add(monthdayIn);
|
||||
|
||||
// ---- 当月出库量 ----
|
||||
JSONObject monthdayOut = new JSONObject();
|
||||
monthdayOut.put("Title", "当月出库量");
|
||||
|
||||
// B客户
|
||||
List<JSONObject> custBList4 = monthOutList.stream()
|
||||
.filter(row -> custB.contains(row.getString("customer_name")))
|
||||
.collect(Collectors.toList());
|
||||
monthdayOut.put("Customerqty1", NumberUtil.round(custBList4.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
|
||||
// C客户
|
||||
List<JSONObject> custCList4 = monthOutList.stream()
|
||||
.filter(row -> custC.contains(row.getString("customer_name")))
|
||||
.collect(Collectors.toList());
|
||||
monthdayOut.put("Customerqty2", NumberUtil.round(custCList4.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
|
||||
// 汇总
|
||||
monthdayOut.put("Customerqty3",NumberUtil.round( monthOutList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2)+"");
|
||||
Arrayobject4.add(monthdayOut);
|
||||
|
||||
result.put("Arrayobject4",Arrayobject4);
|
||||
|
||||
/*
|
||||
* 各区域库存变化
|
||||
* 数据
|
||||
* {
|
||||
* B库存:10000708 蕉城时代,10000698 江苏时代,10000779 四川时代,10000561 宁德时代
|
||||
* C库存:10000426 比亚迪,2010 海亮股份
|
||||
* }
|
||||
* {
|
||||
* region_code: A1,A2,A3,A4
|
||||
* }
|
||||
*/
|
||||
JSONArray Arrayobject5 = new JSONArray();
|
||||
|
||||
// 所有昨日入库量区域分组集合
|
||||
List<JSONObject> yesterdayInRegList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "11")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 所有昨日出库量区域分组集合
|
||||
List<JSONObject> yesterdayOutRegList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "12")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 所有昨日入库量区域、客户分组集合
|
||||
List<JSONObject> yesterdayCustInRegList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "13")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 所有昨日出库量区域、客户分组集合
|
||||
List<JSONObject> yesterdayCustOutRegList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "14")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 所有当月入库量区域分组集合
|
||||
List<JSONObject> monthInRegList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "15")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 所有当月出库量区域分组集合
|
||||
List<JSONObject> monthOutRegList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "16")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 所有当月入库量区域、客户分组集合
|
||||
List<JSONObject> monthCustInRegList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "17")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 所有当月出库量区域、客户分组集合
|
||||
List<JSONObject> monthCustOutRegList = WQL.getWO("AUTOQUERYBILLINFO").addParam("flag", "18")
|
||||
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// ---- 当月入库量 ----
|
||||
JSONObject monthRegIn = monthReg(monthInRegList, "当月入库量");
|
||||
Arrayobject5.add(monthRegIn);
|
||||
|
||||
// ---- 当月出库量 ----
|
||||
JSONObject monthRegOut = monthReg(monthOutRegList, "当月出库量");
|
||||
Arrayobject5.add(monthRegOut);
|
||||
|
||||
// ---- 昨日入库量 ----
|
||||
JSONObject yesterdayInReg = monthReg(yesterdayInRegList, "昨日入库量");
|
||||
Arrayobject5.add(yesterdayInReg);
|
||||
|
||||
// ---- 昨日出库量 ----
|
||||
JSONObject yesterdayOutReg = monthReg(yesterdayOutRegList, "昨日出库量");
|
||||
Arrayobject5.add(yesterdayOutReg);
|
||||
|
||||
// ---- B昨日出库量 ----
|
||||
JSONObject yesterdayCustOutRegB = monthRegCust(yesterdayCustOutRegList, "B昨日出库量", custB);
|
||||
Arrayobject5.add(yesterdayCustOutRegB);
|
||||
|
||||
// ---- B昨日入库量 ----
|
||||
JSONObject yesterdayCustInRegB = monthRegCust(yesterdayCustInRegList, "B昨日入库量", custB);
|
||||
Arrayobject5.add(yesterdayCustInRegB);
|
||||
|
||||
// ---- B当月入库量 ----
|
||||
JSONObject monthCustInRegB = monthRegCust(monthCustInRegList, "B当月入库量", custB);
|
||||
Arrayobject5.add(monthCustInRegB);
|
||||
|
||||
// ---- B当月出库量 ----
|
||||
JSONObject monthCustOutRegB = monthRegCust(monthCustOutRegList, "B当月出库量", custB);
|
||||
Arrayobject5.add(monthCustOutRegB);
|
||||
|
||||
// ---- C昨日出库量 ----
|
||||
JSONObject yesterdayCustOutRegC = monthRegCust(yesterdayCustOutRegList, "C昨日出库量", custC);
|
||||
Arrayobject5.add(yesterdayCustOutRegC);
|
||||
|
||||
// ---- C昨日入库量 ----
|
||||
JSONObject yesterdayCustInRegC = monthRegCust(yesterdayCustInRegList, "C昨日入库量", custC);
|
||||
Arrayobject5.add(yesterdayCustInRegC);
|
||||
|
||||
// ---- C当月入库量 ----
|
||||
JSONObject monthCustInRegC = monthRegCust(monthCustInRegList, "C当月入库量", custC);
|
||||
Arrayobject5.add(monthCustInRegC);
|
||||
|
||||
// ---- C当月出库量 ----
|
||||
JSONObject monthCustOutRegC = monthRegCust(monthCustOutRegList, "C当月出库量", custC);
|
||||
Arrayobject5.add(monthCustOutRegC);
|
||||
|
||||
result.put("Arrayobject5", Arrayobject5);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当月区域公共方法
|
||||
* @param param 、
|
||||
* @param title 、
|
||||
* @return JSONObject
|
||||
*/
|
||||
private JSONObject monthReg(List<JSONObject> param, String title) {
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("Title", title);
|
||||
|
||||
Map<String, List<JSONObject>> paramMap = param.stream()
|
||||
.collect(Collectors.groupingBy(row -> row.getString("region_code")));
|
||||
|
||||
if (paramMap.isEmpty()) {
|
||||
result.put("Areaqty1","0");
|
||||
result.put("Areaqty2","0");
|
||||
result.put("Areaqty3","0");
|
||||
result.put("Areaqty4","0");
|
||||
}
|
||||
|
||||
for (String region_code : paramMap.keySet()) {
|
||||
List<JSONObject> list = paramMap.get(region_code);
|
||||
|
||||
String num = NumberUtil.round(list.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2) + "";
|
||||
|
||||
switch (region_code) {
|
||||
case "A1": result.put("Areaqty1", num); break;
|
||||
case "A2": result.put("Areaqty2", num); break;
|
||||
case "A3": result.put("Areaqty3", num); break;
|
||||
case "A4": result.put("Areaqty4", num); break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(result.getString("Areaqty1"))) result.put("Areaqty1","0");
|
||||
if (ObjectUtil.isEmpty(result.getString("Areaqty2"))) result.put("Areaqty2","0");
|
||||
if (ObjectUtil.isEmpty(result.getString("Areaqty3"))) result.put("Areaqty3","0");
|
||||
if (ObjectUtil.isEmpty(result.getString("Areaqty4"))) result.put("Areaqty4","0");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当月区域、客户公共方法
|
||||
* @param param 、
|
||||
* @param title 、
|
||||
* @param customer 客户 、
|
||||
* @return JSONObject
|
||||
*/
|
||||
private JSONObject monthRegCust(List<JSONObject> param, String title, String customer) {
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("Title", title);
|
||||
|
||||
Map<String, List<JSONObject>> paramMap = param.stream()
|
||||
.collect(Collectors.groupingBy(row -> row.getString("region_code")));
|
||||
|
||||
if (paramMap.isEmpty()) {
|
||||
result.put("Areaqty1","0");
|
||||
result.put("Areaqty2","0");
|
||||
result.put("Areaqty3","0");
|
||||
result.put("Areaqty4","0");
|
||||
}
|
||||
|
||||
for (String region_code : paramMap.keySet()) {
|
||||
List<JSONObject> list = paramMap.get(region_code);
|
||||
|
||||
List<JSONObject> custList = list.stream()
|
||||
.filter(row -> customer.contains(row.getString("customer_name")))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
String num = NumberUtil.round(custList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 2) + "";
|
||||
|
||||
|
||||
switch (region_code) {
|
||||
case "A1": result.put("Areaqty1", num); break;
|
||||
case "A2": result.put("Areaqty2", num); break;
|
||||
case "A3": result.put("Areaqty3", num); break;
|
||||
case "A4": result.put("Areaqty4", num); break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(result.getString("Areaqty1"))) result.put("Areaqty1","0");
|
||||
if (ObjectUtil.isEmpty(result.getString("Areaqty2"))) result.put("Areaqty2","0");
|
||||
if (ObjectUtil.isEmpty(result.getString("Areaqty3"))) result.put("Areaqty3","0");
|
||||
if (ObjectUtil.isEmpty(result.getString("Areaqty4"))) result.put("Areaqty4","0");
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -76,4 +76,12 @@ public class ProductScrapController {
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PostMapping("/onSubmit")
|
||||
@Log("提交")
|
||||
@ApiOperation("提交")
|
||||
public ResponseEntity<Object> onSubmit(@RequestBody JSONObject whereJson) {
|
||||
productScrapService.onSubmit(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,4 +49,10 @@ public interface ProductScrapService {
|
||||
* @param whereJson /
|
||||
*/
|
||||
void auditOut(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 提交
|
||||
* @param whereJson /
|
||||
*/
|
||||
void onSubmit(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -16,10 +16,15 @@ import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.system.service.user.ISysUserService;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl;
|
||||
import org.nl.wms.ext.mes.service.impl.LmsToMesServiceImpl;
|
||||
import org.nl.wms.st.inbill.service.CheckOutBillService;
|
||||
import org.nl.wms.st.instor.service.ProductScrapService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -38,6 +43,9 @@ import java.util.stream.Collectors;
|
||||
public class ProductScrapServiceImpl implements ProductScrapService {
|
||||
private final CheckOutBillService checkOutBillService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService iSysUserService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> pageQuery(Map whereJson, Pageable page) {
|
||||
HashMap<String, String> map = new HashMap<>(whereJson);
|
||||
@@ -284,4 +292,150 @@ public class ProductScrapServiceImpl implements ProductScrapService {
|
||||
mst.update(param,"scrap_id = '"+whereJson.getString("scrap_id")+"'");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void onSubmit(JSONObject whereJson) {
|
||||
WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst");
|
||||
WQLObject dtl = WQLObject.getWQLObject("st_ivt_productscrapdtl");
|
||||
WQLObject sub = WQLObject.getWQLObject("pdm_bi_subpackagerelation");
|
||||
|
||||
List<JSONObject> dtlList = dtl.query("scrap_id = '" + whereJson.getString("scrap_id") + "'").getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
String package_box_in = dtlList.stream()
|
||||
.map(row -> row.getString("package_box_sn"))
|
||||
.distinct()
|
||||
.collect(Collectors.joining("','"));
|
||||
|
||||
// 子卷包装集合
|
||||
List<JSONObject> boxList = sub.query("package_box_sn in ('" + package_box_in + "')").getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 组织数据
|
||||
JSONObject param = new JSONObject(); // 主体
|
||||
param.put("approval_code", "E41632DA-E7BF-4230-B818-760FBFA0EB72"); // 固定值
|
||||
param.put("system", "LMS"); // 固定值
|
||||
|
||||
/*
|
||||
* 当前操作人员
|
||||
*/
|
||||
JSONArray userList = new JSONArray();
|
||||
JSONObject userJson = new JSONObject();
|
||||
|
||||
SysUser userDao = iSysUserService.getById(SecurityUtils.getCurrentUserId());
|
||||
userJson.put("User", userDao.getUsername()); // 当前操作人员code
|
||||
userList.add(userJson);
|
||||
|
||||
param.put("UserList", userList);
|
||||
|
||||
/*
|
||||
* form
|
||||
*/
|
||||
JSONArray formList = new JSONArray();
|
||||
|
||||
// 报废日期: 年月日时分
|
||||
JSONObject jsonDate = new JSONObject();
|
||||
jsonDate.put("id", "widget16989785636210001"); // 固定值
|
||||
jsonDate.put("type", "input"); // 固定值
|
||||
jsonDate.put("value", DateUtil.now().substring(0, 16));
|
||||
formList.add(jsonDate);
|
||||
|
||||
// 报废明细
|
||||
JSONObject jsonDtl = new JSONObject();
|
||||
jsonDtl.put("id", "widget16989759925050001"); // 固定值
|
||||
jsonDtl.put("type", "fieldList"); // 固定值
|
||||
|
||||
JSONArray valueArr = new JSONArray();
|
||||
|
||||
for (int i = 0; i < dtlList.size(); i++) {
|
||||
JSONObject json = dtlList.get(i);
|
||||
JSONArray dtlAtt = new JSONArray();
|
||||
|
||||
JSONObject jsonBox = boxList.stream()
|
||||
.filter(row -> row.getString("container_name").equals(json.getString("pcsn")))
|
||||
.collect(Collectors.toList()).get(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(jsonBox)) throw new BadRequestException("子卷"+json.getString("pcsn")+"不存在,请检查!");
|
||||
|
||||
// 产品名称
|
||||
JSONObject jsonName = new JSONObject();
|
||||
jsonName.put("id","widget16989761117830001");// 固定值
|
||||
jsonName.put("type","input");// 固定值
|
||||
jsonName.put("value",jsonBox.getString("product_description"));
|
||||
dtlAtt.add(jsonName);
|
||||
|
||||
// 产品规格
|
||||
JSONObject jsonThick = new JSONObject();
|
||||
jsonThick.put("id", "widget16989764299770001");// 固定值
|
||||
jsonThick.put("type", "input");// 固定值
|
||||
jsonThick.put("value", jsonBox.getString("thickness"));
|
||||
dtlAtt.add(jsonThick);
|
||||
|
||||
// 不合格品批次号
|
||||
JSONObject jsonOut = new JSONObject();
|
||||
jsonOut.put("id","widget16989764601080001");// 固定值
|
||||
jsonOut.put("type","input");// 固定值
|
||||
jsonOut.put("value",jsonBox.getString("container_name"));
|
||||
dtlAtt.add(jsonOut);
|
||||
|
||||
// 不合格品重量
|
||||
JSONObject jsonWeight = new JSONObject();
|
||||
jsonWeight.put("id", "widget16989773376540001");
|
||||
jsonWeight.put("type", "number");
|
||||
jsonWeight.put("value", json.getDoubleValue("qty"));
|
||||
dtlAtt.add(jsonWeight);
|
||||
|
||||
// 不合格品缺陷描述
|
||||
JSONObject jsonRemark = new JSONObject();
|
||||
jsonRemark.put("id", "widget16989773089460001");// 固定值
|
||||
jsonRemark.put("type", "input");// 固定值
|
||||
jsonRemark.put("value", json.getString("remark"));
|
||||
dtlAtt.add(jsonRemark);
|
||||
|
||||
// 不合格品来源
|
||||
JSONObject jsonSource = new JSONObject();
|
||||
jsonSource.put("id", "widget16989785808620001");
|
||||
jsonSource.put("type", "radioV2");
|
||||
|
||||
switch (json.getString("fail_source")) {
|
||||
case "1" :
|
||||
jsonSource.put("value", "lohzzb0f-dxucmbtkt5j-0");
|
||||
break;
|
||||
case "2" :
|
||||
jsonSource.put("value", "lohzzb0f-728pkzd3t0b-0");
|
||||
break;
|
||||
case "3" :
|
||||
jsonSource.put("value", "lohzzb0f-2d3n1nt9t5x-0");
|
||||
break;
|
||||
case "4" :
|
||||
jsonSource.put("value", "lohzzmz1-ai6w4202ynw-1");
|
||||
break;
|
||||
case "5" :
|
||||
jsonSource.put("value", "lohzzmz1-2d02yqh91t1-3");
|
||||
break;
|
||||
case "6" :
|
||||
jsonSource.put("value", "lohzzmz1-d0j15ri1jyg-5");
|
||||
break;
|
||||
}
|
||||
dtlAtt.add(jsonSource);
|
||||
|
||||
valueArr.add(dtlAtt);
|
||||
}
|
||||
|
||||
jsonDtl.put("value", valueArr);
|
||||
formList.add(jsonDtl);
|
||||
|
||||
param.put("form", formList);
|
||||
|
||||
/*
|
||||
* 调用mes接口,更新单据
|
||||
*/
|
||||
LmsToMesServiceImpl bean = SpringContextHolder.getBean(LmsToMesServiceImpl.class);
|
||||
JSONObject result = bean.scrapAudit(param);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("ext_code", result.getString("RTDAT"));
|
||||
jsonObject.put("bill_status", "20");
|
||||
mst.update(jsonObject,"scrap_id = '"+whereJson.getString("scrap_id")+"'");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user