add: 成品日报接口
This commit is contained in:
@@ -105,4 +105,11 @@ public class LmsToMesController {
|
|||||||
public ResponseEntity<Object> scrapAudit(@RequestBody JSONObject jo) {
|
public ResponseEntity<Object> scrapAudit(@RequestBody JSONObject jo) {
|
||||||
return new ResponseEntity<>(lmsToMesService.scrapAudit(jo), HttpStatus.OK);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,4 +116,10 @@ public interface LmsToMesService {
|
|||||||
* 参数:
|
* 参数:
|
||||||
*/
|
*/
|
||||||
JSONObject scrapAudit(JSONObject jo);
|
JSONObject scrapAudit(JSONObject jo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成品日报推送
|
||||||
|
* 参数:
|
||||||
|
*/
|
||||||
|
JSONObject proudDayData(JSONObject jo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -636,6 +636,43 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} 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) {
|
} catch (Exception e) {
|
||||||
throw new BadRequestException("飞书提示错误:" + e.getMessage());
|
throw new BadRequestException("飞书提示错误:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,4 +63,12 @@ public class LmsToBigScreenController {
|
|||||||
return new ResponseEntity<>(LmsToBigScreenService.getMonthDelivery(jo), HttpStatus.OK);
|
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 getMonthFreight(JSONObject jo);
|
||||||
JSONArray getMonthYield(JSONObject jo);
|
JSONArray getMonthYield(JSONObject jo);
|
||||||
JSONArray getMonthDelivery(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.system.service.param.impl.SysParamServiceImpl;
|
||||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||||
import org.nl.wms.ext.szls.service.LmsToBigScreenService;
|
import org.nl.wms.ext.szls.service.LmsToBigScreenService;
|
||||||
|
import org.nl.wms.sch.manage.AutoQueryProudDayData;
|
||||||
import org.nl.wms.sch.tasks.URLEnum;
|
import org.nl.wms.sch.tasks.URLEnum;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@@ -107,4 +108,9 @@ public class LmsToBigScreenServiceImpl implements LmsToBigScreenService {
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getProudDayData(JSONObject jo) {
|
||||||
|
return SpringContextHolder.getBean(AutoQueryProudDayData.class).data();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ public class ProductInstorServiceImpl implements ProductInstorService {
|
|||||||
//创建二楼去一楼的任务
|
//创建二楼去一楼的任务
|
||||||
JSONObject form = new JSONObject();
|
JSONObject form = new JSONObject();
|
||||||
form.put("point_code1", point_code);
|
form.put("point_code1", point_code);
|
||||||
form.put("point_code2", "NTB01");
|
form.put("point_code2", "1001");
|
||||||
form.put("vehicle_code", box_no);
|
form.put("vehicle_code", box_no);
|
||||||
form.put("task_type", "010507");
|
form.put("task_type", "010507");
|
||||||
cutConveyorTask.createTask(form);
|
cutConveyorTask.createTask(form);
|
||||||
|
|||||||
@@ -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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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 ) 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,519 @@
|
|||||||
|
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());
|
||||||
|
|
||||||
|
System.out.println(param.toString());
|
||||||
|
|
||||||
|
// 调用接口
|
||||||
|
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()+"成品数据");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 查询各仓库库存
|
||||||
|
*/
|
||||||
|
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() ? "0KG" : NumberUtil.round(collect.get(0).getString("num"), 3)+"KG");
|
||||||
|
|
||||||
|
// 超期库存
|
||||||
|
List<JSONObject> collect2 = sidIvtList.stream()
|
||||||
|
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
json.put("OverdueInventory", collect2.isEmpty() ? "0KG" : NumberUtil.round(collect2.get(0).getString("num"),3)+"KG");
|
||||||
|
|
||||||
|
// 临期库存
|
||||||
|
List<JSONObject> collect3 = faceIvtList.stream()
|
||||||
|
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
json.put("InterimInventory", collect3.isEmpty() ? "0KG" : NumberUtil.round(collect3.get(0).getString("num"),3)+"KG");
|
||||||
|
|
||||||
|
// 正常库存
|
||||||
|
List<JSONObject> collect4 = regIvtList.stream()
|
||||||
|
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
json.put("NormalStockAge", collect4.isEmpty() ? "0KG" : NumberUtil.round(collect4.get(0).getString("num"),3)+"KG");
|
||||||
|
|
||||||
|
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(), 3)+"KG");
|
||||||
|
allIvt.put("OverdueInventory", NumberUtil.round(sidIvtList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 3)+"KG");
|
||||||
|
allIvt.put("InterimInventory", NumberUtil.round(faceIvtList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 3)+"KG");
|
||||||
|
allIvt.put("NormalStockAge", NumberUtil.round(regIvtList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 3)+"KG");
|
||||||
|
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() ? "0KG" : NumberUtil.round(collectB.get(0).getString("num"), 3)+"KG");
|
||||||
|
|
||||||
|
// 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() ? "0KG" : NumberUtil.round(collectC.get(0).getString("num"), 3)+"KG");
|
||||||
|
|
||||||
|
// 其他库存
|
||||||
|
List<JSONObject> collectOthen = custIvtOtherList.stream()
|
||||||
|
.filter(row -> row.getString("stor_id").equals(item.getString("stor_id")))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
json.put("Customernventory3", collectOthen.isEmpty() ? "0KG" : NumberUtil.round(collectOthen.get(0).getString("num"), 3)+"KG");
|
||||||
|
|
||||||
|
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(), 3)+"KG");
|
||||||
|
allCustIvt.put("Customernventory2", NumberUtil.round(custIvtCList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 3)+"KG");
|
||||||
|
allCustIvt.put("Customernventory3", NumberUtil.round(custIvtOtherList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 3)+"KG");
|
||||||
|
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(), 3)+"KG");
|
||||||
|
|
||||||
|
// 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(), 3)+"KG");
|
||||||
|
|
||||||
|
// 汇总
|
||||||
|
yesterdayIn.put("Customerqty3", NumberUtil.round(yesterdayInList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 3)+"KG");
|
||||||
|
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(), 3)+"KG");
|
||||||
|
|
||||||
|
// 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(), 3)+"KG");
|
||||||
|
|
||||||
|
// 汇总
|
||||||
|
yesterdayOut.put("Customerqty3", NumberUtil.round(yesterdayOutList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 3)+"KG");
|
||||||
|
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(), 3)+"KG");
|
||||||
|
|
||||||
|
// 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(), 3)+"KG");
|
||||||
|
|
||||||
|
// 汇总
|
||||||
|
monthdayIn.put("Customerqty3", NumberUtil.round(monthInList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 3)+"KG");
|
||||||
|
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(), 3)+"KG");
|
||||||
|
|
||||||
|
// 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(), 3)+"KG");
|
||||||
|
|
||||||
|
// 汇总
|
||||||
|
monthdayOut.put("Customerqty3",NumberUtil.round( monthOutList.stream().map(row -> row.getDoubleValue("num")).reduce(Double::sum).orElse(0.0).toString(), 3)+"KG");
|
||||||
|
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","0KG");
|
||||||
|
result.put("Areaqty2","0KG");
|
||||||
|
result.put("Areaqty3","0KG");
|
||||||
|
result.put("Areaqty4","0KG");
|
||||||
|
}
|
||||||
|
|
||||||
|
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(), 3) + "KG";
|
||||||
|
|
||||||
|
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","0KG");
|
||||||
|
if (ObjectUtil.isEmpty(result.getString("Areaqty2"))) result.put("Areaqty2","0KG");
|
||||||
|
if (ObjectUtil.isEmpty(result.getString("Areaqty3"))) result.put("Areaqty3","0KG");
|
||||||
|
if (ObjectUtil.isEmpty(result.getString("Areaqty4"))) result.put("Areaqty4","0KG");
|
||||||
|
|
||||||
|
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","0KG");
|
||||||
|
result.put("Areaqty2","0KG");
|
||||||
|
result.put("Areaqty3","0KG");
|
||||||
|
result.put("Areaqty4","0KG");
|
||||||
|
}
|
||||||
|
|
||||||
|
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(), 3) + "KG";
|
||||||
|
|
||||||
|
|
||||||
|
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","0KG");
|
||||||
|
if (ObjectUtil.isEmpty(result.getString("Areaqty2"))) result.put("Areaqty2","0KG");
|
||||||
|
if (ObjectUtil.isEmpty(result.getString("Areaqty3"))) result.put("Areaqty3","0KG");
|
||||||
|
if (ObjectUtil.isEmpty(result.getString("Areaqty4"))) result.put("Areaqty4","0KG");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user