|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.CombParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.GDYKConfirmGoodsParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.MobileAdjustParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.OffSaleParam; | 
|---|
|  |  |  | 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.common.model.WrkDto; | 
|---|
|  |  |  | import com.zy.common.web.BaseController; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 移动端接口控制器 | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkDetlLogService wrkDetlLogService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static Logger logger = LogManager.getLogger(MobileController.class); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 商品上架 | 
|---|
|  |  |  | @RequestMapping("/mat/onSale/auth") | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping("/comb/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "组托") | 
|---|
|  |  |  | public R comb(@RequestBody CombParam combParam) { | 
|---|
|  |  |  | logger.info("组托参数:{}", combParam); | 
|---|
|  |  |  | if (Cools.isEmpty(combParam.getOrderNo())) { | 
|---|
|  |  |  | combParam.setOrderNo(combParam.getBillNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok("组托成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/pack/comb/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "下线组托") | 
|---|
|  |  |  | public R packComb(@RequestBody CombParam combParam) { | 
|---|
|  |  |  | mobileService.packComb(combParam, getUserId()); | 
|---|
|  |  |  | return R.ok("组托成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //    @RequestMapping("/pack/comb/auth") | 
|---|
|  |  |  | //    @ManagerAuth(memo = "下线组托") | 
|---|
|  |  |  | //    public R packComb(@RequestBody CombParam combParam) { | 
|---|
|  |  |  | //        mobileService.packComb(combParam, getUserId()); | 
|---|
|  |  |  | //        return R.ok("组托成功"); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 出库 --------------------------------------------------------------------------------------------------- | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(barcode)) { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | System.out.println(barcode); | 
|---|
|  |  |  | if (!Cools.isEmpty(barcode)) { | 
|---|
|  |  |  | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("zpallet", barcode)); | 
|---|
|  |  |  | return R.ok().add(wrkDetls); | 
|---|
|  |  |  | 
|---|
|  |  |  | public R billQuery1(@RequestParam String billNo, @RequestParam String size) { | 
|---|
|  |  |  | Order temp1 = orderService.selectOne(new EntityWrapper<Order>().eq("temp1", billNo)); | 
|---|
|  |  |  | if (temp1 == null) { | 
|---|
|  |  |  | throw new CoolException("该订单不存在"); | 
|---|
|  |  |  | temp1 = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", billNo)); | 
|---|
|  |  |  | if (temp1 == null) { | 
|---|
|  |  |  | throw new CoolException("该订单不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<OrderDetl> waitMatins = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", temp1.getOrderNo()).like("model", size).last("and anfme > work_qty")); | 
|---|
|  |  |  | List<OrderDetl> waitMatins = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", temp1.getOrderNo()).last("and anfme > work_qty")); | 
|---|
|  |  |  | if (waitMatins == null || waitMatins.isEmpty()) { | 
|---|
|  |  |  | throw new CoolException("该订单项不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!Cools.isEmpty(waitMatins)) { | 
|---|
|  |  |  | for (OrderDetl waitMatin : waitMatins) { | 
|---|
|  |  |  | CombBillQueryVo vo = new CombBillQueryVo(); | 
|---|
|  |  |  | vo.setDetlId(waitMatin.getId()); | 
|---|
|  |  |  | vo.setMatnr(waitMatin.getMatnr()); | 
|---|
|  |  |  | vo.setMatName(waitMatin.getMaktx()); | 
|---|
|  |  |  | vo.setQty(waitMatin.getAnfme()); | 
|---|
|  |  |  | vo.setQty(waitMatin.getAnfme() - waitMatin.getWorkQty()); | 
|---|
|  |  |  | vo.setCount(waitMatin.getAnfme() - waitMatin.getWorkQty()); | 
|---|
|  |  |  | vo.setBillNo(waitMatin.getOrderNo()); | 
|---|
|  |  |  | vo.setSeqNo(waitMatin.getINo()); | 
|---|
|  |  |  | 
|---|
|  |  |  | vo.setSize(waitMatin.getModel()); | 
|---|
|  |  |  | vo.setColor(waitMatin.getColor()); | 
|---|
|  |  |  | vo.setItemBatch(waitMatin.getBatch()); | 
|---|
|  |  |  | vo.setLuHao(waitMatin.getLuHao()); | 
|---|
|  |  |  | vo.setOutOrderNo(waitMatin.getOutOrderNo()); | 
|---|
|  |  |  | vo.setSPgNO(waitMatin.getSPgNO()); | 
|---|
|  |  |  | vo.setProType(waitMatin.getProType()); | 
|---|
|  |  |  | vo.setPacking(waitMatin.getPacking()); | 
|---|
|  |  |  | //vo.setOveFlag(waitMatin.getOveFlag()); | 
|---|
|  |  |  | vos.add(vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok().add(vos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //------------------------------------------------------------------------------------------------------------------------------------------------并板功能新增--------------------------------------------------------------------------------------------- | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 新增拣料途中并板功能 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/barcode/list/pick") | 
|---|
|  |  |  | @ManagerAuth(memo = "拣料入库途中并板") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R orderOutListOrderPick(@RequestBody String barcode) { | 
|---|
|  |  |  | ArrayList<WrkMast> wrkMastArrayList = new ArrayList<>(); | 
|---|
|  |  |  | if (Cools.isEmpty(barcode) || barcode.isEmpty()) { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("wrk_sts", 14L) | 
|---|
|  |  |  | .eq("io_type", 103)); | 
|---|
|  |  |  | wrkMastArrayList.addAll(wrkMasts); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .like("barcode", barcode) | 
|---|
|  |  |  | .eq("wrk_sts", 14L) | 
|---|
|  |  |  | .eq("io_type", 103)); | 
|---|
|  |  |  | wrkMastArrayList.addAll(wrkMasts); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok().add(wrkMastArrayList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/pick/mat/list") | 
|---|
|  |  |  | @ManagerAuth(memo = "获取并板物料") | 
|---|
|  |  |  | public R pickMats(@RequestParam(required = false) String matnr, @RequestParam(required = false) String orderNo) { | 
|---|
|  |  |  | List<DocType> docTypes = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakin", 1)); | 
|---|
|  |  |  | ArrayList<Long> typeList = new ArrayList<>(); | 
|---|
|  |  |  | for (DocType docType : docTypes) { | 
|---|
|  |  |  | typeList.add(docType.getDocId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | EntityWrapper<Order> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper.eq("status", 1); | 
|---|
|  |  |  | wrapper.in("doc_type", typeList); | 
|---|
|  |  |  | List<Order> orders = orderService.selectList(wrapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ArrayList<Long> orderIds = new ArrayList<>(); | 
|---|
|  |  |  | for (Order order : orders) { | 
|---|
|  |  |  | orderIds.add(order.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //搜索明细 | 
|---|
|  |  |  | EntityWrapper<OrderDetl> wrapper1 = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper1.eq("status", 1); | 
|---|
|  |  |  | wrapper1.in("order_id", orderIds); | 
|---|
|  |  |  | wrapper1.orderBy("create_time", false); | 
|---|
|  |  |  | if (!Cools.isEmpty(matnr)) { | 
|---|
|  |  |  | wrapper1.like("matnr", matnr); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(orderNo)) { | 
|---|
|  |  |  | wrapper1.like("order_no", orderNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<OrderDetl> list = orderDetlService.selectList(wrapper1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ArrayList<PickMatParam> maps = new ArrayList<>(); | 
|---|
|  |  |  | for (OrderDetl orderDetl : list) { | 
|---|
|  |  |  | //剩余可用数量 | 
|---|
|  |  |  | double count = orderDetl.getAnfme() - orderDetl.getWorkQty(); | 
|---|
|  |  |  | if (count <= 0) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PickMatParam matParam = new PickMatParam(); | 
|---|
|  |  |  | matParam.setMatnr(orderDetl.getMatnr()); | 
|---|
|  |  |  | matParam.setMaktx(orderDetl.getMaktx()); | 
|---|
|  |  |  | matParam.setBatch(orderDetl.getBatch()); | 
|---|
|  |  |  | matParam.setOrderNo(orderDetl.getOrderNo()); | 
|---|
|  |  |  | matParam.setOrderId(orderDetl.getOrderId()); | 
|---|
|  |  |  | matParam.setCount(count); | 
|---|
|  |  |  | matParam.setUseCount(count); | 
|---|
|  |  |  | ////"outOrderNo", "luHao", "packing", "sPgNO", "proType","color"}; | 
|---|
|  |  |  | matParam.setOutOrderNo(orderDetl.getOutOrderNo()); | 
|---|
|  |  |  | matParam.setLuHao(orderDetl.getLuHao()); | 
|---|
|  |  |  | matParam.setPacking(orderDetl.getPacking()); | 
|---|
|  |  |  | matParam.setProType(orderDetl.getProType()); | 
|---|
|  |  |  | matParam.setSPgNO(orderDetl.getSPgNO()); | 
|---|
|  |  |  | matParam.setColor(orderDetl.getColor()); | 
|---|
|  |  |  | maps.add(matParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(maps); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/order/list/orderNo") | 
|---|
|  |  |  | public R orderListorderNo(@RequestParam String orderNo) { | 
|---|
|  |  |  | //数量修改成为完成数量 | 
|---|
|  |  |  | List<OrderDetl> orderDetl1 = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("orderNo", orderNo)); | 
|---|
|  |  |  | List<OrderDetl> orderDetls = new ArrayList<OrderDetl>(); | 
|---|
|  |  |  | for (OrderDetl o : orderDetl1) { | 
|---|
|  |  |  | BigDecimal c1 = new BigDecimal(o.getEnableQty()).setScale(2, BigDecimal.ROUND_HALF_UP); | 
|---|
|  |  |  | o.setAnfme(c1.doubleValue()); | 
|---|
|  |  |  | if (o.getAnfme().equals(0.0)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderDetls.add(o); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(orderDetls); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/order/list/all") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R orderList() { | 
|---|
|  |  |  | return R.ok(orderService.selectAllorderNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/orderDetl/forOrderNo/mergePakin/v1") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R forOrderNoMergePakinV1(@RequestParam String orderNo) { | 
|---|
|  |  |  | List<DocType> docTypes = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakin", 1)); | 
|---|
|  |  |  | ArrayList<Long> docTypeIds = new ArrayList<>(); | 
|---|
|  |  |  | for (DocType docType : docTypes) { | 
|---|
|  |  |  | docTypeIds.add(docType.getDocId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (docTypeIds.isEmpty()) { | 
|---|
|  |  |  | return R.error("单据类型不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Order> orders = orderService.selectList(new EntityWrapper<Order>().in("doc_type", docTypeIds).in("settle", 0, 1, 2)); | 
|---|
|  |  |  | if (orders.isEmpty()) { | 
|---|
|  |  |  | return R.error("未查询到订单"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ArrayList<Long> orderIds = new ArrayList<>(); | 
|---|
|  |  |  | for (Order order : orders) { | 
|---|
|  |  |  | orderIds.add(order.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<OrderDetl> orderDetlList = orderDetlService.selectList(new EntityWrapper<OrderDetl>() | 
|---|
|  |  |  | .in("order_id", orderIds) | 
|---|
|  |  |  | .like("order_no", orderNo) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if (Cools.isEmpty(orderDetlList)) { | 
|---|
|  |  |  | return R.error("未查询到此订单此物料数据"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ArrayList<OrderDetl> orderDetls = new ArrayList<>(); | 
|---|
|  |  |  | for (OrderDetl orderDetl : orderDetlList) { | 
|---|
|  |  |  | double count = orderDetl.getAnfme() - orderDetl.getWorkQty(); | 
|---|
|  |  |  | if (count <= 0D) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderDetl.setAnfme(count); | 
|---|
|  |  |  | orderDetls.add(orderDetl); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(orderDetls); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 拣料途中并板 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/pda/WarehouseOutPickMerge/v1") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R WarehouseOutPickMergeV1(@RequestBody WarehouseOutPickMergeParam param) { | 
|---|
|  |  |  | return mobileService.WarehouseOutPickMergeV1(param, getUserId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|