package org.jeecg.modules.mdcJc.service.impl;
|
|
import org.jeecg.common.util.dynamic.db.DynamicDBUtil;
|
import org.jeecg.modules.mdcJc.dto.MesRcJobreport;
|
import org.jeecg.modules.mdcJc.service.MesRcJobreportService;
|
import org.springframework.stereotype.Service;
|
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.Collections;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
|
/**
|
* @Author: Lius
|
* @CreateTime: 2025-04-14
|
* @Description:
|
*/
|
@Service
|
public class MesRcJobreportServiceImpl implements MesRcJobreportService {
|
|
|
@Override
|
public List<MesRcJobreport> findPartProcessInfo(String date, List<String> equipmentIdList) {
|
List<MesRcJobreport> result = new ArrayList<>();
|
|
// 空参数检查
|
if (equipmentIdList == null || equipmentIdList.isEmpty()) {
|
return result;
|
}
|
|
// 构建动态IN子句
|
String inClause = String.join(",", Collections.nCopies(equipmentIdList.size(), "?"));
|
|
// 构建安全SQL(注意WHERE子句的空格)
|
String sql = "SELECT the_data AS thedate, " +
|
"device_number AS deviceNumber, " +
|
"okuqty, qty " +
|
"FROM hegelv " +
|
"WHERE the_data = ? " + // 使用参数化查询
|
"AND device_number IN (" + inClause + ")";
|
|
// 准备参数(日期在前,设备ID在后)
|
List<String> params = new ArrayList<>();
|
params.add(date);
|
params.addAll(equipmentIdList);
|
|
System.out.println("SQL参数: date=" + date + ", equipmentIds=" + equipmentIdList);
|
|
List<Map<String, Object>> mapList = DynamicDBUtil.findList("basicDB", sql, params.toArray());
|
|
if (mapList == null || mapList.isEmpty()) {
|
return result;
|
}
|
|
result = mapList.stream().map(map -> {
|
MesRcJobreport mesRcJobreport = new MesRcJobreport();
|
mesRcJobreport.setBillDate(map.get("thedate").toString());
|
mesRcJobreport.setDeviceNumber(map.get("deviceNumber").toString());
|
mesRcJobreport.setOkuqty(new BigDecimal(map.get("okuqty").toString()));
|
mesRcJobreport.setQty(new BigDecimal(map.get("qty").toString()));
|
return mesRcJobreport;
|
}).collect(Collectors.toList());
|
|
return result;
|
}
|
}
|