自动化立体仓库 - WMS系统
skyouc
2 天以前 518099da49917ed319318dc88860e3c5bbf04925
src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
@@ -22,6 +22,7 @@
import com.zy.asrs.utils.Utils;
import com.zy.common.constant.MesConstant;
import com.zy.common.utils.HttpHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -31,6 +32,9 @@
import java.util.*;
import java.util.stream.Collectors;
import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
@Slf4j
@Service
public class WcsApiServiceImpl implements WcsApiService {
@@ -127,28 +131,36 @@
        if (Objects.isNull(params.getTaskNo())) {
            return R.error("任务号不能为空!!");
        }
        if (Objects.isNull(params.getBarcode())) {
            return R.error("托盘码不能为空!!");
        }
        if (Objects.isNull(params.getLocNo())) {
            return R.error("目标库位不能为空!!");
        }
//        if (params.getType().equals("in"))
//        if (Objects.isNull(params.getBarcode())) {
//            return R.error("托盘码不能为空!!");
//        }
//        if (Objects.isNull(params.getLocNo())) {
//            return R.error("目标库位不能为空!!");
//        }
        String url = MesConstant.PUB_TASK_IN;
        if (Objects.isNull(params.getType()) && params.getType().equals("out")) {
        if (!Objects.isNull(params.getType()) && params.getType().equals("out")) {
            url = MesConstant.PUB_TASK_OUT;
        }
        log.info("出库任务下发参数:{}", JSON.toJSONString(params));
        String response;
        try {
            response = new HttpHandler.Builder()
                    .setUri(MesConstant.URL)
                    .setUri(MesConstant.WCS_URL)
                    .setPath(url)
                    .setJson(JSON.toJSONString(params))
                    .build()
                    .doPost();
            R result = JSON.parseObject(response, R.class);
            Map<String, Object> result = JSON.parseObject(response, Map.class);
            if (result.get("code").equals("200")) {
            if (result.get("code").equals(200)) {
                WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getTaskNo()));
                wrkMast.setWrkSts(12L);
                wrkMastService.updateById(wrkMast);
                //TODO 上报是否成功
            } else {
                return R.error().add(result);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
@@ -167,22 +179,23 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R receviceTaskFromWcs(ReceviceTaskParams params) {
        if (Objects.isNull(params.getWrkNo())) {
        if (Objects.isNull(params.getSuperTaskNo())) {
            throw new CoolException("WMS任务号不能为空!!");
        }
        if (Objects.isNull(params.getNotifyType())) {
            throw new CoolException("动作类型不能为空!!");
        }
        WrkMast mast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getWrkNo()));
        WrkMast mast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getSuperTaskNo()));
        if (Objects.isNull(mast)) {
            throw new CoolException("任务档不存在!!");
        }
        log.info("任务执行参数回写:{}", JSON.toJSONString(params));
        if (params.getNotifyType().equals("task")) {
            //任务
            if (params.getMsgType().equals("task_complete")) {
                if (mast.getIoType() == 1) {
                if (mast.getIoType() == 1 || mast.getIoType() == 10 || mast.getIoType() == 53 || mast.getIoType() == 54 || mast.getIoType() == 57) {
                    mast.setWrkSts(4L);
                } else if (mast.getIoType() == 101) {
                } else if (mast.getIoType() == 101 || mast.getIoType() == 110 || mast.getIoType() == 103 || mast.getIoType() == 104  || mast.getIoType() == 107) {
                    mast.setWrkSts(14L);
                }
                if (!wrkMastService.updateById(mast)) {