| | |
| | | @Autowired |
| | | private MatCodeService matCodeService; |
| | | |
| | | @RequestMapping(value = "/matCode/auto/id/auth") |
| | | @ManagerAuth |
| | | public R autoId() { |
| | | String matnr = ""; |
| | | do { |
| | | matnr = getNewMatnr(); |
| | | } while (matCodeService.selectById(matnr) != null); |
| | | return R.ok().add(matnr); |
| | | } |
| | | |
| | | private String getNewMatnr(){ |
| | | StringBuilder sb = new StringBuilder("MAT"); |
| | | sb.append(new Date().getTime()); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/matCode/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | |
| | | |
| | | // 导出 |
| | | @RequestMapping(value = "/matCode/export/auth") |
| | | @ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "物料编码数据导出") |
| | | @ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "商品编号数据导出") |
| | | public void export(@RequestParam(required = false) String fileName, |
| | | @RequestParam(required = false) Integer rowCount, |
| | | HttpServletResponse response) throws Exception { |
| | |
| | | } |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | fileName = URLEncoder.encode(Cools.isEmpty(fileName)?"物料编码":fileName, "UTF-8"); |
| | | fileName = URLEncoder.encode(Cools.isEmpty(fileName)?"商品编号":fileName, "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | EasyExcel.write(response.getOutputStream(), MatCodeExcel.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | |
| | | |
| | | // 导入 |
| | | @RequestMapping(value = "/matCode/import/auth") |
| | | @ManagerAuth(memo = "物料编码数据导入") |
| | | @ManagerAuth(memo = "商品编号数据导入") |
| | | @Transactional |
| | | public R matCodeImport(MultipartFile file) throws IOException, InterruptedException { |
| | | MatCodeExcelListener listener = new MatCodeExcelListener(getUserId()); |
| | |
| | | |
| | | // 打印 |
| | | @RequestMapping(value = "/matCode/print/auth") |
| | | @ManagerAuth(memo = "物料编码打印") |
| | | @ManagerAuth(memo = "商品编号打印") |
| | | public R matCodePrint(@RequestParam(value = "param[]") String[] param) { |
| | | if(Cools.isEmpty(param)) { |
| | | return R.parse(CodeRes.EMPTY); |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/macCode/code/auth") |
| | | // @ManagerAuth(memo = "物料编码条形码获取(type:1(条形码);2(二维码)") |
| | | // @ManagerAuth(memo = "商品编号条形码获取(type:1(条形码);2(二维码)") |
| | | public R matCodeBarcode(@RequestParam(defaultValue = "1") Integer type |
| | | , @RequestParam String param |
| | | , HttpServletResponse response) throws Exception { |