EquipmentConstrainHistDAOImpl.java
package com.mycim.server.constrain.dao.impl;
import com.mycim.framework.jdbc.JdbcTemplate;
import com.mycim.framework.jdbc.Page;
import com.mycim.framework.jdbc.mapper.RowMapper;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.framework.utils.lang.time.DateUtils;
import com.mycim.server.constrain.dao.EquipmentConstrainHistDAO;
import com.mycim.valueobject.prp.EquipmentConstrainInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Repository
public class EquipmentConstrainHistDAOImpl implements EquipmentConstrainHistDAO {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public Page qryEquipmentConstrainHist(EquipmentConstrainInfo ecs, Page page) {
List args = new ArrayList();
StringBuilder sb = new StringBuilder("SELECT ");
sb.append(" ECH.PRODUCT_ID,ECH.PROCESS_ID,ECH.OPERATION_ID, ");
sb.append(" ECH.RECIPE_ID,ECH.LOT_ID,ECH.EQUIPMENT_ID,ECH.CONSTRAIN_ACTION,ECH.CONSTRAIN_TYPE,ECH" +
".CONSTRAIN_STATUS,");
sb.append(" ECH.REMARK,ECH.CREATE_BY,ECH.MODIFY_BY,ECH.CREATE_TIME, ECH.MODIFY_TIME, ECH.ATTRIBUTE_DATA1," +
"ECH.ATTRIBUTE_DATA2,");
sb.append(
" ECH.ATTRIBUTE_DATA3, ECH.ATTRIBUTE_DATA4,ECH.ATTRIBUTE_DATA5, ECH.CONSTRAIN_SEQ, ECH" + ".ROUTE_ID," +
"ECH.CUSTOMER_ID,");
sb.append(" ECH.DAILY_WAFER_COUNT, ECH.TOTAL_WAFER_COUNT, ECH.EXPIRE_DATE, ECH.STAGE_ID, TR.TRANS_ID,");
sb.append(" TR.TRANS_START_TIMESTAMP, TR.TRANS_PERFORMED_BY ");
sb.append(" FROM EQUIPMENT_CONSTRAIN_HISTORY ECH,TRANSACTION_LOG TR WHERE ECH.TRANS_RRN=TR.TRANS_RRN ");
if (StringUtils.isNotBlank(ecs.getEquipmentId())) {
sb.append(" and ECH.EQUIPMENT_ID LIKE ? ");
args.add(ecs.getEquipmentId().replace("*", "%"));
}
if (StringUtils.isNotBlank(ecs.getStartDate())) {
sb.append(" AND TR.TRANS_START_TIMESTAMP >=? ");
args.add(DateUtils.parse(ecs.getStartDate(), "yyyy/MM/dd"));
}
if (StringUtils.isNotBlank(ecs.getEndDate())) {
sb.append(" AND TR.TRANS_START_TIMESTAMP <=? ");
args.add(DateUtils.parse(ecs.getEndDate(), "yyyy/MM/dd"));
}
sb.append("ORDER BY TR.TRANS_START_TIMESTAMP DESC ");
return jdbcTemplate.queryForPage(page, sb.toString(), args.toArray(), new RowMapper<Map<String, Object>>() {
@Override
public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
Map<String, Object> map = new HashMap<String, Object>();
map.put("seq", rowNum + 1);
map.put("productId", rs.getString("PRODUCT_ID"));
map.put("processId", rs.getString("PROCESS_ID"));
map.put("operationId", rs.getString("OPERATION_ID"));
map.put("recipeId", rs.getString("RECIPE_ID"));
map.put("lotId", rs.getString("LOT_ID"));
map.put("eqptId", rs.getString("EQUIPMENT_ID"));
String constrainAction = rs.getString("CONSTRAIN_ACTION");
map.put("constrainAction", rs.getString("CONSTRAIN_ACTION"));
map.put("constrainActionForShow",
StringUtils.equalsIgnoreCase(constrainAction, EquipmentConstrainInfo.REJECTSTOP) ? "RN" : "PN");
map.put("constrainType", rs.getString("CONSTRAIN_TYPE"));
map.put("constrainStatus", rs.getString("CONSTRAIN_STATUS"));
map.put("remark", rs.getString("REMARK"));
map.put("constrainSeq", rs.getString("CONSTRAIN_SEQ"));
map.put("routeId", rs.getString("ROUTE_ID"));
map.put("customerId", rs.getString("CUSTOMER_ID"));
map.put("dailyWaferCount", rs.getString("DAILY_Wafer_Count"));
map.put("totalWaferCount", rs.getString("TOTAL_Wafer_Count"));
map.put("expireDate", rs.getString("EXPIRE_DATE"));
map.put("stageId", rs.getString("STAGE_ID"));
map.put("transId", rs.getString("TRANS_ID"));
String startTime = rs.getString("TRANS_START_TIMESTAMP");
if (startTime.indexOf(".") > 0) {
map.put("transStartTimestamp", startTime.substring(0, startTime.indexOf(".")));
} else {
map.put("transStartTimestamp", rs.getString("TRANS_START_TIMESTAMP"));
}
map.put("transPerformedBy", rs.getString("TRANS_PERFORMED_BY"));
return map;
}
});
}
}