|  |  |  | 
|---|
|  |  |  | 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.Mat; | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.entity.result.LocDetlAll; | 
|---|
|  |  |  | import com.zy.asrs.entity.result.LocDetlDTO; | 
|---|
|  |  |  | import com.zy.asrs.mapper.LocDetlMapper; | 
|---|
|  |  |  | import com.zy.asrs.service.LocDetlService; | 
|---|
|  |  |  | import com.zy.asrs.service.LocOwnerService; | 
|---|
|  |  |  | import com.zy.asrs.service.ManLocDetlService; | 
|---|
|  |  |  | import com.zy.asrs.service.MatService; | 
|---|
|  |  |  | import com.zy.common.web.BaseController; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocDetlService locDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocOwnerService locOwnerService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocDetlMapper locDetlMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatService matService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ManLocDetlService manLocDetlService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/selectAllNumWarning/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "库存数量预警") | 
|---|
|  |  |  | public R selectAllNumWarning(@RequestParam(defaultValue = "1")Integer curr, | 
|---|
|  |  |  | @RequestParam(defaultValue = "10")Integer limit, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param) { | 
|---|
|  |  |  | //        Page<LocDetl> stockStatis = locDetlService.getStockStatis(toPage(curr, limit, param, LocDetl.class)); | 
|---|
|  |  |  | //        for (LocDetl locDetl : stockStatis.getRecords()) { | 
|---|
|  |  |  | //            Mat mat = matService.selectByMatnr(locDetl.getMatnr()); | 
|---|
|  |  |  | //            if (mat != null) { | 
|---|
|  |  |  | //                locDetl.sync(mat); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        return R.ok().add(stockStatis); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Page<LocDetlAll> stockStatis = locDetlService.getWarningNumPage(toPage(curr, limit, param, LocDetlAll.class)); | 
|---|
|  |  |  | for (LocDetlAll locDetlAll : stockStatis.getRecords()) { | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(locDetlAll.getMatnr()); | 
|---|
|  |  |  | if (mat != null) { | 
|---|
|  |  |  | locDetlAll.sync(mat); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(stockStatis); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/selectAllWarning/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "库龄预警") | 
|---|
|  |  |  | public Map<String,Object> queryViewStayTimeListByPages(@RequestParam(defaultValue = "1")Integer curr, | 
|---|
|  |  |  | @RequestParam(defaultValue = "10")Integer limit, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param){ | 
|---|
|  |  |  | LocDetlWarningDTO locDetlWarningDTO = new LocDetlWarningDTO(); | 
|---|
|  |  |  | locDetlWarningDTO.setPageSize(limit); | 
|---|
|  |  |  | locDetlWarningDTO.setPageNumber(curr); | 
|---|
|  |  |  | String locNo = String.valueOf(param.get("locNo")); | 
|---|
|  |  |  | String matnr = String.valueOf(param.get("matnr")); | 
|---|
|  |  |  | if (!Cools.isEmpty(locNo) && !locNo.equals("null")) { | 
|---|
|  |  |  | locDetlWarningDTO.setLocNo(locNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(matnr) && !matnr.equals("null")) { | 
|---|
|  |  |  | locDetlWarningDTO.setMatnr(matnr); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetlWarningDTO> list = locDetlService.selectAllWarning(locDetlWarningDTO); | 
|---|
|  |  |  | int count = locDetlService.getAllWarningCount(locDetlWarningDTO); | 
|---|
|  |  |  | Page<LocDetlWarningDTO> page = new Page<>(); | 
|---|
|  |  |  | page.setRecords(list); | 
|---|
|  |  |  | page.setTotal(count); | 
|---|
|  |  |  | return R.ok(page); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/update") | 
|---|
|  |  |  | public R update1() { | 
|---|
|  |  |  | 
|---|
|  |  |  | param.remove("modi_time"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(locDetlService.getStockOut(toPage(curr, limit, param, LocDetl.class))); | 
|---|
|  |  |  | return R.ok(locDetlService.getStockOut(toPage(curr, limit, param, LocDetl.class),"2")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/list/auth") | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/list/auth")// /locDetl/list/auth 接口问题 | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R list(@RequestParam(defaultValue = "1")Integer curr, | 
|---|
|  |  |  | @RequestParam(defaultValue = "10")Integer limit, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByField, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByType, | 
|---|
|  |  |  | @RequestParam(required = false)String condition, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param, | 
|---|
|  |  |  | @RequestParam(required = false)Boolean unreason){ | 
|---|
|  |  |  | if (unreason) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(locDetlService.selectPage(new Page<>(curr, limit), new EntityWrapper<LocDetl>() | 
|---|
|  |  |  | .where(" DATALENGTH( batch ) != 11 or\n" + | 
|---|
|  |  |  | "            batch LIKE '%[a-z]%'"))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | param.remove("unreason"); | 
|---|
|  |  |  | String row = ""; | 
|---|
|  |  |  | @RequestParam Map<String, Object> param){ | 
|---|
|  |  |  | //        String row = ""; | 
|---|
|  |  |  | EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | if (param.get("row") != null) { | 
|---|
|  |  |  | String chooseRow = (String) param.get("row"); | 
|---|
|  |  |  | if (chooseRow.length() == 1) { | 
|---|
|  |  |  | row = "0" + chooseRow; | 
|---|
|  |  |  | param.remove("row"); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | row = chooseRow; | 
|---|
|  |  |  | param.remove("row"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (param.get("row") != null) { | 
|---|
|  |  |  | //            String chooseRow = (String) param.get("row"); | 
|---|
|  |  |  | //            if (chooseRow.length() == 1) { | 
|---|
|  |  |  | //                row = "0" + chooseRow; | 
|---|
|  |  |  | //                param.remove("row"); | 
|---|
|  |  |  | //            }else { | 
|---|
|  |  |  | //                row = chooseRow; | 
|---|
|  |  |  | //                param.remove("row"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | excludeTrash(param); | 
|---|
|  |  |  | convert(param, wrapper); | 
|---|
|  |  |  | String locNo = convert(param, wrapper); | 
|---|
|  |  |  | allLike(LocDetl.class, param.keySet(), wrapper, condition); | 
|---|
|  |  |  | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} | 
|---|
|  |  |  | if (!row.equals("")){ | 
|---|
|  |  |  | wrapper.and() | 
|---|
|  |  |  | .where("loc_no like '" +row +"%'"); | 
|---|
|  |  |  | Page<LocDetl> locDetlPage = locDetlService.selectPage(new Page<>(curr, limit), wrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(locDetlPage) || locDetlPage.getTotal()==0){ | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.queryStockViewMerge(locNo); | 
|---|
|  |  |  | return R.ok(locDetlPage.setRecords(locDetls)); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | return R.ok(locDetlPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(locDetlService.selectPage(new Page<>(curr, limit), wrapper)); | 
|---|
|  |  |  | //        if (!row.equals("")){ | 
|---|
|  |  |  | //            wrapper.and() | 
|---|
|  |  |  | //                    .where("loc_no like '" +row +"%'"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private <T> String convert(Map<String, Object> map, EntityWrapper<T> wrapper){ | 
|---|
|  |  |  | String locNo=null; | 
|---|
|  |  |  | for (Map.Entry<String, Object> entry : map.entrySet()){ | 
|---|
|  |  |  | String val = String.valueOf(entry.getValue()); | 
|---|
|  |  |  | if (val.contains(RANGE_TIME_LINK)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); | 
|---|
|  |  |  | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (entry.getKey().equals("locNo")) { | 
|---|
|  |  |  | if (entry.getKey().equals("loc_no")) { | 
|---|
|  |  |  | wrapper.eq("loc_no", String.valueOf(entry.getValue())); | 
|---|
|  |  |  | locNo=String.valueOf(entry.getValue()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return locNo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/add/auth") | 
|---|
|  |  |  | 
|---|
|  |  |  | public R statis(@RequestParam(defaultValue = "1")Integer curr, | 
|---|
|  |  |  | @RequestParam(defaultValue = "10")Integer limit, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param) { | 
|---|
|  |  |  | Page<LocDetl> stockStatis = locDetlService.getStockStatis(toPage(curr, limit, param, LocDetl.class)); | 
|---|
|  |  |  | for (LocDetl locDetl : stockStatis.getRecords()) { | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(locDetl.getMatnr()); | 
|---|
|  |  |  | //        Page<LocDetl> stockStatis = locDetlService.getStockStatis(toPage(curr, limit, param, LocDetl.class)); | 
|---|
|  |  |  | //        for (LocDetl locDetl : stockStatis.getRecords()) { | 
|---|
|  |  |  | //            Mat mat = matService.selectByMatnr(locDetl.getMatnr()); | 
|---|
|  |  |  | //            if (mat != null) { | 
|---|
|  |  |  | //                locDetl.sync(mat); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        return R.ok().add(stockStatis); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Page<LocDetlAll> stockStatis = locDetlService.getStockStatisAll(toPage(curr, limit, param, LocDetlAll.class)); | 
|---|
|  |  |  | for (LocDetlAll locDetlAll : stockStatis.getRecords()) { | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(locDetlAll.getMatnr()); | 
|---|
|  |  |  | if (mat != null) { | 
|---|
|  |  |  | locDetl.sync(mat); | 
|---|
|  |  |  | locDetlAll.sync(mat); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(stockStatis); | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/locDetl/count") | 
|---|
|  |  |  | public R getAllCount(){ | 
|---|
|  |  |  | Integer sum = locDetlService.sum(); | 
|---|
|  |  |  | Double sum = locDetlService.sumAll(); | 
|---|
|  |  |  | return R.ok(sum); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/turn/over/list/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R turnOverList(@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"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(param.get("owner"))){ | 
|---|
|  |  |  | List<LocOwner> locOwners = locOwnerService.selectList(new EntityWrapper<LocOwner>().eq("owner", param.get("owner"))); | 
|---|
|  |  |  | if (Cools.isEmpty(locOwners) || locOwners.size()>1){ | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | param.remove("owner"); | 
|---|
|  |  |  | param.put("owner", locOwners.get(0).getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(locDetlService.getStockOut(toPage(curr, limit, param, LocDetl.class),"1")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/selectPayment/list/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R list(@RequestParam(defaultValue = "1")Integer curr, | 
|---|
|  |  |  | @RequestParam(defaultValue = "10")Integer limit, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByField, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByType, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param){ | 
|---|
|  |  |  | if (param.get("owner$") != null && param.get("owner$") != ""){ | 
|---|
|  |  |  | LocOwner locOwner = locOwnerService.selectOne(new EntityWrapper<LocOwner>().eq("owner", param.get("owner$"))); | 
|---|
|  |  |  | if(locOwner == null){ | 
|---|
|  |  |  | return R.error("参数有误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | param.remove("owner$"); | 
|---|
|  |  |  | param.put("owner",locOwner.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocDetlDTO locDetlDTO = new LocDetlDTO(); | 
|---|
|  |  |  | locDetlDTO.setPageSize(limit); | 
|---|
|  |  |  | locDetlDTO.setPageNumber(curr); | 
|---|
|  |  |  | String locNo = String.valueOf(param.get("locNo")); | 
|---|
|  |  |  | String owner = String.valueOf(param.get("owner")); | 
|---|
|  |  |  | String matnr = String.valueOf(param.get("matnr")); | 
|---|
|  |  |  | String payment = String.valueOf(param.get("payment")); | 
|---|
|  |  |  | if (!Cools.isEmpty(locNo) && !locNo.equals("null")) { | 
|---|
|  |  |  | locDetlDTO.setLocNo(locNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(matnr) && !matnr.equals("null")) { | 
|---|
|  |  |  | locDetlDTO.setMatnr(matnr); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(owner) && !owner.equals("null")) { | 
|---|
|  |  |  | locDetlDTO.setOwner(owner); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(payment) && !payment.equals("null")) { | 
|---|
|  |  |  | locDetlDTO.setPayment(payment); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetlAll> list = locDetlService.selectAllPyment(locDetlDTO); | 
|---|
|  |  |  | int count = locDetlService.selectAllPymentcount(locDetlDTO); | 
|---|
|  |  |  | Page<LocDetlAll> page = new Page<>(); | 
|---|
|  |  |  | page.setRecords(list); | 
|---|
|  |  |  | page.setTotal(count); | 
|---|
|  |  |  | return R.ok(page); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/selectOwner/list/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R selectOwnerlist(@RequestParam(defaultValue = "1")Integer curr, | 
|---|
|  |  |  | @RequestParam(defaultValue = "10")Integer limit, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByField, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByType, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param){ | 
|---|
|  |  |  | if (param.get("owner$") != null && param.get("owner$") != ""){ | 
|---|
|  |  |  | LocOwner locOwner = locOwnerService.selectOne(new EntityWrapper<LocOwner>().eq("owner", param.get("owner$"))); | 
|---|
|  |  |  | if(locOwner == null){ | 
|---|
|  |  |  | return R.error("参数有误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | param.remove("owner$"); | 
|---|
|  |  |  | param.put("owner",locOwner.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocDetlDTO locDetlDTO = new LocDetlDTO(); | 
|---|
|  |  |  | locDetlDTO.setPageSize(limit); | 
|---|
|  |  |  | locDetlDTO.setPageNumber(curr); | 
|---|
|  |  |  | String locNo = String.valueOf(param.get("locNo")); | 
|---|
|  |  |  | String owner = String.valueOf(param.get("owner")); | 
|---|
|  |  |  | String matnr = String.valueOf(param.get("matnr")); | 
|---|
|  |  |  | if (!Cools.isEmpty(locNo) && !locNo.equals("null")) { | 
|---|
|  |  |  | locDetlDTO.setLocNo(locNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(matnr) && !matnr.equals("null")) { | 
|---|
|  |  |  | locDetlDTO.setMatnr(matnr); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(owner) && !owner.equals("null")) { | 
|---|
|  |  |  | locDetlDTO.setOwner(owner); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetlAll> list = locDetlService.selectAllOwner(locDetlDTO); | 
|---|
|  |  |  | int count = locDetlService.selectAllCount(locDetlDTO); | 
|---|
|  |  |  | Page<LocDetlAll> page = new Page<>(); | 
|---|
|  |  |  | page.setRecords(list); | 
|---|
|  |  |  | page.setTotal(count); | 
|---|
|  |  |  | if (list.size()==0){ | 
|---|
|  |  |  | locDetlDTO.setPageNumber(1); | 
|---|
|  |  |  | list = locDetlService.selectAllOwner(locDetlDTO); | 
|---|
|  |  |  | count = locDetlService.selectAllCount(locDetlDTO); | 
|---|
|  |  |  | page = new Page<>(); | 
|---|
|  |  |  | page.setRecords(list); | 
|---|
|  |  |  | page.setTotal(count); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(page); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|