|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.wms.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.sun.org.apache.xpath.internal.operations.Or; | 
|---|
|  |  |  | import com.zy.asrs.common.domain.dto.LocDetlDto; | 
|---|
|  |  |  | import com.zy.asrs.common.domain.dto.WrkDto; | 
|---|
|  |  |  | import com.zy.asrs.common.domain.entity.MobileAdjustResult; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.common.domain.param.PickConfirmParam; | 
|---|
|  |  |  | import com.zy.asrs.common.domain.param.PickMatParam; | 
|---|
|  |  |  | import com.zy.asrs.common.openapi.entity.param.CombParam; | 
|---|
|  |  |  | import com.zy.asrs.common.openapi.entity.param.WarehouseOutMergeBoardManyParam; | 
|---|
|  |  |  | import com.zy.asrs.common.openapi.entity.param.WarehouseOutPickMergeParam; | 
|---|
|  |  |  | import com.zy.asrs.common.sys.service.StaDescService; | 
|---|
|  |  |  | import com.zy.asrs.common.web.BaseController; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.entity.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.framework.exception.CoolException; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | 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.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatService matService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 平庫上架 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param locNo | 
|---|
|  |  |  | * @param barcode | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/pda/WarehouseIn") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R WarehouseIn(@RequestParam String locNo,@RequestParam String barcode){ | 
|---|
|  |  |  | return mobileService.WarehouseIn(locNo,barcode,getHostId()); | 
|---|
|  |  |  | public R WarehouseIn(@RequestParam String locNo, @RequestParam String barcode) { | 
|---|
|  |  |  | return mobileService.WarehouseIn(locNo, barcode, getHostId(), getUserId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 平庫下架 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param combParam | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/pda/WarehouseOut") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R WarehouseOut(@RequestBody CombParam combParam){ | 
|---|
|  |  |  | return mobileService.WarehouseOut(combParam,getHostId()); | 
|---|
|  |  |  | public R WarehouseOut(@RequestBody CombParam combParam) { | 
|---|
|  |  |  | return mobileService.WarehouseOut(combParam, getHostId(), getUserId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/outBound/mat/list") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R WarehouseMat(@RequestParam String matnr, @RequestParam String orderNo) { | 
|---|
|  |  |  | if (Cools.isEmpty(matnr)) { | 
|---|
|  |  |  | R.error("品号不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ArrayList<PickMatParam> maps = new ArrayList<>(); | 
|---|
|  |  |  | if (Cools.isEmpty(orderNo)) { | 
|---|
|  |  |  | List<OrderDetl> list = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>() | 
|---|
|  |  |  | .eq(OrderDetl::getMatnr, matnr) | 
|---|
|  |  |  | .orderByDesc(OrderDetl::getCreateTime)); | 
|---|
|  |  |  | List<OrderDetl> orderDetls = new ArrayList<OrderDetl>(); | 
|---|
|  |  |  | for (OrderDetl orderDetl : list | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, orderDetl.getOrderNo())); | 
|---|
|  |  |  | if (!Cools.isEmpty(order)) { | 
|---|
|  |  |  | DocType docType = docTypeService.getOne(new LambdaQueryWrapper<DocType>().eq(DocType::getDocId, order.getDocType())); | 
|---|
|  |  |  | if (!Cools.isEmpty(docType) && docType.getPakout() == 1) { | 
|---|
|  |  |  | double count = orderDetl.getAnfme() - orderDetl.getWorkQty(); | 
|---|
|  |  |  | PickMatParam matParam = new PickMatParam(); | 
|---|
|  |  |  | matParam.setMatnr(orderDetl.getMatnr()); | 
|---|
|  |  |  | matParam.setBatch(orderDetl.getBatch()); | 
|---|
|  |  |  | matParam.setOrderNo(orderDetl.getOrderNo()); | 
|---|
|  |  |  | matParam.setOrderId(orderDetl.getOrderId()); | 
|---|
|  |  |  | matParam.setCount(count); | 
|---|
|  |  |  | matParam.setUseCount(count); | 
|---|
|  |  |  | maps.add(matParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(maps); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | List<OrderDetl> list = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>() | 
|---|
|  |  |  | .eq(OrderDetl::getMatnr, matnr) | 
|---|
|  |  |  | .like(OrderDetl::getOrderNo, orderNo) | 
|---|
|  |  |  | .orderByDesc(OrderDetl::getCreateTime)); | 
|---|
|  |  |  | for (OrderDetl orderDetl : list | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | double count = orderDetl.getAnfme() - orderDetl.getWorkQty(); | 
|---|
|  |  |  | PickMatParam matParam = new PickMatParam(); | 
|---|
|  |  |  | matParam.setMatnr(orderDetl.getMatnr()); | 
|---|
|  |  |  | matParam.setBatch(orderDetl.getBatch()); | 
|---|
|  |  |  | matParam.setOrderNo(orderDetl.getOrderNo()); | 
|---|
|  |  |  | matParam.setOrderId(orderDetl.getOrderId()); | 
|---|
|  |  |  | matParam.setCount(count); | 
|---|
|  |  |  | matParam.setUseCount(count); | 
|---|
|  |  |  | maps.add(matParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(maps); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 并板途中拣料 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param combParam | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/pda/WarehouseOut/v1") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R WarehouseOutV1(@RequestBody CombParam combParam) { | 
|---|
|  |  |  | return mobileService.WarehouseOutV1(combParam, getHostId(), getUserId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 拣料途中并板 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/pda/WarehouseOutPickMerge/v1") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R WarehouseOutPickMergeV1(@RequestBody WarehouseOutPickMergeParam param) { | 
|---|
|  |  |  | return mobileService.WarehouseOutPickMergeV1(param, getHostId(), getUserId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 多次并板 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/pda/WarehouseOutMergeBoardMany/v1") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R WarehouseOutMergeBoardManyV1(@RequestBody WarehouseOutMergeBoardManyParam param) { | 
|---|
|  |  |  | return mobileService.WarehouseOutMergeBoardMany(param, getHostId(), getUserId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/menu/pda/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R menuPda(){ | 
|---|
|  |  |  | public R menuPda() { | 
|---|
|  |  |  | List<RolePermission> rolePermissions; | 
|---|
|  |  |  | Long roleId = getUser().getRoleId(); | 
|---|
|  |  |  | rolePermissions = rolePermissionService.list(new LambdaQueryWrapper<RolePermission>().eq(RolePermission::getRoleId, getHostId())); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 入库制令检测  -- 指令在库存里面借用批号字段batch | 
|---|
|  |  |  | * 1.可正常入库 | 
|---|
|  |  |  | * 2.库存包含相同制令货物,是否进行补货 | 
|---|
|  |  |  | * 3.工作档存在正在入库任务,拒绝入库 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/pda/decrees/check") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R pdaDecreesCheck(@RequestParam String decrees) { | 
|---|
|  |  |  | if (Cools.isEmpty(decrees)) { | 
|---|
|  |  |  | return R.error("制令不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Long hostId = getHostId(); | 
|---|
|  |  |  | //查询是否有库存 | 
|---|
|  |  |  | List<LocDetl> list = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getBatch, decrees)); | 
|---|
|  |  |  | //查询是否有正在工作的工作档 | 
|---|
|  |  |  | List<WrkDetl> wrkDetls = wrkDetlService.list(new LambdaQueryWrapper<WrkDetl>().eq(WrkDetl::getBatch, decrees)); | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | if (list.isEmpty() && wrkDetls.isEmpty()) { | 
|---|
|  |  |  | map.put("status", 1);//可正常入库 | 
|---|
|  |  |  | } else if (!wrkDetls.isEmpty()) { | 
|---|
|  |  |  | map.put("status", 3);//存在工作档,拒绝入库 | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //获取库存最少的一条记录 | 
|---|
|  |  |  | Double anfme = 999999999D; | 
|---|
|  |  |  | LocDetl miniLocDetl = null; | 
|---|
|  |  |  | for (LocDetl locDetl : list) { | 
|---|
|  |  |  | if (locDetl.getAnfme() < anfme) { | 
|---|
|  |  |  | anfme = locDetl.getAnfme(); | 
|---|
|  |  |  | miniLocDetl = locDetl; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | map.put("status", 2);//库存包含相同制令货物,是否进行补货 | 
|---|
|  |  |  | map.put("data", miniLocDetl);//库存信息 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据单号检索单据数据 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/order/search/orderNo/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R orderSearchByBarcode(@RequestParam String orderNo){ | 
|---|
|  |  |  | public R orderSearchByBarcode(@RequestParam String orderNo) { | 
|---|
|  |  |  | Order order = orderService.selectByNo(orderNo, getHostId()); | 
|---|
|  |  |  | if (order == null) { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/comb/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "组托") | 
|---|
|  |  |  | public R comb(@RequestBody CombParam combParam){ | 
|---|
|  |  |  | public R comb(@RequestBody CombParam combParam) { | 
|---|
|  |  |  | mobileService.comb(combParam, getUserId(), getHostId()); | 
|---|
|  |  |  | return R.ok("组托成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/adjust/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "盘点") | 
|---|
|  |  |  | public R adjust(@RequestBody MobileAdjustParam combParam){ | 
|---|
|  |  |  | public R adjust(@RequestBody MobileAdjustParam combParam) { | 
|---|
|  |  |  | mobileService.adjust(combParam, getUserId(), getHostId()); | 
|---|
|  |  |  | return R.ok("盘点成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/loc/f/list") | 
|---|
|  |  |  | @ManagerAuth(memo = "获取在库库位") | 
|---|
|  |  |  | public R locNoF(@RequestParam(required = false) String locNo){ | 
|---|
|  |  |  | public R locNoF(@RequestParam(required = false) String locNo) { | 
|---|
|  |  |  | LambdaQueryWrapper<LocMast> wrapper = new LambdaQueryWrapper<LocMast>() | 
|---|
|  |  |  | .eq(LocMast::getLocSts, "F") | 
|---|
|  |  |  | .eq(LocMast::getHostId, getHostId()); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/pick/sta/list") | 
|---|
|  |  |  | @ManagerAuth(memo = "获取并板站") | 
|---|
|  |  |  | public R pickSta(){ | 
|---|
|  |  |  | public R pickSta() { | 
|---|
|  |  |  | List<StaDesc> list = staDescService.list(new LambdaQueryWrapper<StaDesc>() | 
|---|
|  |  |  | .eq(StaDesc::getTypeNo, 104) | 
|---|
|  |  |  | .eq(StaDesc::getHostId, getHostId())); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/pick/mat/list") | 
|---|
|  |  |  | @ManagerAuth(memo = "获取并板物料") | 
|---|
|  |  |  | public R pickMats(@RequestParam(required = false) String matnr){ | 
|---|
|  |  |  | List<DocType> docTypes = docTypeService.list(new LambdaQueryWrapper<DocType>().like(DocType::getDocName, "入库")); | 
|---|
|  |  |  | public R pickMats(@RequestParam(required = false) String matnr, @RequestParam(required = false) String orderNo) { | 
|---|
|  |  |  | List<DocType> docTypes = docTypeService.list(new LambdaQueryWrapper<DocType>().like(DocType::getPakin, 1)); | 
|---|
|  |  |  | ArrayList<Long> typeList = new ArrayList<>(); | 
|---|
|  |  |  | for (DocType docType : docTypes) { | 
|---|
|  |  |  | typeList.add(docType.getDocId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LambdaQueryWrapper<Order> wrapper = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | wrapper.eq(Order::getStatus, 1); | 
|---|
|  |  |  | wrapper.eq(Order::getHostId, getHostId()); | 
|---|
|  |  |  | wrapper.in(Order::getDocType, typeList); | 
|---|
|  |  |  | List<Order> orders = orderService.list(wrapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ArrayList<Long> orderIds = new ArrayList<>(); | 
|---|
|  |  |  | for (Order order : orders) { | 
|---|
|  |  |  | orderIds.add(order.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //搜索明细 | 
|---|
|  |  |  | LambdaQueryWrapper<OrderDetl> wrapper1 = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | wrapper1.eq(OrderDetl::getStatus, 1); | 
|---|
|  |  |  | wrapper1.eq(OrderDetl::getHostId, getHostId()); | 
|---|
|  |  |  | wrapper1.in(OrderDetl::getOrderId, orderIds); | 
|---|
|  |  |  | wrapper1.orderByDesc(OrderDetl::getCreateTime); | 
|---|
|  |  |  | if (!Cools.isEmpty(matnr)) { | 
|---|
|  |  |  | wrapper1.like(OrderDetl::getMatnr, matnr); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(orderNo)) { | 
|---|
|  |  |  | wrapper1.like(OrderDetl::getOrderNo, orderNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<OrderDetl> list = orderDetlService.list(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.setBatch(orderDetl.getBatch()); | 
|---|
|  |  |  | matParam.setOrderNo(orderDetl.getOrderNo()); | 
|---|
|  |  |  | matParam.setOrderId(orderDetl.getOrderId()); | 
|---|
|  |  |  | matParam.setCount(count); | 
|---|
|  |  |  | matParam.setUseCount(count); | 
|---|
|  |  |  | maps.add(matParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(maps); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/outBound/order/list") | 
|---|
|  |  |  | @ManagerAuth(memo = "获取出库订单") | 
|---|
|  |  |  | public R outBound(@RequestParam(required = false) String matnr, @RequestParam(required = false) String orderNo) { | 
|---|
|  |  |  | List<DocType> docTypes = docTypeService.list(new LambdaQueryWrapper<DocType>().like(DocType::getPakout, 1)); | 
|---|
|  |  |  | ArrayList<Long> typeList = new ArrayList<>(); | 
|---|
|  |  |  | for (DocType docType : docTypes) { | 
|---|
|  |  |  | typeList.add(docType.getDocId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | matParam.setOrderNo(orderDetl.getOrderNo()); | 
|---|
|  |  |  | matParam.setOrderId(orderDetl.getOrderId()); | 
|---|
|  |  |  | matParam.setCount(count); | 
|---|
|  |  |  | matParam.setUseCount(0D); | 
|---|
|  |  |  | matParam.setUseCount(count); | 
|---|
|  |  |  | maps.add(matParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(maps); | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping("/pick/in") | 
|---|
|  |  |  | @ManagerAuth(memo = "并板入库") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R pickConfirm(@RequestBody PickConfirmParam param){ | 
|---|
|  |  |  | public R pickConfirm(@RequestBody PickConfirmParam param) { | 
|---|
|  |  |  | LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>() | 
|---|
|  |  |  | .eq(LocMast::getLocNo, param.getLocNo()) | 
|---|
|  |  |  | .eq(LocMast::getHostId, getHostId())); | 
|---|
|  |  |  | 
|---|
|  |  |  | wrkDetl.setModiUser(getUserId()); | 
|---|
|  |  |  | wrkDetl.setHostId(getHostId()); | 
|---|
|  |  |  | wrkDetl.setWrkMastId(wrkMast.getId()); | 
|---|
|  |  |  | wrkDetl.setZpallet(wrkMast.getBarcode()); | 
|---|
|  |  |  | if (!wrkDetlService.save(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Order order = orderService.selectByNo(matParam.getOrderNo(), getHostId()); | 
|---|
|  |  |  | if (order == null) { | 
|---|
|  |  |  | throw new CoolException("Order is not exits"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //更新订单工作数量 | 
|---|
|  |  |  | orderDetlService.increaseWorkQtyByOrderNo(matParam.getOrderNo(), matParam.getMatnr(), matParam.getBatch(), matParam.getUseCount(), getHostId()); | 
|---|
|  |  |  | orderService.updateSettle(order.getId(), 2L, getUserId(), getHostId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改库位状态:   F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 | 
|---|
|  |  |  | locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, param.getLocNo()).eq(LocMast::getHostId, getHostId())); | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/barcode/list/all") | 
|---|
|  |  |  | @ManagerAuth(memo = "并板入库途中拣料出库获取任务信息") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R orderOutListOrder(@RequestBody String barcode) { | 
|---|
|  |  |  | ArrayList<WrkMast> wrkMastArrayList = new ArrayList<>(); | 
|---|
|  |  |  | if (Cools.isEmpty(barcode) || barcode.isEmpty()) { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.list(new LambdaQueryWrapper<WrkMast>() | 
|---|
|  |  |  | .eq(WrkMast::getHostId, getHostId()) | 
|---|
|  |  |  | .eq(WrkMast::getWrkSts, 199L) | 
|---|
|  |  |  | .eq(WrkMast::getIoType, 104)); | 
|---|
|  |  |  | wrkMastArrayList.addAll(wrkMasts); | 
|---|
|  |  |  | List<WrkMast> wrkMasts1 = wrkMastService.list(new LambdaQueryWrapper<WrkMast>() | 
|---|
|  |  |  | .eq(WrkMast::getHostId, getHostId()) | 
|---|
|  |  |  | .eq(WrkMast::getWrkSts, 199L) | 
|---|
|  |  |  | .eq(WrkMast::getIoType, 107)); | 
|---|
|  |  |  | wrkMastArrayList.addAll(wrkMasts1); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.list(new LambdaQueryWrapper<WrkMast>() | 
|---|
|  |  |  | .like(WrkMast::getBarcode, barcode) | 
|---|
|  |  |  | .eq(WrkMast::getHostId, getHostId()) | 
|---|
|  |  |  | .eq(WrkMast::getWrkSts, 199L) | 
|---|
|  |  |  | .eq(WrkMast::getIoType, 104)); | 
|---|
|  |  |  | wrkMastArrayList.addAll(wrkMasts); | 
|---|
|  |  |  | List<WrkMast> wrkMasts1 = wrkMastService.list(new LambdaQueryWrapper<WrkMast>() | 
|---|
|  |  |  | .like(WrkMast::getBarcode, barcode) | 
|---|
|  |  |  | .eq(WrkMast::getHostId, getHostId()) | 
|---|
|  |  |  | .eq(WrkMast::getWrkSts, 199L) | 
|---|
|  |  |  | .eq(WrkMast::getIoType, 107)); | 
|---|
|  |  |  | wrkMastArrayList.addAll(wrkMasts1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok().add(wrkMastArrayList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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.list(new LambdaQueryWrapper<WrkMast>() | 
|---|
|  |  |  | .eq(WrkMast::getHostId, getHostId()) | 
|---|
|  |  |  | .eq(WrkMast::getWrkSts, 199L) | 
|---|
|  |  |  | .eq(WrkMast::getIoType, 103)); | 
|---|
|  |  |  | wrkMastArrayList.addAll(wrkMasts); | 
|---|
|  |  |  | List<WrkMast> wrkMasts1 = wrkMastService.list(new LambdaQueryWrapper<WrkMast>() | 
|---|
|  |  |  | .eq(WrkMast::getHostId, getHostId()) | 
|---|
|  |  |  | .eq(WrkMast::getWrkSts, 199L) | 
|---|
|  |  |  | .eq(WrkMast::getIoType, 107)); | 
|---|
|  |  |  | wrkMastArrayList.addAll(wrkMasts1); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.list(new LambdaQueryWrapper<WrkMast>() | 
|---|
|  |  |  | .like(WrkMast::getBarcode, barcode) | 
|---|
|  |  |  | .eq(WrkMast::getHostId, getHostId()) | 
|---|
|  |  |  | .eq(WrkMast::getWrkSts, 199L) | 
|---|
|  |  |  | .eq(WrkMast::getIoType, 103) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | wrkMastArrayList.addAll(wrkMasts); | 
|---|
|  |  |  | List<WrkMast> wrkMasts1 = wrkMastService.list(new LambdaQueryWrapper<WrkMast>() | 
|---|
|  |  |  | .like(WrkMast::getBarcode, barcode) | 
|---|
|  |  |  | .eq(WrkMast::getHostId, getHostId()) | 
|---|
|  |  |  | .eq(WrkMast::getWrkSts, 199L) | 
|---|
|  |  |  | .eq(WrkMast::getIoType, 107)); | 
|---|
|  |  |  | wrkMastArrayList.addAll(wrkMasts1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok().add(wrkMastArrayList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/pda/OutLocNo") | 
|---|
|  |  |  | @ManagerAuth(memo = "获得平库出库的对应库位号") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R OutLocNo(@RequestParam Long orderId) { | 
|---|
|  |  |  | List<OrderDetl> orderDetls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>() | 
|---|
|  |  |  | .eq(OrderDetl::getOrderId, orderId) | 
|---|
|  |  |  | .eq(OrderDetl::getHostId, getHostId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if (Cools.isEmpty(orderDetls)) { | 
|---|
|  |  |  | return R.error("订单明细不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> list = new ArrayList<>(); | 
|---|
|  |  |  | for (OrderDetl o : orderDetls | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | if (o.getAnfme() <= o.getWorkQty()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //查看库位明细中有的物料 | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>() | 
|---|
|  |  |  | .eq(LocDetl::getMatnr, o.getMatnr()).eq(LocDetl::getHostId, getHostId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if (Cools.isEmpty(locDetls)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | for (LocDetl l : locDetls | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | String s = l.getLocNo().substring(1, 2); | 
|---|
|  |  |  | if (Integer.valueOf(s) > 4) { | 
|---|
|  |  |  | list.add(l.getLocNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> myList = list.stream().distinct().collect(Collectors.toList()); | 
|---|
|  |  |  | return R.ok(myList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/pda/OrderDetlContrastLocDetl") | 
|---|
|  |  |  | @ManagerAuth(memo = "获得订单明细对应的库存明细") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R OrderDetlContrastLocDetl(@RequestParam Long orderId, @RequestParam String locNo) { | 
|---|
|  |  |  | List<LocDetl> locDetlList = new ArrayList<LocDetl>(); | 
|---|
|  |  |  | List<OrderDetl> orderDetls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>() | 
|---|
|  |  |  | .eq(OrderDetl::getOrderId, orderId) | 
|---|
|  |  |  | .eq(OrderDetl::getHostId, getHostId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if (Cools.isEmpty(orderDetls)) { | 
|---|
|  |  |  | return R.error("订单明细不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>() | 
|---|
|  |  |  | .eq(LocDetl::getLocNo, locNo)); | 
|---|
|  |  |  | if (Cools.isEmpty(locDetls)) { | 
|---|
|  |  |  | return R.error("库位为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (OrderDetl o : orderDetls | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | if(o.getAnfme().equals(o.getQty())){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (LocDetl l : locDetls | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | if (o.getMatnr().equals(l.getMatnr())) { | 
|---|
|  |  |  | if (o.getAnfme() - o.getWorkQty() >= l.getAnfme()) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | l.setAnfme(o.getAnfme() - o.getWorkQty()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locDetlList.add(l); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(locDetlList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/pda/OutOrder") | 
|---|
|  |  |  | @ManagerAuth(memo = "获得出库单") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R OutOrder(@RequestParam String orderNo) { | 
|---|
|  |  |  | List<Order> orders=new ArrayList<Order>(); | 
|---|
|  |  |  | List<Order> OrderList=new ArrayList<Order>(); | 
|---|
|  |  |  | if(Cools.isEmpty(orderNo)){ | 
|---|
|  |  |  | orders= orderService.list(new LambdaQueryWrapper<Order>() | 
|---|
|  |  |  | .between(Order::getSettle,1,2) | 
|---|
|  |  |  | .eq(Order::getHostId, getHostId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders= orderService.list(new LambdaQueryWrapper<Order>() | 
|---|
|  |  |  | .like(Order::getOrderNo, orderNo) | 
|---|
|  |  |  | .between(Order::getSettle,1,2) | 
|---|
|  |  |  | .eq(Order::getHostId, getHostId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Cools.isEmpty(orders)){ | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (Order o:orders | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | DocType docType=docTypeService.getOne(new LambdaQueryWrapper<DocType>() | 
|---|
|  |  |  | .eq(DocType::getDocId,o.getDocType())); | 
|---|
|  |  |  | if(docType.getPakout()==1){ | 
|---|
|  |  |  | OrderList.add(o); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(OrderList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|