SplitRunCardSkipStepAction.java
package com.mycim.webapp.actions.splitruncardlot;
import com.fa.sesa.exception.Assert;
import com.fa.sesa.exception.Errors;
import com.fa.sesa.threadlocal.LocalContext;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.framework.utils.lang.collections.MapUtils;
import com.mycim.valueobject.MessageIdList;
import com.mycim.valueobject.ObjectList;
import com.mycim.valueobject.bas.ErrorMsg;
import com.mycim.valueobject.consts.ContextNames;
import com.mycim.valueobject.runcard.util.RunCardConstants;
import com.mycim.valueobject.security.User;
import com.mycim.valueobject.wip.*;
import com.mycim.webapp.WebUtils;
import com.mycim.webapp.actions.WipSetupAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SplitRunCardSkipStepAction extends WipSetupAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
Long facilityRrn = LocalContext.getFacilityRrn();
String lotId = WebUtils.getParameter("lotId", request);
Lot lot = lotInqService.getLot(lotId);
// 卡控 cst是否存在 sort job
Map<String, Object> lotInfoMap = lotRunCardQueryService.getRCLotInfoMap(lot.getLotId());
long carrierRrn = MapUtils.getLong(lotInfoMap, "carrierRrn", -1L);
this.checkWaitJobs(carrierRrn, 0L, 0L, null);
Assert.isFalse(lot == null || lot.getLotRrn() <= 0,
Errors.create().key(MessageIdList.LOT_LOTRRN_NOT_FOUND).content("Cannot Find Lot!").build());
Assert.isTrue(StringUtils.equals(LotStatus.HOLD, lot.getLotStatus()),
Errors.create().key(MessageIdList.LOT_LOT_STATUS_MUSTBE_HOLD).content("lot status must be hold!")
.build());
RunCardLotInfo lotInfo = runCardLotInqService.getRunCardLotInfo(lot.getLotRrn());
long refRrn = getInstanceRrn(ContextNames.EEN_CONTEXT_HOLDLOT, LocalContext.getFacilityRrn(),
ObjectList.CONTEXT_KEY);
List<Map> futureholdlistbylot = getFutureHoldListbyLot(refRrn, lot);
request.setAttribute("futureholdlistbylot", futureholdlistbylot);
request.setAttribute("priority", wipQueryService
.getHotflagSplicingPriority(new Integer(lot.getHotFlag()), lot.getPriority(), facilityRrn));
request.setAttribute("lotInfo", lotInfo);
return mapping.findForward("init");
}
public Map checkPollution(Map conditionMap) {
Map map = new HashMap();
int stepSequence = MapUtils.getIntValue(conditionMap, "stepSequence");
String lotId = MapUtils.getString(conditionMap, "lotId");
if (StringUtils.indexOf(lotId, ".MAINRC") <= 0 && StringUtils.indexOf(lotId, ".S") <= 0) {
lotId = lotId + ".MAINRC";
}
Lot sourceLot = lotQueryService.getLot(lotId);
LotRunCardStore store = lotRunCardQueryService.getSplitRunCardLotStore(sourceLot.getLotRrn());
SRCLotSpecialStep step = lotRunCardQueryService
.getLotSplitRunCardSpecialStep(store.getLotSpecialStepRrn(), stepSequence);
Assert.notNull(step, Errors.create().key(MessageIdList.RUNCARD_STEP_NO_FOUND).content("No runcard steps found")
.build());
ErrorMsg errorMsg = splitRunCardService.isSkipAllow(sourceLot.getPollutionLevel(), step.getContaminationFlag());
map.put("errorCode", errorMsg.getErrorCode());
map.put("errorMsg", errorMsg.getErrorMsg());
return map;
}
public ActionForward skipStepBySrc(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
Long facilityRrn = LocalContext.getFacilityRrn();
String lotId = WebUtils.getParameter("lotId", request);
int stepSequence = WebUtils.getParameterInt("stepSequence", request);
String reasonCode = WebUtils.getParameter("reasonCode", request);
String deptExt = WebUtils.getParameter("deptExt", request);
String reason = WebUtils.getParameter("reason", request);
Long userRrn = WebUtils.getParameterLong("userRrn", request);
if (StringUtils.indexOf(lotId, ".MAINRC") <= 0 && StringUtils.indexOf(lotId, ".S") <= 0) {
lotId = lotId + ".MAINRC";
}
Lot lot = lotQueryService.getLot(lotId);
Assert.isTrue(StringUtils.equals(LotStatus.HOLD, lot.getLotStatus()),
Errors.create().key(MessageIdList.LOT_LOT_STATUS_MUSTBE_HOLD).content("Lot status must be HOLD!")
.build());
LotRunCardStore runCardStore = lotRunCardQueryService.getSplitRunCardLotStore(lot.getLotRrn());
Assert.isFalse(runCardStore.getStepSequence().intValue() == stepSequence,
Errors.create().content("Can not skip to current step!").build());
long rcProcessRrn = getInstanceRrn(RunCardConstants.SRC_PROCESS_ID, facilityRrn, ObjectList.WFL_KEY);
Map tempInfo = wipWorkflowQueryService.getStepsInfo(rcProcessRrn, null, new HashMap());
User user = securityService.getUser(userRrn);
String reasonInfo = reasonCode + " " + deptExt + " " + user.getUserName() + " " + reason;
TransReason transReason = new TransReason();
transReason.setReasonCode(reasonCode);
transReason.setReason(reasonInfo);
transReason.setTransQty1(lot.getQty1());
transReason.setTransQty2(lot.getQty2());
transReason.setResponsibility(user.getInstanceId());
Map changeProcessInfo = new HashMap();
changeProcessInfo.put("lotRrn", new Long(lot.getLotRrn()));
changeProcessInfo.put("lotId", lot.getLotId());
//changeProcessInfo.put("lastUpdateTimestamp", lot.getLastUpdateTimestamp());
changeProcessInfo.put("lotStatus", lot.getLotStatus());
changeProcessInfo.put("qty", "" + lot.getQty1());
changeProcessInfo.put("lotOwner", lot.getLotOwner());
changeProcessInfo.put("currOperation", lot.getOperationId());
changeProcessInfo.put("transPerformedBy", user.getUserName());
changeProcessInfo.put("productRrn", lot.getProductRrn());
changeProcessInfo.put("productId", lot.getProductId());
changeProcessInfo.put("processRrn", lot.getProcessRrn());
changeProcessInfo.put("stageId", tempInfo.get("stageId"));
changeProcessInfo.put("layerId", tempInfo.get("layerId"));
changeProcessInfo.put("executionRrn", tempInfo.get("executionRrn"));
changeProcessInfo.put("operationRrn", tempInfo.get("operationRrn"));
changeProcessInfo.put("operationId", getInstanceId(((Long) tempInfo.get("operationRrn")).longValue()));
changeProcessInfo.put("operationVer", tempInfo.get("operationVer"));
changeProcessInfo.put("processStepVersion", tempInfo.get("processStepVersion"));
changeProcessInfo.put("processVersion", lot.getProcessVersion());
changeProcessInfo.put("processStepIdVersion", tempInfo.get("processStepIdVersion"));
changeProcessInfo.put("processStepVersion4wfl", tempInfo.get("processStepVersion4wfl"));
changeProcessInfo.put("nextoperationRrn1", tempInfo.get("nextoperationRrn1"));
changeProcessInfo.put("nextoperationRrn2", tempInfo.get("nextoperationRrn2"));
changeProcessInfo.put("nextprocessStepVersion1", tempInfo.get("nextprocessStepVersion1"));
changeProcessInfo.put("nextprocessStepIdVersion1", tempInfo.get("nextprocessStepIdVersion1"));
changeProcessInfo.put("nextprocessStepVersion2", tempInfo.get("nextprocessStepVersion2"));
changeProcessInfo.put("nextprocessStepIdVersion2", tempInfo.get("nextprocessStepIdVersion2"));
String temp = (String) tempInfo.get("processStepVersion");
String route = "";
if (temp != null) {
int i = 0;
int j = 0;
i = temp.indexOf("|");
if (i != -1) {
j = temp.indexOf("|", i + 1);
if (j > 0) {
route = temp.substring(i + 1, j);
} else if (i > 0) {
route = temp.substring(0, i);
}
}
}
route = route.replace(',', '.');
changeProcessInfo.put("route", route);
changeProcessInfo.put("reticleRrn", tempInfo.get("reticleRrn"));
changeProcessInfo.put("transPerformedBy", user.getUserName());
changeProcessInfo.put("transComments", request.getParameter("comments"));
changeProcessInfo.put("transReason", transReason);
changeProcessInfo.put("stepSequence", stepSequence);
changeProcessInfo.put("trackUnitFlag", "0");
changeProcessInfo.put("keepUnitHistoryFlag", "0");
splitRunCardService.skipStepBySrc(changeProcessInfo);
request.getRequestDispatcher("splitRunCardLotInfo.do?action=init&lotId=" + lotId).forward(request, response);
return WebUtils.NULLActionForward;
}
}