自动化立体仓库 - WMS系统
#
tqs
2022-10-29 a8b6582ffbcdc353bd06436d76e262e547114897
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;
    }
}