自动化立体仓库 - WMS系统
zhang
2025-09-24 e3e268107c141f10e937761fa6bc94b74a9c9abc
src/main/java/com/zy/asrs/controller/MobileController.java
@@ -3,12 +3,11 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.CombParam;
import com.zy.asrs.entity.param.MobileAdjustParam;
@@ -16,13 +15,13 @@
import com.zy.asrs.entity.result.MobileAdjustResult;
import com.zy.asrs.mapper.ManLocDetlMapper;
import com.zy.asrs.service.*;
import com.zy.common.model.LocDto;
import com.zy.common.model.TaskDto;
import com.zy.common.model.WrkDto;
import com.zy.common.utils.HttpHandler;
import com.zy.common.web.BaseController;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import com.zy.third.entity.ExdvYanbu;
import com.zy.third.mapper.ExdMaterialMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -40,7 +39,7 @@
@Slf4j
@RestController
@RequestMapping("mobile")
public class MobileController extends BaseController  {
public class MobileController extends BaseController {
    @Autowired
    private MobileService mobileService;
@@ -80,21 +79,24 @@
    @Autowired
    private ConfigService configService;
    @Autowired
    private ExdMaterialMapper exdMaterialMapper;
    // 商品上架
    @RequestMapping("/mat/onSale/auth")
    @ManagerAuth
    public R matOnSale(@RequestBody CombParam combParam){
    public R matOnSale(@RequestBody CombParam combParam) {
        mobileService.onSale(combParam);
        return R.ok("上架成功");
    }
    // 商品下架
    @RequestMapping("/mat/offSale/auth")
    //@ManagerAuth
    public R matOffSale(@RequestBody OffSaleParam offSaleParam){
    public R matOffSale(@RequestBody OffSaleParam offSaleParam) {
        mobileService.offSale(offSaleParam);
        return R.ok("下架成功");
    }
    // 组托 ----------------------------------------------------------------------------------------------------
@@ -105,7 +107,7 @@
     */
    @RequestMapping("/order/search/orderNo/auth")
    @ManagerAuth
    public R orderSearchByBarcode(@RequestParam String orderNo){
    public R orderSearchByBarcode(@RequestParam String orderNo) {
        Order order = orderService.selectByNo(orderNo);
        if (order == null) {
            return R.ok();
@@ -126,14 +128,14 @@
    @RequestMapping("/comb/auth")
    @ManagerAuth(memo = "组托")
    public R comb(@RequestBody CombParam combParam){
        mobileService.comb(combParam, getUserId());
    public R comb(@RequestBody CombParam combParam) {
        mobileService.comb(combParam, getUserId(), getUser().getEmail());
        return R.ok("组托成功");
    }
    @RequestMapping("/pack/get/auth")
    @ManagerAuth
    public R packGet(@RequestParam String barcode){
    public R packGet(@RequestParam String barcode) {
        Pack pack = packService.selectByBarcode(barcode);
        if (pack == null) {
            return R.ok();
@@ -146,7 +148,7 @@
    @RequestMapping("/pack/comb/auth")
    @ManagerAuth(memo = "下线组托")
    public R packComb(@RequestBody CombParam combParam){
    public R packComb(@RequestBody CombParam combParam) {
        mobileService.packComb(combParam, getUserId());
        return R.ok("组托成功");
    }
@@ -159,7 +161,7 @@
    @Deprecated
    public R pakoutQuery(@RequestParam(required = false) String barcode,
                         @RequestParam(required = false) Integer staNo,
                         @RequestParam(required = false) String matnr){
                         @RequestParam(required = false) String matnr) {
        if (Cools.isEmpty(barcode) && Cools.isEmpty(matnr)) {
            return R.ok();
        }
@@ -183,7 +185,7 @@
     */
    @RequestMapping("/pakout/confirm/barcode/auth")
    @ManagerAuth
    public R pakoutQueryByBarcode(@RequestParam(required = false) String barcode){
    public R pakoutQueryByBarcode(@RequestParam(required = false) String barcode) {
        if (Cools.isEmpty(barcode)) {
            return R.ok();
        }
@@ -200,7 +202,7 @@
    // 根据库位码和商品码搜索商品
    @RequestMapping("/mat/find/auth")
    public R find(@RequestParam(required = false) String locNo
            , @RequestParam(required = false) String matnr){
            , @RequestParam(required = false) String matnr) {
        //List<ManLocDetl> manLocDetls = manLocDetlMapper.selectItem0(locNo, matnr);
        ManLocDetl manLocDetl = manLocDetlMapper.selectLocNo0(locNo, matnr);
        return R.ok(manLocDetl);
@@ -213,7 +215,7 @@
    @RequestMapping("/pakout/confirm/pick/auth")
    @ManagerAuth
    public R pakoutQueryByBarcode(@RequestParam(required = false) Integer wrkNo
                                , @RequestParam(required = false) String matnr){
            , @RequestParam(required = false) String matnr) {
        if (Cools.isEmpty(wrkNo)) {
            return R.ok();
        }
@@ -279,9 +281,9 @@
                for (WrkDetl wrkDetl : dto.getWrkDetls()) {
                    wrkDetlService.updateInspect(wrkDetl.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
                }
                if(wrkMast.getIoType() == 103 || wrkMast.getIoType() == 107) {
                    wrkMast.setWrkSts(16L);//下架完成等待回库
                }else {
                if (wrkMast.getIoType() == 103 || wrkMast.getIoType() == 107) {
                    wrkMast.setWrkSts(34L);//下架完成等待回库
                } else {
                    wrkMast.setWrkSts(15L);
                }
                wrkMastService.updateById(wrkMast);
@@ -340,7 +342,7 @@
    @RequestMapping("/adjust/auth")
    @ManagerAuth(memo = "盘点")
    public R adjust(@RequestBody MobileAdjustParam combParam){
    public R adjust(@RequestBody MobileAdjustParam combParam) {
        mobileService.adjust(combParam, getUserId());
        return R.ok("盘点成功");
    }
@@ -348,10 +350,10 @@
    @PostMapping("/order/out/pakout/auth")
    @ManagerAuth(memo = "订单出库")
    public synchronized R pakoutByOrder(@RequestBody JSONObject param) {
        if(!param.containsKey("staNo") || !param.containsKey("orderNo")){
        if (!param.containsKey("staNo") || !param.containsKey("orderNo")) {
            return R.parse(BaseRes.PARAM);
        }
        mobileService.pakoutByOrder(param,getUserId());
        mobileService.pakoutByOrder(param, getUserId());
        return R.ok("出库成功");
    }
@@ -359,38 +361,39 @@
    /**
     * 补空板   区域到点
     *
     * @param locNo 目标站点
     * @param size  托盘大小 1:小托盘  2:大托盘
     * @return
     */
    @RequestMapping("/FillEmptyPallets")
    public synchronized R FillEmptyPallets(@RequestParam(required = false) String locNo
            ,@RequestParam(required = false) String size){
            , @RequestParam(required = false) String size) {
        if (Cools.isEmpty(locNo) || Cools.isEmpty(size)) {
            return R.error("站点或者大小不能为空");
        }
        //空托盘缓冲区 小:E8  大:E9
        String rStaNo ="E8";
        if(size.equals("2")){
        String rStaNo = "E8";
        if (size.equals("2")) {
            rStaNo = "E9";
        }
        LinkedHashMap<String,Object> rcsParam=new LinkedHashMap<>();
        LinkedHashMap<String, Object> rcsParam = new LinkedHashMap<>();
        rcsParam.put("taskType", "PF-FMR-COMMON");
        List<LinkedHashMap<String,Object>> targetRoutes=new ArrayList<>();
        LinkedHashMap<String,Object> t1=new LinkedHashMap<>();
        LinkedHashMap<String,Object> t2=new LinkedHashMap<>();
        List<LinkedHashMap<String, Object>> targetRoutes = new ArrayList<>();
        LinkedHashMap<String, Object> t1 = new LinkedHashMap<>();
        LinkedHashMap<String, Object> t2 = new LinkedHashMap<>();
        t1.put("seq", 0);
        t1.put("type","ZONE");
        t1.put("type", "ZONE");
        t1.put("code", rStaNo);
        t1.put("autoStart",0);
        t1.put("operation","COLLECT");
        t1.put("autoStart", 0);
        t1.put("operation", "COLLECT");
        t2.put("seq", 0);
        t2.put("type","SITE");
        t2.put("type", "SITE");
        t2.put("code", locNo);
        t2.put("autoStart",0);
        t2.put("operation","DELIVERY");
        t2.put("autoStart", 0);
        t2.put("operation", "DELIVERY");
        targetRoutes.add(t1);
        targetRoutes.add(t2);
@@ -398,119 +401,12 @@
        rcsParam.put("initPriority", 100);
        String response ="";
        Boolean bool =false;
        String response = "";
        Boolean bool = false;
        String msg = "";
        HashMap<String,Object> map = new HashMap<>();
        HashMap<String, Object> map = new HashMap<>();
        Date date = new Date();
        String time = date.getTime()+"";
        map.put("X-LR-REQUEST-ID", time);
        try {
            log.info("wms派发搬运任务给AGV搬运={}", rcsParam);
            response = new HttpHandler.Builder()
                     .setHeaders(map)
                    .setUri(url)
                    .setHttps(true)
                    .setPath(attrcs)
                    .setJson(JSON.toJSONString(rcsParam))
                    .build()
                    .doPostCloseSSL();
            JSONObject jsonObject = JSON.parseObject(response);
            if(jsonObject.getString("code").equals("SUCCESS")){
                bool = true;
            }else{
                msg=jsonObject.getString("message");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error("wms派发搬运任务给AGV搬运失败返回值={}", response);
        } finally {
            apiLogService.save("wms派发搬运任务给AGV搬运"
                    , url + attrcs
                    , null
                    , "127.0.0.1"
                    , JSON.toJSONString(rcsParam)
                    , response
                    , bool
            );
        }
        if(bool){
            return R.ok();
        }else {
            return R.error(msg);
        }
    }
    /**
     * 空托盘回库
     * @param sourceStaNo 原站点
     * @param barcode  托盘大小 1:小托盘  2:大托盘  目标区或者巷道
     * @return
     */
    @RequestMapping("/FillEmptyPalletsStack")
    public synchronized R FillEmptyPalletsStack(@RequestParam(required = false) String sourceStaNo
            ,@RequestParam(required = false) String barcode){
        if (Cools.isEmpty(sourceStaNo) || Cools.isEmpty(barcode)) {
            return R.error("站点或者大小不能为空");
        }
        //空托盘缓冲区 小:E8  大:E9
        String rStaNo ="E8";
        if(barcode.substring(0,1).equals("9")){
            rStaNo = "E9";
        }
        String type ="ZONE"; //区域
        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "autoE").eq("status", "1"));
        if (config != null) {
            type ="STACK"; //巷道
            if (Cools.isEmpty(config.getValue())) {
                rStaNo = rStaNo + "01";
                config.setValue("2");
            }else if (config.getValue().equals("1")) {
                rStaNo = rStaNo + "01";
                config.setValue("2");
            }else if (config.getValue().equals("2")) {
                rStaNo = rStaNo + "02";
                config.setValue("3");
            }else if (config.getValue().equals("3")) {
                rStaNo = rStaNo + "03";
                config.setValue("1");
            }
            configService.updateById(config);
        }
        LinkedHashMap<String,Object> rcsParam=new LinkedHashMap<>();
        rcsParam.put("taskType", "PF-FMR-COMMON");
        List<LinkedHashMap<String,Object>> targetRoutes=new ArrayList<>();
        LinkedHashMap<String,Object> t1=new LinkedHashMap<>();
        LinkedHashMap<String,Object> t2=new LinkedHashMap<>();
        t1.put("seq", 0);
        t1.put("type","SITE");
        t1.put("code", sourceStaNo);
        t1.put("autoStart",0);
        t1.put("operation","COLLECT");
        t2.put("seq", 0);
        t2.put("type",type);
        t2.put("code", rStaNo);
        t2.put("autoStart",0);
        t2.put("operation","DELIVERY");
        targetRoutes.add(t1);
        targetRoutes.add(t2);
        rcsParam.put("targetRoute", targetRoutes);
        rcsParam.put("initPriority", 100);
        String response ="";
        Boolean bool =false;
        String msg = "";
        HashMap<String,Object> map = new HashMap<>();
        Date date = new Date();
        String time = date.getTime()+"";
        String time = date.getTime() + "";
        map.put("X-LR-REQUEST-ID", time);
        try {
@@ -524,10 +420,10 @@
                    .build()
                    .doPostCloseSSL();
            JSONObject jsonObject = JSON.parseObject(response);
            if(jsonObject.getString("code").equals("SUCCESS")){
            if (jsonObject.getString("code").equals("SUCCESS")) {
                bool = true;
            }else{
                msg=jsonObject.getString("message");
            } else {
                msg = jsonObject.getString("message");
            }
        } catch (Exception e) {
            e.printStackTrace();
@@ -543,9 +439,117 @@
            );
        }
        if(bool){
        if (bool) {
            return R.ok();
        }else {
        } else {
            return R.error(msg);
        }
    }
    /**
     * 空托盘回库
     *
     * @param sourceStaNo 原站点
     * @param barcode     托盘大小 1:小托盘  2:大托盘  目标区或者巷道
     * @return
     */
    @RequestMapping("/FillEmptyPalletsStack")
    public synchronized R FillEmptyPalletsStack(@RequestParam(required = false) String sourceStaNo
            , @RequestParam(required = false) String barcode) {
        if (Cools.isEmpty(sourceStaNo) || Cools.isEmpty(barcode)) {
            return R.error("站点或者大小不能为空");
        }
        //空托盘缓冲区 小:E8  大:E9
        String rStaNo = "E8";
        if (barcode.substring(0, 1).equals("9")) {
            rStaNo = "E9";
        }
        String type = "ZONE"; //区域
        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "autoE").eq("status", "1"));
        if (config != null) {
            type = "STACK"; //巷道
            if (Cools.isEmpty(config.getValue())) {
                rStaNo = rStaNo + "01";
                config.setValue("2");
            } else if (config.getValue().equals("1")) {
                rStaNo = rStaNo + "01";
                config.setValue("2");
            } else if (config.getValue().equals("2")) {
                rStaNo = rStaNo + "02";
                config.setValue("3");
            } else if (config.getValue().equals("3")) {
                rStaNo = rStaNo + "03";
                config.setValue("1");
            }
            configService.updateById(config);
        }
        LinkedHashMap<String, Object> rcsParam = new LinkedHashMap<>();
        rcsParam.put("taskType", "PF-FMR-COMMON");
        List<LinkedHashMap<String, Object>> targetRoutes = new ArrayList<>();
        LinkedHashMap<String, Object> t1 = new LinkedHashMap<>();
        LinkedHashMap<String, Object> t2 = new LinkedHashMap<>();
        t1.put("seq", 0);
        t1.put("type", "SITE");
        t1.put("code", sourceStaNo);
        t1.put("autoStart", 0);
        t1.put("operation", "COLLECT");
        t2.put("seq", 0);
        t2.put("type", type);
        t2.put("code", rStaNo);
        t2.put("autoStart", 0);
        t2.put("operation", "DELIVERY");
        targetRoutes.add(t1);
        targetRoutes.add(t2);
        rcsParam.put("targetRoute", targetRoutes);
        rcsParam.put("initPriority", 100);
        String response = "";
        Boolean bool = false;
        String msg = "";
        HashMap<String, Object> map = new HashMap<>();
        Date date = new Date();
        String time = date.getTime() + "";
        map.put("X-LR-REQUEST-ID", time);
        try {
            log.info("wms派发搬运任务给AGV搬运={}", rcsParam);
            response = new HttpHandler.Builder()
                    .setHeaders(map)
                    .setUri(url)
                    .setHttps(true)
                    .setPath(attrcs)
                    .setJson(JSON.toJSONString(rcsParam))
                    .build()
                    .doPostCloseSSL();
            JSONObject jsonObject = JSON.parseObject(response);
            if (jsonObject.getString("code").equals("SUCCESS")) {
                bool = true;
            } else {
                msg = jsonObject.getString("message");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error("wms派发搬运任务给AGV搬运失败返回值={}", response);
        } finally {
            apiLogService.save("wms派发搬运任务给AGV搬运"
                    , url + attrcs
                    , null
                    , "127.0.0.1"
                    , JSON.toJSONString(rcsParam)
                    , response
                    , bool
            );
        }
        if (bool) {
            return R.ok();
        } else {
            return R.error(msg);
        }
@@ -554,39 +558,40 @@
    /**
     * 执行移库任务--点到点
     *
     * @param sourceStaNo
     * @param staNo
     * @return
     */
    @RequestMapping("/SITESITEAGVMove")
    public synchronized R SITESITEAGVMove(@RequestParam(required = false) String sourceStaNo
            ,@RequestParam(required = false) String staNo
            ,@RequestParam(required = false) String taskNo){
            , @RequestParam(required = false) String staNo
            , @RequestParam(required = false) String taskNo) {
        if (Cools.isEmpty(sourceStaNo) || Cools.isEmpty(staNo)) {
            return R.error("源站点和目标站点不能为空");
        }
        LinkedHashMap<String,Object> rcsParam=new LinkedHashMap<>();
        LinkedHashMap<String, Object> rcsParam = new LinkedHashMap<>();
        rcsParam.put("taskType", "PF-FMR-COMMON");
        if(!Cools.isEmpty(taskNo)){
        if (!Cools.isEmpty(taskNo)) {
            rcsParam.put("robotTaskCode", taskNo);
        }
        List<LinkedHashMap<String,Object>> targetRoutes=new ArrayList<>();
        LinkedHashMap<String,Object> t1=new LinkedHashMap<>();
        LinkedHashMap<String,Object> t2=new LinkedHashMap<>();
        List<LinkedHashMap<String, Object>> targetRoutes = new ArrayList<>();
        LinkedHashMap<String, Object> t1 = new LinkedHashMap<>();
        LinkedHashMap<String, Object> t2 = new LinkedHashMap<>();
        t1.put("seq", 0);
        t1.put("type","SITE");
        t1.put("type", "SITE");
        t1.put("code", sourceStaNo);
        t1.put("autoStart",0);
        t1.put("operation","COLLECT");
        t1.put("autoStart", 0);
        t1.put("operation", "COLLECT");
        t2.put("seq", 0);
        t2.put("type","SITE");
        t2.put("type", "SITE");
        t2.put("code", staNo);
        t2.put("autoStart",0);
        t2.put("operation","DELIVERY");
        t2.put("autoStart", 0);
        t2.put("operation", "DELIVERY");
        targetRoutes.add(t1);
        targetRoutes.add(t2);
@@ -594,12 +599,12 @@
        rcsParam.put("initPriority", 100);
        String response ="";
        Boolean bool =false;
        String response = "";
        Boolean bool = false;
        String msg = "";
        HashMap<String,Object> map = new HashMap<>();
        HashMap<String, Object> map = new HashMap<>();
        Date date = new Date();
        String time = date.getTime()+"";
        String time = date.getTime() + "";
        map.put("X-LR-REQUEST-ID", time);
        try {
@@ -613,10 +618,10 @@
                    .build()
                    .doPostCloseSSL();
            JSONObject jsonObject = JSON.parseObject(response);
            if(jsonObject.getString("code").equals("SUCCESS")){
            if (jsonObject.getString("code").equals("SUCCESS")) {
                bool = true;
            }else{
                msg=jsonObject.getString("message");
            } else {
                msg = jsonObject.getString("message");
            }
        } catch (Exception e) {
            e.printStackTrace();
@@ -632,9 +637,9 @@
            );
        }
        if(bool){
        if (bool) {
            return R.ok();
        }else {
        } else {
            return R.error(msg);
        }
@@ -642,38 +647,39 @@
    /**
     * 执行移库任务--点到区域
     *
     * @param sourceStaNo
     * @param staNo
     * @return
     */
    @RequestMapping("/SITEZONEAGVMove")
    public synchronized R SITEZONEAGVMove(@RequestParam(required = false) String sourceStaNo
            ,@RequestParam(required = false) String staNo
            ,@RequestParam(required = false) String taskNo){
            , @RequestParam(required = false) String staNo
            , @RequestParam(required = false) String taskNo) {
        if (Cools.isEmpty(sourceStaNo) || Cools.isEmpty(staNo)) {
            return R.error("源站点和目标站点不能为空");
        }
        LinkedHashMap<String,Object> rcsParam=new LinkedHashMap<>();
        LinkedHashMap<String, Object> rcsParam = new LinkedHashMap<>();
        rcsParam.put("taskType", "PF-FMR-COMMON");
        if(!Cools.isEmpty(taskNo)){
        if (!Cools.isEmpty(taskNo)) {
            rcsParam.put("robotTaskCode", taskNo);
        }
        List<LinkedHashMap<String,Object>> targetRoutes=new ArrayList<>();
        LinkedHashMap<String,Object> t1=new LinkedHashMap<>();
        LinkedHashMap<String,Object> t2=new LinkedHashMap<>();
        List<LinkedHashMap<String, Object>> targetRoutes = new ArrayList<>();
        LinkedHashMap<String, Object> t1 = new LinkedHashMap<>();
        LinkedHashMap<String, Object> t2 = new LinkedHashMap<>();
        t1.put("seq", 0);
        t1.put("type","SITE");
        t1.put("type", "SITE");
        t1.put("code", sourceStaNo);
        t1.put("autoStart",0);
        t1.put("operation","COLLECT");
        t1.put("autoStart", 0);
        t1.put("operation", "COLLECT");
        t2.put("seq", 0);
        t2.put("type","ZONE");
        t2.put("type", "ZONE");
        t2.put("code", staNo);
        t2.put("autoStart",0);
        t2.put("operation","DELIVERY");
        t2.put("autoStart", 0);
        t2.put("operation", "DELIVERY");
        targetRoutes.add(t1);
        targetRoutes.add(t2);
@@ -681,12 +687,12 @@
        rcsParam.put("initPriority", 100);
        String response ="";
        Boolean bool =false;
        String response = "";
        Boolean bool = false;
        String msg = "";
        HashMap<String,Object> map = new HashMap<>();
        HashMap<String, Object> map = new HashMap<>();
        Date date = new Date();
        String time = date.getTime()+"";
        String time = date.getTime() + "";
        map.put("X-LR-REQUEST-ID", time);
        try {
@@ -700,10 +706,10 @@
                    .build()
                    .doPostCloseSSL();
            JSONObject jsonObject = JSON.parseObject(response);
            if(jsonObject.getString("code").equals("SUCCESS")){
            if (jsonObject.getString("code").equals("SUCCESS")) {
                bool = true;
            }else{
                msg=jsonObject.getString("message");
            } else {
                msg = jsonObject.getString("message");
            }
        } catch (Exception e) {
            e.printStackTrace();
@@ -719,9 +725,9 @@
            );
        }
        if(bool){
        if (bool) {
            return R.ok();
        }else {
        } else {
            return R.error(msg);
        }
@@ -729,38 +735,39 @@
    /**
     * 执行移库任务--区域到点
     *
     * @param sourceStaNo
     * @param staNo
     * @return
     */
    @RequestMapping("/ZONESITEAGVMove")
    public synchronized R ZONESITEAGVMove(@RequestParam(required = false) String sourceStaNo
            ,@RequestParam(required = false) String staNo
            ,@RequestParam(required = false) String taskNo){
            , @RequestParam(required = false) String staNo
            , @RequestParam(required = false) String taskNo) {
        if (Cools.isEmpty(sourceStaNo) || Cools.isEmpty(staNo)) {
            return R.error("源站点和目标站点不能为空");
        }
        LinkedHashMap<String,Object> rcsParam=new LinkedHashMap<>();
        LinkedHashMap<String, Object> rcsParam = new LinkedHashMap<>();
        rcsParam.put("taskType", "PF-FMR-COMMON");
        if(!Cools.isEmpty(taskNo)){
        if (!Cools.isEmpty(taskNo)) {
            rcsParam.put("robotTaskCode", taskNo);
        }
        List<LinkedHashMap<String,Object>> targetRoutes=new ArrayList<>();
        LinkedHashMap<String,Object> t1=new LinkedHashMap<>();
        LinkedHashMap<String,Object> t2=new LinkedHashMap<>();
        List<LinkedHashMap<String, Object>> targetRoutes = new ArrayList<>();
        LinkedHashMap<String, Object> t1 = new LinkedHashMap<>();
        LinkedHashMap<String, Object> t2 = new LinkedHashMap<>();
        t1.put("seq", 0);
        t1.put("type","ZONE");
        t1.put("type", "ZONE");
        t1.put("code", sourceStaNo);
        t1.put("autoStart",0);
        t1.put("operation","COLLECT");
        t1.put("autoStart", 0);
        t1.put("operation", "COLLECT");
        t2.put("seq", 0);
        t2.put("type","SITE");
        t2.put("type", "SITE");
        t2.put("code", staNo);
        t2.put("autoStart",0);
        t2.put("operation","DELIVERY");
        t2.put("autoStart", 0);
        t2.put("operation", "DELIVERY");
        targetRoutes.add(t1);
        targetRoutes.add(t2);
@@ -768,12 +775,12 @@
        rcsParam.put("initPriority", 100);
        String response ="";
        Boolean bool =false;
        String response = "";
        Boolean bool = false;
        String msg = "";
        HashMap<String,Object> map = new HashMap<>();
        HashMap<String, Object> map = new HashMap<>();
        Date date = new Date();
        String time = date.getTime()+"";
        String time = date.getTime() + "";
        map.put("X-LR-REQUEST-ID", time);
        try {
@@ -787,10 +794,10 @@
                    .build()
                    .doPostCloseSSL();
            JSONObject jsonObject = JSON.parseObject(response);
            if(jsonObject.getString("code").equals("SUCCESS")){
            if (jsonObject.getString("code").equals("SUCCESS")) {
                bool = true;
            }else{
                msg=jsonObject.getString("message");
            } else {
                msg = jsonObject.getString("message");
            }
        } catch (Exception e) {
            e.printStackTrace();
@@ -806,9 +813,9 @@
            );
        }
        if(bool){
        if (bool) {
            return R.ok();
        }else {
        } else {
            return R.error(msg);
        }
@@ -816,54 +823,55 @@
    /**
     * AGV站点绑定和解绑
     * @param sourceStaNo   //站点
     * @param barcodeType   //托盘码
     * @param invoke        //BIND为绑定    UNBIND为解绑
     *
     * @param sourceStaNo //站点
     * @param barcodeType //托盘码
     * @param invoke      //BIND为绑定    UNBIND为解绑
     * @return
     */
    @RequestMapping("/siteBindAndUnbind")
    public synchronized R siteBindAndUnbind(@RequestParam(required = false) String sourceStaNo
            ,@RequestParam(required = false) String barcodeType
            ,@RequestParam(required = false) String invoke){
            , @RequestParam(required = false) String barcodeType
            , @RequestParam(required = false) String invoke) {
        if (Cools.isEmpty(sourceStaNo) || Cools.isEmpty(barcodeType)) {
            return R.error("站点和托盘类型不能为空");
        }
        if(barcodeType.substring(0,1).equals("8")){
            barcodeType="11";
        }else if(barcodeType.substring(0,1).equals("9")){
            barcodeType="21";
        if (barcodeType.substring(0, 1).equals("8")) {
            barcodeType = "11";
        } else if (barcodeType.substring(0, 1).equals("9")) {
            barcodeType = "21";
        }
        LinkedHashMap<String,Object> rcsParam=new LinkedHashMap<>();
        LinkedHashMap<String, Object> rcsParam = new LinkedHashMap<>();
        rcsParam.put("slotCategory", "SITE");
        rcsParam.put("slotCode", sourceStaNo);
        rcsParam.put("carrierCategory", "PALLET");
        rcsParam.put("carrierType", barcodeType);//11为小托盘   21为大托盘
if(sourceStaNo.equals("101")){
    rcsParam.put("carrierDir","0");
}else  if(sourceStaNo.equals("R01")||sourceStaNo.equals("R03")){
    rcsParam.put("carrierDir","-90");
        if (sourceStaNo.equals("101")) {
            rcsParam.put("carrierDir", "0");
        } else if (sourceStaNo.equals("R01") || sourceStaNo.equals("R03")) {
            rcsParam.put("carrierDir", "-90");
    }else  if(sourceStaNo.equals("R02")){
    rcsParam.put("carrierDir","90");
}else {
    rcsParam.put("carrierDir","180");
}
        } else if (sourceStaNo.equals("R02")) {
            rcsParam.put("carrierDir", "90");
        } else {
            rcsParam.put("carrierDir", "180");
        }
        rcsParam.put("temporary", "");
        rcsParam.put("invoke", invoke);
        String response ="";
        Boolean bool =false;
        String response = "";
        Boolean bool = false;
        String msg = "";
        HashMap<String,Object> map = new HashMap<>();
        HashMap<String, Object> map = new HashMap<>();
        Date date = new Date();
        String time = date.getTime()+"";
        String time = date.getTime() + "";
        map.put("X-LR-REQUEST-ID", time);
        try {
            log.info("WMS完成"+invoke+"agv站点={},上报参数为={}",sourceStaNo,rcsParam);
            log.info("WMS完成" + invoke + "agv站点={},上报参数为={}", sourceStaNo, rcsParam);
            response = new HttpHandler.Builder()
                    .setHeaders(map)
                    .setUri(url)
@@ -873,16 +881,16 @@
                    .build()
                    .doPostCloseSSL();
            JSONObject jsonObject = JSON.parseObject(response);
            if(jsonObject.getString("code").equals("SUCCESS")){
            if (jsonObject.getString("code").equals("SUCCESS")) {
                bool = true;
            }else{
                msg=jsonObject.getString("message");
            } else {
                msg = jsonObject.getString("message");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error("WMS完成"+invoke+"agv站点失败={}", response);
            log.error("WMS完成" + invoke + "agv站点失败={}", response);
        } finally {
            apiLogService.save("WMS完成"+invoke+"agv站点"+sourceStaNo
            apiLogService.save("WMS完成" + invoke + "agv站点" + sourceStaNo
                    , url + siteBindAndUnbing
                    , null
                    , "127.0.0.1"
@@ -892,9 +900,9 @@
            );
        }
        if(bool){
        if (bool) {
            return R.ok();
        }else {
        } else {
            return R.error(msg);
        }
@@ -902,32 +910,37 @@
    /**
     * 空板回库或者拣料回库
     *
     * @param sourceStaNo
     * @param staNo
     * @return
     */
    @RequestMapping("/AGVStartReturn")
    public synchronized R AGVStartReturn(@RequestParam(required = false) String sourceStaNo
            ,@RequestParam(required = false) String staNo
            ,@RequestParam(required = false) String taskNo){
            , @RequestParam(required = false) String staNo
            , @RequestParam(required = false) String taskNo) {
        if (Cools.isEmpty(sourceStaNo) || Cools.isEmpty(staNo)) {
            return R.error("源站点和托盘码不能为空");
        }
        R r=R.ok();
        R r = R.ok();
        WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", staNo).in("io_type",103,105,107));
        WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", staNo).in("io_type", 103, 105, 107));
        if (wrkMast == null) {
            r=FillEmptyPalletsStack(sourceStaNo,staNo);
        }else {
            if (wrkMast.getWrkSts()>30){
            r = FillEmptyPalletsStack(sourceStaNo, staNo);
        } else {
            if (wrkMast.getWrkSts() > 30) {
                return R.error("该托盘={},没有下架,请下架后再回库!!!");
            }
            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("sta_no", wrkMast.getStaNo()).in("io_type", 101, 103, 105, 107).lt("wrk_sts", 33));
            if (!Cools.isEmpty(wrkMasts)) {
                return R.error(wrkMast.getCrnNo() + "堆垛机,有出库任务,禁止回库!!!");
            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String format = sdf.format(new Date());
            String s = format+"-" + wrkMast.getWrkNo() + "-" + wrkMast.getBarcode();
            r=SITESITEAGVMove(sourceStaNo,wrkMast.getStaNo$(),s);
            String s = format + "-" + wrkMast.getWrkNo() + "-" + wrkMast.getBarcode();
            r = SITESITEAGVMove(sourceStaNo, wrkMast.getStaNo$(), s);
            if (r.get("code").equals(200)) {
                wrkMast.setPdcType(s);
                /**
@@ -947,16 +960,38 @@
    /**
     * 获取仓库
     *
     * @return
     */
    @RequestMapping("/ck")
    @PostMapping
    public R AGVStartReturn(){
        List<String> list=new ArrayList<>();
    public R AGVStartReturn() {
        List<String> list = new ArrayList<>();
        list.add("半成品仓库");
        list.add("成品仓库");
        return R.ok(list);
    }
    @RequestMapping(value = "/mat/tiaoma/auth")
    @ManagerAuth
    public R find(@RequestParam("barcode") String barcode) {
        ExdvYanbu barcode1 = exdMaterialMapper.getBacode(barcode);
        if (barcode1 == null) {
            return R.error("批次对应的验布数据不存在");
        }
        return R.ok(barcode1);
    }
    @RequestMapping(value = "/getOrderNo/auth")
    @ManagerAuth
    public R findOrderNo(@RequestParam("orderNo") String orderNo) {
        Page<Order> orderPage = orderService.selectPage(new Page<>(0, 10), new EntityWrapper<Order>().like("order_no", "%" + orderNo + "%"));
        List<String> objects = new ArrayList<>();
        for (Order record : orderPage.getRecords()) {
            objects.add(record.getOrderNo());
        }
        return R.ok(objects);
    }
}