CdwTerminateLotSelectAction.java
package com.mycim.webapp.actions.lot.terminatelot;
import com.fa.sesa.exception.Assert;
import com.fa.sesa.exception.Errors;
import com.fa.sesa.i18n.I18nUtils;
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.MessageIdList;
import com.mycim.valueobject.consts.LotInfoConstants;
import com.mycim.valueobject.prp.Operation;
import com.mycim.valueobject.wip.BatchLotStore;
import com.mycim.valueobject.wip.Lot;
import com.mycim.valueobject.wip.LotStatus;
import com.mycim.webapp.Constants;
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.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author can.yang
* @date 2021/6/10
*/
public class CdwTerminateLotSelectAction extends TerminateLotSelectAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
String language = I18nUtils.getCurrentLanguage().toString();
long facilityRrn = LocalContext.getFacilityRrn();
String username = LocalContext.getUserId();
String lotInfoFlag = request.getParameter("lotInfoFlag");
boolean readOnly = StringUtils.isNotBlank(lotInfoFlag) ? true : false;
initLotBaseInfoForJsp(request, readOnly, LotStatus.HOLD, null);
if (WebUtils.getParameterBoolean(Constants.NAV_KEY, request)) {
request.setAttribute("lotInfo", new LotInfoForm());
return new ActionForward(mapping.getInput());
}
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 = StringUtils.EMPTY;
lotId = getLotIdFromRequest(request, "byCarrierId");
String msg = "";
if (StringUtils.equalsIgnoreCase("CN", language)) {
msg = WebUtils.getParameter("byCarrierId", request) != null ? "晶舟号" : "批次号";
} else {
msg = WebUtils.getParameter("byCarrierId", request) != null ? "Cassette Id" : "lot Id";
}
Assert.isFalse((lotId == null) || lotId.trim().equalsIgnoreCase(""),
Errors.create().key(MessageIdList.LOT_LOTID_OR_CARRIERID_INCORRECT).content("批次号或晶舟号不正确!")
.args(msg).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());
Assert.isFalse(lot.getLotRrn() <= NumberUtils.INTEGER_ZERO,
Errors.create().key(MessageIdList.LOT_MISSING_ID).content("No such lotId").build());
Assert.isFalse(
lot.getLotStatus() == null || lot.getLotStatus() != null && !lot.getLotStatus().equals(LotStatus.HOLD),
Errors.create().key(MessageIdList.LOT_LOT_STATUS_MUSTBE_HOLD).content("批次必须为暂停状态!").build());
Assert.isFalse(StringUtils.equalsIgnoreCase("P", lot.getLotType()),
Errors.create().content("The lot type should not be" + " P!").build());
Assert.isFalse(diffBatchQueryService.checkLotInBatch(lot.getLotRrn()),
Errors.create().key(MessageIdList.SCRAPLOT_LOT_BATCH).content("Lot in batch!").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_LOT_PARAMETER_ERROR).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(lotInfoFlag));
cachePageInfo.put("lossTable", lossTable);
this.setTheFormSession(theform, request, lot, lotInfoForm, cachePageInfo);
return new ActionForward(mapping.getInput());
}
}