|  |  |  | 
|---|
|  |  |  | 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 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 | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/update") | 
|---|
|  |  |  | public R update1() { | 
|---|
|  |  |  | if (!locDetlService.updateLocNo("0402805", "0402804")) { | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | return R.error("参数缺失"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestParam(required = false)String orderByField, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByType, | 
|---|
|  |  |  | @RequestParam(required = false)String condition, | 
|---|
|  |  |  | @RequestParam Map<String, Object> 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) { | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "库位明细修改") | 
|---|
|  |  |  | public R update(LocDetl locDetl){ | 
|---|
|  |  |  | if (Cools.isEmpty(locDetl) || null==locDetl.getMatnr()){ | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | return R.error("参数缺失"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locDetl.setModiUser(getUserId()); | 
|---|
|  |  |  | locDetl.setModiTime(new Date()); | 
|---|
|  |  |  | locDetlService.updateById(locDetl); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/locDetl/updateStockFreeze/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "库位冻结") | 
|---|
|  |  |  | public R updateStockFreeze(LocDetl locDetl){ | 
|---|
|  |  |  | if (Cools.isEmpty(locDetl) || null==locDetl.getMatnr()){ | 
|---|
|  |  |  | return R.error("参数缺失"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locDetlService.updateStockFreeze(locDetl.getMatnr(), locDetl.getLocNo(), locDetl.getStockFreeze()); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public R delete(@RequestParam String param){ | 
|---|
|  |  |  | List<LocDetl> list = JSONArray.parseArray(param, LocDetl.class); | 
|---|
|  |  |  | if (Cools.isEmpty(list)){ | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | return R.error("参数缺失"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (LocDetl entity : list){ | 
|---|
|  |  |  | locDetlService.delete(new EntityWrapper<>(entity)); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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")); | 
|---|
|  |  |  | 
|---|
|  |  |  | @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); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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); | 
|---|
|  |  |  | @ManagerAuth(memo = "库位明细导出") | 
|---|
|  |  |  | public synchronized R statisExport(@RequestBody JSONObject param){ | 
|---|
|  |  |  | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); | 
|---|
|  |  |  | List<LocDetl> stockStatisExcel = LocDetlMapper.getStockStatisExcel(); | 
|---|
|  |  |  | return R.ok(exportSupport(stockStatisExcel, fields)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|