From 617a8c4fc0b81ec4b96db8a013a91f4e666b0b96 Mon Sep 17 00:00:00 2001 From: zhangc <zc@123> Date: 星期三, 08 一月 2025 14:33:45 +0800 Subject: [PATCH] 出现空指针异常 --- src/main/java/com/zy/asrs/controller/AgvMobileController.java | 117 ++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 77 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/AgvMobileController.java b/src/main/java/com/zy/asrs/controller/AgvMobileController.java index 33a4f1e..4c99399 100644 --- a/src/main/java/com/zy/asrs/controller/AgvMobileController.java +++ b/src/main/java/com/zy/asrs/controller/AgvMobileController.java @@ -1,5 +1,6 @@ package com.zy.asrs.controller; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.core.annotations.ManagerAuth; @@ -10,14 +11,17 @@ import com.zy.asrs.entity.*; import com.zy.asrs.entity.param.*; import com.zy.asrs.service.*; +import com.zy.asrs.service.impl.OrderServiceImpl; import com.zy.common.web.BaseController; -import io.swagger.models.auth.In; import lombok.Synchronized; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import java.util.*; import java.util.stream.Collectors; @@ -28,7 +32,7 @@ */ @RestController @RequestMapping("agvMobile") -public class AgvMobileController extends BaseController { +public class AgvMobileController extends BaseController { private static final Logger log = LoggerFactory.getLogger(AgvMobileController.class); @@ -52,13 +56,15 @@ private SnowflakeIdWorker snowflakeIdWorker; @Autowired private FlowLogService flowLogService; + @Autowired + private OrderServiceImpl orderService; /* locno锛熺粍鎵�+缁戝畾鏆傚瓨浣� 锛� 缁勬墭 */ @PostMapping("/comb/auth") - public R comb(@RequestBody CombParam combParam){ + public R comb(@RequestBody CombParam combParam) { agvMobileService.comb(combParam, getUserId()); return R.ok(); @@ -67,7 +73,7 @@ // 鍐嶆鎷f枡 @RequestMapping("/pick/again/auth") @ManagerAuth(memo = "鍐嶆鎷f枡") - public R pickAgain(@RequestBody PickParam pickParams){ + public R pickAgain(@RequestBody PickParam pickParams) { agvMobileService.pickAgain(pickParams, 1l); return R.ok("鎷f枡鎴愬姛"); } @@ -76,11 +82,11 @@ 缁戝畾璐ф灦鏉$爜涓庢殏瀛樹綅 */ @PostMapping("/combBinging/auth") - public R combBinding(@RequestBody Map<String,Object> map){ + public R combBinding(@RequestBody Map<String, Object> map) { String barcode = map.get("barcode").toString(); String stationCode = map.get("stationCode").toString(); - Short containerType = Short.valueOf(barcode.substring(0,2)); - agvMobileService.combBinding(barcode,stationCode,containerType); + Short containerType = Short.valueOf(barcode.substring(0, 2)); + agvMobileService.combBinding(barcode, stationCode, containerType); return R.ok("璐ф灦缁戝畾绔欑偣鎴愬姛"); } @@ -88,9 +94,9 @@ 鑾峰彇褰撳墠宸茬粦瀹氱殑杩樻病鐢熸垚宸ヤ綔妗g殑鏆傚瓨浣� */ @PostMapping("/getBasDevp/auth") - public R getBasDevpByFloor(@RequestBody Map<String,Object> map){ + public R getBasDevpByFloor(@RequestBody Map<String, Object> map) { String floor = map.get("floor").toString(); - if("1".equals(floor) || "3".equals(floor)){ + if ("1".equals(floor) || "3".equals(floor)) { return R.ok(agvMobileService.getAgvBasDevpByFloor(Integer.parseInt(floor))); } return R.error("鍙傛暟閿欒"); @@ -100,7 +106,7 @@ 鑾峰彇杈撻�佺嚎绔欑偣 */ @PostMapping("/getBasDevp/noCacheShelves/auth") - public R getBasDevpByNoCacheShelves(){ + public R getBasDevpByNoCacheShelves() { return R.ok(agvBasDevpService.getBasDevpByNoCacheShelves()); } @@ -109,15 +115,15 @@ */ @PostMapping("/pakin/auth") @Synchronized - public R pakin(@RequestBody Map<String,Object> map){ + public R pakin(@RequestBody Map<String, Object> map) { List<String> devNos = (List<String>) map.get("devNo"); List<AgvBasDevp> agvBasDevpList = devNos.stream().map(devNo -> { return agvBasDevpService.selectById(devNo); }).collect(Collectors.toList()); - workService.createWaitPainWrkMastStart(agvBasDevpList, getUserId(),false); - + workService.createWaitPainWrkMastStart(agvBasDevpList, getUserId(), false); + return R.ok("鐢熸垚宸ヤ綔妗f垚鍔�"); } @@ -128,13 +134,14 @@ @Synchronized @Transactional @ManagerAuth(memo = "鍚姩鍏ュ簱") - public R startPakin(@RequestBody AgvMobileStartPakin params){ + public R startPakin(@RequestBody AgvMobileStartPakin params) { + log.info("鍚姩鍏ュ簱,{}", JSON.toJSONString(params)); // 缁勬墭 params.getCombParams().forEach(combParam -> { - agvMobileService.comb(combParam,getUserId()); + agvMobileService.comb(combParam, getUserId()); }); - params.setContainerType(Short.valueOf(params.getContainerCode().substring(0,2))); - workService.emptyPlateIn(params.getDevNo(),params.getContainerCode(),params.getContainerType(), getUserId(),false); + params.setContainerType(Short.valueOf(params.getContainerCode().substring(0, 2))); + workService.emptyPlateIn(params.getDevNo(), params.getContainerCode(), params.getContainerType(), getUserId(), false); return R.ok("鐢熸垚宸ヤ綔妗f垚鍔�"); } @@ -145,11 +152,11 @@ @PostMapping("/pakin/empty/auth") @Synchronized @ManagerAuth(memo = "绌烘澘鍏ュ簱") - public R pakinEmpty(@RequestBody AgvMobileStartParam params){ + public R pakinEmpty(@RequestBody AgvMobileStartParam params) { for (AgvMobileStartParam.Pda pda : params.getPad()) { - pda.setContainerType(Short.valueOf(pda.getContainerCode().substring(0,2))); - workService.emptyPlateIn(pda.getDevNo(),pda.getContainerCode(),pda.getContainerType(), getUserId(),false); + pda.setContainerType(Short.valueOf(pda.getContainerCode().substring(0, 2))); + workService.emptyPlateIn(pda.getDevNo(), pda.getContainerCode(), pda.getContainerType(), getUserId(), false); } return R.ok(); @@ -161,10 +168,13 @@ @PostMapping("/pakout/empty/auth") @Synchronized @ManagerAuth(memo = "绌烘澘鍑哄簱") - public R pakoutEmpty(@RequestBody AgvMobileStartParam params){ + public R pakoutEmpty(@RequestBody AgvMobileStartParam params) { for (AgvMobileStartParam.Pda pda : params.getPad()) { - workService.emptyPlateOut(pda.getDevNo(),pda.getContainerType(), getUserId()); + if (pda == null) { + return R.error("缂哄皯绔欑偣淇℃伅"); + } + workService.emptyPlateOut(pda.getDevNo(), pda.getContainerType(), getUserId()); } return R.ok(); @@ -174,7 +184,7 @@ 绌烘澘鍑哄簱璐ф灦鐮侀�夋嫨 */ @PostMapping("/pakout/empty/container/selector/auth") - public R containerType(@RequestBody HashMap<String,String> params){ + public R containerType(@RequestBody HashMap<String, String> params) { String devNo = params.get("devNo"); AgvBasDevp agvBasDevp = agvBasDevpService.selectById(devNo); @@ -182,12 +192,12 @@ return R.ok(agvLocMastService.queryContainerTypeByLocType1(agvBasDevp.getLocType1())); } - + /* 鏌ヨ搴撳瓨 鍏ュ簱璁㈠崟涓庨攢鍞崟鍙� */ @PostMapping("/query/locDetl/v1") - public R queryAgvLocDetl(@RequestBody HashMap<String,String> params){ + public R queryAgvLocDetl(@RequestBody HashMap<String, String> params) { String orderNo = params.get("orderNo"); String threeCode = params.get("threeCode"); @@ -209,7 +219,7 @@ for (AgvLocDetl agvLocDetl : agvLocDetls) { AgvLocMast agvLocMast = new AgvLocMast(); if (Cools.isEmpty(floor)) { - agvLocMast = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocDetl.getLocNo()).notLike("loc_no","F1")); + agvLocMast = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocDetl.getLocNo()).notLike("loc_no", "F1")); } else { // 濡傛灉鏄姞宸ュ崟 鍙湪 lev1 = 1 鏌ュ簱瀛� if ("JG".equals(orderNo.substring(0,2))) { @@ -374,24 +384,23 @@ AgvLocMast agvLocMastByContainerCode = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("barcode", containerCode)); AgvLocMast agvLocMastByLocNo = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", locNo)); - String barcode1 = agvLocMastByLocNo.getBarcode(); + String barcode1 = agvLocMastByLocNo.getBarcode(); - - if((!Cools.eq("F",agvLocMastByLocNo.getLocSts()) - && !Cools.eq("D",agvLocMastByLocNo.getLocSts()))){ + if ((!Cools.eq("F", agvLocMastByLocNo.getLocSts()) + && !Cools.eq("D", agvLocMastByLocNo.getLocSts()))) { return R.error("搴撲綅鐘舵�佷笉涓篎鎴栬�匘锛屾棤娉曠淮鎶�"); } // -------------1----------------------------- //搴撲綅淇℃伅涓虹┖ 璐ф灦淇℃伅涓嶄负绌� - if(Cools.isEmpty(listByLocNo) && !Cools.isEmpty(listByContainerCode)){ + if (Cools.isEmpty(listByLocNo) && !Cools.isEmpty(listByContainerCode)) { //鏇存柊璐ф灦淇℃伅鐨勫簱浣嶄负褰撳墠搴撲綅 listByContainerCode.forEach(agvLocDetl -> { String sourceLoc = agvLocDetl.getLocNo(); agvLocDetl.setLocNo(locNo); - agvLocDetlService.updateLocNo(locNo,sourceLoc,agvLocDetl); + agvLocDetlService.updateLocNo(locNo, sourceLoc, agvLocDetl); }); agvLocMastByLocNo.setLocSts("F"); @@ -403,6 +412,9 @@ agvLocMastByContainerCode.setBarcode(barcode1); agvLocMastService.updateById(agvLocMastByContainerCode); } + // 淇濆瓨璋冩暣璁板綍 + AdjDetl adjDetl = new AdjDetl(); + return R.ok("缁存姢鎴愬姛"); } @@ -503,6 +515,9 @@ for (AgvLocDetl agvLocDetl : agvLocDetls) { // 鏇存柊璁㈠崟 OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no", "DB" + agvLocDetl.getOrderNo()).eq("matnr", agvLocDetl.getMatnr()).eq("three_code",agvLocDetl.getThreeCode())); + if (orderDetl == null) { + throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�"); + } orderDetl.setQty(orderDetl.getQty() + agvLocDetl.getAnfme()); if (!orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>().eq("order_no","DB" + agvLocDetl.getOrderNo()).eq("matnr", agvLocDetl.getMatnr()).eq("three_code",agvLocDetl.getThreeCode()))){ throw new CoolException("淇敼璁㈠崟鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�"+agvLocDetl.getOrderNo()+agvLocDetl.getMatnr()); @@ -523,6 +538,7 @@ List<HashMap<String,String>> dbList = (List<HashMap<String, String>>) params.get("dbList"); params.get("dbList"); Object mT = params.get("moveType"); + String orderNo = params.get("orderNo").toString(); String moveType = ""; Integer ioType = 0; if (mT.equals("unAuto")) { @@ -557,6 +573,7 @@ wrkDetl.setWrkNo(wrkMast.getWrkNo()); wrkDetl.sync(agvLocDetl); wrkDetl.setSuppCode(agvLocDetl.getSuppCode()); + wrkDetl.setModel(orderNo); wrkDetl.setIoTime(now); wrkDetl.setAppeUser(getUserId()); wrkDetl.setAppeTime(now); @@ -565,10 +582,13 @@ if (!agvWrkDetlService.insert(wrkDetl)) { throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触"); } - // 鏇存柊璁㈠崟 - OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("source",33).eq("matnr", agvLocDetl.getMatnr()).eq("three_code",agvLocDetl.getThreeCode())); -// FlowLog flowLog = new FlowLog(); + OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no",orderNo).eq("source",33).eq("matnr", agvLocDetl.getMatnr()).eq("three_code",agvLocDetl.getThreeCode())); + // 鍒ゆ柇璁㈠崟鏄惁瓒呴噺 + if (orderDetl.getQty() >= orderDetl.getAnfme()) { + throw new CoolException("璋冩嫧鍗�:" + orderNo + "鐨�<" + agvLocDetl.getMatnr() + ">宸插畬鎴愯皟鎷ㄦ暟閲�,璇锋鏌�!"); + } + // FlowLog flowLog = new FlowLog(); // flowLog.setFid(String.valueOf(flowId)); // flowLog.setSpare2(wrkMast.getWrkNo().toString()); // flowLog.setLocNo(wrkMast.getSourceLocNo()); @@ -595,8 +615,16 @@ // throw new CoolException("鍚屾鍗婃垚鍝佽皟鎷ㄥ崟娴佹按璁板綍澶辫触"); // } orderDetl.setQty(orderDetl.getQty() + agvLocDetl.getAnfme()); - if (!orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>().eq("source",33).eq("matnr", agvLocDetl.getMatnr()).eq("three_code",agvLocDetl.getThreeCode()))){ - throw new CoolException("淇敼璁㈠崟鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�"+agvLocDetl.getOrderNo()+agvLocDetl.getMatnr()); + if (!orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>().eq("order_no",orderNo).eq("source",33).eq("matnr", agvLocDetl.getMatnr()).eq("three_code",agvLocDetl.getThreeCode()))){ + throw new CoolException("璁㈠崟鍙凤細{"+orderNo+"}鏇存柊璁㈠崟鏄庣粏澶辫触锛� 寮傚父鐗╂枡:"+agvLocDetl.getMatnr()+"(鍗婃垚鍝佽皟鎷ㄥ崟浠诲姟)" ); + } + // 鏇存柊璁㈠崟鐘舵�� + Order order = orderService.selectByNo(orderDetl.getOrderNo()); + Long settle = order.getSettle(); + if (settle == 1L) { + if (!orderService.updateSettle(order.getId(),2L,getUserId())) { + throw new CoolException("璁㈠崟鍙凤細{"+order.getOrderNo()+"}鏇存柊璁㈠崟鐘舵�侊細1-->2 澶辫触锛�(鍗婃垚鍝佽皟鎷ㄥ崟浠诲姟)" ); + } } } // 鏇存柊婧愬簱浣� @@ -615,6 +643,7 @@ Date now = new Date(); List<HashMap<String,String>> dbList = (List<HashMap<String, String>>) params.get("dbList"); params.get("dbList"); + String orderNo = params.get("orderNo").toString(); for (HashMap<String, String> map : dbList) { String locNo = map.get("locNo"); String barcode = map.get("suppCode"); @@ -645,11 +674,19 @@ // 鏇存柊璁㈠崟 // 鍏堟煡璇㈠簱璁㈠崟鏄庣粏 鎵�灞炵殑璁㈠崟 - OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("source",36).eq("matnr", agvLocDetl.getMatnr()).eq("three_code",agvLocDetl.getThreeCode())); + OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no",orderNo).eq("source",17).eq("matnr", agvLocDetl.getMatnr()).eq("three_code",agvLocDetl.getThreeCode())); orderDetl.setQty(orderDetl.getQty() + agvLocDetl.getAnfme()); - if (!orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>().eq("source",36).eq("matnr", agvLocDetl.getMatnr()).eq("three_code",agvLocDetl.getThreeCode()))){ + if (!orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>().eq("order_no",orderNo).eq("source",17).eq("matnr", agvLocDetl.getMatnr()).eq("three_code",agvLocDetl.getThreeCode()))){ throw new CoolException("淇敼璁㈠崟鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�"+agvLocDetl.getOrderNo()+agvLocDetl.getMatnr()); } + // 鏇存柊璁㈠崟鐘舵�� + Order order = orderService.selectByNo(orderNo); + Long settle = order.getSettle(); + if (settle == 1L) { + if (!orderService.updateSettle(order.getId(),2L,getUserId())) { + throw new CoolException("璁㈠崟鍙凤細{"+order.getOrderNo()+"}鏇存柊璁㈠崟鐘舵�侊細1-->2 澶辫触锛�(鍗婃垚鍝佽皟鎷ㄥ崟浠诲姟)" ); + } + } } // 鏇存柊婧愬簱浣� AgvLocMast locMast = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", locNo)); -- Gitblit v1.9.1