瀏覽代碼

Merge branch 'feature/1.0.0' of github.com:ab-inbev-apac/abi-cloud-qr-platform into feature/1.0.0

tanzhongran 3 年之前
父節點
當前提交
d43598b94d

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

@@ -1,7 +1,13 @@
 package com.abi.qms.platform.controller.console;
 
-import com.abi.qms.platform.dto.req.*;
+import com.abi.qms.platform.dto.req.DeleteQrFormatReq;
+import com.abi.qms.platform.dto.req.DisableQrFormatReq;
+import com.abi.qms.platform.dto.req.EnableQrFormatReq;
+import com.abi.qms.platform.dto.req.GetQrFormatDetailReq;
+import com.abi.qms.platform.dto.req.ListQrFormatReq;
+import com.abi.qms.platform.dto.req.SaveQrFormatReq;
 import com.abi.qms.platform.dto.res.GetQrFormatDetailRes;
+import com.abi.qms.platform.dto.res.ListFormatSelectRes;
 import com.abi.qms.platform.dto.res.ListQrFormatRes;
 import com.abi.qms.platform.service.QrFormatService;
 import com.abi.task.common.api.base.BaseResponse;
@@ -10,11 +16,15 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * 码格式 Controller
- * 
+ *
  * @author WeiganCai
  * @date 2021-04-19
  */
@@ -68,4 +78,12 @@ public class QrFormatController {
         return BaseResponse.create();
     }
 
+    @ApiOperation("码格式下拉列表")
+    @GetMapping("/listFormatSelect")
+    public BaseResponse<ListFormatSelectRes> listFormatSelect() {
+
+        ListFormatSelectRes res = qrFormatService.listFormatSelect();
+        return BaseResponse.create(res);
+    }
+
 }

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

@@ -29,4 +29,7 @@ public class QrInnerData implements Serializable {
 	/** 排序号 */
 	private Integer sortNumber;
 
+	/** 已生成码包位置 */
+	private Long codeIndex;
+
 }

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

@@ -28,9 +28,6 @@ public class QrRepertoryColumn {
     @ApiModelProperty("码格式id")
     private Long qrFormatId;
 
-    @ApiModelProperty("克隆列 -1:未克隆 >=0:克隆了哪列,下标从0开始")
-    private Integer cloneColumn;
-
     @ApiModelProperty("排序号")
     private Integer sortNumber;
 

+ 5 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/tablestore/entity/QrCode.java

@@ -46,4 +46,9 @@ public class QrCode implements TableStoreEntity, Serializable {
      * 创建时间
      */
     private LocalDateTime createTime;
+
+    /**
+     * 已生成码包位置
+     */
+    private Long codeIndex;
 }

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

@@ -30,9 +30,6 @@ public class QrRepertoryColumnVO {
     @ApiModelProperty("码格式")
     private QrFormatVO qrFormatVO;
 
-    @ApiModelProperty("克隆列 -1:未克隆 >=0:克隆了哪列,下标从0开始")
-    private Integer cloneColumn;
-
     @ApiModelProperty("排序号")
     private Integer sortNumber;
 

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

@@ -19,30 +19,23 @@ import java.io.Serializable;
 @ApiModel
 public class SaveQrRepertoryColumnReq implements Serializable {
 
-	@ApiModelProperty("码格式id")
-	private Long qrFormatId;
+    @ApiModelProperty("码格式id")
+    private Long qrFormatId;
 
-	@ApiModelProperty("克隆列 -1:未克隆 >=0:克隆了哪列,下标从0开始")
-	private Integer cloneColumn;
+    @ApiModelProperty("排序号")
+    private Integer sortNumber;
 
-	@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 = "列别名为空")
-	@Pattern(regexp = "^[a-zA-Z-z0-9\\u4e00-\\u9fa5]{1,20}$", message = "列别名限制20字内的汉字or字母or数字")
-	@ApiModelProperty("别名")
-	private String alias;
+    @NotNull(message = "URL格式为空")
+    @ApiModelProperty("url格式类型 0-非URL 1-系统URL 2-部门URL")
+    private Integer urlType;
 
-	@NotNull(message = "拆分数量为空")
-	@ApiModelProperty("拆分数量")
-	private Integer splitNum;
-
-	@NotNull(message = "URL格式为空")
-	@ApiModelProperty("url格式类型 0-非URL 1-系统URL 2-部门URL")
-	private Integer urlType;
-
-	@Size(max = 50, message = "备注长度超过50")
-	@ApiModelProperty("备注")
-	private String remark;
+    @Size(max = 50, message = "备注长度超过50")
+    @ApiModelProperty("备注")
+    private String remark;
 
 }

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

@@ -28,9 +28,6 @@ public class GetQrRepertoryColumnDetailRes implements Serializable {
 	@ApiModelProperty("码格式名称")
 	private String qrFormatName;
 
-	@ApiModelProperty("克隆列 -1:未克隆 >=0:克隆了哪列,下标从0开始")
-	private Integer cloneColumn;
-
 	@ApiModelProperty("排序号")
 	private Integer sortNumber;
 

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

@@ -0,0 +1,42 @@
+package com.abi.qms.platform.dto.res;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author: fangxinjian
+ * @date: 2021/05/26 15:21
+ * @description: 码格式下拉列表出参
+ */
+@Data
+@ApiModel
+public class ListFormatSelectRes implements Serializable {
+
+    @ApiModelProperty("码格式下拉列表")
+    private List<FormatBean> formatBeanList;
+
+    /**
+     *
+     */
+    @Data
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ToString
+    @ApiModel(value = "ListFormatSelectRes_FormatBean")
+    public static class FormatBean implements Serializable {
+
+        @ApiModelProperty("码格式id")
+        private Long id;
+
+        @ApiModelProperty("码格式名称")
+        private String name;
+    }
+
+}

+ 55 - 28
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/infrastructure/mq/GenerateCodeConsumer.java

@@ -3,6 +3,7 @@ package com.abi.qms.platform.infrastructure.mq;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.file.FileWriter;
 import com.abi.base.foundation.util.JsonUtil;
+import com.abi.base.foundation.util.RedisClient;
 import com.abi.qms.platform.dao.entity.*;
 import com.abi.qms.platform.dao.enums.QrFormatUrlEnum;
 import com.abi.qms.platform.dao.enums.QrPackageGenerateStatusEnum;
@@ -105,6 +106,12 @@ public class GenerateCodeConsumer {
 	@Autowired
 	private QrBoxCodeFormatSplitMapper qrBoxCodeFormatSplitMapper;
 
+	@Autowired
+	private QrIndexMapper qrIndexMapper;
+
+	@Autowired
+	private RedisClient redisClient;
+
 	//生成码数据
 	final List<QrData> qrDataList = new LinkedList<>();
 
@@ -131,8 +138,35 @@ public class GenerateCodeConsumer {
         String str = JsonUtil.toBean(id, String.class);
 		QrPackageVO qrPackageVO = qrPackageMapper.selectQrPackageDetailById(Long.parseLong(str));
 		try {
+			//声明码对应的值
+			Long codeIndex = 0L;
+			Object code_qr_index = redisClient.get("code_qr_index");
+			if(ObjectUtils.isEmpty(code_qr_index)){
+				QueryWrapper<QrIndex>  indexQuery= new QueryWrapper<>();
+				indexQuery.orderByDesc("index_current").last("limit 1");
+				QrIndex qrIndex = qrIndexMapper.selectOne(indexQuery);
+				if(ObjectUtils.isEmpty(qrIndex)){
+					QrIndex index = new QrIndex();
+					index.setIndexCurrent(qrPackageVO.getQrNumber());
+					qrIndexMapper.insert(index);
+					redisClient.set("code_qr_index",qrPackageVO.getQrNumber());
+				} else {
+					codeIndex = qrIndex.getIndexCurrent();
+					QrIndex index = new QrIndex();
+					index.setIndexCurrent(qrIndex.getIndexCurrent()+qrPackageVO.getQrNumber());
+					qrIndexMapper.insert(index);
+					redisClient.set("code_qr_index",qrIndex.getIndexCurrent()+qrPackageVO.getQrNumber());
+				}
+			} else {
+				codeIndex = Long.parseLong(code_qr_index.toString());
+				long l = qrPackageVO.getQrNumber() + Long.parseLong(code_qr_index.toString());
+				QrIndex index = new QrIndex();
+				index.setIndexCurrent(l);
+				qrIndexMapper.insert(index);
+				redisClient.set("code_qr_index",l);
+			}
 			// 生成码
-			loopGenerateCode(qrPackageVO);
+			loopGenerateCode(qrPackageVO,codeIndex);
 		} catch (Exception e) {
 			log.error("生成码失败", e);
 			// 回滚
@@ -150,7 +184,7 @@ public class GenerateCodeConsumer {
 	/**
 	 * 生成码
 	 */
-	private void loopGenerateCode(QrPackageVO qrPackageVO) {
+	private void loopGenerateCode(QrPackageVO qrPackageVO,Long codeIndex) {
 		//刷新码包信息
 		QrPackage qrPackage = qrPackageMapper.selectById(qrPackageVO.getId());
 
@@ -209,7 +243,7 @@ public class GenerateCodeConsumer {
 			 * boxCodeFormat 箱码幅面
 			 */
 			// 循环生成码
-			List<QrData> codeList = loopGenerateCode(qrRepertoryColumnList, qrRepertoryId, urlMap, qrRepertorySerialNumberMap, qrNumber, batchNumber, repeatTimes,boxCodeFormat);
+			List<QrData> codeList = loopGenerateCode(qrRepertoryColumnList, qrRepertoryId, urlMap, qrRepertorySerialNumberMap, qrNumber, batchNumber, repeatTimes,boxCodeFormat,codeIndex);
 
             // 更新码库流水号
             if (!qrRepertorySerialNumberMap.isEmpty()) {
@@ -319,6 +353,8 @@ public class GenerateCodeConsumer {
 				qrCode.setUrl(qrInnerData.getUrl());
 				//创建时间
 				qrCode.setCreateTime(LocalDateTime.now());
+				//已生成码包位置
+				qrCode.setCodeIndex(qrInnerData.getCodeIndex());
 				codeSave.add(qrCode);
 			}
 		}
@@ -336,7 +372,8 @@ public class GenerateCodeConsumer {
      * repeatTimes 失败次数
 	 * formatNumber 幅面数量
      */
-	private List<QrData> loopGenerateCode(List<QrRepertoryColumnVO> qrRepertoryColumnList, Long qrRepertoryId, Map<Long, String> urlMap, Map<String, QrRepertorySerialNumber> qrRepertorySerialNumberMap, Long qrNumber, String batchNumber, int repeatTimes,QrBoxCodeFormat boxCodeFormat) {
+	private List<QrData> loopGenerateCode(List<QrRepertoryColumnVO> qrRepertoryColumnList, Long qrRepertoryId, Map<Long, String> urlMap, Map<String, QrRepertorySerialNumber> qrRepertorySerialNumberMap, Long qrNumber, String batchNumber, int repeatTimes,QrBoxCodeFormat boxCodeFormat,Long codeIndex ) {
+		codeIndex ++;
         LocalDateTime localDateTime = LocalDateTime.now();
 		while (true) {
 			// 计算还需生成的数量
@@ -384,37 +421,27 @@ public class GenerateCodeConsumer {
 							splitNum = qrBoxCodeFormatSplits.getSplitNum();
 						}
 
-						// 判断当前列是否为clone列
-						Integer cloneColumn = qrRepertoryColumn.getCloneColumn();
-						if (cloneColumn.compareTo(-1) == 0) {
-							// 非clone列,设置code和url
-							String code = buildUniqueCode(uniqueSet, qrRepertoryColumn, codeSb, paramMap, qrRepertorySerialNumberMap, 0);
-							String url = urlMap.get(qrRepertoryColumnId);
-							if (code == null) {
-								throw new RuntimeException("生成码失败,重复生成码次数超过" + REPEAT_BUILD_CODE_TIMES + "次");
-							}
-							//判断拆分数量是否为空
-							if( splitNum >0){
-								List<char[]> codeStr = a(code, splitNum);
-								for (char[] chars:codeStr) {
-									QrInnerData qrInnerData = new QrInnerData();
-									qrInnerData.setCode(String.valueOf(chars)).setUrl(url);
-									qrInnerData.setQrRepertoryColumnId(qrRepertoryColumnId).setSortNumber(qrRepertoryColumn.getSortNumber());
-									qrInnerDataList.add(qrInnerData);
-								}
-							} else {
+						// 非clone列,设置code和url
+						String code = buildUniqueCode(uniqueSet, qrRepertoryColumn, codeSb, paramMap, qrRepertorySerialNumberMap, 0);
+						String url = urlMap.get(qrRepertoryColumnId);
+						if (code == null) {
+							throw new RuntimeException("生成码失败,重复生成码次数超过" + REPEAT_BUILD_CODE_TIMES + "次");
+						}
+						//判断拆分数量是否为空
+						if( splitNum >0){
+							List<char[]> codeStr = a(code, splitNum);
+							for (char[] chars:codeStr) {
 								QrInnerData qrInnerData = new QrInnerData();
-								qrInnerData.setCode(code).setUrl(url);
+								qrInnerData.setCode(String.valueOf(chars)).setUrl(url);
 								qrInnerData.setQrRepertoryColumnId(qrRepertoryColumnId).setSortNumber(qrRepertoryColumn.getSortNumber());
+								qrInnerData.setCodeIndex(codeIndex);
 								qrInnerDataList.add(qrInnerData);
 							}
 						} else {
-							//鼎昌提供的clone列,暂时未知可用性
-							// clone列,设置相同的code和url
 							QrInnerData qrInnerData = new QrInnerData();
-							QrInnerData originalQrInnerData = qrInnerDataList.get( a * qrRepertoryColumnList.size() + cloneColumn );
-							qrInnerData.setCode(originalQrInnerData.getCode()).setUrl(originalQrInnerData.getUrl());
+							qrInnerData.setCode(code).setUrl(url);
 							qrInnerData.setQrRepertoryColumnId(qrRepertoryColumnId).setSortNumber(qrRepertoryColumn.getSortNumber());
+							qrInnerData.setCodeIndex(codeIndex);
 							qrInnerDataList.add(qrInnerData);
 						}
 					}

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

@@ -1,7 +1,13 @@
 package com.abi.qms.platform.service;
 
-import com.abi.qms.platform.dto.req.*;
+import com.abi.qms.platform.dto.req.DeleteQrFormatReq;
+import com.abi.qms.platform.dto.req.DisableQrFormatReq;
+import com.abi.qms.platform.dto.req.EnableQrFormatReq;
+import com.abi.qms.platform.dto.req.GetQrFormatDetailReq;
+import com.abi.qms.platform.dto.req.ListQrFormatReq;
+import com.abi.qms.platform.dto.req.SaveQrFormatReq;
 import com.abi.qms.platform.dto.res.GetQrFormatDetailRes;
+import com.abi.qms.platform.dto.res.ListFormatSelectRes;
 import com.abi.qms.platform.dto.res.ListQrFormatRes;
 
 /**
@@ -12,34 +18,40 @@ import com.abi.qms.platform.dto.res.ListQrFormatRes;
  */
 public interface QrFormatService {
 
-	/**
-	 * 保存码格式
-	 */
-	void saveQrFormat(SaveQrFormatReq saveQrFormatReq);
-
-	/**
-	 * 码格式查询分页
-	 */
-	ListQrFormatRes listQrFormat(ListQrFormatReq listQrFormatReq);
-
-	/**
-	 * 码格式查询详情
-	 */
-	GetQrFormatDetailRes getQrFormatDetail(GetQrFormatDetailReq getQrFormatDetailReq);
-
-	/**
-	 * 码格式启用
-	 */
-	void enableQrFormat(EnableQrFormatReq enableQrFormatReq);
-
-	/**
-	 * 码格式禁用
-	 */
-	void disableQrFormat(DisableQrFormatReq disableQrFormatReq);
-
-	/**
-	 * 删除码格式
-	 */
-	void deleteQrFormat(DeleteQrFormatReq deleteQrFormatReq);
-
+    /**
+     * 保存码格式
+     */
+    void saveQrFormat(SaveQrFormatReq saveQrFormatReq);
+
+    /**
+     * 码格式查询分页
+     */
+    ListQrFormatRes listQrFormat(ListQrFormatReq listQrFormatReq);
+
+    /**
+     * 码格式查询详情
+     */
+    GetQrFormatDetailRes getQrFormatDetail(GetQrFormatDetailReq getQrFormatDetailReq);
+
+    /**
+     * 码格式启用
+     */
+    void enableQrFormat(EnableQrFormatReq enableQrFormatReq);
+
+    /**
+     * 码格式禁用
+     */
+    void disableQrFormat(DisableQrFormatReq disableQrFormatReq);
+
+    /**
+     * 删除码格式
+     */
+    void deleteQrFormat(DeleteQrFormatReq deleteQrFormatReq);
+
+    /**
+     * 码格式下拉列表
+     *
+     * @return
+     */
+    ListFormatSelectRes listFormatSelect();
 }

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

@@ -3,6 +3,7 @@ package com.abi.qms.platform.service.impl;
 import com.abi.qms.platform.dao.entity.QrFormat;
 import com.abi.qms.platform.dao.entity.QrRepertoryColumn;
 import com.abi.qms.platform.dao.entity.QrVariable;
+import com.abi.qms.platform.dao.enums.QrFormatUniqueStatusEunm;
 import com.abi.qms.platform.dao.enums.QrFormatUseStatusEnum;
 import com.abi.qms.platform.dao.mapper.QrFormatMapper;
 import com.abi.qms.platform.dao.mapper.QrRepertoryColumnMapper;
@@ -16,6 +17,7 @@ import com.abi.qms.platform.dto.req.GetQrFormatDetailReq;
 import com.abi.qms.platform.dto.req.ListQrFormatReq;
 import com.abi.qms.platform.dto.req.SaveQrFormatReq;
 import com.abi.qms.platform.dto.res.GetQrFormatDetailRes;
+import com.abi.qms.platform.dto.res.ListFormatSelectRes;
 import com.abi.qms.platform.dto.res.ListQrFormatRes;
 import com.abi.qms.platform.infrastructure.task.VerifyUniqueTask;
 import com.abi.qms.platform.infrastructure.util.AssertUtil;
@@ -240,4 +242,19 @@ public class QrFormatServiceImpl implements QrFormatService {
         qrFormatMapper.updateById(update);
     }
 
+    @Override
+    public ListFormatSelectRes listFormatSelect() {
+
+        ListFormatSelectRes res = new ListFormatSelectRes();
+
+        QueryWrapper<QrFormat> qw = new QueryWrapper<>();
+        qw.eq("unique_status", QrFormatUniqueStatusEunm.VERIFY_FAIL.getCode());
+        qw.eq("is_delete", 0);
+        List<QrFormat> formatList = qrFormatMapper.selectList(qw);
+        List<ListFormatSelectRes.FormatBean> beanList = PojoConverterUtils.copyList(formatList, ListFormatSelectRes.FormatBean.class);
+
+        res.setFormatBeanList(beanList);
+        return res;
+    }
+
 }

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

@@ -8,7 +8,6 @@
         <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"/>
@@ -21,10 +20,10 @@
     </resultMap>
 
     <insert id="batchInsert">
-        INSERT INTO qr_repertory_column (qr_repertory_id, qr_format_id, clone_column, sort_number, alias, url_type,
+        INSERT INTO qr_repertory_column (qr_repertory_id, qr_format_id, 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},
+            ( #{qrRepertoryId}, #{item.qrFormatId}, #{item.sortNumber},
             #{item.alias}, #{item.urlType}, #{item.remark}, #{createBy}, #{updateBy} )
         </foreach>
     </insert>

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

@@ -25,7 +25,6 @@
         <result property="qrFormatName" column="qr_format_name"/>
         <result property="qrFormatVO.id" column="qr_format_id"/>
         <result property="qrFormatVO.codeVariableBuildClass" column="code_variable_build_class"/>
-        <result property="cloneColumn" column="clone_column"/>
         <result property="sortNumber" column="sort_number"/>
         <result property="alias" column="alias"/>
         <result property="urlType" column="url_type"/>
@@ -63,7 +62,6 @@
             id,
             qr_repertory_id,
             qr_format_id,
-            clone_column,
             sort_number,
             alias,
             url_type,
@@ -120,7 +118,6 @@
             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,