From 7d7090b098add475808ffdebebff8b4e2a3b98ff Mon Sep 17 00:00:00 2001 From: whycq <123456> Date: 星期六, 06 八月 2022 12:58:12 +0800 Subject: [PATCH] Merge branch 'hylyasrs' of http://47.97.1.152:5880/r/zy-asrs into hylyasrs --- src/main/webapp/views/locDetl/locDetl.html | 139 + src/main/java/com/zy/asrs/entity/param/CombParam.java | 3 src/main/java/com/zy/asrs/mapper/LocDetlMapper.java | 4 src/main/java/com/zy/common/web/BaseController.java | 42 src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java | 122 ++ src/main/java/com/zy/system/entity/UserLogin.java | 14 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 38 src/main/java/com/zy/asrs/service/impl/NodeServiceImpl.java | 55 + src/main/java/com/zy/common/entity/NodeExcel.java | 18 src/main/java/com/zy/common/entity/NodeExcelListener.java | 146 ++ src/main/java/com/zy/asrs/service/MobileService.java | 5 src/main/java/com/zy/asrs/controller/ManLocDetlController.java | 57 + src/main/java/com/zy/asrs/mapper/NodeMapper.java | 13 src/main/java/com/zy/asrs/service/LocDetlService.java | 3 src/main/java/com/zy/asrs/controller/LocDetlController.java | 6 src/main/java/com/zy/asrs/entity/Node.java | 425 ++++++++ src/main/java/com/zy/asrs/service/impl/LocDetlServiceImpl.java | 7 src/main/java/com/zy/asrs/controller/MobileController.java | 10 src/main/java/com/zy/asrs/mapper/ManLocDetlMapper.java | 68 + src/main/java/com/zy/asrs/entity/ManLocDetl.java | 325 ++++++ src/main/resources/mapper/ManLocDetlMapper.xml | 221 ++++ src/main/webapp/static/js/locDetl/locDetl.js | 180 +- src/main/webapp/views/node/node.html | 431 ++++++++ src/main/java/com/zy/asrs/controller/NodeController.java | 282 +++++ src/main/java/com/zy/common/utils/TreeUtils.java | 53 + src/main/java/com/zy/common/utils/NodeUtils.java | 44 src/main/webapp/static/js/nodeTree.js | 87 + src/main/java/com/zy/asrs/service/ManLocDetlService.java | 56 + src/main/java/com/zy/asrs/service/NodeService.java | 17 src/main/resources/application.yml | 2 src/main/java/com/zy/asrs/entity/NodeExcel.java | 20 31 files changed, 2,759 insertions(+), 134 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/LocDetlController.java b/src/main/java/com/zy/asrs/controller/LocDetlController.java index 2f91219..32c72fd 100644 --- a/src/main/java/com/zy/asrs/controller/LocDetlController.java +++ b/src/main/java/com/zy/asrs/controller/LocDetlController.java @@ -13,9 +13,11 @@ import com.core.common.DateUtils; import com.core.common.R; import com.zy.asrs.entity.LocDetl; +import com.zy.asrs.entity.ManLocDetl; import com.zy.asrs.entity.Mat; import com.zy.asrs.mapper.LocDetlMapper; import com.zy.asrs.service.LocDetlService; +import com.zy.asrs.service.ManLocDetlService; import com.zy.asrs.service.MatService; import com.zy.common.web.BaseController; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +33,7 @@ @Autowired private LocDetlService locDetlService; + @Autowired private LocDetlMapper locDetlMapper; @Autowired @@ -83,7 +86,7 @@ return R.ok(locDetlService.getStockOut(toPage(curr, limit, param, LocDetl.class))); } - @RequestMapping(value = "/locDetl/list/auth") + @RequestMapping(value = "/error/locDetl/list/auth")// /locDetl/list/auth 鎺ュ彛闂 @ManagerAuth public R list(@RequestParam(defaultValue = "1")Integer curr, @RequestParam(defaultValue = "10")Integer limit, @@ -114,6 +117,7 @@ return R.ok(locDetlService.selectPage(new Page<>(curr, limit), wrapper)); } + private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ for (Map.Entry<String, Object> entry : map.entrySet()){ String val = String.valueOf(entry.getValue()); diff --git a/src/main/java/com/zy/asrs/controller/ManLocDetlController.java b/src/main/java/com/zy/asrs/controller/ManLocDetlController.java new file mode 100644 index 0000000..6202e80 --- /dev/null +++ b/src/main/java/com/zy/asrs/controller/ManLocDetlController.java @@ -0,0 +1,57 @@ +package com.zy.asrs.controller; + +import com.core.annotations.ManagerAuth; +import com.core.common.Cools; +import com.core.common.DateUtils; +import com.core.common.R; +import com.zy.asrs.entity.ManLocDetl; +import com.zy.asrs.service.ManLocDetlService; +import com.zy.common.web.BaseController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +public class ManLocDetlController extends BaseController { + + @Autowired + private ManLocDetlService manLocDetlService; + + @RequestMapping(value = "/manLocDetl/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){ + Long hostId = getHostId(); + System.out.println(hostId); + if (hostId != null) { + param.put("host_id", hostId); + } + Object nodeId = param.get("node_id"); + if (Cools.isEmpty(nodeId)) { + nodeId = getOriginNode().getId(); + param.put("node_id", String.valueOf(nodeId)); + } + Object tagId = param.get("tag_id"); + if (Cools.isEmpty(tagId)) { + tagId = getOriginTag().getId(); + param.put("tag_id", String.valueOf(tagId)); + } + if (!Cools.isEmpty(param.get("update_time"))){ + String val = String.valueOf(param.get("update_time")); + if (val.contains(RANGE_TIME_LINK)) { + String[] dates = val.split(RANGE_TIME_LINK); + param.put("startTime", DateUtils.convert(dates[0])); + param.put("endTime", DateUtils.convert(dates[1])); + param.remove("update_time"); + } + } + System.out.println(param); + return R.ok(manLocDetlService.getPage(toPage(curr, limit, param, ManLocDetl.class))); + } +} diff --git a/src/main/java/com/zy/asrs/controller/MobileController.java b/src/main/java/com/zy/asrs/controller/MobileController.java index 0b1729b..a59f8bb 100644 --- a/src/main/java/com/zy/asrs/controller/MobileController.java +++ b/src/main/java/com/zy/asrs/controller/MobileController.java @@ -52,6 +52,16 @@ @Autowired private PackService packService; + + // 鍟嗗搧涓婃灦 + @RequestMapping("/mat/onSale/auth") + //@ManagerAuth + public R matOnSale(@RequestBody CombParam combParam){ + mobileService.onSale(combParam); + return R.ok("涓婃灦鎴愬姛"); + } + // 鍟嗗搧涓嬫灦 + // 缁勬墭 ---------------------------------------------------------------------------------------------------- /** diff --git a/src/main/java/com/zy/asrs/controller/NodeController.java b/src/main/java/com/zy/asrs/controller/NodeController.java new file mode 100644 index 0000000..f03e4e7 --- /dev/null +++ b/src/main/java/com/zy/asrs/controller/NodeController.java @@ -0,0 +1,282 @@ +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.BaseRes; +import com.core.common.Cools; +import com.core.common.DateUtils; +import com.core.common.R; +import com.zy.asrs.entity.Node; +import com.zy.asrs.service.NodeService; +import com.zy.common.entity.NodeExcel; +import com.zy.common.entity.NodeExcelListener; +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.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.*; + +import static jdk.nashorn.api.scripting.ScriptUtils.convert; + +@RestController +public class NodeController extends BaseController { + + @Autowired + private NodeService nodeService; + @Autowired + private TreeUtils treeUtils; + + @RequestMapping(value = "/node/{id}/auth") + @ManagerAuth + public R get(@PathVariable("id") String id) { + return R.ok(nodeService.selectById(String.valueOf(id))); + } + + @RequestMapping(value = "/node/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<Node> wrapper = new EntityWrapper<>(); + excludeTrash(param); + convert(param, wrapper); + hostEq(wrapper); + if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} + return R.ok(nodeService.selectPage(new Page<>(curr, limit), wrapper)); + } + + @RequestMapping(value = "/node/list/tree/auth") + @ManagerAuth + public R listTree(@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<Node> wrapper = new EntityWrapper<>(); + excludeTrash(param); + convert(param, wrapper); + hostEq(wrapper); + if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} + return R.parse("0-鎿嶄綔鎴愬姛").add(nodeService.selectList(wrapper)); + } + + @RequestMapping(value = "/node/tree/auth") + @ManagerAuth + public R tree(@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<Node> wrapper = new EntityWrapper<>(); + excludeTrash(param); + convert(param, wrapper); + hostEq(wrapper); + if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} + return R.parse("0-鎿嶄綔鎴愬姛").add(nodeService.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 = "/node/add/auth") + @ManagerAuth + public R add(Node node) { + if (node.getType() != 1) { + Node parentNode = nodeService.selectById(node.getParentId()); + if (parentNode == null || parentNode.getStatus() == 0) { + return R.error(node.getType()==2?"鎵�灞炰粨搴撲笉瀛樺湪":"鎵�灞炲簱鍖轰笉瀛樺湪"); + } + node.setParentName(parentNode.getName()); + node.setLevel(parentNode.getLevel() + 1); + } + // path + NodeUtils nodeUtils = new NodeUtils(); + nodeUtils.executePath(node); + node.setHostId(getHostId()); + node.setUuid(node.getName().toString()); + System.out.println(node.getUuid()); + node.setPath(nodeUtils.path.toString()); + node.setNamePath(nodeUtils.pathName.toString()); + node.setLevel(node.getType()); + node.setCreateBy(getUserId()); + node.setCreateTime(new Date()); + node.setUpdateBy(getUserId()); + node.setUpdateTime(new Date()); + node.setStatus(1); + nodeService.insert(node); + return R.ok(); + } + + @RequestMapping(value = "/node/update/auth") + @ManagerAuth + public R update(Node node){ + if (Cools.isEmpty(node) || null==node.getId()){ + return R.error(); + } + if (node.getType() != 1) { + Node parentNode = nodeService.selectById(node.getParentId()); + if (parentNode == null || parentNode.getStatus() == 0) { + return R.error(node.getType()==2?"鎵�灞炰粨搴撲笉瀛樺湪":"鎵�灞炲簱鍖轰笉瀛樺湪"); + } + node.setParentName(parentNode.getName()); + node.setLevel(parentNode.getLevel() + 1); + } + // path + NodeUtils nodeUtils = new NodeUtils(); + nodeUtils.executePath(node); + node.setPath(nodeUtils.path.toString()); + node.setNamePath(nodeUtils.pathName.toString()); + + node.setUpdateBy(getUserId()); + node.setUpdateTime(new Date()); + nodeService.updateById(node); + return R.ok(); + } + + @RequestMapping(value = "/node/delete/auth") + @ManagerAuth + public R delete(@RequestParam String param){ + List<Node> list = JSONArray.parseArray(param, Node.class); + if (Cools.isEmpty(list)){ + return R.error(); + } + for (Node entity : list){ + nodeService.delete(new EntityWrapper<>(entity)); + } + return R.ok(); + } + + @RequestMapping(value = "/node/delete0/auth") + @ManagerAuth + public R delete(@RequestParam(value="ids[]") Long[] ids){ + for (Long id : ids){ + nodeService.deleteById(id); + } + return R.ok(); + } + + @RequestMapping(value = "/node/export/auth") + @ManagerAuth + public R export(@RequestBody JSONObject param){ + EntityWrapper<Node> wrapper = new EntityWrapper<>(); + List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); + Map<String, Object> map = excludeTrash(param.getJSONObject("node")); + convert(map, wrapper); + List<Node> list = nodeService.selectList(wrapper); + return R.ok(exportSupport(list, fields)); + } + + @RequestMapping(value = "/nodeQuery/auth") + @ManagerAuth + public R query(String condition) { + EntityWrapper<Node> wrapper = new EntityWrapper<>(); + wrapper.like("name", condition).or().like("uuid", condition).eq("type", 3); + hostEq(wrapper); + Page<Node> page = nodeService.selectPage(new Page<>(0, 10), wrapper); + List<Map<String, Object>> result = new ArrayList<>(); + for (Node node : page.getRecords()){ + Map<String, Object> map = new HashMap<>(); + map.put("id", node.getId()); + map.put("value", node.getUuid() + "锛�" +node.getName()+ "锛�"); + result.add(map); + } + return R.ok(result); + } + + @RequestMapping(value = "/node/check/column/auth") + @ManagerAuth + public R query(@RequestBody JSONObject param) { + Wrapper<Node> wrapper = new EntityWrapper<Node>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); + if (null != nodeService.selectOne(wrapper)){ + return R.parse(BaseRes.REPEAT).add(getComment(Node.class, String.valueOf(param.get("key")))); + } + return R.ok(); + } + + @PostMapping(value = "/parent/node/group") + @ManagerAuth + public R getParentNodeGroup(@RequestParam(required = false) String condition, + @RequestParam Integer type) { + EntityWrapper<Node> wrapper = new EntityWrapper<>(); + wrapper.eq("type", type).eq("status", 1); + hostEq(wrapper); + List<Node> nodes = nodeService.selectList(wrapper); + + List<Map<String, Object>> result = new ArrayList<>(); + for (Node node : nodes) { + Map<String, Object> map = new HashMap<>(); + map.put("key", node.getId()); + map.put("val", node.getName()); + result.add(map); + } + return R.ok().add(result); + } + + @PostMapping(value = "/node/tree/auth") + @ManagerAuth + public R tree(@RequestParam(required = false, defaultValue = "") String condition) throws IOException, ClassNotFoundException { + ArrayList<Map> tree = treeUtils.getNodeTree(String.valueOf(getOriginNode().getId()), getHostId()); + // 娣辨嫹璐� + List<Map> result = ListUtils.deepCopy(tree); + if (!Cools.isEmpty(condition)) { + treeUtils.remove(condition, result); + treeUtils.remove(condition, result); + } + return R.ok(result); + } + + /*************************************** 鏁版嵁鐩稿叧 ***********************************************/ + + /** + * excel瀵煎叆妯℃澘涓嬭浇 + */ + @RequestMapping(value = "/node/excel/import/mould") + public void nodeExcelImportMould(HttpServletResponse response) throws IOException { + List<NodeExcel> 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(), NodeExcel.class) + .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) + .sheet("sheet1") + .doWrite(excels); + } + + // excel瀵煎叆 + @PostMapping(value = "/node/excel/import/auth") + @ManagerAuth(memo = "璐т綅妗f鏁版嵁瀵煎叆") + @Transactional + public R nodeExcelImport(MultipartFile file) throws IOException { + NodeExcelListener listener = new NodeExcelListener(getUserId(), getHostId()); + EasyExcel.read(file.getInputStream(), NodeExcel.class, listener).sheet().doRead(); + return R.ok("鎴愬姛鍚屾"+listener.getTotal()+"涓揣浣�"); + } + +} diff --git a/src/main/java/com/zy/asrs/entity/ManLocDetl.java b/src/main/java/com/zy/asrs/entity/ManLocDetl.java new file mode 100644 index 0000000..ce546a1 --- /dev/null +++ b/src/main/java/com/zy/asrs/entity/ManLocDetl.java @@ -0,0 +1,325 @@ +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.NodeService; +import com.zy.system.entity.Host; +import com.zy.system.entity.User; +import com.zy.system.service.HostService; +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_loc_detl") +public class ManLocDetl implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 鎵�灞為」鐩� + */ + @ApiModelProperty(value= "鎵�灞為」鐩�") + @TableField("host_id") + private Long hostId; + + /** + * 璐т綅缂栧彿 + */ + @ApiModelProperty(value= "璐т綅缂栧彿") + @TableId(value = "loc_no", type = IdType.INPUT) + @TableField("loc_no") + private String locNo; + + /** + * 鎵�灞炶揣浣� + */ + @ApiModelProperty(value= "鎵�灞炶揣浣�") + @TableField("node_id") + private Long nodeId; + + /** + * 鎵樼洏鐮� + */ + @ApiModelProperty(value= "鎵樼洏鐮�") + private String zpallet; + + /** + * 搴撳瓨浣欓噺 + */ + @ApiModelProperty(value= "搴撳瓨浣欓噺") + @ExcelProperty(value = "搴撳瓨鎬婚噺") + private Double anfme; + + /** + * 鍟嗗搧缂栧彿 + */ + @ApiModelProperty(value= "鍟嗗搧缂栧彿") + @TableId(value = "matnr", type = IdType.INPUT) + @ExcelProperty(value = "鍟嗗搧缂栧彿") + private String matnr; + + /** + * 鍟嗗搧鍚嶇О + */ + @ApiModelProperty(value= "鍟嗗搧鍚嶇О") + @ExcelProperty(value = "鍟嗗搧鍚嶇О") + private String maktx; + + /** + * 鍚嶇О + */ + @ApiModelProperty(value= "鍚嶇О") + private String name; + + /** + * 瑙勬牸 + */ + @ApiModelProperty(value= "瑙勬牸") + @ExcelProperty(value = "瑙勬牸") + private String specs; + + /** + * 鍨嬪彿 + */ + @ApiModelProperty(value= "鍨嬪彿") + private String model; + + /** + * 鎵瑰彿 + */ + @ApiModelProperty(value= "鎵瑰彿") + @TableId(value = "batch", type = IdType.INPUT) + private String batch; + + /** + * 鍗曚綅 + */ + @ApiModelProperty(value= "鍗曚綅") + @ExcelProperty(value = "鍗曚綅") + private String unit; + + /** + * SKC + */ + @ApiModelProperty(value= "SKC") + @ExcelProperty(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; + + + /** + * 鍗曚环 + */ + @ApiModelProperty(value= "鍗曚环") + private Double price; + + /** + * 閲嶉噺 + */ + @ApiModelProperty(value= "閲嶉噺") + private Double weight; + + /** + * 鐘舵�� 1: 姝e父 0: 绂佺敤 + */ + @ApiModelProperty(value= "鐘舵�� 1: 姝e父 0: 绂佺敤 ") + 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; + + /** + * 澶囨敞 + */ + @ApiModelProperty(value= "澶囨敞") + private String memo; + + public ManLocDetl() {} + + public ManLocDetl(Long hostId, String locNo,Long nodeId,String zpallet,Double anfme,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.hostId = hostId; + this.nodeId = nodeId; + this.zpallet = zpallet; + this.anfme = anfme; + 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; + } + +// LocDetl locDetl = new LocDetl( +// null, // 璐т綅缂栧彿[闈炵┖] +// 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 getHostId$(){ + HostService service = SpringUtils.getBean(HostService.class); + Host host = service.selectById(this.hostId); + if (!Cools.isEmpty(host)){ + return String.valueOf(host.getName()); + } + return null; + } + + public Long getNodeId() { + return nodeId; + } + + public String getNodeId$(){ + NodeService service = SpringUtils.getBean(NodeService.class); + Node node = service.selectById(this.nodeId); + if (!Cools.isEmpty(node)){ + return String.valueOf(node.getName()); + } + return null; + } + + 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 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 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/Node.java b/src/main/java/com/zy/asrs/entity/Node.java new file mode 100644 index 0000000..db7fe9d --- /dev/null +++ b/src/main/java/com/zy/asrs/entity/Node.java @@ -0,0 +1,425 @@ +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.Host; +import com.zy.system.entity.User; +import com.zy.system.service.HostService; +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_node") +public class Node implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * ID + */ + @ApiModelProperty(value= "ID") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 鎵�灞為」鐩� + */ + @ApiModelProperty(value= "鎵�灞為」鐩�") + @TableField("host_id") + private Long hostId; + + /** + * 缂栧彿 + */ + @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; + + /** + * 绫诲瀷 1: 浠撳簱 2: 搴撳尯 3: 璐т綅 + */ + @ApiModelProperty(value= "绫诲瀷 1: 浠撳簱 2: 搴撳尯 3: 璐т綅 ") + private Integer type; + + /** + * 鍏宠仈璺緞 + */ + @ApiModelProperty(value= "鍏宠仈璺緞") + private String path; + + /** + * 鍏宠仈璺緞鍚� + */ + @ApiModelProperty(value= "鍏宠仈璺緞鍚�") + @TableField("name_path") + private String namePath; + + /** + * 绛夌骇 + */ + @ApiModelProperty(value= "绛夌骇") + private Integer level; + + /** + * 璐熻矗浜� + */ + @ApiModelProperty(value= "璐熻矗浜�") + private String leading; + + /** + * 鎺掑簭 + */ + @ApiModelProperty(value= "鎺掑簭") + private Integer sort; + + /** + * 鏉$爜 + */ + @ApiModelProperty(value= "鏉$爜") + private String barcode; + + /** + * 鎺ㄨ崘浣� + */ + @ApiModelProperty(value= "鎺ㄨ崘浣�") + private Integer major; + + /** + * 鐘舵�� 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 Node() {} + + public Node(Long hostId, String uuid,String name,Long parentId,String parentName,Integer type,String path,String namePath,Integer level,String leading,Integer sort,String barcode,Integer major,Integer status,Date createTime,Long createBy,Date updateTime,Long updateBy,String memo) { + this.hostId = hostId; + this.uuid = uuid; + this.name = name; + this.parentId = parentId; + this.parentName = parentName; + this.type = type; + this.path = path; + this.namePath = namePath; + this.level = level; + this.leading = leading; + this.sort = sort; + this.barcode = barcode; + this.major = major; + this.status = status; + this.createTime = createTime; + this.createBy = createBy; + this.updateTime = updateTime; + this.updateBy = updateBy; + this.memo = memo; + } + +// Node node = new Node( +// 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 Long getHostId() { + return hostId; + } + + public void setHostId(Long hostId) { + this.hostId = hostId; + } + + public String getHostId$(){ + HostService service = SpringUtils.getBean(HostService.class); + Host host = service.selectById(this.hostId); + if (!Cools.isEmpty(host)){ + return String.valueOf(host.getName()); + } + return null; + } + + 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 Integer getType() { + return type; + } + + public String getType$(){ + if (null == this.type){ return null; } + switch (this.type){ + case 1: + return "浠撳簱"; + case 2: + return "搴撳尯"; + case 3: + return "璐т綅"; + default: + return String.valueOf(this.type); + } + } + + public void setType(Integer type) { + this.type = type; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getNamePath() { + return namePath; + } + + public void setNamePath(String namePath) { + this.namePath = namePath; + } + + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + public String getLeading() { + return leading; + } + + public void setLeading(String leading) { + this.leading = leading; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public String getBarcode() { + return barcode; + } + + public void setBarcode(String barcode) { + this.barcode = barcode; + } + + public Integer getMajor() { + return major; + } + + public void setMajor(Integer major) { + this.major = major; + } + + 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.getUsername()); + } + 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.getUsername()); + } + 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/NodeExcel.java b/src/main/java/com/zy/asrs/entity/NodeExcel.java new file mode 100644 index 0000000..0b2a114 --- /dev/null +++ b/src/main/java/com/zy/asrs/entity/NodeExcel.java @@ -0,0 +1,20 @@ +package com.zy.asrs.entity; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +@Data +@ExcelIgnoreUnannotated +public class NodeExcel { + + @ExcelProperty(index = 0, value = "浠撳簱") + private String warehouse; + + @ExcelProperty(index = 1, value = "搴撳尯") + private String area; + + @ExcelProperty(index = 2, value = "璐т綅") + private String allo; + +} \ No newline at end of file diff --git a/src/main/java/com/zy/asrs/entity/param/CombParam.java b/src/main/java/com/zy/asrs/entity/param/CombParam.java index 84a4927..e19b459 100644 --- a/src/main/java/com/zy/asrs/entity/param/CombParam.java +++ b/src/main/java/com/zy/asrs/entity/param/CombParam.java @@ -16,6 +16,9 @@ // 鎵樼洏鏉$爜 private String barcode; + // 搴撲綅缂栧彿 + private String locno; + private List<CombMat> combMats; @Data diff --git a/src/main/java/com/zy/asrs/mapper/LocDetlMapper.java b/src/main/java/com/zy/asrs/mapper/LocDetlMapper.java index 70a401c..df6a553 100644 --- a/src/main/java/com/zy/asrs/mapper/LocDetlMapper.java +++ b/src/main/java/com/zy/asrs/mapper/LocDetlMapper.java @@ -17,6 +17,10 @@ @Repository public interface LocDetlMapper extends BaseMapper<LocDetl> { + List<LocDetl> listByPage(Map<String, Object> map); + + Integer listByPageCount(Map<String, Object> map); + LocDetl selectItem(@Param("locNo")String locNo, @Param("matnr")String matnr, @Param("batch")String batch); int deleteItem(@Param("locNo")String locNo, @Param("matnr")String matnr, @Param("batch")String batch); diff --git a/src/main/java/com/zy/asrs/mapper/ManLocDetlMapper.java b/src/main/java/com/zy/asrs/mapper/ManLocDetlMapper.java new file mode 100644 index 0000000..f53365d --- /dev/null +++ b/src/main/java/com/zy/asrs/mapper/ManLocDetlMapper.java @@ -0,0 +1,68 @@ +package com.zy.asrs.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.zy.asrs.entity.ManLocDetl; +import com.zy.asrs.entity.result.StockVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +@Mapper +@Repository +public interface ManLocDetlMapper extends BaseMapper<ManLocDetl> { + List<ManLocDetl> listByPage(Map<String, Object> map); + + Integer listByPageCount(Map<String, Object> map); + + ManLocDetl selectItem(@Param("locNo")String locNo, @Param("matnr")String matnr, @Param("batch")String batch); + + int deleteItem(@Param("locNo")String locNo, @Param("matnr")String matnr, @Param("batch")String batch); + + int updateAnfme(@Param("anfme")Double anfme, @Param("locNo")String locNo, @Param("matnr")String matnr, @Param("batch")String batch); + + List<ManLocDetl> getStockOutPage(Map<String, Object> map); + + Integer getStockOutPageCount(Map<String, Object> map); + + @Update("update asr_loc_detl set loc_no = #{newLocNo}, modi_time=getDate() where loc_no = #{oldLocNo}") + int updateLocNo(String newLocNo, String oldLocNo); + + @Select("SELECT ld.loc_no FROM asr_loc_detl ld LEFT JOIN asr_loc_mast lm ON ld.loc_no = lm.loc_no WHERE (1 = 1 AND ld.matnr = #{matnr} AND (lm.row1 >= #{start} AND lm.row1 <= #{end}) AND lm.loc_sts = 'F' AND DateDiff(dd, lm.appe_time, getdate()) = 0) ORDER BY lm.appe_time ASC") + List<String> selectSameDetlToday(@Param("matnr") String matnr, @Param("start") Integer start, @Param("end") Integer end); + + List<ManLocDetl> getStockStatis(Map<String, Object> map); + + Integer getStockStatisCount(Map<String, Object> map); + + List<ManLocDetl> getStockStatisExcel(); + + @Select("select sum(a.anfme) as sum from asr_loc_detl a left join asr_loc_mast b on a.loc_no = b.loc_no where b.loc_sts = 'F' and a.matnr = #{matnr}") + Double selectSumAnfmeByMatnr(@Param("matnr") String matnr); + + List<ManLocDetl> selectPakoutByRule(String matnr); + + List<ManLocDetl> getAsrsLocDetl(String matnr); + + Integer countLocNoNum(String locNo); + + // ------------------------------------------------- + + List<ManLocDetl> queryStock(@Param("matnr")String matnr, @Param("batch")String batch, @Param("orderNo")String orderNo, @Param("locNos") Set<String> locNos); + + Double queryStockAnfme(String matnr, String batch); + + List<StockVo> queryStockTotal(); + + + Integer sum(); + + List<ManLocDetl> unreason(); + + Double selectLocDetlSumQty(String locNo); +} diff --git a/src/main/java/com/zy/asrs/mapper/NodeMapper.java b/src/main/java/com/zy/asrs/mapper/NodeMapper.java new file mode 100644 index 0000000..3ef9b37 --- /dev/null +++ b/src/main/java/com/zy/asrs/mapper/NodeMapper.java @@ -0,0 +1,13 @@ +package com.zy.asrs.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.zy.asrs.entity.Node; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +@Mapper +@Repository +public interface NodeMapper extends BaseMapper<Node> { + Node selectByUuid(@Param("uuid") String uuid, @Param("hostId") Long hostId); +} diff --git a/src/main/java/com/zy/asrs/service/LocDetlService.java b/src/main/java/com/zy/asrs/service/LocDetlService.java index dcc7369..0023ecf 100644 --- a/src/main/java/com/zy/asrs/service/LocDetlService.java +++ b/src/main/java/com/zy/asrs/service/LocDetlService.java @@ -6,10 +6,13 @@ import com.zy.asrs.entity.result.StockVo; import java.util.List; +import java.util.Map; import java.util.Set; public interface LocDetlService extends IService<LocDetl> { + Page<LocDetl> getPage(Page<LocDetl> page); + LocDetl selectItem(String locNo, String matnr, String batch); Page<LocDetl> getStockOut(Page<LocDetl> page); diff --git a/src/main/java/com/zy/asrs/service/ManLocDetlService.java b/src/main/java/com/zy/asrs/service/ManLocDetlService.java new file mode 100644 index 0000000..21597aa --- /dev/null +++ b/src/main/java/com/zy/asrs/service/ManLocDetlService.java @@ -0,0 +1,56 @@ +package com.zy.asrs.service; + +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.IService; +import com.zy.asrs.entity.ManLocDetl; +import com.zy.asrs.entity.result.StockVo; + +import java.util.List; +import java.util.Set; + +public interface ManLocDetlService extends IService<ManLocDetl> { + Page<ManLocDetl> getPage(Page<ManLocDetl> page); + + ManLocDetl selectItem(String locNo, String matnr, String batch); + + Page<ManLocDetl> getStockOut(Page<ManLocDetl> page); + + /** + * 淇敼搴撳瓨鏄庣粏鏁伴噺锛屽鏋滄暟閲忎负0锛屽垯鍒犻櫎璁板綍 + */ + boolean updateAnfme(Double anfme, String locNo, String matnr, String batch); + + boolean updateLocNo(String newLocNo, String oldLocNo); + + /** + * 鑾峰彇褰撳ぉ鐩稿悓瑙勬牸璐х墿鐨勬繁搴撲綅鍙� + * @param matnr 鍟嗗搧缂栧彿 + * @return locNo 搴撲綅鍙� + */ + List<String> getSameDetlToday(String matnr, Integer start, Integer end); + + Page<ManLocDetl> getStockStatis(Page<ManLocDetl> page); + + Double getSumAnfme(String matnr); + + List<ManLocDetl> selectPakoutByRule(String matnr); + + List<ManLocDetl> getAsrsLocDetl(String matnr); + + Integer countLocNoNum(String locNo); + + // -------------------------------------------------- + + List<ManLocDetl> queryStock(String matnr, String batch, String orderNo, Set<String> locNos); + + Double queryStockAnfme(String matnr, String batch); + + List<StockVo> queryStockTotal(); + + + Integer sum(); + + List<ManLocDetl> unreason(); + + Double getLocDetlSumQty(String locNo); +} diff --git a/src/main/java/com/zy/asrs/service/MobileService.java b/src/main/java/com/zy/asrs/service/MobileService.java index a6f1e5a..1dcc010 100644 --- a/src/main/java/com/zy/asrs/service/MobileService.java +++ b/src/main/java/com/zy/asrs/service/MobileService.java @@ -17,6 +17,11 @@ void comb(CombParam param, Long userId); /** + * 涓婃灦 + */ + void onSale(CombParam param); + + /** * 鐩樼偣 */ void adjust(MobileAdjustParam param, Long userId); diff --git a/src/main/java/com/zy/asrs/service/NodeService.java b/src/main/java/com/zy/asrs/service/NodeService.java new file mode 100644 index 0000000..caabb24 --- /dev/null +++ b/src/main/java/com/zy/asrs/service/NodeService.java @@ -0,0 +1,17 @@ +package com.zy.asrs.service; + +import com.baomidou.mybatisplus.service.IService; +import com.zy.asrs.entity.Node; + +public interface NodeService extends IService<Node> { + + Node getTop(); + + Node selectByUuid(String uuid); + + Node selectByUuid(String uuid, Long hostId); + + Node selectByUuid(String uuid, Long hostId, Integer type); + + Node selectByUuid(String uuid, Long hostId, Integer type, Long parentId); +} diff --git a/src/main/java/com/zy/asrs/service/impl/LocDetlServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/LocDetlServiceImpl.java index 5935ae7..44bdd07 100644 --- a/src/main/java/com/zy/asrs/service/impl/LocDetlServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/LocDetlServiceImpl.java @@ -15,6 +15,13 @@ public class LocDetlServiceImpl extends ServiceImpl<LocDetlMapper, LocDetl> implements LocDetlService { @Override + public Page<LocDetl> getPage(Page<LocDetl> page) { + page.setRecords(baseMapper.listByPage(page.getCondition())); + page.setTotal(baseMapper.listByPageCount(page.getCondition())); + return page; + } + + @Override public Page<LocDetl> getStockOut(Page<LocDetl> page) { page.setRecords(baseMapper.getStockOutPage(page.getCondition())); page.setTotal(baseMapper.getStockOutPageCount(page.getCondition())); diff --git a/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java new file mode 100644 index 0000000..3357726 --- /dev/null +++ b/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java @@ -0,0 +1,122 @@ +package com.zy.asrs.service.impl; + +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.zy.asrs.entity.ManLocDetl; +import com.zy.asrs.entity.result.StockVo; +import com.zy.asrs.mapper.ManLocDetlMapper; +import com.zy.asrs.service.ManLocDetlService; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Set; + +@Service("manLocDetlService") +public class ManLocDetlServiceImpl extends ServiceImpl<ManLocDetlMapper, ManLocDetl> implements ManLocDetlService{ + + + + @Override + public Page<ManLocDetl> getPage(Page<ManLocDetl> page) { + page.setRecords(baseMapper.listByPage(page.getCondition())); + page.setTotal(baseMapper.listByPageCount(page.getCondition())); + return page; + } + + @Override + public Page<ManLocDetl> getStockOut(Page<ManLocDetl> page) { + page.setRecords(baseMapper.getStockOutPage(page.getCondition())); + page.setTotal(baseMapper.getStockOutPageCount(page.getCondition())); + return page; + } + + @Override + public boolean updateAnfme(Double anfme, String locNo, String matnr, String batch) { + if (anfme <= 0) { + return this.baseMapper.deleteItem(locNo, matnr, batch) > 0; + } else { + return baseMapper.updateAnfme(anfme, locNo, matnr, batch) > 0; + } + } + + + @Override + public boolean updateLocNo(String newLocNo, String oldLocNo) { + return baseMapper.updateLocNo(newLocNo, oldLocNo) > 0; + } + + @Override + public List<String> getSameDetlToday(String matnr, Integer start, Integer end) { + return this.baseMapper.selectSameDetlToday(matnr, start, end); + } + + + @Override + public Page<ManLocDetl> getStockStatis(Page<ManLocDetl> page) { + page.setRecords(baseMapper.getStockStatis(page.getCondition())); + page.setTotal(baseMapper.getStockStatisCount(page.getCondition())); + return page; + } + + @Override + public Double getSumAnfme(String matnr) { + return this.baseMapper.selectSumAnfmeByMatnr(matnr); + } + + @Override + public List<ManLocDetl> selectPakoutByRule(String matnr) { + return this.baseMapper.selectPakoutByRule(matnr); + } + + @Override + public List<ManLocDetl> getAsrsLocDetl(String matnr) { + return this.baseMapper.getAsrsLocDetl(matnr); + } + + @Override + public Integer countLocNoNum(String locNo) { + return this.baseMapper.countLocNoNum(locNo); + } + + @Override + public List<ManLocDetl> queryStock(String matnr, String batch, String orderNo, Set<String> locNos) { + return this.baseMapper.queryStock(matnr, batch, orderNo, locNos); + } + + @Override + public Double queryStockAnfme(String matnr, String batch) { + return this.baseMapper.queryStockAnfme(matnr, batch); + } + + @Override + public List<StockVo> queryStockTotal() { + return this.baseMapper.queryStockTotal(); + } + + /** + * 鑾峰彇搴撳瓨鎬绘暟 + * @return + */ + @Override + public Integer sum() { + + return this.baseMapper.sum(); + } + + @Override + public List<ManLocDetl> unreason() { + return this.baseMapper.unreason(); + } + + + @Override + public ManLocDetl selectItem(String locNo, String matnr, String batch) { + return this.baseMapper.selectItem(locNo, matnr, batch); + } + + @Override + public Double getLocDetlSumQty(String locNo) { + return this.baseMapper.selectLocDetlSumQty(locNo); + } + +} diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java index 4736f0e..c05df4d 100644 --- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java @@ -69,6 +69,11 @@ private StaDescService staDescService; @Autowired private CommonService commonService; + @Autowired + private NodeService nodeService; + @Autowired + private ManLocDetlService manLocDetlService; + @Override @Transactional @@ -183,6 +188,39 @@ } @Override + public void onSale(CombParam param) { + // 鑾峰彇搴撲綅鍙� + String locno = param.getLocno(); + Node node = nodeService.selectByUuid(locno); + if (Cools.isEmpty(node)) { + throw new CoolException(param.getLocno() + ":搴撲綅涓嶅瓨鍦�"); + } + + // 鑾峰彇鍟嗗搧鍒楄〃 + for(CombParam.CombMat combMat : param.getCombMats()){ + Mat mat = matService.selectByMatnr(combMat.getMatnr()); + if (Cools.isEmpty(mat)){ + throw new CoolException(combMat.getMatnr() + ":鍟嗗搧妗f涓嶅瓨鍦紒"); + } + if (Cools.isEmpty(combMat.getAnfme()) || combMat.getAnfme()==0){ + throw new CoolException(combMat.getMatnr() + ":鍟嗗搧鏁伴噺鏈夎锛�"); + } + if (Cools.isEmpty(combMat.getBatch())){ + throw new CoolException(combMat.getMatnr() + ":鍟嗗搧鎵瑰彿鏈夎锛�"); + } + ManLocDetl manLocDetl = new ManLocDetl(); + manLocDetl.setLocNo(locno); + manLocDetl.setNodeId(node.getId()); + manLocDetl.setMatnr(combMat.getMatnr()); + manLocDetl.setBatch(combMat.getBatch()); + manLocDetl.setAnfme(combMat.getAnfme()); + if (!manLocDetlService.insert(manLocDetl)) { + throw new CoolException("鍟嗗搧涓婃灦澶辫触锛�"); + } + } + } + + @Override @Transactional public void adjust(MobileAdjustParam param, Long userId) { BasDevp basDevp = basDevpService.selectById(param.getStaNo()); diff --git a/src/main/java/com/zy/asrs/service/impl/NodeServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/NodeServiceImpl.java new file mode 100644 index 0000000..7bda2b3 --- /dev/null +++ b/src/main/java/com/zy/asrs/service/impl/NodeServiceImpl.java @@ -0,0 +1,55 @@ +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 com.zy.asrs.entity.Node; +import com.zy.asrs.mapper.NodeMapper; +import com.zy.asrs.service.NodeService; +import org.springframework.stereotype.Service; + +import java.util.Date; + +@Service("nodeService") +public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements NodeService { + @Override + public Node getTop() { + Node top = this.selectOne(new EntityWrapper<Node>().eq("type", 0).eq("level", 0)); + if (top == null) { + top = new Node(); + top.setName("鍏ㄩ儴"); + top.setUuid("鍏ㄩ儴"); + top.setType(0); + top.setLevel(0); + top.setSort(0); + top.setStatus(1); + top.setCreateTime(new Date()); + top.setUpdateTime(new Date()); + Integer insert = this.baseMapper.insert(top); + if (insert == 0) { + throw new CoolException("鏈嶅姟鍣ㄥ紓甯�"); + } + } + return top; + } + + @Override + public Node selectByUuid(String uuid) { + return selectOne(new EntityWrapper<Node>().eq("uuid", uuid)); + } + + @Override + public Node selectByUuid(String uuid, Long hostId) { + return this.baseMapper.selectByUuid(uuid, hostId); + } + + @Override + public Node selectByUuid(String uuid, Long hostId, Integer type) { + return selectOne(new EntityWrapper<Node>().eq("host_id", hostId).eq("uuid", uuid).eq("type", type)); + } + + @Override + public Node selectByUuid(String uuid, Long hostId, Integer type, Long parentId) { + return selectOne(new EntityWrapper<Node>().eq("host_id", hostId).eq("uuid", uuid).eq("type", type).eq("parent_id", parentId)); + } +} diff --git a/src/main/java/com/zy/common/entity/NodeExcel.java b/src/main/java/com/zy/common/entity/NodeExcel.java new file mode 100644 index 0000000..8547df8 --- /dev/null +++ b/src/main/java/com/zy/common/entity/NodeExcel.java @@ -0,0 +1,18 @@ +package com.zy.common.entity; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +@Data +@ExcelIgnoreUnannotated +public class NodeExcel { + @ExcelProperty(index = 0, value = "浠撳簱") + private String warehouse; + + @ExcelProperty(index = 1, value = "搴撳尯") + private String area; + + @ExcelProperty(index = 2, value = "璐т綅") + private String allo; +} diff --git a/src/main/java/com/zy/common/entity/NodeExcelListener.java b/src/main/java/com/zy/common/entity/NodeExcelListener.java new file mode 100644 index 0000000..7cd45bf --- /dev/null +++ b/src/main/java/com/zy/common/entity/NodeExcelListener.java @@ -0,0 +1,146 @@ +package com.zy.common.entity; + +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.Node; +import com.zy.asrs.mapper.NodeMapper; +import com.zy.asrs.service.NodeService; +import com.zy.common.utils.NodeUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +public class NodeExcelListener extends AnalysisEventListener<NodeExcel> { + private int total = 0; + private Long userId; + private Long hostId; + + public NodeExcelListener() { + } + + public NodeExcelListener(Long userId, Long hostId) { + this.userId = userId; + this.hostId = hostId; + } + + /** + * 姣忛殧5鏉″瓨鍌ㄦ暟鎹簱锛屽疄闄呬娇鐢ㄤ腑鍙互3000鏉★紝鐒跺悗娓呯悊list 锛屾柟渚垮唴瀛樺洖鏀� + */ + private static final int BATCH_COUNT = 50; + + private final List<NodeExcel> list = new ArrayList<>(); + + /** + * 杩欓噷浼氫竴琛岃鐨勮繑鍥炲ご + */ + @Override + public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { + } + + /** + * 杩欎釜姣忎竴鏉℃暟鎹В鏋愰兘浼氭潵璋冪敤 + */ + @Override + public void invoke(NodeExcel excel, AnalysisContext ctx) { + NodeService nodeService = SpringUtils.getBean(NodeService.class); + NodeMapper nodeMapper = SpringUtils.getBean(NodeMapper.class); + Date now = new Date(); + Node top = nodeService.getTop(); + // 浠撳簱 + if (!Cools.isEmpty(excel.getWarehouse())) { + Node wareHouse = nodeService.selectByUuid(excel.getWarehouse(), hostId, 1, top.getId()); + if (wareHouse == null) { + wareHouse = new Node(); + wareHouse.setHostId(this.hostId); + wareHouse.setUuid(excel.getWarehouse()); + wareHouse.setName(excel.getWarehouse()); + wareHouse.setType(1); + wareHouse.setParentId(top.getId()); + wareHouse.setParentName(top.getName()); + wareHouse.setLevel(top.getLevel() + 1); + NodeUtils nodeUtils = new NodeUtils(); + nodeUtils.executePath(wareHouse); + wareHouse.setPath(nodeUtils.path.toString()); + wareHouse.setNamePath(nodeUtils.pathName.toString()); + wareHouse.setStatus(1); + wareHouse.setCreateTime(now); + wareHouse.setUpdateTime(now); + if (nodeMapper.insert(wareHouse) == 0) { + throw new CoolException("淇濆瓨浠撳簱鏁版嵁澶辫触"); + } + total ++; + } + + // 搴撳尯 + if (!Cools.isEmpty(excel.getArea())) { + Node area = nodeService.selectByUuid(excel.getArea(), hostId, 2, wareHouse.getId()); + if (area == null) { + area = new Node(); + area.setHostId(this.hostId); + area.setUuid(excel.getArea()); + area.setName(excel.getArea()); + area.setType(2); + area.setParentId(wareHouse.getId()); + area.setParentName(wareHouse.getName()); + area.setLevel(wareHouse.getLevel() + 1); + NodeUtils nodeUtils = new NodeUtils(); + nodeUtils.executePath(area); + area.setPath(nodeUtils.path.toString()); + area.setNamePath(nodeUtils.pathName.toString()); + area.setStatus(1); + area.setCreateTime(now); + area.setUpdateTime(now); + if (nodeMapper.insert(area) == 0) { + throw new CoolException("淇濆瓨搴撳尯鏁版嵁澶辫触"); + } + total ++; + } + + // 璐т綅 + if (!Cools.isEmpty(excel.getAllo())) { + Node allo = nodeService.selectByUuid(excel.getAllo(), hostId, 3); + if (allo == null) { + allo = new Node(); + allo.setHostId(this.hostId); + allo.setUuid(excel.getAllo()); + allo.setName(excel.getAllo()); + allo.setType(3); + allo.setParentId(area.getId()); + allo.setParentName(area.getName()); + allo.setLevel(area.getLevel() + 1); + NodeUtils nodeUtils = new NodeUtils(); + nodeUtils.executePath(allo); + allo.setPath(nodeUtils.path.toString()); + allo.setNamePath(nodeUtils.pathName.toString()); + allo.setStatus(1); + allo.setCreateTime(now); + allo.setUpdateTime(now); + if (nodeMapper.insert(allo) == 0) { + throw new CoolException("淇濆瓨璐т綅鏁版嵁澶辫触"); + } + total ++; + } + } + + } + } + } + + /** + * 鎵�鏈夋暟鎹В鏋愬畬鎴愪簡璋冪敤 + * 閫傚悎浜嬪姟 + */ + @Override + public void doAfterAllAnalysed(AnalysisContext ctx) { + //log.info("鏂板{}鏉$墿鏂欎俊鎭紒", total); + } + + public int getTotal() { + return total; + } +} diff --git a/src/main/java/com/zy/common/utils/NodeUtils.java b/src/main/java/com/zy/common/utils/NodeUtils.java index 1703cdb..7d8a4ae 100644 --- a/src/main/java/com/zy/common/utils/NodeUtils.java +++ b/src/main/java/com/zy/common/utils/NodeUtils.java @@ -1,8 +1,20 @@ package com.zy.common.utils; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.core.common.SpringUtils; +import com.zy.asrs.entity.Node; import com.zy.asrs.entity.Tag; +import com.zy.asrs.service.NodeService; import com.zy.asrs.service.TagService; +import com.zy.common.entity.NodeExcel; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.List; /** * Created by vincent on 2021/1/19 @@ -12,6 +24,21 @@ public StringBuilder path = new StringBuilder(); public StringBuilder pathName = new StringBuilder(); + + public void executePath(Node node) { + NodeService bean = SpringUtils.getBean(NodeService.class); + Node parent = bean.selectById(node.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(Tag tag) { TagService bean = SpringUtils.getBean(TagService.class); @@ -42,5 +69,22 @@ } } } + /*************************************** 鏁版嵁鐩稿叧 ***********************************************/ + + /** + * excel瀵煎叆妯℃澘涓嬭浇 + */ + @RequestMapping(value = "/node/excel/import/mould") + public void nodeExcelImportMould(HttpServletResponse response) throws IOException { + List<NodeExcel> 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(), NodeExcel.class) + .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) + .sheet("sheet1") + .doWrite(excels); + } } diff --git a/src/main/java/com/zy/common/utils/TreeUtils.java b/src/main/java/com/zy/common/utils/TreeUtils.java index 271ee28..e18416c 100644 --- a/src/main/java/com/zy/common/utils/TreeUtils.java +++ b/src/main/java/com/zy/common/utils/TreeUtils.java @@ -1,7 +1,10 @@ package com.zy.common.utils; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.zy.asrs.entity.Node; import com.zy.asrs.entity.Tag; +import com.zy.asrs.service.NodeService; import com.zy.asrs.service.TagService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; @@ -18,6 +21,8 @@ @Autowired private TagService tagService; + @Autowired + private NodeService nodeService; /******************************** 褰掔被鏍� *********************************/ @@ -85,5 +90,53 @@ } } } + /******************************** 鑺傜偣鏍� *********************************/ + + /** + * 鑾峰彇鏍戝浘鏁版嵁缁撴瀯 + */ + @Cacheable(cacheNames="nodeTree",key="#id") + public ArrayList<Map> getNodeTree(String id, Long hostId){ + ArrayList<Map> result = new ArrayList<>(); + Node node = nodeService.selectById(id); + // 涓昏妭鐐� + Map<String, Object> map = new HashMap<>(); + map.put("title", node.getName()); + map.put("id", node.getId()); + map.put("spread", true); + List<Map> childrens = new ArrayList<>(); + map.put("children", childrens); + dealNode(node, childrens, hostId); + result.add(map); + // 寮�濮嬪鐞嗗瓧鑺傜偣 +// deal(tag, childrens); + return result; + } + + /** + * 閫掑綊鑾峰彇瀛愯妭鐐规暟鎹� + */ + public void dealNode(Node parent, List<Map> list, Long hostId) { + Wrapper<Node> wrapper = new EntityWrapper<Node>() + .eq("parent_id", parent.getId()) + .eq("status", "1"); + if (hostId != null) { + wrapper.eq("host_id", hostId); + } + List<Node> nodes = nodeService.selectList(wrapper); + for (Node node : nodes) { + Map<String, Object> map = new HashMap<>(); + map.put("title", node.getName()); + map.put("id", node.getId()); + map.put("spread", true); + List<Map> childrens = new ArrayList<>(); + map.put("children", childrens); + dealNode(node, childrens, hostId); + list.add(map); + } + } + + + // ------------------------------------------------------------------------------------------------------- } diff --git a/src/main/java/com/zy/common/web/BaseController.java b/src/main/java/com/zy/common/web/BaseController.java index 60d9fc1..995c3d9 100644 --- a/src/main/java/com/zy/common/web/BaseController.java +++ b/src/main/java/com/zy/common/web/BaseController.java @@ -7,9 +7,13 @@ import com.core.common.Cools; import com.core.controller.AbstractBaseController; import com.core.exception.CoolException; +import com.zy.asrs.entity.Node; import com.zy.asrs.entity.Tag; +import com.zy.asrs.service.NodeService; import com.zy.asrs.service.TagService; import com.zy.system.entity.User; +import com.zy.system.entity.UserLogin; +import com.zy.system.service.UserLoginService; import com.zy.system.service.UserService; import io.swagger.annotations.ApiModelProperty; import org.springframework.beans.factory.annotation.Autowired; @@ -32,6 +36,37 @@ private UserService userService; @Autowired private TagService tagService; + @Autowired + private NodeService nodeService; + @Autowired + private UserLoginService userLoginService; + + protected Node getOriginNode(){ + Node node = nodeService.getTop(); + if (node == null) { + throw new CoolException("搴撳尯鏁版嵁閿欒"); + } + return node; + } + + protected Long getHostId(){ + if (getUserId() == 9527) { + return null; + } + User user = getUser(); + if (user.getRoleId() == 1) { + String hostId = String.valueOf(request.getAttribute("hostId")); + if (Cools.isEmpty(hostId)) { + UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("user_id", user.getId())); + if (userLogin != null) { + return userLogin.getHostId(); + } + } + return Long.parseLong(hostId); + } else { + return user.getHostId(); + } + } protected Long getUserId(){ return Long.parseLong(String.valueOf(request.getAttribute("userId"))); @@ -59,6 +94,13 @@ return tagService.getTop(); } + protected <T> void hostEq(EntityWrapper<T> wrapper){ + Long hostId = getHostId(); + if (hostId != null) { + wrapper.eq("host_id", hostId); + } + } + /** * 鍒嗛〉缁勮 * @param pageNumber diff --git a/src/main/java/com/zy/system/entity/UserLogin.java b/src/main/java/com/zy/system/entity/UserLogin.java index 52d5a5a..9c11c8d 100644 --- a/src/main/java/com/zy/system/entity/UserLogin.java +++ b/src/main/java/com/zy/system/entity/UserLogin.java @@ -7,6 +7,7 @@ import com.zy.system.service.UserService; import com.core.common.Cools; import com.core.common.SpringUtils; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.text.SimpleDateFormat; @@ -23,6 +24,12 @@ @TableId(value = "id", type = IdType.AUTO) private Long id; + /** + * 鎵�灞為」鐩� + */ + @ApiModelProperty(value= "鎵�灞為」鐩�") + @TableField("host_id") + private Long hostId; /** * 鍛樺伐 */ @@ -48,6 +55,13 @@ this.id = id; } + public Long getHostId() { + return hostId; + } + + public void setHostId(Long hostId) { + this.hostId = hostId; + } public Long getUserId() { return userId; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 43082fc..da1af6a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 8081 + port: 8088 servlet: context-path: /@pom.build.finalName@ diff --git a/src/main/resources/mapper/ManLocDetlMapper.xml b/src/main/resources/mapper/ManLocDetlMapper.xml new file mode 100644 index 0000000..f92d616 --- /dev/null +++ b/src/main/resources/mapper/ManLocDetlMapper.xml @@ -0,0 +1,221 @@ +<?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.ManLocDetlMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="BaseResultMap" type="com.zy.asrs.entity.ManLocDetl"> + <result column="host_id" property="hostId" /> + <result column="loc_no" property="locNo" /> + <result column="node_id" property="nodeId" /> + <result column="zpallet" property="zpallet" /> + <result column="anfme" property="anfme" /> + <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" /> + + </resultMap> + + <sql id="locDetlCondition"> + <if test="host_id != null and host_id != ''"> + and mld.host_id = #{host_id} + </if> + <if test="loc_no != null and loc_no != ''"> + and mld.loc_no like concat('%',#{loc_no},'%') + </if> + <if test="matnr != null and matnr != ''"> + and mld.matnr like concat('%',#{matnr},'%') + </if> + <if test="maktx != null and maktx != ''"> + and mld.maktx like concat('%',#{maktx},'%') + </if> + <if test="startTime!=null and endTime!=null"> + and mld.update_time between #{startTime} and #{endTime} + </if> + </sql> + + <select id="listByPage" resultMap="BaseResultMap"> + select * from + ( + SELECT + ROW_NUMBER() over (order by mld.create_time desc) as row, + mld.* + FROM man_loc_detl mld + LEFT JOIN man_node mn ON mld.node_id = mn.id + LEFT JOIN man_mat mm ON mld.matnr = mm.matnr + LEFT JOIN man_tag mt ON mm.tag_id = mt.id + WHERE 1=1 + AND (CHARINDEX(','+#{node_id}+',', ','+mn.path+',') > 0 OR mn.id = #{node_id}) + AND (CHARINDEX(','+#{tag_id}+',', ','+mt.path+',') > 0 OR mt.id = #{tag_id}) + <include refid="locDetlCondition"></include> + ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize}) + </select> + + <select id="listByPageCount" parameterType="java.util.Map" resultType="java.lang.Integer"> + select + count(1) + FROM man_loc_detl mld + LEFT JOIN man_node mn ON mld.node_id = mn.id + LEFT JOIN man_mat mm ON mld.matnr = mm.matnr + LEFT JOIN man_tag mt ON mm.tag_id = mt.id + WHERE 1=1 + AND (CHARINDEX(','+#{node_id}+',', ','+mn.path+',') > 0 OR mn.id = #{node_id}) + AND (CHARINDEX(','+#{tag_id}+',', ','+mt.path+',') > 0 OR mt.id = #{tag_id}) + <include refid="locDetlCondition"></include> + </select> + + <select id="selectByLocNoAndMatnr" resultMap="BaseResultMap"> + select top 1 * + from man_loc_detl + where 1=1 + and anfme > 0 + <if test="nodeId != null and nodeId != ''"> + and node_id = #{nodeId} + </if> + <if test="matnr != null and matnr != ''"> + and matnr = #{matnr} + </if> + order by create_time asc + </select> + + <select id="selectCountByMatnr" resultType="java.lang.Double"> + select sum(anfme) as count from man_loc_detl where 1=1 and matnr = #{matnr} and host_id = #{hostId} + </select> + + <update id="reduceStock"> + update man_loc_detl + set anfme = anfme - #{anfme} + , update_time = getdate() + where 1=1 + and node_id = #{nodeId} + and matnr = #{matnr} + </update> + + <update id="incrementStock"> + update man_loc_detl + set anfme = anfme + #{anfme} + , update_time = getdate() + where 1=1 + and node_id = #{nodeId} + and matnr = #{matnr} + </update> + + <update id="removeStock"> + delete from man_loc_detl + where 1=1 + and node_id = #{nodeId} + and matnr = #{matnr} + </update> + + <select id="selectByPrior" resultMap="BaseResultMap"> + select + mld.* + from man_loc_detl mld + left join man_prior mp on mld.node_id = mp.node_id and mld.matnr = mp.matnr + where 1=1 + <if test="hostId != null and hostId != ''"> + and mld.host_id = #{hostId} + </if> + <if test="nodeId != null and nodeId != ''"> + and mld.node_id = #{nodeId} + </if> + <if test="matnr != null and matnr != ''"> + and mld.matnr = #{matnr} + </if> + and mld.anfme > 0 + and mp.status = 1 + order by mp.prio desc, mld.create_time asc + </select> + + <select id="getLocDetlStatis" resultMap="BaseResultMap"> + select + ROW_NUMBER() over (order by sum(a.anfme) desc) as row + , a.matnr + , sum(a.anfme) as anfme + from man_loc_detl a + where 1=1 + group by a.matnr + </select> + + <select id="selectByNodeUuid" resultMap="BaseResultMap"> + select * from man_loc_detl mld left join man_node mn on mld.node_id = mn.id + where 1=1 + and mn.uuid = #{uuid} + and mld.hostId = #{hostId} + and mld.status = 1 + order by mld.create_time + </select> + + <select id="getStockStatis" resultMap="BaseResultMap"> + select * from + ( + select + ROW_NUMBER() over (order by a.matnr, sum(a.anfme) desc) as row + , a.matnr + , sum(a.anfme) as anfme + from man_loc_detl a + where 1=1 + <include refid="stockOutCondition"></include> + group by a.matnr + ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize}) + </select> + + <select id="getStockStatisCount" parameterType="java.util.Map" resultType="java.lang.Integer"> + select count(1) as count from + ( + select + a.matnr + from man_loc_detl a + where 1=1 + <include refid="stockOutCondition"></include> + group by a.matnr + ) b + </select> + + <sql id="stockOutCondition"> + <if test="host_id!=null and host_id!='' "> + and a.host_id = #{host_id} + </if> + <if test="node_id!=null and node_id!='' "> + and a.node_id like '%' + #{node_id} + '%' + </if> + <if test="loc_no!=null and loc_no!='' "> + and a.loc_no like '%' + #{loc_no} + '%' + </if> + <if test="matnr!=null and matnr!='' "> + and a.matnr like '%' + #{matnr} + '%' + </if> + <if test="maktx!=null and maktx!='' "> + and a.maktx like '%' + #{maktx} + '%' + </if> + </sql> + + <select id="getStockStatisExcel" resultMap="BaseResultMap"> + select + ROW_NUMBER() over (order by a.matnr, sum(a.anfme) desc) as row + , a.matnr + , sum(a.anfme) as anfme + from man_loc_detl a + where 1=1 + and a.host_id = #{hostId} + group by a.matnr + </select> + +</mapper> diff --git a/src/main/webapp/static/js/locDetl/locDetl.js b/src/main/webapp/static/js/locDetl/locDetl.js index 211c380..c1f1c61 100644 --- a/src/main/webapp/static/js/locDetl/locDetl.js +++ b/src/main/webapp/static/js/locDetl/locDetl.js @@ -55,7 +55,7 @@ tableIns = table.render({ elem: '#locDetl', headers: {token: localStorage.getItem('token')}, - url: baseUrl+'/locDetl/list/auth', + url: baseUrl+'/manLocDetl/list/auth', page: true, limit: 16, limits: [16, 30, 50, 100, 200, 500], @@ -68,6 +68,7 @@ pageSize: 'limit' }, parseData: function (res) { + console.log(res) return { 'code': res.code, 'msg': res.msg, @@ -132,7 +133,7 @@ content: 'locDetl_detail.html', success: function(layero, index){ layer.getChildFrame('#data-detail-submit-edit', index).hide(); - clearFormVal(layer.getChildFrame('#detail', index)); + clearFormVal(layer.getChildFrame('#detail', index)); layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); } }); @@ -262,35 +263,35 @@ if (param === undefined) { layer.msg("鏃犳暟鎹�"); } else { - layer.open({ - type: 2, - title: '搴撲綅鍙疯鎯�', - maxmin: true, - area: [top.detailWidth, top.detailHeight], - shadeClose: false, - content: '../locMast/locMast_detail.html', - success: function(layero, index){ - $.ajax({ - url: baseUrl+"/locMast/"+ param +"/auth", - headers: {'token': localStorage.getItem('token')}, - method: 'GET', - success: function (res) { - if (res.code === 200){ - setFormVal(layer.getChildFrame('#detail', index), res.data, true); - top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); - layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide(); - layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); - layero.find('iframe')[0].contentWindow.layui.form.render('select'); - layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); - } else if (res.code === 403){ - parent.location.href = "/"; - }else { - layer.msg(res.msg) - } - } - }) - } - }); + layer.open({ + type: 2, + title: '搴撲綅鍙疯鎯�', + maxmin: true, + area: [top.detailWidth, top.detailHeight], + shadeClose: false, + content: '../locMast/locMast_detail.html', + success: function(layero, index){ + $.ajax({ + url: baseUrl+"/locMast/"+ param +"/auth", + headers: {'token': localStorage.getItem('token')}, + method: 'GET', + success: function (res) { + if (res.code === 200){ + setFormVal(layer.getChildFrame('#detail', index), res.data, true); + top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); + layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide(); + layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); + layero.find('iframe')[0].contentWindow.layui.form.render('select'); + layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); + } else if (res.code === 403){ + parent.location.href = "/"; + }else { + layer.msg(res.msg) + } + } + }) + } + }); } break; case 'modiUser': @@ -298,35 +299,35 @@ if (param === undefined) { layer.msg("鏃犳暟鎹�"); } else { - layer.open({ - type: 2, - title: '淇敼浜哄憳璇︽儏', - maxmin: true, - area: [top.detailWidth, top.detailHeight], - shadeClose: false, - content: '../user/user_detail.html', - success: function(layero, index){ - $.ajax({ - url: baseUrl+"/user/"+ param +"/auth", - headers: {'token': localStorage.getItem('token')}, - method: 'GET', - success: function (res) { - if (res.code === 200){ - setFormVal(layer.getChildFrame('#detail', index), res.data, true); - top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); - layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide(); - layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); - layero.find('iframe')[0].contentWindow.layui.form.render('select'); - layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); - } else if (res.code === 403){ - parent.location.href = "/"; - }else { - layer.msg(res.msg) - } - } - }) - } - }); + layer.open({ + type: 2, + title: '淇敼浜哄憳璇︽儏', + maxmin: true, + area: [top.detailWidth, top.detailHeight], + shadeClose: false, + content: '../user/user_detail.html', + success: function(layero, index){ + $.ajax({ + url: baseUrl+"/user/"+ param +"/auth", + headers: {'token': localStorage.getItem('token')}, + method: 'GET', + success: function (res) { + if (res.code === 200){ + setFormVal(layer.getChildFrame('#detail', index), res.data, true); + top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); + layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide(); + layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); + layero.find('iframe')[0].contentWindow.layui.form.render('select'); + layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); + } else if (res.code === 403){ + parent.location.href = "/"; + }else { + layer.msg(res.msg) + } + } + }) + } + }); } break; case 'appeUser': @@ -334,35 +335,35 @@ if (param === undefined) { layer.msg("鏃犳暟鎹�"); } else { - layer.open({ - type: 2, - title: '鍒涘缓鑰呰鎯�', - maxmin: true, - area: [top.detailWidth, top.detailHeight], - shadeClose: false, - content: '../user/user_detail.html', - success: function(layero, index){ - $.ajax({ - url: baseUrl+"/user/"+ param +"/auth", - headers: {'token': localStorage.getItem('token')}, - method: 'GET', - success: function (res) { - if (res.code === 200){ - setFormVal(layer.getChildFrame('#detail', index), res.data, true); - top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); - layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide(); - layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); - layero.find('iframe')[0].contentWindow.layui.form.render('select'); - layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); - } else if (res.code === 403){ - parent.location.href = "/"; - }else { - layer.msg(res.msg) - } - } - }) - } - }); + layer.open({ + type: 2, + title: '鍒涘缓鑰呰鎯�', + maxmin: true, + area: [top.detailWidth, top.detailHeight], + shadeClose: false, + content: '../user/user_detail.html', + success: function(layero, index){ + $.ajax({ + url: baseUrl+"/user/"+ param +"/auth", + headers: {'token': localStorage.getItem('token')}, + method: 'GET', + success: function (res) { + if (res.code === 200){ + setFormVal(layer.getChildFrame('#detail', index), res.data, true); + top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); + layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide(); + layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); + layero.find('iframe')[0].contentWindow.layui.form.render('select'); + layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); + } else if (res.code === 403){ + parent.location.href = "/"; + }else { + layer.msg(res.msg) + } + } + }) + } + }); } break; @@ -384,6 +385,7 @@ }); function method(name){ + var index = layer.load(1, { shade: [0.5,'#000'] //0.1閫忔槑搴︾殑鑳屾櫙 }); diff --git a/src/main/webapp/static/js/nodeTree.js b/src/main/webapp/static/js/nodeTree.js new file mode 100644 index 0000000..ee9c67f --- /dev/null +++ b/src/main/webapp/static/js/nodeTree.js @@ -0,0 +1,87 @@ +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+"/node/tree/auth", + headers: {'token': localStorage.getItem('token')}, + data: { + 'condition': condition + }, + method: 'POST', + success: function (res) { + console.log(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: {node_id: obj.data.id}, + page: {curr: 1} + }); + } + }); + treeData = res.data; + if (isEmpty(condition) && init) { + tableIns.reload({ + where: {node_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/locDetl/locDetl.html b/src/main/webapp/views/locDetl/locDetl.html index 6248d71..eb21eaa 100644 --- a/src/main/webapp/views/locDetl/locDetl.html +++ b/src/main/webapp/views/locDetl/locDetl.html @@ -7,61 +7,114 @@ <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/common.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%; + } + </style> </head> <body> -<!-- 鎼滅储鏍� --> -<div id="search-box" class="layui-form layui-card-header"> - <div class="layui-inline"> - <div class="layui-input-inline"> - <input class="layui-input" type="text" name="loc_no" placeholder="搴撲綅鍙�" autocomplete="off"> +<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="loc_no" 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="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="locDetl" lay-filter="locDetl"></table> + </div> + </div> </div> </div> - <div class="layui-inline"> - <div class="layui-input-inline"> - <input class="layui-input" type="text" name="zpallet" placeholder="鎵樼洏鐮�" autocomplete="off"> - </div> - </div> - <div class="layui-inline"> - <div class="layui-input-inline"> - <input class="layui-input" type="text" name="matnr" placeholder="鍟嗗搧缂栧彿" autocomplete="off"> - </div> - </div> -<!-- <div class="layui-inline">--> -<!-- <div class="layui-input-inline">--> -<!-- <input class="layui-input" type="text" name="row" placeholder="鎺掓暟" autocomplete="off">--> -<!-- </div>--> -<!-- </div>--> - <div class="layui-inline"> - <div class="layui-input-inline"> - <input class="layui-input" type="text" name="condition" placeholder="璇疯緭鍏�" autocomplete="off"> - </div> - - </div> - - <!-- 寰呮坊鍔� --> - <div id="data-search-btn" class="layui-btn-container layui-form-item" style="display: inline-block"> - <button id="search" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="search">鎼滅储</button> - <button id="reset" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="reset">閲嶇疆</button> -<!-- <button id="unreason" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="unreason">鏌ョ湅寮傚父鏁版嵁</button>--> - </div> - </div> -<!-- 琛ㄦ牸 --> -<div class="layui-form"> - <table class="layui-hide" id="locDetl" lay-filter="locDetl"></table> -</div> <script type="text/html" id="toolbar"> <div class="layui-btn-container"> - <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData" style="margin-top: 10px">瀵煎嚭</button> + <!-- <button class="layui-btn layui-btn-sm" id="btn-add" lay-event="addData">鏂板</button>--> + <button class="layui-btn layui-btn-sm layui-btn-danger" id="btn-delete" lay-event="deleteData">鍒犻櫎</button> + <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="locNoTpl"> + <span name="locNo" class="layui-badge layui-badge-gray">{{d.locNo}}</span> +</script> <script type="text/html" id="operate"> <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">璇︽儏</a> + <!-- <a class="layui-btn layui-btn-xs btn-edit" lay-event="edit">缂栬緫</a>--> </script> <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> @@ -69,8 +122,8 @@ <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/locDetl/locDetl.js" charset="utf-8"></script> - -<iframe id="detail-iframe" scrolling="auto" style="display:none;"></iframe> +<!--<script type="text/javascript" src="../../static/js/tagTree.js" charset="utf-8"></script>--> +<script type="text/javascript" src="../../static/js/nodeTree.js" charset="utf-8"></script> </body> </html> diff --git a/src/main/webapp/views/node/node.html b/src/main/webapp/views/node/node.html new file mode 100644 index 0000000..bc3b016 --- /dev/null +++ b/src/main/webapp/views/node/node.html @@ -0,0 +1,431 @@ +<!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="node"></table> + </div> + </div> +</div> + +<script type="text/html" id="toolbar"> + <div class="layui-btn-container" style="width: 100%"> + <button lay-event="add" class="layui-btn layui-btn-sm layui-btn-normal 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> + <button class="layui-btn layui-btn-sm" id="btn-print-batch" lay-event="printBatch">鎵归噺鎵撳嵃</button> + <!-- 鍟嗗搧/鐗╂枡 鏁版嵁涓績 --> + <div class="dropdown-menu" style="margin-left: 0"> + <button class="layui-btn layui-btn-sm icon-btn layui-btn-primary" style="margin-top: 2px"> 鏁版嵁鍚屾 <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> + </div> +</script> + +<script type="text/html" id="typeTpl"> + {{# if( d.type === 1){ }} + <span name="type" class="layui-badge layui-badge-red" ><span style="display: none">{{d.number}}</span>浠撳簱</span> + {{# } else if(d.type === 2){ }} + <span name="type" class="layui-badge layui-badge-blue" ><span style="display: none">{{d.number}}</span>搴撳尯</span> + {{# } else if(d.type === 3){ }} + <span name="type" class="layui-badge layui-badge-green" ><span style="display: none">{{d.number}}</span>璐т綅</span> + {{# } else { }} + <span name="type" class="layui-badge layui-badge-gray" ><span style="display: none">{{d.number}}</span>鍏朵粬</span> + {{# } }} +</script> + +<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="level" type="hidden"> + <input name="sort" type="hidden"> + <input name="leading" type="hidden"> + <input name="barcode" type="hidden"> + <input name="major" 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="nodeParentSel" 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"> + <select name="type" lay-vertype="tips" lay-verify="required" required=""> + <option value="">璇烽�夋嫨绫诲瀷</option> + <option value="1">浠撳簱</option> + <option value="2">搴撳尯</option> + <option value="3">璐т綅</option> + </select> + </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="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/template" id="locPrintTpl"> + {{#each data}} + <img class="template-code" src="{{this.barcodeUrl}}" width="100%"> + <div style="letter-spacing: 2px;margin-top: 1px; text-align: center"> + <span>{{this.item}}</span> + </div> + {{/each}} +</script> +<div id="printBox" style="display: none;"></div> +<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></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/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> + var insTb; + var admin; + layui.config({ + base: baseUrl + "/static/layui/lay/modules/" + }).extend({ + dropdown: 'dropdown/dropdown', + }).use(['form','treeTable', 'admin', 'xmSelect', 'dropdown', 'element'], function() { + var $ = layui.jquery; + var layer = layui.layer; + var form = layui.form; + admin = layui.admin; + var treeTable = layui.treeTable; + var xmSelect = layui.xmSelect; + var tbDataList = []; + + insTb = treeTable.render({ + elem: '#node', + url: baseUrl+'/node/list/tree/auth', + headers: {token: localStorage.getItem('token')}, + height: 'full-200', + toolbar: '#toolbar', + 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', left: 'center',title: '缂栧彿/鍚嶇О', minWidth: 150} + ,{field: 'type$', align: 'center',title: '绫诲瀷', templet: '#typeTpl'} + // ,{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: '鐘舵��', hide: true} + ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿'} + ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳'} + ,{field: 'memo', align: 'center',title: '澶囨敞', hide: true} + + ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:150} + ]], + done: function (data) { + console.log(data) + $('.ew-tree-table-box').css('height', '100%'); + insTb.expandAll(); + tbDataList = data; + } + }); + + /* 琛ㄦ牸澶村伐鍏锋爮鐐瑰嚮浜嬩欢 */ + treeTable.on('toolbar(node)', function (obj) { + var checkRows = insTb.checkStatus(); + if (obj.event === 'add') { // 娣诲姞 + showEditModel(); + } else if (obj.event === 'del') { // 鍒犻櫎 + 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}); + } else if (obj.event === 'printBatch') { + if (checkRows.length === 0) { + layer.msg('璇烽�夋嫨瑕佹墦鍗扮殑鏁版嵁', {icon: 2}); + return; + } + var printContent = checkRows.map(function (d) { + if (!d.LAY_INDETERMINATE && d.type === 3) { + return d.name; + } else { + return null; + } + }); + printBatch(printContent, 1); + } + }); + + /* 琛ㄦ牸鎿嶄綔鍒楃偣鍑讳簨浠� */ + treeTable.on('tool(node)', 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+"/node/"+(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: '#nodeParentSel', + 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: true + } + }); + // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯 + $(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+"/node/delete0/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}); + } + } + }) + }); + } + + // 鎵归噺鎵撳嵃 + function printBatch(printMsgList, type) { + var data = []; + for (var i = 0; i<printMsgList.length; i ++) { + if (printMsgList[i] != null && printMsgList[i] !== '') { + var barcodeUrl; + if (type === 1) { + barcodeUrl = baseUrl+"/barcode/qrcode/auth?type="+type+"¶m="+printMsgList[i]+"&width="+200+"&height="+70; + } else { + barcodeUrl = baseUrl+"/barcode/qrcode/auth?type="+type+"¶m="+printMsgList[i]+"&width="+400+"&height="+180; + } + data.push({ + item: printMsgList[i], + barcodeUrl: barcodeUrl + }) + } + } + var tpl = $('#locPrintTpl').html(); + var template = Handlebars.compile(tpl); + var html = template({data: data}); + var box = $("#printBox"); + box.html(html); + box.show(); + box.print({mediaPrint:true}); + box.hide(); + } + + }); + + // excel瀵煎叆妯℃澘涓嬭浇 + function excelMouldDownload(){ + layer.load(1, {shade: [0.1,'#fff']}); + location.href = baseUrl + "/node/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 + "/node/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}); + insTb.refresh(); + } 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() { + + } + +</script> +</body> +</html> + -- Gitblit v1.9.1