CdwChangeLotRouteAction.java
package com.mycim.webapp.actions.lot.changeflow;
import com.fa.sesa.exception.Assert;
import com.fa.sesa.exception.Errors;
import com.fa.sesa.threadlocal.LocalContext;
import com.mycim.framework.utils.beans.BeanUtils;
import com.mycim.framework.utils.beans.PropertyUtils;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.framework.utils.lang.math.NumberUtils;
import com.mycim.valueobject.MessageIdList;
import com.mycim.valueobject.ObjectList;
import com.mycim.valueobject.bas.Relation;
import com.mycim.valueobject.consts.CarrierType;
import com.mycim.valueobject.consts.LinkTypeList;
import com.mycim.valueobject.consts.LotInfoConstants;
import com.mycim.valueobject.consts.SessionNames;
import com.mycim.valueobject.ems.Carrier;
import com.mycim.valueobject.wip.BatchLotStore;
import com.mycim.valueobject.wip.Lot;
import com.mycim.valueobject.wip.LotStatus;
import com.mycim.webapp.forms.RootForm;
import com.mycim.webapp.forms.lot.LotInfoForm;
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.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* @author can.yang
* @date 2021/6/9
**/
public class CdwChangeLotRouteAction extends ChangeLotRouteAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
long facilityRrn = LocalContext.getFacilityRrn();
long userRrn = LocalContext.getUserRrn();
// Populate the form bean instance
if (form == null) {
form = new RootForm();
if ("request".equals(mapping.getScope())) {
request.setAttribute(mapping.getAttribute(), form);
}
}
RootForm theform = (RootForm) form;
// Populate the new valid format id
Lot lot = initLotBaseInfoForJsp(request, true, null, null);
Carrier carrier = carrierService.getCarrier(lot.getCarrierRrn());
//卡控post future hold被hold住的lot
checkPostFutureHold(lot.getLotRrn());
Assert.isTrue(LotInfoConstants.isCategoryC(lot.getCreateCategory()),
Errors.create().key(MessageIdList.CDW_INVALID_CATEGORY).content("Current lot category is not allowed!").build());
Assert.isFalse(carrier == null || carrier.getInstanceRrn() <= NumberUtils.INTEGER_ZERO,
Errors.create().key(MessageIdList.LOT_CARRIER_MISSING)
.content("Can not find this carrier of " + "Lot.").build());
Assert.isFalse(StringUtils.equalsIgnoreCase(carrier.getObjectSubtype(), CarrierType.DUMMY) &&
lot.getAutoSplitMergFlag() != 1, Errors.create().key(MessageIdList.LOT_CARRIER_REMOVED)
.content(
"This carrier of Lot is already removed.")
.build());
Assert.isFalse(diffBatchQueryService.checkLotInBatch(lot.getLotRrn()),
Errors.create().key(MessageIdList.LOT_IN_BATCH).content("Lot in batch!").build());
boolean approveFlag = checkUserBtnByLotCategory(userRrn, facilityRrn, lot);
Assert.isTrue(approveFlag, Errors.create().key(MessageIdList.SYSTEM_NO_PERMISSION_SKIP_LOT)
.content("You do not have permission to Skip!").build());
wipQueryService.checkActiveInlineOcapId(lot.getLotRrn());
// added by Junfeng: Ignore the status--
Assert.isFalse(lot.getLotStatus() == null || !lot.getLotStatus().equals(LotStatus.HOLD),
Errors.create().key(MessageIdList.SCRAPLOT_STATUS_NOT_ALLOW)
.content("Lot status must be " + "Hold!").build());
theform.setInstanceStatus(lot.getLotStatus());
// populate lot information for next page
LotInfoForm lotInfoForm = new LotInfoForm();
PropertyUtils.copyProperties(lotInfoForm, lot);
Map conditionMap = BeanUtils.copyBeanToMap(lot);
lotInfoForm.setOperationDesc(ctxExecService.getOperationDescByProcessInfo(conditionMap));
lotInfoForm.setRecipePhysicalId(getRecipePhysicalId(lot));
lotInfoForm.setFlowSeq(ctxExecService.getFlowSeqByProcessInfo(conditionMap));
String equipmentRrns = request.getParameter("avaliableEqtRrn");
request.setAttribute("equipmentRrns", equipmentRrns);
request.setAttribute("oldOperationRrn", lot.getOperationRrn());
request.setAttribute(SessionNames.LOT_INFO_FORM_KEY, lotInfoForm);
request.setAttribute("processId", lot.getProcessId());
request.setAttribute("productId", lot.getProductId());
request.setAttribute("productVersion", lot.getProductVersion());
request.setAttribute("processVersion", lot.getProcessVersion());
request.setAttribute("isRework", StringUtils.isNotBlank(lot.getReworkCategory()));
if (lot.getReworkTransRrn() > NumberUtils.INTEGER_ZERO) {
request.setAttribute("isRework", "y");
} else {
request.setAttribute("isRework", "n");
}
request.setAttribute("executionRrn", lot.getExecutionRrn());
String s_flag = request.getParameter("flag");
if (s_flag != null) {
request.setAttribute("cancelFlag", "Y");
}
request.setAttribute("skip_flag", s_flag);
// futrue hold 查询
Collection allFutureHoldInfos = getAllFutureHoldForLot(facilityRrn, lot);
request.setAttribute(SessionNames.ALL_FUTUREHOLDLIST_KEY, allFutureHoldInfos);
return new ActionForward(mapping.getInput());
}
}