CdwUnTerminateLotSelectAction.java
package com.mycim.webapp.actions.lot.unterminatelot;
import com.fa.sesa.exception.Assert;
import com.fa.sesa.exception.Errors;
import com.fa.sesa.threadlocal.LocalContext;
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.LotConstants;
import com.mycim.valueobject.MessageIdList;
import com.mycim.valueobject.consts.CarrierType;
import com.mycim.valueobject.consts.LotInfoConstants;
import com.mycim.valueobject.ems.Carrier;
import com.mycim.valueobject.prp.Operation;
import com.mycim.valueobject.wip.Lot;
import com.mycim.valueobject.wip.LotStatus;
import com.mycim.webapp.WebUtils;
import com.mycim.webapp.forms.DummyForm;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author can.yang
* @date 2021/6/10
*/
public class CdwUnTerminateLotSelectAction extends UnTerminateLotSelectAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
long facilityRrn = LocalContext.getFacilityRrn();
initLotBaseInfoForJsp(request, true, LotStatus.TERMINATED, null);
DummyForm theform = (DummyForm) form;
Map<String, Object> cachePageInfo = (Map<String, Object>) WebUtils
.getCacheString2Obj(theform.getCachePageInfo());
if (cachePageInfo == null) {
cachePageInfo = new HashMap<String, Object>();
}
// Populate the new valid format id
String lotId = request.getParameter("lotId");
Assert.isFalse((lotId == null) || lotId.trim().equalsIgnoreCase(""),
Errors.create().key(MessageIdList.LOT_MISSING_ID).content("Lot Id can't be Empty!").build());
// Construct a new value object that stores the id,named space(implicit, derived),object(hard coded)
lotId = lotId.toUpperCase();
Lot lot = lotQueryService.getLot(lotId, facilityRrn);
//卡控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());
Carrier carrier = carrierService.getCarrier(lot.getCarrierRrn());
if (carrier != null && carrier.getInstanceRrn() > NumberUtils.INTEGER_ZERO) {
if (StringUtils.equalsIgnoreCase(carrier.getObjectSubtype(), CarrierType.DUMMY)) {
request.setAttribute("carrierType", carrier.getDmmType());
request.setAttribute("carrierCategory", carrier.getFlagType());
} else {
request.setAttribute("carrierType", carrier.getObjectSubtype());
request.setAttribute("carrierCategory", carrier.getFlagType());
}
}
Assert.isFalse(lot.getLotRrn() <= NumberUtils.INTEGER_ZERO,
Errors.create().key(MessageIdList.LOT_MISSING_ID).content("No such lotId").build());
Assert.isFalse(StringUtils.equalsIgnoreCase("P", lot.getLotType()),
Errors.create().content("The lot type should not be" + " P!").build());
Assert.isFalse(lot.getLotStatus() == null ||
lot.getLotStatus() != null && !lot.getLotStatus().equals(LotStatus.TERMINATED),
Errors.create().key(MessageIdList.LOT_LOT_STATUS_MUSTBE_TERMINATED).content("批次必须为终止状态!")
.build());
Assert.isFalse(lot.getQty1().intValue() <= NumberUtils.INTEGER_ZERO,
Errors.create().key(MessageIdList.LOT_LOT_QTY_GREATER_TNAN_ZERO).content("批次数量必须大于0!").build());
String lossTable = null;
Operation operation = new Operation();
Long operRrn = lot.getOperationRrn();
Assert.isTrue(operRrn != null && operRrn.intValue() != NumberUtils.INTEGER_ZERO,
Errors.create().key(MessageIdList.LOT_NON_UNTERMINATE_FOR_UNFIND_STEP).content("找不到该步骤。无法取消终止!")
.build());
operation = prpService.getOperation(operRrn);
if (operation.getLossTableId() != null && operation.getLossTableId() != "") {
lossTable = operation.getLossTableId();
}
// populate lot information for next page
LotInfoForm lotInfoForm = new LotInfoForm();
PropertyUtils.copyProperties(lotInfoForm, lot);
lotInfoForm.setRecipePhysicalId(getRecipePhysicalId(lot));
request.setAttribute("lotInfoFlag", StringUtils.trimToEmpty(request.getParameter("lotInfoFlag")));
cachePageInfo.put("lossTable", lossTable);
// modify by steven for fmi
List holdReasons = new ArrayList();
holdReasons = getHoldReasons(lot.getLotRrn());
cachePageInfo.put("unterminateCollection", holdReasons);
this.setTheFormSession(theform, request, lot, lotInfoForm, cachePageInfo);
return new ActionForward(mapping.getInput());
}
}