CdwCancelLotPlanAction.java
package com.mycim.webapp.actions.lot.lotplan;
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.lang.StringUtils;
import com.mycim.valueobject.MessageIdList;
import com.mycim.valueobject.consts.LotInfoConstants;
import com.mycim.valueobject.wip.Lot;
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/9/22
*/
public class CdwCancelLotPlanAction extends CancelLotPlanAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
return mapping.findForward("deleteLotResult");
}
public ActionForward cancelLotPlan(ActionMapping mapping, HttpServletRequest request, HttpServletResponse response,
LotInfoForm theform) throws Exception {
String user = LocalContext.getUserId();
String language = I18nUtils.getCurrentLanguage().toString();
String lotId = theform.getLotId();
Assert.isFalse(lotId == null || lotId.trim().length() == 0,
Errors.create().key(MessageIdList.LOT_ENTER_CORRECT_LOTID).content("please enter correct lotId")
.build());
Lot lot = wipQueryService.getLotPlan(StringUtils.trimToUpperCase(lotId));
Assert.isFalse(lot == null || lot.getLotRrn() <= 0,
Errors.create().key(MessageIdList.LOT_LOT_NOT_EXIST_OR_CAST).content("lot not exist").build());
Assert.isTrue((LotInfoConstants.isCategoryC(lot.getCreateCategory())),
Errors.create().key(MessageIdList.CDW_INVALID_CATEGORY)
.content("Current lot category is not allowed!").build());
lot.setTransPerformedby(user);
lotService.deleteLotPlan(lot);
request.setAttribute("deleteLotResult", StringUtils.equalsIgnoreCase("CN", language) ? "批次已取消投片!" :
"The Lot has been " + "cancelled!");
return mapping.findForward("deleteLotResult");
}
}