| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | |
| | | 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.*; |
| | | import com.zy.asrs.mapper.LocDetlMapper; |
| | | import com.zy.asrs.service.LocDetlService; |
| | | 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; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | @Autowired |
| | | private LocDetlMapper locDetlMapper; |
| | | @Autowired |
| | | private MatService matService; |
| | | |
| | | @RequestMapping(value = "/locDetl/update") |
| | | public R update1() { |
| | |
| | | param.remove("modi_time"); |
| | | } |
| | | } |
| | | return R.ok(locDetlService.getStockOut(toPage(curr, limit, param, LocDetl.class))); |
| | | Page<LocDetl> stockOut = locDetlService.getStockOut(toPage(curr, limit, param, LocDetl.class)); |
| | | if (stockOut.getRecords().size()==0){ |
| | | stockOut = locDetlService.getStockOut(toPage(1, limit, param, LocDetl.class)); |
| | | } |
| | | return R.ok(stockOut); |
| | | } |
| | | |
| | | @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 orderByType, |
| | | @RequestParam(required = false)String condition, |
| | | @RequestParam Map<String, Object> param){ |
| | | excludeTrash(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"); |
| | | // } |
| | | // } |
| | | 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)); |
| | | } |
| | | |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | |
| | | 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)); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/locDetl/statis/auth") |
| | | @ManagerAuth |
| | | 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()); |
| | | if (mat != null) { |
| | | locDetl.sync(mat); |
| | | } |
| | | } |
| | | return R.ok().add(stockStatis); |
| | | } |
| | | |
| | | @RequestMapping(value = "/locDetl/check/auth") |
| | | @ManagerAuth |
| | | public R check(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam Map<String, Object> param) { |
| | | Page<CheckDetl> stockStatis = locDetlService.getStockCheck(toPage(curr, limit, param, CheckDetl.class)); |
| | | return R.ok().add(stockStatis); |
| | | } |
| | | |
| | | @Autowired |
| | | private LocDetlMapper LocDetlMapper; |
| | | |
| | | @RequestMapping(value = "/locDetl/statis/export") |
| | | // @ManagerAuth |
| | | public void statisExport(HttpServletResponse response) throws IOException { |
| | | List<LocDetl> excel = LocDetlMapper.getStockStatisExcel(); |
| | | for (LocDetl locDetl : excel) { |
| | | Mat mat = matService.selectByMatnr(locDetl.getMatnr()); |
| | | if (mat != null) { |
| | | locDetl.sync(mat); |
| | | } |
| | | } |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("库存明细统计报表", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | EasyExcel.write(response.getOutputStream(), LocDetl.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .sheet("表1") |
| | | .doWrite(excel); |
| | | } |
| | | |
| | | /** |
| | | * 获取库存总数 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/locDetl/count") |
| | | public R getAllCount(){ |
| | | Integer sum = locDetlService.sum(); |
| | | return R.ok(sum); |
| | | } |
| | | |
| | | } |