CompletedssLotManagerAction.java
package com.mycim.webapp.actions.lot.completedsslotmanage;
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.CompletedssConstants;
import com.mycim.valueobject.sys.ReferenceFileDetail;
import com.mycim.valueobject.wip.Lot;
import com.mycim.webapp.WebUtils;
import com.mycim.webapp.actions.WipSetupAction;
import com.mycim.webapp.forms.lot.CompletedssLotForm;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.beans.BeanUtils;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author kang.zhang
* @date 2019年9月27日
* @description 完成品仓批次的操作管理
*/
public class CompletedssLotManagerAction extends WipSetupAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
return mapping.findForward("init");
}
public ActionForward back(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
return mapping.findForward("back");
}
public ActionForward completedssLotInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws ServletException {
String language = I18nUtils.getCurrentLanguage().toString();
String user = LocalContext.getUserId();
Long facilityRrn = LocalContext.getFacilityRrn();
CompletedssLotForm themform = (CompletedssLotForm) form;
String lotId = request.getParameter("lotId");
Lot completedssLotInfo = lotQueryService.getCompletedssLotInfo(lotId.trim());
// 批次不存在的
Assert.isFalse(completedssLotInfo == null,
Errors.create().key(MessageIdList.LOT_LOTRRN_NOT_FOUND).content("批次不存在!").build());
String lotStatus = completedssLotInfo.getLotStatus();
Assert.isFalse(!"COMPLETEDSS".equalsIgnoreCase(lotStatus) && !"FREEZE".equalsIgnoreCase(lotStatus) &&
!"SCRAP".equalsIgnoreCase(lotStatus) && !"SHIP".equalsIgnoreCase(lotStatus),
Errors.create().key(MessageIdList.COMPLETEDSSLOT_LOT_NON_EXISTENT_STORAGE)
.content("lot Not put in storage!").build());
if (StringUtils.isNotBlank(completedssLotInfo.getStorage())) {
ReferenceFileDetail referenceFileDetail = getReferenceFileDetail("$STORAGE",
completedssLotInfo.getStorage(),
facilityRrn);
if (referenceFileDetail != null) {
completedssLotInfo.setStorage(referenceFileDetail.getData1Value());
} else {
completedssLotInfo.setStorage("");
}
}
BeanUtils.copyProperties(completedssLotInfo, themform);
return mapping.findForward("completedssLotInfo");
}
public ActionForward changeLevel(CompletedssLotForm form, ActionMapping mapping, HttpServletRequest request) {
Long facilityRrn = LocalContext.getFacilityRrn();
lotService.setLotCompletedssInfo(form.getLotRrn(), form.getCompletedssLevel(), "", "", null);
Lot completedssLotInfo = lotQueryService.getCompletedssLotInfo(form.getLotId());
if (StringUtils.isNotBlank(completedssLotInfo.getStorage())) {
ReferenceFileDetail referenceFileDetail = getReferenceFileDetail("$STORAGE",
completedssLotInfo.getStorage(),
facilityRrn);
if (referenceFileDetail != null) {
completedssLotInfo.setStorage(referenceFileDetail.getData1Value());
} else {
completedssLotInfo.setStorage("");
}
}
BeanUtils.copyProperties(completedssLotInfo, form);
return mapping.findForward("completedssLotInfo");
}
public ActionForward completedssLotChangeStatus(CompletedssLotForm form, ActionMapping mapping,
HttpServletRequest request) {
String user = LocalContext.getUserId();
Long facilityRrn = LocalContext.getFacilityRrn();
String transId = "";
String status = "";
String freeze = WebUtils.getParameter("freeze", request);
String unfreeze = WebUtils.getParameter("unfreeze", request);
if (StringUtils.isNotBlank(freeze)) {// 冻结批次
transId = CompletedssConstants.COMPLETEDSS_FREEZE;
status = CompletedssConstants.LOT_STATUS_FREEZE;
} else if (StringUtils.isNotBlank(unfreeze)) {
transId = CompletedssConstants.COMPLETEDSS_CANCLE_FREEZE;
status = CompletedssConstants.LOT_STATUS_COMPLETEDSS;
}
lotService.completedssLotChangeStatus(form.getLotRrn(), status, user, transId, "", "");
Lot completedssLotInfo = lotQueryService.getCompletedssLotInfo(form.getLotId());
if (StringUtils.isNotBlank(completedssLotInfo.getStorage())) {
ReferenceFileDetail referenceFileDetail = getReferenceFileDetail("$STORAGE",
completedssLotInfo.getStorage(),
facilityRrn);
if (referenceFileDetail != null) {
completedssLotInfo.setStorage(referenceFileDetail.getData1Value());
} else {
completedssLotInfo.setStorage("");
}
}
BeanUtils.copyProperties(completedssLotInfo, form);
return mapping.findForward("completedssLotInfo");
}
}