| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.annotations.AppAuth; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | 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.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | 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.zy.asrs.entity.param.MobileAdjustParam; |
| | | import com.zy.asrs.entity.param.Review; |
| | | import com.zy.asrs.entity.result.MobileAdjustResult; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.handler.WorkLogHandler; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.model.LocDto; |
| | | import com.zy.common.model.TaskDto; |
| | | import com.zy.common.model.WrkDto; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.common.web.param.SearchLocParam; |
| | | 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.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 移动端接口控制器 |
| | |
| | | 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; |
| | | |
| | | |
| | | // 商品上架 |
| | | @RequestMapping("/mat/onSale/auth") |
| | | //@ManagerAuth |
| | | public R matOnSale(@RequestBody CombParam combParam){ |
| | | mobileService.onSale(combParam); |
| | | return R.ok("上架成功"); |
| | | } |
| | | // 商品下架 |
| | | |
| | | // 组托 ---------------------------------------------------------------------------------------------------- |
| | | |
| | | /** |
| | | * 根据单号检索单据数据 |
| | | * http://localhost:8081/jkwms/mobile/order/serach/orderNo/auth?orderNo=123123 |
| | | */ |
| | | @RequestMapping("/order/serach/orderNo/auth") |
| | | @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(orderNo); |
| | | List<OrderDetl> orderDetls = orderService.selectWorkingDetls(order.getId()); |
| | | if (Cools.isEmpty(orderDetls)) { |
| | | return R.ok(); |
| | | } |
| | | return R.ok().add(orderDetls); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 组托 |
| | | */ |
| | | @RequestMapping("/comb/auth") |
| | | @ManagerAuth(memo = "组托") |
| | | public R comb(@RequestBody CombParam combParam){ |
| | | 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(); |
| | | } |
| | | |
| | | /** |
| | | * 根据库位号查找库存明细 |
| | | * 出库确认 - 拣料出库 - 选择具体条码商品 |
| | | */ |
| | | @RequestMapping("/locDetl") |
| | | @RequestMapping("/pakout/confirm/pick/auth") |
| | | @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); |
| | | 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(); |
| | | } |
| | | 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 ((wrkDetl.getMatnr() + "-" + wrkDetl.getBatch()).equals(matnr)) { |
| | | return R.ok().add(wrkDetl); |
| | | } |
| | | } |
| | | 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); |
| | | // 替换 明细 |
| | | 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.parse(BaseRes.PARAM); |
| | | 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("/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("出库成功"); |
| | | } |
| | | |
| | | |
| | | /*...........................赣州新增..............以下.............赣州新增...........................*/ |
| | | // @PostMapping("/test/startUp/auth") |
| | | // @ManagerAuth(memo = "申请PACK测试") |
| | | // public synchronized R startUpTestPACK(@RequestBody TestMast testMast) { |
| | | // if (Cools.isEmpty(testMast)) { |
| | | // return R.parse(BaseRes.PARAM); |
| | | // } |
| | | // mobileService.startUpTestPACK(testMast); //提交测试系统 |
| | | // return R.ok(); |
| | | // } |
| | | |
| | | @PostMapping("/test/suspend/auth") |
| | | // @ManagerAuth(memo = "暂停测试") |
| | | @ResponseBody |
| | | public synchronized R suspendTestPACK(@RequestBody SearchLocParam param) { |
| | | if (mobileService.suspendTestPACK(param.getBarcode())){ //请求暂停测试 |
| | | return R.ok(); |
| | | }else { |
| | | return R.error("暂停失败"); |
| | | } |
| | | } |
| | | /** |
| | | * 测试库基本信息 |
| | | */ |
| | | @RequestMapping("/pack/basic/information") |
| | | // @ManagerAuth(memo = "测试库基本信息") |
| | | public R packTestBasicInformation(){ |
| | | return R.ok().add(mobileService.packTestBasicInformation()); |
| | | } |
| | | /** |
| | | * 测试库使用情况 |
| | | */ |
| | | @RequestMapping("/pack/usage/rate") |
| | | // @ManagerAuth(memo = "测试库使用情况") |
| | | public R packUsageRate(){ |
| | | return R.ok().add(mobileService.packUsageRate()); |
| | | } |
| | | /** |
| | | * 测试库合格数 |
| | | */ |
| | | @RequestMapping("/pack/qualified") |
| | | // @ManagerAuth(memo = "测试库合格数") |
| | | public R packQualified(){ |
| | | return R.ok().add(mobileService.packQualified()); |
| | | } |
| | | /** |
| | | * 早8-晚20 |
| | | */ |
| | | @RequestMapping("/pack/morning") |
| | | // @ManagerAuth(memo = "测试库合格数") |
| | | public R chartAxisMorning(){ |
| | | return R.ok().add(mobileService.chartAxisMorning()); |
| | | } |
| | | /** |
| | | * 晚20-第二天早8 |
| | | */ |
| | | @RequestMapping("/pack/evening") |
| | | // @ManagerAuth(memo = "测试库合格数") |
| | | public R chartAxisEvening(){ |
| | | return R.ok().add(mobileService.chartAxisEvening()); |
| | | } |
| | | |
| | | @RequestMapping("/pack/morning/v2") |
| | | // @ManagerAuth(memo = "测试库合格数") |
| | | public R chartAxisMorningV2(){ |
| | | Map<String,Object> map=new HashMap<String, Object>(); |
| | | List<AxisBean> list = new ArrayList<AxisBean>(); |
| | | |
| | | List<WorkChartAxis> listChart = mobileService.chartAxisMorning(); |
| | | |
| | | if(listChart!=null) { |
| | | ArrayList<Integer> data1 = new ArrayList<Integer>(); |
| | | ArrayList<Integer> data2 = new ArrayList<Integer>(); |
| | | |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.DATE, -12); |
| | | for(int i=0;i<12;i++) { |
| | | boolean flag = true; |
| | | calendar.add(Calendar.DATE, 1); |
| | | String str = sf.format(calendar.getTime()); |
| | | for(WorkChartAxis workChart : listChart) { |
| | | if(str.equals(workChart.getYmd())) { |
| | | data1.add(workChart.getInqty()); |
| | | data2.add(workChart.getOutqty()); |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | if(flag) { |
| | | data1.add(0); |
| | | data2.add(0); |
| | | } |
| | | } |
| | | AxisBean inqty = new AxisBean(); |
| | | inqty.setName("入库数量"); |
| | | Integer[] array1 = new Integer[data1.size()]; |
| | | inqty.setData(data1.toArray(array1)); |
| | | list.add(inqty); |
| | | AxisBean outqty = new AxisBean(); |
| | | outqty.setName("出库数量"); |
| | | Integer[] array2 = new Integer[data2.size()]; |
| | | outqty.setData(data2.toArray(array2)); |
| | | list.add(outqty); |
| | | } |
| | | map.put("rows",list); |
| | | return R.ok(map); |
| | | } |
| | | /** |
| | | * 晚20-第二天早8 |
| | | */ |
| | | @RequestMapping("/pack/evening/v2") |
| | | // @ManagerAuth(memo = "测试库合格数") |
| | | public R chartAxisEveningV2(){ |
| | | Map<String,Object> map=new HashMap<String, Object>(); |
| | | List<AxisBean> list = new ArrayList<AxisBean>(); |
| | | |
| | | List<WorkChartAxis> listChart = mobileService.chartAxisEvening(); |
| | | |
| | | if(listChart!=null) { |
| | | ArrayList<Integer> data1 = new ArrayList<Integer>(); |
| | | ArrayList<Integer> data2 = new ArrayList<Integer>(); |
| | | |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.DATE, -12); |
| | | for(int i=0;i<12;i++) { |
| | | boolean flag = true; |
| | | calendar.add(Calendar.DATE, 1); |
| | | String str = sf.format(calendar.getTime()); |
| | | for(WorkChartAxis workChart : listChart) { |
| | | if(str.equals(workChart.getYmd())) { |
| | | data1.add(workChart.getInqty()); |
| | | data2.add(workChart.getOutqty()); |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | if(flag) { |
| | | data1.add(0); |
| | | data2.add(0); |
| | | } |
| | | } |
| | | AxisBean inqty = new AxisBean(); |
| | | inqty.setName("入库数量"); |
| | | Integer[] array1 = new Integer[data1.size()]; |
| | | inqty.setData(data1.toArray(array1)); |
| | | list.add(inqty); |
| | | AxisBean outqty = new AxisBean(); |
| | | outqty.setName("出库数量"); |
| | | Integer[] array2 = new Integer[data2.size()]; |
| | | outqty.setData(data2.toArray(array2)); |
| | | list.add(outqty); |
| | | } |
| | | map.put("rows",list); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | /*...........................赣州新增..............以上.............赣州新增...........................*/ |
| | | |
| | | |
| | | } |