ManualUnlockAction.java
package com.mycim.webapp.actions.lot.locklot;
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.valueobject.MessageIdList;
import com.mycim.valueobject.ObjectList;
import com.mycim.valueobject.wip.Lot;
import com.mycim.valueobject.wip.LotTransLock;
import com.mycim.webapp.Constants;
import com.mycim.webapp.WebUtils;
import com.mycim.webapp.actions.WipSetupAction;
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.List;
/**
* ManualUnlockAction
*
* @author chaoyu.song
* @version 6.0.0
* @date 2020/8/10
**/
public class ManualUnlockAction extends WipSetupAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
long facilityRrn = LocalContext.getFacilityRrn();
String lotId = WebUtils.getParameterUpperCase("lotId", request);
Assert.isFalse(StringUtils.isBlank(lotId), Errors.create().content("lot id cannot be empty").build());
Lot lot = lotQueryService.getLot(lotId, facilityRrn);
Assert.isFalse(lot == null && lot.getLotRrn() <= 0,
Errors.create().key(MessageIdList.LOT_MISSING).content("Lot did not find!").build());
LotTransLock lock = new LotTransLock();
lock.setLotId(lotId);
lock.setLotRrn(lot.getLotRrn());
// List<LotTransLock> lotLocks = getLotTransLocks(lock);
// if (lotLocks != null && lotLocks.size() > 0) {
// request.setAttribute("lotLocks", lotLocks.get(0));
// }
request.setAttribute("lotId", lotId);
return mapping.findForward(Constants.INIT_KEY);
}
public ActionForward queryLotLockInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
long facilityRrn = LocalContext.getFacilityRrn();
String lotId = WebUtils.getParameterUpperCase("lotId", request);
Assert.isFalse(StringUtils.isBlank(lotId), Errors.create().content("lot id cannot be empty").build());
Lot lot = lotQueryService.getLot(lotId, facilityRrn);
Assert.isFalse(lot == null && lot.getLotRrn() <= 0,
Errors.create().key(MessageIdList.LOT_MISSING).content("Lot did not find!").build());
LotTransLock lock = new LotTransLock();
lock.setLotId(lotId);
lock.setLotRrn(lot.getLotRrn());
// List<LotTransLock> lotLocks = getLotTransLocks(lock);
// Assert.isFalse(lotLocks == null || lotLocks.size() <= 0, Errors.create().content("The lot no lock!").build());
// request.setAttribute("lotLocks", lotLocks.get(0));
request.setAttribute("lotId", lotId);
return mapping.findForward(Constants.INIT_KEY);
}
public ActionForward manualUnlockLot(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
// String user = LocalContext.getUserId();
long facilityRrn = LocalContext.getFacilityRrn();
String lotId = WebUtils.getParameterUpperCase("lotId", request);
// String transId = WebUtils.getParameterUpperCase("transId", request);
// String userName = WebUtils.getParameterUpperCase("userName", request);
// String comments = WebUtils.getParameterUpperCase("comments", request);
Assert.isFalse(StringUtils.isBlank(lotId), Errors.create().content("lot id cannot be empty").build());
Lot lot = lotQueryService.getLot(lotId, facilityRrn);
Assert.isFalse(lot == null && lot.getLotRrn() <= 0,
Errors.create().key(MessageIdList.LOT_MISSING).content("Lot did not find!").build());
// Long userRrn = getInstanceRrn(userName, getNamedSpace(ObjectList.USER_KEY, facilityRrn), ObjectList.USER_KEY);
// removeLotLock(userRrn, lot, transId, "Manual UnLock by:" + user + " comments:" + comments);
return mapping.findForward(Constants.LOTLOCATION_KEY);
}
}