From ed36af4d4cc5feac72a384d85f9032fc6dc1223a Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: 星期六, 14 九月 2024 17:01:55 +0800
Subject: [PATCH] update
---
hazmat-system/src/main/java/com/gkhy/hazmat/system/mapper/SysCompanyMapper.java | 8
hazmat-system/src/main/resources/mapper/system/HzProductBasicMapper.xml | 3
hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/HazmatKindEnum.java | 54 +++
hazmat-system/src/main/resources/mapper/system/HzHazmatBasicMapper.xml | 3
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzEntryRecordServiceImpl.java | 31 +
hazmat-admin/src/test/java/com/gkhy/hazmat/admin/PasswordTest.java | 26 +
hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/OperateStatusEnum.java | 3
hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/HazmatPackageEnum.java | 55 +++
hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/ProductBasicExcelDataListener.java | 17 +
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductEntryRecordServiceImpl.java | 31 +
pom.xml | 7
hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzProductEntryRecord.java | 6
hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzHazmatController.java | 13
hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/HazmatBasicExcelData.java | 72 ++++
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java | 3
hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzHazmatBasicController.java | 11
hazmat-admin/src/main/resources/db/migration/V20240906001_change_company.sql | 2
hazmat-common/src/main/java/com/gkhy/hazmat/common/domain/TableSupport.java | 6
hazmat-system/src/main/resources/mapper/system/SysDictTypeMapper.xml | 0
hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/SysCompany.java | 6
hazmat-system/src/main/resources/mapper/system/HzEntryRecordMapper.xml | 3
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzHazmatBasicService.java | 8
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzProductBasicService.java | 10
hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/app/AppUserController.java | 2
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatBasicServiceImpl.java | 142 +++++++++
hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/ProductBasicExcelData.java | 61 ++++
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/SysCompanyServiceImpl.java | 19 +
hazmat-admin/src/main/resources/db/migration/V20240914001_change_hazmat_basic.sql | 5
hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzProductBasicController.java | 13
hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzProductBasic.java | 6
hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzHazmatBasic.java | 8
hazmat-system/src/main/resources/mapper/system/SysCompanyMapper.xml | 7
hazmat-framework/src/main/java/com/gkhy/hazmat/framework/interceptor/LogInterceptor.java | 37 ++
hazmat-system/src/main/java/com/gkhy/hazmat/system/mapper/HzHazmatFlowMapper.java | 2
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzHazmatService.java | 6
hazmat-common/pom.xml | 5
hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/HazmatBasicExcelDataListener.java | 17 +
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductBasicServiceImpl.java | 129 ++++++++
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatServiceImpl.java | 37 ++
hazmat-system/src/main/resources/mapper/system/SysDeptMapper.xml | 2
hazmat-system/src/main/resources/mapper/system/HzProductEntryRecordMapper.xml | 3
hazmat-system/src/main/resources/mapper/system/SysUserMapper.xml | 8
42 files changed, 847 insertions(+), 40 deletions(-)
diff --git a/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/app/AppUserController.java b/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/app/AppUserController.java
index 5fcf3d6..dd73e14 100644
--- a/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/app/AppUserController.java
+++ b/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/app/AppUserController.java
@@ -27,7 +27,7 @@
@Autowired
private SysUserService userService;
- @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
+ @PreAuthorize("hasAnyAuthority('hazmat:manage:common')")
@ApiOperation(value = "重置密码")
@PutMapping(value = "/resetPwd")
public CommonResult restPwd(@RequestBody SysUser user){
diff --git a/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzHazmatBasicController.java b/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzHazmatBasicController.java
index 78d98f6..105dd20 100644
--- a/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzHazmatBasicController.java
+++ b/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzHazmatBasicController.java
@@ -13,6 +13,9 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
/**
* <p>
@@ -74,4 +77,12 @@
}
+ @RepeatSubmit
+ @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
+ @ApiOperation(value = "危化品基础数据Excel导入")
+ @PostMapping("/importExcel")
+ public CommonResult importExcel(MultipartFile file) throws IOException {
+ return CommonResult.success(hazmatBasicService.importExcel(file));
+ }
+
}
diff --git a/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzHazmatController.java b/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzHazmatController.java
index 554d645..441cb06 100644
--- a/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzHazmatController.java
+++ b/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzHazmatController.java
@@ -71,13 +71,24 @@
return CommonResult.success();
}
+ @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
+ @RepeatSubmit
+ @ApiOperation(value = "零头修改")
+ @PostMapping(value = { "/changeRemaining" })
+ public CommonResult changeRemaining(@RequestBody HzHazmat hazmat){
+ hazmatService.changeRemaining(hazmat);
+ return CommonResult.success();
+ }
+
@PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
@RepeatSubmit
@ApiOperation(value = "修改状态")
@PostMapping(value = { "/changeState" })
- public CommonResult changeState(HzHazmat hazmat){
+ public CommonResult changeState(@RequestBody HzHazmat hazmat){
hazmatService.changeState(hazmat);
return CommonResult.success();
}
+
+
}
diff --git a/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzProductBasicController.java b/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzProductBasicController.java
index 4e426e2..c016a8c 100644
--- a/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzProductBasicController.java
+++ b/hazmat-admin/src/main/java/com/gkhy/hazmat/admin/controller/web/HzProductBasicController.java
@@ -13,6 +13,9 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
/**
* <p>
@@ -74,4 +77,14 @@
}
+ @RepeatSubmit
+ @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
+ @ApiOperation(value = "危化品基础数据Excel导入")
+ @PostMapping("/importExcel")
+ public CommonResult importExcel( MultipartFile file) throws IOException {
+ return CommonResult.success(productBasicService.importExcel(file));
+ }
+
+
+
}
diff --git a/hazmat-admin/src/main/resources/db/migration/V20240906001_change_company.sql b/hazmat-admin/src/main/resources/db/migration/V20240906001_change_company.sql
new file mode 100644
index 0000000..d7fe8da
--- /dev/null
+++ b/hazmat-admin/src/main/resources/db/migration/V20240906001_change_company.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `hazmat_manage`.`sys_company`
+ADD COLUMN `code` varchar(2) NULL COMMENT '公司唯一编码(2位)' AFTER `version`;
\ No newline at end of file
diff --git a/hazmat-admin/src/main/resources/db/migration/V20240914001_change_hazmat_basic.sql b/hazmat-admin/src/main/resources/db/migration/V20240914001_change_hazmat_basic.sql
new file mode 100644
index 0000000..003d734
--- /dev/null
+++ b/hazmat-admin/src/main/resources/db/migration/V20240914001_change_hazmat_basic.sql
@@ -0,0 +1,5 @@
+ALTER TABLE `hazmat_manage`.`hz_hazmat_basic`
+ADD COLUMN `max_entry` int NOT NULL DEFAULT 150 COMMENT '单次入库最大数量' AFTER `version`;
+
+ALTER TABLE `hazmat_manage`.`hz_product_basic`
+ADD COLUMN `max_entry` int NOT NULL DEFAULT 150 COMMENT '单次入库最大数量' AFTER `version`;
\ No newline at end of file
diff --git a/hazmat-admin/src/test/java/com/gkhy/hazmat/admin/PasswordTest.java b/hazmat-admin/src/test/java/com/gkhy/hazmat/admin/PasswordTest.java
index 7d94f80..12b32a3 100644
--- a/hazmat-admin/src/test/java/com/gkhy/hazmat/admin/PasswordTest.java
+++ b/hazmat-admin/src/test/java/com/gkhy/hazmat/admin/PasswordTest.java
@@ -77,4 +77,30 @@
System.out.println("hhhhhh");
}
}
+
+
+ @Test
+ public void testList(){
+ List<Integer> tmpList=new ArrayList<>();
+ tmpList.add(1);
+ tmpList.add(2);
+ tmpList.add(3);
+ tmpList.add(4);
+ tmpList.add(5);
+ tmpList.add(6);
+ tmpList.add(7);
+ tmpList.add(8);
+ tmpList.add(9);
+ Integer pageSize=3;
+ while(true){
+ List<Integer> subLIst=tmpList.subList(0,tmpList.size()>pageSize?pageSize:tmpList.size());
+ System.out.println("subSize="+subLIst.size());
+ if(subLIst.size()<pageSize){
+ break;
+ }
+ tmpList=tmpList.subList(pageSize,tmpList.size());
+ System.out.println("size="+tmpList.size());
+
+ }
+ }
}
diff --git a/hazmat-common/pom.xml b/hazmat-common/pom.xml
index 09dc694..a87cf24 100644
--- a/hazmat-common/pom.xml
+++ b/hazmat-common/pom.xml
@@ -135,6 +135,11 @@
<artifactId>jaudiotagger</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>easyexcel</artifactId>
+ </dependency>
+
</dependencies>
</project>
\ No newline at end of file
diff --git a/hazmat-common/src/main/java/com/gkhy/hazmat/common/domain/TableSupport.java b/hazmat-common/src/main/java/com/gkhy/hazmat/common/domain/TableSupport.java
index c4980e1..ecc34d6 100644
--- a/hazmat-common/src/main/java/com/gkhy/hazmat/common/domain/TableSupport.java
+++ b/hazmat-common/src/main/java/com/gkhy/hazmat/common/domain/TableSupport.java
@@ -42,7 +42,11 @@
{
PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
- pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10));
+ Integer pageSize=Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
+ if(pageSize>100){
+ pageSize=100;
+ }
+ pageDomain.setPageSize(pageSize);
pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC));
pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE));
diff --git a/hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/HazmatKindEnum.java b/hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/HazmatKindEnum.java
new file mode 100644
index 0000000..74852ac
--- /dev/null
+++ b/hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/HazmatKindEnum.java
@@ -0,0 +1,54 @@
+package com.gkhy.hazmat.common.enums;
+
+import java.util.Objects;
+
+/**
+ * 危化品最小包装
+ *
+ */
+public enum HazmatKindEnum
+{
+ REAGENT(0, "试剂"),
+ STOCK(1, "原料"),
+ SIMIGOOD(2, "半成品"),
+ GOOD(3, "成品"),
+ OTHER(4, "其他");
+
+ private final Integer code;
+ private final String info;
+
+ HazmatKindEnum(Integer code, String info)
+ {
+ this.code = code;
+ this.info = info;
+ }
+
+ public Integer getCode()
+ {
+ return code;
+ }
+
+ public String getInfo()
+ {
+ return info;
+ }
+
+
+ public static String getInfoByCode(Integer code){
+ for(HazmatKindEnum hazmatKindEnum:HazmatKindEnum.values()){
+ if(Objects.equals(hazmatKindEnum.getCode(), code)){
+ return hazmatKindEnum.getInfo();
+ }
+ }
+ return "";
+ }
+
+ public static Integer getCodeByInfo(String info){
+ for(HazmatKindEnum hazmatKindEnum:HazmatKindEnum.values()){
+ if(info.equals(hazmatKindEnum.getInfo())){
+ return hazmatKindEnum.getCode();
+ }
+ }
+ return null;
+ }
+}
diff --git a/hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/HazmatPackageEnum.java b/hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/HazmatPackageEnum.java
new file mode 100644
index 0000000..ee3255c
--- /dev/null
+++ b/hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/HazmatPackageEnum.java
@@ -0,0 +1,55 @@
+package com.gkhy.hazmat.common.enums;
+
+import java.util.Objects;
+
+/**
+ * 危化品最小包装
+ *
+ */
+public enum HazmatPackageEnum
+{
+ PING(0, "瓶"),
+ DAI(1, "袋"),
+ TONG(2, "桶"),
+ HE(3, "盒"),
+ XIANG(4, "箱"),
+ OTHER(5,"其他");
+
+ private final Integer code;
+ private final String info;
+
+ HazmatPackageEnum(Integer code, String info)
+ {
+ this.code = code;
+ this.info = info;
+ }
+
+ public Integer getCode()
+ {
+ return code;
+ }
+
+ public String getInfo()
+ {
+ return info;
+ }
+
+
+ public static String getInfoByCode(Integer code){
+ for(HazmatPackageEnum hazmatPackageEnum: HazmatPackageEnum.values()){
+ if(Objects.equals(hazmatPackageEnum.getCode(), code)){
+ return hazmatPackageEnum.getInfo();
+ }
+ }
+ return "";
+ }
+
+ public static Integer getCodeByInfo(String info){
+ for(HazmatPackageEnum hazmatPackageEnum:HazmatPackageEnum.values()){
+ if(info.equals(hazmatPackageEnum.getInfo())){
+ return hazmatPackageEnum.getCode();
+ }
+ }
+ return null;
+ }
+}
diff --git a/hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/OperateStatusEnum.java b/hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/OperateStatusEnum.java
index 0c3d85e..9bc9f13 100644
--- a/hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/OperateStatusEnum.java
+++ b/hazmat-common/src/main/java/com/gkhy/hazmat/common/enums/OperateStatusEnum.java
@@ -11,7 +11,8 @@
RETURN(2, "归还"),
DISCARD(3, "标签作废"),
USE_UP(4, "用尽登记"),
- SOLD(5,"销售");
+ SOLD(5,"销售"),
+ REMNANT(6,"零头入库");
private final Integer code;
private final String info;
diff --git a/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/HazmatBasicExcelData.java b/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/HazmatBasicExcelData.java
new file mode 100644
index 0000000..558f523
--- /dev/null
+++ b/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/HazmatBasicExcelData.java
@@ -0,0 +1,72 @@
+package com.gkhy.hazmat.common.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+@Getter
+@Setter
+public class HazmatBasicExcelData {
+ @ExcelProperty("序号")
+ private Integer index;
+
+ @ExcelProperty("名称")
+ private String name;
+
+ @ExcelProperty("产品编号")
+ private String productSn;
+
+ @ExcelProperty("种类")
+ private String kind;
+
+ @ExcelProperty("CAS")
+ private String cas;
+
+ @ExcelProperty("试剂类型")
+ private String hazmatType;
+
+ @ExcelProperty("危险性质")
+ private String hazmatCharacter;
+
+ @ExcelProperty("供应商")
+ private String supplier;
+
+ @ExcelProperty("厂家")
+ private String manufacturer;
+
+ @ExcelProperty("规格")
+ private String hazmatFormat;
+
+
+ @ExcelProperty("包装数量")
+ private BigDecimal metering;
+
+ @ExcelProperty("包装单位")
+ private String unit;
+
+ @ExcelProperty("含税价格")
+ private BigDecimal price;
+
+ @ExcelProperty("每箱数量")
+ private Integer perBox;
+
+
+ @ExcelProperty("最小包装类型")
+ private String minPackage;
+
+
+ @ExcelProperty("安全库存")
+ private Integer safeNum;
+
+
+ @ExcelProperty("超期阀值(小时)")
+ private Integer threshold;
+
+
+ @ExcelProperty("单次入库最大数量")
+ private Integer maxEntry;
+
+
+}
diff --git a/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/HazmatBasicExcelDataListener.java b/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/HazmatBasicExcelDataListener.java
new file mode 100644
index 0000000..e8b6fb9
--- /dev/null
+++ b/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/HazmatBasicExcelDataListener.java
@@ -0,0 +1,17 @@
+package com.gkhy.hazmat.common.excel;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+
+public class HazmatBasicExcelDataListener extends AnalysisEventListener<HazmatBasicExcelData> {
+ @Override
+ public void invoke(HazmatBasicExcelData hazmatBasicExcelData, AnalysisContext analysisContext) {
+ System.out.println("invoke");
+ }
+
+ @Override
+ public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+ //所有数据解析完成后的操作
+ System.out.println("doAfterAllAnalysed");
+ }
+}
diff --git a/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/ProductBasicExcelData.java b/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/ProductBasicExcelData.java
new file mode 100644
index 0000000..d15a042
--- /dev/null
+++ b/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/ProductBasicExcelData.java
@@ -0,0 +1,61 @@
+package com.gkhy.hazmat.common.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+@Getter
+@Setter
+public class ProductBasicExcelData {
+ @ExcelProperty("序号")
+ private Integer index;
+
+ @ExcelProperty("名称")
+ private String name;
+
+ @ExcelProperty("产品编号")
+ private String productSn;
+
+ @ExcelProperty("种类")
+ private String kind;
+
+ @ExcelProperty("CAS")
+ private String cas;
+
+ @ExcelProperty("试剂类型")
+ private String productType;
+
+ @ExcelProperty("危险性质")
+ private String productCharacter;
+
+ @ExcelProperty("供应商")
+ private String supplier;
+
+ @ExcelProperty("厂家")
+ private String manufacturer;
+
+ @ExcelProperty("规格")
+ private String productFormat;
+
+
+ @ExcelProperty("包装数量")
+ private BigDecimal metering;
+
+ @ExcelProperty("包装单位")
+ private String unit;
+
+ @ExcelProperty("含税价格")
+ private BigDecimal price;
+
+ @ExcelProperty("每箱数量")
+ private Integer perBox;
+
+
+ @ExcelProperty("最小包装类型")
+ private String minPackage;
+
+ @ExcelProperty("单次入库最大数量")
+ private Integer maxEntry;
+}
diff --git a/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/ProductBasicExcelDataListener.java b/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/ProductBasicExcelDataListener.java
new file mode 100644
index 0000000..eb83eea
--- /dev/null
+++ b/hazmat-common/src/main/java/com/gkhy/hazmat/common/excel/ProductBasicExcelDataListener.java
@@ -0,0 +1,17 @@
+package com.gkhy.hazmat.common.excel;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+
+public class ProductBasicExcelDataListener extends AnalysisEventListener<ProductBasicExcelData> {
+ @Override
+ public void invoke(ProductBasicExcelData productBasicExcelData, AnalysisContext analysisContext) {
+ System.out.println("invoke");
+ }
+
+ @Override
+ public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+ //所有数据解析完成后的操作
+ System.out.println("doAfterAllAnalysed");
+ }
+}
diff --git a/hazmat-framework/src/main/java/com/gkhy/hazmat/framework/interceptor/LogInterceptor.java b/hazmat-framework/src/main/java/com/gkhy/hazmat/framework/interceptor/LogInterceptor.java
new file mode 100644
index 0000000..b66d4e1
--- /dev/null
+++ b/hazmat-framework/src/main/java/com/gkhy/hazmat/framework/interceptor/LogInterceptor.java
@@ -0,0 +1,37 @@
+package com.gkhy.hazmat.framework.interceptor;
+
+import cn.hutool.extra.servlet.ServletUtil;
+import com.gkhy.hazmat.common.utils.SecurityUtils;
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.UUID;
+
+/**
+ * @ClassName LogInterceptor
+ * @Description TODO
+ **/
+@Component
+public class LogInterceptor implements HandlerInterceptor {
+ @Override
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+ String requestId = UUID.randomUUID().toString();
+ String ip = ServletUtil.getClientIP(request,null);
+ String url=request.getRequestURI();
+
+ MDC.put("requestId", requestId);
+ MDC.put("clientIP", ip);
+ MDC.put("url", url);
+ String userId= SecurityUtils.getLoginUserWithoutError()!=null?String.valueOf(SecurityUtils.getLoginUserWithoutError().getUser().getId()):"";
+ MDC.put("userId", userId);
+ return true;
+ }
+
+ @Override
+ public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
+ MDC.clear();
+ }
+}
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzHazmatBasic.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzHazmatBasic.java
index e44a5a7..4a5e723 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzHazmatBasic.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzHazmatBasic.java
@@ -6,6 +6,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
+import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@@ -25,6 +26,7 @@
*/
@Getter
@Setter
+@Accessors(chain = true)
@TableName("hz_hazmat_basic")
@ApiModel(value = "HzHazmatBasic对象", description = "危化品基础数据表")
@JsonInclude(NON_NULL)
@@ -99,7 +101,7 @@
@TableField("price")
private BigDecimal price;
- @NotNull(message = "每箱数量不能为空")
+ // @NotNull(message = "每箱数量不能为空")
@ApiModelProperty(value = "每箱数量",required = true)
@TableField("per_box")
private Integer perBox;
@@ -143,6 +145,10 @@
@TableField("remark")
private String remark;
+ @ApiModelProperty("单次入库最大数量")
+ @TableField("max_entry")
+ private Integer maxEntry;
+
@Version
@TableField("version")
private Integer version;
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzProductBasic.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzProductBasic.java
index fbfe6f4..dced607 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzProductBasic.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzProductBasic.java
@@ -6,6 +6,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
+import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@@ -24,6 +25,7 @@
*/
@Getter
@Setter
+@Accessors(chain = true)
@TableName("hz_product_basic")
@ApiModel(value = "HzProductBasic对象", description = "成品基础数据表")
@JsonInclude(NON_NULL)
@@ -120,6 +122,10 @@
@TableField("remark")
private String remark;
+ @ApiModelProperty("单次入库最大数量")
+ @TableField("max_entry")
+ private Integer maxEntry;
+
@Version
@TableField("version")
private Integer version;
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzProductEntryRecord.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzProductEntryRecord.java
index 5201b65..7711408 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzProductEntryRecord.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/HzProductEntryRecord.java
@@ -1,9 +1,6 @@
package com.gkhy.hazmat.system.domain;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gkhy.hazmat.common.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
@@ -78,6 +75,7 @@
@TableField("company_id")
private Long companyId;
+ @Version
@TableField("version")
private Integer version;
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/SysCompany.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/SysCompany.java
index 255f27d..d383b22 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/SysCompany.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/domain/SysCompany.java
@@ -63,6 +63,12 @@
@TableField("del_flag")
private Integer delFlag;
+ @NotBlank(message = "公司唯一编码为空")
+ @Length(min = 2, max = 2, message = "公司唯一编码只能为2位")
+ @ApiModelProperty("公司唯一编码(2位)")
+ @TableField("code")
+ private String code;
+
@Version
@ApiModelProperty("乐观锁")
@TableField("version")
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/mapper/HzHazmatFlowMapper.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/mapper/HzHazmatFlowMapper.java
index 610edcc..c7ff187 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/mapper/HzHazmatFlowMapper.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/mapper/HzHazmatFlowMapper.java
@@ -52,4 +52,6 @@
* @return
*/
HzHazmatFlow selectLastFlow(@Param("slice") Integer slice,@Param("hazmatId") Long hazmatId, @Param("state")Integer state);
+
+
}
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/mapper/SysCompanyMapper.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/mapper/SysCompanyMapper.java
index 6d48b12..af18e12 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/mapper/SysCompanyMapper.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/mapper/SysCompanyMapper.java
@@ -47,6 +47,10 @@
*/
SysCompany checkNameUnique(String name);
-
-
+ /**
+ * 校验公司编码是否唯一
+ * @param code
+ * @return
+ */
+ SysCompany checkCodeUnique(String code);
}
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzHazmatBasicService.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzHazmatBasicService.java
index 62c92d4..a6a0e2f 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzHazmatBasicService.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzHazmatBasicService.java
@@ -3,6 +3,9 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.gkhy.hazmat.common.api.CommonPage;
import com.gkhy.hazmat.system.domain.HzHazmatBasic;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
/**
* <p>
@@ -65,4 +68,9 @@
*/
public boolean checkProductSnUnique(HzHazmatBasic hazmatBasic);
+ /**
+ * excel导入
+ * @param file
+ */
+ Integer importExcel(MultipartFile file) throws IOException;
}
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzHazmatService.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzHazmatService.java
index 6aeb726..501f364 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzHazmatService.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzHazmatService.java
@@ -86,4 +86,10 @@
* @param hazmat
*/
void changeState(HzHazmat hazmat);
+
+ /**
+ * 零头数据处理(修改在库余量)
+ * @param hazmat
+ */
+ void changeRemaining(HzHazmat hazmat);
}
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzProductBasicService.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzProductBasicService.java
index e32a7a2..d7a808a 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzProductBasicService.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/HzProductBasicService.java
@@ -3,6 +3,9 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.gkhy.hazmat.common.api.CommonPage;
import com.gkhy.hazmat.system.domain.HzProductBasic;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
/**
* <p>
@@ -64,4 +67,11 @@
* @return boolean
*/
public boolean checkProductSnUnique(HzProductBasic productBasic);
+
+
+ /**
+ * excel导入
+ * @param file
+ */
+ Integer importExcel(MultipartFile file) throws IOException;
}
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzEntryRecordServiceImpl.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzEntryRecordServiceImpl.java
index 4bc8fa4..1a428f6 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzEntryRecordServiceImpl.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzEntryRecordServiceImpl.java
@@ -15,14 +15,8 @@
import com.gkhy.hazmat.common.utils.PageUtils;
import com.gkhy.hazmat.common.utils.SecurityUtils;
import com.gkhy.hazmat.common.utils.StringUtils;
-import com.gkhy.hazmat.system.domain.HzEntryRecord;
-import com.gkhy.hazmat.system.domain.HzHazmat;
-import com.gkhy.hazmat.system.domain.HzHazmatBasic;
-import com.gkhy.hazmat.system.domain.HzWarehouseRecord;
-import com.gkhy.hazmat.system.mapper.HzEntryRecordMapper;
-import com.gkhy.hazmat.system.mapper.HzHazmatBasicMapper;
-import com.gkhy.hazmat.system.mapper.HzHazmatMapper;
-import com.gkhy.hazmat.system.mapper.HzWarehouseRecordMapper;
+import com.gkhy.hazmat.system.domain.*;
+import com.gkhy.hazmat.system.mapper.*;
import com.gkhy.hazmat.system.service.HzEntryRecordService;
import com.gkhy.hazmat.system.service.HzHazmatService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -56,6 +50,8 @@
private HzWarehouseRecordMapper warehouseRecordMapper;
@Autowired
private CustomEventPublisher customEventPublisher;
+ @Autowired
+ private SysCompanyMapper companyMapper;
@Override
public CommonPage selectEntryRecordList(HzEntryRecord entryRecord) {
@@ -87,6 +83,9 @@
if(hazmatBasic==null){
throw new ApiException("危化品基础数据不存在");
}
+ if(entryRecord.getNum()>hazmatBasic.getMaxEntry()){
+ throw new ApiException("数量超过单次入库最大数量<"+hazmatBasic.getMaxEntry()+">");
+ }
entryRecord.setCompanyId(currentUser.getCompanyId());
entryRecord.setCreateBy(currentUser.getUsername());
checkUserAllowed(null,currentUser);
@@ -103,11 +102,18 @@
}
public void generateCode(HzEntryRecord entryRecord){
+ SysCompany company=companyMapper.selectById(entryRecord.getCompanyId());
+ String code=company.getCode();
+ if(StringUtils.isBlank(code)){
+ throw new ApiException("公司两位编码为空");
+ }
String currentDate= DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT);
StringBuilder prefixBuilder=new StringBuilder().append(CodePrexEnum.MATERIAL.getCode())
+ .append(code)
.append(currentDate);
+
HzEntryRecord er=baseMapper.selectLastEntryRecord(prefixBuilder.toString(),entryRecord.getCompanyId());
- int startCode=0;
+ int startCode=1;
int endCode=startCode+entryRecord.getNum()-1;
if(er!=null){
startCode=er.getEndCode()+1;
@@ -209,10 +215,17 @@
public int updateEntryRecord(HzEntryRecord entryRecord) {
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
checkUserAllowed(entryRecord,currentUser);
+ HzHazmatBasic hazmatBasic=hazmatBasicMapper.selectById(entryRecord.getBasicId());
+ if(hazmatBasic==null){
+ throw new ApiException("危化品基础数据不存在");
+ }
HzEntryRecord existEr=baseMapper.selectById(entryRecord.getId());
if(existEr.getState().equals(EntryStateEnum.ENTER.getCode())){
throw new ApiException("已经入库,不能再修改");
}
+ if(entryRecord.getNum()>hazmatBasic.getMaxEntry()){
+ throw new ApiException("数量超过单次入库最大数量<"+hazmatBasic.getMaxEntry()+">");
+ }
entryRecord.setUpdateBy(currentUser.getUsername());
int row=baseMapper.updateById(entryRecord);
if(row<1){
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatBasicServiceImpl.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatBasicServiceImpl.java
index 6e67893..9d4e01f 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatBasicServiceImpl.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatBasicServiceImpl.java
@@ -1,18 +1,31 @@
package com.gkhy.hazmat.system.service.impl;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.hazmat.common.api.CommonPage;
import com.gkhy.hazmat.common.constant.UserConstant;
import com.gkhy.hazmat.common.domain.entity.SysUser;
+import com.gkhy.hazmat.common.enums.HazmatKindEnum;
+import com.gkhy.hazmat.common.enums.HazmatPackageEnum;
import com.gkhy.hazmat.common.enums.UserTypeEnum;
+import com.gkhy.hazmat.common.excel.HazmatBasicExcelData;
+import com.gkhy.hazmat.common.excel.HazmatBasicExcelDataListener;
import com.gkhy.hazmat.common.exception.ApiException;
import com.gkhy.hazmat.common.utils.PageUtils;
import com.gkhy.hazmat.common.utils.SecurityUtils;
+import com.gkhy.hazmat.common.utils.StringUtils;
import com.gkhy.hazmat.system.domain.HzHazmatBasic;
import com.gkhy.hazmat.system.mapper.HzHazmatBasicMapper;
import com.gkhy.hazmat.system.service.HzHazmatBasicService;
+import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -59,6 +72,7 @@
throw new ApiException("产品编号已存在");
}
checkUserAllowed(null,currentUser);
+
int row = baseMapper.insert(hazmatBasic);
if (row < 1) {
throw new ApiException("新增危化品基础信息失败");
@@ -114,4 +128,132 @@
}
return UserConstant.UNIQUE;
}
+
+ @Override
+ @Transactional(rollbackFor = RuntimeException.class)
+ public Integer importExcel(MultipartFile file) throws IOException {
+ if(ObjectUtil.isEmpty(file)){
+ throw new ApiException("上传对象不能为空");
+ }
+ SysUser currentUser=SecurityUtils.getLoginUser().getUser();
+ checkUserAllowed(null,currentUser);
+ List<HazmatBasicExcelData> hazmatExcelDataList = EasyExcel.read(file.getInputStream(), HazmatBasicExcelData.class, new HazmatBasicExcelDataListener()).sheet().doReadSync();
+ List<HzHazmatBasic> hazmatBasicList=new ArrayList<>();
+
+ for(HazmatBasicExcelData hazmatBasicExcelData:hazmatExcelDataList){
+ validateData(hazmatBasicExcelData);
+ if (!checkProductSnUnique(new HzHazmatBasic().setProductSn(hazmatBasicExcelData.getProductSn()).setCompanyId(currentUser.getCompanyId()))) {
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"产品编号已存在");
+ }
+ HzHazmatBasic hazmatBasic=new HzHazmatBasic();
+ BeanUtils.copyProperties(hazmatBasicExcelData,hazmatBasic,new String[]{"kind","minPackage"});
+ Integer kind= HazmatKindEnum.getCodeByInfo(hazmatBasicExcelData.getKind());
+ if(kind==null){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"种类填写不正确");
+ }
+ Integer minPackage= HazmatPackageEnum.getCodeByInfo(hazmatBasicExcelData.getMinPackage());
+ if(minPackage==null){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"最小包装类型填写不正确");
+ }
+ hazmatBasic.setKind(kind);
+ hazmatBasic.setMinPackage(minPackage);
+ hazmatBasic.setCompanyId(currentUser.getCompanyId());
+ hazmatBasic.setCreateBy(currentUser.getUsername());
+ hazmatBasicList.add(hazmatBasic);
+ }
+ if(!hazmatBasicList.isEmpty()){
+ if(hazmatBasicList.size()>100){
+ int pageSize=100;
+ while (true){
+ List<HzHazmatBasic> hazmatBasics=hazmatBasicList.subList(0, Math.min(hazmatBasicList.size(), pageSize));
+ saveBatch(hazmatBasics);
+ if(hazmatBasics.size()<pageSize){
+ break;
+ }
+ hazmatBasicList=hazmatBasicList.subList(pageSize,hazmatBasicList.size());
+ if(hazmatBasicList.isEmpty()){
+ break;
+ }
+ }
+ }else{
+ saveBatch(hazmatBasicList);
+ }
+ }
+ return hazmatBasicList.size();
+ }
+
+
+ public void validateData(HazmatBasicExcelData hazmatBasicExcelData){
+ if(StringUtils.isBlank(hazmatBasicExcelData.getName())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"名称为空");
+ }
+ if(StringUtils.isBlank(hazmatBasicExcelData.getProductSn())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"产品编码为空");
+ }
+ if(StringUtils.isBlank(hazmatBasicExcelData.getKind())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"种类为空");
+ }
+ if(StringUtils.isBlank(hazmatBasicExcelData.getCas())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"CAS为空");
+ }
+ if(StringUtils.isBlank(hazmatBasicExcelData.getHazmatType())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"试剂类型为空");
+ }
+ if(StringUtils.isBlank(hazmatBasicExcelData.getHazmatCharacter())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"危险性质为空");
+ }
+ if(StringUtils.isBlank(hazmatBasicExcelData.getSupplier())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"供应商为空");
+ }
+ if(StringUtils.isBlank(hazmatBasicExcelData.getManufacturer())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"厂家为空");
+ }
+ if(StringUtils.isBlank(hazmatBasicExcelData.getHazmatFormat())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"规格为空");
+ }
+ if(ObjectUtil.isEmpty(hazmatBasicExcelData.getMetering())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"包装数量为空");
+ }
+ if(StringUtils.isBlank(hazmatBasicExcelData.getUnit())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"包装单位为空");
+ }
+ if(ObjectUtil.isEmpty(hazmatBasicExcelData.getPrice())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"含税价格为空");
+ }
+ if(ObjectUtil.isEmpty(hazmatBasicExcelData.getMinPackage())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"最小包装类型为空");
+ }
+ if(ObjectUtil.isEmpty(hazmatBasicExcelData.getSafeNum())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"安全库存为空");
+ }
+ if(ObjectUtil.isEmpty(hazmatBasicExcelData.getThreshold())){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"超期阀值为空");
+ }
+
+ if(ObjectUtil.isEmpty(hazmatBasicExcelData.getMaxEntry())||hazmatBasicExcelData.getMaxEntry()<1){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"单次录入最大数量为空或者小于0");
+ }
+
+ if(hazmatBasicExcelData.getMetering().compareTo(BigDecimal.ZERO)<=0){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"包装数量小于0");
+ }
+
+ if(hazmatBasicExcelData.getPrice().compareTo(BigDecimal.ZERO)<=0){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"含税价格小于0");
+ }
+
+ if(ObjectUtil.isNotEmpty(hazmatBasicExcelData.getPerBox()) && hazmatBasicExcelData.getPerBox()<=0){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"每箱数量小于0");
+ }
+
+ if(hazmatBasicExcelData.getSafeNum()<0){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"安全库存小于0");
+ }
+
+ if(hazmatBasicExcelData.getThreshold()<0){
+ throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"超期阀值小于0");
+ }
+
+
+ }
}
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java
index 34eb0f0..461412e 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java
@@ -53,6 +53,7 @@
//设置分表id
IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
HzHazmatFlow hazmatFlow = baseMapper.selectById(hazmatFlowId);
+ IdTableNameHandler.removeCurrentId();
if (!hazmatFlow.getCompanyId().equals(currentUser.getCompanyId())) {
throw new ApiException("无权限查看其它企业数据");
}
@@ -68,6 +69,7 @@
//设置分表id
IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
int row = baseMapper.insert(hazmatFlow);
+ IdTableNameHandler.removeCurrentId();
if (row < 1) {
throw new ApiException("新增危化品流向失败");
}
@@ -81,6 +83,7 @@
//设置分表id
IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
HzHazmatFlow hazmatFlow=baseMapper.selectById(hazmatFlowId);
+ IdTableNameHandler.removeCurrentId();
if(hazmatFlow==null){
throw new ApiException("流向信息不存在");
}
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatServiceImpl.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatServiceImpl.java
index e2751cd..acad8a2 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatServiceImpl.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatServiceImpl.java
@@ -1,5 +1,6 @@
package com.gkhy.hazmat.system.service.impl;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.hazmat.common.api.CommonPage;
import com.gkhy.hazmat.common.config.IdTableNameHandler;
@@ -309,6 +310,42 @@
IdTableNameHandler.removeCurrentId();
}
+ @Override
+ @Transactional(rollbackFor = RuntimeException.class)
+ public void changeRemaining(HzHazmat hazmat) {
+ if(hazmat.getId()==null||hazmat.getRemaining()==null){
+ throw new ApiException("参数不正确");
+ }
+ SysUser currentUser=SecurityUtils.getLoginUser().getUser();
+ checkUserAllowed(null,currentUser);
+ //设置分表id
+ IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
+ HzHazmat dbHazmat=getById(hazmat.getId());
+ checkUserAllowed(dbHazmat,currentUser);
+ if(hazmat.getRemaining().compareTo(dbHazmat.getRemaining())>=0){
+ throw new ApiException("修改值不能大于等于在库容量");
+ }
+ //校验是否产生流向
+ Long flowCount=hazmatFlowMapper.selectCount(Wrappers.<HzHazmatFlow>lambdaQuery().eq(HzHazmatFlow::getHazmatId,hazmat.getId())
+ .ne(HzHazmatFlow::getState,OperateStatusEnum.ENTRY.getCode()));
+ if(flowCount>0){
+ throw new ApiException("该危化品已流转,不能修改!");
+ }
+ HzHazmat newHazmat=new HzHazmat().setId(hazmat.getId()).setRemaining(hazmat.getRemaining());
+ newHazmat.setUpdateBy(currentUser.getUsername());
+ updateById(newHazmat);
+ //生成流向
+ HzHazmatFlow hazmatFlow=new HzHazmatFlow();
+ hazmatFlow.setHazmatId(hazmat.getId());
+ hazmatFlow.setBasicId(dbHazmat.getBasicId());
+ hazmatFlow.setState(OperateStatusEnum.REMNANT.getCode());
+ hazmatFlow.setCompanyId(currentUser.getCompanyId());
+ hazmatFlow.setNum(hazmat.getRemaining());
+ hazmatFlow.setCreateId(currentUser.getId());
+ hazmatFlowMapper.insert(hazmatFlow);
+ IdTableNameHandler.removeCurrentId();
+ }
+
public void checkUserAllowed(HzHazmat hazmat,SysUser user) {
if (user.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())) {
throw new ApiException("管理员不能操作");
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductBasicServiceImpl.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductBasicServiceImpl.java
index 86c1b8e..c5f0ce9 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductBasicServiceImpl.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductBasicServiceImpl.java
@@ -1,18 +1,31 @@
package com.gkhy.hazmat.system.service.impl;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.hazmat.common.api.CommonPage;
import com.gkhy.hazmat.common.constant.UserConstant;
import com.gkhy.hazmat.common.domain.entity.SysUser;
+import com.gkhy.hazmat.common.enums.HazmatKindEnum;
+import com.gkhy.hazmat.common.enums.HazmatPackageEnum;
import com.gkhy.hazmat.common.enums.UserTypeEnum;
+import com.gkhy.hazmat.common.excel.ProductBasicExcelData;
+import com.gkhy.hazmat.common.excel.ProductBasicExcelDataListener;
import com.gkhy.hazmat.common.exception.ApiException;
import com.gkhy.hazmat.common.utils.PageUtils;
import com.gkhy.hazmat.common.utils.SecurityUtils;
+import com.gkhy.hazmat.common.utils.StringUtils;
import com.gkhy.hazmat.system.domain.HzProductBasic;
import com.gkhy.hazmat.system.mapper.HzProductBasicMapper;
import com.gkhy.hazmat.system.service.HzProductBasicService;
+import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -113,4 +126,120 @@
}
return UserConstant.UNIQUE;
}
+
+
+ @Override
+ @Transactional(rollbackFor = RuntimeException.class)
+ public Integer importExcel(MultipartFile file) throws IOException {
+ if(ObjectUtil.isEmpty(file)){
+ throw new ApiException("上传对象不能为空");
+ }
+ SysUser currentUser=SecurityUtils.getLoginUser().getUser();
+ checkUserAllowed(null,currentUser);
+ List<ProductBasicExcelData> productExcelDataList = EasyExcel.read(file.getInputStream(), ProductBasicExcelData.class, new ProductBasicExcelDataListener()).sheet().doReadSync();
+ List<HzProductBasic> productBasicList=new ArrayList<>();
+
+ for(ProductBasicExcelData productBasicExcelData:productExcelDataList){
+ validateData(productBasicExcelData);
+ if (!checkProductSnUnique(new HzProductBasic().setProductSn(productBasicExcelData.getProductSn()).setCompanyId(currentUser.getCompanyId()))) {
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"产品编号已存在");
+ }
+ HzProductBasic productBasic=new HzProductBasic();
+ BeanUtils.copyProperties(productBasicExcelData,productBasic,new String[]{"kind","minPackage"});
+ Integer kind= HazmatKindEnum.getCodeByInfo(productBasicExcelData.getKind());
+ if(kind==null){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"种类填写不正确");
+ }
+ Integer minPackage= HazmatPackageEnum.getCodeByInfo(productBasicExcelData.getMinPackage());
+ if(minPackage==null){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"最小包装类型填写不正确");
+ }
+ productBasic.setKind(kind);
+ productBasic.setMinPackage(minPackage);
+ productBasic.setCompanyId(currentUser.getCompanyId());
+ productBasic.setCreateBy(currentUser.getUsername());
+ productBasicList.add(productBasic);
+ }
+ if(!productBasicList.isEmpty()){
+ if(productBasicList.size()>100){
+ int pageSize=100;
+ while (true){
+ List<HzProductBasic> hazmatBasics=productBasicList.subList(0, Math.min(productBasicList.size(), pageSize));
+ saveBatch(hazmatBasics);
+ if(hazmatBasics.size()<pageSize){
+ break;
+ }
+ productBasicList=productBasicList.subList(pageSize,productBasicList.size());
+ if(productBasicList.isEmpty()){
+ break;
+ }
+ }
+ }else{
+ saveBatch(productBasicList);
+ }
+ }
+ return productBasicList.size();
+ }
+
+
+ public void validateData(ProductBasicExcelData productBasicExcelData){
+ if(StringUtils.isBlank(productBasicExcelData.getName())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"名称为空");
+ }
+ if(StringUtils.isBlank(productBasicExcelData.getProductSn())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"产品编码为空");
+ }
+ if(StringUtils.isBlank(productBasicExcelData.getKind())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"种类为空");
+ }
+ if(StringUtils.isBlank(productBasicExcelData.getCas())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"CAS为空");
+ }
+ if(StringUtils.isBlank(productBasicExcelData.getProductType())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"试剂类型为空");
+ }
+ if(StringUtils.isBlank(productBasicExcelData.getProductCharacter())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"危险性质为空");
+ }
+ if(StringUtils.isBlank(productBasicExcelData.getSupplier())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"供应商为空");
+ }
+ if(StringUtils.isBlank(productBasicExcelData.getManufacturer())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"厂家为空");
+ }
+ if(StringUtils.isBlank(productBasicExcelData.getProductFormat())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"规格为空");
+ }
+ if(ObjectUtil.isEmpty(productBasicExcelData.getMetering())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"包装数量为空");
+ }
+ if(StringUtils.isBlank(productBasicExcelData.getUnit())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"包装单位为空");
+ }
+ if(ObjectUtil.isEmpty(productBasicExcelData.getPrice())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"含税价格为空");
+ }
+ if(ObjectUtil.isEmpty(productBasicExcelData.getMinPackage())){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"最小包装类型为空");
+ }
+
+ if(ObjectUtil.isEmpty(productBasicExcelData.getMaxEntry())||productBasicExcelData.getMaxEntry()<1){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"单次录入最大数量为空或者小于0");
+ }
+
+ if(productBasicExcelData.getMetering().compareTo(BigDecimal.ZERO)<=0){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"包装数量小于0");
+ }
+
+ if(productBasicExcelData.getPrice().compareTo(BigDecimal.ZERO)<=0){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"含税价格小于0");
+ }
+
+ if(ObjectUtil.isNotEmpty(productBasicExcelData.getPerBox()) && productBasicExcelData.getPerBox()<=0){
+ throw new ApiException("序号"+productBasicExcelData.getIndex()+"每箱数量小于0");
+ }
+
+
+
+ }
}
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductEntryRecordServiceImpl.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductEntryRecordServiceImpl.java
index 38d041e..ff9d8a7 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductEntryRecordServiceImpl.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductEntryRecordServiceImpl.java
@@ -15,14 +15,8 @@
import com.gkhy.hazmat.common.utils.PageUtils;
import com.gkhy.hazmat.common.utils.SecurityUtils;
import com.gkhy.hazmat.common.utils.StringUtils;
-import com.gkhy.hazmat.system.domain.HzProduct;
-import com.gkhy.hazmat.system.domain.HzProductBasic;
-import com.gkhy.hazmat.system.domain.HzProductEntryRecord;
-import com.gkhy.hazmat.system.domain.HzProductWarehouseRecord;
-import com.gkhy.hazmat.system.mapper.HzProductBasicMapper;
-import com.gkhy.hazmat.system.mapper.HzProductEntryRecordMapper;
-import com.gkhy.hazmat.system.mapper.HzProductMapper;
-import com.gkhy.hazmat.system.mapper.HzProductWarehouseRecordMapper;
+import com.gkhy.hazmat.system.domain.*;
+import com.gkhy.hazmat.system.mapper.*;
import com.gkhy.hazmat.system.service.HzProductEntryRecordService;
import com.gkhy.hazmat.system.service.HzProductService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -56,6 +50,8 @@
private HzProductWarehouseRecordMapper productWarehouseRecordMapper;
@Autowired
private CustomEventPublisher customEventPublisher;
+ @Autowired
+ private SysCompanyMapper companyMapper;
@Override
public CommonPage selectEntryRecordList(HzProductEntryRecord entryRecord) {
@@ -87,6 +83,9 @@
if(productBasic==null){
throw new ApiException("成品基础数据不存在");
}
+ if(entryRecord.getNum()>productBasic.getMaxEntry()){
+ throw new ApiException("数量超过单次入库最大数量<"+productBasic.getMaxEntry()+">");
+ }
entryRecord.setCompanyId(currentUser.getCompanyId());
entryRecord.setCreateBy(currentUser.getUsername());
checkUserAllowed(null,currentUser);
@@ -103,11 +102,17 @@
}
public void generateCode(HzProductEntryRecord entryRecord){
+ SysCompany company=companyMapper.selectById(entryRecord.getCompanyId());
+ String code=company.getCode();
+ if(StringUtils.isBlank(code)){
+ throw new ApiException("公司两位编码为空");
+ }
String currentDate= DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT);
StringBuilder prefixBuilder=new StringBuilder().append(CodePrexEnum.GOOD.getCode())
+ .append(code)
.append(currentDate);
HzProductEntryRecord per=baseMapper.selectLastEntryRecord(prefixBuilder.toString(),entryRecord.getCompanyId());
- int startCode=0;
+ int startCode=1;
int endCode=startCode+entryRecord.getNum()-1;
if(per!=null){
startCode=per.getEndCode()+1;
@@ -208,10 +213,18 @@
public int updateEntryRecord(HzProductEntryRecord entryRecord) {
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
checkUserAllowed(entryRecord,currentUser);
+ HzProductBasic productBasic=productBasicMapper.selectById(entryRecord.getBasicId());
+ if(productBasic==null){
+ throw new ApiException("成品基础数据不存在");
+ }
+ if(entryRecord.getNum()>productBasic.getMaxEntry()){
+ throw new ApiException("数量超过单次入库最大数量<"+productBasic.getMaxEntry()+">");
+ }
HzProductEntryRecord existEr=baseMapper.selectById(entryRecord.getId());
if(existEr.getState().equals(EntryStateEnum.ENTER.getCode())){
throw new ApiException("已经入库,不能再修改");
}
+
entryRecord.setUpdateBy(currentUser.getUsername());
int row=baseMapper.updateById(entryRecord);
if(row<1){
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/SysCompanyServiceImpl.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/SysCompanyServiceImpl.java
index 377ce1b..9116355 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/SysCompanyServiceImpl.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/SysCompanyServiceImpl.java
@@ -44,12 +44,15 @@
if(!checkNameUnique(company)){
throw new ApiException("公司名称已存在");
}
+ if(!checkCodeUnique(company)){
+ throw new ApiException("公司编码已存在");
+ }
+ company.setCode(company.getCode().toUpperCase());
company.setCreateBy(SecurityUtils.getUsername());
int row= baseMapper.insert(company);
if(row<1){
throw new ApiException("新增公司失败");
}
-
return row;
}
@@ -58,6 +61,10 @@
if(!checkNameUnique(company)){
throw new ApiException("公司名称已存在");
}
+ if(!checkCodeUnique(company)){
+ throw new ApiException("公司编码已存在");
+ }
+ company.setCode(company.getCode().toUpperCase());
company.setUpdateBy(SecurityUtils.getUsername());
return baseMapper.updateById(company);
}
@@ -76,4 +83,14 @@
}
return UserConstant.UNIQUE;
}
+
+
+ public boolean checkCodeUnique(SysCompany company){
+ Long companyId=company.getId()==null?-1L:company.getId();
+ SysCompany com= baseMapper.checkCodeUnique(company.getCode());
+ if(com!=null&&com.getId().longValue()!=companyId.longValue()){
+ return UserConstant.NOT_UNIQUE;
+ }
+ return UserConstant.UNIQUE;
+ }
}
diff --git a/hazmat-system/src/main/resources/mapper/system/HzEntryRecordMapper.xml b/hazmat-system/src/main/resources/mapper/system/HzEntryRecordMapper.xml
index b1224e6..11781d4 100644
--- a/hazmat-system/src/main/resources/mapper/system/HzEntryRecordMapper.xml
+++ b/hazmat-system/src/main/resources/mapper/system/HzEntryRecordMapper.xml
@@ -35,6 +35,7 @@
<result property="metering" column="basic_metering" />
<result property="unit" column="basic_unit" />
<result property="productSn" column="product_sn" />
+ <result property="maxEntry" column="max_entry" />
</resultMap>
<resultMap id="wareResult" type="com.gkhy.hazmat.system.domain.HzWarehouse">
@@ -47,7 +48,7 @@
select a.id, a.warehouse_id, a.num,a.batch_no,a.state,a.basic_id,a.company_id,a.start_code,a.end_code,a.code_prex,a.version, a.create_by,
a.create_time, a.update_by, a.update_time, a.remark,
b.id as basic_id,b.name as basic_name,b.cas as basic_cas,b.hazmat_type as basic_hazmat_type,b.hazmat_character as basic_hazmat_character,
- b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package,
+ b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package,b.max_entry,
c.id as warehouse_id,c.name as warehouse_name
from hz_entry_record a
left join hz_hazmat_basic b on b.id=a.basic_id
diff --git a/hazmat-system/src/main/resources/mapper/system/HzHazmatBasicMapper.xml b/hazmat-system/src/main/resources/mapper/system/HzHazmatBasicMapper.xml
index 3b29a0b..b598e3f 100644
--- a/hazmat-system/src/main/resources/mapper/system/HzHazmatBasicMapper.xml
+++ b/hazmat-system/src/main/resources/mapper/system/HzHazmatBasicMapper.xml
@@ -27,13 +27,14 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
+ <result property="maxEntry" column="max_entry" />
<result property="companyName" column="company_name" />
</resultMap>
<sql id="selectHazmatBasicVo">
select a.id, a.name, a.cas, a.hazmat_type,a.min_package, a.kind,a.hazmat_character,a.supplier,a.manufacturer,a.hazmat_format,a.metering,
a.unit,a.price,a.per_box,a.safe_num,a.threshold,a.product_sn,a.company_id,a.version, a.create_by, a.create_time,
- a.update_by, a.update_time, a.remark,b.name as company_name
+ a.update_by, a.update_time, a.remark,a.max_entry,b.name as company_name
from hz_hazmat_basic a
left join sys_company b on b.id=a.company_id
</sql>
diff --git a/hazmat-system/src/main/resources/mapper/system/HzProductBasicMapper.xml b/hazmat-system/src/main/resources/mapper/system/HzProductBasicMapper.xml
index fe4fccf..c1493ec 100644
--- a/hazmat-system/src/main/resources/mapper/system/HzProductBasicMapper.xml
+++ b/hazmat-system/src/main/resources/mapper/system/HzProductBasicMapper.xml
@@ -25,12 +25,13 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
+ <result property="maxEntry" column="max_entry" />
<result property="companyName" column="company_name" />
</resultMap>
<sql id="selectProductBasicVo">
select a.id, a.name, a.cas, a.product_type, a.min_package,a.kind,a.product_character,a.supplier,a.manufacturer,a.product_format,a.metering,
- a.unit,a.price,a.per_box,a.product_sn,a.company_id,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as company_name
+ a.unit,a.price,a.per_box,a.product_sn,a.company_id,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,a.max_entry,b.name as company_name
from hz_product_basic a
left join sys_company b on b.id=a.company_id
</sql>
diff --git a/hazmat-system/src/main/resources/mapper/system/HzProductEntryRecordMapper.xml b/hazmat-system/src/main/resources/mapper/system/HzProductEntryRecordMapper.xml
index 10232c4..5675b3e 100644
--- a/hazmat-system/src/main/resources/mapper/system/HzProductEntryRecordMapper.xml
+++ b/hazmat-system/src/main/resources/mapper/system/HzProductEntryRecordMapper.xml
@@ -34,6 +34,7 @@
<result property="metering" column="basic_metering" />
<result property="unit" column="basic_unit" />
<result property="productSn" column="product_sn" />
+ <result property="maxEntry" column="max_entry" />
</resultMap>
<resultMap id="wareResult" type="com.gkhy.hazmat.system.domain.HzWarehouse">
@@ -46,7 +47,7 @@
select a.id, a.warehouse_id, a.num,a.batch_no,a.state,a.basic_id,a.company_id,a.start_code,a.end_code,a.code_prex,a.version, a.create_by,
a.create_time, a.update_by, a.update_time, a.remark,
b.id as basic_id,b.name as basic_name,b.cas as basic_cas,b.product_type as basic_product_type,b.product_character as basic_product_character,
- b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package,
+ b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package,b.max_entry,
c.id as warehouse_id,c.name as warehouse_name
from hz_product_entry_record a
left join hz_product_basic b on b.id=a.basic_id
diff --git a/hazmat-system/src/main/resources/mapper/system/SysCompanyMapper.xml b/hazmat-system/src/main/resources/mapper/system/SysCompanyMapper.xml
index d215de1..e32821c 100644
--- a/hazmat-system/src/main/resources/mapper/system/SysCompanyMapper.xml
+++ b/hazmat-system/src/main/resources/mapper/system/SysCompanyMapper.xml
@@ -7,6 +7,7 @@
<result property="creditCode" column="credit_code" />
<result property="major" column="major" />
<result property="phone" column="phone" />
+ <result property="code" column="code" />
<result property="delFlag" column="del_flag" />
<result property="version" column="version" />
<result property="createBy" column="create_by" />
@@ -18,7 +19,7 @@
</resultMap>
<sql id="selectCompanyVo">
- select id, name, credit_code, major, phone,version, create_by, create_time, update_by, update_time, remark
+ select id, name, credit_code, major,code, phone,version, create_by, create_time, update_by, update_time, remark
from sys_company
</sql>
@@ -53,6 +54,10 @@
select id,name from sys_company where name=#{name} and del_flag=0 limit 1
</select>
+ <select id="checkCodeUnique" resultType="com.gkhy.hazmat.system.domain.SysCompany"
+ parameterType="java.lang.String">
+ select id,code from sys_company where code=#{code} and del_flag=0 limit 1
+ </select>
</mapper>
diff --git a/hazmat-system/src/main/resources/mapper/system/SysDeptMapper.xml b/hazmat-system/src/main/resources/mapper/system/SysDeptMapper.xml
index 5e584c5..cafec6a 100644
--- a/hazmat-system/src/main/resources/mapper/system/SysDeptMapper.xml
+++ b/hazmat-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -4,7 +4,7 @@
<update id="updateDeptStatusNormal" parameterType="Long">
- update sys_dept set status = '0' where id in
+ update sys_dept set status = 0 where id in
<foreach collection="array" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
diff --git a/hazmat-system/src/main/resources/mapper/system/HzStatisticService.xml b/hazmat-system/src/main/resources/mapper/system/SysDictTypeMapper.xml
similarity index 100%
rename from hazmat-system/src/main/resources/mapper/system/HzStatisticService.xml
rename to hazmat-system/src/main/resources/mapper/system/SysDictTypeMapper.xml
diff --git a/hazmat-system/src/main/resources/mapper/system/SysUserMapper.xml b/hazmat-system/src/main/resources/mapper/system/SysUserMapper.xml
index 00ed8b1..fd1c267 100644
--- a/hazmat-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/hazmat-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -36,11 +36,11 @@
<select id="getUserByUsername" resultMap="SysUserResult">
select id,username,name,password,user_type,company_id,status,del_flag from sys_user
- where username=#{username} limit 1
+ where username=#{username} and del_flag=0 limit 1
</select>
<select id="userList" resultMap="SysUserResult">
- select u.id,u.username,u.name,u.user_type,u.phone,u.company_id,u.depart_id,u.sex,u.status,u.del_flag,
+ select u.id,u.username,u.name,u.user_type,u.phone,u.company_id,u.depart_id,u.sex,u.status,u.del_flag,u.version,
u.login_ip,u.login_date,u.create_by,u.create_time,u.remark,c.name as company_name,d.name as depart_name
from sys_user u
left join sys_company c on c.id=u.company_id
@@ -79,11 +79,11 @@
<select id="getUserByPhone" resultMap="SysUserResult">
select id,username,name,password,company_id,phone,status,del_flag from sys_user
- where phone=#{phone} and del_flag=0
+ where phone=#{phone} and del_flag=0 limit 1
</select>
<select id="getUserById" resultMap="SysUserResult">
- select u.id,u.username,u.user_type,u.name,u.phone,u.company_id,u.depart_id,u.status,u.sex,u.del_flag,c.name as company_name,d.name as depart_name
+ select u.id,u.username,u.user_type,u.name,u.phone,u.company_id,u.depart_id,u.status,u.sex,u.del_flag,u.version,c.name as company_name,d.name as depart_name
from sys_user u
left join sys_company c on c.id=u.company_id
left join sys_dept d on d.id=u.depart_id
diff --git a/pom.xml b/pom.xml
index 4422549..bb86fd9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,6 +43,7 @@
<poi.version>5.2.3</poi.version>
<pdfbox.version>2.0.27</pdfbox.version>
<jaudiotagger.version>2.0.1</jaudiotagger.version>
+ <easyexcel.version>4.0.2</easyexcel.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -180,6 +181,12 @@
<version>${jaudiotagger.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>easyexcel</artifactId>
+ <version>${easyexcel.version}</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
--
Gitblit v1.9.2