rev 大屏首页需求数据
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -71,3 +71,86 @@
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT
|
||||
p.point_code AS device_code,
|
||||
p.point_name,
|
||||
p.point_status,
|
||||
p.region_code,
|
||||
p.point_type,
|
||||
p.vehicle_type,
|
||||
p.vehicle_code,
|
||||
p.sort_seq,
|
||||
vd.qty,
|
||||
vd.weight,
|
||||
vd.stand_status,
|
||||
vd.create_time,
|
||||
mb.material_number,
|
||||
mb.material_name,
|
||||
d.device_name,
|
||||
vd.in_kiln_time,
|
||||
vd.out_kiln_time
|
||||
FROM
|
||||
sch_base_point p
|
||||
LEFT JOIN st_ivt_vehicle_detail vd ON p.vd_id = vd.vd_id
|
||||
LEFT JOIN md_me_materialbase mb ON vd.material_id = mb.material_id
|
||||
LEFT JOIN pdm_bi_device d ON vd.kiln_number = d.device_code
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
QUERY
|
||||
SELECT
|
||||
wo.device_code,
|
||||
mb.material_number
|
||||
FROM
|
||||
pdm_bd_workorder wo
|
||||
LEFT JOIN md_me_materialbase mb ON wo.material_id = mb.material_id
|
||||
WHERE
|
||||
wo.is_delete = '0'
|
||||
AND wo.order_status = '3'
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "5"
|
||||
QUERY
|
||||
SELECT
|
||||
wo.device_code,
|
||||
mb.material_name,
|
||||
wo.kh,
|
||||
SUM(wod.weight) AS weight,
|
||||
SUM(wod.qty) AS qty
|
||||
FROM
|
||||
pdm_bd_work_order_daily wod
|
||||
LEFT JOIN pdm_bd_workorder wo ON wod.workorder_id = wo.workorder_id
|
||||
LEFT JOIN md_me_materialbase mb ON wo.material_id = mb.material_id
|
||||
WHERE
|
||||
TO_DAYS(wod.date) = TO_DAYS(NOW())
|
||||
GROUP BY
|
||||
wod.workorder_id, TO_DAYS(wod.date)
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "6"
|
||||
QUERY
|
||||
SELECT
|
||||
vd.qty,
|
||||
mb.material_name,
|
||||
wo.kh,
|
||||
wo.device_code
|
||||
FROM
|
||||
st_ivt_vehicle_detail vd
|
||||
LEFT JOIN md_me_materialbase mb ON vd.material_id = mb.material_id
|
||||
LEFT JOIN pdm_bd_workorder wo ON vd.workorder_id = wo.workorder_id
|
||||
WHERE
|
||||
vd.is_delete = '0'
|
||||
AND vd.vehicle_type = '2'
|
||||
AND TO_DAYS(vd.out_kiln_time) = TO_DAYS(NOW())
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -221,4 +221,12 @@ public class AcsToWmsController {
|
||||
public ResponseEntity<JSONObject> fjNeed(@RequestBody JSONObject param) {
|
||||
return ResponseEntity.ok(acsToWmsService.fjNeed(param));
|
||||
}
|
||||
|
||||
@PostMapping("/equipmentFailure")
|
||||
@Log("设备故障")
|
||||
@ApiOperation("设备故障")
|
||||
@SaIgnore
|
||||
public void equipmentFailure(@RequestBody JSONObject param) {
|
||||
acsToWmsService.equipmentFailure(param);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,4 +116,6 @@ public interface AcsToWmsService {
|
||||
JSONObject fjCallEmpty(JSONObject param);
|
||||
|
||||
JSONObject fjNeed(JSONObject param);
|
||||
|
||||
void equipmentFailure(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -1098,9 +1098,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
regionIn.put("id", IdUtil.getSnowflake(1L, 1L).nextId());
|
||||
regionIn.put("cCode", CodeUtil.getNewCode("IN_STORE_CODE"));
|
||||
regionIn.put("dDate", DateUtil.now());
|
||||
regionIn.put("cVouchType", RegionInType.BCPRK.label());
|
||||
regionIn.put("cVouchType", RegionInType.WGRK.label());
|
||||
regionIn.put("cMocode", dd);
|
||||
regionIn.put("cInvCode", detail.getString("material_number"));
|
||||
String materialNumber = detail.getString("material_number");
|
||||
if (materialNumber.startsWith("W")) {
|
||||
materialNumber = "F" + materialNumber.substring(1);
|
||||
}
|
||||
regionIn.put("cInvCode", materialNumber);
|
||||
regionIn.put("iQuantity", String.format("%.3f", detail.getDoubleValue("weight") / 1000));
|
||||
regionIn.put("iNum", detail.getIntValue("qty"));
|
||||
regionIn.put("iinvexchrate", String.format("%.5f", detail.getDoubleValue("dz") / 1000));
|
||||
@@ -1177,9 +1181,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
regionIn.put("id", IdUtil.getSnowflake(1L, 1L).nextId());
|
||||
regionIn.put("cCode", CodeUtil.getNewCode("IN_STORE_CODE"));
|
||||
regionIn.put("dDate", DateUtil.now());
|
||||
regionIn.put("cVouchType", RegionInType.BCPRK.label());
|
||||
regionIn.put("cVouchType", RegionInType.WGRK.label());
|
||||
regionIn.put("cMocode", dd);
|
||||
regionIn.put("cInvCode", detail.getString("material_number"));
|
||||
String materialNumber = detail.getString("material_number");
|
||||
if (materialNumber.startsWith("W")) {
|
||||
materialNumber = "F" + materialNumber.substring(1);
|
||||
}
|
||||
regionIn.put("cInvCode", materialNumber);
|
||||
regionIn.put("iQuantity", String.format("%.3f", detail.getDoubleValue("weight2") / 1000));
|
||||
regionIn.put("iNum", detail.getIntValue("qty2"));
|
||||
regionIn.put("iinvexchrate", String.format("%.5f", detail.getDoubleValue("dz") / 1000));
|
||||
@@ -1256,4 +1264,16 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
result.put("message", "反馈成功!");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void equipmentFailure(JSONObject param) {
|
||||
String deviceCode = param.getString("device_code");
|
||||
if (StrUtil.isNotBlank(deviceCode)) {
|
||||
JSONObject dn = new JSONObject();
|
||||
dn.put("data_id", IdUtil.getSnowflake().nextId());
|
||||
dn.put("device_code", deviceCode);
|
||||
dn.put("failure_time", DateUtil.now());
|
||||
WQLObject.getWQLObject("das_device_number").insert(dn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,13 +89,7 @@ public class PdaController {
|
||||
throw new BadRequestException("载具编码不能为空!");
|
||||
}
|
||||
int qty = param.getIntValue("qty");
|
||||
if (qty == 0) {
|
||||
throw new BadRequestException("数量不能为零!");
|
||||
}
|
||||
double weight = param.getDoubleValue("weight");
|
||||
if (weight == 0) {
|
||||
throw new BadRequestException("重量不能为零!");
|
||||
}
|
||||
|
||||
pdaService.sendMaterial(point_code, vehicle_code, qty, weight, param.toJSONString());
|
||||
return PdaUtils.buildSuccessResultJSON(null);
|
||||
|
||||
@@ -696,10 +696,10 @@ public class WorkorderServiceImpl implements WorkordeService {
|
||||
workOrder.put("qualified_qty", workOrderDailyList.stream().mapToInt(o -> ((JSONObject) o).getIntValue("qualified_qty")).sum());
|
||||
workOrder.put("unqualified_qty", workOrderDailyList.stream().mapToInt(o -> ((JSONObject) o).getIntValue("unqualified_qty")).sum());
|
||||
workOrder.put("avg_piece_weight", workOrderDailyList.stream().mapToDouble(o -> ((JSONObject) o).getDoubleValue("avg_piece_weight")).sum() / workOrderDailyList.size());
|
||||
workOrder.put("order_status", WorkOrderEnum.ORDER_STATUS_STOP.value());
|
||||
TaskUtils.addACSUpdateColum(workOrder);
|
||||
workOrderTable.update(workOrder);
|
||||
}
|
||||
workOrder.put("order_status", WorkOrderEnum.ORDER_STATUS_STOP.value());
|
||||
TaskUtils.addACSUpdateColum(workOrder);
|
||||
workOrderTable.update(workOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -722,9 +722,9 @@ public class WorkorderServiceImpl implements WorkordeService {
|
||||
workOrder.put("qualified_qty", workOrderDailyList.stream().mapToInt(o -> ((JSONObject) o).getIntValue("qualified_qty")).sum());
|
||||
workOrder.put("unqualified_qty", workOrderDailyList.stream().mapToInt(o -> ((JSONObject) o).getIntValue("unqualified_qty")).sum());
|
||||
workOrder.put("avg_piece_weight", workOrderDailyList.stream().mapToDouble(o -> ((JSONObject) o).getDoubleValue("avg_piece_weight")).sum() / workOrderDailyList.size());
|
||||
workOrder.put("order_status", WorkOrderEnum.ORDER_STATUS_FINISH.value());
|
||||
TaskUtils.addACSUpdateColum(workOrder);
|
||||
workOrderTable.update(workOrder);
|
||||
}
|
||||
workOrder.put("order_status", WorkOrderEnum.ORDER_STATUS_FINISH.value());
|
||||
TaskUtils.addACSUpdateColum(workOrder);
|
||||
workOrderTable.update(workOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package org.nl.wms.sch.manage;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
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.wms.basedata.eum.TrueOrFalse;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.sch.task.util.TaskUtils;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author zhangjiangwei
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Component("autoUpdateWorkOrder")
|
||||
@SuppressWarnings("unused")
|
||||
public class AutoUpdateWorkOrder {
|
||||
|
||||
private final WmsToAcsService wmsToAcsService;
|
||||
|
||||
private final RedissonClient redissonClient;
|
||||
|
||||
@SneakyThrows
|
||||
public void run() {
|
||||
RLock lock = redissonClient.getFairLock("autoUpdateWorkOrder");
|
||||
boolean tryLock = false;
|
||||
try {
|
||||
tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
if (tryLock) {
|
||||
|
||||
JSONArray wo = WQL.getWO("MANAGE_QUERY").addParam("flag", "3").process().getResultJSONArray(0);
|
||||
|
||||
JSONObject responseBody = wmsToAcsService.getDeviceStatus(wo);
|
||||
if ("200".equals(responseBody.getString("status"))) {
|
||||
JSONArray data = responseBody.getJSONArray("data");
|
||||
if (ObjectUtil.isNotEmpty(data)) {
|
||||
WQLObject wodTable = WQLObject.getWQLObject("pdm_bd_work_order_daily");
|
||||
String today = DateUtil.today();
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject datum = data.getJSONObject(i);
|
||||
|
||||
long workOrderId = datum.getLongValue("workorder_id");
|
||||
JSONObject wod = wodTable.query("workorder_id = " + workOrderId + " AND date = '" + today + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(wod)) {
|
||||
wod = new JSONObject();
|
||||
wod.put("id", IdUtil.getSnowflake().nextId());
|
||||
wod.put("date", today);
|
||||
wod.put("workorder_id", workOrderId);
|
||||
wod.put("qty", datum.getIntValue("qty"));
|
||||
wod.put("qualified_qty", datum.getIntValue("qualified_qty"));
|
||||
wod.put("unqualified_qty", datum.getIntValue("unqualified_qty"));
|
||||
wod.put("weight", datum.getDoubleValue("weight"));
|
||||
wod.put("avg_piece_weight", datum.getDoubleValue("avg_piece_weight") / 1000);
|
||||
TaskUtils.addAutoCreateColum(wod);
|
||||
wodTable.insert(wod);
|
||||
} else {
|
||||
if (TrueOrFalse.TRUE.value().equals(wod.getString("is_report"))) {
|
||||
wod.put("qty", datum.getIntValue("qty") + wod.getIntValue("qty"));
|
||||
wod.put("qualified_qty", datum.getIntValue("qualified_qty") + wod.getIntValue("qualified_qty"));
|
||||
wod.put("unqualified_qty", datum.getIntValue("unqualified_qty") + wod.getIntValue("unqualified_qty"));
|
||||
wod.put("weight", datum.getDoubleValue("weight") + wod.getIntValue("weight"));
|
||||
wod.put("avg_piece_weight", datum.getDoubleValue("avg_piece_weight") / 1000);
|
||||
TaskUtils.addAutoUpdateColum(wod);
|
||||
wodTable.update(wod);
|
||||
} else {
|
||||
wod.put("qty", datum.getIntValue("qty"));
|
||||
wod.put("qualified_qty", datum.getIntValue("qualified_qty"));
|
||||
wod.put("unqualified_qty", datum.getIntValue("unqualified_qty"));
|
||||
wod.put("weight", datum.getDoubleValue("weight"));
|
||||
wod.put("avg_piece_weight", datum.getDoubleValue("avg_piece_weight") / 1000);
|
||||
TaskUtils.addAutoUpdateColum(wod);
|
||||
wodTable.update(wod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("auto update work order error !", e);
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package org.nl.wms.sch.manage;
|
||||
|
||||
/**
|
||||
* @author zhangjiangwei
|
||||
*/
|
||||
public class AutoUpdateWorkOrderDaily {
|
||||
}
|
||||
@@ -69,3 +69,19 @@
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT
|
||||
wo.workorder_id,
|
||||
d.device_code
|
||||
FROM
|
||||
pdm_bd_workorder wo
|
||||
LEFT JOIN pdm_bi_device d ON wo.device_id = d.device_id
|
||||
WHERE
|
||||
wo.is_delete = '0'
|
||||
AND wo.order_status = '3'
|
||||
AND d.region_code IN ('YZ', 'FJ')
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -164,4 +164,10 @@ public class TaskUtils {
|
||||
row.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
row.put("create_time", DateUtil.now());
|
||||
}
|
||||
|
||||
public static void addAutoCreateColum(JSONObject row) {
|
||||
row.put("create_id", AutoCreate.id);
|
||||
row.put("create_name", AutoCreate.nick_name);
|
||||
row.put("create_time", DateUtil.now());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ spring:
|
||||
freemarker:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
active: prod
|
||||
active: dev
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
data:
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.test;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -9,6 +10,9 @@ import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author zhangjiangwei
|
||||
* @date 2023/03/02 16:54
|
||||
@@ -19,26 +23,13 @@ public class PointTest {
|
||||
|
||||
@Test
|
||||
public void test01() {
|
||||
JSONObject point = new JSONObject();
|
||||
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
|
||||
String now = DateUtil.now();
|
||||
for (int i = 1; i <= 9; i++) {
|
||||
if (i == 7) {
|
||||
continue;
|
||||
}
|
||||
point.put("point_id", IdUtil.getSnowflake(1L, 1L).nextId());
|
||||
point.put("point_code", "YJ" + String.format("%02d", i) + "SL01");
|
||||
point.put("point_name", "压机" + i + "上料位");
|
||||
point.put("point_type", "2");
|
||||
point.put("region_id", 1695713335233875968L);
|
||||
point.put("region_code", "YZ");
|
||||
point.put("region_name", "压制区");
|
||||
point.put("device_code", "YJ" + String.format("%02d", i));
|
||||
point.put("lock_type", "1");
|
||||
point.put("create_id", 1);
|
||||
point.put("create_name", "管理员");
|
||||
point.put("create_time", now);
|
||||
point_table.insert(point);
|
||||
JSONArray jsonArray = WQLObject.getWQLObject("sch_base_point").query("region_code = 'YHHJ'").getResultJSONArray(0);
|
||||
List<Object> list = jsonArray.stream().sorted((o1, o2) -> Integer.compare(((JSONObject) o1).getIntValue("sort_seq"), ((JSONObject) o2).getIntValue("sort_seq"))).collect(Collectors.toList());
|
||||
JSONArray a1 = new JSONArray();
|
||||
for (Object o : list) {
|
||||
a1.add(o);
|
||||
}
|
||||
|
||||
System.out.println(a1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user