| | |
| | | import com.core.common.R; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import zy.cloud.wms.common.CodeRes; |
| | | import zy.cloud.wms.common.config.AdminInterceptor; |
| | | import zy.cloud.wms.common.utils.BarcodeUtils; |
| | | import zy.cloud.wms.common.utils.QrCode; |
| | | import zy.cloud.wms.common.web.BaseController; |
| | | import zy.cloud.wms.manager.entity.Mat; |
| | | import zy.cloud.wms.manager.entity.MatPrint; |
| | | import zy.cloud.wms.manager.service.MatService; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | // EntityWrapper<Mat> wrapper = new EntityWrapper<>(); |
| | | // excludeTrash(param); |
| | | // convert(param, wrapper); |
| | | // if (!Cools.isEmpty(orderByField)){ |
| | | // wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); |
| | | // } |
| | | // Page<Mat> page = matService.selectPage(new Page<>(curr, limit), wrapper); |
| | | // |
| | | // return R.ok().add(page); |
| | | Object tagId = param.get("tag_id"); |
| | | if (Cools.isEmpty(tagId)) { |
| | | tagId = getOriginTag().getId(); |
| | |
| | | @ManagerAuth |
| | | public R query(String condition) { |
| | | EntityWrapper<Mat> wrapper = new EntityWrapper<>(); |
| | | wrapper.like("id", condition); |
| | | wrapper.like("matnr", condition).or().like("maktx", condition); |
| | | Page<Mat> page = matService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Mat mat : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", mat.getId()); |
| | | map.put("value", mat.getId()); |
| | | map.put("value", mat.getMatnr() + "(" + mat.getMaktx() + ")"); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/mac/code/auth") |
| | | // @ManagerAuth(memo = "物料编码条形码获取(type:1(条形码);2(二维码)") |
| | | public R matCodeBarcode(@RequestParam(defaultValue = "1") Integer type |
| | | , @RequestParam String param |
| | | , HttpServletResponse response) throws Exception { |
| | | AdminInterceptor.cors(response); |
| | | if (Cools.isEmpty(param)){ |
| | | return R.parse(BaseRes.EMPTY); |
| | | } |
| | | BufferedImage img; |
| | | if (type == 1) { |
| | | img = BarcodeUtils.encode(param); |
| | | } else { |
| | | img = QrCode.createImg(param); |
| | | } |
| | | if (!ImageIO.write(img, "jpg", response.getOutputStream())) { |
| | | throw new IOException("Could not write an image of format jpg"); |
| | | } |
| | | response.getOutputStream().flush(); |
| | | response.getOutputStream().close(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | // 打印 |
| | | @RequestMapping(value = "/mat/print/auth") |
| | | @ManagerAuth(memo = "物料编码打印") |
| | | public R matCodePrint(@RequestParam(value = "param[]") String[] param) { |
| | | if(Cools.isEmpty(param)) { |
| | | return R.parse(CodeRes.EMPTY); |
| | | } |
| | | List<MatPrint> res = new ArrayList<>(); |
| | | for (String matnr : param){ |
| | | Mat mat = matService.selectByMatnr(matnr); |
| | | // 打印数据注入 |
| | | MatPrint print = new MatPrint(); |
| | | print.setMatnr(mat.getMatnr()); |
| | | print.setBarcode(mat.getBarcode()); |
| | | print.setMaktx(mat.getMaktx()); |
| | | print.setSpecs(mat.getSpecs()); |
| | | print.setUnit(mat.getUnit()); |
| | | res.add(print); |
| | | } |
| | | return R.ok().add(res); |
| | | } |
| | | |
| | | } |