Procházet zdrojové kódy

保存码库时保存码库的列

bess-WeiganCai před 4 roky
rodič
revize
154b12c46a
25 změnil soubory, kde provedl 505 přidání a 31 odebrání
  1. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/QrFormatController.java
  2. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/QrRepertoryController.java
  3. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/entity/QrRepertory.java
  4. 61 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/entity/QrRepertoryColumn.java
  5. 8 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/QrFormatMapper.java
  6. 26 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/QrRepertoryColumnMapper.java
  7. 5 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/QrRepertoryMapper.java
  8. 54 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/QrRepertoryColumnVO.java
  9. 9 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/QrRepertoryVO.java
  10. 37 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/BatchInsertQrRepertoryColumnReq.java
  11. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/ListQrRepertoryReq.java
  12. 44 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/SaveQrRepertoryColumnReq.java
  13. 11 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/SaveQrRepertoryReq.java
  14. 42 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetQrRepertoryColumnDetailRes.java
  15. 5 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetQrRepertoryDetailRes.java
  16. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/ListQrRepertoryRes.java
  17. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/QrFormatService.java
  18. 11 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/QrRepertoryColumnService.java
  19. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/QrRepertoryService.java
  20. 11 6
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrFormatServiceImpl.java
  21. 15 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrRepertoryColumnServiceImpl.java
  22. 88 14
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrRepertoryServiceImpl.java
  23. 11 0
      abi-cloud-qr-platform-server/src/main/resources/dao/mapper/QrFormatMapper.xml
  24. 35 0
      abi-cloud-qr-platform-server/src/main/resources/dao/mapper/QrRepertoryColumnMapper.xml
  25. 25 1
      abi-cloud-qr-platform-server/src/main/resources/dao/mapper/QrRepertoryMapper.xml

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/QrFormatController.java

@@ -57,7 +57,7 @@ public class QrFormatController {
     @ApiOperation("码格式禁用")
     @PostMapping("/disableQrFormat")
     public BaseResponse disableQrFormat(@Validated @RequestBody DisableQrFormatReq disableQrFormatReq) {
-        qrFormatService.disableFormat(disableQrFormatReq);
+        qrFormatService.disableQrFormat(disableQrFormatReq);
         return BaseResponse.create();
     }
 

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/QrRepertoryController.java

@@ -57,7 +57,7 @@ public class QrRepertoryController {
     @ApiOperation("码库禁用")
     @PostMapping("/disableQrRepertory")
     public BaseResponse disableQrRepertory(@Validated @RequestBody DisableQrRepertoryReq disableQrRepertoryReq) {
-        qrRepertoryService.disableFormat(disableQrRepertoryReq);
+        qrRepertoryService.disableQrRepertory(disableQrRepertoryReq);
         return BaseResponse.create();
     }
 

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/entity/QrRepertory.java

@@ -33,7 +33,7 @@ public class QrRepertory {
 	@ApiModelProperty("码库名称")
 	private String name;
 
-	@ApiModelProperty("码库类型 0-系统生成 1-文本导入 2-FTP接入")
+	@ApiModelProperty("码库类型 1-系统生成 2-文本导入 3-FTP接入")
 	private Integer type;
 
 	@ApiModelProperty("自带流水号 0-不带 1-带")

+ 61 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/entity/QrRepertoryColumn.java

@@ -0,0 +1,61 @@
+package com.abi.qms.platform.dao.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import java.time.LocalDateTime;
+
+/**
+ * 码库的列信息 对象 qr_repertory_column
+ * 
+ * @author WeiganCai
+ * @date 2021-04-25
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="码库的列信息对象", description="码库的列信息")
+public class QrRepertoryColumn {
+
+    @ApiModelProperty("码库列id")
+    private Long id;
+
+    @ApiModelProperty("码库id")
+    private Long qrRepertoryId;
+
+    @ApiModelProperty("码格式id")
+    private Long qrFormatId;
+
+    @ApiModelProperty("克隆列 -1:未克隆 >=0:克隆了哪列,下标从0开始")
+    private Integer cloneColumn;
+
+    @ApiModelProperty("排序号")
+    private Integer sortNumber;
+
+    @ApiModelProperty("别名")
+    private String alias;
+
+    @ApiModelProperty("url格式类型")
+    private Integer urlType;
+
+    @ApiModelProperty("备注")
+    private String remark;
+
+    @ApiModelProperty(value = "创建时间")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty(value = "创建人id")
+    private Long createBy;
+
+    @ApiModelProperty(value = "修改时间")
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty(value = "修改人id")
+    private Long updateBy;
+
+    @ApiModelProperty("是否删除")
+    private Integer isDelete;
+
+}

+ 8 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/QrFormatMapper.java

@@ -6,6 +6,8 @@ import com.abi.qms.platform.dto.req.ListQrFormatReq;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import java.util.List;
+
 /**
  * 码格式 Mapper接口
  *
@@ -18,4 +20,10 @@ public interface QrFormatMapper extends BaseMapper<QrFormat> {
 	 * 分页查询码格式信息
 	 */
 	IPage<QrFormatVO> listQrFormat(IPage page, ListQrFormatReq param);
+
+	/**
+	 * 根据码库id查询与码库关联的,被禁用的码格式
+	 * @param qrRepertoryId 码库id
+	 */
+	 List<String> selectDisabledQrFormat(Long qrRepertoryId);
 }

+ 26 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/QrRepertoryColumnMapper.java

@@ -0,0 +1,26 @@
+package com.abi.qms.platform.dao.mapper;
+
+import com.abi.qms.platform.dao.entity.QrRepertoryColumn;
+import com.abi.qms.platform.dto.req.BatchInsertQrRepertoryColumnReq;
+import com.abi.qms.platform.dto.req.SaveQrRepertoryReq;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 码库的列信息 Mapper接口
+ *
+ * @author WeiganCai
+ * @date 2021-04-25
+ */
+public interface QrRepertoryColumnMapper extends BaseMapper<QrRepertoryColumn> {
+
+	/**
+	 * 批量插入码库的列
+	 */
+	int batchInsert(BatchInsertQrRepertoryColumnReq req);
+
+	/**
+	 * 逻辑删除码库的列
+	 * @param
+	 */
+	void deleteByQrRepertoryId(Long qrRepertory);
+}

+ 5 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/QrRepertoryMapper.java

@@ -18,4 +18,9 @@ public interface QrRepertoryMapper extends BaseMapper<QrRepertory> {
 	 * 分页查询码库信息
 	 */
 	IPage<QrRepertoryVO> listQrRepertory(IPage page, ListQrRepertoryReq param);
+
+	/**
+	 * 查询码库详细信息
+	 */
+	QrRepertoryVO selectQrRepertoryDetailById(Long id);
 }

+ 54 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/QrRepertoryColumnVO.java

@@ -0,0 +1,54 @@
+package com.abi.qms.platform.dao.vo.result;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * 码库的列 对象 qr_repertory_column
+ *
+ * @author WeiganCai
+ * @date: 2021-04-26
+ */
+@Data
+@ApiModel
+public class QrRepertoryColumnVO {
+	@ApiModelProperty("码库列id")
+	private Long id;
+
+	@ApiModelProperty("码库id")
+	private Long qrRepertoryId;
+
+	@ApiModelProperty("码格式id")
+	private Long qrFormatId;
+
+	@ApiModelProperty("克隆列 -1:未克隆 >=0:克隆了哪列,下标从0开始")
+	private Integer cloneColumn;
+
+	@ApiModelProperty("排序号")
+	private Integer sortNumber;
+
+	@ApiModelProperty("别名")
+	private String alias;
+
+	@ApiModelProperty("url格式类型")
+	private Integer urlType;
+
+	@ApiModelProperty("备注")
+	private String remark;
+
+	@ApiModelProperty(value = "创建时间")
+	private LocalDateTime createTime;
+
+	@ApiModelProperty(value = "创建人id")
+	private Long createBy;
+
+	@ApiModelProperty(value = "修改时间")
+	private LocalDateTime updateTime;
+
+	@ApiModelProperty(value = "修改人id")
+	private Long updateBy;
+
+}

+ 9 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/QrRepertoryVO.java

@@ -1,10 +1,12 @@
 package com.abi.qms.platform.dao.vo.result;
 
+import com.abi.qms.platform.dto.req.SaveQrRepertoryColumnReq;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * 码库 对象 qr_repertory
@@ -19,13 +21,16 @@ public class QrRepertoryVO {
 	@ApiModelProperty("码库id")
 	private Long id;
 
+	@ApiModelProperty("部门id")
+	private Long deptId;
+
 	@ApiModelProperty("部门名称")
 	private String deptName;
 
 	@ApiModelProperty("码库名称")
 	private String name;
 
-	@ApiModelProperty("码库类型 0-系统生成 1-文本导入 2-FTP接入")
+	@ApiModelProperty("码库类型 1-系统生成 2-文本导入 3-FTP接入")
 	private Integer type;
 
 	@ApiModelProperty("自带流水号 0-不带 1-带")
@@ -40,6 +45,9 @@ public class QrRepertoryVO {
 	@ApiModelProperty("克隆规则")
 	private String cloneRule;
 
+	@ApiModelProperty("码库的列")
+	private List<QrRepertoryColumnVO> qrRepertoryColumnList;
+
 	@ApiModelProperty(value = "创建时间")
 	private LocalDateTime createTime;
 

+ 37 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/BatchInsertQrRepertoryColumnReq.java

@@ -0,0 +1,37 @@
+package com.abi.qms.platform.dto.req;
+
+import com.abi.qms.platform.dao.entity.QrRepertory;
+import com.abi.qms.platform.dao.entity.QrRepertoryColumn;
+import com.abi.task.common.utils.PojoConverterUtils;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 批量插入码库的列 Mapper入参
+ *
+ * @author WeiganCai
+ * @date: 2021-04-26
+ */
+@Data
+public class BatchInsertQrRepertoryColumnReq {
+
+	/** 码库id */
+	private Long qrRepertoryId;
+
+	/** 创建人id */
+	private Long createBy;
+
+	/** 更新人id */
+	private Long updateBy;
+
+	/** 码库的列 */
+	private List<QrRepertoryColumn> qrRepertoryColumnList;
+
+	public BatchInsertQrRepertoryColumnReq(QrRepertory qrRepertory, List<SaveQrRepertoryColumnReq> qrRepertoryColumnList) {
+		this.qrRepertoryId = qrRepertory.getId();
+		this.createBy = qrRepertory.getCreateBy();
+		this.updateBy = qrRepertory.getUpdateBy();
+		this.qrRepertoryColumnList = PojoConverterUtils.copyList(qrRepertoryColumnList, QrRepertoryColumn.class);
+	}
+}

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/ListQrRepertoryReq.java

@@ -23,7 +23,7 @@ public class ListQrRepertoryReq extends PageReq implements Serializable {
 	@ApiModelProperty("码库名称")
 	private String name;
 
-	@ApiModelProperty("码库类型 0-系统生成 1-文本导入 2-FTP接入")
+	@ApiModelProperty("码库类型 1-系统生成 2-文本导入 3-FTP接入")
 	private Integer type;
 
 	@ApiModelProperty("码库状态 10-待生成 11-自动生成 20-待导入 21-已导入 40-停用")

+ 44 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/SaveQrRepertoryColumnReq.java

@@ -0,0 +1,44 @@
+package com.abi.qms.platform.dto.req;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+
+/**
+ * 码库的列新增修改入参
+ *
+ * @author WeiganCai
+ * @date: 2021-04-26
+ */
+@Data
+@ApiModel
+public class SaveQrRepertoryColumnReq implements Serializable {
+
+	@ApiModelProperty("码格式id")
+	private Long qrFormatId;
+
+	@ApiModelProperty("克隆列 -1:未克隆 >=0:克隆了哪列,下标从0开始")
+	private Integer cloneColumn;
+
+	@ApiModelProperty("排序号")
+	private Integer sortNumber;
+
+	@NotNull(message = "列别名为空")
+	@Pattern(regexp = "^[a-zA-Z-z0-9\\u4e00-\\u9fa5]{1,20}$", message = "列别名限制20字内的汉字or字母or数字")
+	@ApiModelProperty("别名")
+	private String alias;
+
+	@NotNull(message = "URL格式为空")
+	@ApiModelProperty("url格式类型")
+	private Integer urlType;
+
+	@Size(max = 50, message = "备注长度超过50")
+	@ApiModelProperty("备注")
+	private String remark;
+
+}

+ 11 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/SaveQrRepertoryReq.java

@@ -4,9 +4,13 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.Valid;
+import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * 码库新增修改入参
@@ -31,12 +35,18 @@ public class SaveQrRepertoryReq implements Serializable {
 	private String name;
 
 	@NotNull(message = "码库类型为空")
-	@ApiModelProperty("码库类型 0-系统生成 1-文本导入 2-FTP接入")
+	@ApiModelProperty("码库类型 1-系统生成 2-文本导入 3-FTP接入")
 	private Integer type;
 
 	@ApiModelProperty("自带流水号 0-不带 1-带")
 	private Integer haveSerial;
 
+	@NotEmpty(message = "码数据组成为空")
+	@Size(max = 10, message = "码数据组成超过10列")
+	@Valid
+	@ApiModelProperty("码库的列")
+	private List<SaveQrRepertoryColumnReq> qrRepertoryColumnList;
+
 	@ApiModelProperty("码数据组成")
 	private String dataComposition;
 

+ 42 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetQrRepertoryColumnDetailRes.java

@@ -0,0 +1,42 @@
+package com.abi.qms.platform.dto.res;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 码库的列查询详情出参
+ *
+ * @author WeiganCai
+ * @date: 2021-04-26
+ */
+@Data
+@ApiModel
+public class GetQrRepertoryColumnDetailRes implements Serializable {
+
+	@ApiModelProperty("码库列id")
+	private Long id;
+
+	@ApiModelProperty("码库id")
+	private Long qrRepertoryId;
+
+	@ApiModelProperty("码格式id")
+	private Long qrFormatId;
+
+	@ApiModelProperty("克隆列 -1:未克隆 >=0:克隆了哪列,下标从0开始")
+	private Integer cloneColumn;
+
+	@ApiModelProperty("排序号")
+	private Integer sortNumber;
+
+	@ApiModelProperty("别名")
+	private String alias;
+
+	@ApiModelProperty("url格式类型")
+	private Integer urlType;
+
+	@ApiModelProperty("备注")
+	private String remark;
+}

+ 5 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetQrRepertoryDetailRes.java

@@ -7,6 +7,7 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * 码库查询详情出参
@@ -27,7 +28,7 @@ public class GetQrRepertoryDetailRes implements Serializable {
 	@ApiModelProperty("码库名称")
 	private String name;
 
-	@ApiModelProperty("码库类型 0-系统生成 1-文本导入 2-FTP接入")
+	@ApiModelProperty("码库类型 1-系统生成 2-文本导入 3-FTP接入")
 	private Integer type;
 
 	@ApiModelProperty("自带流水号 0-不带 1-带")
@@ -42,6 +43,9 @@ public class GetQrRepertoryDetailRes implements Serializable {
 	@ApiModelProperty("克隆规则")
 	private String cloneRule;
 
+	@ApiModelProperty("码库的列")
+	private List<GetQrRepertoryColumnDetailRes> qrRepertoryColumnList;
+
 	@ApiModelProperty(value = "创建时间")
 	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	private LocalDateTime createTime;

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/ListQrRepertoryRes.java

@@ -45,7 +45,7 @@ public class ListQrRepertoryRes extends PageResp implements Serializable {
 		@ApiModelProperty("码库名称")
 		private String name;
 
-		@ApiModelProperty("码库类型 0-系统生成 1-文本导入 2-FTP接入")
+		@ApiModelProperty("码库类型 1-系统生成 2-文本导入 3-FTP接入")
 		private Integer type;
 
 		@ApiModelProperty("自带流水号 0-不带 1-带")

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/QrFormatService.java

@@ -35,7 +35,7 @@ public interface QrFormatService {
 	/**
 	 * 码格式禁用
 	 */
-	void disableFormat(DisableQrFormatReq disableQrFormatReq);
+	void disableQrFormat(DisableQrFormatReq disableQrFormatReq);
 
 	/**
 	 * 删除码格式

+ 11 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/QrRepertoryColumnService.java

@@ -0,0 +1,11 @@
+package com.abi.qms.platform.service;
+
+/**
+ * 码库的列信息 Service接口
+ *
+ * @author WeiganCai
+ * @date 2021-04-25
+ */
+public interface QrRepertoryColumnService {
+
+}

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/QrRepertoryService.java

@@ -35,7 +35,7 @@ public interface QrRepertoryService {
 	/**
 	 * 码库禁用
 	 */
-	void disableFormat(DisableQrRepertoryReq disableQrRepertoryReq);
+	void disableQrRepertory(DisableQrRepertoryReq disableQrRepertoryReq);
 
 	/**
 	 * 删除码库

+ 11 - 6
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrFormatServiceImpl.java

@@ -45,10 +45,11 @@ public class QrFormatServiceImpl implements QrFormatService {
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void saveQrFormat(SaveQrFormatReq req) {
+		Long qrFormatId = req.getId();
 		// 修改码格式时的条件限制
 		QrFormat qrFormat;
-		if (req.getId() != null) {
-			qrFormat = qrFormatMapper.selectById(req.getId());
+		if (qrFormatId != null) {
+			qrFormat = qrFormatMapper.selectById(qrFormatId);
 			AssertUtil.isNull(qrFormat, "码格式不存在");
 			// 只有未使用状态下才可编辑
 			if (!QrFormatUseStatusEnum.UN_USE.is(qrFormat.getUseStatus())) {
@@ -60,8 +61,9 @@ public class QrFormatServiceImpl implements QrFormatService {
 		QueryWrapper<QrFormat> qrFormatQw = new QueryWrapper<>();
 		qrFormatQw.eq("dept_id", req.getDeptId());
 		qrFormatQw.eq("name", req.getName());
-		if (req.getId() != null) {
-			qrFormatQw.ne("id", req.getId());
+		qrFormatQw.eq("is_delete", 0);
+		if (qrFormatId != null) {
+			qrFormatQw.ne("id", qrFormatId);
 		}
 		Integer count = qrFormatMapper.selectCount(qrFormatQw);
 		if (!count.equals(0)) {
@@ -74,7 +76,7 @@ public class QrFormatServiceImpl implements QrFormatService {
 		// 新增or修改
 		Long userId = UserUtil.getUser().getId();
 		qrFormat.setUpdateBy(userId);
-		if (req.getId() != null) {
+		if (qrFormatId != null) {
 			qrFormatMapper.updateById(qrFormat);
 		} else {
 			qrFormat.setCreateBy(userId);
@@ -122,6 +124,7 @@ public class QrFormatServiceImpl implements QrFormatService {
 	 * 码格式启用
 	 */
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public void enableQrFormat(EnableQrFormatReq req) {
 		List<Long> idList = req.getIds();
 		for (Long id : idList) {
@@ -142,7 +145,8 @@ public class QrFormatServiceImpl implements QrFormatService {
 	 * 码格式禁用
 	 */
 	@Override
-	public void disableFormat(DisableQrFormatReq req) {
+	@Transactional(rollbackFor = Exception.class)
+	public void disableQrFormat(DisableQrFormatReq req) {
 		List<Long> idList = req.getIds();
 		for (Long id : idList) {
 			QrFormat qrFormat = qrFormatMapper.selectById(id);
@@ -161,6 +165,7 @@ public class QrFormatServiceImpl implements QrFormatService {
 	 * 删除码格式
 	 */
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public void deleteQrFormat(DeleteQrFormatReq req) {
 		QrFormat qrFormat = qrFormatMapper.selectById(req.getId());
 		AssertUtil.isNull(qrFormat, "码格式不存在");

+ 15 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrRepertoryColumnServiceImpl.java

@@ -0,0 +1,15 @@
+package com.abi.qms.platform.service.impl;
+
+import com.abi.qms.platform.service.QrRepertoryColumnService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 码库的列信息 Service业务层处理
+ *
+ * @author WeiganCai
+ * @date 2021-04-25
+ */
+@Service
+public class QrRepertoryColumnServiceImpl implements QrRepertoryColumnService {
+
+}

+ 88 - 14
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrRepertoryServiceImpl.java

@@ -3,6 +3,8 @@ package com.abi.qms.platform.service.impl;
 import com.abi.qms.platform.dao.entity.QrRepertory;
 import com.abi.qms.platform.dao.enums.QrRepertoryStatusEnum;
 import com.abi.qms.platform.dao.enums.QrRepertoryTypeEnum;
+import com.abi.qms.platform.dao.mapper.QrFormatMapper;
+import com.abi.qms.platform.dao.mapper.QrRepertoryColumnMapper;
 import com.abi.qms.platform.dao.mapper.QrRepertoryMapper;
 import com.abi.qms.platform.dao.vo.result.QrRepertoryVO;
 import com.abi.qms.platform.dto.req.*;
@@ -19,8 +21,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 /**
  * 码库 Service业务层处理
@@ -34,26 +39,59 @@ public class QrRepertoryServiceImpl  implements QrRepertoryService {
 	@Autowired
 	private QrRepertoryMapper qrRepertoryMapper;
 
+	@Autowired
+	private QrRepertoryColumnMapper qrRepertoryColumnMapper;
+
+	@Autowired
+	private QrFormatMapper qrFormatMapper;
+
 	/**
 	 * 保存码库
 	 */
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void saveQrRepertory(SaveQrRepertoryReq req) {
-		// 同部门下码库名称不可重复
+		Long qrRepertoryId = req.getId();
+		// 修改码库时的条件限制
+		QrRepertory qrRepertory;
+		if (qrRepertoryId != null) {
+			qrRepertory = qrRepertoryMapper.selectById(qrRepertoryId);
+			AssertUtil.isNull(qrRepertory, "码库不存在");
+			// 只有待生成、待导入状态下才可编辑
+			Integer qrRepertoryStatus = qrRepertory.getStatus();
+			if (!QrRepertoryStatusEnum.WAIT_GENERATE.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.WAIT_IMPORT.is(qrRepertoryStatus)) {
+				throw new BusinessException("码库不可编辑");
+			}
+		}
+
+		// 码库名称不可重复
 		QueryWrapper<QrRepertory> qrRepertoryQw = new QueryWrapper<>();
-		qrRepertoryQw.eq("dept_id", req.getDeptId());
 		qrRepertoryQw.eq("name", req.getName());
-		if (req.getId() != null) {
-			qrRepertoryQw.ne("id", req.getId());
+		qrRepertoryQw.eq("is_delete", 0);
+		if (qrRepertoryId != null) {
+			qrRepertoryQw.ne("id", qrRepertoryId);
 		}
 		Integer count = qrRepertoryMapper.selectCount(qrRepertoryQw);
 		if (!count.equals(0)) {
 			throw new BusinessException("码库名称已存在");
 		}
 
+		// 验证:1.码库类型为系统生成时,码格式必填 2.同一个码库内的列别名不可重复
+		List<SaveQrRepertoryColumnReq> qrRepertoryColumnList = req.getQrRepertoryColumnList();
+		Set<String> notRepeat = new HashSet<>();
+		SaveQrRepertoryColumnReq qrRepertoryColumn;
+		for (int i = 0; i < qrRepertoryColumnList.size(); i++) {
+			qrRepertoryColumn = qrRepertoryColumnList.get(i);
+			if (QrRepertoryTypeEnum.SYSTEM_GENERATE.is(req.getType()) && qrRepertoryColumn.getQrFormatId() == null) {
+				throw new BusinessException("码格式为空");
+			}
+			if (!notRepeat.add(qrRepertoryColumn.getAlias())) {
+				throw new BusinessException("列名称已存在");
+			}
+		}
+
 		// copy属性值
-		QrRepertory qrRepertory = PojoConverterUtils.copy(req, QrRepertory.class);
+		qrRepertory = PojoConverterUtils.copy(req, QrRepertory.class);
 		Integer qrRepertoryType = qrRepertory.getType();
 		// 文本导入类型设置状态为待导入,其他两种类型设置状态为待生成
 		if (QrRepertoryTypeEnum.FILE_IMPORT.is(qrRepertoryType)) {
@@ -65,13 +103,19 @@ public class QrRepertoryServiceImpl  implements QrRepertoryService {
 		// 新增or修改
 		Long userId = UserUtil.getUser().getId();
 		qrRepertory.setUpdateBy(userId);
-		if (req.getId() != null) {
+		if (qrRepertoryId != null) {
 			qrRepertoryMapper.updateById(qrRepertory);
+			// 逻辑删除码库的列
+			qrRepertoryColumnMapper.deleteByQrRepertoryId(qrRepertoryId);
 		} else {
 			qrRepertory.setCreateBy(userId);
 			qrRepertoryMapper.insert(qrRepertory);
 		}
 
+		// 批量插入码库的列
+		BatchInsertQrRepertoryColumnReq batchInsertQrRepertoryColumnReq = new BatchInsertQrRepertoryColumnReq(qrRepertory, qrRepertoryColumnList);
+		qrRepertoryColumnMapper.batchInsert(batchInsertQrRepertoryColumnReq);
+
 	}
 
 	/**
@@ -98,24 +142,44 @@ public class QrRepertoryServiceImpl  implements QrRepertoryService {
 	@Override
 	public GetQrRepertoryDetailRes getQrRepertoryDetail(GetQrRepertoryDetailReq req) {
 		// 查询码库对象
-		QrRepertory qrRepertory = qrRepertoryMapper.selectById(req.getId());
-		AssertUtil.isNull(qrRepertory, "码库不存在");
+		QrRepertoryVO qrRepertoryVO = qrRepertoryMapper.selectQrRepertoryDetailById(req.getId());
+		AssertUtil.isNull(qrRepertoryVO, "码库不存在");
 
-		return PojoConverterUtils.copy(qrRepertory, GetQrRepertoryDetailRes.class);
+		return PojoConverterUtils.copy(qrRepertoryVO, GetQrRepertoryDetailRes.class);
 	}
 
 	/**
-	 * 码库启用
+	 * 码库启用:针对的是系统生成和FTP接入,文本导入不存在启用的概念
 	 */
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public void enableQrRepertory(EnableQrRepertoryReq req) {
 		List<Long> idList = req.getIds();
 		for (Long id : idList) {
 			QrRepertory qrRepertory = qrRepertoryMapper.selectById(id);
 			AssertUtil.isNull(qrRepertory, "码库不存在");
 
-			// TODO
-			QrRepertory update = new QrRepertory().setId(id).setStatus(null);
+			// 启用针对的是系统生成和FTP接入类型的码库
+			Integer qrRepertoryType = qrRepertory.getType();
+			if (QrRepertoryTypeEnum.FILE_IMPORT.is(qrRepertoryType)) {
+				continue;
+			}
+
+			// 在状态为待生成、停用时可启用
+			Integer qrRepertoryStatus = qrRepertory.getStatus();
+			if (!QrRepertoryStatusEnum.WAIT_GENERATE.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.DISABLE.is(qrRepertoryStatus)) {
+				continue;
+			}
+
+			// 启用时需判断其关联的码格式是否停用,若是,则启用失败
+			if (QrRepertoryTypeEnum.SYSTEM_GENERATE.is(qrRepertoryType)) {
+				List<String> disabledQrFormatList = qrFormatMapper.selectDisabledQrFormat(id);
+				if (!CollectionUtils.isEmpty(disabledQrFormatList)) {
+					throw new BusinessException("该码库关联的码格式" + disabledQrFormatList + "已停用,码库启用失败");
+				}
+			}
+
+			QrRepertory update = new QrRepertory().setId(id).setStatus(QrRepertoryStatusEnum.GENERATING.getCode());
 			qrRepertoryMapper.updateById(update);
 		}
 	}
@@ -124,13 +188,19 @@ public class QrRepertoryServiceImpl  implements QrRepertoryService {
 	 * 码库禁用
 	 */
 	@Override
-	public void disableFormat(DisableQrRepertoryReq req) {
+	@Transactional(rollbackFor = Exception.class)
+	public void disableQrRepertory(DisableQrRepertoryReq req) {
 		List<Long> idList = req.getIds();
 		for (Long id : idList) {
 			QrRepertory qrRepertory = qrRepertoryMapper.selectById(id);
 			AssertUtil.isNull(qrRepertory, "码库不存在");
 
-			// TODO
+			// 在状态为已导入、自动生成时可停用
+			Integer qrRepertoryStatus = qrRepertory.getStatus();
+			if (!QrRepertoryStatusEnum.GENERATING.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.IMPORTED.is(qrRepertoryStatus)) {
+				continue;
+			}
+
 			QrRepertory update = new QrRepertory().setId(id).setStatus(QrRepertoryStatusEnum.DISABLE.getCode());
 			qrRepertoryMapper.updateById(update);
 		}
@@ -140,6 +210,7 @@ public class QrRepertoryServiceImpl  implements QrRepertoryService {
 	 * 删除码库
 	 */
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public void deleteQrRepertory(DeleteQrRepertoryReq req) {
 		QrRepertory qrRepertory = qrRepertoryMapper.selectById(req.getId());
 		AssertUtil.isNull(qrRepertory, "码库不存在");
@@ -152,5 +223,8 @@ public class QrRepertoryServiceImpl  implements QrRepertoryService {
 		// 逻辑删除
 		QrRepertory update = new QrRepertory().setId(req.getId()).setIsDelete(1);
 		qrRepertoryMapper.updateById(update);
+
+		// 逻辑删除码库的列
+		qrRepertoryColumnMapper.deleteByQrRepertoryId(req.getId());
 	}
 }

+ 11 - 0
abi-cloud-qr-platform-server/src/main/resources/dao/mapper/QrFormatMapper.xml

@@ -48,5 +48,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
+    <select id="selectDisabledQrFormat" resultType="java.lang.String">
+        SELECT
+            name
+        FROM
+            qr_format
+        WHERE
+            id IN ( SELECT DISTINCT qr_format_id FROM qr_repertory_column WHERE qr_repertory_id = 10 AND is_delete = 0 )
+            AND is_delete = 0
+            AND use_status = 2
+    </select>
+
 
 </mapper>

+ 35 - 0
abi-cloud-qr-platform-server/src/main/resources/dao/mapper/QrRepertoryColumnMapper.xml

@@ -0,0 +1,35 @@
+<?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.abi.qms.platform.dao.mapper.QrRepertoryColumnMapper">
+
+    <resultMap type="com.abi.qms.platform.dao.entity.QrRepertoryColumn" id="QrRepertoryColumnResult">
+        <result property="id" column="id"/>
+        <result property="qrRepertoryId" column="qr_repertory_id"/>
+        <result property="qrFormatId" column="qr_format_id"/>
+        <result property="cloneColumn" column="clone_column"/>
+        <result property="sortNumber" column="sort_number"/>
+        <result property="alias" column="alias"/>
+        <result property="urlType" column="url_type"/>
+        <result property="remark" column="remark"/>
+        <result property="createTime" column="create_time"/>
+        <result property="createBy" column="create_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="isDelete" column="is_delete"/>
+    </resultMap>
+
+    <insert id="batchInsert">
+        INSERT INTO qr_repertory_column (qr_repertory_id, qr_format_id, clone_column, sort_number, alias, url_type, remark, create_by, update_by) VALUES
+        <foreach item="item" index="index" collection="qrRepertoryColumnList" separator=",">
+            ( #{qrRepertoryId}, #{item.qrFormatId}, #{item.cloneColumn}, #{item.sortNumber}, #{item.alias}, #{item.urlType}, #{item.remark}, #{createBy}, #{updateBy} )
+        </foreach>
+    </insert>
+
+    <update id="deleteByQrRepertoryId">
+        UPDATE qr_repertory_column SET is_delete = 1
+    </update>
+
+
+</mapper>

+ 25 - 1
abi-cloud-qr-platform-server/src/main/resources/dao/mapper/QrRepertoryMapper.xml

@@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.abi.qms.platform.dao.mapper.QrRepertoryMapper">
 
-    <resultMap type="com.abi.qms.platform.dao.entity.QrRepertory" id="QrRepertoryResult">
+    <resultMap id="QrRepertoryResult" type="com.abi.qms.platform.dao.entity.QrRepertory">
         <result property="id" column="id"/>
         <result property="deptId" column="dept_id"/>
         <result property="name" column="name"/>
@@ -20,6 +20,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="isDelete" column="is_delete"/>
     </resultMap>
 
+    <resultMap id="QrRepertoryColumnResult" type="com.abi.qms.platform.dao.entity.QrRepertoryColumn">
+        <result property="id" column="qr_repertory_column_id"/>
+        <result property="qrRepertoryId" column="qr_repertory_id"/>
+        <result property="qrFormatId" column="qr_format_id"/>
+        <result property="cloneColumn" column="clone_column"/>
+        <result property="sortNumber" column="sort_number"/>
+        <result property="alias" column="alias"/>
+        <result property="urlType" column="url_type"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+    <resultMap id="QrRepertoryQrRepertoryColumnResult" type="com.abi.qms.platform.dao.vo.result.QrRepertoryVO" extends="QrRepertoryResult">
+        <collection property="qrRepertoryColumnList" notNullColumn="id" javaType="java.util.List" resultMap="QrRepertoryColumnResult" />
+    </resultMap>
+
     <select id="listQrRepertory" resultType="com.abi.qms.platform.dao.vo.result.QrRepertoryVO">
         SELECT
             qr.id, bd.dept_name, qr.name, qr.type, qr.have_serial,
@@ -55,5 +70,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     </select>
 
+    <select id="selectQrRepertoryDetailById" resultMap="QrRepertoryQrRepertoryColumnResult">
+        SELECT
+            qr.id, qr.dept_id, qr.name, qr.type, qr.have_serial, qr.status, qr.data_composition, qr.clone_rule, qr.create_time, qr.create_by, qr.update_time, qr.update_by,
+            qrc.id AS qr_repertory_column_id, qrc.qr_repertory_id, qrc.qr_format_id, qrc.clone_column, qrc.sort_number, qrc.alias, qrc.url_type, qrc.remark
+        FROM qr_repertory qr
+        LEFT JOIN qr_repertory_column qrc ON qrc.qr_repertory_id = qr.id
+        WHERE qr.id = #{id} AND qrc.is_delete = 0
+    </select>
+
 
 </mapper>