自动化立体仓库 - WMS系统
zhangc
2024-12-25 97c6071eaf01a3ce1a706cb0114dcb27d255aa3d
src/main/java/com/zy/asrs/controller/AgvWaitPakinController.java
@@ -1,5 +1,6 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
@@ -10,13 +11,17 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.asrs.entity.AgvBasDevp;
import com.zy.asrs.entity.AgvWaitPakin;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.entity.WaitPakin;
import com.zy.asrs.service.AgvBasDevpService;
import com.zy.asrs.service.AgvWaitPakinService;
import com.zy.asrs.service.OrderDetlService;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@@ -32,6 +37,8 @@
    private AgvWaitPakinService agvWaitPakinService;
    @Autowired
    private AgvBasDevpService agvBasDevpService;
    @Autowired
    private OrderDetlService orderDetlService;
    @RequestMapping(value = "/waitPakin/{id}/auth")
    @ManagerAuth
@@ -88,6 +95,7 @@
    @RequestMapping(value = "/waitPakin/delete/auth")
    @ManagerAuth
    @Transactional
    public R delete(@RequestParam String param){
        List<AgvWaitPakin> list = JSONArray.parseArray(param, AgvWaitPakin.class);
        if (Cools.isEmpty(list)){
@@ -95,10 +103,36 @@
        }
        for (AgvWaitPakin entity : list){
            AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("barcode", entity.getSuppCode()));
            if(Cools.isEmpty(agvBasDevp)){
                agvWaitPakinService.delete(new EntityWrapper<>(entity));
            }else {
                return R.error("料箱码为" + entity.getSuppCode() + "已绑定站点,请先从AGV站点管理解绑该料箱");
            if(!Cools.isEmpty(agvBasDevp)){
                if(!Cools.eq("F",agvBasDevp.getLocSts())){
                    throw new CoolException("该入库通知档已经在作业中,无法删除");
                }
                //解绑站点
                agvBasDevp.setLocSts("O");
                agvBasDevp.setBarcode("");
                agvBasDevp.setLocType2(null);
                agvBasDevpService.update(agvBasDevp,new EntityWrapper<AgvBasDevp>().eq("dev_no",agvBasDevp.getDevNo()));
            }
            agvWaitPakinService.delete(new EntityWrapper<>(entity));
            //订单回滚
            if(!Cools.isEmpty(entity.getOrderNo())){
                String orderNo = entity.getOrderNo();
                if(orderNo.contains("{")){
                    JSONArray orderArray = JSON.parseArray(orderNo);
                    for (Object o : orderArray){
                        JSONObject jsonobject = (JSONObject) o;
                        OrderDetl orderDetl = orderDetlService.selectByOrderNoAndMatnr(jsonobject.get("orderNo").toString(),entity.getMatnr(),entity.getThreeCode(),entity.getDeadTime());
                        orderDetl.setQty(orderDetl.getQty() - entity.getAnfme());
                        orderDetlService.updateById(orderDetl);
                    }
                }else {
                    OrderDetl orderDetl = orderDetlService.selectByOrderNoAndMatnr(entity.getOrderNo(),entity.getMatnr(),entity.getThreeCode(),entity.getDeadTime());
                    orderDetl.setQty(orderDetl.getQty() - entity.getAnfme());
                    orderDetlService.updateById(orderDetl);
                }
            }
        }