CdwAdjustLotAction.java
package com.mycim.webapp.actions.lot.adjustlot;
import com.fa.sesa.exception.Assert;
import com.fa.sesa.exception.Errors;
import com.mycim.framework.utils.MiscUtils;
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.framework.utils.lang.time.DateUtils;
import com.mycim.valueobject.MessageIdList;
import com.mycim.valueobject.consts.LotInfoConstants;
import com.mycim.valueobject.prp.ContextValue;
import com.mycim.valueobject.wip.Lot;
import com.mycim.valueobject.wip.LotStatus;
import com.mycim.webapp.Constants;
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;
/**
* @author can.yang
* @date 2021/6/10
**/
public class CdwAdjustLotAction extends AdjustLotAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
LotInfoForm theform = (LotInfoForm) form;
Lot lot = initLotBaseInfoForJsp(request, true, null, null);
Assert.isTrue((LotInfoConstants.isCategoryC(lot.getCreateCategory())),
Errors.create().key(MessageIdList.CDW_INVALID_CATEGORY).content("Current lot category is not allowed!").build());
String lotStatus = lot.getLotStatus();
//卡控post future hold被hold住的lot
checkPostFutureHold(lot.getLotRrn());
Assert.isFalse(
LotStatus.DISPATCH.equalsIgnoreCase(lotStatus) || LotStatus.PROCESSED.equalsIgnoreCase(lotStatus),
Errors.create().content("Lot Status {} Not Allowed!").args(lotStatus).build());
// 当carrierId为空事,视图渲染为N/A ;
PropertyUtils.copyProperties(theform, lot);
theform.setRecipePhysicalId(getRecipePhysicalId(lot));
theform.setDueDateS(DateUtils.formatDate(lot.getDueDate(), DateUtils.DATE_FORMAT4DAY));
request.setAttribute("DATE_FORMAT_KEY", DateUtils.DATE_FORMAT4DAY);
theform.setWaitTime(lot.getwaitTime());
String carrierId = getInstanceId(MiscUtils.parseSQL(lot.getCarrierRrn()));
String productId = getInstanceId(MiscUtils.parseSQL(lot.getProductRrn()));
theform.setCarrierId(carrierId == null || carrierId.trim().equals("") ? StringUtils.STRING_NA : carrierId);
theform.setProductId(productId);
theform.setLotComments(lot.getLotComments());
theform.setQty1toInt(theform.getQty1().intValue());
String createType = lot.getCreateCategory().toUpperCase();
if (StringUtils.equalsIgnoreCase(LotInfoConstants.LOT_CATEGORY_C,createType) || StringUtils.equalsIgnoreCase(LotInfoConstants.LOT_CATEGORY_D,createType)) {
//该字段只用于页面区分批次类型
theform.setLotPlanType(StringUtils.toString(NumberUtils.INTEGER_ONE));
} else {
theform.setLotPlanType(StringUtils.toString(NumberUtils.INTEGER_ZERO));
}
request.setAttribute("createType", createType);
request.setAttribute("currentLotType", lot.getLotType().toUpperCase());
ContextValue reticleFamilyContext = ctxExecService
.getReticleFamilyContext(lot.getProductRrn(), lot.getProductVersion(), lot.getProcessRrn(),
lot.getProcessVersion(), lot.getRouteRrn(), lot.getOperationRrn());
if (reticleFamilyContext != null) {
theform.setReticleGroupId(reticleFamilyContext.getResultValue1());
}
String location = lot.getLocation();
theform.setLocation("");
theform.setpLocation(location);
return mapping.findForward(Constants.INIT_KEY);
}
}