forked from I3-YF/i3plus-mes-yfai
QMS点检结果脚本
parent
552e0098c4
commit
56f285e1cf
@ -0,0 +1,82 @@
|
|||||||
|
import cn.estsh.i3plus.platform.plugin.datasource.DynamicDataSourceProxy
|
||||||
|
import cn.estsh.i3plus.pojo.mes.dbinterface.MesInterfaceDataMapper
|
||||||
|
import com.alibaba.fastjson.JSON
|
||||||
|
import lombok.Getter
|
||||||
|
import lombok.Setter
|
||||||
|
import org.slf4j.Logger
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
|
||||||
|
|
||||||
|
import javax.annotation.Resource
|
||||||
|
import java.sql.Connection
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : QMS点检结果
|
||||||
|
* @Reference :
|
||||||
|
* @Author : gsz
|
||||||
|
* @CreateDate 2024/7/5 10:43
|
||||||
|
* @Modify:
|
||||||
|
* */
|
||||||
|
class MesSpotCheckOrderToSap {
|
||||||
|
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(MesSpotCheckOrderToSap.class)
|
||||||
|
|
||||||
|
|
||||||
|
@Resource(name = "yfasDataSource")
|
||||||
|
private DynamicDataSourceProxy yfasDataSource;
|
||||||
|
|
||||||
|
@Resource(name = "mesDataSource")
|
||||||
|
private DynamicDataSourceProxy mesDataSource;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Connection mesConn;
|
||||||
|
|
||||||
|
def filterData(MesInterfaceDataMapper mapper, List<Map<String, Object>> srcData) throws Exception {
|
||||||
|
if (srcData == null || srcData.size() == 0) {
|
||||||
|
return srcData
|
||||||
|
}
|
||||||
|
LOGGER.info("-------- filterData Start QMS点检结果 ---------------")
|
||||||
|
//汇总
|
||||||
|
List<Map<String, Object>> destData = new ArrayList<>();
|
||||||
|
for (Map<String, Object> rowMap : srcData) {
|
||||||
|
def orderId = String.valueOf(rowMap.get("id"));
|
||||||
|
Map<String, Object> sqlParams = new HashMap<>(1)
|
||||||
|
sqlParams.put("pid", orderId);
|
||||||
|
StringBuffer sql = new StringBuffer("select * from mes_spot_check_order_result where pid =:pid ");
|
||||||
|
List<Map<String, Object>> resultMap = this.queryDataTable(sql.toString(), sqlParams)
|
||||||
|
if (resultMap.size() > 0) {
|
||||||
|
LOGGER.info("--------QMS点检结果明细---------------")
|
||||||
|
List<Map<String, Object>> checkList = new ArrayList<>();
|
||||||
|
for (Map<String, Object> objectMap : resultMap) {
|
||||||
|
Map<String, Object> checkMap = new HashMap<>();
|
||||||
|
|
||||||
|
checkMap.put("task_item_name",objectMap.get("task_item_name"));
|
||||||
|
checkMap.put("max_value",objectMap.get("max_value"));
|
||||||
|
checkMap.put("min_value",objectMap.get("min_value"));
|
||||||
|
checkMap.put("task_item_type",objectMap.get("data_type"));
|
||||||
|
checkMap.put("item_task_result",objectMap.get("spot_check_result"));
|
||||||
|
checkMap.put("task_value",objectMap.get("spot_check_real_value"));
|
||||||
|
checkMap.put("IsAuto",objectMap.get("spot_check_item_type"));
|
||||||
|
checkMap.put("ConfigValue",objectMap.get("spot_check_set_value"));
|
||||||
|
checkMap.put("Remark",objectMap.get("remark"));
|
||||||
|
|
||||||
|
checkList.add(checkMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
rowMap.put("items",JSON.toJSONString(checkList))
|
||||||
|
}
|
||||||
|
destData.add(rowMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return destData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Map<String, Object>> queryDataTable(String sql, Map<String, Object> params) {
|
||||||
|
NamedParameterJdbcTemplate namedJdbcTemplate = new NamedParameterJdbcTemplate(mesDataSource.getDataSource())
|
||||||
|
|
||||||
|
List<Map<String, Object>> dataMap = namedJdbcTemplate.queryForList(sql, params)
|
||||||
|
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue