CdwScrapLotEditAction.java
package com.mycim.webapp.actions.lot.lotscrapunscrap;
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.math.NumberUtils;
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.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.lot.ScrapLotInfoForm;
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.List;
import java.util.Map;
/**
* @author can.yang
* @date 2021/6/10
**/
public class CdwScrapLotEditAction extends ScrapLotEditAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
ScrapLotInfoForm theform = (ScrapLotInfoForm) form;
long facilityRrn = LocalContext.getFacilityRrn();
Lot lot = new Lot();
String lotId = StringUtils.trimToUpperCase(WebUtils.getParameter("lotId", request));
String transId = WebUtils.getParameter("transId", request);
if (StringUtils.isNotBlank(lotId)) {
lot = lotQueryService.getLot(lotId, facilityRrn);
Assert.isTrue((LotInfoConstants.isCategoryC(lot.getCreateCategory())),
Errors.create().key(MessageIdList.CDW_INVALID_CATEGORY).content("Current lot category is not allowed!").build());
long lotRrn = lot.getLotRrn();
//卡控post future hold被hold住的lot
checkPostFutureHold(lotRrn);
Assert.isFalse(lotRrn <= NumberUtils.INTEGER_ZERO,
Errors.create().key(MessageIdList.SCRAPLOT_NOT_FIND_LOT).content("Cannot Find Lot!")
.build());
// Assert.isTrue(StringUtils.equalsIgnoreCase("P", lot.getLotType()), Errors.create().content("The lot type should be P!").build());
if (transId.equalsIgnoreCase(Constants.SCRAP_KEY)) {
Assert.isTrue(lot.getLotStatus().equals(LotStatus.HOLD),
Errors.create().key(MessageIdList.SCRAPLOT_STATUS_NOT_ALLOW)
.content("Lot status must be Hold!").build());
theform.setTransId(Constants.SCRAP_KEY);
} else if (transId.equalsIgnoreCase(Constants.UNSCRAP_KEY)) {
Assert.isTrue(lot.getLotStatus().equals(LotStatus.SCRAPPED),
Errors.create().key(MessageIdList.UNSCRAP_INVALID_LOT_STATUS)
.content("Invalid Lot status!").build());
Assert.isFalse(workOrderService.getErpPackageCount(lot.getLotRrn()) > NumberUtils.INTEGER_ZERO,
Errors.create().key(MessageIdList.UNSCRAP_EXIST_LOT_PACKAGE)
.content("Lot package info exists!").build());
theform.setQty1(lot.getInputQty1());
theform.setTransId(Constants.UNSCRAP_KEY);
List<Map> scrapReasons = lotQueryService.getScrapReasons(lot.getLotRrn());
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());
}
}
request.setAttribute("unscrapCollection", scrapReasons);
theform.setTransId(Constants.UNSCRAP_KEY);
}
wipQueryService.checkActiveInlineOcapId(lot.getLotRrn());
}
Assert.isFalse(diffBatchQueryService.checkLotInBatch(lot.getLotRrn()),
Errors.create().key(MessageIdList.SCRAPLOT_LOT_BATCH).content("Lot in batch!").build());
request.setAttribute("lotId", lotId);
theform.setCacheLot(getCacheObj2String(lot));
request.setAttribute("collection", new ArrayList<>());
initLotBaseInfoForJsp(request, true, "", "");
return mapping.getInputForward();
}
}