瀏覽代碼

Merge remote-tracking branch 'origin/feature/1.0.0' into feature/1.0.0

luyanwen-001 4 年之前
父節點
當前提交
db393a2863
共有 15 個文件被更改,包括 99 次插入100 次删除
  1. 15 5
      abi-cloud-qr-platform-common/src/main/java/com/abi/task/common/tablestore/TableStorePlusUtils.java
  2. 3 9
      abi-cloud-qr-platform-common/src/main/java/com/abi/task/common/tablestore/TableStoreUtils.java
  3. 35 33
      abi-cloud-qr-platform-common/src/main/java/com/abi/task/common/tablestore/common/TableStoreReq.java
  4. 8 1
      abi-cloud-qr-platform-common/src/main/java/com/abi/task/common/tablestore/common/TableStoreRes.java
  5. 1 3
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/enums/ActiveAuditStatusEnum.java
  6. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/ListActiveReq.java
  7. 4 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/ListActiveRes.java
  8. 0 10
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/ActiveServiceImpl.java
  9. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/FactoryServiceImpl.java
  10. 2 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrBoxCodeFormatImpl.java
  11. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrPackageServiceImpl.java
  12. 13 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/UserManagerServiceImpl.java
  13. 1 6
      abi-cloud-qr-platform-server/src/main/resources/dao/mapper/BaseActiveMapper.xml
  14. 14 6
      abi-cloud-qr-platform-server/src/test/java/com/abi/qms/platform/TableStorePlusTest.java
  15. 0 21
      abi-cloud-qr-platform-server/src/test/java/com/abi/qms/platform/TableStoreTest.java

+ 15 - 5
abi-cloud-qr-platform-common/src/main/java/com/abi/task/common/tablestore/TableStorePlusUtils.java

@@ -13,8 +13,10 @@ import com.alicloud.openservices.tablestore.model.Column;
 import com.alicloud.openservices.tablestore.model.ColumnValue;
 import com.alicloud.openservices.tablestore.model.PrimaryKeyColumn;
 import com.alicloud.openservices.tablestore.model.Row;
+import com.alicloud.openservices.tablestore.model.search.SearchResponse;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -185,7 +187,7 @@ public class TableStorePlusUtils {
      * @param <T>
      * @return
      */
-    public <T extends TableStoreEntity> List<T> selectList(TableStoreReq req) {
+    public <T extends TableStoreEntity> TableStoreRes<T> selectList(TableStoreReq<T> req) {
         if(req.getClz()==null){
             throw new BusinessException("印射对象为空");
         }
@@ -200,10 +202,18 @@ public class TableStorePlusUtils {
      * @param <T>
      * @return
      */
-    public <T extends TableStoreEntity> List<T> selectList(Class<T> clz, TableStoreReq req) {
-        TableStoreRes tableStoreRes = tableStoreUtils.listRows(req);
-        List<T> rows = toEntityList(clz, tableStoreRes.getRowList());
-        return rows;
+    public <T extends TableStoreEntity> TableStoreRes<T> selectList(Class<T> clz, TableStoreReq req) {
+        //拿到tablestore出参
+        SearchResponse resp = tableStoreUtils.listRows(req);
+        //构造我们的出参
+        TableStoreRes<T> res = new TableStoreRes<T>();
+        res.setRowList(resp.getRows());
+        res.setTotalCount(resp.getTotalCount());
+        //把rows转entity
+        List<T> entityList = toEntityList(clz, res.getRowList());
+        res.setEntityList(entityList);
+
+        return res;
     }
 
     /**

+ 3 - 9
abi-cloud-qr-platform-common/src/main/java/com/abi/task/common/tablestore/TableStoreUtils.java

@@ -46,9 +46,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.time.LocalDateTime;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * @author: fangxinjian
@@ -260,7 +258,7 @@ public class TableStoreUtils {
      * @param req
      * @return
      */
-    public TableStoreRes listRows(TableStoreReq req){
+    public SearchResponse listRows(TableStoreReq req){
         //0-校验入参合法性
         if(StringUtils.isBlank(req.getTableName())){
             throw new BusinessException("TableName为空");
@@ -324,11 +322,7 @@ public class TableStoreUtils {
         //table store的出参
         SearchResponse resp = client().search(searchRequest);
 
-        //我们自己的出参
-        TableStoreRes res = new TableStoreRes();
-        res.setTotalCount(resp.getTotalCount());
-        res.setRowList(resp.getRows());
-        return res;
+        return resp;
     }
 
 

+ 35 - 33
abi-cloud-qr-platform-common/src/main/java/com/abi/task/common/tablestore/common/TableStoreReq.java

@@ -5,6 +5,7 @@ import com.abi.task.common.utils.IStringUtil;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.ss.formula.functions.T;
+import org.checkerframework.checker.units.qual.K;
 
 import java.lang.reflect.Field;
 
@@ -14,81 +15,78 @@ import java.lang.reflect.Field;
  */
 @Data
 @Slf4j
-public class TableStoreReq {
+public class TableStoreReq<T extends TableStoreEntity> {
 
     /**
      * 表名
      */
-    String tableName;
+    private String tableName;
 
     /**
      * 索引名
      */
-    String indexName;
+    private String indexName;
 
     /**
      * 匹配的字段名
      */
-    String fieldName;
+    private String fieldName;
 
     /**
      * 匹配的字段值
      */
-    Object fieldValue;
+    private Object fieldValue;
 
     /**
      * 大于xxx
      */
-    Object greaterThan;
+    private Object greaterThan;
 
     /**
      * 小于xxx
      */
-    Object lessThan;
+    private Object lessThan;
 
     /**
      * 每页条数
      */
-    Integer pageCount = 10;
+    private Integer pageCount = 10;
 
     /**
      * 第几页
      */
-    Integer pageNo = 1;
+    private Integer pageNo = 1;
 
     /**
      * 需要返回总数量
      */
-    Boolean getTotalCount = false;
+    private Boolean getTotalCount = false;
 
     /**
      * 是否逆序
      */
-    Boolean sortByFieldDesc = false;
+    private Boolean sortByFieldDesc = false;
 
     /**
      * 印射对象类
      */
-    Class clz;
+    private Class clz;
 
     /**
-     * 无参构造函数
+     * 静态创建函数
      */
-    public TableStoreReq(){}
+    public static <T extends TableStoreEntity> TableStoreReq<T> build(Class<T> clzParam, String fieldName){
+        TableStoreReq<T> req = new TableStoreReq<T>();
 
-    /**
-     * 构造函数
-     */
-    public <T extends TableStoreEntity> TableStoreReq(Class<T> clz, String fieldName){
         Field field = null;
         try{
-            field = clz.getDeclaredField(fieldName);
+            field = clzParam.getDeclaredField(fieldName);
         }catch (Exception e){
             log.info("找不到字段",e);
         }
 
         //表名
-        TableStore tableStore = clz.getAnnotation(TableStore.class);
+        TableStore tableStore = clzParam.getAnnotation(TableStore.class);
         String tableName = tableStore.tableName();
         //索引
         TableStoreIndex tableStoreIndex = field.getAnnotation(TableStoreIndex.class);
@@ -96,10 +94,12 @@ public class TableStoreReq {
         //字段名转下划线
         fieldName = IStringUtil.camelToUnderline(fieldName);
 
-        this.tableName = tableName;
-        this.indexName = indexName;
-        this.fieldName = fieldName;
-        this.clz = clz;
+        req.tableName = tableName;
+        req.indexName = indexName;
+        req.fieldName = fieldName;
+        req.clz = clzParam;
+
+        return req;
     }
 
     /**
@@ -108,10 +108,12 @@ public class TableStoreReq {
      * @param indexName 索引名
      * @param fieldName 匹配的字段名
      */
-    public TableStoreReq(String tableName,String indexName,String fieldName){
-        this.tableName = tableName;
-        this.indexName = indexName;
-        this.fieldName = fieldName;
+    public static <T extends TableStoreEntity> TableStoreReq<T> build(String tableName,String indexName,String fieldName){
+        TableStoreReq<T> req = new TableStoreReq<T>();
+        req.tableName = tableName;
+        req.indexName = indexName;
+        req.fieldName = fieldName;
+        return req;
     }
 
     /**
@@ -120,7 +122,7 @@ public class TableStoreReq {
      * @param lessThan
      * @return
      */
-    public TableStoreReq range(Object greaterThan,Object lessThan){
+    public TableStoreReq<T> range(Object greaterThan,Object lessThan){
         this.setGreaterThan(greaterThan);
         this.setLessThan(lessThan);
         return this;
@@ -131,12 +133,12 @@ public class TableStoreReq {
      * @param fieldValue
      * @return
      */
-    public TableStoreReq equal(Object fieldValue){
+    public TableStoreReq<T> equal(Object fieldValue){
         this.setFieldValue(fieldValue);
         return this;
     }
 
-    public TableStoreReq page(Integer pageNo,Integer pageCount){
+    public TableStoreReq<T> page(Integer pageNo,Integer pageCount){
         this.pageNo = pageNo;
         this.pageCount = pageCount;
         return this;
@@ -146,7 +148,7 @@ public class TableStoreReq {
      * 是否逆序
      * @return
      */
-    public TableStoreReq isDesc(){
+    public TableStoreReq<T> isDesc(){
         this.setSortByFieldDesc(true);
         return this;
     }
@@ -155,7 +157,7 @@ public class TableStoreReq {
      * 是否需要总数
      * @return
      */
-    public TableStoreReq isNeedTotalCount(){
+    public TableStoreReq<T> isNeedTotalCount(){
         this.setGetTotalCount(true);
         return this;
     }

+ 8 - 1
abi-cloud-qr-platform-common/src/main/java/com/abi/task/common/tablestore/common/TableStoreRes.java

@@ -12,7 +12,7 @@ import java.util.List;
  */
 @Data
 @ToString
-public class TableStoreRes {
+public class TableStoreRes<T extends TableStoreEntity> {
 
     /**
      * 总行数
@@ -24,4 +24,11 @@ public class TableStoreRes {
      */
     private List<Row> rowList;
 
+    /**
+     * 对象列表
+     */
+    private List<T> entityList;
+
+
+
 }

+ 1 - 3
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/enums/ActiveAuditStatusEnum.java

@@ -21,9 +21,7 @@ public enum ActiveAuditStatusEnum {
     //活动审核状态 1-待审核 2-通过 9-驳回
     WAIT_REVIEW(1,"待审核"),
     REVIEW_PASS(2,"审核通过"),
-    ENABLE(3, "启用"),
-    REVIEW_REFUSE(9,"审核驳回"),
-    DISABLE(10, "停用");
+    REVIEW_REFUSE(9,"审核驳回");
 
 
     @EnumValue

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

@@ -20,6 +20,6 @@ public class ListActiveReq extends PageReq implements Serializable {
     @ApiModelProperty(value = "活动类型 1-utc 2-bof 3-品质信息")
     private Integer activeType;
 
-    @ApiModelProperty(value = "活动状态 1-待审核 2-通过 3-启用 9-驳回 10-停用")
+    @ApiModelProperty(value = "活动状态 1-待审核 2-通过 9-驳回")
     private Integer auditStatus;
 }

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

@@ -43,7 +43,7 @@ public class ListActiveRes extends PageResp implements Serializable {
         @ApiModelProperty(value = "活动类型 1-utc 2-bof 3-品质信息")
         private Integer activeType;
 
-        @ApiModelProperty(value = "活动状态 1-待审核 2-通过 3-启用 9-驳回 10-停用")
+        @ApiModelProperty(value = "活动状态 1-待审核 2-通过 9-驳回")
         private Integer auditStatus;
 
         @ApiModelProperty(value = "申请时间")
@@ -64,5 +64,8 @@ public class ListActiveRes extends PageResp implements Serializable {
         @ApiModelProperty(value = "活动域名")
         private String activeUrl;
 
+        @ApiModelProperty(value = "是否有效")
+        private Integer valid;
+
     }
 }

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

@@ -144,16 +144,6 @@ public class ActiveServiceImpl implements ActiveService {
         //分页查询
         IPage<BaseActive> iPage = baseActiveMapper.listActivePage(PageUtil.createPage(req), req);
         List<BaseActive> activeList = iPage.getRecords();
-        //活动状态作处理  1-待审核 2-通过 3-启用 9-驳回 10-停用
-        activeList.forEach(active -> {
-            if(ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())){
-                if(ValidEnum.VALID.is(active.getValid())){
-                    active.setAuditStatus(ActiveAuditStatusEnum.ENABLE.getCode());
-                }else{
-                    active.setAuditStatus(ActiveAuditStatusEnum.DISABLE.getCode());
-                }
-            }
-        });
         //封装出参
         ListActiveRes res = new ListActiveRes();
         //放入分页信息

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

@@ -300,7 +300,7 @@ public class FactoryServiceImpl implements FactoryService {
         ListPackageFactorySelectRes listPackageFactorySelectRes = new ListPackageFactorySelectRes();
         QueryWrapper<BaseFactory> param = new QueryWrapper<>();
         //数据权限隔离,如果登录账号是包材厂,只能看账号包材厂的数据。否则看全部
-        if (userUtil.getWholeUser().getFactoryId() != null) {
+        if (userUtil.getWholeUser().getFactoryId() != null && userUtil.getWholeUser().getFactoryType() != null && FactoryTypeEnum.COVER.is(userUtil.getWholeUser().getFactoryType()) ) {
             param.eq("id", userUtil.getWholeUser().getFactoryId());
             listPackageFactorySelectRes.setLoginType(LoginTypeEnum.PACKAGE.getCode());
         } else {

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

@@ -2,6 +2,7 @@ package com.abi.qms.platform.service.impl;
 
 import com.abi.qms.platform.dao.entity.QrBoxCodeFormat;
 import com.abi.qms.platform.dao.entity.QrBoxCodeFormatSplit;
+import com.abi.qms.platform.dao.enums.FactoryTypeEnum;
 import com.abi.qms.platform.dao.enums.StateEnum;
 import com.abi.qms.platform.dao.mapper.QrBoxCodeFormatMapper;
 import com.abi.qms.platform.dao.mapper.QrBoxCodeFormatSplitMapper;
@@ -114,7 +115,7 @@ public class QrBoxCodeFormatImpl implements QrBoxCodeFormatService {
     @Override
     public ListBoxCodeFormatRes listBoxCodeFormat(ListBoxCodeFormatReq req) {
         //数据权限隔离,如果登录账号是包材厂,只能看账号包材厂的数据。否则看全部
-        if (userUtil.getWholeUser().getFactoryId() != null) {
+        if (userUtil.getWholeUser().getFactoryId() != null && userUtil.getWholeUser().getFactoryType() != null && FactoryTypeEnum.COVER.is(userUtil.getWholeUser().getFactoryType()) ) {
             req.setFactoryId(userUtil.getWholeUser().getFactoryId());
         }
         //分页查询

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

@@ -340,7 +340,7 @@ public class QrPackageServiceImpl implements QrPackageService {
     @Override
     public ListQrPackageRes listQrPackage(ListQrPackageReq req) {
         //数据权限隔离,如果登录账号是包材厂,只能看账号包材厂的数据。否则看全部
-        if (userUtil.getWholeUser().getFactoryId() != null) {
+        if (userUtil.getWholeUser().getFactoryId() != null && userUtil.getWholeUser().getFactoryType() != null && FactoryTypeEnum.COVER.is(userUtil.getWholeUser().getFactoryType()) ) {
             req.setFactoryCoverId(userUtil.getWholeUser().getFactoryId());
         }
 

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

@@ -89,9 +89,11 @@ public class UserManagerServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo
             throw new BusinessException("非ABI用户必须选择供应商");
         }
         //查询供应商
+        Integer factoryType = null;
         if(req.getFactoryId()!=null){
             BaseFactory factory = baseFactoryMapper.selectById(req.getFactoryId());
             AssertUtil.isNull(factory,"供应商不存在");
+            factoryType = factory.getFactoryType();
         }
 
         //操作人
@@ -105,6 +107,8 @@ public class UserManagerServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo
         userInfo.setPassword(req.getPassword());
         userInfo.setIsAbi(req.getIsAbi());
         userInfo.setFactoryId(req.getFactoryId());
+        //添加用户供应商类型的标志
+        userInfo.setFactoryType(factoryType);
         userInfo.setRoleCode(req.getRoleCode());
         userInfo.setPhone(req.getPhone());
         userInfoMapper.insert(userInfo);
@@ -143,7 +147,15 @@ public class UserManagerServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo
         //1-修改主表
         userInfo.setEmail(req.getEmail());
         userInfo.setPhone(req.getPhone());
-        userInfo.setFactoryId(req.getFactoryId());
+        //校验供应商
+        if(Objects.nonNull(req.getFactoryId())) {
+            if(!userInfo.getFactoryId().equals(req.getFactoryId())) {
+                BaseFactory factory = baseFactoryMapper.selectById(req.getFactoryId());
+                AssertUtil.isNull(factory,"供应商不存在");
+                userInfo.setFactoryId(req.getFactoryId());
+                userInfo.setFactoryType(factory.getFactoryType());
+            }
+        }
         userInfo.setRoleCode(req.getRoleCode());
         userInfoMapper.updateById(userInfo);
 

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

@@ -44,12 +44,7 @@
                 AND active_type = #{param.activeType}
             </if>
             <if test="param.auditStatus != null ">
-                <if test="param.auditStatus == 1 or param.auditStatus == 2 or param.auditStatus == 9">
-                    AND audit_status = #{param.auditStatus}
-                </if>
-                <if test="param.auditStatus == 3 or param.auditStatus == 10">
-                    AND audit_status = 2 and valid = #{param.valid}
-                </if>
+                AND audit_status = #{param.auditStatus}
             </if>
         </where>
         order by apply_time

+ 14 - 6
abi-cloud-qr-platform-server/src/test/java/com/abi/qms/platform/TableStorePlusTest.java

@@ -53,13 +53,15 @@ public class TableStorePlusTest {
     //按索引范围匹配
     @Test
     public void queryRowsRange(){
-        //构造入参
-        TableStoreReq req = new TableStoreReq(QrCode.class,"codeIndex")
+        TableStoreReq<QrCode> req = TableStoreReq.build(QrCode.class,"codeIndex")
                 .range(1,100)
                 .page(1,15)
                 .isDesc();
         //调用查询
-        List<QrCode> qrCodeList = tableStorePlusUtils.selectList(req);
+        TableStoreRes<QrCode> res = tableStorePlusUtils.selectList(req);
+
+        List<QrCode> qrCodeList = res.getEntityList();
+
         //打印
         for(QrCode qrCode:qrCodeList){
             log.info(qrCode.toString());
@@ -69,15 +71,21 @@ public class TableStorePlusTest {
     //按索引精确匹配
     @Test
     public void queryRowsEqual(){
-        TableStoreReq req = new TableStoreReq(QrCode.class,"packageId")
+        TableStoreReq<QrCode> req = TableStoreReq.build(QrCode.class,"packageId")
                 .equal("1")
-                .page(1,3);
+                .page(1,3)
+                .isNeedTotalCount();
+
+        TableStoreRes<QrCode> res = tableStorePlusUtils.selectList(req);
+
+        List<QrCode> qrCodeList = res.getEntityList();
 
-        List<QrCode> qrCodeList = tableStorePlusUtils.selectList(req);
         //打印
         for(QrCode qrCode:qrCodeList){
             log.info(qrCode.toString());
         }
+        log.info("total count----------->");
+        log.info(String.valueOf(res.getTotalCount()));
     }
 
 

+ 0 - 21
abi-cloud-qr-platform-server/src/test/java/com/abi/qms/platform/TableStoreTest.java

@@ -97,26 +97,5 @@ public class TableStoreTest {
         tableStoreUtils.deleteRow(PRIMARYKEYNAME,"00002",TABLENAME);
     }
 
-    //按索引范围匹配
-    @Test
-    public void queryRowsRange(){
-        TableStoreReq req = new TableStoreReq("qr_code","index_code_index","code_index")
-                .range(1,9)
-                .isDesc();
-
-        TableStoreRes tableStoreRes = tableStoreUtils.listRows(req);
-        log.info(tableStoreRes.toString());
-    }
-
-    //按索引精确匹配
-    @Test
-    public void queryRowsEqual(){
-        TableStoreReq req = new TableStoreReq("qr_code","index_code_index","code_index")
-                .equal("1")
-                .isNeedTotalCount();
-
-        TableStoreRes tableStoreRes = tableStoreUtils.listRows(req);
-        log.info(tableStoreRes.toString());
-    }
 
 }