CdwLotWaferStartAction.java
package com.mycim.webapp.actions.lot.lotplan;
import com.fa.sesa.exception.Assert;
import com.fa.sesa.exception.Errors;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.framework.utils.lang.collections.CollectionUtils;
import com.mycim.valueobject.MessageIdList;
import com.mycim.valueobject.consts.LotInfoConstants;
import com.mycim.valueobject.consts.SessionNames;
import com.mycim.valueobject.wip.Lot;
import com.mycim.webapp.WebUtils;
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/16
**/
public class CdwLotWaferStartAction extends LotWaferStartAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
String lotId = WebUtils.getParameterUpperCase("lotId", request);
LotInfoForm theform = (LotInfoForm) form;
Map lotInfo = new HashMap();
if (StringUtils.isNotBlank(lotId)) {
String carrierId = WebUtils.getParameterUpperCase("carrierId", request);
lotInfo = buildLotMap(lotId);
lotInfo.put("carrierId", carrierId);
}
lotInfo.put("lotPlanTypeMenu", theform.getLotPlanType());
request.setAttribute("_lotInfo", lotInfo);
List<Map> rawMaterials = (List<Map>) WebUtils.getCacheString2Obj(theform.getCacheCollection());
if (CollectionUtils.isNotEmpty(rawMaterials)) {
request.setAttribute(SessionNames.COLLECTION_KEY, rawMaterials);
}
return mapping.getInputForward();
}
@Override
public ActionForward updateLotPlanInit(ActionMapping mapping, HttpServletRequest request,
HttpServletResponse response, LotInfoForm theform) {
String lotId = WebUtils.getParameterUpperCase("lotId", request);
Lot lot = null;
if (StringUtils.isNotBlank(lotId)) {
lot = wipQueryService.getLotPlan(lotId);
Assert.isTrue(LotInfoConstants.isCategoryC(lot.getCreateCategory()),
Errors.create().key(MessageIdList.CDW_INVALID_CATEGORY)
.content("Current lot category is not allowed!").build());
}
return super.updateLotPlanInit(mapping, request, response, theform);
}
@Override
public ActionForward modifyLotPlan(ActionMapping mapping, HttpServletRequest request, HttpServletResponse response,
LotInfoForm theform) {
String lotId = request.getParameter("lotId");
Lot lot = lotService.getLotPlan(lotId);
Assert.isTrue(LotInfoConstants.isCategoryC(lot.getCreateCategory()),
Errors.create().key(MessageIdList.CDW_INVALID_CATEGORY)
.content("Current lot category is not allowed!").build());
return super.modifyLotPlan(mapping, request, response, theform);
}
@Override
protected Map buildLotMap(String lotId) {
Lot lot = lotService.getLotPlan(lotId);
Assert.isTrue(LotInfoConstants.isCategoryC(lot.getCreateCategory()),
Errors.create().key(MessageIdList.CDW_INVALID_CATEGORY)
.content("Current lot category is not allowed!").build());
return super.buildLotMap(lotId);
}
}