From a8b6582ffbcdc353bd06436d76e262e547114897 Mon Sep 17 00:00:00 2001 From: tqs <56479841@qq.com> Date: 星期六, 29 十月 2022 12:49:35 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/controller/LocDetlController.java | 128 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 125 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/LocDetlController.java b/src/main/java/com/zy/asrs/controller/LocDetlController.java index b25c818..767f5a5 100644 --- a/src/main/java/com/zy/asrs/controller/LocDetlController.java +++ b/src/main/java/com/zy/asrs/controller/LocDetlController.java @@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; +import java.text.SimpleDateFormat; import java.util.*; @RestController @@ -90,12 +91,36 @@ @RequestParam(required = false)String orderByField, @RequestParam(required = false)String orderByType, @RequestParam(required = false)String condition, - @RequestParam Map<String, Object> param){ - excludeTrash(param); + @RequestParam Map<String, Object> param, + @RequestParam(required = false)Boolean unreason){ + if (!Cools.isEmpty(unreason) && 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 = ""; 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"); + } + } + excludeTrash(param); 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 +"%'"); + } + return R.ok(locDetlService.selectPage(new Page<>(curr, limit), wrapper)); } @@ -154,11 +179,26 @@ @RequestMapping(value = "/locDetl/export/auth") @ManagerAuth(memo = "搴撲綅鏄庣粏瀵煎嚭") - public R export(@RequestBody JSONObject param){ + public synchronized R export(@RequestBody JSONObject param){ List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); Map<String, Object> map = excludeTrash(param.getJSONObject("locDetl")); + String row = ""; + if (map.get("row") != null) { + String chooseRow = (String) map.get("row"); + if (chooseRow.length() == 1) { + row = "0" + chooseRow; + map.remove("row"); + }else { + row = chooseRow; + map.remove("row"); + } + } convert(map, wrapper); + if (!row.equals("")){ + wrapper.and() + .where("loc_no like '" +row +"%'"); + } List<LocDetl> list = locDetlService.selectList(wrapper); return R.ok(exportSupport(list, fields)); } @@ -237,4 +277,86 @@ return R.ok(sum); } + + /**********************************************************寮傚父搴撳瓨鐩稿叧controller**********************************************************/ + + @RequestMapping(value = "/locDetl/grouplist/auth") + @ManagerAuth + public R groupList(@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){ + + List<LocDetl> result = new ArrayList<>(); +// excludeTrash(param); + param.put("curr",curr); + param.put("limit",limit); + List<LocDetl> groupLocDetl = locDetlService.selectGroupPage(param,curr,limit); + for (LocDetl locDetl : groupLocDetl) { + Mat mat = matService.selectOne(new EntityWrapper<Mat>() + .eq("matnr", locDetl.getMatnr())); + if (Cools.isEmpty(mat) + || Cools.isEmpty(mat.getStoreMax()) + || Cools.isEmpty(mat.getStoreMaxDate()) + || Cools.isEmpty(mat.getStoreMin())) { + continue; + } + if (locDetl.getAnfme() > mat.getStoreMax()){ + result.add(locDetl); + continue; + } + if (locDetl.getAnfme() < mat.getStoreMin()){ + result.add(locDetl); + continue; + } + + + if (Cools.isEmpty(locDetl.getBatch())) { + continue; + } + if (locDetl.getBatch().length() != 8){ + continue; + } + try{ + SimpleDateFormat simple = new SimpleDateFormat("yyyyMMdd"); + Date maxDate = simple.parse(locDetl.getBatch()); + Calendar calendar = new GregorianCalendar(); + calendar.setTime(maxDate); + // 鎶婃棩鏈熷線鍚庡鍔犱竴澶�,鏁存暟 寰�鍚庢帹,璐熸暟寰�鍓嶇Щ鍔� + calendar.add(Calendar.DATE, mat.getStoreMaxDate()); + // 杩欎釜鏃堕棿灏辨槸鏃ユ湡寰�鍚庢帹涓�澶╃殑缁撴灉 + maxDate = calendar.getTime(); + Date now = new Date(); + if (now.compareTo(maxDate) > 0) { + result.add(locDetl); + } + + }catch (Exception e){ + continue; + } + } + + Page<LocDetl> locDetlPage = new Page<>(); + locDetlPage.setRecords(paging(result,curr,limit)); + locDetlPage.setTotal(result.size()); + locDetlPage.setCurrent(curr); + locDetlPage.setSize(limit); + return R.ok(locDetlPage); + } + + private List<LocDetl> paging(List<LocDetl> result, Integer curr, Integer limit) { + List<LocDetl> pageRecord = new ArrayList<LocDetl>(); + int minIndex = (curr - 1) * limit; + int maxIndex = (curr * limit) - 1; + if (result.size() < maxIndex){ + maxIndex = result.size(); + } + for (int i = minIndex; i < maxIndex; i++){ + pageRecord.add(result.get(i)); + } + return pageRecord; + } + } -- Gitblit v1.9.1