Merge remote-tracking branch 'origin/0.8.X' into 0.8.X
# Conflicts: # klp-admin/src/main/resources/application-prod.yml
This commit is contained in:
@@ -466,6 +466,36 @@ public class SqlServerApiClient {
|
||||
return executeSql("oracle", sql.toString(), params);
|
||||
}
|
||||
|
||||
public ExecuteSqlResponse queryExcoilByTimeRange(String startTime, String endTime) {
|
||||
Map<String, Object> params = new java.util.HashMap<>();
|
||||
StringBuilder sql = new StringBuilder("SELECT * FROM JXPLTCM.PLTCM_PDO_EXCOIL WHERE 1=1");
|
||||
if (startTime != null && !startTime.trim().isEmpty()) {
|
||||
sql.append(" AND END_DATE >= TO_DATE(:startTime, 'YYYY-MM-DD HH24:MI:SS')");
|
||||
params.put("startTime", startTime.trim());
|
||||
}
|
||||
if (endTime != null && !endTime.trim().isEmpty()) {
|
||||
sql.append(" AND END_DATE <= TO_DATE(:endTime, 'YYYY-MM-DD HH24:MI:SS')");
|
||||
params.put("endTime", endTime.trim());
|
||||
}
|
||||
sql.append(" ORDER BY END_DATE DESC");
|
||||
return executeSql("oracle", sql.toString(), params);
|
||||
}
|
||||
|
||||
// public ExecuteSqlResponse queryExcoilByInsdateRange(String startTime, String endTime) {
|
||||
// Map<String, Object> params = new java.util.HashMap<>();
|
||||
// StringBuilder sql = new StringBuilder("SELECT * FROM JXPLTCM.PLTCM_PDO_EXCOIL WHERE 1=1");
|
||||
// if (startTime != null && !startTime.trim().isEmpty()) {
|
||||
// sql.append(" AND INSDATE > TO_DATE(:startTime, 'YYYY-MM-DD HH24:MI:SS')");
|
||||
// params.put("startTime", startTime.trim());
|
||||
// }
|
||||
// if (endTime != null && !endTime.trim().isEmpty()) {
|
||||
// sql.append(" AND INSDATE <= TO_DATE(:endTime, 'YYYY-MM-DD HH24:MI:SS')");
|
||||
// params.put("endTime", endTime.trim());
|
||||
// }
|
||||
// sql.append(" ORDER BY INSDATE ASC");
|
||||
// return executeSql("oracle", sql.toString(), params);
|
||||
// }
|
||||
|
||||
public ExecuteSqlResponse queryExcoilList(int page, int pageSize) {
|
||||
int endRow = page * pageSize;
|
||||
int startRow = endRow - pageSize;
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.klp.framework.controller;
|
||||
|
||||
import com.klp.common.core.domain.R;
|
||||
import com.klp.domain.bo.WmsMaterialCoilBo;
|
||||
import com.klp.domain.vo.WmsMaterialCoilVo;
|
||||
import com.klp.framework.service.SqlServerApiBusinessService;
|
||||
import com.klp.service.IWmsMaterialCoilService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/wms/coil-comparison")
|
||||
public class CoilComparisonController {
|
||||
|
||||
private final SqlServerApiBusinessService sqlServerService;
|
||||
private final IWmsMaterialCoilService wmsMaterialCoilService;
|
||||
|
||||
/**
|
||||
* 获取钢卷状态信息接口
|
||||
* 根据时间范围、产线类型查询钢卷状态,并关联本地系统中的钢卷信息
|
||||
*
|
||||
* @param startTime 开始时间(可选)
|
||||
* @param endTime 结束时间(可选)
|
||||
* @param lineType 产线类型(可选)
|
||||
* @return 返回包含钢卷状态信息的列表,每个钢卷信息包含外系统和本系统的相关数据
|
||||
*/
|
||||
@GetMapping("/excoil-status")
|
||||
public R<List<Map<String, Object>>> getExcoilStatus(
|
||||
@RequestParam(required = false) String startTime,
|
||||
@RequestParam(required = false) String endTime,
|
||||
@RequestParam(required = false) String lineType) {
|
||||
|
||||
// 默认时间为今天
|
||||
if (startTime == null || startTime.trim().isEmpty()) {
|
||||
startTime = LocalDate.now().toString() + " 00:00:00";
|
||||
}
|
||||
if (endTime == null || endTime.trim().isEmpty()) {
|
||||
endTime = LocalDate.now().toString() + " 23:59:59";
|
||||
}
|
||||
// 从SQL Server服务获取指定时间范围内的钢卷数据
|
||||
List<Map<String, Object>> excoilRows = sqlServerService.getExcoilByTimeRange(startTime, endTime);
|
||||
|
||||
// 构建查询条件,查询本地系统中的热轧卷板原料信息
|
||||
WmsMaterialCoilBo bo = new WmsMaterialCoilBo();
|
||||
bo.setItemType("raw_material");
|
||||
bo.setMaterialType("原料");
|
||||
bo.setItemName("热轧卷板");
|
||||
bo.setSelectType("raw_material");
|
||||
List<WmsMaterialCoilVo> localCoils = wmsMaterialCoilService.queryList(bo);
|
||||
|
||||
// 将本地钢卷数据以钢卷号为key存入Map,便于后续查找
|
||||
Map<String, WmsMaterialCoilVo> localMap = new HashMap<>();
|
||||
for (WmsMaterialCoilVo coil : localCoils) {
|
||||
if (coil.getEnterCoilNo() != null) {
|
||||
localMap.put(coil.getEnterCoilNo(), coil);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理结果集,将外系统和本地系统的钢卷信息合并
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (Map<String, Object> excoil : excoilRows) {
|
||||
// 获取热轧卷ID
|
||||
String hotCoilId = excoil.get("hot_coilid") != null ? String.valueOf(excoil.get("hot_coilid")) : null;
|
||||
// 创建结果项
|
||||
Map<String, Object> item = new LinkedHashMap<>();
|
||||
// 添加外系统基本信息
|
||||
item.put("excoilId", excoil.get("encoilid"));
|
||||
item.put("hotCoilId", hotCoilId);
|
||||
item.put("endDate", excoil.get("end_date"));
|
||||
item.put("startDate", excoil.get("start_date"));
|
||||
item.put("excoilid", excoil.get("excoilid"));
|
||||
item.put("grade", excoil.get("grade"));
|
||||
item.put("status", excoil.get("status"));
|
||||
item.put("shift", excoil.get("shift"));
|
||||
item.put("crew", excoil.get("crew"));
|
||||
item.put("entryThick", excoil.get("entry_thick"));
|
||||
item.put("entryWeight", excoil.get("entry_weight"));
|
||||
item.put("entryWidth", excoil.get("entry_width"));
|
||||
item.put("exitThick", excoil.get("exit_thick"));
|
||||
item.put("exitWidth", excoil.get("exit_width"));
|
||||
item.put("exitLength", excoil.get("exit_length"));
|
||||
item.put("exitNegDev", excoil.get("exit_neg_dev"));
|
||||
item.put("exitPosDev", excoil.get("exit_pos_dev"));
|
||||
item.put("calcExitWeight", excoil.get("calc_exit_weight"));
|
||||
item.put("measExitWeight", excoil.get("meas_exit_weight"));
|
||||
item.put("quality", excoil.get("quality"));
|
||||
item.put("shapeQuality", excoil.get("shape_quality"));
|
||||
item.put("orderQuality", excoil.get("order_quality"));
|
||||
item.put("productType", excoil.get("product_type"));
|
||||
item.put("parkType", excoil.get("park_type"));
|
||||
item.put("sideTrim", excoil.get("side_trim"));
|
||||
item.put("innerDiameter", excoil.get("inner_diameter"));
|
||||
item.put("outerDiameter", excoil.get("outer_diameter"));
|
||||
item.put("headpos", excoil.get("headpos"));
|
||||
item.put("tailpos", excoil.get("tailpos"));
|
||||
item.put("subid", excoil.get("subid"));
|
||||
item.put("rn", excoil.get("rn"));
|
||||
item.put("comments", excoil.get("comments"));
|
||||
item.put("reportFlag", excoil.get("report_flag"));
|
||||
item.put("usedEntryWeight", excoil.get("used_entry_weight"));
|
||||
item.put("onlineDate", excoil.get("online_date"));
|
||||
item.put("insdate", excoil.get("insdate"));
|
||||
item.put("weldedDate", excoil.get("welded_date"));
|
||||
|
||||
// 如果存在热轧卷ID,则尝试匹配本地系统数据
|
||||
if (hotCoilId != null) {
|
||||
WmsMaterialCoilVo matched = localMap.get(hotCoilId);
|
||||
if (matched != null) {
|
||||
// 匹配成功,添加本地系统数据
|
||||
item.put("enterCoilNo", matched.getEnterCoilNo());
|
||||
item.put("currentCoilNo", matched.getCurrentCoilNo());
|
||||
item.put("supplierCoilNo", matched.getSupplierCoilNo());
|
||||
item.put("dataType", matched.getDataType());
|
||||
item.put("itemName", matched.getItemName());
|
||||
item.put("itemCode", matched.getItemCode());
|
||||
item.put("specification", matched.getSpecification());
|
||||
item.put("material", matched.getMaterial());
|
||||
item.put("manufacturer", matched.getManufacturer());
|
||||
item.put("coilStatus", matched.getStatus());
|
||||
item.put("warehouseName", matched.getWarehouseName());
|
||||
// 根据数据类型设置匹配状态
|
||||
if (matched.getDataType() != null && matched.getDataType() == 0) {
|
||||
item.put("matchStatus", 0);
|
||||
item.put("matchStatusDesc", "已加工");
|
||||
} else {
|
||||
item.put("matchStatus", 1);
|
||||
item.put("matchStatusDesc", "未加工");
|
||||
}
|
||||
} else {
|
||||
// 未匹配到本地数据,设置为未入库状态
|
||||
item.put("enterCoilNo", null);
|
||||
item.put("currentCoilNo", null);
|
||||
item.put("supplierCoilNo", null);
|
||||
item.put("dataType", null);
|
||||
item.put("itemName", null);
|
||||
item.put("itemCode", null);
|
||||
item.put("specification", null);
|
||||
item.put("material", null);
|
||||
item.put("manufacturer", null);
|
||||
item.put("coilStatus", null);
|
||||
item.put("warehouseName", null);
|
||||
item.put("matchStatus", 2);
|
||||
item.put("matchStatusDesc", "未入库");
|
||||
}
|
||||
} else {
|
||||
// 热轧卷ID为空,设置为未入库状态
|
||||
item.put("enterCoilNo", null);
|
||||
item.put("currentCoilNo", null);
|
||||
item.put("supplierCoilNo", null);
|
||||
item.put("dataType", null);
|
||||
item.put("itemName", null);
|
||||
item.put("itemCode", null);
|
||||
item.put("specification", null);
|
||||
item.put("material", null);
|
||||
item.put("manufacturer", null);
|
||||
item.put("coilStatus", null);
|
||||
item.put("warehouseName", null);
|
||||
item.put("matchStatus", 2);
|
||||
item.put("matchStatusDesc", "未入库");
|
||||
}
|
||||
result.add(item);
|
||||
}
|
||||
|
||||
return R.ok(result);
|
||||
}
|
||||
}
|
||||
@@ -199,6 +199,20 @@ public class SqlServerApiBusinessService {
|
||||
public List<Map<String, Object>> getExitTrace() { return exitTrace; }
|
||||
}
|
||||
|
||||
/**
|
||||
* 出口卷实绩列表(按时间段),来自 PLTCM_PDO_EXCOIL。
|
||||
*/
|
||||
public List<Map<String, Object>> getExcoilByTimeRange(String startTime, String endTime) {
|
||||
return asRowList(client.queryExcoilByTimeRange(startTime, endTime));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 出口卷实绩列表(按数据写入时间),用于增量同步。
|
||||
// */
|
||||
// public List<Map<String, Object>> getExcoilByInsdateRange(String startTime, String endTime) {
|
||||
// return asRowList(client.queryExcoilByInsdateRange(startTime, endTime));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 出口卷实绩列表(分页),来自 PLTCM_PDO_EXCOIL。
|
||||
*/
|
||||
|
||||
@@ -155,6 +155,28 @@ public class SqlServerApiController {
|
||||
return R.ok(businessService.getRollHistoryList(page, pageSize, rollId, standId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 出口卷实绩列表(按下线时间),来自 PLTCM_PDO_EXCOIL。
|
||||
* startTime / endTime 格式:yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
@GetMapping("/excoil/by-time")
|
||||
public R<List<Map<String, Object>>> excoilByTime(
|
||||
@RequestParam(required = false) String startTime,
|
||||
@RequestParam(required = false) String endTime) {
|
||||
return R.ok(businessService.getExcoilByTimeRange(startTime, endTime));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 出口卷实绩列表(按数据写入时间),用于增量同步。
|
||||
// * startTime(exclusive)/ endTime(inclusive),格式:yyyy-MM-dd HH:mm:ss
|
||||
// */
|
||||
// @GetMapping("/excoil/by-insdate")
|
||||
// public R<List<Map<String, Object>>> excoilByInsdate(
|
||||
// @RequestParam(required = false) String startTime,
|
||||
// @RequestParam(required = false) String endTime) {
|
||||
// return R.ok(businessService.getExcoilByInsdateRange(startTime, endTime));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 出口卷实绩列表(分页),来自 PLTCM_PDO_EXCOIL。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user