From ab9e3b55225455a503d40aec1a603f355e208ea7 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期四, 31 三月 2022 15:15:25 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/entity/MatPrint.java | 41 src/main/java/com/zy/asrs/utils/MatExcelListener.java | 153 ++ src/main/java/com/zy/common/web/BaseController.java | 8 src/main/webapp/static/js/mat/mat.js | 480 ++++++++ src/main/webapp/static/css/tree.css | 70 + src/main/webapp/views/mat/mat.html | 435 ++++++++ src/main/resources/mapper/TagMapper.xml | 30 src/main/java/com/zy/asrs/service/TagService.java | 12 src/main/java/com/zy/asrs/service/impl/MatServiceImpl.java | 25 src/main/webapp/views/resource/resource.html | 2 src/main/java/com/zy/asrs/entity/Tag.java | 415 +++++++ src/main/resources/mapper/RequestLogMapper.xml | 2 src/main/java/com/zy/asrs/mapper/MatMapper.java | 20 src/main/resources/mapper/MatMapper.xml | 63 + src/main/java/com/zy/asrs/entity/Mat.java | 304 +++++ src/main/java/com/zy/asrs/controller/MatController.java | 295 +++++ src/main/java/com/zy/asrs/service/MatService.java | 13 src/main/webapp/static/js/tagTree.js | 86 + src/main/java/com/zy/asrs/mapper/TagMapper.java | 12 src/main/java/com/zy/common/utils/ListUtils.java | 24 src/main/java/com/zy/asrs/service/impl/TagServiceImpl.java | 36 src/main/webapp/views/tag/tag.html | 303 +++++ src/main/resources/mapper/DocLogMapper.xml | 2 src/main/java/com/zy/common/utils/TreeUtils.java | 89 + src/main/java/com/zy/common/utils/NodeUtils.java | 46 src/main/java/com/zy/common/entity/MatExcel.java | 23 src/main/java/com/zy/asrs/controller/TagController.java | 191 +++ src/main/java/com/zy/asrs/entity/result/KeyValueVo.java | 15 28 files changed, 3,192 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/MatController.java b/src/main/java/com/zy/asrs/controller/MatController.java new file mode 100644 index 0000000..c8ef714 --- /dev/null +++ b/src/main/java/com/zy/asrs/controller/MatController.java @@ -0,0 +1,295 @@ +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.baomidou.mybatisplus.mapper.Wrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.core.annotations.ManagerAuth; +import com.core.common.*; +import com.core.exception.CoolException; +import com.zy.asrs.entity.Mat; +import com.zy.asrs.entity.MatPrint; +import com.zy.asrs.entity.result.KeyValueVo; +import com.zy.asrs.service.MatService; +import com.zy.asrs.utils.MatExcelListener; +import com.zy.common.CodeRes; +import com.zy.common.config.AdminInterceptor; +import com.zy.common.entity.MatExcel; +import com.zy.common.utils.BarcodeUtils; +import com.zy.common.utils.QrCode; +import com.zy.common.web.BaseController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.*; + +@RestController +public class MatController extends BaseController { + + @Autowired + private MatService matService; + @Autowired + private SnowflakeIdWorker snowflakeIdWorker; + + @RequestMapping(value = "/mat/auto/matnr/auth") + public R autoMatnr(){ + return R.ok().add("YJ" + DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmsssss).substring(0, 16)); + } + + @RequestMapping(value = "/mat/list/pda/auth") + @ManagerAuth + 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); + } + + @RequestMapping(value = "/mat/search/pda/auth") + @ManagerAuth + public R pdaSearch(@RequestParam(required = false)String condition){ + EntityWrapper<Mat> wrapper = new EntityWrapper<>(); + if (!Cools.isEmpty(condition)) { + wrapper.like("matnr", condition).or().like("maktx", condition); + } + wrapper.orderBy("create_time", false); + List<Mat> mats = matService.selectList(wrapper); + return R.ok().add(mats); + } + + @RequestMapping(value = "/mat/{id}/auth") + @ManagerAuth + public R get(@PathVariable("id") String id) { + return R.ok(matService.selectById(String.valueOf(id))); + } + + @RequestMapping(value = "/matCode/auth0") + @ManagerAuth + public R find(@RequestParam("matnr") String matnr) { + return R.ok(matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnr))); + } + + @RequestMapping(value = "/mat/list/auth") + @ManagerAuth + public R list(@RequestParam(defaultValue = "1")Integer curr, + @RequestParam(defaultValue = "10")Integer limit, + @RequestParam(required = false)String orderByField, + @RequestParam(required = false)String orderByType, + @RequestParam Map<String, Object> param){ + Object tagId = param.get("tag_id"); + if (Cools.isEmpty(tagId)) { + tagId = getOriginTag().getId(); + } + return R.ok(matService.getPage(new Page<>(curr, limit) + , String.valueOf(tagId) + , param.get("matnr") + , param.get("maktx")) + ); + + } + + private void convert(Map<String, Object> map, EntityWrapper wrapper){ + for (Map.Entry<String, Object> entry : map.entrySet()){ + String val = String.valueOf(entry.getValue()); + if (val.contains(RANGE_TIME_LINK)){ + String[] dates = val.split(RANGE_TIME_LINK); + wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); + wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); + } else { + wrapper.like(entry.getKey(), val); + } + } + } + + @RequestMapping(value = "/mat/add/auth") + @ManagerAuth + public R add(Mat mat) { + if (null != matService.selectByMatnr(mat.getMatnr())) { + return R.error("缂栧彿宸插瓨鍦�"); + } + Date now = new Date(); + mat.setCreateBy(getUserId()); + mat.setCreateTime(now); + mat.setUpdateBy(getUserId()); + mat.setUpdateTime(now); + mat.setStatus(1); + if (!matService.insert(mat)) { + throw new CoolException("娣诲姞澶辫触锛岃鑱旂郴绠$悊鍛�"); + } + return R.ok(); + } + + @RequestMapping(value = "/mat/update/auth") + @ManagerAuth + public R update(Mat mat){ + if (Cools.isEmpty(mat) || null==mat.getId()){ + return R.error(); + } + mat.setUpdateBy(getUserId()); + mat.setUpdateTime(new Date()); + matService.updateById(mat); + return R.ok(); + } + + @RequestMapping(value = "/mat/delete/auth") + @ManagerAuth + public R delete(@RequestParam String param){ + List<Mat> list = JSONArray.parseArray(param, Mat.class); + if (Cools.isEmpty(list)){ + return R.error(); + } + for (Mat entity : list){ + if (!matService.delete(new EntityWrapper<>(entity))) { + throw new CoolException("鍒犻櫎澶辫触锛岃鑱旂郴绠$悊鍛�"); + } + } + return R.ok(); + } + + @RequestMapping(value = "/mat/export/auth") + @ManagerAuth + public R export(@RequestBody JSONObject param){ + EntityWrapper<Mat> wrapper = new EntityWrapper<>(); + List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); + Map<String, Object> map = excludeTrash(param.getJSONObject("mat")); + convert(map, wrapper); + List<Mat> list = matService.selectList(wrapper); + return R.ok(exportSupport(list, fields)); + } + + @RequestMapping(value = "/matQuery/auth") + @ManagerAuth + public R query(String condition) { + EntityWrapper<Mat> wrapper = new EntityWrapper<>(); + 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.getMatnr() + "(" + mat.getMaktx() + ")"); + result.add(map); + } + return R.ok(result); + } + + @RequestMapping(value = "/mat/check/column/auth") + @ManagerAuth + 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")))); + } + 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()); + print.setMemo(mat.getMemo()); + res.add(print); + } + return R.ok().add(res); + } + + + /*************************************** 鏁版嵁鐩稿叧 ***********************************************/ + + /** + * excel瀵煎叆妯℃澘涓嬭浇 + */ + @RequestMapping(value = "/mat/excel/import/mould") + public void matExcelImportMould(HttpServletResponse response) throws IOException { + List<MatExcel> excels = new ArrayList<>(); + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("鍟嗗搧妗fExcel瀵煎叆妯℃澘", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), MatExcel.class) + .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) + .sheet("sheet1") + .doWrite(excels); + } + + // excel瀵煎叆 + @PostMapping(value = "/mat/excel/import/auth") + @ManagerAuth(memo = "鍟嗗搧妗f鏁版嵁瀵煎叆") + @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()+"鏉″晢鍝佹暟鎹�"); + } + + /*************************************** xm-select ***********************************************/ + + // xm-select 鎼滅储鍟嗗搧鍒楄〃 + @RequestMapping("/mat/all/get/kv0") // todo:luxiaotao + @ManagerAuth + public R getMatDataKV(@RequestParam(required = false) String condition) { + Wrapper<Mat> wrapper = new EntityWrapper<Mat>() + .andNew().like("matnr", condition).or().like("maktx", condition) + .orderBy("create_time", false); + List<Mat> mats = matService.selectPage(new Page<>(1, 30), wrapper).getRecords(); + List<KeyValueVo> valueVos = new ArrayList<>(); + for (Mat mat : mats) { + KeyValueVo vo = new KeyValueVo(); + vo.setName(mat.getMatnr() + " - " + mat.getMaktx()); + vo.setValue(mat.getId()); + valueVos.add(vo); + } + return R.ok().add(valueVos); + } + + +} diff --git a/src/main/java/com/zy/asrs/controller/TagController.java b/src/main/java/com/zy/asrs/controller/TagController.java new file mode 100644 index 0000000..8fd2db1 --- /dev/null +++ b/src/main/java/com/zy/asrs/controller/TagController.java @@ -0,0 +1,191 @@ +package com.zy.asrs.controller; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.core.annotations.ManagerAuth; +import com.core.common.BaseRes; +import com.core.common.Cools; +import com.core.common.DateUtils; +import com.core.common.R; +import com.zy.asrs.entity.Tag; +import com.zy.asrs.service.TagService; +import com.zy.common.utils.ListUtils; +import com.zy.common.utils.NodeUtils; +import com.zy.common.utils.TreeUtils; +import com.zy.common.web.BaseController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.util.*; + +@RestController +public class TagController extends BaseController { + + @Autowired + private TagService tagService; + @Autowired + private TreeUtils treeUtils; + + @RequestMapping(value = "/tag/list/pda/auth") + @ManagerAuth + public R pdaList(@RequestParam(defaultValue = "1")Integer curr, + @RequestParam(defaultValue = "10")Integer limit, + @RequestParam(required = false)Long parentId){ + EntityWrapper<Tag> wrapper = new EntityWrapper<>(); + wrapper.eq("parent_id", parentId==null?getOriginTag().getId():parentId); + wrapper.orderBy("sort"); + List<Tag> tags = tagService.selectList(wrapper); + return R.ok().add(tags); + } + + @RequestMapping(value = "/tag/{id}/auth") + @ManagerAuth + public R get(@PathVariable("id") String id) { + return R.ok(tagService.selectById(String.valueOf(id))); + } + + @RequestMapping(value = "/tag/list/auth") + @ManagerAuth + public R list(@RequestParam(defaultValue = "1")Integer curr, + @RequestParam(defaultValue = "10")Integer limit, + @RequestParam(required = false)String orderByField, + @RequestParam(required = false)String orderByType, + @RequestParam Map<String, Object> param){ + EntityWrapper<Tag> wrapper = new EntityWrapper<>(); + excludeTrash(param); + convert(param, wrapper); + if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} + return R.parse("0-鎿嶄綔鎴愬姛").add(tagService.selectList(wrapper)); + } + + private void convert(Map<String, Object> map, EntityWrapper wrapper){ + for (Map.Entry<String, Object> entry : map.entrySet()){ + String val = String.valueOf(entry.getValue()); + if (val.contains(RANGE_TIME_LINK)){ + String[] dates = val.split(RANGE_TIME_LINK); + wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); + wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); + } else { + wrapper.like(entry.getKey(), val); + } + } + } + + @RequestMapping(value = "/tag/add/auth") + @ManagerAuth + public R add(Tag tag) { + tag.setLevel(1); + if (tag.getParentId() != null && tag.getParentId() > 0) { + Tag parent = tagService.selectById(tag.getParentId()); + if (parent != null) { + tag.setParentName(parent.getName()); + tag.setLevel(parent.getLevel() + 1); + } + } else { + tag.setParentId(0L); + } + // path + NodeUtils nodeUtils = new NodeUtils(); + nodeUtils.executePath(tag); + tag.setPath(nodeUtils.path.toString()); + tag.setPathName(nodeUtils.pathName.toString()); + + tag.setCreateBy(getUserId()); + tag.setCreateTime(new Date()); + tag.setUpdateBy(getUserId()); + tag.setUpdateTime(new Date()); + tag.setStatus(1); + tagService.insert(tag); + return R.ok(); + } + + @RequestMapping(value = "/tag/update/auth") + @ManagerAuth + public R update(Tag tag){ + if (Cools.isEmpty(tag) || null==tag.getId()){ + return R.error(); + } + if (tag.getParentId() != null && tag.getParentId() > 0) { + if (tag.getParentId().equals(tag.getId())) { + return R.error("鏁版嵁閿欒"); + } + Tag parent = tagService.selectById(tag.getParentId()); + if (parent != null) { + tag.setParentName(parent.getName()); + tag.setLevel(parent.getLevel() + 1); + } + } + // path + NodeUtils nodeUtils = new NodeUtils(); + nodeUtils.executePath(tag); + tag.setPath(nodeUtils.path.toString()); + tag.setPathName(nodeUtils.pathName.toString()); + tag.setUpdateBy(getUserId()); + tag.setUpdateTime(new Date()); + tagService.updateById(tag); + return R.ok(); + } + + @RequestMapping(value = "/tag/delete/auth") + @ManagerAuth + public R delete(@RequestParam(value="ids[]") Long[] ids){ + for (Long id : ids){ + tagService.deleteById(id); + } + return R.ok(); + } + + @RequestMapping(value = "/tag/export/auth") + @ManagerAuth + public R export(@RequestBody JSONObject param){ + EntityWrapper<Tag> wrapper = new EntityWrapper<>(); + List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); + Map<String, Object> map = excludeTrash(param.getJSONObject("tag")); + convert(map, wrapper); + List<Tag> list = tagService.selectList(wrapper); + return R.ok(exportSupport(list, fields)); + } + + @RequestMapping(value = "/tagQuery/auth") + @ManagerAuth + public R query(String condition) { + EntityWrapper<Tag> wrapper = new EntityWrapper<>(); + wrapper.like("uuid", condition).or().like("name", condition); + Page<Tag> page = tagService.selectPage(new Page<>(0, 10), wrapper); + List<Map<String, Object>> result = new ArrayList<>(); + for (Tag tag : page.getRecords()){ + Map<String, Object> map = new HashMap<>(); + map.put("id", tag.getId()); + map.put("value", tag.getName()); + result.add(map); + } + return R.ok(result); + } + + @RequestMapping(value = "/tag/check/column/auth") + @ManagerAuth + public R query(@RequestBody JSONObject param) { + Wrapper<Tag> wrapper = new EntityWrapper<Tag>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); + if (null != tagService.selectOne(wrapper)){ + return R.parse(BaseRes.REPEAT).add(getComment(Tag.class, String.valueOf(param.get("key")))); + } + return R.ok(); + } + + @PostMapping(value = "/tag/tree/auth") + @ManagerAuth + public R tree(@RequestParam(required = false, defaultValue = "") String condition) throws IOException, ClassNotFoundException { + ArrayList<Map> tree = treeUtils.getTree(String.valueOf(getOriginTag().getId())); + // 娣辨嫹璐� + List<Map> result = ListUtils.deepCopy(tree); + if (!Cools.isEmpty(condition)) { + treeUtils.remove(condition, result); + treeUtils.remove(condition, result); + } + return R.ok(result); + } + +} diff --git a/src/main/java/com/zy/asrs/entity/Mat.java b/src/main/java/com/zy/asrs/entity/Mat.java new file mode 100644 index 0000000..ecd9b5f --- /dev/null +++ b/src/main/java/com/zy/asrs/entity/Mat.java @@ -0,0 +1,304 @@ +package com.zy.asrs.entity; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import com.core.common.Cools; +import com.core.common.SpringUtils; +import com.zy.asrs.service.TagService; +import com.zy.system.entity.User; +import com.zy.system.service.UserService; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.Date; + +@Data +@TableName("man_mat") +public class Mat implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableField(exist = false) + private Double stock; + + public Double getStock() { + return stock; + } + + public void setStock(Double stock) { + this.stock = stock; + } + + /** + * ID + */ + @ApiModelProperty(value= "ID") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 缂栧彿 + */ + @ApiModelProperty(value= "缂栧彿") + private String uuid; + + /** + * 鎵�灞炲尯鍩� + */ + @ApiModelProperty(value= "鎵�灞炲尯鍩�") + @TableField("node_id") + private Long nodeId; + + /** + * 鎵�灞炲綊绫� + */ + @ApiModelProperty(value= "鎵�灞炲綊绫�") + @TableField("tag_id") + private Long tagId; + + /** + * 鍟嗗搧缂栧彿 + */ + @ExcelProperty(index = 2, value = "鍟嗗搧缂栧彿") + @ApiModelProperty(value= "鍟嗗搧缂栧彿") + private String matnr; + + /** + * 鍟嗗搧鍚嶇О + */ + @ExcelProperty(index = 3, value = "鍟嗗搧鍚嶇О") + @ApiModelProperty(value= "鍟嗗搧鍚嶇О") + private String maktx; + + /** + * 鍚嶇О + */ + @ApiModelProperty(value= "鍚嶇О") + private String name; + + /** + * 瑙勬牸 + */ + @ExcelProperty(index = 4, value = "瑙勬牸") + @ApiModelProperty(value= "瑙勬牸") + private String specs; + + /** + * 鍨嬪彿 + */ + @ExcelProperty(index = 5, value = "鍨嬪彿") + @ApiModelProperty(value= "鍨嬪彿") + private String model; + + /** + * 鎵瑰彿 + */ + @ExcelProperty(index = 6, value = "鎵瑰彿") + @ApiModelProperty(value= "鎵瑰彿") + private String batch; + + /** + * 鍗曚綅 + */ + @ExcelProperty(index = 7, value = "鍗曚綅") + @ApiModelProperty(value= "鍗曚綅") + private String unit; + + /** + * SKC + */ + @ExcelProperty(index = 8, value = "SKC") + @ApiModelProperty(value= "SKC") + private String barcode; + + /** + * 鍗曟嵁绫诲瀷 + */ + @ApiModelProperty(value= "鍗曟嵁绫诲瀷") + @TableField("doc_id") + private Long docId; + + /** + * 鍗曟嵁缂栧彿 + */ + @ApiModelProperty(value= "鍗曟嵁缂栧彿") + @TableField("doc_num") + private String docNum; + + /** + * 瀹㈡埛鍚嶇О + */ + @ApiModelProperty(value= "瀹㈡埛鍚嶇О") + @TableField("cust_name") + private String custName; + + /** + * 鍝侀」鏁� + */ + @ApiModelProperty(value= "鍝侀」鏁�") + @TableField("item_num") + private Integer itemNum; + + /** + * 搴撳瓨浣欓噺 + */ + @ApiModelProperty(value= "搴撳瓨浣欓噺") + private Integer count; + + /** + * 鍗曚环 + */ + @ExcelProperty(index = 9, value = "鍗曚环") + @ApiModelProperty(value= "鍗曚环") + private Double price; + + /** + * 閲嶉噺 + */ + @ExcelProperty(index = 10, value = "閲嶉噺") + @ApiModelProperty(value= "閲嶉噺") + private Double weight; + + @ApiModelProperty(value= "") + private Integer status; + + /** + * 娣诲姞浜哄憳 + */ + @ApiModelProperty(value= "娣诲姞浜哄憳") + @TableField("create_by") + private Long createBy; + + /** + * 娣诲姞鏃堕棿 + */ + @ApiModelProperty(value= "娣诲姞鏃堕棿") + @TableField("create_time") + private Date createTime; + + /** + * 淇敼浜哄憳 + */ + @ApiModelProperty(value= "淇敼浜哄憳") + @TableField("update_by") + private Long updateBy; + + /** + * 淇敼鏃堕棿 + */ + @ApiModelProperty(value= "淇敼鏃堕棿") + @TableField("update_time") + private Date updateTime; + + /** + * 澶囨敞 + */ + @ExcelProperty(index = 11, value = "澶囨敞") + @ApiModelProperty(value= "澶囨敞") + private String memo; + + public Mat() {} + + public Mat(String uuid,Long nodeId,Long tagId,String matnr,String maktx,String name,String specs,String model,String batch,String unit,String barcode,Long docId,String docNum,String custName,Integer itemNum,Integer count,Double weight,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { + this.uuid = uuid; + this.nodeId = nodeId; + this.tagId = tagId; + this.matnr = matnr; + this.maktx = maktx; + this.name = name; + this.specs = specs; + this.model = model; + this.batch = batch; + this.unit = unit; + this.barcode = barcode; + this.docId = docId; + this.docNum = docNum; + this.custName = custName; + this.itemNum = itemNum; + this.count = count; + this.weight = weight; + this.status = status; + this.createBy = createBy; + this.createTime = createTime; + this.updateBy = updateBy; + this.updateTime = updateTime; + this.memo = memo; + } + +// Mat mat = new Mat( +// null, // 缂栧彿 +// null, // 鎵�灞炲尯鍩� +// null, // 鎵�灞炲綊绫� +// null, // 鍟嗗搧缂栧彿 +// null, // 鍟嗗搧鍚嶇О +// null, // 鍚嶇О +// null, // 瑙勬牸 +// null, // 鍨嬪彿 +// null, // 鎵瑰彿 +// null, // 鍗曚綅 +// null, // SKC +// null, // 鍗曟嵁绫诲瀷 +// null, // 鍗曟嵁缂栧彿 +// null, // 瀹㈡埛鍚嶇О +// null, // 鍝侀」鏁� +// null, // 搴撳瓨浣欓噺 +// null, // 閲嶉噺 +// null, // +// null, // 娣诲姞浜哄憳 +// null, // 娣诲姞鏃堕棿 +// null, // 淇敼浜哄憳 +// null, // 淇敼鏃堕棿 +// null // 澶囨敞 +// ); + + public String getTagId$(){ + TagService service = SpringUtils.getBean(TagService.class); + Tag tag = service.selectById(this.tagId); + if (!Cools.isEmpty(tag)){ + return String.valueOf(tag.getName()); + } + return null; + } + + public String getCreateBy$(){ + UserService service = SpringUtils.getBean(UserService.class); + User user = service.selectById(this.createBy); + if (!Cools.isEmpty(user)){ + return String.valueOf(user.getNickname()); + } + return null; + } + + public String getCreateTime$(){ + if (Cools.isEmpty(this.createTime)){ + return ""; + } + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); + } + + public Long getUpdateBy() { + return updateBy; + } + + public String getUpdateBy$(){ + UserService service = SpringUtils.getBean(UserService.class); + User user = service.selectById(this.updateBy); + if (!Cools.isEmpty(user)){ + return String.valueOf(user.getNickname()); + } + return null; + } + + public String getUpdateTime$(){ + if (Cools.isEmpty(this.updateTime)){ + return ""; + } + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime); + } + +} diff --git a/src/main/java/com/zy/asrs/entity/MatPrint.java b/src/main/java/com/zy/asrs/entity/MatPrint.java new file mode 100644 index 0000000..486d708 --- /dev/null +++ b/src/main/java/com/zy/asrs/entity/MatPrint.java @@ -0,0 +1,41 @@ +package com.zy.asrs.entity; + +import lombok.Data; + +/** + * Created by vincent on 2020/6/8 + */ +@Data +public class MatPrint { + + /** + * 鐗╂枡缂栫爜 + */ + private String matnr; + + /** + * SKC + */ + private String barcode; + + /** + * 鐗╂枡鍚嶇О + */ + private String maktx; + + /** + * 鐗╂枡鍗曚綅 + */ + private String unit; + + /** + * 鐗╂枡瑙勬牸 + */ + private String specs; + + /** + * 澶囨敞 + */ + private String memo; + +} diff --git a/src/main/java/com/zy/asrs/entity/Tag.java b/src/main/java/com/zy/asrs/entity/Tag.java new file mode 100644 index 0000000..d5e843c --- /dev/null +++ b/src/main/java/com/zy/asrs/entity/Tag.java @@ -0,0 +1,415 @@ +package com.zy.asrs.entity; + +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import com.core.common.Cools; +import com.core.common.SpringUtils; +import com.zy.system.entity.User; +import com.zy.system.service.UserService; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.Date; + +@TableName("man_tag") +public class Tag implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + @ApiModelProperty(value= "ID") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 缂栧彿 + */ + @ApiModelProperty(value= "缂栧彿") + private String uuid; + + /** + * 鍚嶇О + */ + @ApiModelProperty(value= "鍚嶇О") + private String name; + + /** + * 鐖剁骇 + */ + @ApiModelProperty(value= "鐖剁骇") + @TableField("parent_id") + private Long parentId; + + /** + * 鐖剁骇鍚嶇О + */ + @ApiModelProperty(value= "鐖剁骇鍚嶇О") + @TableField("parent_name") + private String parentName; + + /** + * 鍏宠仈璺緞 + */ + @ApiModelProperty(value= "鍏宠仈璺緞") + private String path; + + /** + * 鍏宠仈璺緞鍚� + */ + @ApiModelProperty(value= "鍏宠仈璺緞鍚�") + @TableField("path_name") + private String pathName; + + /** + * 绫诲瀷 1: 鐩掕 2: 琚嬭 0: 鍏朵粬 + */ + @ApiModelProperty(value= "绫诲瀷 1: 鐩掕 2: 琚嬭 0: 鍏朵粬 ") + private Integer type; + + /** + * 璐熻矗浜� + */ + @ApiModelProperty(value= "璐熻矗浜�") + private String leading; + + /** + * 鍥剧墖 + */ + @ApiModelProperty(value= "鍥剧墖") + private String img; + + /** + * 绠�瑕佹弿杩� + */ + @ApiModelProperty(value= "绠�瑕佹弿杩�") + private String brief; + + /** + * 鏁伴噺 + */ + @ApiModelProperty(value= "鏁伴噺") + private Integer count; + + /** + * 绛夌骇 + */ + @ApiModelProperty(value= "绛夌骇") + private Integer level; + + /** + * 鎺掑簭 + */ + @ApiModelProperty(value= "鎺掑簭") + private Integer sort; + + /** + * 鐘舵�� 1: 姝e父 0: 绂佺敤 + */ + @ApiModelProperty(value= "鐘舵�� 1: 姝e父 0: 绂佺敤 ") + private Integer status; + + /** + * 娣诲姞鏃堕棿 + */ + @ApiModelProperty(value= "娣诲姞鏃堕棿") + @TableField("create_time") + private Date createTime; + + /** + * 娣诲姞浜哄憳 + */ + @ApiModelProperty(value= "娣诲姞浜哄憳") + @TableField("create_by") + private Long createBy; + + /** + * 淇敼鏃堕棿 + */ + @ApiModelProperty(value= "淇敼鏃堕棿") + @TableField("update_time") + private Date updateTime; + + /** + * 淇敼浜哄憳 + */ + @ApiModelProperty(value= "淇敼浜哄憳") + @TableField("update_by") + private Long updateBy; + + /** + * 澶囨敞 + */ + @ApiModelProperty(value= "澶囨敞") + private String memo; + + public Tag() {} + + public Tag(String uuid,String name,Long parentId,String parentName,String path,String pathName,Integer type,String leading,String img,String brief,Integer count,Integer level,Integer sort,Integer status,Date createTime,Long createBy,Date updateTime,Long updateBy,String memo) { + this.uuid = uuid; + this.name = name; + this.parentId = parentId; + this.parentName = parentName; + this.path = path; + this.pathName = pathName; + this.type = type; + this.leading = leading; + this.img = img; + this.brief = brief; + this.count = count; + this.level = level; + this.sort = sort; + this.status = status; + this.createTime = createTime; + this.createBy = createBy; + this.updateTime = updateTime; + this.updateBy = updateBy; + this.memo = memo; + } + +// Tag tag = new Tag( +// null, // 缂栧彿 +// null, // 鍚嶇О +// null, // 鐖剁骇 +// null, // 鐖剁骇鍚嶇О +// null, // 鍏宠仈璺緞 +// null, // 鍏宠仈璺緞鍚� +// null, // 绫诲瀷 +// null, // 璐熻矗浜� +// null, // 鍥剧墖 +// null, // 绠�瑕佹弿杩� +// null, // 鏁伴噺 +// null, // 绛夌骇 +// null, // 鎺掑簭 +// null, // 鐘舵�� +// null, // 娣诲姞鏃堕棿 +// null, // 娣诲姞浜哄憳 +// null, // 淇敼鏃堕棿 +// null, // 淇敼浜哄憳 +// null // 澶囨敞 +// ); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public String getParentName() { + return parentName; + } + + public void setParentName(String parentName) { + this.parentName = parentName; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getPathName() { + return pathName; + } + + public void setPathName(String pathName) { + this.pathName = pathName; + } + + public Integer getType() { + return type; + } + + public String getType$(){ + if (null == this.type){ return null; } + switch (this.type){ + case 1: + return "鐩掕"; + case 2: + return "琚嬭"; + case 0: + return "鍏朵粬"; + default: + return String.valueOf(this.type); + } + } + + public void setType(Integer type) { + this.type = type; + } + + public String getLeading() { + return leading; + } + + public void setLeading(String leading) { + this.leading = leading; + } + + public String getImg() { + return img; + } + + public void setImg(String img) { + this.img = img; + } + + public String getBrief() { + return brief; + } + + public void setBrief(String brief) { + this.brief = brief; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public Integer getStatus() { + return status; + } + + public String getStatus$(){ + if (null == this.status){ return null; } + switch (this.status){ + case 1: + return "姝e父"; + case 0: + return "绂佺敤"; + default: + return String.valueOf(this.status); + } + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public String getCreateTime$(){ + if (Cools.isEmpty(this.createTime)){ + return ""; + } + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Long getCreateBy() { + return createBy; + } + + public String getCreateBy$(){ + UserService service = SpringUtils.getBean(UserService.class); + User user = service.selectById(this.createBy); + if (!Cools.isEmpty(user)){ + return String.valueOf(user.getNickname()); + } + return null; + } + + public void setCreateBy(Long createBy) { + this.createBy = createBy; + } + + public Date getUpdateTime() { + return updateTime; + } + + public String getUpdateTime$(){ + if (Cools.isEmpty(this.updateTime)){ + return ""; + } + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime); + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Long getUpdateBy() { + return updateBy; + } + + public String getUpdateBy$(){ + UserService service = SpringUtils.getBean(UserService.class); + User user = service.selectById(this.updateBy); + if (!Cools.isEmpty(user)){ + return String.valueOf(user.getNickname()); + } + return null; + } + + public void setUpdateBy(Long updateBy) { + this.updateBy = updateBy; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } + + +} diff --git a/src/main/java/com/zy/asrs/entity/result/KeyValueVo.java b/src/main/java/com/zy/asrs/entity/result/KeyValueVo.java new file mode 100644 index 0000000..a752c4a --- /dev/null +++ b/src/main/java/com/zy/asrs/entity/result/KeyValueVo.java @@ -0,0 +1,15 @@ +package com.zy.asrs.entity.result; + +import lombok.Data; + +/** + * Created by vincent on 2021/4/13 + */ +@Data +public class KeyValueVo { + + private String name; + + private Long value; + +} diff --git a/src/main/java/com/zy/asrs/mapper/MatMapper.java b/src/main/java/com/zy/asrs/mapper/MatMapper.java new file mode 100644 index 0000000..22e0d28 --- /dev/null +++ b/src/main/java/com/zy/asrs/mapper/MatMapper.java @@ -0,0 +1,20 @@ +package com.zy.asrs.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.baomidou.mybatisplus.plugins.Page; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; +import com.zy.asrs.entity.Mat; + +import java.util.List; + +@Mapper +@Repository +public interface MatMapper extends BaseMapper<Mat> { + + List<Mat> listByPage(Page page, @Param("tagId") String tagId, @Param("matnr") Object matnr, @Param("maktx") Object maktx); + + Mat selectByMatnr(@Param("matnr")String matnr); + +} diff --git a/src/main/java/com/zy/asrs/mapper/TagMapper.java b/src/main/java/com/zy/asrs/mapper/TagMapper.java new file mode 100644 index 0000000..56a9292 --- /dev/null +++ b/src/main/java/com/zy/asrs/mapper/TagMapper.java @@ -0,0 +1,12 @@ +package com.zy.asrs.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; +import com.zy.asrs.entity.Tag; + +@Mapper +@Repository +public interface TagMapper extends BaseMapper<Tag> { + +} diff --git a/src/main/java/com/zy/asrs/service/MatService.java b/src/main/java/com/zy/asrs/service/MatService.java new file mode 100644 index 0000000..3b4b655 --- /dev/null +++ b/src/main/java/com/zy/asrs/service/MatService.java @@ -0,0 +1,13 @@ +package com.zy.asrs.service; + +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.IService; +import com.zy.asrs.entity.Mat; + +public interface MatService extends IService<Mat> { + + Page<Mat> getPage(Page page, String tagId, Object matnr, Object maktx); + + Mat selectByMatnr(String matnr); + +} diff --git a/src/main/java/com/zy/asrs/service/TagService.java b/src/main/java/com/zy/asrs/service/TagService.java new file mode 100644 index 0000000..2112402 --- /dev/null +++ b/src/main/java/com/zy/asrs/service/TagService.java @@ -0,0 +1,12 @@ +package com.zy.asrs.service; + +import com.baomidou.mybatisplus.service.IService; +import com.zy.asrs.entity.Tag; + +public interface TagService extends IService<Tag> { + + Tag getTop(); + + Tag selectByName(String name, Integer level); + +} diff --git a/src/main/java/com/zy/asrs/service/impl/MatServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MatServiceImpl.java new file mode 100644 index 0000000..8abf584 --- /dev/null +++ b/src/main/java/com/zy/asrs/service/impl/MatServiceImpl.java @@ -0,0 +1,25 @@ +package com.zy.asrs.service.impl; + +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import com.zy.asrs.entity.Mat; +import com.zy.asrs.mapper.MatMapper; +import com.zy.asrs.service.MatService; + +@Service("matService") +public class MatServiceImpl extends ServiceImpl<MatMapper, Mat> implements MatService { + + @Override + public Page<Mat> getPage(Page page, String tagId, Object matnr, Object maktx) { + return page.setRecords(baseMapper.listByPage(page, tagId, matnr, maktx)); + } + + + @Override + public Mat selectByMatnr(String matnr) { + return this.baseMapper.selectByMatnr(matnr); + } + + +} diff --git a/src/main/java/com/zy/asrs/service/impl/TagServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/TagServiceImpl.java new file mode 100644 index 0000000..e8255ae --- /dev/null +++ b/src/main/java/com/zy/asrs/service/impl/TagServiceImpl.java @@ -0,0 +1,36 @@ +package com.zy.asrs.service.impl; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.core.exception.CoolException; +import org.springframework.stereotype.Service; +import com.zy.asrs.entity.Tag; +import com.zy.asrs.mapper.TagMapper; +import com.zy.asrs.service.TagService; + +@Service("tagService") +public class TagServiceImpl extends ServiceImpl<TagMapper, Tag> implements TagService { + + @Override + public synchronized Tag getTop() { + Tag top = this.selectOne(new EntityWrapper<Tag>().eq("level", 1)); + if (top == null) { + top = new Tag(); + top.setName("鍏ㄩ儴"); + top.setType(0); + top.setLevel(1); + top.setStatus(1); + top.setSort(0); + Integer insert = this.baseMapper.insert(top); + if (insert == 0) { + throw new CoolException("鏈嶅姟鍣ㄥ紓甯�"); + } + } + return top; + } + + @Override + public Tag selectByName(String name, Integer level) { + return this.selectOne(new EntityWrapper<Tag>().eq("name", name).eq("level", level)); + } +} diff --git a/src/main/java/com/zy/asrs/utils/MatExcelListener.java b/src/main/java/com/zy/asrs/utils/MatExcelListener.java new file mode 100644 index 0000000..0c7ff89 --- /dev/null +++ b/src/main/java/com/zy/asrs/utils/MatExcelListener.java @@ -0,0 +1,153 @@ +package com.zy.asrs.utils; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.core.common.Cools; +import com.core.common.SpringUtils; +import com.core.exception.CoolException; +import com.zy.asrs.entity.Mat; +import com.zy.asrs.entity.Tag; +import com.zy.asrs.mapper.TagMapper; +import com.zy.asrs.service.MatService; +import com.zy.asrs.service.TagService; +import com.zy.common.entity.MatExcel; +import com.zy.common.utils.NodeUtils; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * Created by vincent on 2019-11-25 + */ +@Slf4j +public class MatExcelListener extends AnalysisEventListener<MatExcel> { + + private int total = 0; + private Long userId; + + public MatExcelListener() { + } + + public MatExcelListener(Long userId) { + this.userId = userId; + } + + /** + * 姣忛殧5鏉″瓨鍌ㄦ暟鎹簱锛屽疄闄呬娇鐢ㄤ腑鍙互3000鏉★紝鐒跺悗娓呯悊list 锛屾柟渚垮唴瀛樺洖鏀� + */ + private static final int BATCH_COUNT = 50; + + private final List<MatExcel> list = new ArrayList<>(); + + /** + * 杩欓噷浼氫竴琛岃鐨勮繑鍥炲ご + */ + @Override + public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { + } + + /** + * 杩欎釜姣忎竴鏉℃暟鎹В鏋愰兘浼氭潵璋冪敤 + */ + @Override + public void invoke(MatExcel excel, AnalysisContext ctx) { + TagService tagService = SpringUtils.getBean(TagService.class); + TagMapper tagMapper = SpringUtils.getBean(TagMapper.class); + MatService matService = SpringUtils.getBean(MatService.class); + Date now = new Date(); + Long tagId; + // 鍒嗙被 + // 涓�绾у垎绫� + if (!Cools.isEmpty(excel.getPriClass()) && !Cools.isEmpty(excel.getSecClass())) { + Tag priTag = tagService.selectByName(excel.getPriClass(), 2); + if (priTag == null) { + Tag top = tagService.getTop(); + NodeUtils nodeUtils = new NodeUtils(); + nodeUtils.executePath(top.getId()); + priTag = new Tag( + null, // 缂栧彿 + excel.getPriClass(), // 鍚嶇О + top.getId(), // 鐖剁骇 + top.getName(), // 鐖剁骇鍚嶇О + nodeUtils.path.toString(), // 鍏宠仈璺緞 + nodeUtils.pathName.toString(), // 鍏宠仈璺緞鍚� + 0, // 绫诲瀷 + null, // 璐熻矗浜� + null, // 鍥剧墖 + null, // 绠�瑕佹弿杩� + null, // 鏁伴噺 + 2, // 绛夌骇 + null, // 鎺掑簭 + 1, // 鐘舵�� + now, // 娣诲姞鏃堕棿 + null, // 娣诲姞浜哄憳 + now, // 淇敼鏃堕棿 + null, // 淇敼浜哄憳 + null // 澶囨敞 + ); + if (tagMapper.insert(priTag) == 0) { + throw new CoolException("淇濆瓨涓�绾у垎绫诲け璐�"); + } + } + // 浜岀骇鍒嗙被 + Tag secTag = tagService.selectByName(excel.getSecClass(), 3); + if (secTag == null) { + NodeUtils nodeUtils = new NodeUtils(); + nodeUtils.executePath(priTag.getId()); + secTag = new Tag( + null, // 缂栧彿 + excel.getSecClass(), // 鍚嶇О + priTag.getId(), // 鐖剁骇 + priTag.getName(), // 鐖剁骇鍚嶇О + nodeUtils.path.toString(), // 鍏宠仈璺緞 + nodeUtils.pathName.toString(), // 鍏宠仈璺緞鍚� + 0, // 绫诲瀷 + null, // 璐熻矗浜� + null, // 鍥剧墖 + null, // 绠�瑕佹弿杩� + null, // 鏁伴噺 + 3, // 绛夌骇 + null, // 鎺掑簭 + 1, // 鐘舵�� + now, // 娣诲姞鏃堕棿 + null, // 娣诲姞浜哄憳 + now, // 淇敼鏃堕棿 + null, // 淇敼浜哄憳 + null // 澶囨敞 + ); + if (tagMapper.insert(secTag) == 0) { + throw new CoolException("淇濆瓨浜岀骇鍒嗙被澶辫触"); + } + } + tagId = secTag.getId(); + } else { + tagId = tagService.getTop().getId(); + } + // 鍟嗗搧 + Mat mat = matService.selectByMatnr(excel.getMatnr()); + if (mat == null) { + mat = excel; + mat.setTagId(tagId); + if (!matService.insert(mat)) { + throw new CoolException("淇濆瓨鍟嗗搧淇℃伅澶辫触锛屽晢鍝佺紪鐮侊細" + excel.getMatnr()); + } + total++; + } + } + + /** + * 鎵�鏈夋暟鎹В鏋愬畬鎴愪簡璋冪敤 + * 閫傚悎浜嬪姟 + */ + @Override + public void doAfterAllAnalysed(AnalysisContext ctx) { + log.info("鏂板{}鏉$墿鏂欎俊鎭紒", total); + } + + public int getTotal() { + return total; + } +} diff --git a/src/main/java/com/zy/common/entity/MatExcel.java b/src/main/java/com/zy/common/entity/MatExcel.java new file mode 100644 index 0000000..640c0de --- /dev/null +++ b/src/main/java/com/zy/common/entity/MatExcel.java @@ -0,0 +1,23 @@ +package com.zy.common.entity; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.zy.asrs.entity.Mat; +import lombok.Data; + +/** + * 0.A 1.B 2.C 3.D 4.E 5.F 6.G 7.H 8.I + * 9.J 10.K 11.L 12.M 13.N 14.O 15.P 16.Q 17.R 18.S + * 19.T 20.U 21.V 22.W 23.X 24.Y 25.Z + */ +@Data +@ExcelIgnoreUnannotated +public class MatExcel extends Mat { + + @ExcelProperty(index = 0, value = "涓�绾у垎绫�") + private String priClass; + + @ExcelProperty(index = 1, value = "浜岀骇鍒嗙被") + private String secClass; + +} diff --git a/src/main/java/com/zy/common/utils/ListUtils.java b/src/main/java/com/zy/common/utils/ListUtils.java new file mode 100644 index 0000000..5b3f35f --- /dev/null +++ b/src/main/java/com/zy/common/utils/ListUtils.java @@ -0,0 +1,24 @@ +package com.zy.common.utils; + +import java.io.*; +import java.util.List; +import java.util.Map; + +/** + * Created by vincent on 2020/10/17 + */ +public class ListUtils { + + public static List<Map> deepCopy(List<Map> src) throws IOException, ClassNotFoundException { + ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(byteOut); + out.writeObject(src); + + ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray()); + ObjectInputStream in = new ObjectInputStream(byteIn); + @SuppressWarnings("unchecked") + List<Map> dest = (List<Map>) in.readObject(); + return dest; + } + +} diff --git a/src/main/java/com/zy/common/utils/NodeUtils.java b/src/main/java/com/zy/common/utils/NodeUtils.java new file mode 100644 index 0000000..1703cdb --- /dev/null +++ b/src/main/java/com/zy/common/utils/NodeUtils.java @@ -0,0 +1,46 @@ +package com.zy.common.utils; + +import com.core.common.SpringUtils; +import com.zy.asrs.entity.Tag; +import com.zy.asrs.service.TagService; + +/** + * Created by vincent on 2021/1/19 + */ +public class NodeUtils { + + public StringBuilder path = new StringBuilder(); + + public StringBuilder pathName = new StringBuilder(); + + public void executePath(Tag tag) { + TagService bean = SpringUtils.getBean(TagService.class); + Tag parent = bean.selectById(tag.getParentId()); + if (null != parent) { + path.insert(0, parent.getId()).insert(0,","); + pathName.insert(0, parent.getName()).insert(0,","); + if (parent.getParentId() != null) { + executePath(parent); + } else { + path.deleteCharAt(0); + pathName.deleteCharAt(0); + } + } + } + + public void executePath(Long parentId) { + TagService bean = SpringUtils.getBean(TagService.class); + Tag parent = bean.selectById(parentId); + if (null != parent) { + path.insert(0, parent.getId()).insert(0,","); + pathName.insert(0, parent.getName()).insert(0,","); + if (parent.getParentId() != null) { + executePath(parent); + } else { + path.deleteCharAt(0); + pathName.deleteCharAt(0); + } + } + } + +} diff --git a/src/main/java/com/zy/common/utils/TreeUtils.java b/src/main/java/com/zy/common/utils/TreeUtils.java new file mode 100644 index 0000000..271ee28 --- /dev/null +++ b/src/main/java/com/zy/common/utils/TreeUtils.java @@ -0,0 +1,89 @@ +package com.zy.common.utils; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.zy.asrs.entity.Tag; +import com.zy.asrs.service.TagService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Component; + +import java.util.*; + +/** + * 鏍戝舰鍥惧伐鍏� + * Created by vincent on 2020/10/16 + */ +@Component +public class TreeUtils { + + @Autowired + private TagService tagService; + + /******************************** 褰掔被鏍� *********************************/ + + /** + * 鑾峰彇鏍戝浘鏁版嵁缁撴瀯 + */ + @Cacheable(cacheNames="tagTree",key="#id") + public ArrayList<Map> getTree(String id){ + ArrayList<Map> result = new ArrayList<>(); + Tag tag = tagService.selectById(id); + // 涓昏妭鐐� + Map<String, Object> map = new HashMap<>(); + map.put("title", tag.getName()); + map.put("id", tag.getId()); + map.put("spread", true); + List<Map> childrens = new ArrayList<>(); + map.put("children", childrens); + dealTag(tag, childrens); + result.add(map); + // 寮�濮嬪鐞嗗瓧鑺傜偣 +// deal(tag, childrens); + return result; + } + + /** + * 閫掑綊鑾峰彇瀛愯妭鐐规暟鎹� + */ + public void dealTag(Tag parent, List<Map> list) { + List<Tag> tags = tagService.selectList( + new EntityWrapper<Tag>() + .eq("parent_id", parent.getId()) + .eq("status", "1")); + for (Tag tag : tags) { + Map<String, Object> map = new HashMap<>(); + map.put("title", tag.getName()); + map.put("id", tag.getId()); + map.put("spread", true); + List<Map> childrens = new ArrayList<>(); + map.put("children", childrens); + dealTag(tag, childrens); + list.add(map); + } + } + + + // ------------------------------------------------------------------------------------------------------- + + /** + * 鏉′欢绛涢�� + */ + @SuppressWarnings("unchecked") + public void remove(String condition, List<Map> list) { + Iterator<Map> iterator = list.iterator(); + while (iterator.hasNext()) { + Map map = iterator.next(); + if (map.get("children") != null) { + List<Map> children = (List<Map>) map.get("children"); + if (children.size() > 0) { + remove(condition, children); + } else { + if (!String.valueOf(map.get("title")).contains(condition)) { + iterator.remove(); + } + } + } + } + } + +} diff --git a/src/main/java/com/zy/common/web/BaseController.java b/src/main/java/com/zy/common/web/BaseController.java index ecc7e80..60d9fc1 100644 --- a/src/main/java/com/zy/common/web/BaseController.java +++ b/src/main/java/com/zy/common/web/BaseController.java @@ -7,6 +7,8 @@ import com.core.common.Cools; import com.core.controller.AbstractBaseController; import com.core.exception.CoolException; +import com.zy.asrs.entity.Tag; +import com.zy.asrs.service.TagService; import com.zy.system.entity.User; import com.zy.system.service.UserService; import io.swagger.annotations.ApiModelProperty; @@ -28,6 +30,8 @@ protected HttpServletRequest request; @Autowired private UserService userService; + @Autowired + private TagService tagService; protected Long getUserId(){ return Long.parseLong(String.valueOf(request.getAttribute("userId"))); @@ -51,6 +55,10 @@ return ""; } + protected Tag getOriginTag(){ + return tagService.getTop(); + } + /** * 鍒嗛〉缁勮 * @param pageNumber diff --git a/src/main/resources/mapper/DocLogMapper.xml b/src/main/resources/mapper/DocLogMapper.xml index 61a4865..04b829c 100644 --- a/src/main/resources/mapper/DocLogMapper.xml +++ b/src/main/resources/mapper/DocLogMapper.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="zy.cloud.wms.manager.mapper.DocLogMapper"> +<mapper namespace="com.zy.asrs.mapper.DocLogMapper"> <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> <resultMap id="BaseResultMap" type="com.zy.asrs.entity.DocLog"> diff --git a/src/main/resources/mapper/MatMapper.xml b/src/main/resources/mapper/MatMapper.xml new file mode 100644 index 0000000..fc07fed --- /dev/null +++ b/src/main/resources/mapper/MatMapper.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zy.asrs.mapper.MatMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="BaseResultMap" type="com.zy.asrs.entity.Mat"> + <id column="id" property="id" /> + <result column="uuid" property="uuid" /> + <result column="node_id" property="nodeId" /> + <result column="tag_id" property="tagId" /> + <result column="matnr" property="matnr" /> + <result column="maktx" property="maktx" /> + <result column="name" property="name" /> + <result column="specs" property="specs" /> + <result column="model" property="model" /> + <result column="batch" property="batch" /> + <result column="unit" property="unit" /> + <result column="barcode" property="barcode" /> + <result column="doc_id" property="docId" /> + <result column="doc_num" property="docNum" /> + <result column="cust_name" property="custName" /> + <result column="item_num" property="itemNum" /> + <result column="count" property="count" /> + <result column="price" property="price" /> + <result column="weight" property="weight" /> + <result column="status" property="status" /> + <result column="create_by" property="createBy" /> + <result column="create_time" property="createTime" /> + <result column="update_by" property="updateBy" /> + <result column="update_time" property="updateTime" /> + <result column="memo" property="memo" /> + + <result column="stock" property="stock" /> + </resultMap> + + <select id="listByPage" resultMap="BaseResultMap"> + SELECT + isnull(mld.amount,0) as stock, + mm.* + FROM man_mat mm + LEFT JOIN man_tag mt ON mm.tag_id = mt.id + LEFT JOIN ( + select + matnr, + sum(anfme) as amount + from man_loc_detl + group by matnr + ) as mld on mld.matnr = mm.matnr + WHERE 1=1 + AND (CHARINDEX(','+#{tagId}+',', ','+mt.path+',') > 0 OR mt.id = #{tagId}) + <if test="matnr != null and matnr != ''"> + and mm.matnr like concat('%',#{matnr},'%') + </if> + <if test="maktx != null and maktx != ''"> + and mm.maktx like concat('%',#{maktx},'%') + </if> + ORDER BY mm.create_time DESC + </select> + + <select id="selectByMatnr" resultMap="BaseResultMap"> + select top 1 * from man_mat where 1=1 and matnr = #{matnr} + </select> +</mapper> diff --git a/src/main/resources/mapper/RequestLogMapper.xml b/src/main/resources/mapper/RequestLogMapper.xml index fba3600..cb96b31 100644 --- a/src/main/resources/mapper/RequestLogMapper.xml +++ b/src/main/resources/mapper/RequestLogMapper.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="zy.cloud.wms.manager.mapper.RequestLogMapper"> +<mapper namespace="com.zy.asrs.mapper.RequestLogMapper"> <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> <resultMap id="BaseResultMap" type="com.zy.asrs.entity.RequestLog"> diff --git a/src/main/resources/mapper/TagMapper.xml b/src/main/resources/mapper/TagMapper.xml new file mode 100644 index 0000000..ee6c1a4 --- /dev/null +++ b/src/main/resources/mapper/TagMapper.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zy.asrs.mapper.TagMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="BaseResultMap" type="com.zy.asrs.entity.Tag"> + <id column="id" property="id" /> + <result column="uuid" property="uuid" /> + <result column="name" property="name" /> + <result column="parent_id" property="parentId" /> + <result column="parent_name" property="parentName" /> + <result column="path" property="path" /> + <result column="path_name" property="pathName" /> + <result column="type" property="type" /> + <result column="leading" property="leading" /> + <result column="img" property="img" /> + <result column="brief" property="brief" /> + <result column="count" property="count" /> + <result column="level" property="level" /> + <result column="sort" property="sort" /> + <result column="status" property="status" /> + <result column="create_time" property="createTime" /> + <result column="create_by" property="createBy" /> + <result column="update_time" property="updateTime" /> + <result column="update_by" property="updateBy" /> + <result column="memo" property="memo" /> + + </resultMap> + +</mapper> diff --git a/src/main/webapp/static/css/tree.css b/src/main/webapp/static/css/tree.css new file mode 100644 index 0000000..aef4bf0 --- /dev/null +++ b/src/main/webapp/static/css/tree.css @@ -0,0 +1,70 @@ +#organizationTreeBar { + padding: 10px 15px; + border: 1px solid #e6e6e6; + background-color: #f2f2f2; +} +#organizationTree { + border: 1px solid #e6e6e6; + border-top: none; + padding: 10px 5px; + overflow: auto; + height: -webkit-calc(100vh - 125px); + height: -moz-calc(100vh - 125px); + height: calc(100vh - 125px); +} +.layui-tree-entry .layui-tree-txt { + padding: 0 5px; + border: 1px transparent solid; + text-decoration: none !important; +} + +.layui-tree-entry.ew-tree-click .layui-tree-txt { + background-color: #fff3e0; + border: 1px #FFE6B0 solid; +} + + + +#organizationEditForm.layui-form { + padding: 25px 30px 0 0; +} +#organizationEditForm .layui-form-label { + padding: 8px 15px; + box-sizing: content-box; + -webkit-box-sizing: content-box; +} +#organizationEditForm .layui-form-required:before { + content: "*"; + display: inline-block; + font-family: SimSun,serif; + margin-right: 4px; + font-size: 14px; + line-height: 1; + color: #ed4014; +} +#organizationEditForm .layui-input { + height: 36px; + border-radius: 4px; +} +#organizationEditForm .cool-button-contain { + text-align: right; + margin: 20px 0; +} +#organizationEditForm .layui-form-radio>i:hover, .layui-form-radioed>i { + color: #007bff; +} +#organizationEditForm .layui-btn { + height: 36px; + line-height: 36px; + border-radius: 4px; + box-shadow: 0 1px 0 rgba(0,0,0,.03); +} +#organizationEditForm .layui-btn-primary:hover { + border-color: #777777; +} + + +/* 鑷畾涔� */ +#condition { + height: 30px; +} \ No newline at end of file diff --git a/src/main/webapp/static/js/mat/mat.js b/src/main/webapp/static/js/mat/mat.js new file mode 100644 index 0000000..f1e0dc5 --- /dev/null +++ b/src/main/webapp/static/js/mat/mat.js @@ -0,0 +1,480 @@ +var pageCurr; +var printMatCodeNos = []; +var admin; +function getCol() { + var cols = [ + {type: 'checkbox'} + ,{field: 'tagId$', align: 'center',title: '褰掔被', templet: '#tagTpl'} + ]; + cols.push.apply(cols, matCols); + cols.push( + {fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:150} + ) + return cols; +} + +layui.config({ + base: baseUrl + "/static/layui/lay/modules/" +}).extend({ + dropdown: 'dropdown/dropdown', +}).use(['table','laydate', 'form', 'treeTable', 'admin', 'xmSelect', 'dropdown', 'element'], function(){ + var table = layui.table; + var $ = layui.jquery; + var layer = layui.layer; + var layDate = layui.laydate; + var form = layui.form; + admin = layui.admin; + var treeTable = layui.treeTable; + var xmSelect = layui.xmSelect; + + // 鍟嗗搧鍒嗙被鏁版嵁 + var insTb = treeTable.render({ + elem: '#tag', + url: baseUrl+'/tag/list/auth', + headers: {token: localStorage.getItem('token')}, + tree: { + iconIndex: 2, // 鎶樺彔鍥炬爣鏄剧ず鍦ㄧ鍑犲垪 + isPidData: true, // 鏄惁鏄痠d銆乸id褰㈠紡鏁版嵁 + idName: 'id', // id瀛楁鍚嶇О + pidName: 'parentId' // pid瀛楁鍚嶇О + }, + cols: [], + done: function (data) { + $('.ew-tree-table-box').css('height', '100%'); + insTb.expandAll(); + } + }); + + // 鏁版嵁娓叉煋 + tableIns = table.render({ + elem: '#mat', + headers: {token: localStorage.getItem('token')}, + url: baseUrl+'/mat/list/auth', + page: true, + limit: 16, + limits: [16, 30, 50, 100, 200, 500], + toolbar: '#toolbar', + cellMinWidth: 50, + height: 'full-105', + cols: [getCol()], + request: { + pageName: 'curr', + pageSize: 'limit' + }, + parseData: function (res) { + return { + 'code': res.code, + 'msg': res.msg, + 'count': res.data.total, + 'data': res.data.records + } + }, + response: { + statusCode: 200 + }, + done: function(res, curr, count) { + if (res.code === 403) { + top.location.href = baseUrl+"/"; + } + pageCurr=curr; + limit(); + form.on('checkbox(tableCheckbox)', function (data) { + var _index = $(data.elem).attr('table-index')||0; + if(data.elem.checked){ + res.data[_index][data.value] = 'Y'; + }else{ + res.data[_index][data.value] = 'N'; + } + }); + } + }); + + // 鐩戝惉鎺掑簭浜嬩欢 + table.on('sort(locMast)', function (obj) { + var searchData = {}; + $.each($('#search-box [name]').serializeArray(), function() { + searchData[this.name] = this.value; + }); + searchData['orderByField'] = obj.field; + searchData['orderByType'] = obj.type; + tableIns.reload({ + where: searchData, + page: { + curr: 1 + }, + done: function (res, curr, count) { + if (res.code === 403) { + top.location.href = baseUrl+"/"; + } + pageCurr=curr; + limit(); + } + }); + }); + + // 鐩戝惉澶村伐鍏锋爮浜嬩欢 + table.on('toolbar(mat)', function (obj) { + var checkStatus = table.checkStatus(obj.config.id); + switch(obj.event) { + case 'addData': + showEditModel() + break; + case 'deleteData': + var data = checkStatus.data; + if (data.length === 0){ + layer.msg('璇烽�夋嫨鏁版嵁'); + } else { + layer.confirm('纭畾鍒犻櫎'+(data.length===1?'姝�':data.length)+'鏉℃暟鎹悧', function(){ + $.ajax({ + url: baseUrl+"/mat/delete/auth", + headers: {'token': localStorage.getItem('token')}, + data: {param: JSON.stringify(data)}, + method: 'POST', + traditional:true, + success: function (res) { + if (res.code === 200){ + layer.closeAll(); + tableReload(false); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + } else { + layer.msg(res.msg) + } + } + }) + }); + } + break; + case 'exportData': + layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){ + var titles=[]; + var fields=[]; + obj.config.cols[0].map(function (col) { + if (col.type === 'normal' && col.hide === false && col.toolbar == null) { + titles.push(col.title); + fields.push(col.field); + } + }); + var exportData = {}; + $.each($('#search-box [name]').serializeArray(), function() { + exportData[this.name] = this.value; + }); + var param = { + 'mat': exportData, + 'fields': fields + }; + $.ajax({ + url: baseUrl+"/mat/export/auth", + headers: {'token': localStorage.getItem('token')}, + data: JSON.stringify(param), + dataType:'json', + contentType:'application/json;charset=UTF-8', + method: 'POST', + success: function (res) { + layer.closeAll(); + if (res.code === 200) { + table.exportFile(titles,res.data,'xls'); + } else if (res.code === 403) { + top.location.href = baseUrl+"/"; + } else { + layer.msg(res.msg) + } + } + }); + }); + break; + // 鎵归噺鎵撳嵃 + case "btnPrintBatch": + printMatCodeNos = []; + var data = checkStatus.data; + if (data.length === 0){ + layer.msg('璇烽�夋嫨鎵撳嵃鏁版嵁'); + } else { + layer.open({ + type: 1, + title: '鎵归噺鎵撳嵃 [鏁伴噺'+ data.length +']', + area: ['500px'], + shadeClose: true, + content: $('#printDataDiv'), + success: function(layero, index){ + for (var i = 0; i<data.length;i++) { + printMatCodeNos.push(data[i].matnr); + } + }, + end: function () { + } + }); + } + break; + } + }); + + // 鐩戝惉琛屽伐鍏蜂簨浠� + table.on('tool(mat)', function(obj){ + var data = obj.data; + switch (obj.event) { + // 鎵撳嵃 + case "btnPrint": + printMatCodeNos = []; + layer.open({ + type: 1, + title: data.matnr + ' [鏁伴噺锛�1]', + area: ['500px'], + shadeClose: true, + content: $('#printDataDiv'), + success: function(layero, index){ + layer.iframeAuto(index); + printMatCodeNos.push(data.matnr); + }, + end: function () { + } + }); + break; + // 缂栬緫 + case 'edit': + showEditModel(data) + break; + } + }); + + /* 鏄剧ず琛ㄥ崟寮圭獥 */ + function showEditModel(mData) { + admin.open({ + type: 1, + area: '600px', + title: (mData ? '淇敼' : '娣诲姞') + '鍟嗗搧', + content: $('#editDialog').html(), + success: function (layero, dIndex) { + // 鍥炴樉琛ㄥ崟鏁版嵁 + form.val('detail', mData); + // 鏂板鑷姩鐢熸垚鍟嗗搧缂栧彿 + if (!mData) { + http.get(baseUrl + "/mat/auto/matnr/auth", null, function (res) { + $('#matnr').val(res.data); + }) + } + // 琛ㄥ崟鎻愪氦浜嬩欢 + form.on('submit(editSubmit)', function (data) { + data.field.tagId = insXmSel.getValue('valueStr'); + if (isEmpty(data.field.tagId)) { + layer.msg('鍒嗙被涓嶈兘涓虹┖', {icon: 2}); + return false; + } + var loadIndex = layer.load(2); + $.ajax({ + url: baseUrl+"/mat/"+(mData?'update':'add')+"/auth", + headers: {'token': localStorage.getItem('token')}, + data: data.field, + method: 'POST', + success: function (res) { + layer.close(loadIndex); + if (res.code === 200){ + layer.close(dIndex); + layer.msg(res.msg, {icon: 1}); + $(".layui-laypage-btn")[0].click(); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + }else { + layer.msg(res.msg, {icon: 2}); + } + } + }) + return false; + }); + // 娓叉煋涓嬫媺鏍� + var insXmSel = xmSelect.render({ + el: '#tagSel', + height: '250px', + data: insTb.options.data, + initValue: mData ? [mData.tagId] : [], + model: {label: {type: 'text'}}, + prop: { + name: 'name', + value: 'id' + }, + radio: true, + clickClose: true, + tree: { + show: true, + indent: 15, + strict: false, + expandedKeys: true + } + }); + // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯 + $(layero).children('.layui-layer-content').css('overflow', 'visible'); + layui.form.render('select'); + } + }); + } + + // 妯℃澘閫夋嫨 + form.on('radio(selectTemplateRadio)', function (data) { + $('.template-preview').hide(); + $('#template-preview-'+data.value).show(); + }); + + // 寮�濮嬫墦鍗� + form.on('submit(doPrint)', function (data) { + var templateNo = data.field.selectTemplate; + $.ajax({ + url: baseUrl+"/mat/print/auth", + headers: {'token': localStorage.getItem('token')}, + data: {param: printMatCodeNos}, + method: 'POST', + async: false, + success: function (res) { + if (res.code === 200){ + layer.closeAll(); + for (let i=0;i<res.data.length;i++){ + var templateDom = $("#templatePreview"+templateNo); + var className = templateDom.attr("class"); + if (className === 'template-barcode') { + res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=1¶m="+res.data[i].matnr; + } else { + res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=2¶m="+res.data[i].matnr; + } + } + var tpl = templateDom.html(); + var template = Handlebars.compile(tpl); + var html = template(res); + var box = $("#box"); + box.html(html);box.show(); + box.print({mediaPrint:true}); + box.hide(); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + }else { + layer.msg(res.msg) + } + } + }) + }); + + // 鎼滅储鏍忔悳绱簨浠� + form.on('submit(search)', function (data) { + pageCurr = 1; + tableReload(false); + }); + + // 鎼滅储鏍忛噸缃簨浠� + form.on('submit(reset)', function (data) { + pageCurr = 1; + clearFormVal($('#search-box')); + tableReload(false); + }); + + // 鏃堕棿閫夋嫨鍣� + layDate.render({ + elem: '#createTime\\$', + type: 'datetime' + }); + layDate.render({ + elem: '#updateTime\\$', + type: 'datetime' + }); + + +}); + +// excel瀵煎叆妯℃澘涓嬭浇 +function excelMouldDownload(){ + layer.load(1, {shade: [0.1,'#fff']}); + location.href = baseUrl + "/mat/excel/import/mould"; + layer.closeAll('loading'); +} + +// excel瀵煎叆 +function importExcel() { + $("#importExcel").trigger("click"); +} +function upload(obj){ + if(!obj.files) { + return; + } + var file = obj.files[0]; + admin.confirm('纭鍚屾 [' + file.name +'] 鏂囦欢鍚楋紵', function (index) { + layer.load(1, {shade: [0.1,'#fff']}); + var url = baseUrl + "/mat/excel/import/auth"; + var form = new FormData(); + form.append("file", file); + xhr = new XMLHttpRequest(); + xhr.open("post", url, true); //post鏂瑰紡锛寀rl涓烘湇鍔″櫒璇锋眰鍦板潃锛宼rue 璇ュ弬鏁拌瀹氳姹傛槸鍚﹀紓姝ュ鐞嗐�� + xhr.setRequestHeader('token', localStorage.getItem('token')); + xhr.onload = uploadComplete; //璇锋眰瀹屾垚 + xhr.onerror = uploadFailed; //璇锋眰澶辫触 + xhr.onloadend = function () { // // 涓婁紶瀹屾垚閲嶇疆鏂囦欢娴� + layer.closeAll('loading'); + $("#importExcel").val(""); + }; + // xhr.upload.onprogress = progressFunction;//銆愪笂浼犺繘搴﹁皟鐢ㄦ柟娉曞疄鐜般�� + xhr.upload.onloadstart = function(){//涓婁紶寮�濮嬫墽琛屾柟娉� + ot = new Date().getTime(); //璁剧疆涓婁紶寮�濮嬫椂闂� + oloaded = 0;//璁剧疆涓婁紶寮�濮嬫椂锛屼互涓婁紶鐨勬枃浠跺ぇ灏忎负0 + }; + xhr.send(form); + }, function(index){ + $("#importExcel").val(""); + }); +} +function uploadComplete(evt) { + var res = JSON.parse(evt.target.responseText); + if(res.code === 200) { + layer.msg(res.msg, {icon: 1}); + loadTree(""); + } else { + layer.msg(res.msg, {icon: 2}); + } +} +function uploadFailed(evt) { + var res = JSON.parse(evt.target.responseText); + layer.msg(res.msg, {icon: 2}); +} + +// excel瀵煎嚭 +function exportExcel() { + +} + + +function tableReload(child) { + var searchData = {}; + $.each($('#search-box [name]').serializeArray(), function() { + searchData[this.name] = this.value; + }); + (child ? parent.tableIns : tableIns).reload({ + where: searchData, + page: { + curr: pageCurr + }, + done: function (res, curr, count) { + if (res.code === 403) { + top.location.href = baseUrl+"/"; + } + pageCurr=curr; + if (res.data.length === 0 && count !== 0) { + tableIns.reload({ + where: searchData, + page: { + curr: pageCurr-1 + } + }); + pageCurr -= 1; + } + limit(child); + } + }); +} + +function clearFormVal(el) { + $(':input', el) + .val('') + .removeAttr('checked') + .removeAttr('selected'); +} + +$('body').keydown(function () { + if (event.keyCode === 13) { + $("#search").click(); + } +}); diff --git a/src/main/webapp/static/js/tagTree.js b/src/main/webapp/static/js/tagTree.js new file mode 100644 index 0000000..dcbbca5 --- /dev/null +++ b/src/main/webapp/static/js/tagTree.js @@ -0,0 +1,86 @@ +var currentTemId; +var currentTemName; +var currentTemSsbm; +var init = false; + +layui.config({ + base: baseUrl + "/static/layui/lay/modules/" // 閰嶇疆妯″潡鎵�鍦ㄧ殑鐩綍 +}).use(['table','laydate', 'form', 'tree', 'xmSelect'], function() { + var table = layui.table; + var $ = layui.jquery; + var layer = layui.layer; + var layDate = layui.laydate; + var form = layui.form; + var tree = layui.tree; + var xmSelect = layui.xmSelect; + var selObj, treeData; // 宸︽爲閫変腑鏁版嵁 + + var organizationTree; + window.loadTree = function(condition){ + var loadIndex = layer.load(2); + $.ajax({ + url: baseUrl+"/tag/tree/auth", + headers: {'token': localStorage.getItem('token')}, + data: { + 'condition': condition + }, + method: 'POST', + success: function (res) { + if (res.code === 200){ + layer.close(loadIndex); + // 鏍戝舰鍥� + organizationTree = tree.render({ + elem: '#organizationTree', + id: 'organizationTree', + onlyIconControl: true, + data: res.data, + click: function (obj) { + currentTemId = obj.data.id; + currentTemName = obj.data.title.split(" - ")[0]; + currentTemSsbm = obj.data.title.split(" - ")[1]; + selObj = obj; + $('#organizationTree').find('.ew-tree-click').removeClass('ew-tree-click'); + $(obj.elem).children('.layui-tree-entry').addClass('ew-tree-click'); + tableIns.reload({ + where: {tag_id: obj.data.id}, + page: {curr: 1} + }); + } + }); + treeData = res.data; + if (isEmpty(condition) && init) { + tableIns.reload({ + where: {tag_id: ""}, + page: {curr: 1} + }); + } + if (!init) { + init = true; + } + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + } else { + layer.msg(res.msg) + } + } + }) + } + loadTree(); + + /* 鏍戝舰鍥鹃噸缃� */ + $('#treeReset').click(function () { + $("#condition").val(""); + loadTree(""); + }) + +}) + +function closeDialog() { + layer.closeAll(); +} + +/* 鏍戝舰鍥炬悳绱� */ +function findData(el) { + var condition = $(el).val(); + loadTree(condition) +} \ No newline at end of file diff --git a/src/main/webapp/views/mat/mat.html b/src/main/webapp/views/mat/mat.html new file mode 100644 index 0000000..f4035a4 --- /dev/null +++ b/src/main/webapp/views/mat/mat.html @@ -0,0 +1,435 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title></title> + <meta name="renderer" content="webkit"> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> + <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> + <link rel="stylesheet" href="../../static/css/admin.css?v=318" media="all"> + <link rel="stylesheet" href="../../static/css/cool.css" media="all"> + <link rel="stylesheet" href="../../static/css/tree.css" media="all"> + <style> + body { + color: #595959; + background-color: #f5f7f9; + } + .layui-fluid { + padding: 15px; + } + .layui-form.layui-border-box.layui-table-view { + /*margin: 15px 0 35px 0;*/ + width: 100%; + border-width: 1px; + } + .layui-form.layui-border-box.layui-table-view { + height: calc(100vh - 160px); + } + .layui-form.layui-border-box.layui-table-view { + margin: 0; + } + #search-box { + padding: 30px 30px 10px 0px; + margin-left: 0px; + } + .layui-form.layui-border-box.layui-table-view { + height: 100%; + } + + .admin-form { + padding: 25px 30px 0 0 !important; + margin: 0 !important; + } + + /* ------------------------- 鎵撳嵃琛ㄦ牸 ----------------------- */ + .template-preview { + height: 200px; + display: inline-block; + } + .contain td { + border: 1px solid #000; + /*font-family: 榛戜綋;*/ + /*font-weight: bold;*/ + /*color: #000000;*/ + } + </style> +</head> +<body> + +<div class="layui-fluid"> + <!-- 宸� --> + <div class="layui-row layui-col-space15"> + <div class="layui-col-md3"> + <div class="layui-card"> + <div class="layui-card-body" style="padding: 10px;"> + <!-- 鏍戝伐鍏锋爮 --> + <div class="layui-form toolbar" id="organizationTreeBar"> + <div class="layui-inline" style="max-width: 200px;"> + <input id="condition" onkeyup="findData(this)" type="text" class="layui-input" placeholder="璇疯緭鍏ュ叧閿瓧" autocomplete="off"> + </div> + <div class="layui-inline"> + <button class="layui-btn icon-btn layui-btn-sm" id="treeReset" style="padding: 0 10px"> + <i class="layui-icon layui-icon-close"></i> + </button> + </div> + </div> + <!-- 鏍� --> + <div class="layui-form toolbar" id="organizationTree"></div> + </div> + </div> + </div> + <!-- 鍙� --> + <div class="layui-col-md9"> + <div class="layui-card"> + <div class="layui-card-body" style="padding: 10px;"> + <!-- 琛ㄦ牸宸ュ叿鏍�2 --> + <div id="search-box" class="layui-form toolbar" style="padding-top: 5px"> + <div class="layui-inline"> + <label class="layui-form-label" style="padding: 8px 15px 8px 15px">鍟嗗搧缂栧彿:</label> + <div class="layui-input-inline"> + <input name="matnr" class="layui-input" placeholder="杈撳叆鍟嗗搧缂栧彿"/> + </div> + </div> + <div class="layui-inline"> + <label class="layui-form-label" style="padding: 8px 15px 8px 15px">鍟嗗搧鍚嶇О:</label> + <div class="layui-input-inline"> + <input name="maktx" class="layui-input" placeholder="杈撳叆鍟嗗搧鍚嶇О"/> + </div> + </div> + <div class="layui-inline">  + <button class="layui-btn icon-btn" lay-filter="search" lay-submit> + <i class="layui-icon"></i>鎼滅储 + </button> + <button class="layui-btn icon-btn" lay-filter="reset" lay-submit> + <i class="layui-icon"></i>閲嶇疆 + </button> + </div> + </div> + <table class="layui-hide" id="mat" lay-filter="mat"></table> + </div> + </div> + </div> + </div> +</div> + +<script type="text/html" id="tagTpl"> + <span name="tagId" class="layui-badge layui-badge-gray">{{d.tagId$}}</span> +</script> + +<script type="text/html" id="toolbar"> + <div class="layui-btn-container"> + <button class="layui-btn layui-btn-sm" id="btn-print-batch" lay-event="btnPrintBatch">鎵归噺鎵撳嵃</button> + <button class="layui-btn layui-btn-sm layui-btn-normal" id="btn-add" lay-event="addData">鏂板</button> + <button class="layui-btn layui-btn-sm layui-btn-danger" id="btn-delete" lay-event="deleteData">鍒犻櫎</button> + <!-- 鍟嗗搧/鐗╂枡 鏁版嵁涓績 --> + <div class="dropdown-menu" style="float: right"> + <button class="layui-btn layui-btn-primary layui-border-black icon-btn layui-btn-sm"> 鏁版嵁鍚屾 <i class="layui-icon layui-icon-drop"></i></button> + <ul class="dropdown-menu-nav dark"> + <div class="dropdown-anchor"></div> + <li class="title">1st menu</li> + <li><a onclick="excelMouldDownload()" style="font-size: 12px"><i class="layui-icon layui-icon-template-1"></i>妯℃澘涓嬭浇</a></li> + <li><a onclick="importExcel()" style="font-size: 12px"><i class="layui-icon layui-icon-upload"></i>瀵煎叆 Excel</a></li> + <li style="display: none"><input id="importExcel" type="file" onchange="upload(this)" ></li> + <hr> + <li class="title">2nd menu</li> + <li><a onclick="exportExcel()" style="font-size: 12px"><i class="layui-icon layui-icon-export"></i>瀵煎嚭 Excel</a></li> + </ul> + </div> +<!-- <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData" style="float: right;margin-right: -10px">瀵煎嚭</button>--> + </div> +</script> + +<script type="text/html" id="operate"> + <a class="layui-btn layui-btn-xs btn-edit layui-btn-primary" lay-event="edit">淇敼</a> + <button class="layui-btn layui-btn-xs btn-print" lay-event="btnPrint">鎵撳嵃</button> +</script> + +<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> +<script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> +<script type="text/javascript" src="../../static/js/jquery/jQuery.print.js"></script> +<script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script> +<script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> +<script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> +<script type="text/javascript" src="../../static/js/mat/mat.js" charset="utf-8"></script> +<script type="text/javascript" src="../../static/js/tagTree.js" charset="utf-8"></script> + +<!-- 琛ㄥ崟寮圭獥 --> +<script type="text/html" id="editDialog"> + <form id="detail" lay-filter="detail" class="layui-form admin-form"> + <input name="id" type="hidden"> + <input name="uuid" type="hidden"> + <input name="nodeId" type="hidden"> + <input name="tag_id" type="hidden"> + <input name="model" type="hidden"> + <input name="name" type="hidden"> + <input name="batch" type="hidden"> + <input name="docId" type="hidden"> + <input name="docNum" type="hidden"> + <input name="custName" type="hidden"> + <input name="itemNum" type="hidden"> + <input name="count" type="hidden"> + <input name="weight" type="hidden"> + <input name="status" type="hidden"> + <input name="createBy" type="hidden"> + <input name="updateTime$" type="hidden"> + <input name="updateBy" type="hidden"> + <div class="layui-row"> + + <div class="layui-col-md6"> + + <div class="layui-form-item"> + <label class="layui-form-label">鍒嗙被</label> + <div class="layui-input-block"> + <div id="tagSel" class="ew-xmselect-tree"></div> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label layui-form-required">鍟嗗搧鍚嶇О</label> + <div class="layui-input-block"> + <input name="maktx" placeholder="璇疯緭鍏ュ晢鍝佸悕绉�" class="layui-input" lay-vertype="tips" lay-verify="required" required=""> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">SKC</label> + <div class="layui-input-block"> + <input name="barcode" placeholder="璇疯緭鍏ユ潯鐮�" class="layui-input"> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">鍗曚环</label> + <div class="layui-input-block"> + <input name="price" type="number" placeholder="璇疯緭鍏ュ崟浠�" class="layui-input"> + </div> + </div> + + </div> + + <div class="layui-col-md6"> + <div class="layui-form-item"> + <label class="layui-form-label layui-form-required">鍟嗗搧缂栧彿</label> + <div class="layui-input-block"> + <input id="matnr" name="matnr" placeholder="璇疯緭鍏ュ晢鍝佺紪鍙�" class="layui-input" lay-vertype="tips" lay-verify="required" required=""> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">瑙勬牸</label> + <div class="layui-input-block"> + <input name="specs" placeholder="璇疯緭鍏ヨ鏍�" class="layui-input"> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">鍗曚綅</label> + <div class="layui-input-block"> + <input name="unit" placeholder="璇疯緭鍏ュ崟浣�" class="layui-input"> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">澶囨敞</label> + <div class="layui-input-block"> + <input name="memo" placeholder="璇疯緭鍏ュ娉�" class="layui-input"> + </div> + </div> + + <!-- <div class="layui-form-item">--> + <!-- <label class="layui-form-label layui-form-required">鐘舵��</label>--> + <!-- <div class="layui-input-block">--> + <!-- <select name="status" lay-vertype="tips" lay-verify="required" required="">--> + <!-- <option value="">璇烽�夋嫨鐘舵��</option>--> + <!-- <option value="1">姝e父</option>--> + <!-- <option value="0">绂佺敤</option>--> + <!-- </select>--> + <!-- </div>--> + <!-- </div>--> + + </div> + </div> + <hr class="layui-bg-gray"> + <div class="layui-form-item text-right"> + <button class="layui-btn" lay-filter="editSubmit" lay-submit="">淇濆瓨</button> + <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">鍙栨秷</button> + </div> + </form> +</script> + +<!-- 鎵撳嵃鎿嶄綔寮圭獥 --> +<div id="printDataDiv" style="display: none;padding: 20px"> + <div class="layui-form" style="text-align: center"> + <hr> + <!--鍗曢�夋--> + <div class="layui-form-item" style="display: inline-block; margin-bottom: 10px"> + <input type="radio" name="selectTemplate" value="1" title="妯℃澘涓�" lay-filter="selectTemplateRadio" checked=""> + <input type="radio" name="selectTemplate" value="2" title="妯℃澘浜�" lay-filter="selectTemplateRadio"> + <input type="radio" name="selectTemplate" value="3" title="妯℃澘涓�" lay-filter="selectTemplateRadio"> + </div> + <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;text-align: left;"> + <legend>鎵撳嵃棰勮</legend> + <div id="template-container" style="margin: 20px;text-align: center"> + + <!-- 棰勮鍥� 1 --> + <div id="template-preview-1" class="template-preview" style="display: inline-block"> + <table class="contain" width="280" style="overflow: hidden;font-size: xx-small;table-layout: fixed;"> + <tr style="height: 74px"> + <td colspan="3" align="center" scope="col">鍟嗗搧缂栫爜</td> + <td class="barcode" colspan="9" align="center" scope="col"> + <img class="template-code template-barcode" src="" width="90%;"> + <div style="letter-spacing: 2px;margin-top: 1px; text-align: center;"> + <span>xxxxxx</span> + </div> + </td> + </tr> + <tr style="height: 74px"> + <td align="center" colspan="3">鍟嗗搧</td> + <td align="center" colspan="5">xxxxxx-xx/xx</td> + <td align="center" colspan="2">澶囨敞</td> + <td align="center" colspan="2">xx</td> + </tr> + </table> + </div> + + <!-- 棰勮鍥� 2 --> + <div id="template-preview-2" class="template-preview" style="display: none"> + <table class="contain" width="280" style="overflow: hidden;font-size: xx-small;table-layout: fixed;"> + <tr style="height: 30px"> + <td align="center" width="20%">鍟嗗搧</td> + <td align="center" width="80%" style="overflow:hidden; white-space:nowrap; text-overflow:ellipsis;">xxxxxxx</td> + </tr> + <tr style="height: 30px"> + <td align="center" width="20%">澶囨敞</td> + <td align="center" width="80%">xxxxxxxx</td> + </tr> + <tr style="height: 75px;"> + <td align="center" colspan="2" width="100%" style="border: none"> + <img class="template-code template-barcode" src="" width="80%"> + <div style="letter-spacing: 2px;margin-top: 1px; text-align: center"> + <span>xxxxxx</span> + </div> + </td> + </tr> + </table> + </div> + + <!-- 棰勮鍥� 3 --> + <div id="template-preview-3" class="template-preview" style="display: none"> + <table class="contain" width="280" style="overflow: hidden;font-size: xx-small;table-layout: fixed;"> + <tr style="height: 74px"> + <td align="center" scope="col" colspan="1">鍟嗗搧</td> + <td align="center" scope="col" colspan="1" style="">xxxxxx-xx/xx</td> + <td align="center" scope="col" colspan="2" rowspan="2"> + <img class="template-code template-qrcode" src="" width="80%"> + <div style="letter-spacing: 1px;margin-top: 1px; text-align: center"> + <span>xxxxxx</span> + </div> + </td> + </tr> + <tr style="height: 74px"> + <td align="center" colspan="1">澶囨敞</td> + <td align="center" colspan="1" style="overflow:hidden; white-space:nowrap; text-overflow:ellipsis;">xxxxxxx</td> + </tr> + </table> + </div> + </div> + </fieldset> + + <button class="layui-btn" id="doPrint" lay-submit lay-filter="doPrint" style="margin-top: 20px">纭畾</button> + </div> +</div> + +<div id="box" style="display: block"></div> + +<!-- 鍒濆鍖栨墦鍗版ā鏉跨殑鏉″舰鐮� --> +<script type="text/javascript"> + $('.template-barcode').attr("src", baseUrl+"/mac/code/auth?type=1¶m=123"); + $('.template-qrcode').attr("src", baseUrl+"/mac/code/auth?type=2¶m=123"); +</script> + +<!-- 妯℃澘寮曟搸 --> +<!-- 妯℃澘1 --> +<script type="text/template" id="templatePreview1" class="template-barcode"> + {{#each data}} + <table class="contain" width="280" style="overflow: hidden;font-size: small;table-layout: fixed;"> + <tr style="height: 74px"> + <td align="center" colspan="3" scope="col">鍟嗗搧缂栫爜</td> + <td align="center" class="barcode" colspan="9" scope="col"> + <img class="template-code" src="{{this.barcodeUrl}}" width="90%"> + <div style="letter-spacing: 2px;margin-top: 1px; text-align: center"> + <span>{{this.matnr}}</span> + </div> + </td> + </tr> + <tr style="height: 74px"> + <td align="center" colspan="3">鍟嗗搧</td> + <td align="center" colspan="5" style="overflow: hidden; white-space: nowrap;text-overflow: ellipsis;">{{this.maktx}}</td> + <td align="center" colspan="2">澶囨敞</td> + <td align="center" colspan="2">{{this.memo}}</td> + </tr> + </table> + {{/each}} +</script> +<!-- 妯℃澘2 --> +<script type="text/template" id="templatePreview2" class="template-barcode"> + {{#each data}} + <table class="contain" width="280" style="overflow: hidden;font-size: xx-small;table-layout: fixed;"> + <tr style="height: 35px"> + <td align="center" width="20%">鍟嗗搧</td> + <td align="center" width="80%" style="overflow:hidden; white-space:nowrap; text-overflow:ellipsis;">{{this.maktx}}</td> + </tr> + <tr style="height: 35px"> + <td align="center" width="20%">澶囨敞</td> + <td align="center" width="80%">{{this.memo}}</td> + </tr> + <tr style="height: 79px;"> + <td align="center" colspan="2" width="100%" style="border: none"> + <img class="template-code" src="{{this.barcodeUrl}}" width="80%"> + <div style="letter-spacing: 2px;margin-top: 1px; text-align: center"> + <span>{{this.matnr}}</span> + </div> + </td> + </tr> + </table> + {{/each}} +</script> +<!-- 妯℃澘3 --> +<script type="text/template" id="templatePreview3" class="template-qrcode"> + {{#each data}} + <table class="contain" width="280" style="overflow: hidden;font-size: xx-small;table-layout: fixed;"> + <tr style="height: 74px" > + <td align="center" scope="col" colspan="1">鍟嗗搧</td> + <td align="center" scope="col" colspan="1" style=" + display: inline-block; + line-height: 20px; + vertical-align: middle; + border: none; + border-top: 1px solid #000; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + "> + {{this.maktx}} + </td> + <td align="center" scope="col" colspan="2" rowspan="2"> + <img class="template-code template-qrcode" src="{{this.barcodeUrl}}" width="80%"> + <div style="letter-spacing: 1px;margin-top: 1px; text-align: center"> + <span>{{this.matnr}}</span> + </div> + </td> + </tr> + <tr style="height: 74px"> + <td align="center" colspan="1">澶囨敞</td> + <td align="center" colspan="1" style="overflow:hidden; white-space:nowrap; text-overflow:ellipsis;">{{this.memo}}</td> + </tr> + </table> + {{/each}} +</script> + +</body> +</html> + diff --git a/src/main/webapp/views/resource/resource.html b/src/main/webapp/views/resource/resource.html index d8c7c91..92c2330 100644 --- a/src/main/webapp/views/resource/resource.html +++ b/src/main/webapp/views/resource/resource.html @@ -257,7 +257,7 @@ show: true, indent: 15, strict: false, - expandedKeys: true + expandedKeys: false } }); // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯 diff --git a/src/main/webapp/views/tag/tag.html b/src/main/webapp/views/tag/tag.html new file mode 100644 index 0000000..b82b9f8 --- /dev/null +++ b/src/main/webapp/views/tag/tag.html @@ -0,0 +1,303 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title></title> + <meta name="renderer" content="webkit"> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> + <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> + <link rel="stylesheet" href="../../static/css/admin.css?v=318" media="all"> + <link rel="stylesheet" href="../../static/css/cool.css" media="all"> + <style> + #detail { + padding: 25px 30px 0 0; + } + .ew-tree-table-box { + height: 100%; + } + </style> +</head> +<body> + +<!-- 姝f枃寮�濮� --> +<div class="layui-fluid"> + <div class="layui-card"> + <div class="layui-card-body"> + <!-- 鏁版嵁琛ㄦ牸 --> + <table id="tag"></table> + </div> + </div> +</div> + +<script type="text/html" id="operate"> + <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">淇敼</a> + <a class="layui-btn layui-btn-danger layui-btn-xs btn-del" lay-event="del">鍒犻櫎</a> +</script> + +<!-- 琛ㄥ崟寮圭獥 --> +<script type="text/html" id="editDialog"> + <form id="detail" lay-filter="detail" class="layui-form"> + <input name="id" type="hidden"> + <input name="uuid" type="hidden"> + <input name="path" type="hidden"> + <input name="pathName" type="hidden"> + <input name="img" type="hidden"> + <input name="brief" type="hidden"> + <input name="level" type="hidden"> + <input name="count" type="hidden"> + <input name="createTime$" type="hidden"> + <input name="createBy" type="hidden"> + <input name="updateTime$" type="hidden"> + <input name="updateBy" type="hidden"> + <div class="layui-row"> + + <div class="layui-col-md6"> + + <div class="layui-form-item"> + <label class="layui-form-label">涓婄骇鑿滃崟</label> + <div class="layui-input-block"> + <div id="tagParentSel" class="ew-xmselect-tree"></div> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">绫诲瀷</label> + <div class="layui-input-block"> + <select name="type" lay-vertype="tips"> + <option value="">璇烽�夋嫨绫诲瀷</option> + <option value="0">鍏朵粬</option> + </select> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">璐熻矗浜�</label> + <div class="layui-input-block"> + <input name="leading" placeholder="璇疯緭鍏ヨ礋璐d汉" class="layui-input"> + </div> + </div> + + </div> + + <div class="layui-col-md6"> + + <div class="layui-form-item"> + <label class="layui-form-label layui-form-required">褰掔被鍚嶇О</label> + <div class="layui-input-block"> + <input name="name" placeholder="璇疯緭鍏ュ綊绫诲悕绉�" class="layui-input" lay-vertype="tips" lay-verify="required" required=""> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">鎺掑簭</label> + <div class="layui-input-block"> + <input name="sort" placeholder="璇疯緭鍏ユ帓搴�" class="layui-input"> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">澶囨敞</label> + <div class="layui-input-block"> + <input name="memo" placeholder="璇疯緭鍏ュ娉�" class="layui-input"> + </div> + </div> + + </div> + </div> + <hr class="layui-bg-gray"> + <div class="layui-form-item text-right"> + <button class="layui-btn" lay-filter="editSubmit" lay-submit="">淇濆瓨</button> + <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">鍙栨秷</button> + </div> + </form> +</script> + +<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> +<script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> +<script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> +<script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> + +<script> + layui.config({ + base: baseUrl + "/static/layui/lay/modules/" + }).use(['form','treeTable', 'admin', 'xmSelect'], function() { + var $ = layui.jquery; + var layer = layui.layer; + var form = layui.form; + var admin = layui.admin; + var treeTable = layui.treeTable; + var xmSelect = layui.xmSelect; + var tbDataList = []; + + var insTb = treeTable.render({ + elem: '#tag', + url: baseUrl+'/tag/list/auth', + headers: {token: localStorage.getItem('token')}, + height: 'full-200', + toolbar: ['<p>', + '<button lay-event="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon"></i>娣诲姞</button> ', + '<button lay-event="del" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon"></i>鍒犻櫎</button>', + '</p>'].join(''), + tree: { + iconIndex: 2, // 鎶樺彔鍥炬爣鏄剧ず鍦ㄧ鍑犲垪 + isPidData: true, // 鏄惁鏄痠d銆乸id褰㈠紡鏁版嵁 + idName: 'id', // id瀛楁鍚嶇О + pidName: 'parentId' // pid瀛楁鍚嶇О + }, + cols: [[ + {type: 'checkbox'} + ,{type: 'numbers'} + ,{field: 'name', align: 'left',title: '鍚嶇О', minWidth: 150} + // ,{field: 'uuid', align: 'center',title: '缂栧彿'} + ,{field: 'type$', align: 'center',title: '绫诲瀷'} + ,{field: 'leading', align: 'center',title: '璐熻矗浜�'} + ,{field: 'img', align: 'center',title: '鍥剧墖', hide: true} + // ,{field: 'brief', align: 'center',title: '绠�瑕佹弿杩�'} + // ,{field: 'count', align: 'center',title: '鏁伴噺'} + ,{field: 'sort', align: 'center',title: '鎺掑簭'} + ,{field: 'status$', align: 'center',title: '鐘舵��'} + ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿'} + ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳', hide: true} + ,{field: 'memo', align: 'center',title: '澶囨敞', hide: true} + + ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:150} + ]], + done: function (data) { + $('.ew-tree-table-box').css('height', '100%'); + insTb.expandAll(); + tbDataList = data; + } + }); + + /* 琛ㄦ牸澶村伐鍏锋爮鐐瑰嚮浜嬩欢 */ + treeTable.on('toolbar(tag)', function (obj) { + if (obj.event === 'add') { // 娣诲姞 + showEditModel(); + } else if (obj.event === 'del') { // 鍒犻櫎 + var checkRows = insTb.checkStatus(); + if (checkRows.length === 0) { + layer.msg('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁', {icon: 2}); + return; + } + var ids = checkRows.map(function (d) { + if (!d.LAY_INDETERMINATE) { + return d.id; + } else { + return null; + } + }); + doDel({ids: ids}); + } + }); + + /* 琛ㄦ牸鎿嶄綔鍒楃偣鍑讳簨浠� */ + treeTable.on('tool(tag)', function (obj) { + if (obj.event === 'edit') { // 淇敼 + showEditModel(obj.data); + } else if (obj.event === 'del') { // 鍒犻櫎 + doDel(obj); + } + }); + + /* 鏄剧ず琛ㄥ崟寮圭獥 */ + function showEditModel(mData) { + admin.open({ + type: 1, + area: '600px', + title: (mData ? '淇敼' : '娣诲姞') + '褰掔被', + content: $('#editDialog').html(), + success: function (layero, dIndex) { + // 鍥炴樉琛ㄥ崟鏁版嵁 + form.val('detail', mData); + // 琛ㄥ崟鎻愪氦浜嬩欢 + form.on('submit(editSubmit)', function (data) { + data.field.parentId = insXmSel.getValue('valueStr'); + var loadIndex = layer.load(2); + $.ajax({ + url: baseUrl+"/tag/"+(mData?'update':'add')+"/auth", + headers: {'token': localStorage.getItem('token')}, + data: data.field, + method: 'POST', + success: function (res) { + layer.close(loadIndex); + if (res.code === 200){ + layer.close(dIndex); + layer.msg(res.msg, {icon: 1}); + insTb.refresh(); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + }else { + layer.msg(res.msg, {icon: 2}); + } + } + }) + return false; + }); + // 娓叉煋涓嬫媺鏍� + var insXmSel = xmSelect.render({ + el: '#tagParentSel', + height: '250px', + data: insTb.options.data, + initValue: mData ? [mData.parentId] : [], + model: {label: {type: 'text'}}, + prop: { + name: 'name', + value: 'id' + }, + radio: true, + clickClose: true, + tree: { + show: true, + indent: 15, + strict: false, + expandedKeys: false + } + }); + // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯 + $(layero).children('.layui-layer-content').css('overflow', 'visible'); + layui.form.render('select'); + } + }); + } + + /* 鍒犻櫎 */ + function doDel(obj) { + layer.confirm('纭畾瑕佸垹闄ら�変腑鏁版嵁鍚楋紵', { + skin: 'layui-layer-admin', + shade: .1 + }, function (i) { + layer.close(i); + var loadIndex = layer.load(2); + var ids; + if (obj.data) { + ids = []; + ids[0] = obj.data.id; + } else { + ids = obj.ids; + } + $.ajax({ + url: baseUrl+"/tag/delete/auth", + headers: {'token': localStorage.getItem('token')}, + data: {ids: ids}, + method: 'POST', + success: function (res) { + layer.close(loadIndex); + if (res.code === 200){ + layer.msg(res.msg, {icon: 1}); + insTb.refresh(); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + } else { + layer.msg(res.msg, {icon: 2}); + } + } + }) + }); + } + + }); +</script> +</body> +</html> + -- Gitblit v1.9.1