|  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONArray; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.entity.LocDetl; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.entity.Mat; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.service.LocDetlService; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.service.MatService; | 
|---|
|  |  |  | import com.zy.asrs.framework.annotations.ManagerAuth; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.Cools; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.R; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocDetlService locDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatService matService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/forLocNoAndBarcode/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R forLocNoAndBarcode(@RequestParam String locNo,@RequestParam String barcode) { | 
|---|
|  |  |  | List<LocDetl> detls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo, locNo).eq(LocDetl::getZpallet, barcode).eq(LocDetl::getHostId, getHostId())); | 
|---|
|  |  |  | if (Cools.isEmpty(detls)){ | 
|---|
|  |  |  | return R.error("未查询到库存数据"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(detls); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/forlocNo/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R forlocNo(@RequestParam String orderNo,@RequestParam String locNo,@RequestParam String batch,@RequestParam String matnr) { | 
|---|
|  |  |  | LambdaQueryWrapper<LocDetl> locDetlLambdaQueryWrapper = new LambdaQueryWrapper<LocDetl>() | 
|---|
|  |  |  | .eq(LocDetl::getLocNo, locNo) | 
|---|
|  |  |  | .eq(LocDetl::getHostId, getHostId()) | 
|---|
|  |  |  | .eq(LocDetl::getMatnr, matnr); | 
|---|
|  |  |  | if (!Cools.isEmpty(batch)){ | 
|---|
|  |  |  | locDetlLambdaQueryWrapper.eq(LocDetl::getBatch,batch); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetl> detls = locDetlService.list(locDetlLambdaQueryWrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(detls)){ | 
|---|
|  |  |  | return R.error("未查询到库存数据"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(detls); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/{id}/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | 
|---|
|  |  |  | wrapper.ge(LocDetl::getAppeTime, DateUtils.convert(range[0])); | 
|---|
|  |  |  | wrapper.le(LocDetl::getAppeTime, DateUtils.convert(range[1])); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(param.get("loc_no"))) { | 
|---|
|  |  |  | wrapper.eq(LocDetl::getLocNo, param.get("loc_no")); | 
|---|
|  |  |  | if (!Cools.isEmpty(param.get("locNo"))) { | 
|---|
|  |  |  | wrapper.eq(LocDetl::getLocNo, param.get("locNo")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(locDetlService.page(new Page<>(curr, limit), wrapper)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok().add(vos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/statis/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R statis(@RequestParam(defaultValue = "1")Integer curr, | 
|---|
|  |  |  | @RequestParam(defaultValue = "10")Integer limit, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param) { | 
|---|
|  |  |  | IPage<LocDetl> stockStatis = locDetlService.getStockStatis(curr, limit, param); | 
|---|
|  |  |  | for (LocDetl locDetl : stockStatis.getRecords()) { | 
|---|
|  |  |  | Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>() | 
|---|
|  |  |  | .eq(Mat::getMatnr, locDetl.getMatnr()) | 
|---|
|  |  |  | .eq(Mat::getHostId, getHostId())); | 
|---|
|  |  |  | if (mat != null) { | 
|---|
|  |  |  | locDetl.sync(mat); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(stockStatis); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取库存总数 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/locDetl/count") | 
|---|
|  |  |  | public R getAllCount(){ | 
|---|
|  |  |  | Integer sum = locDetlService.sum(); | 
|---|
|  |  |  | return R.ok(sum); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/stock/out/list/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R stockOutList(@RequestParam(defaultValue = "1")Integer curr, | 
|---|
|  |  |  | @RequestParam(defaultValue = "10")Integer limit, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param){ | 
|---|
|  |  |  | if (!Cools.isEmpty(param.get("modi_time"))){ | 
|---|
|  |  |  | String val = String.valueOf(param.get("modi_time")); | 
|---|
|  |  |  | if (val.contains(RANGE_TIME_LINK)) { | 
|---|
|  |  |  | String[] dates = val.split(RANGE_TIME_LINK); | 
|---|
|  |  |  | param.put("startTime", DateUtils.convert(dates[0])); | 
|---|
|  |  |  | param.put("endTime", DateUtils.convert(dates[1])); | 
|---|
|  |  |  | param.remove("modi_time"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | param.put("hostId", getHostId()); | 
|---|
|  |  |  | return R.ok(locDetlService.getStockOut(curr, limit, param)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|