|  |  | 
 |  |  | package com.zy.asrs.controller; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
 |  |  | import com.baomidou.mybatisplus.mapper.Wrapper; | 
 |  |  | import com.core.annotations.ManagerAuth; | 
 |  |  | import com.core.common.BaseRes; | 
 |  |  | import com.core.common.Cools; | 
 |  |  | import com.core.common.R; | 
 |  |  | import com.zy.asrs.entity.LocDetl; | 
 |  |  | import com.zy.asrs.entity.LocMast; | 
 |  |  | import com.zy.asrs.entity.Order; | 
 |  |  | import com.zy.asrs.entity.OrderDetl; | 
 |  |  | import com.zy.asrs.entity.param.CombParam; | 
 |  |  | import com.zy.asrs.service.LocDetlService; | 
 |  |  | import com.zy.asrs.service.LocMastService; | 
 |  |  | import com.zy.asrs.service.MobileService; | 
 |  |  | import com.zy.asrs.service.OrderService; | 
 |  |  | import com.zy.common.model.MobileLocDetlVo; | 
 |  |  | import com.core.exception.CoolException; | 
 |  |  | import com.zy.asrs.entity.*; | 
 |  |  | import com.zy.asrs.entity.param.*; | 
 |  |  | import com.zy.asrs.entity.result.MobileAdjustResult; | 
 |  |  | import com.zy.asrs.mapper.ManLocDetlMapper; | 
 |  |  | import com.zy.asrs.service.*; | 
 |  |  | import com.zy.asrs.utils.MathUtils; | 
 |  |  | import com.zy.asrs.utils.OrderInAndOutUtil; | 
 |  |  | import com.zy.common.model.WrkDto; | 
 |  |  | import com.zy.common.utils.Synchro; | 
 |  |  | import com.zy.common.web.BaseController; | 
 |  |  | import com.zy.nc.entity.NccJcQilibcBarcodeflowWms; | 
 |  |  | import com.zy.nc.entity.NccQilibcTmprintWms; | 
 |  |  | import com.zy.nc.entity.NccSaleXclGgsybWms; | 
 |  |  | import com.zy.nc.service.NccJcQilibcBarcodeflowWmsService; | 
 |  |  | import com.zy.nc.service.NccQilibcTmprintWmsService; | 
 |  |  | import com.zy.nc.service.NccSaleXclGgsybWmsService; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
 |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
 |  |  | import org.springframework.web.bind.annotation.RequestParam; | 
 |  |  | import org.springframework.web.bind.annotation.RestController; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  |  | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.List; | 
 |  |  | import javax.annotation.Resource; | 
 |  |  | import java.math.BigDecimal; | 
 |  |  | import java.util.*; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 移动端接口控制器 | 
 |  |  | 
 |  |  |  */ | 
 |  |  | @RestController | 
 |  |  | @RequestMapping("mobile") | 
 |  |  | public class MobileController extends BaseController  { | 
 |  |  | public class MobileController extends BaseController { | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private MobileService mobileService; | 
 |  |  | 
 |  |  |     private LocDetlService locDetlService; | 
 |  |  |     @Autowired | 
 |  |  |     private OrderService orderService; | 
 |  |  |     @Autowired | 
 |  |  |     private OrderDetlService orderDetlService; | 
 |  |  |     @Autowired | 
 |  |  |     private DocTypeService docTypeService; | 
 |  |  |     @Autowired | 
 |  |  |     private WrkMastService wrkMastService; | 
 |  |  |     @Autowired | 
 |  |  |     private WrkDetlService wrkDetlService; | 
 |  |  |     @Autowired | 
 |  |  |     private BasDevpService basDevpService; | 
 |  |  |     @Autowired | 
 |  |  |     private PackService packService; | 
 |  |  |     @Autowired | 
 |  |  |     private ManLocDetlMapper manLocDetlMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private WrkDetlLogService wrkDetlLogService; | 
 |  |  |     @Autowired | 
 |  |  |     private WrkMastLogService wrkMastLogService; | 
 |  |  |     @Autowired | 
 |  |  |     private StoreTypeService storeTypeService; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据单号检索单据数据 | 
 |  |  |      */ | 
 |  |  |     @RequestMapping("/order/serach/orderNo/auth") | 
 |  |  |     @Autowired | 
 |  |  |     private MatService matService; | 
 |  |  |     @Autowired | 
 |  |  |     private NccJcQilibcBarcodeflowWmsService nccJcQilibcBarcodeflowWmsService; | 
 |  |  |     @Autowired | 
 |  |  |     private NccQilibcTmprintWmsService nccQilibcTmprintWmsService; | 
 |  |  |     @Autowired | 
 |  |  |     private NccSaleXclGgsybWmsService nccSaleXclGgsybWmsService; | 
 |  |  |     @Autowired | 
 |  |  |     private OrderPakinService orderPakinService; | 
 |  |  |  | 
 |  |  |     @Resource | 
 |  |  |     private StaDescService staDescService; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private OrderDetlPakinService orderDetlPakinService; | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pda/WarehouseOut/v1") | 
 |  |  |     @ManagerAuth(memo = "并板途中拣料-参考念初") | 
 |  |  |     public R WarehouseOutV1(@RequestBody CombParam combParam) { | 
 |  |  |         return mobileService.WarehouseOutV1(combParam, getHostId(), getUserId()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pda/WarehouseOutPickMerge/v1") | 
 |  |  |     @ManagerAuth(memo = "拣料途中并板") | 
 |  |  |     public R WarehouseOutPickMergeV1(@RequestBody WarehouseOutPickMergeParam param) { | 
 |  |  |         if (Cools.isEmpty(param, param.getLocNo(), param.getBarcode(), param.getCombMats())) { | 
 |  |  |             return R.parse("参数不能为空!"); | 
 |  |  |         } | 
 |  |  |         return mobileService.WarehouseOutPickMergeV1(param, getHostId(), getUserId()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pick/in") | 
 |  |  |     @ManagerAuth(memo = "并板入库") | 
 |  |  |     public R pickConfirm(@RequestBody PickConfirmParam param) { | 
 |  |  |  | 
 |  |  |         if (Cools.isEmpty(param, param.getList(), param.getLocNo(), param.getStaNo())) { | 
 |  |  |             return R.parse("参数不完整"); | 
 |  |  |         } | 
 |  |  |         return mobileService.pickConfirm(param, getUserId()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/barcode/list/all") | 
 |  |  |     @ManagerAuth(memo = "并板入库途中拣料出库获取任务信息") | 
 |  |  |     public R orderOutListOrder(@RequestParam(required = false) String barcode) { | 
 |  |  |         return mobileService.orderOutListOrder(barcode, getUserId()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/barcode/list/pick") | 
 |  |  |     @ManagerAuth(memo = "拣料入库途中并板获取任务信息") | 
 |  |  |     public R orderOutListOrderPick(@RequestParam(required = false) String barcode) { | 
 |  |  |         return mobileService.orderOutListOrderPick(barcode, getUserId()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/loc/f/list") | 
 |  |  |     @ManagerAuth(memo = "获取在库库位") | 
 |  |  |     public R locNoF(@RequestParam(required = false) String locNo) { | 
 |  |  |         Wrapper<LocMast> wrapper = new EntityWrapper<LocMast>() | 
 |  |  |                 .eq("loc_sts", "F"); | 
 |  |  |         if (!Cools.isEmpty(locNo)) { | 
 |  |  |             wrapper.like("loc_no", locNo); | 
 |  |  |         } | 
 |  |  |         List<LocMast> list = locMastService.selectList(wrapper); | 
 |  |  |         return R.ok().add(list); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pick/sta/list") | 
 |  |  |     @ManagerAuth(memo = "获取并板站") | 
 |  |  |     public R pickSta() { | 
 |  |  |         List<StaDesc> list = staDescService.selectList(new EntityWrapper<StaDesc>() | 
 |  |  |                 .eq("type_no", 104)); | 
 |  |  |         return R.ok().add(list); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pick/mat/list") | 
 |  |  |     @ManagerAuth(memo = "获取并板物料") | 
 |  |  |     public R pickMats(@RequestParam(required = false) String matnr, @RequestParam(required = false) String orderNo) { | 
 |  |  |         return mobileService.pickMats(matnr, orderNo); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     // 商品上架 | 
 |  |  |     @RequestMapping("/mat/onSale/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R orderSearchByBarcode(@RequestParam String orderNo){ | 
 |  |  |         Order order = orderService.selectByNo(orderNo); | 
 |  |  |         if (order.getSettle() > 2) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         List<OrderDetl> orderDetls = orderService.selectWorkingDetls(order.getId()); | 
 |  |  |         if (Cools.isEmpty(orderDetls)) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         return R.ok().add(orderDetls); | 
 |  |  |     public R matOnSale(@RequestBody CombParam combParam) { | 
 |  |  |         mobileService.onSale(combParam); | 
 |  |  |         return R.ok("上架成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     // 商品下架 | 
 |  |  |     @RequestMapping("/mat/offSale/auth") | 
 |  |  |     //@ManagerAuth | 
 |  |  |     public R matOffSale(@RequestBody OffSaleParam offSaleParam) { | 
 |  |  |         mobileService.offSale(offSaleParam); | 
 |  |  |         return R.ok("下架成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     // 组托 ---------------------------------------------------------------------------------------------------- | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 组托 | 
 |  |  |      * 根据单号检索单据数据 | 
 |  |  |      * http://localhost:8081/jkwms/mobile/order/serach/orderNo/auth?orderNo=123123 | 
 |  |  |      */ | 
 |  |  | //    @RequestMapping("/order/search/orderNo/auth") | 
 |  |  | //    @ManagerAuth | 
 |  |  | //    public R orderSearchByBarcode(@RequestParam String orderNo){ | 
 |  |  | //        Order order = orderService.selectByNo(orderNo); | 
 |  |  | //        if (order == null) { | 
 |  |  | //            return R.ok(); | 
 |  |  | //        } | 
 |  |  | //        DocType docType = docTypeService.selectById(order.getDocType()); | 
 |  |  | //        if (docType.getPakin() == null || docType.getPakin() != 1) { | 
 |  |  | //            return R.ok(); | 
 |  |  | //        } | 
 |  |  | //        if (order.getSettle() > 2) { | 
 |  |  | //            return R.ok(); | 
 |  |  | //        } | 
 |  |  | //        List<OrderDetl> orderDetls = orderService.selectWorkingDetls(order.getId()); | 
 |  |  | //        if (Cools.isEmpty(orderDetls)) { | 
 |  |  | //            return R.ok(); | 
 |  |  | //        } | 
 |  |  | //        return R.ok().add(orderDetls); | 
 |  |  | //    } | 
 |  |  |     @RequestMapping("/order/search/orderNo/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R orderSearchByBarcode(@RequestParam String orderNo) { | 
 |  |  |         if (Cools.isEmpty(orderNo)) { | 
 |  |  |             orderNo = null; | 
 |  |  |         } | 
 |  |  |         List<OrderPakin> orderPakins = orderPakinService.selectorderNoL(orderNo); | 
 |  |  |         //List<Order> orders = OrderInAndOutUtil.selectOrderNoL(OrderEnumVo.PAKIN.getCode(), orderNo); | 
 |  |  |         if (Cools.isEmpty(orderPakins)) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         LinkedList<CombParam> combParams = new LinkedList<>(); | 
 |  |  |         if (!Cools.isEmpty(orderPakins)) { | 
 |  |  |             for (OrderPakin order : orderPakins) { | 
 |  |  |                 CombParam combParam = new CombParam(); | 
 |  |  |                 if (order == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 DocType docType = docTypeService.selectById(order.getDocType()); | 
 |  |  |                 if (docType.getPakin() == null || docType.getPakin() != 1) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 if (order.getSettle() > 2) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  | //                List<OrderDetl> orderDetls = orderService.selectWorkingDetls(order.getId()); | 
 |  |  |                 List<OrderDetl> orderDetls = OrderInAndOutUtil.selectWorkingDetls(order.getPakinPakoutStatus$(), order.getId()); | 
 |  |  |                 if (!Cools.isEmpty(orderDetls)) { | 
 |  |  |                     LinkedList<CombParam.CombMat> combMats = new LinkedList<>(); | 
 |  |  |                     for (OrderDetl orderDetl : orderDetls) { | 
 |  |  |                         CombParam.CombMat combMat = new CombParam.CombMat(); | 
 |  |  |                         Synchro.Copy(orderDetl, combMat); | 
 |  |  |                         combMat.setMatnr(orderDetl.getMatnr()); | 
 |  |  |                         combMat.setBatch(orderDetl.getBatch()); | 
 |  |  |                         combMat.setAnfme(MathUtils.subtract(orderDetl.getAnfme(), orderDetl.getWorkQty())); | 
 |  |  |                         combMat.setMaktx(orderDetl.getMaktx()); | 
 |  |  |                         combMat.setSpecs(orderDetl.getSpecs()); | 
 |  |  |                         combMat.setEnableQty(MathUtils.subtract(orderDetl.getAnfme(), orderDetl.getWorkQty())); | 
 |  |  |                         combMats.add(combMat); | 
 |  |  |                     } | 
 |  |  |                     combParam.setCombMats(combMats); | 
 |  |  |                 } | 
 |  |  |                 //combParam.setOrderNo(order.getOrderNo()); | 
 |  |  |                 combParams.add(combParam); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return R.ok().add(combParams.get(0)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/mat/search/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R pdaSearchV2(@RequestParam String matnr) { | 
 |  |  |         EntityWrapper<NccJcQilibcBarcodeflowWms> wrapper = new EntityWrapper<>(); | 
 |  |  |         wrapper.eq("VBARCODE", matnr).orderBy("ts", false); | 
 |  |  |         NccJcQilibcBarcodeflowWms nccJcQilibcBarcodeflowWms = nccJcQilibcBarcodeflowWmsService.selectOne(wrapper); | 
 |  |  |         if (null == nccJcQilibcBarcodeflowWms) { | 
 |  |  |             return R.error("未找到此条码"); | 
 |  |  |         } else { | 
 |  |  |             if (!nccJcQilibcBarcodeflowWms.getInfla().equals("出库")) { | 
 |  |  |                 return R.error("该条码最后一次不是出库"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         Mat mat = matService.selectByMatnr(nccJcQilibcBarcodeflowWms.getWlbm()); | 
 |  |  |         MatParam matParam = new MatParam(); | 
 |  |  |         Synchro.Copy(mat, matParam); | 
 |  |  |         OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>().eq("order_no", nccJcQilibcBarcodeflowWms.getZkdh()).eq("matnr", mat.getMatnr()).eq("batch", nccJcQilibcBarcodeflowWms.getVbatchcode())); | 
 |  |  |         if (orderDetlPakin == null) { | 
 |  |  |             throw new CoolException("未找到此单号"); | 
 |  |  |         } | 
 |  |  |         matParam.setStandby1(orderDetlPakin.getStandby1()); | 
 |  |  |         matParam.setOrderNo(nccJcQilibcBarcodeflowWms.getZkdh()); | 
 |  |  |         matParam.setBatch(nccJcQilibcBarcodeflowWms.getVbatchcode()); | 
 |  |  |         matParam.setAnfme(nccJcQilibcBarcodeflowWms.getAsnnum() == null ? 0.0D : nccJcQilibcBarcodeflowWms.getAsnnum().doubleValue()); | 
 |  |  |         matParam.setWeight(nccJcQilibcBarcodeflowWms.getNastnum() == null ? 0.0D : nccJcQilibcBarcodeflowWms.getNastnum().doubleValue()); | 
 |  |  |         matParam.setAnfme2(nccJcQilibcBarcodeflowWms.getNastnum() == null ? 0.0D : nccJcQilibcBarcodeflowWms.getNastnum().doubleValue()); | 
 |  |  |         matParam.setTiaoma(nccJcQilibcBarcodeflowWms.getVbarcode()); | 
 |  |  |         matParam.setCstateid(nccJcQilibcBarcodeflowWms.getCstateid()); | 
 |  |  |         return R.ok().add(matParam); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/mat/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R pdaSearchV3(@RequestParam String matnr) { | 
 |  |  |         EntityWrapper<NccQilibcTmprintWms> wrapper = new EntityWrapper<>(); | 
 |  |  |         wrapper.eq("BARCODE", matnr).orderBy("PRINTTIME", false); | 
 |  |  |         NccQilibcTmprintWms nccQilibcTmprintWms = nccQilibcTmprintWmsService.selectOne(wrapper); | 
 |  |  |         if (null == nccQilibcTmprintWms) { | 
 |  |  |             return R.error("未找到此条码"); | 
 |  |  |         } | 
 |  |  |         Mat mat = matService.selectByMatnr(nccQilibcTmprintWms.getWlbm()); | 
 |  |  |         MatParam matParam = new MatParam(); | 
 |  |  |         Synchro.Copy(mat, matParam); | 
 |  |  |         matParam.setBatch(nccQilibcTmprintWms.getVbatchcode()); | 
 |  |  | //        matParam.setAnfme(nccQilibcTmprintWms.getAsnnum() == null ? 0.0D : nccQilibcTmprintWms.getAsnnum().doubleValue()); | 
 |  |  | //        matParam.setAnfme2(nccQilibcTmprintWms.getNastnum() == null ? 0.0D : nccQilibcTmprintWms.getNastnum().doubleValue()); | 
 |  |  |         matParam.setAnfme(0.0D); | 
 |  |  |         matParam.setAnfme2(0.0D); | 
 |  |  |         matParam.setTiaoma(nccQilibcTmprintWms.getBarcode()); | 
 |  |  |         matParam.setStandby1(nccQilibcTmprintWms.getCkbm()); | 
 |  |  |         matParam.setCstateid(nccQilibcTmprintWms.getCstateid()); | 
 |  |  |         return R.ok().add(matParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/mat/back") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R pdaSearchBack(@RequestParam String barcode) { | 
 |  |  |         WrkMastLog wrkMastLog = wrkMastLogService.selectOne(new EntityWrapper<WrkMastLog>() | 
 |  |  |                 .eq("barcode", barcode) | 
 |  |  |                 .in("io_type", 101, 103, 107) | 
 |  |  |                 .orderBy("appe_time", false) | 
 |  |  |         ); | 
 |  |  |  | 
 |  |  |         if(null == wrkMastLog) { | 
 |  |  |             return R.error("未找到此托盘码出库记录"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectList(new EntityWrapper<WrkDetlLog>() | 
 |  |  |                 .eq("wrk_no", wrkMastLog.getWrkNo()) | 
 |  |  |                 .eq("zpallet", barcode) | 
 |  |  |                 .orderBy("io_time", false) | 
 |  |  |         ); | 
 |  |  |         if (wrkDetlLogs.isEmpty()) { | 
 |  |  |             return R.error("未找到此托盘码出库记录明细"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         WrkDetlLog wrkDetlLog = wrkDetlLogs.get(0); | 
 |  |  |         String batch = wrkDetlLog.getBatch(); | 
 |  |  |  | 
 |  |  |         HashMap<String, Object> map = new HashMap<>(); | 
 |  |  |         Mat mat = matService.selectByMatnr(wrkDetlLog.getMatnr()); | 
 |  |  |         if (mat == null) { | 
 |  |  |             return R.error("未找到物料明细"); | 
 |  |  |         } | 
 |  |  |         MatParam matParam = new MatParam(); | 
 |  |  |         Synchro.Copy(mat, matParam); | 
 |  |  |         matParam.setBatch(batch); | 
 |  |  |         matParam.setAnfme(0.0D); | 
 |  |  |         matParam.setAnfme2(0.0D); | 
 |  |  |         matParam.setTiaoma(batch); | 
 |  |  |         matParam.setCstateid(wrkDetlLog.getCstateid()); | 
 |  |  |  | 
 |  |  |         String[] split = wrkDetlLog.getOrderNo().split("-"); | 
 |  |  |         map.put("orderNo", split[0]); | 
 |  |  |         map.put("matData", matParam); | 
 |  |  |         return R.ok().add(map); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/comb/cancel") | 
 |  |  |     @ManagerAuth(memo = "取消组托") | 
 |  |  |     public R combCancel(@RequestBody CombCancelParam param) { | 
 |  |  |         mobileService.combCancel(param, getUserId()); | 
 |  |  |         return R.ok("取消组托成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/comb/auth") | 
 |  |  |     @ManagerAuth(memo = "组托") | 
 |  |  |     public R comb(@RequestBody CombParam combParam){ | 
 |  |  |     public R comb(@RequestBody CombParam combParam) { | 
 |  |  |         mobileService.comb(combParam, getUserId()); | 
 |  |  |         return R.ok("组托成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/comb2/auth") | 
 |  |  |     @ManagerAuth(memo = "采购组托") | 
 |  |  |     public R comb2(@RequestBody CombParam combParam) { | 
 |  |  |         CombParam.CombMat combMat = combParam.getCombMats().get(0); | 
 |  |  |  | 
 |  |  |         ArrayList<String> ckbmList = new ArrayList<>(); | 
 |  |  |         List<StoreType> storeTypes = storeTypeService.selectList(new EntityWrapper<StoreType>() | 
 |  |  |                 .like("store_name", "立体库")); | 
 |  |  |         for (StoreType storeType : storeTypes) { | 
 |  |  |             ckbmList.add(storeType.getStoreId()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  | //        NccSaleXclGgsybWms nccSaleXclGgsybWms = nccSaleXclGgsybWmsService.selectOne(new EntityWrapper<NccSaleXclGgsybWms>() | 
 |  |  | //                .eq("WLBM", combMat.getMatnr()) | 
 |  |  | //                .eq("VBATCHCODE", combMat.getBatch()) | 
 |  |  | //                .in("CKBM", ckbmList) | 
 |  |  | //        ); | 
 |  |  | //        if(null == nccSaleXclGgsybWms) { | 
 |  |  | //            return R.error("未查到ERP库存"); | 
 |  |  | //        } | 
 |  |  | // | 
 |  |  | //        //ERP库存数量 | 
 |  |  | //        BigDecimal zsl = nccSaleXclGgsybWms.getZsl(); | 
 |  |  | // | 
 |  |  | //        //获取立库数量 | 
 |  |  | //        List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() | 
 |  |  | //                .eq("matnr", combMat.getMatnr()) | 
 |  |  | //                .eq("batch", combMat.getBatch()) | 
 |  |  | //        ); | 
 |  |  | //        BigDecimal stockNum = new BigDecimal(0); | 
 |  |  | //        for (LocDetl locDetl : locDetls) { | 
 |  |  | //            stockNum = stockNum.add(BigDecimal.valueOf(locDetl.getAnfme())); | 
 |  |  | //        } | 
 |  |  | // | 
 |  |  | //        //加上组托数量 | 
 |  |  | //        for (CombParam.CombMat mat : combParam.getCombMats()) { | 
 |  |  | //            stockNum = stockNum.add(BigDecimal.valueOf(mat.getAnfme())); | 
 |  |  | //        } | 
 |  |  | // | 
 |  |  | //        if(stockNum.doubleValue() > zsl.doubleValue()) { | 
 |  |  | //            return R.error("组托数量超过ERP库存"); | 
 |  |  | //        } | 
 |  |  | // | 
 |  |  | //        List<CombParam.CombMat> combMats = combParam.getCombMats(); | 
 |  |  | //        for (CombParam.CombMat mat : combMats) { | 
 |  |  | //            mat.setStandby1(nccSaleXclGgsybWms.getCkbm()); | 
 |  |  | //        } | 
 |  |  |  | 
 |  |  |         mobileService.comb(combParam, getUserId()); | 
 |  |  |         return R.ok("组托成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pack/get/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R packGet(@RequestParam String barcode) { | 
 |  |  |         Pack pack = packService.selectByBarcode(barcode); | 
 |  |  |         if (pack == null) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         if (pack.getSettle() == 1L) { | 
 |  |  |             return R.ok().add(pack); | 
 |  |  |         } | 
 |  |  |         return R.ok("组托成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pack/comb/auth") | 
 |  |  |     @ManagerAuth(memo = "下线组托") | 
 |  |  |     public R packComb(@RequestBody CombParam combParam) { | 
 |  |  |         mobileService.packComb(combParam, getUserId()); | 
 |  |  |         return R.ok("组托成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     // 出库 --------------------------------------------------------------------------------------------------- | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pakout/query/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     @Deprecated | 
 |  |  |     public R pakoutQuery(@RequestParam(required = false) String barcode, | 
 |  |  |                          @RequestParam(required = false) Integer staNo, | 
 |  |  |                          @RequestParam(required = false) String matnr) { | 
 |  |  |         if (Cools.isEmpty(barcode) && Cools.isEmpty(matnr)) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         if (!Cools.isEmpty(barcode)) { | 
 |  |  |             List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("zpallet", barcode)); | 
 |  |  |             return R.ok().add(wrkDetls); | 
 |  |  |         } | 
 |  |  |         if (!Cools.isEmpty(matnr)) { | 
 |  |  |             if (!Cools.isEmpty(staNo)) { | 
 |  |  |                 List<WrkDetl> wrkDetls = wrkDetlService.selectPakoutQuery(staNo, matnr); | 
 |  |  |                 return R.ok().add(wrkDetls); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 出库确认 - 扫托盘码 | 
 |  |  |      * 1.全板 返回 101 | 
 |  |  |      * 2.拣料 返回 103 | 
 |  |  |      */ | 
 |  |  |     @RequestMapping("/pakout/confirm/barcode/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R pakoutQueryByBarcode(@RequestParam(required = false) String barcode) { | 
 |  |  |         if (Cools.isEmpty(barcode)) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         WrkMast wrkMast = wrkMastService.selectByBarcode(barcode); | 
 |  |  |         if (wrkMast != null) { | 
 |  |  |             List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); | 
 |  |  |             // 去除已出库确认的明细 | 
 |  |  |             wrkDetls.removeIf(wrkDetl -> wrkDetl.getInspect() != null && wrkDetl.getInspect() != 0); | 
 |  |  |             return R.ok().add(Cools.add("wrkNo", wrkMast.getWrkNo()).add("ioType", wrkMast.getIoType()).add("list", wrkDetls)); | 
 |  |  |         } | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 出库确认 - 扫货物  广德宜科版 | 
 |  |  |      * 1.全板 返回 101 | 
 |  |  |      * 2.拣料 返回 103 | 
 |  |  |      */ | 
 |  |  |     @RequestMapping("/pakout/confirm/goods/auth")       //待完善  原因(客户未给出详细信息) | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R pakoutQueryByGoods(@RequestBody GDYKConfirmGoodsParam combParam) { | 
 |  |  |         if (Cools.isEmpty(combParam)) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  | //        List<Order> orders = orderService.selectorderNoL(batch); | 
 |  |  | //        OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("matnr", combParam.getMatnr()).eq("batch", combParam.getBatch()).eq("order_no",combParam.getOrderNo())); | 
 |  |  |         Order order = OrderInAndOutUtil.selectByNo(Boolean.FALSE, combParam.getOrderNo()); | 
 |  |  |         List<OrderDetl> orderDetlList = OrderInAndOutUtil.selectByOrderId(Boolean.FALSE, order.getId()); | 
 |  |  |         OrderDetl orderDetl = null; | 
 |  |  |         for (OrderDetl orderDetl1 : orderDetlList) { | 
 |  |  |             if (combParam.getMatnr().equals(orderDetl1.getMatnr()) && combParam.getBatch().equals(orderDetl1.getBatch())) { | 
 |  |  |                 orderDetl = orderDetl1; | 
 |  |  |                 break; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if (Cools.isEmpty(orderDetl)) { | 
 |  |  |             return R.error("未查到数据"); | 
 |  |  |         } | 
 |  |  |         if (!orderDetl.getQty$().equals("已完成")) { | 
 |  |  |             return R.error("任务未完成"); | 
 |  |  |         } | 
 |  |  |         //复核数 | 
 |  |  |         orderDetl.setSource(1); | 
 |  |  | //        orderDetlService.updateById(orderDetl); | 
 |  |  |         OrderInAndOutUtil.updateOrderDetl(Boolean.FALSE, order, orderDetl); | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     // 根据库位码和商品码搜索商品 | 
 |  |  |     @RequestMapping("/mat/find/auth") | 
 |  |  |     public R find(@RequestParam(required = false) String locNo | 
 |  |  |             , @RequestParam(required = false) String matnr) { | 
 |  |  |         //List<ManLocDetl> manLocDetls = manLocDetlMapper.selectItem0(locNo, matnr); | 
 |  |  |         ManLocDetl manLocDetl = manLocDetlMapper.selectLocNo0(locNo, matnr); | 
 |  |  |         return R.ok(manLocDetl); | 
 |  |  |         //return R.ok(manLocDetlMapper.selectItem0(locNo, matnr)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 出库确认 - 拣料出库 - 选择具体条码商品 | 
 |  |  |      */ | 
 |  |  |     @RequestMapping("/pakout/confirm/pick/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R pakoutQueryByBarcode(@RequestParam(required = false) Integer wrkNo | 
 |  |  |             , @RequestParam(required = false) String matnr) { | 
 |  |  |         if (Cools.isEmpty(wrkNo)) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         if (Cools.isEmpty(matnr)) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         WrkMast wrkMast = wrkMastService.selectById(wrkNo); | 
 |  |  |         if (wrkMast == null) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         String orderNo = null; | 
 |  |  |         List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); | 
 |  |  |         for (WrkDetl wrkDetl : wrkDetls) { | 
 |  |  |             if (Cools.isEmpty(orderNo)) { | 
 |  |  |                 orderNo = wrkDetl.getOrderNo(); | 
 |  |  |             } | 
 |  |  |             if ((wrkDetl.getMatnr() + "-" + wrkDetl.getBatch()).equals(matnr)) { | 
 |  |  |                 return R.ok().add(wrkDetl); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         // 替换 明细 | 
 |  |  |         List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo())); | 
 |  |  |         for (LocDetl locDetl : locDetls) { | 
 |  |  |             if ((locDetl.getMatnr() + "-" + locDetl.getBatch()).equals(matnr)) { | 
 |  |  |                 WrkDetl wrkDetl = new WrkDetl(); | 
 |  |  |                 wrkDetl.sync(locDetl); | 
 |  |  |                 wrkDetl.setOrderNo(orderNo); | 
 |  |  |                 wrkDetl.setIoTime(wrkMast.getIoTime()); | 
 |  |  |                 wrkDetl.setWrkNo(wrkNo); | 
 |  |  |                 return R.ok().add(wrkDetl); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return R.error("系统错误,条码不存在"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pakout/confirm/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     @Transactional | 
 |  |  |     public R pakoutConfirm(@RequestBody List<WrkDetl> list) { | 
 |  |  |         if (Cools.isEmpty(list)) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         Set<Integer> wrkNos = new HashSet<>(); | 
 |  |  |         List<WrkDto> dtos = new ArrayList<>(); | 
 |  |  |         for (WrkDetl wrkDetl : list) { | 
 |  |  |             if (wrkNos.contains(wrkDetl.getWrkNo())) { | 
 |  |  |                 for (WrkDto dto : dtos) { | 
 |  |  |                     if (dto.getWrkNo().equals(wrkDetl.getWrkNo())) { | 
 |  |  |                         dto.getWrkDetls().add(wrkDetl); | 
 |  |  |                         break; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } else { | 
 |  |  |                 wrkNos.add(wrkDetl.getWrkNo()); | 
 |  |  |                 dtos.add(new WrkDto(wrkDetl.getWrkNo(), wrkDetl)); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         for (WrkDto dto : dtos) { | 
 |  |  |             WrkMast wrkMast = wrkMastService.selectById(dto.getWrkNo()); | 
 |  |  |             if (wrkMast != null) { | 
 |  |  |                 // 101 | 
 |  |  |                 if (wrkMast.getIoType() == 101) { | 
 |  |  |                     for (WrkDetl wrkDetl : dto.getWrkDetls()) { | 
 |  |  |                         wrkDetlService.updateInspect(wrkDetl.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getBatch()); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 // 103 | 
 |  |  |                 if (wrkMast.getIoType() == 103) { | 
 |  |  |                     if (!wrkDetlService.delete(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo()))) { | 
 |  |  |                         throw new CoolException("拣料出库确认失败"); | 
 |  |  |                     } | 
 |  |  |                     for (WrkDetl wrkDetl : dto.getWrkDetls()) { | 
 |  |  |                         wrkDetl.setInspect(1); | 
 |  |  |                         if (!wrkDetlService.insert(wrkDetl)) { | 
 |  |  |                             throw new CoolException("拣料出库确认失败"); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         for (Integer wrkNo : wrkNos) { | 
 |  |  |             WrkMast wrkMast = wrkMastService.selectById(wrkNo); | 
 |  |  |             if (wrkMast.getWrkSts() == 14 && (Cools.isEmpty(wrkMast.getInvWh()) || wrkMast.getInvWh().equals("N"))) { | 
 |  |  |                 List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkNo); | 
 |  |  |                 boolean complete = true; | 
 |  |  |                 for (WrkDetl wrkDetl : wrkDetls) { | 
 |  |  |                     if (wrkDetl.getInspect() == null || wrkDetl.getInspect() == 0) { | 
 |  |  |                         complete = false; | 
 |  |  |                         break; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 if (complete) { | 
 |  |  |                     wrkMast.setInvWh("Y"); | 
 |  |  |                     wrkMast.setModiTime(new Date()); | 
 |  |  |                     if (!wrkMastService.updateById(wrkMast)) { | 
 |  |  |                         throw new CoolException("修改工作档" + wrkNo + "失败"); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return R.ok("完成确认"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     // 盘点 ---------------------------------------------------------------------------------------------------- | 
 |  |  |  | 
 |  |  |     @RequestMapping("/checkDetl/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R getCheckDetl(@RequestParam(required = false) Integer staNo) { | 
 |  |  |         if (null == staNo || staNo == 0) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         BasDevp basDevp = basDevpService.selectById(staNo); | 
 |  |  |         if (null != basDevp && basDevp.getWrkNo() != null) { | 
 |  |  |             WrkMast wrkMast = wrkMastService.selectById(basDevp.getWrkNo()); | 
 |  |  |             if (wrkMast != null && wrkMast.getIoType() == 107) { | 
 |  |  |                 List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); | 
 |  |  |                 if (!Cools.isEmpty(wrkDetls)) { | 
 |  |  |                     MobileAdjustResult result = new MobileAdjustResult(); | 
 |  |  |                     result.setStaNo(staNo); | 
 |  |  |                     result.setWrkNo(wrkMast.getWrkNo()); | 
 |  |  |                     result.setWrkDetls(wrkDetls); | 
 |  |  |                     return R.ok().add(result); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/checkDetl/auth/v2") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R getCheckDetlV2(@RequestParam(required = false) String barcode) { | 
 |  |  |         if (Cools.isEmpty(barcode)) { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         WrkMast wrkMast = wrkMastService.selectByBarcode(barcode); | 
 |  |  |         if (wrkMast != null && (wrkMast.getIoType() == 107 || wrkMast.getIoType() == 57)) { | 
 |  |  |             List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); | 
 |  |  |             if (!Cools.isEmpty(wrkDetls)) { | 
 |  |  |                 MobileAdjustResult result = new MobileAdjustResult(); | 
 |  |  |                 result.setBarcode(barcode); | 
 |  |  |                 result.setWrkNo(wrkMast.getWrkNo()); | 
 |  |  |                 result.setWrkDetls(wrkDetls); | 
 |  |  |                 return R.ok().add(result); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      *  根据库位号查找库存明细 | 
 |  |  |      */ | 
 |  |  |     @RequestMapping("/locDetl") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R getLocDetl(@RequestParam(required = false)String locNo, | 
 |  |  |                         @RequestParam(required = false)String matNo){ | 
 |  |  |         if (!Cools.isEmpty(locNo)) { | 
 |  |  |             LocMast locMast = locMastService.selectById(locNo); | 
 |  |  |             if (null == locMast || !"F".equals(locMast.getLocSts())) { | 
 |  |  |                 return R.parse(BaseRes.EMPTY); | 
 |  |  |             } | 
 |  |  |             List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() | 
 |  |  |                     .eq("loc_no", locNo).orderBy("appe_time", false)); | 
 |  |  |             List<MobileLocDetlVo> res = new ArrayList<>(); | 
 |  |  |             locDetls.forEach(locDetl -> { | 
 |  |  |                 MobileLocDetlVo vo = new MobileLocDetlVo(); | 
 |  |  |                 vo.setLocNo(locDetl.getLocNo()); | 
 |  |  |                 vo.setMatnr(locDetl.getMatnr()); | 
 |  |  |                 vo.setMaktx(locDetl.getMaktx()); | 
 |  |  |                 vo.setCount(locDetl.getAnfme()); | 
 |  |  |                 res.add(vo); | 
 |  |  |             }); | 
 |  |  |             return R.ok().add(res); | 
 |  |  |         } | 
 |  |  |         if (!Cools.isEmpty(matNo)) { | 
 |  |  |             List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() | 
 |  |  |                     .eq("matnr", matNo).orderBy("appe_time", false)); | 
 |  |  |             List<MobileLocDetlVo> res = new ArrayList<>(); | 
 |  |  |             locDetls.forEach(locDetl -> { | 
 |  |  |                 MobileLocDetlVo vo = new MobileLocDetlVo(); | 
 |  |  |                 vo.setLocNo(locDetl.getLocNo()); | 
 |  |  |                 vo.setMatnr(locDetl.getMatnr()); | 
 |  |  |                 vo.setMaktx(locDetl.getMaktx()); | 
 |  |  |                 vo.setCount(locDetl.getAnfme()); | 
 |  |  |                 res.add(vo); | 
 |  |  |             }); | 
 |  |  |             return R.ok().add(res); | 
 |  |  |         } | 
 |  |  |         return R.parse(BaseRes.PARAM); | 
 |  |  |     @RequestMapping("/adjust/auth") | 
 |  |  |     @ManagerAuth(memo = "盘点") | 
 |  |  |     public R adjust(@RequestBody MobileAdjustParam combParam) { | 
 |  |  |         mobileService.adjust(combParam, getUserId()); | 
 |  |  |         return R.ok("盘点成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PostMapping("/order/out/pakout/auth") | 
 |  |  |     @ManagerAuth(memo = "订单出库") | 
 |  |  |     public synchronized R pakoutByOrder(@RequestBody JSONObject param) { | 
 |  |  |         if (!param.containsKey("staNo") || !param.containsKey("orderNo")) { | 
 |  |  |             return R.parse(BaseRes.PARAM); | 
 |  |  |         } | 
 |  |  |         mobileService.pakoutByOrder(param, getUserId()); | 
 |  |  |         return R.ok("出库成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/checkOut/submit/auth") | 
 |  |  |     @ManagerAuth(memo = "盘点上报ERP") | 
 |  |  |     public R checkOutSubmit(@RequestParam("orderId") Integer orderId) { | 
 |  |  |         mobileService.checkOutSubmit(orderId, getUserId()); | 
 |  |  |         return R.ok("上报ERP成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pallet/toOutSta") | 
 |  |  |     @ManagerAuth(memo = "托盘去出库口") | 
 |  |  |     public R toOutSta(@RequestBody PalletToOutStaParam param) { | 
 |  |  |         mobileService.toOutSta(param, getUserId()); | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/pallet/toAllOut") | 
 |  |  |     @ManagerAuth(memo = "拣料转全板") | 
 |  |  |     public R toAllOut(@RequestBody PalletToAllOutParam param) { | 
 |  |  |         mobileService.toAllOut(param, getUserId()); | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |