add 仓储监控
This commit is contained in:
@@ -44,4 +44,11 @@ public class DashboardController {
|
||||
public ResponseEntity<Object> productionStatistics(){
|
||||
return new ResponseEntity<>(dashboardService.productionStatistics(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/warehouseMonitor")
|
||||
@Log("仓储监控")
|
||||
@ApiOperation("仓储监控")
|
||||
public ResponseEntity<Object> warehouseMonitor(){
|
||||
return new ResponseEntity<>(dashboardService.warehouseMonitor(), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.nl.wms.sch.manage.WorkOrderEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author zhangjiangwei
|
||||
*/
|
||||
@@ -420,7 +422,7 @@ public class DashboardService {
|
||||
*/
|
||||
public JSONObject productionStatistics() {
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
|
||||
// 总量----------------------------------------------------------------------------------------------------------
|
||||
JSONObject total = new JSONObject();
|
||||
result.put("total", total);
|
||||
@@ -504,6 +506,132 @@ public class DashboardService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 仓储监控
|
||||
*
|
||||
* @return 仓储监控数据
|
||||
*/
|
||||
public JSONObject warehouseMonitor() {
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
// 困料监控------------------------------------------------------------------------------------------------------
|
||||
JSONArray standMonitor = new JSONArray();
|
||||
result.put("standMonitor", standMonitor);
|
||||
// todo 现在是假数据,后期更新。
|
||||
for (int i = 1; i <= 41; i++) {
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("storageLocation", i + "号位");
|
||||
String pointStatus = this.randomFrom1To(3);
|
||||
row.put("pointStatus", pointStatus);
|
||||
if (!"1".equals(pointStatus)) {
|
||||
row.put("vehicleCode", String.format("%04d", Integer.parseInt(this.randomFrom1To(9999))));
|
||||
if (!"2".equals(pointStatus)) {
|
||||
row.put("materialCode", "WL" + String.format("%02d", i));
|
||||
row.put("materialName", "物料" + i);
|
||||
row.put("weight", this.randomFrom1To(2000));
|
||||
row.put("warehousingTime", DateUtil.format(DateUtil.offsetHour(DateUtil.date(), -1), "yyyy-MM-dd HH:mm:ss"));
|
||||
row.put("standTime", "1");
|
||||
row.put("standStatus", this.randomFrom1To(5));
|
||||
}
|
||||
}
|
||||
standMonitor.add(row);
|
||||
}
|
||||
|
||||
// 成型暂存监控---------------------------------------------------------------------------------------------------
|
||||
JSONArray frontWarehouseMonitor = new JSONArray();
|
||||
result.put("frontWarehouseMonitor", frontWarehouseMonitor);
|
||||
// todo 现在是假数据,后期更新。
|
||||
for (int i = 1; i <= 28; i += 2) {
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("storageLocation", "窑前货位" + i);
|
||||
String pointStatus = this.randomFrom1To(3);
|
||||
row.put("pointStatus", pointStatus);
|
||||
if (!"1".equals(pointStatus)) {
|
||||
row.put("vehicleCode", String.format("%04d", Integer.parseInt(this.randomFrom1To(9999))));
|
||||
if (!"2".equals(pointStatus)) {
|
||||
row.put("materialCode", "WL" + String.format("%02d", i));
|
||||
row.put("materialName", "物料" + i);
|
||||
row.put("qty", this.randomFrom1To(200));
|
||||
row.put("warehousingTime", DateUtil.format(DateUtil.offsetHour(DateUtil.date(), -1), "yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
||||
frontWarehouseMonitor.add(row);
|
||||
}
|
||||
for (int i = 2; i <= 28; i += 2) {
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("storageLocation", "窑前货位" + i);
|
||||
String pointStatus = this.randomFrom1To(3);
|
||||
row.put("pointStatus", pointStatus);
|
||||
if (!"1".equals(pointStatus)) {
|
||||
row.put("vehicleCode", String.format("%04d", Integer.parseInt(this.randomFrom1To(9999))));
|
||||
if (!"2".equals(pointStatus)) {
|
||||
row.put("materialCode", "WL" + String.format("%02d", i));
|
||||
row.put("materialName", "物料" + i);
|
||||
row.put("qty", this.randomFrom1To(200));
|
||||
row.put("warehousingTime", DateUtil.format(DateUtil.offsetHour(DateUtil.date(), -1), "yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
||||
frontWarehouseMonitor.add(row);
|
||||
}
|
||||
|
||||
// 半成品暂存监控-------------------------------------------------------------------------------------------------
|
||||
JSONArray backWarehouseMonitor = new JSONArray();
|
||||
result.put("backWarehouseMonitor", backWarehouseMonitor);
|
||||
// todo 现在是假数据,后期更新。
|
||||
for (int i = 1; i <= 26; i += 2) {
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("storageLocation", "窑后货位" + i);
|
||||
String pointStatus = this.randomFrom1To(3);
|
||||
row.put("pointStatus", pointStatus);
|
||||
if (!"1".equals(pointStatus)) {
|
||||
row.put("vehicleCode", String.format("%04d", Integer.parseInt(this.randomFrom1To(9999))));
|
||||
if (!"2".equals(pointStatus)) {
|
||||
row.put("materialCode", "WL" + String.format("%02d", i));
|
||||
row.put("materialName", "物料" + i);
|
||||
row.put("qty", this.randomFrom1To(200));
|
||||
row.put("warehousingTime", DateUtil.format(DateUtil.offsetHour(DateUtil.date(), -1), "yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
||||
backWarehouseMonitor.add(row);
|
||||
}
|
||||
for (int i = 2; i <= 26; i += 2) {
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("storageLocation", "窑后货位" + i);
|
||||
String pointStatus = this.randomFrom1To(3);
|
||||
row.put("pointStatus", pointStatus);
|
||||
if (!"1".equals(pointStatus)) {
|
||||
row.put("vehicleCode", String.format("%04d", Integer.parseInt(this.randomFrom1To(9999))));
|
||||
if (!"2".equals(pointStatus)) {
|
||||
row.put("materialCode", "WL" + String.format("%02d", i));
|
||||
row.put("materialName", "物料" + i);
|
||||
row.put("qty", this.randomFrom1To(200));
|
||||
row.put("warehousingTime", DateUtil.format(DateUtil.offsetHour(DateUtil.date(), -1), "yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
||||
backWarehouseMonitor.add(row);
|
||||
}
|
||||
|
||||
// 困料库存------------------------------------------------------------------------------------------------------
|
||||
JSONArray standStock = new JSONArray(standMonitor.stream()
|
||||
.filter(o -> "3".equals(((JSONObject) o).getString("pointStatus")))
|
||||
.collect(Collectors.toList()));
|
||||
result.put("standStock", standStock);
|
||||
|
||||
// 成型库存------------------------------------------------------------------------------------------------------
|
||||
JSONArray frontWarehouseStock = new JSONArray(frontWarehouseMonitor.stream()
|
||||
.filter(o -> "3".equals(((JSONObject) o).getString("pointStatus")))
|
||||
.collect(Collectors.toList()));
|
||||
result.put("frontWarehouseStock", frontWarehouseStock);
|
||||
|
||||
// 半成品库存-----------------------------------------------------------------------------------------------------
|
||||
JSONArray backWarehouseStock = new JSONArray(backWarehouseMonitor.stream()
|
||||
.filter(o -> "3".equals(((JSONObject) o).getString("pointStatus")))
|
||||
.collect(Collectors.toList()));
|
||||
result.put("backWarehouseStock", backWarehouseStock);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private String randomFrom1To(int to) {
|
||||
return String.valueOf(1 + (int) (Math.random() * to));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user