diff --git a/pom.xml b/pom.xml
index 67947811d63ab3373a9ab1dd3a37411ed6a9c5f8..0e954ca6f08c86e8f3af47561372d748387e4f82 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,7 @@
8
8
1.0.0-SNAPSHOT
- 4.0.5
+ 4.0.6
diff --git a/xingyun-api/src/main/resources/db/all/tenant.sql b/xingyun-api/src/main/resources/db/all/tenant.sql
index 97160921a3f42013eb895fcf2869e9be7c96bd82..882821f0b24f8617028610128c687a65af4151a1 100644
--- a/xingyun-api/src/main/resources/db/all/tenant.sql
+++ b/xingyun-api/src/main/resources/db/all/tenant.sql
@@ -4166,7 +4166,7 @@ CREATE TABLE `flow_cu_approve_his` (
INDEX `instance_id`(`instance_id`) USING BTREE,
INDEX `task_id`(`task_id`) USING BTREE,
INDEX `node_code`(`node_code`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程审核历史' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程审核历史' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of flow_cu_approve_his
@@ -4200,7 +4200,7 @@ CREATE TABLE `flow_cu_instance` (
`start_time` datetime NOT NULL COMMENT '发起时间',
`end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程实例扩展表' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程实例扩展表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of flow_cu_instance
@@ -4228,7 +4228,7 @@ CREATE TABLE `flow_definition` (
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志',
`tenant_id` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程定义表' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程定义表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of flow_definition
@@ -4263,7 +4263,7 @@ CREATE TABLE `flow_his_task` (
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志',
`tenant_id` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '历史任务记录表' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '历史任务记录表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of flow_his_task
@@ -4291,7 +4291,7 @@ CREATE TABLE `flow_instance` (
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志',
`tenant_id` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程实例表' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程实例表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of flow_instance
@@ -4324,7 +4324,7 @@ CREATE TABLE `flow_node` (
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志',
`tenant_id` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程节点表' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程节点表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of flow_node
@@ -4350,7 +4350,7 @@ CREATE TABLE `flow_skip` (
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志',
`tenant_id` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '节点跳转关联表' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '节点跳转关联表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of flow_skip
@@ -4375,7 +4375,7 @@ CREATE TABLE `flow_task` (
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '删除标志',
`tenant_id` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '待办任务表' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '待办任务表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of flow_task
@@ -4398,7 +4398,7 @@ CREATE TABLE `flow_user` (
PRIMARY KEY (`id`) USING BTREE,
INDEX `user_processed_type`(`processed_by`, `type`) USING BTREE,
INDEX `user_associated`(`associated`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程用户表' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '流程用户表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of flow_user
@@ -5564,7 +5564,7 @@ CREATE TABLE `sys_generate_code` (
`name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称',
`config_str` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置信息(JSONArray)',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '编号规则' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of sys_generate_code
@@ -5885,6 +5885,7 @@ INSERT INTO `sys_menu` VALUES ('3000007001', '3000007001', '', '新增库存预
INSERT INTO `sys_menu` VALUES ('3000007002', '3000007002', '', '修改库存预警', NULL, 0, '', NULL, '3000007', '8', '', 0, 2, 0, 'stock:warning:modify', 1, 1, '', '系统管理员', '1', '2021-05-12 22:50:27', '系统管理员', '1', '2021-07-04 00:34:23');
INSERT INTO `sys_menu` VALUES ('3000007003', '3000007003', '', '删除库存预警', NULL, 0, '', NULL, '3000007', '8', '', 0, 2, 0, 'stock:warning:delete', 1, 1, '', '系统管理员', '1', '2021-05-12 22:50:27', '系统管理员', '1', '2021-07-04 00:34:23');
INSERT INTO `sys_menu` VALUES ('3000007004', '3000007004', '', '设置消息通知组', NULL, 0, '', NULL, '3000007', '8', '', 0, 2, 0, 'stock:warning:notify', 1, 1, '', '系统管理员', '1', '2021-05-12 22:50:27', '系统管理员', '1', '2021-07-04 00:34:23');
+INSERT INTO `sys_menu` VALUES ('3000007005', '3000007005', '', '导入库存预警', NULL, 0, '', NULL, '3000007', '8', '', 0, 2, 0, 'stock:warning:import', 1, 1, '', '系统管理员', '1', '2021-05-12 22:50:27', '系统管理员', '1', '2021-07-04 00:34:23');
INSERT INTO `sys_menu` VALUES ('4000', '4000', 'SettleManage', '结算管理', 'ant-design:credit-card-outlined', NULL, '', NULL, NULL, '11', '/settle', 0, 0, 0, '', 1, 1, '', '系统管理员', '1', '2021-07-05 01:21:35', '系统管理员', '1', '2021-07-05 01:21:39');
INSERT INTO `sys_menu` VALUES ('4000001', '4000001', 'SettleInItem', '收入项目', NULL, 0, '/settle/in-item/index', NULL, '4000', '11', '/in-item', 0, 1, 0, 'settle:in-item:query', 1, 1, '', '系统管理员', '1', '2021-07-05 21:59:35', '系统管理员', '1', '2021-07-05 21:59:36');
INSERT INTO `sys_menu` VALUES ('4000001001', '4000001001', '', '新增收入项目', NULL, 0, '', NULL, '4000001', '11', '', 0, 2, 0, 'settle:in-item:add', 1, 1, '', '系统管理员', '1', '2021-05-12 10:53:45', '系统管理员', '1', '2021-07-04 00:34:23');
@@ -7767,4 +7768,4 @@ CREATE TABLE `tbl_take_stock_sheet_detail` (
-- Records of tbl_take_stock_sheet_detail
-- ----------------------------
-SET FOREIGN_KEY_CHECKS = 1;
+SET FOREIGN_KEY_CHECKS = 1;
\ No newline at end of file
diff --git a/xingyun-api/src/main/resources/db/migration/tenant/V1.18__stock_warning_batch_handle.sql b/xingyun-api/src/main/resources/db/migration/tenant/V1.18__stock_warning_batch_handle.sql
new file mode 100644
index 0000000000000000000000000000000000000000..1ba239afd89b2af7d199d871cc39f71ce0a7a288
--- /dev/null
+++ b/xingyun-api/src/main/resources/db/migration/tenant/V1.18__stock_warning_batch_handle.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `sys_generate_code` COMMENT = '编号规则';
+INSERT INTO `sys_menu` (`id`, `code`, `name`, `title`, `icon`, `component_type`, `component`, `request_param`, `parent_id`, `sys_module_id`, `path`, `no_cache`, `display`, `hidden`, `permission`, `is_special`, `available`, `description`, `create_by`, `create_by_id`, `create_time`, `update_by`, `update_by_id`, `update_time`) VALUES ('3000007005', '3000007005', '', '导入库存预警', NULL, 0, '', NULL, '3000007', '8', '', 0, 2, 0, 'stock:warning:import', 1, 1, '', '系统管理员', '1', '2021-05-12 22:50:27', '系统管理员', '1', '2021-07-04 00:34:23');
diff --git a/xingyun-basedata/src/main/resources/mappers/product/ProductPropertyItemMapper.xml b/xingyun-basedata/src/main/resources/mappers/product/ProductPropertyItemMapper.xml
index 58ff2a31d7417e59c2e81bdcc2b5aaa06b67e487..8e63def761a1a74c8f6d6b02c612d0808f39aa19 100644
--- a/xingyun-basedata/src/main/resources/mappers/product/ProductPropertyItemMapper.xml
+++ b/xingyun-basedata/src/main/resources/mappers/product/ProductPropertyItemMapper.xml
@@ -50,6 +50,7 @@
diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/controller/stock/warning/ProductStockWarningController.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/controller/stock/warning/ProductStockWarningController.java
index b20deed39f4eff3a871b338790c1e8787322e479..54473a03734bbb920cd9336f95fa6aa4c9066702 100644
--- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/controller/stock/warning/ProductStockWarningController.java
+++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/controller/stock/warning/ProductStockWarningController.java
@@ -4,16 +4,19 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.lframework.starter.common.exceptions.impl.DefaultClientException;
import com.lframework.starter.common.utils.CollectionUtil;
import com.lframework.starter.web.core.annotations.security.HasPermission;
-import com.lframework.starter.web.core.controller.DefaultBaseController;
import com.lframework.starter.web.core.components.resp.InvokeResult;
import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
import com.lframework.starter.web.core.components.resp.PageResult;
+import com.lframework.starter.web.core.controller.DefaultBaseController;
+import com.lframework.starter.web.core.utils.ExcelUtil;
import com.lframework.starter.web.core.utils.PageResultUtil;
import com.lframework.xingyun.sc.bo.stock.warning.GetProductStockWarningBo;
import com.lframework.xingyun.sc.bo.stock.warning.GetProductStockWarningNotifyBo;
import com.lframework.xingyun.sc.bo.stock.warning.QueryProductStockWarningBo;
import com.lframework.xingyun.sc.entity.ProductStockWarning;
import com.lframework.xingyun.sc.entity.ProductStockWarningNotify;
+import com.lframework.xingyun.sc.excel.stock.warning.StockWarningImportListener;
+import com.lframework.xingyun.sc.excel.stock.warning.StockWarningImportModel;
import com.lframework.xingyun.sc.service.stock.warning.ProductStockWarningNotifyService;
import com.lframework.xingyun.sc.service.stock.warning.ProductStockWarningService;
import com.lframework.xingyun.sc.vo.stock.warning.CreateProductStockWarningVo;
@@ -28,6 +31,7 @@ import java.util.stream.Collectors;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
@@ -37,6 +41,7 @@ import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
/**
* 库存预警 Controller
@@ -195,4 +200,24 @@ public class ProductStockWarningController extends DefaultBaseController {
return InvokeResultBuilder.success();
}
+
+ @ApiOperation("下载导入模板")
+ @HasPermission({"stock:warning:import"})
+ @GetMapping("/import/template")
+ public void downloadImportTemplate() {
+ ExcelUtil.exportXls("库存预警导入模板", StockWarningImportModel.class);
+ }
+
+ @ApiOperation("导入")
+ @HasPermission({"stock:warning:import"})
+ @PostMapping("/import")
+ public InvokeResult importExcel(@NotBlank(message = "ID不能为空") String id,
+ @NotNull(message = "请上传文件") MultipartFile file) {
+
+ StockWarningImportListener listener = new StockWarningImportListener();
+ listener.setTaskId(id);
+ ExcelUtil.read(file, StockWarningImportModel.class, listener).sheet().doRead();
+
+ return InvokeResultBuilder.success();
+ }
}
diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/warning/StockWarningImportListener.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/warning/StockWarningImportListener.java
new file mode 100644
index 0000000000000000000000000000000000000000..b1f794e42251fb69caa5d3f563d2564ce02de1c9
--- /dev/null
+++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/warning/StockWarningImportListener.java
@@ -0,0 +1,102 @@
+package com.lframework.xingyun.sc.excel.stock.warning;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.lframework.starter.common.exceptions.impl.DefaultClientException;
+import com.lframework.starter.web.core.components.excel.ExcelImportListener;
+import com.lframework.starter.web.core.utils.ApplicationUtil;
+import com.lframework.starter.web.core.utils.IdUtil;
+import com.lframework.xingyun.basedata.entity.Product;
+import com.lframework.xingyun.basedata.entity.StoreCenter;
+import com.lframework.xingyun.basedata.service.product.ProductService;
+import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService;
+import com.lframework.xingyun.sc.entity.ProductStockWarning;
+import com.lframework.xingyun.sc.service.stock.warning.ProductStockWarningService;
+import com.lframework.xingyun.sc.vo.stock.warning.CreateProductStockWarningVo;
+import com.lframework.xingyun.sc.vo.stock.warning.UpdateProductStockWarningVo;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class StockWarningImportListener extends ExcelImportListener {
+
+ @Override
+ protected void doInvoke(StockWarningImportModel data, AnalysisContext context) {
+ StoreCenterService storeCenterService = ApplicationUtil.getBean(StoreCenterService.class);
+ Wrapper queryScWrapper = Wrappers.lambdaQuery(StoreCenter.class)
+ .eq(StoreCenter::getCode, data.getScCode());
+ StoreCenter sc = storeCenterService.getOne(queryScWrapper);
+ if (sc == null) {
+ throw new DefaultClientException(
+ "第" + context.readRowHolder().getRowIndex() + "行“仓库编号”不存在");
+ }
+
+ data.setScId(sc.getId());
+ ProductService productService = ApplicationUtil.getBean(ProductService.class);
+ Wrapper queryProductWrapper = Wrappers.lambdaQuery(Product.class)
+ .eq(Product::getCode, data.getProductCode());
+ Product product = productService.getOne(queryProductWrapper);
+ if (product == null) {
+ throw new DefaultClientException(
+ "第" + context.readRowHolder().getRowIndex() + "行“商品编号”不存在");
+ }
+ data.setProductId(product.getId());
+
+ if (data.getMinLimit() <= 0) {
+ throw new DefaultClientException(
+ "第" + context.readRowHolder().getRowIndex() + "行“预警下限”不能小于0");
+ }
+
+ if (data.getMaxLimit() <= 0) {
+ throw new DefaultClientException(
+ "第" + context.readRowHolder().getRowIndex() + "行“预警上限”不能小于0");
+ }
+
+ if (data.getMaxLimit() < data.getMinLimit()) {
+ throw new DefaultClientException(
+ "第" + context.readRowHolder().getRowIndex() + "行“预警上限”不能小于“预警下限”");
+ }
+ }
+
+ @Override
+ protected void afterAllAnalysed(AnalysisContext context) {
+
+ ProductStockWarningService productStockWarningService = ApplicationUtil.getBean(
+ ProductStockWarningService.class);
+
+ int index = 0;
+ for (StockWarningImportModel data : this.getDatas()) {
+ Wrapper checkWrapper = Wrappers.lambdaQuery(ProductStockWarning.class)
+ .eq(ProductStockWarning::getScId, data.getScId())
+ .eq(ProductStockWarning::getProductId, data.getProductId());
+ ProductStockWarning record = productStockWarningService.getOne(checkWrapper);
+ if (record == null) {
+ CreateProductStockWarningVo vo = new CreateProductStockWarningVo();
+ vo.setScId(data.getScId());
+ vo.setProductId(data.getProductId());
+ vo.setMinLimit(data.getMinLimit());
+ vo.setMaxLimit(data.getMaxLimit());
+
+ productStockWarningService.create(vo);
+ } else {
+ UpdateProductStockWarningVo vo = new UpdateProductStockWarningVo();
+ vo.setId(record.getId());
+ vo.setAvailable(record.getAvailable());
+ vo.setScId(data.getScId());
+ vo.setProductId(data.getProductId());
+ vo.setMinLimit(data.getMinLimit());
+ vo.setMaxLimit(data.getMaxLimit());
+
+ productStockWarningService.update(vo);
+ }
+
+ index++;
+ this.setSuccessProcessByIndex(index);
+ }
+ }
+
+ @Override
+ protected void doComplete() {
+
+ }
+}
diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/warning/StockWarningImportModel.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/warning/StockWarningImportModel.java
new file mode 100644
index 0000000000000000000000000000000000000000..79faec766a9a0948dab9a7e0658897fca751b7dc
--- /dev/null
+++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/warning/StockWarningImportModel.java
@@ -0,0 +1,51 @@
+package com.lframework.xingyun.sc.excel.stock.warning;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.lframework.starter.web.core.annotations.excel.ExcelRequired;
+import com.lframework.starter.web.core.components.excel.ExcelModel;
+import lombok.Data;
+
+@Data
+public class StockWarningImportModel implements ExcelModel {
+
+ /**
+ * 仓库ID
+ */
+ @ExcelIgnore
+ private String scId;
+
+ /**
+ * 仓库编号
+ */
+ @ExcelRequired
+ @ExcelProperty("仓库编号")
+ private String scCode;
+
+ /**
+ * 商品ID
+ */
+ @ExcelIgnore
+ private String productId;
+
+ /**
+ * 商品编号
+ */
+ @ExcelRequired
+ @ExcelProperty("商品编号")
+ private String productCode;
+
+ /**
+ * 预警上限
+ */
+ @ExcelRequired
+ @ExcelProperty("预警上限")
+ private Integer maxLimit;
+
+ /**
+ * 预警下限
+ */
+ @ExcelRequired
+ @ExcelProperty("预警下限")
+ private Integer minLimit;
+}