SplitRunCardLotReleaseAction.java

package com.mycim.webapp.actions.splitruncardlot;

import com.fa.sesa.exception.Errors;
import com.fa.sesa.exception.SystemIllegalArgumentException;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.framework.utils.lang.collections.MapUtils;
import com.mycim.valueobject.MessageIdList;
import com.mycim.valueobject.wip.Lot;
import com.mycim.valueobject.wip.LotStatus;
import com.mycim.webapp.Constants;
import com.mycim.webapp.actions.RunCardAction;
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.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author pinyan.song
 * @version 6.0.0
 * @date 2020-1-9
 **/
public class SplitRunCardLotReleaseAction extends RunCardAction {
    @Override
    public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                              HttpServletResponse response) throws Exception {
        Lot lot = initLotBaseInfoForJsp(request);

        List<Map> holdInfos = new ArrayList<>();
        if (lot != null && lot.getLotRrn() > 0) {
            holdInfos = wipQueryService.getHoldReasons(lot.getLotRrn());
            request.setAttribute("lotId", lot.getLotId());
        }

        request.setAttribute("collection", holdInfos);

        if (StringUtils.equals(lot.getLotStatus(), LotStatus.HOLD)) {
            // release 时 若cst 存在未完成的sort job 进行卡控
            Map<String, Object> lotInfoMap = lotRunCardQueryService.getRCLotInfoMap(lot.getLotId());
            long carrierRrn = MapUtils.getLong(lotInfoMap, "carrierRrn", -1L);
            this.checkWaitJobs(carrierRrn, 0L, 0L, null);
            return mapping.findForward(Constants.RELEASE_KEY);
        } else if (StringUtils.equals(lot.getLotStatus(), LotStatus.RUNNINGHOLD)) {
            return mapping.findForward(Constants.RUNNING_RELEASE_KEY);
        } else {
            throw new SystemIllegalArgumentException(
                    Errors.create().key(MessageIdList.LOT_STATUS_NOT_ALLOW).content("Lot status not allow").build());
        }
    }

    /**
     * Action 方法: release
     */
    public ActionForward release(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                 HttpServletResponse response) throws Exception {
        return releaseHandle(mapping, form, request, response);
    }

    /**
     * Action 方法: runningRelease
     */
    public ActionForward runningRelease(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                        HttpServletResponse response) throws Exception {
        return releaseRunningHandle(mapping, form, request, response);
    }


}