| | |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import com.microsoft.sqlserver.jdbc.SQLServerException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.GlobleParameter; |
| | | import com.zy.asrs.entity.result.KeyValueVo; |
| | |
| | | |
| | | @RequestMapping(value = "/pla/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String condition, |
| | | @RequestParam Map<String, Object> param){ |
| | | public R list(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String condition, |
| | | @RequestParam Map<String, Object> param) { |
| | | excludeTrash(param); |
| | | EntityWrapper<Pla> wrapper = new EntityWrapper<>(); |
| | | |
| | | if(!Cools.isEmpty(param.get("brand"))){ |
| | | wrapper.eq("brand",param.get("brand")); |
| | | if (!Cools.isEmpty(param.get("brand"))) { |
| | | wrapper.eq("brand", param.get("brand")); |
| | | param.remove("brand"); |
| | | } |
| | | // 没有选择的时候默认不显示已出库的物料 |
| | |
| | | wrapper.ne("status", "全部出库"); |
| | | } |
| | | |
| | | if (!Cools.isEmpty(param.get("batch")) && param.get("batch").toString().contains(",")){ |
| | | if (!Cools.isEmpty(param.get("batch")) && param.get("batch").toString().contains(",")) { |
| | | String[] batchs = param.get("batch").toString().split(","); |
| | | wrapper.in("batch",batchs); |
| | | wrapper.in("batch", batchs); |
| | | param.remove("batch"); |
| | | } |
| | | |
| | | convert(param, wrapper); |
| | | wrapper.orderBy("batch",true).orderBy("package_no" ,true); |
| | | wrapper.orderBy("batch", true).orderBy("package_no", true); |
| | | allLike(Pla.class, param.keySet(), wrapper, condition); |
| | | return R.ok(plaService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | |
| | | plaService.updateById(pla); |
| | | |
| | | PlaLog plaLog = new PlaLog(); |
| | | BeanUtils.copyProperties(plaSave,plaLog); |
| | | BeanUtils.copyProperties(plaSave, plaLog); |
| | | plaLog.setId(null); |
| | | plaLog.setCreateTime(new Date()); |
| | | plaLog.setModifyUser(getUser().getUsername()); |
| | |
| | | public R delete(@RequestBody List<Pla> plas) { |
| | | System.out.println(plas.toString()); |
| | | plas.forEach(pla -> { |
| | | if(!pla.getStatus().equals(GlobleParameter.PLA_STATUS_00) && !pla.getStatus().equals(GlobleParameter.PLA_STATUS_0) && !pla.getStatus().equals(GlobleParameter.PLA_STATUS_1)){ |
| | | if (!pla.getStatus().equals(GlobleParameter.PLA_STATUS_00) && !pla.getStatus().equals(GlobleParameter.PLA_STATUS_0) && !pla.getStatus().equals(GlobleParameter.PLA_STATUS_1)) { |
| | | throw new CoolException("已入库的数据无法被删除"); |
| | | } |
| | | Pla plaSave = plaService.selectById(pla.getId()); |
| | |
| | | plaService.deleteById(pla.getId()); |
| | | |
| | | PlaLog plaLog = new PlaLog(); |
| | | BeanUtils.copyProperties(plaSave,plaLog); |
| | | BeanUtils.copyProperties(plaSave, plaLog); |
| | | plaLog.setId(null); |
| | | plaLog.setCreateTime(new Date()); |
| | | plaLog.setModifyUser(getUser().getUsername()); |
| | |
| | | Order order = orderService.selectByNo(orderNo); |
| | | OrderDetl orderDetl = orderDetlService.selectByOrderNoAndMaktx(orderNo, maktx); |
| | | |
| | | for (Pla pla : plas){ |
| | | for (Pla pla : plas) { |
| | | |
| | | if(pla.getStockFreeze() == 0){ |
| | | if (pla.getStockFreeze() == 0) { |
| | | // throw new CoolException("库存已被冻结,请重新选择库存"); |
| | | System.out.println(pla.getStockFreezeBy() + "," + getUser().getUsername()); |
| | | if(!Cools.eq(pla.getStockFreezeBy(),getUser().getUsername())){ |
| | | if (!Cools.eq(pla.getStockFreezeBy(), getUser().getUsername())) { |
| | | throw new CoolException("该库存已被其他用户冻结,请重新选择"); |
| | | } |
| | | } |
| | | |
| | | allOrderWeight += pla.getOrderWeight(); |
| | | |
| | | if(pla.getWeightAnfme() - pla.getQtyAnfme() - pla.getOrderWeight() < 0){ |
| | | throw new CoolException("批号:" + pla.getBatch() +",包号:" + pla.getPackageNo() +" 剩余可出库重量不足,请调整出库重量"); |
| | | if (pla.getWeightAnfme() - pla.getQtyAnfme() - pla.getOrderWeight() < 0) { |
| | | throw new CoolException("批号:" + pla.getBatch() + ",包号:" + pla.getPackageNo() + " 剩余可出库重量不足,请调整出库重量"); |
| | | } |
| | | pla.setQtyAnfme(pla.getQtyAnfme() + pla.getOrderWeight()); |
| | | pla.setHandlerBy(getUser().getUsername()); |
| | |
| | | pla.setPakoutTime(pla.getPakoutTime().split("\\(")[0]); |
| | | //生成此次作业信息 |
| | | PlaQty plaQty = new PlaQty(); |
| | | BeanUtils.copyProperties(pla,plaQty); |
| | | BeanUtils.copyProperties(pla, plaQty); |
| | | plaQty.setCreateTime(new Date()); |
| | | plaQty.setId(null); |
| | | plaQty.setTransfer(order.getDocType$()); |
| | |
| | | plaService.updateById(pla); |
| | | plaQtyService.insert(plaQty); |
| | | //生成拣货单 |
| | | addPakOUT(plaQty,getUserId()); |
| | | addPakOUT(plaQty, getUserId()); |
| | | |
| | | }; |
| | | } |
| | | ; |
| | | |
| | | //修改单据信息 |
| | | if(orderDetl.getAnfme()-orderDetl.getWorkQty()-allOrderWeight < 0){ |
| | | if (orderDetl.getAnfme() - orderDetl.getWorkQty() - allOrderWeight < 0) { |
| | | throw new CoolException("该订单出库数量大于订单待出数量,请重新选择出库数量"); |
| | | } |
| | | if(order.getStatus() < 2){ |
| | | orderService.updateSettle(order.getId(),2L,getUserId()); |
| | | if (order.getStatus() < 2) { |
| | | orderService.updateSettle(order.getId(), 2L, getUserId()); |
| | | } |
| | | |
| | | orderDetl.setWorkQty(orderDetl.getWorkQty() + allOrderWeight); |
| | |
| | | @RequestMapping(value = "/pla/returned/auth") |
| | | @ManagerAuth |
| | | public R returned(@RequestBody List<PlaQty> plaQties) { |
| | | plaService.returned(plaQties,getUser()); |
| | | plaService.returned(plaQties, getUser()); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/pla/viladate/auth") |
| | | @ManagerAuth |
| | | public R viladate(@RequestBody List<Pla> plas) { |
| | | plaService.viladate(plas,getUser()); |
| | | plaService.viladate(plas, getUser()); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | pla.setModifyTime(new Date()); |
| | | pla.setWeightAnfme(0.0); |
| | | plaService.updateById(pla); |
| | | SaasUtils.insertLog(1,pla.getLocNo(),pla.getBrand(),anfme,getUser().getUsername(), |
| | | null,pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop(),null); |
| | | SaasUtils.insertLog(1, pla.getLocNo(), pla.getBrand(), anfme, getUser().getUsername(), |
| | | null, pla.getBatch(), pla.getPackageNo(), pla.getOwner(), pla.getWorkshop(), null); |
| | | }); |
| | | |
| | | return R.ok(); |
| | |
| | | @RequestMapping(value = "/pla/updateStockFreeze") |
| | | @Transactional |
| | | @ManagerAuth(memo = "库位冻结") |
| | | public R updateStockFreeze(@RequestBody List<Pla> plas){ |
| | | if (Cools.isEmpty(plas)){ |
| | | public R updateStockFreeze(@RequestBody List<Pla> plas) { |
| | | if (Cools.isEmpty(plas)) { |
| | | return R.error("无数据"); |
| | | } |
| | | for (Pla pla : plas){ |
| | | if (pla.getStockFreeze() == 0){ |
| | | for (Pla pla : plas) { |
| | | if (pla.getStockFreeze() == 0) { |
| | | continue; |
| | | // throw new CoolException("库存已被冻结!"); |
| | | } |
| | |
| | | |
| | | @RequestMapping(value = "/pla/updateStockDisFreeze") |
| | | @ManagerAuth(memo = "库位解冻") |
| | | public R updateStockDisFreeze(@RequestBody List<Pla> plas){ |
| | | if (Cools.isEmpty(plas)){ |
| | | public R updateStockDisFreeze(@RequestBody List<Pla> plas) { |
| | | if (Cools.isEmpty(plas)) { |
| | | return R.error("无数据"); |
| | | } |
| | | for (Pla pla : plas){ |
| | | if (pla.getStockFreeze() == 1){ |
| | | for (Pla pla : plas) { |
| | | if (pla.getStockFreeze() == 1) { |
| | | continue; |
| | | // throw new CoolException("库位未冻结,无需解冻"); |
| | | } |
| | | if(!Cools.eq(pla.getStockFreezeBy(),getUser().getUsername())){ |
| | | if (!Cools.eq(pla.getStockFreezeBy(), getUser().getUsername())) { |
| | | throw new CoolException("无法解冻其他用户冻结的库位"); |
| | | } |
| | | pla.setStockFreeze(1); |
| | |
| | | wrapper.like("maktx", condition); |
| | | Page<Mat> page = matService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Mat mat : page.getRecords()){ |
| | | for (Mat mat : page.getRecords()) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", mat.getMaktx()); |
| | | map.put("value", mat.getMaktx()); |
| | |
| | | |
| | | @RequestMapping(value = "/pla/statis/auth") |
| | | @ManagerAuth |
| | | public R statis(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | public R statis(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam Map<String, Object> param) { |
| | | |
| | | Page<Pla> stockStatis = plaService.getStockStatisAll(toPage(curr, limit, param, Pla.class)); |
| | |
| | | PlaExcelListener listener = new PlaExcelListener(getUserId()); |
| | | try { |
| | | EasyExcel.read(file.getInputStream(), PlaExcel.class, listener).sheet().doRead(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | int index = listener.getIndex() - 1; |
| | | throw new CoolException("导入的数据格式错误,原因:" + e.getMessage() + ",第" + index + ",数据格式不对"); |
| | | } |
| | | log.info("导入修改信息输出:" + listener.getRecordLog()); |
| | | return R.ok("成功同步"+listener.getTotal()+"条pla物料数据"); |
| | | return R.ok("成功同步" + listener.getTotal() + "条pla物料数据"); |
| | | } |
| | | |
| | | // 打印 |
| | | @RequestMapping(value = "/pla/print/auth") |
| | | @ManagerAuth(memo = "pla编码打印") |
| | | public R matCodePrint(@RequestBody List<Pla> plas) { |
| | | if(Cools.isEmpty(plas)) { |
| | | if (Cools.isEmpty(plas)) { |
| | | return R.parse(CodeRes.EMPTY); |
| | | } |
| | | List<Pla> res = new ArrayList<>(); |
| | | for (Pla pla : plas){ |
| | | for (Pla pla : plas) { |
| | | res.add(pla); |
| | | } |
| | | return R.ok().add(res); |
| | |
| | | Wrapper<Pla> wrapper = new EntityWrapper<Pla>().setSqlSelect("batch") |
| | | .andNew().like("batch", condition) |
| | | .groupBy("batch") |
| | | .orderBy("batch",false); |
| | | .orderBy("batch", false); |
| | | List<Pla> plas = plaService.selectPage(new Page<Pla>(1, 30), wrapper).getRecords(); |
| | | List<KeyValueVo> valueVos = new ArrayList<>(); |
| | | for (Pla pla : plas) { |
| | |
| | | return R.ok().add(valueVos); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) { |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (val.contains(RANGE_TIME_LINK)){ |
| | | if (val.contains(RANGE_TIME_LINK)) { |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); |
| | | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); |
| | | }else if (entry.getKey().contains("Min")){ |
| | | wrapper.ge(entry.getKey().substring(0,entry.getKey().length()-3),val); |
| | | }else if (entry.getKey().contains("Max")){ |
| | | wrapper.le(entry.getKey().substring(0,entry.getKey().length()-3),val); |
| | | } else if (entry.getKey().contains("Min")) { |
| | | wrapper.ge(entry.getKey().substring(0, entry.getKey().length() - 3), val); |
| | | } else if (entry.getKey().contains("Max")) { |
| | | wrapper.le(entry.getKey().substring(0, entry.getKey().length() - 3), val); |
| | | } else { |
| | | wrapper.like(entry.getKey(), val); |
| | | } |
| | |
| | | } |
| | | |
| | | @Synchronized |
| | | private R addPakOUT(PlaQty plaQty,Long userId){ |
| | | ManPakOut manPakOut=new ManPakOut(); |
| | | manPakOut.setWrkNo(plaQty.getOrderNo()+"-"+String.valueOf(snowflakeIdWorker.nextId())); |
| | | manPakOut.setWrkSts((long)1); |
| | | private R addPakOUT(PlaQty plaQty, Long userId) { |
| | | ManPakOut manPakOut = new ManPakOut(); |
| | | manPakOut.setWrkNo(plaQty.getOrderNo() + "-" + String.valueOf(snowflakeIdWorker.nextId())); |
| | | manPakOut.setWrkSts((long) 1); |
| | | manPakOut.setAnfme(plaQty.getOrderWeight()); |
| | | manPakOut.setMaktx(plaQty.getBrand()); |
| | | manPakOut.setLocNo(plaQty.getLocNo()); |