refactor: 注释掉出口卷数据同步相关代码并优化钢卷对比默认查询逻辑
本次提交主要变更: 1. 注释掉所有出口卷数据同步的接口、服务实现和相关工具方法 2. 优化钢卷对比页面的默认时间逻辑,移除默认7天前的起始时间,改为默认查询今日全天数据 3. 新增日期格式化工具方法统一处理时间字符串拼接 4. 完善钢卷对比接口的注释和字段映射逻辑
This commit is contained in:
@@ -428,20 +428,20 @@ public class SqlServerApiClient {
|
||||
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 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;
|
||||
|
||||
@@ -11,6 +11,7 @@ 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;
|
||||
@@ -25,14 +26,32 @@ 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) {
|
||||
@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("原料");
|
||||
@@ -40,6 +59,7 @@ public class CoilComparisonController {
|
||||
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) {
|
||||
@@ -47,23 +67,57 @@ public class CoilComparisonController {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理结果集,将外系统和本地系统的钢卷信息合并
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
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<>();
|
||||
item.put("excoilId", excoil.get("EXCOILID"));
|
||||
item.put("coilId", excoil.get("COILID"));
|
||||
// 添加外系统基本信息
|
||||
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("actualThick", excoil.get("ACTUAL_THICK"));
|
||||
item.put("actualWidth", excoil.get("ACTUAL_WIDTH"));
|
||||
item.put("actualWeight", excoil.get("ACTUAL_WEIGHT"));
|
||||
item.put("processCode", excoil.get("PROCESS_CODE"));
|
||||
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());
|
||||
@@ -75,6 +129,7 @@ public class CoilComparisonController {
|
||||
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", "已加工");
|
||||
@@ -83,6 +138,7 @@ public class CoilComparisonController {
|
||||
item.put("matchStatusDesc", "未加工");
|
||||
}
|
||||
} else {
|
||||
// 未匹配到本地数据,设置为未入库状态
|
||||
item.put("enterCoilNo", null);
|
||||
item.put("currentCoilNo", null);
|
||||
item.put("supplierCoilNo", null);
|
||||
@@ -98,6 +154,7 @@ public class CoilComparisonController {
|
||||
item.put("matchStatusDesc", "未入库");
|
||||
}
|
||||
} else {
|
||||
// 热轧卷ID为空,设置为未入库状态
|
||||
item.put("enterCoilNo", null);
|
||||
item.put("currentCoilNo", null);
|
||||
item.put("supplierCoilNo", null);
|
||||
|
||||
@@ -161,12 +161,12 @@ public class SqlServerApiBusinessService {
|
||||
return asRowList(client.queryExcoilByTimeRange(startTime, endTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 出口卷实绩列表(按数据写入时间),用于增量同步。
|
||||
*/
|
||||
public List<Map<String, Object>> getExcoilByInsdateRange(String startTime, String endTime) {
|
||||
return asRowList(client.queryExcoilByInsdateRange(startTime, endTime));
|
||||
}
|
||||
// /**
|
||||
// * 出口卷实绩列表(按数据写入时间),用于增量同步。
|
||||
// */
|
||||
// public List<Map<String, Object>> getExcoilByInsdateRange(String startTime, String endTime) {
|
||||
// return asRowList(client.queryExcoilByInsdateRange(startTime, endTime));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 出口卷实绩列表(分页),来自 PLTCM_PDO_EXCOIL。
|
||||
|
||||
@@ -166,16 +166,16 @@ public class SqlServerApiController {
|
||||
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));
|
||||
}
|
||||
// /**
|
||||
// * 出口卷实绩列表(按数据写入时间),用于增量同步。
|
||||
// * 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。
|
||||
|
||||
@@ -98,15 +98,15 @@ public class MesExCoilController extends BaseController {
|
||||
return toAjax(iMesExCoilService.deleteWithValidByIds(Arrays.asList(exIds), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 L2 系统同步出口卷实绩数据。
|
||||
* 首次全量同步,后续增量同步(以 insdate 为锚点)。
|
||||
*/
|
||||
@Log(title = "出口卷数据同步", businessType = BusinessType.OTHER)
|
||||
@RepeatSubmit(interval = 300000, message = "同步任务已提交,请勿重复操作")
|
||||
@PostMapping("/sync")
|
||||
public R<Map<String, Object>> sync() {
|
||||
Map<String, Object> result = iMesExCoilService.syncExCoilData();
|
||||
return R.ok(result);
|
||||
}
|
||||
// /**
|
||||
// * 从 L2 系统同步出口卷实绩数据。
|
||||
// * 首次全量同步,后续增量同步(以 insdate 为锚点)。
|
||||
// */
|
||||
// @Log(title = "出口卷数据同步", businessType = BusinessType.OTHER)
|
||||
// @RepeatSubmit(interval = 300000, message = "同步任务已提交,请勿重复操作")
|
||||
// @PostMapping("/sync")
|
||||
// public R<Map<String, Object>> sync() {
|
||||
// Map<String, Object> result = iMesExCoilService.syncExCoilData();
|
||||
// return R.ok(result);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ public interface IMesExCoilService {
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 从 L2 系统同步出口卷实绩数据
|
||||
*/
|
||||
Map<String, Object> syncExCoilData();
|
||||
// /**
|
||||
// * 从 L2 系统同步出口卷实绩数据
|
||||
// */
|
||||
// Map<String, Object> syncExCoilData();
|
||||
}
|
||||
|
||||
@@ -143,217 +143,217 @@ public class MesExCoilServiceImpl implements IMesExCoilService {
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> syncExCoilData() {
|
||||
Date maxInsdate = baseMapper.getMaxInsdate();
|
||||
boolean isFullSync = (maxInsdate == null);
|
||||
|
||||
List<Map<String, Object>> apiRows;
|
||||
if (isFullSync) {
|
||||
apiRows = fetchAllFromApi();
|
||||
} else {
|
||||
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));
|
||||
// @Override
|
||||
// public Map<String, Object> syncExCoilData() {
|
||||
// Date maxInsdate = baseMapper.getMaxInsdate();
|
||||
// boolean isFullSync = (maxInsdate == null);
|
||||
//
|
||||
// List<Map<String, Object>> apiRows;
|
||||
// if (isFullSync) {
|
||||
// apiRows = fetchAllFromApi();
|
||||
// } else {
|
||||
// apiRows = fetchIncrementalFromApi(maxInsdate);
|
||||
// }
|
||||
|
||||
// 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;
|
||||
for (int i = 0; i < toInsert.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, toInsert.size());
|
||||
List<MesExCoil> batch = toInsert.subList(i, end);
|
||||
baseMapper.insertBatch(batch);
|
||||
}
|
||||
insertCount = toInsert.size();
|
||||
}
|
||||
|
||||
// // 6. 批量更新
|
||||
// if (!toUpdate.isEmpty()) {
|
||||
// // 分批更新,每批500条
|
||||
//
|
||||
// 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. 分离新增和更新的记录
|
||||
// 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;
|
||||
// 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());
|
||||
// for (int i = 0; i < toInsert.size(); i += batchSize) {
|
||||
// int end = Math.min(i + batchSize, toInsert.size());
|
||||
// List<MesExCoil> batch = toInsert.subList(i, end);
|
||||
// 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<>();
|
||||
result.put("totalFetched", apiRows.size());
|
||||
result.put("insertCount", insertCount);
|
||||
result.put("updateCount", updateCount);
|
||||
result.put("fullSync", isFullSync);
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Map<String, Object>> fetchAllFromApi() {
|
||||
List<Map<String, Object>> all = new ArrayList<>();
|
||||
int page = 1;
|
||||
int pageSize = 500;
|
||||
String baseUrl = getInternalApiBaseUrl();
|
||||
|
||||
while (true) {
|
||||
String url = baseUrl + "/sql-server-api/excoil?page=" + page + "&pageSize=" + pageSize;
|
||||
Map<String, Object> response = getRestTemplate().getForObject(url, Map.class);
|
||||
if (response == null) break;
|
||||
|
||||
Map<String, Object> data = (Map<String, Object>) response.get("data");
|
||||
if (data == null) break;
|
||||
|
||||
List<Map<String, Object>> rows = (List<Map<String, Object>>) data.get("rows");
|
||||
if (rows == null || rows.isEmpty()) break;
|
||||
|
||||
all.addAll(rows);
|
||||
if (rows.size() < pageSize) break;
|
||||
page++;
|
||||
}
|
||||
return all;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Map<String, Object>> fetchIncrementalFromApi(Date since) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String startTime = sdf.format(since);
|
||||
String baseUrl = getInternalApiBaseUrl();
|
||||
String url = baseUrl + "/sql-server-api/excoil/by-insdate?startTime=" + startTime;
|
||||
|
||||
Map<String, Object> response = getRestTemplate().getForObject(url, Map.class);
|
||||
if (response != null && response.get("data") instanceof List) {
|
||||
return (List<Map<String, Object>>) response.get("data");
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private MesExCoil mapRowToEntity(Map<String, Object> row) {
|
||||
MesExCoil entity = new MesExCoil();
|
||||
entity.setExcoilid(str(row.get("excoilid")));
|
||||
entity.setEncoilid(str(row.get("encoilid")));
|
||||
entity.setHotCoilid(str(row.get("hot_coilid")));
|
||||
entity.setGrade(str(row.get("grade")));
|
||||
entity.setOrderQuality(str(row.get("order_quality")));
|
||||
entity.setProductType(str(row.get("product_type")));
|
||||
entity.setStatus(str(row.get("status")));
|
||||
entity.setShift(str(row.get("shift")));
|
||||
entity.setParkType(str(row.get("park_type")));
|
||||
entity.setSideTrim(str(row.get("side_trim")));
|
||||
entity.setEntryThick(bd(row.get("entry_thick")));
|
||||
entity.setEntryWidth(bd(row.get("entry_width")));
|
||||
entity.setEntryWeight(bd(row.get("entry_weight")));
|
||||
entity.setUsedEntryWeight(bd(row.get("used_entry_weight")));
|
||||
entity.setExitThick(bd(row.get("exit_thick")));
|
||||
entity.setExitWidth(bd(row.get("exit_width")));
|
||||
entity.setExitLength(bd(row.get("exit_length")));
|
||||
entity.setExitWeight(bd(row.get("exit_weight")));
|
||||
entity.setCalcExitWeight(bd(row.get("calc_exit_weight")));
|
||||
entity.setMeasExitWeight(bd(row.get("meas_exit_weight")));
|
||||
entity.setExitPosDev(bd(row.get("exit_pos_dev")));
|
||||
entity.setExitNegDev(bd(row.get("exit_neg_dev")));
|
||||
entity.setInnerDiameter(bd(row.get("inner_diameter")));
|
||||
entity.setOuterDiameter(bd(row.get("outer_diameter")));
|
||||
entity.setHeadpos(bd(row.get("headpos")));
|
||||
entity.setTailpos(bd(row.get("tailpos")));
|
||||
entity.setQuality(bd(row.get("quality")));
|
||||
entity.setShapeQuality(bd(row.get("shape_quality")));
|
||||
entity.setCrew(str(row.get("crew")));
|
||||
entity.setReportFlag(longVal(row.get("report_flag")));
|
||||
entity.setSubid(longVal(row.get("subid")));
|
||||
entity.setRn(longVal(row.get("rn")));
|
||||
entity.setOnlineDate(parseDate(row.get("online_date")));
|
||||
entity.setStartDate(parseDate(row.get("start_date")));
|
||||
entity.setEndDate(parseDate(row.get("end_date")));
|
||||
entity.setWeldedDate(parseDate(row.get("welded_date")));
|
||||
entity.setInsdate(parseDate(row.get("insdate")));
|
||||
entity.setComments(str(row.get("comments")));
|
||||
entity.setRemark(str(row.get("remark")));
|
||||
return entity;
|
||||
}
|
||||
|
||||
private String str(Object value) {
|
||||
return value == null ? null : String.valueOf(value);
|
||||
}
|
||||
|
||||
private BigDecimal bd(Object value) {
|
||||
if (value == null) return null;
|
||||
if (value instanceof BigDecimal) return (BigDecimal) value;
|
||||
if (value instanceof Number) return BigDecimal.valueOf(((Number) value).doubleValue());
|
||||
try { return new BigDecimal(String.valueOf(value)); } catch (Exception e) { return null; }
|
||||
}
|
||||
|
||||
private Long longVal(Object value) {
|
||||
if (value == null) return null;
|
||||
if (value instanceof Number) return ((Number) value).longValue();
|
||||
try { return Long.parseLong(String.valueOf(value)); } catch (Exception e) { return null; }
|
||||
}
|
||||
|
||||
private Date parseDate(Object value) {
|
||||
if (value == null) return null;
|
||||
if (value instanceof Date) return (Date) value;
|
||||
String s = String.valueOf(value);
|
||||
if (s.isEmpty() || "null".equals(s)) 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;
|
||||
}
|
||||
}
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private List<Map<String, Object>> fetchAllFromApi() {
|
||||
// List<Map<String, Object>> all = new ArrayList<>();
|
||||
// int page = 1;
|
||||
// int pageSize = 500;
|
||||
// String baseUrl = getInternalApiBaseUrl();
|
||||
//
|
||||
// while (true) {
|
||||
// String url = baseUrl + "/sql-server-api/excoil?page=" + page + "&pageSize=" + pageSize;
|
||||
// Map<String, Object> response = getRestTemplate().getForObject(url, Map.class);
|
||||
// if (response == null) break;
|
||||
//
|
||||
// Map<String, Object> data = (Map<String, Object>) response.get("data");
|
||||
// if (data == null) break;
|
||||
//
|
||||
// List<Map<String, Object>> rows = (List<Map<String, Object>>) data.get("rows");
|
||||
// if (rows == null || rows.isEmpty()) break;
|
||||
//
|
||||
// all.addAll(rows);
|
||||
// if (rows.size() < pageSize) break;
|
||||
// page++;
|
||||
// }
|
||||
// return all;
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private List<Map<String, Object>> fetchIncrementalFromApi(Date since) {
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// String startTime = sdf.format(since);
|
||||
// String baseUrl = getInternalApiBaseUrl();
|
||||
// String url = baseUrl + "/sql-server-api/excoil/by-insdate?startTime=" + startTime;
|
||||
//
|
||||
// Map<String, Object> response = getRestTemplate().getForObject(url, Map.class);
|
||||
// if (response != null && response.get("data") instanceof List) {
|
||||
// return (List<Map<String, Object>>) response.get("data");
|
||||
// }
|
||||
// return new ArrayList<>();
|
||||
// }
|
||||
//
|
||||
// private MesExCoil mapRowToEntity(Map<String, Object> row) {
|
||||
// MesExCoil entity = new MesExCoil();
|
||||
// entity.setExcoilid(str(row.get("excoilid")));
|
||||
// entity.setEncoilid(str(row.get("encoilid")));
|
||||
// entity.setHotCoilid(str(row.get("hot_coilid")));
|
||||
// entity.setGrade(str(row.get("grade")));
|
||||
// entity.setOrderQuality(str(row.get("order_quality")));
|
||||
// entity.setProductType(str(row.get("product_type")));
|
||||
// entity.setStatus(str(row.get("status")));
|
||||
// entity.setShift(str(row.get("shift")));
|
||||
// entity.setParkType(str(row.get("park_type")));
|
||||
// entity.setSideTrim(str(row.get("side_trim")));
|
||||
// entity.setEntryThick(bd(row.get("entry_thick")));
|
||||
// entity.setEntryWidth(bd(row.get("entry_width")));
|
||||
// entity.setEntryWeight(bd(row.get("entry_weight")));
|
||||
// entity.setUsedEntryWeight(bd(row.get("used_entry_weight")));
|
||||
// entity.setExitThick(bd(row.get("exit_thick")));
|
||||
// entity.setExitWidth(bd(row.get("exit_width")));
|
||||
// entity.setExitLength(bd(row.get("exit_length")));
|
||||
// entity.setExitWeight(bd(row.get("exit_weight")));
|
||||
// entity.setCalcExitWeight(bd(row.get("calc_exit_weight")));
|
||||
// entity.setMeasExitWeight(bd(row.get("meas_exit_weight")));
|
||||
// entity.setExitPosDev(bd(row.get("exit_pos_dev")));
|
||||
// entity.setExitNegDev(bd(row.get("exit_neg_dev")));
|
||||
// entity.setInnerDiameter(bd(row.get("inner_diameter")));
|
||||
// entity.setOuterDiameter(bd(row.get("outer_diameter")));
|
||||
// entity.setHeadpos(bd(row.get("headpos")));
|
||||
// entity.setTailpos(bd(row.get("tailpos")));
|
||||
// entity.setQuality(bd(row.get("quality")));
|
||||
// entity.setShapeQuality(bd(row.get("shape_quality")));
|
||||
// entity.setCrew(str(row.get("crew")));
|
||||
// entity.setReportFlag(longVal(row.get("report_flag")));
|
||||
// entity.setSubid(longVal(row.get("subid")));
|
||||
// entity.setRn(longVal(row.get("rn")));
|
||||
// entity.setOnlineDate(parseDate(row.get("online_date")));
|
||||
// entity.setStartDate(parseDate(row.get("start_date")));
|
||||
// entity.setEndDate(parseDate(row.get("end_date")));
|
||||
// entity.setWeldedDate(parseDate(row.get("welded_date")));
|
||||
// entity.setInsdate(parseDate(row.get("insdate")));
|
||||
// entity.setComments(str(row.get("comments")));
|
||||
// entity.setRemark(str(row.get("remark")));
|
||||
// return entity;
|
||||
// }
|
||||
//
|
||||
// private String str(Object value) {
|
||||
// return value == null ? null : String.valueOf(value);
|
||||
// }
|
||||
//
|
||||
// private BigDecimal bd(Object value) {
|
||||
// if (value == null) return null;
|
||||
// if (value instanceof BigDecimal) return (BigDecimal) value;
|
||||
// if (value instanceof Number) return BigDecimal.valueOf(((Number) value).doubleValue());
|
||||
// try { return new BigDecimal(String.valueOf(value)); } catch (Exception e) { return null; }
|
||||
// }
|
||||
//
|
||||
// private Long longVal(Object value) {
|
||||
// if (value == null) return null;
|
||||
// if (value instanceof Number) return ((Number) value).longValue();
|
||||
// try { return Long.parseLong(String.valueOf(value)); } catch (Exception e) { return null; }
|
||||
// }
|
||||
//
|
||||
// private Date parseDate(Object value) {
|
||||
// if (value == null) return null;
|
||||
// if (value instanceof Date) return (Date) value;
|
||||
// String s = String.valueOf(value);
|
||||
// if (s.isEmpty() || "null".equals(s)) 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;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -69,7 +69,6 @@ export default {
|
||||
created() {
|
||||
const end = new Date();
|
||||
const start = new Date();
|
||||
start.setDate(start.getDate() - 7);
|
||||
this.dateRange = [start, end];
|
||||
this.handleQuery();
|
||||
},
|
||||
@@ -80,6 +79,10 @@ export default {
|
||||
if (this.dateRange && this.dateRange.length === 2) {
|
||||
params.startTime = this.dateRange[0];
|
||||
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;
|
||||
getExcoilStatus(params).then(res => {
|
||||
@@ -89,6 +92,12 @@ export default {
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user