|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.framework.annotations.ManagerAuth; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.Cools; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.R; | 
|---|
|  |  |  | import com.zy.asrs.framework.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.CacheSite; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.Order; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.WaitPakin; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.dto.OrderInfoDto; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.dto.PickSheetDetlDto; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.dto.ShippingOrderDetlDto; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.enums.OrderType; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.param.BatchMergeOrdersParam; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.param.PakinOnShelvesParams; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.MobileService; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.OrderService; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.WaitPakinService; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.controller.BaseController; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.entity.Host; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.entity.User; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.entity.UserLogin; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.service.UserLoginService; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${super.pwd}") | 
|---|
|  |  |  | private String superPwd; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserService userService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MobileService mobileService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WaitPakinService waitPakinService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取用户机构 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/current/host") | 
|---|
|  |  |  | public R getUserHost() { | 
|---|
|  |  |  | List<Host> hosts = mobileService.getHosts(); | 
|---|
|  |  |  | return R.ok(hosts); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 入库单据--扫码获取订单明细列表 | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/mat/auth") | 
|---|
|  |  |  | public R getProductForBarcode(@RequestBody Map<String, String> barcode) { | 
|---|
|  |  |  | if (Objects.isNull(barcode)) { | 
|---|
|  |  |  | return  R.error("参数不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (StringUtil.isNullOrEmpty(barcode.get("barcode"))) { | 
|---|
|  |  |  | return  R.error("条码不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Order order =  orderService.selectByBarcode(barcode.get("barcode")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!(order.getOrderType() == 1)) { | 
|---|
|  |  |  | return R.error("非入库订单, 不可操作!!"); | 
|---|
|  |  |  | if (Objects.isNull(order)) { | 
|---|
|  |  |  | return R.error("订单不存在!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (order.getOrderSettle() > 2) { | 
|---|
|  |  |  | return R.error("单据当前状态不可做入库操作!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<OrderInfoDto> orders = orderService.getDetlForOrderId(order.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(orders); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 平库上架 | 
|---|
|  |  |  | * PDA扫码入库 | 
|---|
|  |  |  | * 1. 绑定库位号与拖盘码 | 
|---|
|  |  |  | * 2. 库位置为在库状态 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/matnr/in/barcode") | 
|---|
|  |  |  | public R pakinToStock(@RequestBody PakinOnShelvesParams shelvesParams) { | 
|---|
|  |  |  | if (StringUtil.isNullOrEmpty(shelvesParams.getBarcode())) { | 
|---|
|  |  |  | return R.error("拖盘码不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (StringUtil.isNullOrEmpty(shelvesParams.getLoc())) { | 
|---|
|  |  |  | return R.error("库位不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //TODO 绑定库位,添加库位明细 | 
|---|
|  |  |  | if (mobileService.pakinToStock(shelvesParams)) { | 
|---|
|  |  |  | return R.ok("入库成功!!"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return R.error("入库失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取拖盘码绑定商品 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/barcode/matnr/{code}") | 
|---|
|  |  |  | public R getAllGoods(@PathVariable String code) { | 
|---|
|  |  |  | if (StringUtil.isNullOrEmpty(code)) { | 
|---|
|  |  |  | return R.error("托盘码不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String str = code.trim(); | 
|---|
|  |  |  | // CUT库条码T开头,截取后10位 | 
|---|
|  |  |  | if (str.charAt(0) == 'T') { | 
|---|
|  |  |  | code = str.substring(str.length() - 10); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, code)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(waitPakins); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.parse(CodeRes.USER_10003); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String system = null;//登陆系统 | 
|---|
|  |  |  | if (wms) { | 
|---|
|  |  |  | if (Objects.isNull(wms) || wms) { | 
|---|
|  |  |  | system = String.valueOf(LoginSystemType.WMS); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | system = String.valueOf(LoginSystemType.WCS); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author Ryan | 
|---|
|  |  |  | * @date 2025/6/25 | 
|---|
|  |  |  | * @description: 组托 | 
|---|
|  |  |  | * @version 1.0 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/comb/auth") | 
|---|
|  |  |  | public  R combMats(@RequestBody BatchMergeOrdersParam ordersParam) { | 
|---|
|  |  |  | if (StringUtil.isNullOrEmpty(ordersParam.getOrderNo())) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.error("订单明细不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String str = ordersParam.getMergeNo().trim(); | 
|---|
|  |  |  | // CTU库条码T开头,截取后10位 | 
|---|
|  |  |  | if (str.charAt(0) == 'T') { | 
|---|
|  |  |  | ordersParam.setMergeNo(str.substring(str.length() - 10)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (str.startsWith("PK")) { | 
|---|
|  |  |  | ordersParam.setInType(OrderType.PK_IN_ORDER.id); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | ordersParam.setInType(OrderType.UTC_OUT_ORDER.id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | boolean result = mobileService.batchMergeOrders(ordersParam); | 
|---|
|  |  |  | if (result) { | 
|---|
|  |  |  | return R.ok("组托成功!!"); | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok("组托失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取拣货明细 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/pick/detl/{code}") | 
|---|
|  |  |  | public R pickDetlByPickNo(@PathVariable String code) { | 
|---|
|  |  |  | if (StringUtil.isNullOrEmpty(code)) { | 
|---|
|  |  |  | return R.error("拣货单据编码不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | PickSheetDetlDto pickSheetDetls =  mobileService.outFlatSheet(code); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(pickSheetDetls); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 拣货单确认出库 | 
|---|
|  |  |  | * @param code | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/pick/confirm/{code}") | 
|---|
|  |  |  | public R confirmOutFlatSheet(@PathVariable String code) { | 
|---|
|  |  |  | if (StringUtil.isNullOrEmpty(code)) { | 
|---|
|  |  |  | return R.error("拣货单据编码不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!mobileService.confirmFlatSheet(code)) { | 
|---|
|  |  |  | return R.error("出库失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("出库成功!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取播种位 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/pick/seed/locs") | 
|---|
|  |  |  | public R seedLocs() { | 
|---|
|  |  |  | List<CacheSite> sites = mobileService.getSeedLocs(); | 
|---|
|  |  |  | return R.ok(sites); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 订单绑定站点 | 
|---|
|  |  |  | * @param param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/pick/seed/bind") | 
|---|
|  |  |  | public R bindLoc(@RequestBody Map<String, Object> param) { | 
|---|
|  |  |  | if (Objects.isNull(param)) { | 
|---|
|  |  |  | throw new CoolException("请求参数不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Objects.isNull(param.get("barcode"))) { | 
|---|
|  |  |  | throw new CoolException("播种墙容器编码不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Objects.isNull(param.get("orderNo"))) { | 
|---|
|  |  |  | throw new CoolException("订单编号不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Objects.isNull(param.get("siteNo"))) { | 
|---|
|  |  |  | throw new CoolException("播种站点不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Objects.isNull(param.get("type"))) { | 
|---|
|  |  |  | throw new CoolException("参数类型不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | boolean result =  mobileService.bindOrderBySite(param); | 
|---|
|  |  |  | if (result) { | 
|---|
|  |  |  | return R.ok("绑定成功!!"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return R.error("绑定失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取发货订单明细 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/shipping/order/detl") | 
|---|
|  |  |  | public R  getOrderDetl(@RequestBody Map<String, Object> params) { | 
|---|
|  |  |  | if (Objects.isNull(params)) { | 
|---|
|  |  |  | throw new CoolException("参数不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return mobileService.selectShippingDetl(params); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author Ryan | 
|---|
|  |  |  | * @date 2025/6/28 | 
|---|
|  |  |  | * @description: 获取推荐库位 | 
|---|
|  |  |  | * @version 1.0 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/recommend/locs") | 
|---|
|  |  |  | public R getRecommend() { | 
|---|
|  |  |  | return  mobileService.getRecommendLocs(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author Ryan | 
|---|
|  |  |  | * @date 2025/6/28 | 
|---|
|  |  |  | * @description: 查询物料信息 | 
|---|
|  |  |  | * @version 1.0 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/mats/search/{matnr}") | 
|---|
|  |  |  | public R getMats(@PathVariable String matnr) { | 
|---|
|  |  |  | return mobileService.getMatsByCode(matnr); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 确认发货单明细 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/shipping/confirm") | 
|---|
|  |  |  | public R confirmShipping(@RequestBody List<ShippingOrderDetlDto> params) { | 
|---|
|  |  |  | if (params.isEmpty()) { | 
|---|
|  |  |  | throw new CoolException("发货单明细不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return mobileService.confirmShippingDetl(params); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|