Browse Source

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

tanzhongran 3 years ago
parent
commit
1478a577de

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

@@ -3,7 +3,6 @@ package com.abi.qms.platform.dao.vo.result;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 import java.io.Serializable;

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

@@ -25,7 +25,6 @@ public class UpdatePhoneEmailWxReq implements Serializable {
     private String phone;
 
     @NotEmpty(message = "邮箱为空")
-    @Email(message = "邮件格式不正确,请重新输入")
     @ApiModelProperty(value = "邮箱")
     private String email;
 

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

@@ -8,19 +8,9 @@ import com.abi.qms.platform.dao.enums.InvalidEnum;
 import com.abi.qms.platform.dao.mapper.BaseFactoryMapper;
 import com.abi.qms.platform.dao.mapper.QrBoxMappingMapper;
 import com.abi.qms.platform.dao.tablestore.entity.QrCode;
-import com.abi.qms.platform.dao.vo.result.ActivateDetailVo;
-import com.abi.qms.platform.dao.vo.result.ActivationRecordVO;
-import com.abi.qms.platform.dao.vo.result.PrintingDetailVO;
-import com.abi.qms.platform.dao.vo.result.QrBoxMappingVO;
-import com.abi.qms.platform.dao.vo.result.QueryWxQrBoxMappingDetailsVO;
+import com.abi.qms.platform.dao.vo.result.*;
 import com.abi.qms.platform.dto.req.*;
-import com.abi.qms.platform.dto.res.ActivateDetailRes;
-import com.abi.qms.platform.dto.res.ActivationRecordRes;
-import com.abi.qms.platform.dto.res.ListQrBoxCodeMappingRes;
-import com.abi.qms.platform.dto.res.PrintingDetailRes;
-import com.abi.qms.platform.dto.res.QrBoxCodeUploadRes;
-import com.abi.qms.platform.dto.res.QueryWxQrBoxMappingDetailsWxRes;
-import com.abi.qms.platform.dto.res.UploadFileRes;
+import com.abi.qms.platform.dto.res.*;
 import com.abi.qms.platform.infrastructure.util.AssertUtil;
 import com.abi.qms.platform.infrastructure.util.PageUtil;
 import com.abi.qms.platform.infrastructure.util.UserUtil;
@@ -48,7 +38,6 @@ import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -154,11 +143,11 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
                 doUpload(file, packageId);
                 resultMap.put(o.getKey(), new UploadFileRes(SUCCESS, "上传箱码合一文件成功!"));
             } catch (BusinessException e) {
+                log.warn("文件上传失败",e);
                 throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "文件上传失败");
-//                resultMap.put(o.getKey(), new UploadFileRes(FAIL, e.getMessage()));
             } catch (Exception e) {
+                log.warn("文件上传异常",e);
                 throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "文件上传异常");
-//                resultMap.put(o.getKey(), new UploadFileRes(FAIL, e.getMessage()));
             }
         });
 

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

@@ -105,9 +105,9 @@ public class ReportServiceImpl implements ReportService {
         List<ListFactoryCodeReportRes.FactoryCodeReportResBean> reportFactoryRes = PojoConverterUtils.copyList(listFactoryCodeTotalReportVOS, ListFactoryCodeReportRes.FactoryCodeReportResBean.class);
         reportFactoryRes.forEach(reportFactoryRe ->{
             //需求未定,暂时不做处理
-            reportFactoryRe.setQrDownloadNumber(0l);
-            reportFactoryRe.setQrNumber(0l);
-            reportFactoryRe.setDownloadNumber(0l);
+            reportFactoryRe.setQrDownloadNumber(0L);
+            reportFactoryRe.setQrNumber(0L);
+            reportFactoryRe.setDownloadNumber(0L);
         });
         res.setFactoryCodeResReportList(reportFactoryRes);
         return res;
@@ -127,18 +127,29 @@ public class ReportServiceImpl implements ReportService {
         QueryWxFactoryRes res = new QueryWxFactoryRes();
         if (isMainAccount.equals(0)) {
             //子账号报表
+            //返回数据初始化(4个月份)
+            List<QueryWxFactoryVO> queryWxFactorySumSummary = new ArrayList<QueryWxFactoryVO>();
+            getMonthFactorySumSummaryInit(3,queryWxFactorySumSummary);
             //获取现在时间 获取前三个月的时间
             //总量=下单量
             List<QueryWxFactoryVO> queryWxFactorySumNumber = reportServiceMapper.queryWxFactorySumNumber(queryWxFactoryReq,getMonth());
-            AssertUtil.isNull(queryWxFactorySumNumber,"查询为空!");
+            Map<String, Long> sumNumberMap = queryWxFactorySumNumber.stream().collect(Collectors.toMap(QueryWxFactoryVO::getMonth, QueryWxFactoryVO::getTotal));
             //激活量
             List<QueryWxFactoryVO> queryWxFactoryActivationNumber = reportServiceMapper.queryWxFactoryActivationNumber(queryWxFactoryReq,getMonth());
             Map<String, Long> activationNumberMap = queryWxFactoryActivationNumber.stream().collect(Collectors.toMap(QueryWxFactoryVO::getMonth, QueryWxFactoryVO::getActivation));
-            queryWxFactorySumNumber.forEach(factorySumNumber->{
-                Long aLong = (null == activationNumberMap.get(factorySumNumber.getMonth()) ? 0L : activationNumberMap.get(factorySumNumber.getMonth()));
-                factorySumNumber.setActivation(aLong);
+            //信息汇总
+            queryWxFactorySumSummary.forEach(factorySumNumber->{
+                //存在总量
+                if(null != sumNumberMap.get(factorySumNumber.getMonth())){
+                    factorySumNumber.setTotal(sumNumberMap.get(factorySumNumber.getMonth()));
+                }
+                //存在下载量
+                if(null != activationNumberMap.get(factorySumNumber.getMonth())){
+                    factorySumNumber.setActivation(activationNumberMap.get(factorySumNumber.getMonth()));
+                }
+
             });
-            List<QueryWxFactoryRes.QueryWxFactoryBean> queryWxFactoryBeans = PojoConverterUtils.copyList(queryWxFactorySumNumber, QueryWxFactoryRes.QueryWxFactoryBean.class);
+            List<QueryWxFactoryRes.QueryWxFactoryBean> queryWxFactoryBeans = PojoConverterUtils.copyList(queryWxFactorySumSummary, QueryWxFactoryRes.QueryWxFactoryBean.class);
             queryWxFactoryBeans.forEach(beans->{
                 beans.setInStock(beans.getTotal() - beans.getActivation());
             });
@@ -209,12 +220,14 @@ public class ReportServiceImpl implements ReportService {
         //本周
         if (timeType == 1){
             int day_of_week = calStart.get(Calendar.DAY_OF_WEEK) - 1;
-            if (day_of_week == 0)
+            if (day_of_week == 0){
                 day_of_week = 7;
+            }
             calStart.add(Calendar.DATE, -day_of_week + 1);
             day_of_week = calEnd.get(Calendar.DAY_OF_WEEK) - 1;
-            if (day_of_week == 0)
+            if (day_of_week == 0) {
                 day_of_week = 7;
+            }
             calEnd.add(Calendar.DATE, -day_of_week + 7);
         }
 
@@ -402,7 +415,7 @@ public class ReportServiceImpl implements ReportService {
      * @date 2021/6/10 17:03
      * @return java.time.LocalDateTime
      */
-    private LocalDateTime getMonth(){
+    private static LocalDateTime getMonth(){
         Calendar calStart = Calendar.getInstance();
         calStart.add(Calendar.MONTH, -3);//上一月
         calStart.set(Calendar.DAY_OF_MONTH, 1);
@@ -414,4 +427,25 @@ public class ReportServiceImpl implements ReportService {
         ZoneId zoneId = ZoneId.systemDefault();
         return instant.atZone(zoneId).toLocalDateTime();
     }
+
+    /**
+     * 统计下单量信息数据初始化
+     * @param monthNumber 前几个月
+     * @param queryWxFactorySumSummary 初始化对象list
+     */
+    private void getMonthFactorySumSummaryInit(int monthNumber,List<QueryWxFactoryVO> queryWxFactorySumSummary){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+        for (int i = monthNumber*-1 ; i <= 0; i++) {
+            Calendar calStart = Calendar.getInstance();
+            calStart.add(Calendar.MONTH, i);//上一月
+            calStart.set(Calendar.DAY_OF_MONTH, 1);
+            calStart.set(Calendar.HOUR_OF_DAY, 0);
+            String month = sdf.format(calStart.getTime());
+            QueryWxFactoryVO queryWxFactoryVO = new QueryWxFactoryVO();
+            queryWxFactoryVO.setMonth(month);
+            queryWxFactoryVO.setTotal(0L);//总量初始化为0
+            queryWxFactoryVO.setActivation(0L);//下载量初始化为0
+            queryWxFactorySumSummary.add(queryWxFactoryVO);
+        }
+    }
 }

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

@@ -33,34 +33,34 @@
     </sql>
 
     <select id="listActivePage" resultType="com.abi.qms.platform.dao.vo.result.ListActiveVO">
-        select active.id, active.active_name, active.active_type, active.audit_status,
-            active.apply_time, active.apply_user_name, active.begin_time, active.end_time,
-            active.active_url, active.valid, active.is_modify_apply,
-            active.url_tab,
-            apply.audit_status as apply_audit_status
-        from base_active active
-        left join base_active_modify_apply apply on active.id = apply.active_id and apply.is_delete = 0
+        select ac.id, ac.active_name, ac.active_type, ac.audit_status,
+        ac.apply_time, ac.apply_user_name, ac.begin_time, ac.end_time,
+        ac.active_url, ac.valid, ac.is_modify_apply,
+        ac.url_tab,
+        ac.audit_status as apply_audit_status
+        from base_active ac
+        left join base_active_modify_apply ap on ac.id = ap.active_id and ap.is_delete = 0
         <where>
-            active.is_delete = 0
+            ac.is_delete = 0
             <if test="param.activeName != null and param.activeName != ''">
-                AND active.active_name like concat('%',#{param.activeName},'%')
+                AND ac.active_name like concat('%',#{param.activeName},'%')
             </if>
             <if test="param.activeType != null">
-                AND active.active_type = #{param.activeType}
+                AND ac.active_type = #{param.activeType}
             </if>
             <if test="param.auditStatus != null ">
-                AND active.audit_status = #{param.auditStatus}
+                AND ac.audit_status = #{param.auditStatus}
             </if>
             <if test="param.valid==1 or param.valid==0 ">
-                AND active.valid = #{param.valid}
-                AND active.audit_status = 2
+                AND ac.valid = #{param.valid}
+                AND ac.audit_status = 2
             </if>
             <if test="param.valid==9">
-                AND active.valid = 1
-                AND active.audit_status in (1,9)
+                AND ac.valid = 1
+                AND ac.audit_status in (1,9)
             </if>
         </where>
-        order by active.apply_time desc
+        order by ac.apply_time desc
     </select>
 
     <select id="getPackageActive" resultType="com.abi.qms.platform.dao.vo.result.PackageActiveVO">

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

@@ -121,7 +121,7 @@
 
     <select id="queryWxFactorySumNumber" resultType="com.abi.qms.platform.dao.vo.result.QueryWxFactoryVO">
         SELECT
-        sum( qpackage.qr_number ) total,
+        CEILING(sum( qpackage.qr_number +( IF ( qpackage.standby_ratio IS NULL, 0, qpackage.standby_ratio / 100 * qpackage.qr_number )) )) total,
         DATE_FORMAT( qpackage.create_time, "%Y-%m" ) `month`
         FROM
         qr_package qpackage