| | |
| | | |
| | | @RequestMapping(value = "/mat/auto/matnr/auth") |
| | | public R autoMatnr(){ |
| | | return R.ok().add("YJ" + DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmsssss).substring(0, 16)); |
| | | R r = R.ok(); |
| | | r.put("data","YJ" + DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmsssss).substring(0, 16)); |
| | | return r; |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/list/pda/auth") |
| | | @ManagerAuth |
| | | @ManagerAuth(memo = "response.mat_pda_list") |
| | | public R pdaList(@RequestParam(required = true)Long tagId){ |
| | | EntityWrapper<Mat> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("tag_id", tagId); |
| | | wrapper.orderBy("create_time", false); |
| | | List<Mat> mats = matService.selectList(wrapper); |
| | | return R.ok().add(mats); |
| | | R r = R.ok(); |
| | | r.put("data",mats); |
| | | return r; |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/search/pda/auth") |
| | | @ManagerAuth |
| | | @ManagerAuth(memo = "response.mat_pda_search") |
| | | public R pdaSearch(@RequestParam(required = false)String condition){ |
| | | EntityWrapper<Mat> wrapper = new EntityWrapper<>(); |
| | | if (!Cools.isEmpty(condition)) { |
| | |
| | | } |
| | | wrapper.orderBy("create_time", false); |
| | | List<Mat> mats = matService.selectList(wrapper); |
| | | return R.ok().add(mats); |
| | | R r = R.ok(); |
| | | r.put("data",mats); |
| | | return r; |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/{id}/auth") |
| | | @ManagerAuth |
| | | @ManagerAuth(memo = "response.mat_detail") |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(matService.selectById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/auth") |
| | | @ManagerAuth |
| | | @ManagerAuth(memo = "response.mat_find") |
| | | public R find(@RequestParam("matnr") String matnr) { |
| | | return R.ok(matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnr))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/list/auth") |
| | | @ManagerAuth |
| | | @ManagerAuth(memo = "response.mat_list") |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/add/auth") |
| | | @ManagerAuth |
| | | @ManagerAuth(memo = "response.mat_add") |
| | | public R add(Mat mat) { |
| | | if (null != matService.selectByMatnr(mat.getMatnr())) { |
| | | return R.error("编号已存在"); |
| | | return R.error("response.code_exists"); |
| | | } |
| | | Date now = new Date(); |
| | | mat.setCreateBy(getUserId()); |
| | |
| | | mat.setUpdateTime(now); |
| | | mat.setStatus(1); |
| | | if (!matService.insert(mat)) { |
| | | throw new CoolException("添加失败,请联系管理员"); |
| | | throw new CoolException("response.add_failed_contact_admin"); |
| | | } |
| | | return R.ok(); |
| | | return R.ok("response.operation_success"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/update/auth") |
| | | @ManagerAuth |
| | | @ManagerAuth(memo = "response.mat_update") |
| | | public R update(Mat mat){ |
| | | if (Cools.isEmpty(mat) || null==mat.getId()){ |
| | | return R.error(); |
| | | return R.error("response.parameter_error"); |
| | | } |
| | | mat.setUpdateBy(getUserId()); |
| | | mat.setUpdateTime(new Date()); |
| | | matService.updateById(mat); |
| | | return R.ok(); |
| | | return R.ok("response.operation_success"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/delete/auth") |
| | | @ManagerAuth |
| | | @ManagerAuth(memo = "response.mat_delete") |
| | | public R delete(@RequestParam String param){ |
| | | List<Mat> list = JSONArray.parseArray(param, Mat.class); |
| | | if (Cools.isEmpty(list)){ |
| | | return R.error(); |
| | | return R.error("response.parameter_error"); |
| | | } |
| | | for (Mat entity : list){ |
| | | if (!matService.delete(new EntityWrapper<>(entity))) { |
| | | throw new CoolException("删除失败,请联系管理员"); |
| | | throw new CoolException("response.delete_failed_contact_admin"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | |
| | | map.put("desc", mat.getMatnr()); |
| | | result.add(map); |
| | | } |
| | | return R.ok().add(result); |
| | | R r = R.ok(); |
| | | r.put("data",result); |
| | | return r; |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/export/auth") |
| | | @ManagerAuth |
| | | @ManagerAuth(memo = "response.mat_export") |
| | | public R export(@RequestBody JSONObject param){ |
| | | EntityWrapper<Mat> wrapper = new EntityWrapper<>(); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | |
| | | public R query(@RequestBody JSONObject param) { |
| | | Wrapper<Mat> wrapper = new EntityWrapper<Mat>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | if (null != matService.selectOne(wrapper)){ |
| | | return R.parse(BaseRes.REPEAT).add(getComment(Mat.class, String.valueOf(param.get("key")))); |
| | | R r = R.parse(BaseRes.REPEAT); |
| | | r.put("data", getComment(Mat.class, String.valueOf(param.get("key")))); |
| | | return r; |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.sync(mat); |
| | | orderDetl.setAnfme(0.0D); |
| | | return R.ok().add(orderDetl); |
| | | R r = R.ok(); |
| | | r.put("data",orderDetl); |
| | | return r; |
| | | } |
| | | |
| | | /*************************************** 打印相关 ***********************************************/ |
| | |
| | | |
| | | // 打印 |
| | | @RequestMapping(value = "/mat/print/auth") |
| | | @ManagerAuth(memo = "商品编码打印") |
| | | @ManagerAuth(memo = "response.mat_code_print") |
| | | public R matCodePrint(@RequestParam(value = "param[]") String[] param) { |
| | | if(Cools.isEmpty(param)) { |
| | | return R.parse(CodeRes.EMPTY); |
| | |
| | | print.setMemo(mat.getMemo()); |
| | | res.add(print); |
| | | } |
| | | return R.ok().add(res); |
| | | R r = R.ok(); |
| | | r.put("data", res); |
| | | return r; |
| | | } |
| | | |
| | | |
| | |
| | | * excel导入模板下载 |
| | | */ |
| | | @RequestMapping(value = "/mat/excel/import/mould") |
| | | public void matExcelImportMould(HttpServletResponse response) throws IOException { |
| | | public void matExcelImportMould(HttpServletResponse response, @RequestParam(required = false, defaultValue = "zh-cn") String lang) throws IOException { |
| | | List<MatExcel> excels = new ArrayList<>(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("商品档案Excel导入模板", "UTF-8"); |
| | | boolean isEn = "en".equalsIgnoreCase(lang); |
| | | String fileNameStr = "response.mat_excel_template_name"; |
| | | String fileName = URLEncoder.encode(fileNameStr, "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | EasyExcel.write(response.getOutputStream(), MatExcel.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | |
| | | |
| | | // excel导入 |
| | | @PostMapping(value = "/mat/excel/import/auth") |
| | | @ManagerAuth(memo = "商品档案数据导入") |
| | | @ManagerAuth(memo = "response.mat_excel_import") |
| | | @Transactional |
| | | public R matExcelImport(MultipartFile file) throws IOException { |
| | | MatExcelListener listener = new MatExcelListener(getUserId()); |
| | | EasyExcel.read(file.getInputStream(), MatExcel.class, listener).sheet().doRead(); |
| | | return R.ok("成功同步"+listener.getTotal()+"条商品数据"); |
| | | R r = R.ok("response.sync_success_count"); |
| | | r.put("count", listener.getTotal()); |
| | | return r; |
| | | } |
| | | |
| | | /*************************************** xm-select ***********************************************/ |
| | |
| | | vo.setValue(mat.getMatnr()); |
| | | valueVos.add(vo); |
| | | } |
| | | return R.ok().add(valueVos); |
| | | R r = R.ok(); |
| | | r.put("data",valueVos); |
| | | return r; |
| | | } |
| | | |
| | | |