ArgRecipeSetupAction.java
package com.mycim.webapp.actions;
import com.fa.sesa.exception.Assert;
import com.fa.sesa.exception.Errors;
import com.fa.sesa.threadlocal.LocalContext;
import com.mycim.framework.context.spring.SpringContext;
import com.mycim.framework.jdbc.Page;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.framework.utils.lang.collections.MapUtils;
import com.mycim.framework.utils.lang.math.NumberUtils;
import com.mycim.server.ems.service.EmsService;
import com.mycim.server.rcp.service.ArgRecipeService;
import com.mycim.server.wip.service.ArgRecipeQueryService;
import com.mycim.utils.CheckRegexUtils;
import com.mycim.valueobject.MessageIdList;
import com.mycim.valueobject.ObjectList;
import com.mycim.valueobject.SystemConstant;
import com.mycim.valueobject.prp.ArgRecipeInfo;
import com.mycim.webapp.WebUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
/**
* @author finatice.yang
* @date 2021/6/23
**/
public class ArgRecipeSetupAction extends AbstractAction {
protected ArgRecipeService argRecipeService = SpringContext.getBean(ArgRecipeService.class);
protected ArgRecipeQueryService argRecipeQueryService = SpringContext.getBean(ArgRecipeQueryService.class);
protected EmsService emsService = SpringContext.getBean(EmsService.class);
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
return mapping.findForward("query");
}
public ActionForward qryArgList(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
String eqptId = CheckRegexUtils.formatSearchString(request.getParameter("eqptId"));
String flowRecipeId = CheckRegexUtils.formatSearchString(request.getParameter("flowRecipeId"));
ArgRecipeInfo condition = new ArgRecipeInfo();
condition.setEqptId(eqptId);
condition.setFlowRecipeId(flowRecipeId);
List<ArgRecipeInfo> argList = argRecipeQueryService.getArgInfoList(condition);
request.setAttribute("argList", argList);
request.setAttribute("eqptId", eqptId);
request.setAttribute("flowRecipeId", flowRecipeId);
return mapping.findForward("query");
}
public ActionForward qryArgHistory(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
String init = request.getParameter("init");//点击Arg Recipe Setup History菜单后不自动query
if (StringUtils.isNotEmpty(init) && StringUtils.equalsIgnoreCase(SystemConstant.Str.ONE,init)){
return mapping.findForward("history");
}
String eqptId = CheckRegexUtils.formatSearchString(request.getParameter("eqptId"));
String flowRecipeId = CheckRegexUtils.formatSearchString(request.getParameter("flowRecipeId"));
Page page = new Page(WebUtils.getThisPage(request), WebUtils.getPageSize(request));
ArgRecipeInfo condition = new ArgRecipeInfo();
condition.setEqptId(eqptId);
condition.setFlowRecipeId(flowRecipeId);
page = argRecipeQueryService.getArgInfoListHistory(condition, page);
request.setAttribute("currentPage", page.getPageNo());
request.setAttribute("lastPage", page.getTotalPages());
request.setAttribute("argList", page.getResults());
request.setAttribute("eqptId", eqptId);
request.setAttribute("flowRecipeId", flowRecipeId);
return mapping.findForward("history");
}
public void addArgRecipe(Map<String, Object> params) {
String eqptId = StringUtils.trimToUpperCase(MapUtils.getString(params, "eqptId"));
long eqptRrn = getInstanceRrn(eqptId, LocalContext.getFacilityRrn(), ObjectList.ENTITY_KEY);
Assert.isFalse(eqptRrn <= 0, Errors.create().key(MessageIdList.EQUIPMENT_ID_NOT_EXIST).build());
Map eqptExt = emsService.getEquipmentExtMap(eqptRrn);
String diffFlag = MapUtils.getString(eqptExt, "diffFlag");
Assert.isTrue(CheckRegexUtils.checkFlagOn(diffFlag), Errors.create().content("Eqp is not a diff eqp!").build());
String flowRecipeId = StringUtils.trimToUpperCase(MapUtils.getString(params, "flowRecipeId"));
long flowRecipeRrn = getInstanceRrn(flowRecipeId, LocalContext.getFacilityRrn(), ObjectList.RECIPE_KEY);
Assert.isFalse(flowRecipeRrn <= 0, Errors.create().key(MessageIdList.RECIPE_NOT_DEFINED).build());
String argRecipeId = StringUtils.trimToUpperCase(MapUtils.getString(params, "argRecipeId"));
long argRecipeRrn = getInstanceRrn(argRecipeId, LocalContext.getFacilityRrn(), ObjectList.RECIPE_KEY);
Assert.isFalse(argRecipeRrn <= 0, Errors.create().key(MessageIdList.ARG_RECIPE_NOT_DEFINED).build());
Integer lowerWaferCount = MapUtils.getInteger(params, "lowerWaferCount");
Integer upperWaferCount = MapUtils.getInteger(params, "upperWaferCount");
Assert.isFalse(lowerWaferCount == null && upperWaferCount == null,
Errors.create().key(MessageIdList.WAFER_QTY_CANNOT_EMPTY).build());
if (lowerWaferCount == null) {
lowerWaferCount = NumberUtils.INTEGER_ZERO;
}
ArgRecipeInfo argRecipeInfo = new ArgRecipeInfo();
argRecipeInfo.setEqptId(eqptId);
argRecipeInfo.setEqptRrn(eqptRrn);
argRecipeInfo.setFlowRecipeId(flowRecipeId);
argRecipeInfo.setFlowRecipeRrn(flowRecipeRrn);
argRecipeInfo.setArgRecipeId(argRecipeId);
argRecipeInfo.setArgRecipeRrn(argRecipeRrn);
argRecipeInfo.setLowerWaferCount(lowerWaferCount);
argRecipeInfo.setUpperWaferCount(upperWaferCount);
argRecipeService.addArgInfo(argRecipeInfo);
}
public void modifyArgInfo(Map<String, Object> params) {
String argRecipeId = StringUtils.trimToUpperCase(MapUtils.getString(params, "argRecipeId"));
long argRecipeRrn = getInstanceRrn(argRecipeId, LocalContext.getFacilityRrn(), ObjectList.RECIPE_KEY);
Assert.isFalse(argRecipeRrn <= 0, Errors.create().key(MessageIdList.RECIPE_INVALID_ID).build());
Integer lowerWaferCount = MapUtils.getInteger(params, "lowerWaferCount");
Integer upperWaferCount = MapUtils.getInteger(params, "upperWaferCount");
Assert.isFalse(lowerWaferCount == null && upperWaferCount == null,
Errors.create().key(MessageIdList.WAFER_QTY_CANNOT_EMPTY).build());
if (lowerWaferCount == null) {
lowerWaferCount = NumberUtils.INTEGER_ZERO;
}
ArgRecipeInfo argRecipeInfo = new ArgRecipeInfo();
argRecipeInfo.setEqptRrn(MapUtils.getLong(params, "eqptRrn"));
argRecipeInfo.setFlowRecipeId(MapUtils.getString(params, "flowRecipeId"));
argRecipeInfo.setSequence(MapUtils.getLong(params, "sequence"));
argRecipeInfo.setArgRecipeId(argRecipeId);
argRecipeInfo.setArgRecipeRrn(argRecipeRrn);
argRecipeInfo.setLowerWaferCount(lowerWaferCount);
argRecipeInfo.setUpperWaferCount(upperWaferCount);
argRecipeService.modifyArgInfo(argRecipeInfo);
}
public void deleteArgInfos(Map<String, Object> params) {
List<String> argInfoList = new ArrayList<>();
Object argInfos = MapUtils.getObject(params, "argInfos");
if (argInfos instanceof List) {
argInfoList = (List<String>) argInfos;
} else if (argInfos instanceof String) {
argInfoList.add(MapUtils.getString(params, "argInfos"));
}
List<ArgRecipeInfo> argList = new ArrayList<ArgRecipeInfo>();
for (String argInfo : argInfoList) {
String[] infos = StringUtils.split(argInfo, ",");
long eqptRrn = NumberUtils.toLong(infos[0]);
if (eqptRrn > 0) {
String flowRecipeId = infos[1];
long sequence = NumberUtils.toLong(infos[2]);
ArgRecipeInfo info = new ArgRecipeInfo();
info.setEqptRrn(eqptRrn);
info.setFlowRecipeId(flowRecipeId);
info.setSequence(sequence);
argList.add(info);
}
}
argRecipeService.deleteArgInfos(argList);
}
}