refactor: 注释掉出口卷数据同步相关代码并优化钢卷对比默认查询逻辑

本次提交主要变更:
1.  注释掉所有出口卷数据同步的接口、服务实现和相关工具方法
2.  优化钢卷对比页面的默认时间逻辑,移除默认7天前的起始时间,改为默认查询今日全天数据
3.  新增日期格式化工具方法统一处理时间字符串拼接
4.  完善钢卷对比接口的注释和字段映射逻辑
This commit is contained in:
2026-05-22 14:01:16 +08:00
parent 80fbe70ab7
commit c2b7a08414
8 changed files with 332 additions and 266 deletions

View File

@@ -428,20 +428,20 @@ public class SqlServerApiClient {
return executeSql("oracle", sql.toString(), params); return executeSql("oracle", sql.toString(), params);
} }
public ExecuteSqlResponse queryExcoilByInsdateRange(String startTime, String endTime) { // public ExecuteSqlResponse queryExcoilByInsdateRange(String startTime, String endTime) {
Map<String, Object> params = new java.util.HashMap<>(); // Map<String, Object> params = new java.util.HashMap<>();
StringBuilder sql = new StringBuilder("SELECT * FROM JXPLTCM.PLTCM_PDO_EXCOIL WHERE 1=1"); // StringBuilder sql = new StringBuilder("SELECT * FROM JXPLTCM.PLTCM_PDO_EXCOIL WHERE 1=1");
if (startTime != null && !startTime.trim().isEmpty()) { // if (startTime != null && !startTime.trim().isEmpty()) {
sql.append(" AND INSDATE > TO_DATE(:startTime, 'YYYY-MM-DD HH24:MI:SS')"); // sql.append(" AND INSDATE > TO_DATE(:startTime, 'YYYY-MM-DD HH24:MI:SS')");
params.put("startTime", startTime.trim()); // params.put("startTime", startTime.trim());
} // }
if (endTime != null && !endTime.trim().isEmpty()) { // if (endTime != null && !endTime.trim().isEmpty()) {
sql.append(" AND INSDATE <= TO_DATE(:endTime, 'YYYY-MM-DD HH24:MI:SS')"); // sql.append(" AND INSDATE <= TO_DATE(:endTime, 'YYYY-MM-DD HH24:MI:SS')");
params.put("endTime", endTime.trim()); // params.put("endTime", endTime.trim());
} // }
sql.append(" ORDER BY INSDATE ASC"); // sql.append(" ORDER BY INSDATE ASC");
return executeSql("oracle", sql.toString(), params); // return executeSql("oracle", sql.toString(), params);
} // }
public ExecuteSqlResponse queryExcoilList(int page, int pageSize) { public ExecuteSqlResponse queryExcoilList(int page, int pageSize) {
int endRow = page * pageSize; int endRow = page * pageSize;

View File

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -25,14 +26,32 @@ public class CoilComparisonController {
private final SqlServerApiBusinessService sqlServerService; private final SqlServerApiBusinessService sqlServerService;
private final IWmsMaterialCoilService wmsMaterialCoilService; private final IWmsMaterialCoilService wmsMaterialCoilService;
/**
* 获取钢卷状态信息接口
* 根据时间范围、产线类型查询钢卷状态,并关联本地系统中的钢卷信息
*
* @param startTime 开始时间(可选)
* @param endTime 结束时间(可选)
* @param lineType 产线类型(可选)
* @return 返回包含钢卷状态信息的列表,每个钢卷信息包含外系统和本系统的相关数据
*/
@GetMapping("/excoil-status") @GetMapping("/excoil-status")
public R<List<Map<String, Object>>> getExcoilStatus( public R<List<Map<String, Object>>> getExcoilStatus(
@RequestParam(required = false) String startTime, @RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime, @RequestParam(required = false) String endTime,
@RequestParam(required = false) String lineType) { @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); List<Map<String, Object>> excoilRows = sqlServerService.getExcoilByTimeRange(startTime, endTime);
// 构建查询条件,查询本地系统中的热轧卷板原料信息
WmsMaterialCoilBo bo = new WmsMaterialCoilBo(); WmsMaterialCoilBo bo = new WmsMaterialCoilBo();
bo.setItemType("raw_material"); bo.setItemType("raw_material");
bo.setMaterialType("原料"); bo.setMaterialType("原料");
@@ -40,6 +59,7 @@ public class CoilComparisonController {
bo.setSelectType("raw_material"); bo.setSelectType("raw_material");
List<WmsMaterialCoilVo> localCoils = wmsMaterialCoilService.queryList(bo); List<WmsMaterialCoilVo> localCoils = wmsMaterialCoilService.queryList(bo);
// 将本地钢卷数据以钢卷号为key存入Map便于后续查找
Map<String, WmsMaterialCoilVo> localMap = new HashMap<>(); Map<String, WmsMaterialCoilVo> localMap = new HashMap<>();
for (WmsMaterialCoilVo coil : localCoils) { for (WmsMaterialCoilVo coil : localCoils) {
if (coil.getEnterCoilNo() != null) { if (coil.getEnterCoilNo() != null) {
@@ -47,23 +67,57 @@ public class CoilComparisonController {
} }
} }
// 处理结果集,将外系统和本地系统的钢卷信息合并
List<Map<String, Object>> result = new ArrayList<>(); List<Map<String, Object>> result = new ArrayList<>();
for (Map<String, Object> excoil : excoilRows) { for (Map<String, Object> excoil : excoilRows) {
String hotCoilId = excoil.get("HOT_COILID") != null ? String.valueOf(excoil.get("HOT_COILID")) : null; // 获取热轧卷ID
String hotCoilId = excoil.get("hot_coilid") != null ? String.valueOf(excoil.get("hot_coilid")) : null;
// 创建结果项
Map<String, Object> item = new LinkedHashMap<>(); Map<String, Object> item = new LinkedHashMap<>();
item.put("excoilId", excoil.get("EXCOILID")); // 添加外系统基本信息
item.put("coilId", excoil.get("COILID")); item.put("excoilId", excoil.get("encoilid"));
item.put("hotCoilId", hotCoilId); item.put("hotCoilId", hotCoilId);
item.put("endDate", excoil.get("END_DATE")); item.put("endDate", excoil.get("end_date"));
item.put("startDate", excoil.get("START_DATE")); item.put("startDate", excoil.get("start_date"));
item.put("actualThick", excoil.get("ACTUAL_THICK")); item.put("excoilid", excoil.get("excoilid"));
item.put("actualWidth", excoil.get("ACTUAL_WIDTH")); item.put("grade", excoil.get("grade"));
item.put("actualWeight", excoil.get("ACTUAL_WEIGHT")); item.put("status", excoil.get("status"));
item.put("processCode", excoil.get("PROCESS_CODE")); 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) { if (hotCoilId != null) {
WmsMaterialCoilVo matched = localMap.get(hotCoilId); WmsMaterialCoilVo matched = localMap.get(hotCoilId);
if (matched != null) { if (matched != null) {
// 匹配成功,添加本地系统数据
item.put("enterCoilNo", matched.getEnterCoilNo()); item.put("enterCoilNo", matched.getEnterCoilNo());
item.put("currentCoilNo", matched.getCurrentCoilNo()); item.put("currentCoilNo", matched.getCurrentCoilNo());
item.put("supplierCoilNo", matched.getSupplierCoilNo()); item.put("supplierCoilNo", matched.getSupplierCoilNo());
@@ -75,6 +129,7 @@ public class CoilComparisonController {
item.put("manufacturer", matched.getManufacturer()); item.put("manufacturer", matched.getManufacturer());
item.put("coilStatus", matched.getStatus()); item.put("coilStatus", matched.getStatus());
item.put("warehouseName", matched.getWarehouseName()); item.put("warehouseName", matched.getWarehouseName());
// 根据数据类型设置匹配状态
if (matched.getDataType() != null && matched.getDataType() == 0) { if (matched.getDataType() != null && matched.getDataType() == 0) {
item.put("matchStatus", 0); item.put("matchStatus", 0);
item.put("matchStatusDesc", "已加工"); item.put("matchStatusDesc", "已加工");
@@ -83,6 +138,7 @@ public class CoilComparisonController {
item.put("matchStatusDesc", "未加工"); item.put("matchStatusDesc", "未加工");
} }
} else { } else {
// 未匹配到本地数据,设置为未入库状态
item.put("enterCoilNo", null); item.put("enterCoilNo", null);
item.put("currentCoilNo", null); item.put("currentCoilNo", null);
item.put("supplierCoilNo", null); item.put("supplierCoilNo", null);
@@ -98,6 +154,7 @@ public class CoilComparisonController {
item.put("matchStatusDesc", "未入库"); item.put("matchStatusDesc", "未入库");
} }
} else { } else {
// 热轧卷ID为空设置为未入库状态
item.put("enterCoilNo", null); item.put("enterCoilNo", null);
item.put("currentCoilNo", null); item.put("currentCoilNo", null);
item.put("supplierCoilNo", null); item.put("supplierCoilNo", null);

View File

@@ -161,12 +161,12 @@ public class SqlServerApiBusinessService {
return asRowList(client.queryExcoilByTimeRange(startTime, endTime)); return asRowList(client.queryExcoilByTimeRange(startTime, endTime));
} }
/** // /**
* 出口卷实绩列表(按数据写入时间),用于增量同步。 // * 出口卷实绩列表(按数据写入时间),用于增量同步。
*/ // */
public List<Map<String, Object>> getExcoilByInsdateRange(String startTime, String endTime) { // public List<Map<String, Object>> getExcoilByInsdateRange(String startTime, String endTime) {
return asRowList(client.queryExcoilByInsdateRange(startTime, endTime)); // return asRowList(client.queryExcoilByInsdateRange(startTime, endTime));
} // }
/** /**
* 出口卷实绩列表(分页),来自 PLTCM_PDO_EXCOIL。 * 出口卷实绩列表(分页),来自 PLTCM_PDO_EXCOIL。

View File

@@ -166,16 +166,16 @@ public class SqlServerApiController {
return R.ok(businessService.getExcoilByTimeRange(startTime, endTime)); return R.ok(businessService.getExcoilByTimeRange(startTime, endTime));
} }
/** // /**
* 出口卷实绩列表(按数据写入时间),用于增量同步。 // * 出口卷实绩列表(按数据写入时间),用于增量同步。
* startTimeexclusive/ endTimeinclusive格式yyyy-MM-dd HH:mm:ss // * startTimeexclusive/ endTimeinclusive格式yyyy-MM-dd HH:mm:ss
*/ // */
@GetMapping("/excoil/by-insdate") // @GetMapping("/excoil/by-insdate")
public R<List<Map<String, Object>>> excoilByInsdate( // public R<List<Map<String, Object>>> excoilByInsdate(
@RequestParam(required = false) String startTime, // @RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime) { // @RequestParam(required = false) String endTime) {
return R.ok(businessService.getExcoilByInsdateRange(startTime, endTime)); // return R.ok(businessService.getExcoilByInsdateRange(startTime, endTime));
} // }
/** /**
* 出口卷实绩列表(分页),来自 PLTCM_PDO_EXCOIL。 * 出口卷实绩列表(分页),来自 PLTCM_PDO_EXCOIL。

View File

@@ -98,15 +98,15 @@ public class MesExCoilController extends BaseController {
return toAjax(iMesExCoilService.deleteWithValidByIds(Arrays.asList(exIds), true)); return toAjax(iMesExCoilService.deleteWithValidByIds(Arrays.asList(exIds), true));
} }
/** // /**
* 从 L2 系统同步出口卷实绩数据。 // * 从 L2 系统同步出口卷实绩数据。
* 首次全量同步,后续增量同步(以 insdate 为锚点)。 // * 首次全量同步,后续增量同步(以 insdate 为锚点)。
*/ // */
@Log(title = "出口卷数据同步", businessType = BusinessType.OTHER) // @Log(title = "出口卷数据同步", businessType = BusinessType.OTHER)
@RepeatSubmit(interval = 300000, message = "同步任务已提交,请勿重复操作") // @RepeatSubmit(interval = 300000, message = "同步任务已提交,请勿重复操作")
@PostMapping("/sync") // @PostMapping("/sync")
public R<Map<String, Object>> sync() { // public R<Map<String, Object>> sync() {
Map<String, Object> result = iMesExCoilService.syncExCoilData(); // Map<String, Object> result = iMesExCoilService.syncExCoilData();
return R.ok(result); // return R.ok(result);
} // }
} }

View File

@@ -48,8 +48,8 @@ public interface IMesExCoilService {
*/ */
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/** // /**
* 从 L2 系统同步出口卷实绩数据 // * 从 L2 系统同步出口卷实绩数据
*/ // */
Map<String, Object> syncExCoilData(); // Map<String, Object> syncExCoilData();
} }

View File

@@ -143,217 +143,217 @@ public class MesExCoilServiceImpl implements IMesExCoilService {
return baseMapper.deleteBatchIds(ids) > 0; return baseMapper.deleteBatchIds(ids) > 0;
} }
@Override // @Override
public Map<String, Object> syncExCoilData() { // public Map<String, Object> syncExCoilData() {
Date maxInsdate = baseMapper.getMaxInsdate(); // Date maxInsdate = baseMapper.getMaxInsdate();
boolean isFullSync = (maxInsdate == null); // boolean isFullSync = (maxInsdate == null);
//
List<Map<String, Object>> apiRows; // List<Map<String, Object>> apiRows;
if (isFullSync) { // if (isFullSync) {
apiRows = fetchAllFromApi(); // apiRows = fetchAllFromApi();
} else { // } else {
apiRows = fetchIncrementalFromApi(maxInsdate); // apiRows = fetchIncrementalFromApi(maxInsdate);
}
if (apiRows == null || apiRows.isEmpty()) {
Map<String, Object> result = new HashMap<>();
result.put("totalFetched", 0);
result.put("insertCount", 0);
result.put("updateCount", 0);
result.put("fullSync", isFullSync);
return result;
}
int insertCount = 0;
int updateCount = 0;
Date now = new Date();
// 1. 批量转换所有数据
List<MesExCoil> allEntities = new ArrayList<>(apiRows.size());
for (Map<String, Object> row : apiRows) {
MesExCoil entity = mapRowToEntity(row);
entity.setSyncTime(now);
allEntities.add(entity);
}
// // 2. 收集所有 excoilid
// List<String> excoilids = allEntities.stream()
// .map(MesExCoil::getExcoilid)
// .filter(StringUtils::isNotBlank)
// .distinct()
// .collect(java.util.stream.Collectors.toList());
// // 3. 批量查询已存在的记录
// Map<String, MesExCoil> existingMap = new HashMap<>();
// if (!excoilids.isEmpty()) {
// LambdaQueryWrapper<MesExCoil> wrapper = Wrappers.lambdaQuery();
// wrapper.in(MesExCoil::getExcoilid, excoilids);
// List<MesExCoil> existingList = baseMapper.selectList(wrapper);
// existingMap = existingList.stream()
// .collect(java.util.stream.Collectors.toMap(MesExCoil::getExcoilid, v -> v, (a, b) -> a));
// } // }
//
// 4. 分离新增和更新的记录 // if (apiRows == null || apiRows.isEmpty()) {
List<MesExCoil> toInsert = new ArrayList<>(); // Map<String, Object> result = new HashMap<>();
// List<MesExCoil> toUpdate = new ArrayList<>(); // result.put("totalFetched", 0);
// result.put("insertCount", 0);
for (MesExCoil entity : allEntities) { // result.put("updateCount", 0);
// MesExCoil existing = existingMap.get(entity.getExcoilid()); // result.put("fullSync", isFullSync);
// if (existing != null) { // return result;
// // 更新:设置主键 // }
// entity.setExId(existing.getExId()); //
// toUpdate.add(entity); // int insertCount = 0;
// } else { // int updateCount = 0;
// 新增 // Date now = new Date();
toInsert.add(entity); //
// } // // 1. 批量转换所有数据
} // List<MesExCoil> allEntities = new ArrayList<>(apiRows.size());
// for (Map<String, Object> row : apiRows) {
// 5. 批量插入 // MesExCoil entity = mapRowToEntity(row);
if (!toInsert.isEmpty()) { // entity.setSyncTime(now);
// 分批插入每批500条 // allEntities.add(entity);
int batchSize = 500; // }
for (int i = 0; i < toInsert.size(); i += batchSize) { //
int end = Math.min(i + batchSize, toInsert.size()); //// // 2. 收集所有 excoilid
List<MesExCoil> batch = toInsert.subList(i, end); //// List<String> excoilids = allEntities.stream()
baseMapper.insertBatch(batch); //// .map(MesExCoil::getExcoilid)
} //// .filter(StringUtils::isNotBlank)
insertCount = toInsert.size(); //// .distinct()
} //// .collect(java.util.stream.Collectors.toList());
//
// // 6. 批量更新 //// // 3. 批量查询已存在的记录
// if (!toUpdate.isEmpty()) { //// Map<String, MesExCoil> existingMap = new HashMap<>();
// // 分批更新每批500条 //// if (!excoilids.isEmpty()) {
//// LambdaQueryWrapper<MesExCoil> wrapper = Wrappers.lambdaQuery();
//// wrapper.in(MesExCoil::getExcoilid, excoilids);
//// List<MesExCoil> existingList = baseMapper.selectList(wrapper);
//// existingMap = existingList.stream()
//// .collect(java.util.stream.Collectors.toMap(MesExCoil::getExcoilid, v -> v, (a, b) -> a));
//// }
//
// // 4. 分离新增和更新的记录
// List<MesExCoil> toInsert = new ArrayList<>();
//// List<MesExCoil> toUpdate = new ArrayList<>();
//
// for (MesExCoil entity : allEntities) {
//// MesExCoil existing = existingMap.get(entity.getExcoilid());
//// if (existing != null) {
//// // 更新:设置主键
//// entity.setExId(existing.getExId());
//// toUpdate.add(entity);
//// } else {
// // 新增
// toInsert.add(entity);
//// }
// }
//
// // 5. 批量插入
// if (!toInsert.isEmpty()) {
// // 分批插入每批500条
// int batchSize = 500; // int batchSize = 500;
// for (int i = 0; i < toUpdate.size(); i += batchSize) { // for (int i = 0; i < toInsert.size(); i += batchSize) {
// int end = Math.min(i + batchSize, toUpdate.size()); // int end = Math.min(i + batchSize, toInsert.size());
// List<MesExCoil> batch = toUpdate.subList(i, end); // List<MesExCoil> batch = toInsert.subList(i, end);
// baseMapper.updateBatchById(batch, batch.size()); // baseMapper.insertBatch(batch);
// } // }
// updateCount = toUpdate.size(); // insertCount = toInsert.size();
// } // }
//
//// // 6. 批量更新
//// if (!toUpdate.isEmpty()) {
//// // 分批更新每批500条
//// int batchSize = 500;
//// for (int i = 0; i < toUpdate.size(); i += batchSize) {
//// int end = Math.min(i + batchSize, toUpdate.size());
//// List<MesExCoil> batch = toUpdate.subList(i, end);
//// baseMapper.updateBatchById(batch, batch.size());
//// }
//// updateCount = toUpdate.size();
//// }
//
// Map<String, Object> result = new HashMap<>();
// result.put("totalFetched", apiRows.size());
// result.put("insertCount", insertCount);
// result.put("updateCount", updateCount);
// result.put("fullSync", isFullSync);
// return result;
// }
Map<String, Object> result = new HashMap<>(); // @SuppressWarnings("unchecked")
result.put("totalFetched", apiRows.size()); // private List<Map<String, Object>> fetchAllFromApi() {
result.put("insertCount", insertCount); // List<Map<String, Object>> all = new ArrayList<>();
result.put("updateCount", updateCount); // int page = 1;
result.put("fullSync", isFullSync); // int pageSize = 500;
return result; // String baseUrl = getInternalApiBaseUrl();
} //
// while (true) {
@SuppressWarnings("unchecked") // String url = baseUrl + "/sql-server-api/excoil?page=" + page + "&pageSize=" + pageSize;
private List<Map<String, Object>> fetchAllFromApi() { // Map<String, Object> response = getRestTemplate().getForObject(url, Map.class);
List<Map<String, Object>> all = new ArrayList<>(); // if (response == null) break;
int page = 1; //
int pageSize = 500; // Map<String, Object> data = (Map<String, Object>) response.get("data");
String baseUrl = getInternalApiBaseUrl(); // if (data == null) break;
//
while (true) { // List<Map<String, Object>> rows = (List<Map<String, Object>>) data.get("rows");
String url = baseUrl + "/sql-server-api/excoil?page=" + page + "&pageSize=" + pageSize; // if (rows == null || rows.isEmpty()) break;
Map<String, Object> response = getRestTemplate().getForObject(url, Map.class); //
if (response == null) break; // all.addAll(rows);
// if (rows.size() < pageSize) break;
Map<String, Object> data = (Map<String, Object>) response.get("data"); // page++;
if (data == null) break; // }
// return all;
List<Map<String, Object>> rows = (List<Map<String, Object>>) data.get("rows"); // }
if (rows == null || rows.isEmpty()) break; //
// @SuppressWarnings("unchecked")
all.addAll(rows); // private List<Map<String, Object>> fetchIncrementalFromApi(Date since) {
if (rows.size() < pageSize) break; // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
page++; // String startTime = sdf.format(since);
} // String baseUrl = getInternalApiBaseUrl();
return all; // String url = baseUrl + "/sql-server-api/excoil/by-insdate?startTime=" + startTime;
} //
// Map<String, Object> response = getRestTemplate().getForObject(url, Map.class);
@SuppressWarnings("unchecked") // if (response != null && response.get("data") instanceof List) {
private List<Map<String, Object>> fetchIncrementalFromApi(Date since) { // return (List<Map<String, Object>>) response.get("data");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // }
String startTime = sdf.format(since); // return new ArrayList<>();
String baseUrl = getInternalApiBaseUrl(); // }
String url = baseUrl + "/sql-server-api/excoil/by-insdate?startTime=" + startTime; //
// private MesExCoil mapRowToEntity(Map<String, Object> row) {
Map<String, Object> response = getRestTemplate().getForObject(url, Map.class); // MesExCoil entity = new MesExCoil();
if (response != null && response.get("data") instanceof List) { // entity.setExcoilid(str(row.get("excoilid")));
return (List<Map<String, Object>>) response.get("data"); // entity.setEncoilid(str(row.get("encoilid")));
} // entity.setHotCoilid(str(row.get("hot_coilid")));
return new ArrayList<>(); // entity.setGrade(str(row.get("grade")));
} // entity.setOrderQuality(str(row.get("order_quality")));
// entity.setProductType(str(row.get("product_type")));
private MesExCoil mapRowToEntity(Map<String, Object> row) { // entity.setStatus(str(row.get("status")));
MesExCoil entity = new MesExCoil(); // entity.setShift(str(row.get("shift")));
entity.setExcoilid(str(row.get("excoilid"))); // entity.setParkType(str(row.get("park_type")));
entity.setEncoilid(str(row.get("encoilid"))); // entity.setSideTrim(str(row.get("side_trim")));
entity.setHotCoilid(str(row.get("hot_coilid"))); // entity.setEntryThick(bd(row.get("entry_thick")));
entity.setGrade(str(row.get("grade"))); // entity.setEntryWidth(bd(row.get("entry_width")));
entity.setOrderQuality(str(row.get("order_quality"))); // entity.setEntryWeight(bd(row.get("entry_weight")));
entity.setProductType(str(row.get("product_type"))); // entity.setUsedEntryWeight(bd(row.get("used_entry_weight")));
entity.setStatus(str(row.get("status"))); // entity.setExitThick(bd(row.get("exit_thick")));
entity.setShift(str(row.get("shift"))); // entity.setExitWidth(bd(row.get("exit_width")));
entity.setParkType(str(row.get("park_type"))); // entity.setExitLength(bd(row.get("exit_length")));
entity.setSideTrim(str(row.get("side_trim"))); // entity.setExitWeight(bd(row.get("exit_weight")));
entity.setEntryThick(bd(row.get("entry_thick"))); // entity.setCalcExitWeight(bd(row.get("calc_exit_weight")));
entity.setEntryWidth(bd(row.get("entry_width"))); // entity.setMeasExitWeight(bd(row.get("meas_exit_weight")));
entity.setEntryWeight(bd(row.get("entry_weight"))); // entity.setExitPosDev(bd(row.get("exit_pos_dev")));
entity.setUsedEntryWeight(bd(row.get("used_entry_weight"))); // entity.setExitNegDev(bd(row.get("exit_neg_dev")));
entity.setExitThick(bd(row.get("exit_thick"))); // entity.setInnerDiameter(bd(row.get("inner_diameter")));
entity.setExitWidth(bd(row.get("exit_width"))); // entity.setOuterDiameter(bd(row.get("outer_diameter")));
entity.setExitLength(bd(row.get("exit_length"))); // entity.setHeadpos(bd(row.get("headpos")));
entity.setExitWeight(bd(row.get("exit_weight"))); // entity.setTailpos(bd(row.get("tailpos")));
entity.setCalcExitWeight(bd(row.get("calc_exit_weight"))); // entity.setQuality(bd(row.get("quality")));
entity.setMeasExitWeight(bd(row.get("meas_exit_weight"))); // entity.setShapeQuality(bd(row.get("shape_quality")));
entity.setExitPosDev(bd(row.get("exit_pos_dev"))); // entity.setCrew(str(row.get("crew")));
entity.setExitNegDev(bd(row.get("exit_neg_dev"))); // entity.setReportFlag(longVal(row.get("report_flag")));
entity.setInnerDiameter(bd(row.get("inner_diameter"))); // entity.setSubid(longVal(row.get("subid")));
entity.setOuterDiameter(bd(row.get("outer_diameter"))); // entity.setRn(longVal(row.get("rn")));
entity.setHeadpos(bd(row.get("headpos"))); // entity.setOnlineDate(parseDate(row.get("online_date")));
entity.setTailpos(bd(row.get("tailpos"))); // entity.setStartDate(parseDate(row.get("start_date")));
entity.setQuality(bd(row.get("quality"))); // entity.setEndDate(parseDate(row.get("end_date")));
entity.setShapeQuality(bd(row.get("shape_quality"))); // entity.setWeldedDate(parseDate(row.get("welded_date")));
entity.setCrew(str(row.get("crew"))); // entity.setInsdate(parseDate(row.get("insdate")));
entity.setReportFlag(longVal(row.get("report_flag"))); // entity.setComments(str(row.get("comments")));
entity.setSubid(longVal(row.get("subid"))); // entity.setRemark(str(row.get("remark")));
entity.setRn(longVal(row.get("rn"))); // return entity;
entity.setOnlineDate(parseDate(row.get("online_date"))); // }
entity.setStartDate(parseDate(row.get("start_date"))); //
entity.setEndDate(parseDate(row.get("end_date"))); // private String str(Object value) {
entity.setWeldedDate(parseDate(row.get("welded_date"))); // return value == null ? null : String.valueOf(value);
entity.setInsdate(parseDate(row.get("insdate"))); // }
entity.setComments(str(row.get("comments"))); //
entity.setRemark(str(row.get("remark"))); // private BigDecimal bd(Object value) {
return entity; // if (value == null) return null;
} // if (value instanceof BigDecimal) return (BigDecimal) value;
// if (value instanceof Number) return BigDecimal.valueOf(((Number) value).doubleValue());
private String str(Object value) { // try { return new BigDecimal(String.valueOf(value)); } catch (Exception e) { return null; }
return value == null ? null : String.valueOf(value); // }
} //
// private Long longVal(Object value) {
private BigDecimal bd(Object value) { // if (value == null) return null;
if (value == null) return null; // if (value instanceof Number) return ((Number) value).longValue();
if (value instanceof BigDecimal) return (BigDecimal) value; // try { return Long.parseLong(String.valueOf(value)); } catch (Exception e) { return null; }
if (value instanceof Number) return BigDecimal.valueOf(((Number) value).doubleValue()); // }
try { return new BigDecimal(String.valueOf(value)); } catch (Exception e) { return null; } //
} // private Date parseDate(Object value) {
// if (value == null) return null;
private Long longVal(Object value) { // if (value instanceof Date) return (Date) value;
if (value == null) return null; // String s = String.valueOf(value);
if (value instanceof Number) return ((Number) value).longValue(); // if (s.isEmpty() || "null".equals(s)) return null;
try { return Long.parseLong(String.valueOf(value)); } catch (Exception e) { return null; } // try {
} // if (s.contains("T")) {
// s = s.replace("T", " ");
private Date parseDate(Object value) { // if (s.length() > 19) s = s.substring(0, 19);
if (value == null) return null; // }
if (value instanceof Date) return (Date) value; // return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(s);
String s = String.valueOf(value); // } catch (Exception e) {
if (s.isEmpty() || "null".equals(s)) return null; // return null;
try { // }
if (s.contains("T")) { // }
s = s.replace("T", " ");
if (s.length() > 19) s = s.substring(0, 19);
}
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(s);
} catch (Exception e) {
return null;
}
}
} }

View File

@@ -69,7 +69,6 @@ export default {
created() { created() {
const end = new Date(); const end = new Date();
const start = new Date(); const start = new Date();
start.setDate(start.getDate() - 7);
this.dateRange = [start, end]; this.dateRange = [start, end];
this.handleQuery(); this.handleQuery();
}, },
@@ -80,6 +79,10 @@ export default {
if (this.dateRange && this.dateRange.length === 2) { if (this.dateRange && this.dateRange.length === 2) {
params.startTime = this.dateRange[0]; params.startTime = this.dateRange[0];
params.endTime = this.dateRange[1]; params.endTime = this.dateRange[1];
} else {
const today = new Date();
params.startTime = this.formatDateTime(today, '00:00:00');
params.endTime = this.formatDateTime(today, '23:59:59');
} }
params.lineType = this.activeLine; params.lineType = this.activeLine;
getExcoilStatus(params).then(res => { getExcoilStatus(params).then(res => {
@@ -89,6 +92,12 @@ export default {
this.loading = false; this.loading = false;
}); });
}, },
formatDateTime(date, time) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day} ${time}`;
},
}, },
}; };
</script> </script>