CancelLotPlanAction.java
/*
* @ Copyright 2001 FA Software;
* All right reserved. No part of this program may be reproduced or
* transmitted in any form or by any means, electronic or
* mechanical, including photocopying, recording, or by any
* information storage or retrieval system without written
* permission from FA Software, except for inclusion of brief
* quotations in a review.
*/
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.wip.Lot;
import com.mycim.webapp.actions.WipSetupAction;
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;
public class CancelLotPlanAction extends WipSetupAction {
@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());
lot.setTransPerformedby(user);
lotService.deleteLotPlan(lot);
request.setAttribute("deleteLotResult", StringUtils.equalsIgnoreCase("CN", language) ? "批次已取消投片!" :
"The Lot has been " + "cancelled!");
return mapping.findForward("deleteLotResult");
}
}