27 changed files with 858 additions and 192 deletions
@ -0,0 +1,47 @@ |
|||||
|
package org.nl.wms.dashboard.rest; |
||||
|
|
||||
|
import cn.dev33.satoken.annotation.SaIgnore; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.nl.modules.logging.annotation.Log; |
||||
|
import org.nl.wms.dashboard.service.DashboardService; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* @author zhangjiangwei |
||||
|
*/ |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/api/dashboard") |
||||
|
@Api(tags = "大屏") |
||||
|
@SaIgnore |
||||
|
public class DashboardController { |
||||
|
|
||||
|
private final DashboardService dashboardService; |
||||
|
|
||||
|
@PostMapping("/homepageDataLeft") |
||||
|
@Log("大屏首页报表(左)") |
||||
|
@ApiOperation("大屏首页报表(左)") |
||||
|
public ResponseEntity<Object> homepageDataLeft(){ |
||||
|
return new ResponseEntity<>(dashboardService.homepageDataLeft(), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/homepageDataRight") |
||||
|
@Log("大屏首页报表(右)") |
||||
|
@ApiOperation("大屏首页报表(右)") |
||||
|
public ResponseEntity<Object> homepageDataRight(){ |
||||
|
return new ResponseEntity<>(dashboardService.homepageDataRight(), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/homepageEquipment") |
||||
|
@Log("大屏首页设备") |
||||
|
@ApiOperation("大屏首页设备") |
||||
|
public ResponseEntity<Object> homepageEquipment(){ |
||||
|
return new ResponseEntity<>(dashboardService.homepageEquipment(), HttpStatus.OK); |
||||
|
} |
||||
|
} |
@ -0,0 +1,335 @@ |
|||||
|
package org.nl.wms.dashboard.service; |
||||
|
|
||||
|
import cn.hutool.core.date.DateTime; |
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import com.alibaba.fastjson.JSONArray; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.nl.modules.wql.WQL; |
||||
|
import org.nl.modules.wql.core.bean.WQLObject; |
||||
|
import org.nl.wms.ext.acs.service.WmsToAcsService; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @author zhangjiangwei |
||||
|
*/ |
||||
|
@RequiredArgsConstructor |
||||
|
@Service |
||||
|
public class DashboardService { |
||||
|
|
||||
|
private final WmsToAcsService wmsToAcsService; |
||||
|
|
||||
|
/** |
||||
|
* 大屏首页报表(左) |
||||
|
* |
||||
|
* @return 大屏首页报表数据(左) |
||||
|
*/ |
||||
|
public JSONObject homepageDataLeft() { |
||||
|
JSONObject result = new JSONObject(); |
||||
|
|
||||
|
List<JSONObject> todayPlanWorkOrders = WQL.getWO("DASHBOARD").addParam("flag", "1").process().getResultJSONArray(0).stream().map(o -> (JSONObject) o).collect(Collectors.toList()); |
||||
|
List<JSONObject> existVDs = WQL.getWO("DASHBOARD").addParam("flag", "2").process().getResultJSONArray(0).stream().map(o -> (JSONObject) o).collect(Collectors.toList()); |
||||
|
|
||||
|
// 今日生产 -----------------------------------------------------------------------------------------------------
|
||||
|
JSONObject todayProduction = new JSONObject(); |
||||
|
result.put("todayProduction", todayProduction); |
||||
|
|
||||
|
// 订单完成
|
||||
|
JSONObject orderFulfillmentRate = new JSONObject(); |
||||
|
todayProduction.put("orderFulfillmentRate", orderFulfillmentRate); |
||||
|
orderFulfillmentRate.put("plan", todayPlanWorkOrders.stream().mapToInt(o -> o.getIntValue("plan_qty")).sum()); |
||||
|
orderFulfillmentRate.put("real", todayPlanWorkOrders.stream().mapToInt(o -> o.getIntValue("real_qty")).sum()); |
||||
|
|
||||
|
// 混料
|
||||
|
JSONObject todayMixProduction = new JSONObject(); |
||||
|
todayProduction.put("todayMixProduction", todayMixProduction); |
||||
|
todayMixProduction.put("plan", todayPlanWorkOrders.stream().filter(o -> "HL".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("plan_qty")).sum() / 1000.00); |
||||
|
todayMixProduction.put("real", todayPlanWorkOrders.stream().filter(o -> "HL".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("real_qty")).sum() / 1000.00); |
||||
|
|
||||
|
// 成型
|
||||
|
JSONObject todayPressProduction = new JSONObject(); |
||||
|
todayProduction.put("todayPressProduction", todayPressProduction); |
||||
|
todayPressProduction.put("plan", todayPlanWorkOrders.stream().filter(o -> "YZ".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("plan_qty")).sum()); |
||||
|
todayPressProduction.put("real", todayPlanWorkOrders.stream().filter(o -> "YZ".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("real_qty")).sum()); |
||||
|
|
||||
|
// 包装
|
||||
|
JSONObject todaySortProduction = new JSONObject(); |
||||
|
todayProduction.put("todaySortProduction", todaySortProduction); |
||||
|
todaySortProduction.put("plan", todayPlanWorkOrders.stream().filter(o -> "FJ".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("plan_qty")).sum()); |
||||
|
todaySortProduction.put("real", todayPlanWorkOrders.stream().filter(o -> "FJ".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("real_qty")).sum()); |
||||
|
|
||||
|
// 信息
|
||||
|
int todayTotalPlan = todayPressProduction.getIntValue("plan") + todaySortProduction.getIntValue("plan"); |
||||
|
JSONObject materialCount = new JSONObject(); |
||||
|
for (JSONObject todayPlanWorkOrder : todayPlanWorkOrders) { |
||||
|
materialCount.put(todayPlanWorkOrder.getString("material_id"), 1); |
||||
|
} |
||||
|
List<JSONObject> todaySortVDs = existVDs.stream().filter(o -> "FJ".equals(o.getString("region_code")) && DateUtil.isSameDay(DateUtil.date(), DateUtil.parseDate(o.getString("create_time")))).collect(Collectors.toList()); |
||||
|
int sortCompleted = todaySortVDs.size(); |
||||
|
int sortCompletedQty = todaySortVDs.stream().mapToInt(o -> o.getIntValue("qty")).sum(); |
||||
|
JSONObject sortMaterialCount = new JSONObject(); |
||||
|
for (JSONObject sortVD : todaySortVDs) { |
||||
|
sortMaterialCount.put(sortVD.getString("material_id"), 1); |
||||
|
} |
||||
|
int fulfillmentRate = orderFulfillmentRate.getDoubleValue("plan") == 0.00 ? 100 : (int) (orderFulfillmentRate.getDoubleValue("real") / orderFulfillmentRate.getDoubleValue("plan") * 100); |
||||
|
todayProduction.put("message", "今日共需生产" + todayTotalPlan + "块,物料种类" + materialCount.size() + "种,已完成包装" + sortCompleted + "托,共" + sortCompletedQty + "块," + sortMaterialCount.size() + "个物料,完成率" + fulfillmentRate + "%。"); |
||||
|
|
||||
|
// 当日混料 -----------------------------------------------------------------------------------------------------
|
||||
|
Map<String, JSONObject> todayMixMaterialPlan = new HashMap<>(); |
||||
|
List<JSONObject> todayMixPlanWorkOrders = todayPlanWorkOrders.stream().filter(o -> "HL".equals(o.getString("region_code"))).collect(Collectors.toList()); |
||||
|
for (JSONObject wo : todayMixPlanWorkOrders) { |
||||
|
JSONObject temp = new JSONObject(); |
||||
|
temp.put("materialCode", wo.getString("material_code")); |
||||
|
temp.put("plan", wo.getDoubleValue("plan_qty") / 1000.00); |
||||
|
temp.put("real", wo.getDoubleValue("real_qty") / 1000.00); |
||||
|
todayMixMaterialPlan.merge(wo.getString("material_id"), temp, (o1, o2) -> { |
||||
|
o1.put("plan", o1.getDoubleValue("plan") + o2.getDoubleValue("plan")); |
||||
|
o1.put("real", o1.getDoubleValue("real") + o2.getDoubleValue("real")); |
||||
|
return o1; |
||||
|
}); |
||||
|
} |
||||
|
result.put("todayMix", todayMixMaterialPlan.values().stream().sorted((o1, o2) -> -(Double.compare(o1.getDoubleValue("real"), o2.getDoubleValue("real")))).limit(7L).collect(Collectors.toList())); |
||||
|
|
||||
|
// 当日成品 -----------------------------------------------------------------------------------------------------
|
||||
|
Map<String, JSONObject> todaySortMaterialPlan = new HashMap<>(); |
||||
|
List<JSONObject> todaySortPlanWorkOrders = todayPlanWorkOrders.stream().filter(o -> "FJ".equals(o.getString("region_code"))).collect(Collectors.toList()); |
||||
|
List<JSONObject> todayPressPlanWorkOrders = todayPlanWorkOrders.stream().filter(o -> "YZ".equals(o.getString("region_code"))).collect(Collectors.toList()); |
||||
|
for (JSONObject wo : todaySortPlanWorkOrders) { |
||||
|
JSONObject temp = new JSONObject(); |
||||
|
temp.put("materialCode", wo.getString("material_code")); |
||||
|
temp.put("plan", wo.getDoubleValue("plan_qty")); |
||||
|
temp.put("real", wo.getDoubleValue("real_qty")); |
||||
|
temp.put("press", todayPressPlanWorkOrders.stream().filter(o -> wo.getString("material_id").equals(o.getString("material_id"))).mapToInt(o -> o.getIntValue("real_qty")).sum()); |
||||
|
todaySortMaterialPlan.merge(wo.getString("material_id"), temp, (o1, o2) -> { |
||||
|
o1.put("plan", o1.getDoubleValue("plan") + o2.getDoubleValue("plan")); |
||||
|
o1.put("real", o1.getDoubleValue("real") + o2.getDoubleValue("real")); |
||||
|
return o1; |
||||
|
}); |
||||
|
} |
||||
|
result.put("todaySort", todaySortMaterialPlan.values().stream().sorted((o1, o2) -> -(Double.compare(o1.getDoubleValue("real"), o2.getDoubleValue("real")))).limit(7L).collect(Collectors.toList())); |
||||
|
|
||||
|
// 库存量监控 ---------------------------------------------------------------------------------------------------
|
||||
|
List<JSONObject> pressVDs = existVDs.stream().filter(o -> "YZ".equals(o.getString("region_code"))).collect(Collectors.toList()); |
||||
|
Map<String, JSONObject> inventory = new HashMap<>(); |
||||
|
for (JSONObject vd : pressVDs) { |
||||
|
JSONObject temp = new JSONObject(); |
||||
|
temp.put("materialCode", vd.getString("material_code")); |
||||
|
temp.put("qty", vd.getDoubleValue("qty")); |
||||
|
inventory.merge(vd.getString("material_id"), temp, (o1, o2) -> { |
||||
|
o1.put("qty", o1.getDoubleValue("qty") + o2.getDoubleValue("qty")); |
||||
|
return o1; |
||||
|
}); |
||||
|
} |
||||
|
result.put("inventory", todaySortMaterialPlan.values().stream().sorted((o1, o2) -> -(Double.compare(o1.getDoubleValue("qty"), o2.getDoubleValue("qty")))).limit(7L).collect(Collectors.toList())); |
||||
|
|
||||
|
// 历史分析 -----------------------------------------------------------------------------------------------------
|
||||
|
JSONArray history = new JSONArray(); |
||||
|
result.put("history", history); |
||||
|
for (int i = 6; i >= 0; i--) { |
||||
|
JSONObject temp = new JSONObject(); |
||||
|
DateTime date = DateUtil.offsetDay(DateUtil.date(), -i); |
||||
|
temp.put("date", DateUtil.format(date, "M月d日")); |
||||
|
temp.put("press", existVDs.stream().filter(o -> "YZ".equals(o.getString("region_code")) && DateUtil.isSameDay(date, DateUtil.parseDate(o.getString("create_time")))).mapToInt(o -> o.getIntValue("qty")).sum()); |
||||
|
temp.put("sort", existVDs.stream().filter(o -> "FJ".equals(o.getString("region_code")) && DateUtil.isSameDay(date, DateUtil.parseDate(o.getString("create_time")))).mapToInt(o -> o.getIntValue("qty")).sum()); |
||||
|
history.add(temp); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 大屏首页报表(右) |
||||
|
* |
||||
|
* @return 大屏首页报表数据(右) |
||||
|
*/ |
||||
|
public JSONObject homepageDataRight() { |
||||
|
JSONObject result = new JSONObject(); |
||||
|
|
||||
|
JSONArray devices = WQLObject.getWQLObject("pdm_bi_device").query("is_delete = '0'").getResultJSONArray(0); |
||||
|
JSONObject deviceStatus = wmsToAcsService.getDeviceStatus2(devices); |
||||
|
|
||||
|
|
||||
|
// 设备产能利用 --------------------------------------------------------------------------------------------------
|
||||
|
JSONObject capacityRate = new JSONObject(); |
||||
|
result.put("capacityRate", capacityRate); |
||||
|
capacityRate.put("mix", Math.random() * (90 - 50) + 50); |
||||
|
capacityRate.put("press", Math.random() * (90 - 50) + 50); |
||||
|
capacityRate.put("dry", Math.random() * (90 - 50) + 50); |
||||
|
capacityRate.put("sort", Math.random() * (90 - 50) + 50); |
||||
|
|
||||
|
// 设备运行统计 --------------------------------------------------------------------------------------------------
|
||||
|
JSONObject stateStatistics = new JSONObject(); |
||||
|
result.put("stateStatistics", stateStatistics); |
||||
|
// 初始化 0
|
||||
|
stateStatistics.put("count", devices.size()); |
||||
|
stateStatistics.put("running", 0); |
||||
|
stateStatistics.put("pausing", 0); |
||||
|
stateStatistics.put("shutdown", 0); |
||||
|
stateStatistics.put("inTrouble", 0); |
||||
|
// 真实获取
|
||||
|
if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { |
||||
|
JSONArray data = deviceStatus.getJSONArray("data"); |
||||
|
|
||||
|
stateStatistics.put("running", data.stream().filter(o -> ((JSONObject) o).getIntValue("status") == 2).count()); |
||||
|
stateStatistics.put("pausing", data.stream().filter(o -> ((JSONObject) o).getIntValue("status") == 1).count()); |
||||
|
stateStatistics.put("shutdown", data.stream().filter(o -> ((JSONObject) o).getIntValue("status") == 0).count()); |
||||
|
stateStatistics.put("inTrouble", data.stream().filter(o -> ((JSONObject) o).getIntValue("status") == 3).count()); |
||||
|
} |
||||
|
|
||||
|
// 工序设备状态 --------------------------------------------------------------------------------------------------
|
||||
|
JSONObject areaDeviceStatus = new JSONObject(); |
||||
|
result.put("areaDeviceStatus", areaDeviceStatus); |
||||
|
|
||||
|
// 混料
|
||||
|
JSONObject mix = new JSONObject(); |
||||
|
areaDeviceStatus.put("mix", mix); |
||||
|
// 初始化 0
|
||||
|
mix.put("running", 0); |
||||
|
mix.put("pausing", 0); |
||||
|
mix.put("shutdown", 0); |
||||
|
mix.put("inTrouble", 0); |
||||
|
// 真实获取
|
||||
|
if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { |
||||
|
List<JSONObject> data = deviceStatus.getJSONArray("data").stream().map(o -> (JSONObject) o).filter(o -> "HL".equals(o.getString("region_code"))).collect(Collectors.toList()); |
||||
|
|
||||
|
mix.put("running", data.stream().filter(o -> o.getIntValue("status") == 2).count()); |
||||
|
mix.put("pausing", data.stream().filter(o -> o.getIntValue("status") == 1).count()); |
||||
|
mix.put("shutdown", data.stream().filter(o -> o.getIntValue("status") == 0).count()); |
||||
|
mix.put("inTrouble", data.stream().filter(o -> o.getIntValue("status") == 3).count()); |
||||
|
} |
||||
|
|
||||
|
// 压制
|
||||
|
JSONObject press = new JSONObject(); |
||||
|
areaDeviceStatus.put("press", press); |
||||
|
// 初始化 0
|
||||
|
press.put("running", 0); |
||||
|
press.put("pausing", 0); |
||||
|
press.put("shutdown", 0); |
||||
|
press.put("inTrouble", 0); |
||||
|
// 真实获取
|
||||
|
if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { |
||||
|
List<JSONObject> data = deviceStatus.getJSONArray("data").stream().map(o -> (JSONObject) o).filter(o -> "YZ".equals(o.getString("region_code"))).collect(Collectors.toList()); |
||||
|
|
||||
|
press.put("running", data.stream().filter(o -> o.getIntValue("status") == 2).count()); |
||||
|
press.put("pausing", data.stream().filter(o -> o.getIntValue("status") == 1).count()); |
||||
|
press.put("shutdown", data.stream().filter(o -> o.getIntValue("status") == 0).count()); |
||||
|
press.put("inTrouble", data.stream().filter(o -> o.getIntValue("status") == 3).count()); |
||||
|
} |
||||
|
|
||||
|
// 烧制
|
||||
|
JSONObject dry = new JSONObject(); |
||||
|
areaDeviceStatus.put("dry", dry); |
||||
|
// 初始化 0
|
||||
|
dry.put("running", 0); |
||||
|
dry.put("pausing", 0); |
||||
|
dry.put("shutdown", 0); |
||||
|
dry.put("inTrouble", 0); |
||||
|
// 真实获取
|
||||
|
if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { |
||||
|
List<JSONObject> data = deviceStatus.getJSONArray("data").stream().map(o -> (JSONObject) o).filter(o -> "SZ".equals(o.getString("region_code"))).collect(Collectors.toList()); |
||||
|
|
||||
|
dry.put("running", data.stream().filter(o -> o.getIntValue("status") == 2).count()); |
||||
|
dry.put("pausing", data.stream().filter(o -> o.getIntValue("status") == 1).count()); |
||||
|
dry.put("shutdown", data.stream().filter(o -> o.getIntValue("status") == 0).count()); |
||||
|
dry.put("inTrouble", data.stream().filter(o -> o.getIntValue("status") == 3).count()); |
||||
|
} |
||||
|
|
||||
|
// 包装
|
||||
|
JSONObject sort = new JSONObject(); |
||||
|
areaDeviceStatus.put("sort", sort); |
||||
|
// 初始化 0
|
||||
|
sort.put("running", 0); |
||||
|
sort.put("pausing", 0); |
||||
|
sort.put("shutdown", 0); |
||||
|
sort.put("inTrouble", 0); |
||||
|
// 真实获取
|
||||
|
if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { |
||||
|
List<JSONObject> data = deviceStatus.getJSONArray("data").stream().map(o -> (JSONObject) o).filter(o -> "FJ".equals(o.getString("region_code"))).collect(Collectors.toList()); |
||||
|
|
||||
|
sort.put("running", data.stream().filter(o -> o.getIntValue("status") == 2).count()); |
||||
|
sort.put("pausing", data.stream().filter(o -> o.getIntValue("status") == 1).count()); |
||||
|
sort.put("shutdown", data.stream().filter(o -> o.getIntValue("status") == 0).count()); |
||||
|
sort.put("inTrouble", data.stream().filter(o -> o.getIntValue("status") == 3).count()); |
||||
|
} |
||||
|
|
||||
|
// 30天故障top10 ------------------------------------------------------------------------------------------------
|
||||
|
result.put("top10Of30Days", WQL.getWO("DASHBOARD").addParam("flag", "3").process().getResultJSONArray(0)); |
||||
|
|
||||
|
// 设备工单生产 --------------------------------------------------------------------------------------------------
|
||||
|
JSONArray deviceWorkOrder = new JSONArray(); |
||||
|
result.put("deviceWorkOrder", deviceWorkOrder); |
||||
|
List<JSONObject> inProductionWorkOrder = WQL.getWO("DASHBOARD").addParam("flag", "4").process().getResultJSONArray(0).stream().map(o -> (JSONObject) o).collect(Collectors.toList()); |
||||
|
List<JSONObject> workDevice = devices.stream().map(o -> (JSONObject) o).filter(o -> "1".equals(o.getString("is_workorder"))).collect(Collectors.toList()); |
||||
|
for (JSONObject device : workDevice) { |
||||
|
JSONObject row = new JSONObject(); |
||||
|
row.put("process", this.regionToProcess(device.getString("region_code"))); |
||||
|
row.put("deviceCode", device.getString("device_code")); |
||||
|
row.put("deviceName", device.getString("device_name")); |
||||
|
if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { |
||||
|
JSONObject data = deviceStatus.getJSONArray("data").stream().map(o -> (JSONObject) o).filter(o -> device.getString("device_code").equals(o.getString("device_code"))).collect(Collectors.toList()).get(0); |
||||
|
row.put("status", this.deviceStatusToChinese(data.getIntValue("status"))); |
||||
|
} else{ |
||||
|
row.put("status", "未知"); |
||||
|
} |
||||
|
JSONObject wo = inProductionWorkOrder.stream().filter(o -> device.getString("device_code").equals(o.getString("device_code"))).collect(Collectors.toList()).get(0); |
||||
|
row.put("workOrder", wo.getString("workorder_code")); |
||||
|
row.put("bom", wo.getString("material_code").substring(5, 11)); |
||||
|
row.put("material", wo.getString("material_code")); |
||||
|
if ("HL".equals(device.getString("region_code"))) { |
||||
|
row.put("qty", wo.getIntValue("plan_qty") + "千克"); |
||||
|
} else { |
||||
|
row.put("qty", wo.getIntValue("plan_qty") + "块"); |
||||
|
} |
||||
|
row.put("startTime", wo.getString("realproducestart_date")); |
||||
|
deviceWorkOrder.add(row); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 大屏首页设备 |
||||
|
* |
||||
|
* @return 大屏首页设备数据 |
||||
|
*/ |
||||
|
public JSONObject homepageEquipment() { |
||||
|
JSONObject result = new JSONObject(); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
private String regionToProcess(String regionCode) { |
||||
|
switch (regionCode) { |
||||
|
case "HL": |
||||
|
return "混碾"; |
||||
|
case "YZ": |
||||
|
return "压制"; |
||||
|
case "FJ": |
||||
|
return "包装"; |
||||
|
default: |
||||
|
return regionCode; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private String deviceStatusToChinese(int status) { |
||||
|
switch (status) { |
||||
|
case 0: |
||||
|
return "停机"; |
||||
|
case 1: |
||||
|
return "暂停"; |
||||
|
case 2: |
||||
|
return "运行"; |
||||
|
case 3: |
||||
|
return "故障"; |
||||
|
default: |
||||
|
return "未知"; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,121 @@ |
|||||
|
[交易说明] |
||||
|
交易名: 大屏 |
||||
|
所属模块: |
||||
|
功能简述: |
||||
|
版权所有: |
||||
|
表引用: |
||||
|
版本经历: |
||||
|
|
||||
|
[数据库] |
||||
|
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 |
||||
|
|
||||
|
[IO定义] |
||||
|
################################################# |
||||
|
## 表字段对应输入参数 |
||||
|
################################################# |
||||
|
输入.flag TYPEAS s_string |
||||
|
|
||||
|
[临时表] |
||||
|
--这边列出来的临时表就会在运行期动态创建 |
||||
|
|
||||
|
[临时变量] |
||||
|
--所有中间过程变量均可在此处定义 |
||||
|
|
||||
|
[业务过程] |
||||
|
|
||||
|
########################################## |
||||
|
# 1、输入输出检查 # |
||||
|
########################################## |
||||
|
|
||||
|
|
||||
|
########################################## |
||||
|
# 2、主过程前处理 # |
||||
|
########################################## |
||||
|
|
||||
|
|
||||
|
########################################## |
||||
|
# 3、业务主过程 # |
||||
|
########################################## |
||||
|
|
||||
|
IF 输入.flag = "1" |
||||
|
QUERY |
||||
|
SELECT |
||||
|
wo.plan_qty, |
||||
|
wo.real_qty, |
||||
|
d.region_code, |
||||
|
wo.material_id, |
||||
|
mb.material_code, |
||||
|
d.device_code, |
||||
|
d.device_name |
||||
|
FROM |
||||
|
pdm_bd_workorder wo |
||||
|
LEFT JOIN pdm_bi_device d ON wo.device_id = d.device_id |
||||
|
LEFT JOIN md_me_materialbase mb ON wo.material_id = mb.material_id |
||||
|
WHERE |
||||
|
wo.is_delete = '0' |
||||
|
AND TO_DAYS(wo.plan_date) = TO_DAYS(NOW()) |
||||
|
ENDSELECT |
||||
|
ENDQUERY |
||||
|
ENDIF |
||||
|
|
||||
|
IF 输入.flag = "2" |
||||
|
QUERY |
||||
|
SELECT |
||||
|
vd.qty, |
||||
|
vd.weight, |
||||
|
d.region_code, |
||||
|
vd.material_id, |
||||
|
mb.material_code, |
||||
|
vd.create_time |
||||
|
FROM |
||||
|
st_ivt_vehicle_detail vd |
||||
|
LEFT JOIN pdm_bd_workorder wo ON vd.workorder_id = wo.workorder_id |
||||
|
LEFT JOIN pdm_bi_device d ON wo.device_id = d.device_id |
||||
|
LEFT JOIN md_me_materialbase mb ON vd.material_id = mb.material_id |
||||
|
WHERE |
||||
|
vd.is_delete = '0' |
||||
|
ENDSELECT |
||||
|
ENDQUERY |
||||
|
ENDIF |
||||
|
|
||||
|
IF 输入.flag = "3" |
||||
|
QUERY |
||||
|
SELECT |
||||
|
dn.device_code, |
||||
|
COUNT(dn.device_code) AS "count" |
||||
|
FROM |
||||
|
das_device_number dn LEFT JOIN pdm_bi_device d ON dn.device_code = d.device_code |
||||
|
WHERE |
||||
|
dn.failure_info = 3 |
||||
|
AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= DATE( dn.failure_time ) |
||||
|
GROUP BY |
||||
|
dn.device_code |
||||
|
ORDER BY |
||||
|
count DESC |
||||
|
LIMIT |
||||
|
0, 10 |
||||
|
ENDSELECT |
||||
|
ENDQUERY |
||||
|
ENDIF |
||||
|
|
||||
|
IF 输入.flag = "4" |
||||
|
QUERY |
||||
|
SELECT |
||||
|
wo.workorder_code, |
||||
|
wo.plan_qty, |
||||
|
wo.real_qty, |
||||
|
d.region_code, |
||||
|
wo.material_id, |
||||
|
mb.material_code, |
||||
|
d.device_code, |
||||
|
d.device_name |
||||
|
FROM |
||||
|
pdm_bd_workorder wo |
||||
|
LEFT JOIN pdm_bi_device d ON wo.device_id = d.device_id |
||||
|
LEFT JOIN md_me_materialbase mb ON wo.material_id = mb.material_id |
||||
|
WHERE |
||||
|
wo.is_delete = '0' |
||||
|
AND order_status = '3' |
||||
|
ENDSELECT |
||||
|
ENDQUERY |
||||
|
ENDIF |
Loading…
Reference in new issue