Browse Source

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

tanzhongran 4 years ago
parent
commit
ade3879b7c
26 changed files with 561 additions and 68 deletions
  1. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/FactoryController.java
  2. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/QrVariableController.java
  3. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/wx/WxBreweryProductionLineController.java
  4. 7 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/wx/WxLoginController.java
  5. 64 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/wx/WxUserInfoController.java
  6. 2 2
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/enums/QrFormatUniqueStatusEunm.java
  7. 2 2
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/BaseActiveMapper.java
  8. 15 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/UserInfoMapper.java
  9. 23 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/ListProductionLineNameVO.java
  10. 36 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/ListSubAccountVO.java
  11. 3 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/QrSingleCheckVO.java
  12. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/ListFactorySelectReq.java
  13. 22 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/SubAccountDetailWxReq.java
  14. 36 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/UpdatePhoneEmailWxReq.java
  15. 36 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetUserInfoWxRes.java
  16. 70 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/ListSubAccountWxRes.java
  17. 5 3
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/infrastructure/mq/GenerateCodeConsumer.java
  18. 29 4
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/UserManagerService.java
  19. 3 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/MaterialServiceImpl.java
  20. 2 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrBoxCodeFormatImpl.java
  21. 63 29
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrFormatServiceImpl.java
  22. 8 7
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrPackageServiceImpl.java
  23. 66 16
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/UserManagerServiceImpl.java
  24. 13 0
      abi-cloud-qr-platform-server/src/main/resources/dao/mapper/BaseActiveMapper.xml
  25. 2 1
      abi-cloud-qr-platform-server/src/main/resources/dao/mapper/QrPackageMapper.xml
  26. 50 0
      abi-cloud-qr-platform-server/src/main/resources/dao/mapper/UserInfoMapper.xml

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

@@ -93,7 +93,7 @@ public class FactoryController {
 
     @ApiOperation("excel批量导入")
     @PostMapping("factoryExcelImport")
-    public BaseResponse factoryExcelImport(@RequestParam("file") MultipartFile file) throws Exception {
+    public BaseResponse<ExcelImportRes> factoryExcelImport(@RequestParam("file") MultipartFile file) throws Exception {
         List<FactoryProperty> factoryPropertyList = ExcelInputFactory.getExcelPojoList(file, FactoryProperty.class);
         //excel批量导入
         ExcelImportRes result = factoryService.factoryExcelImport(factoryPropertyList);

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

@@ -50,7 +50,7 @@ public class QrVariableController {
 
     @ApiOperation("码格式变量查询详情")
     @GetMapping("/getQrVariableDetail")
-    public BaseResponse getQrVariableDetail(@Validated GetQrVariableDetailReq getQrVariableDetailReq) {
+    public BaseResponse<GetQrVariableDetailRes> getQrVariableDetail(@Validated GetQrVariableDetailReq getQrVariableDetailReq) {
         GetQrVariableDetailRes result = qrVariableService.getQrVariableDetail(getQrVariableDetailReq);
         return BaseResponse.create(result);
     }

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

@@ -63,7 +63,7 @@ public class WxBreweryProductionLineController {
      */
     @ApiOperation("查询当前登陆人的产线列表")
     @GetMapping("/queryListBreweryProductionLine")
-    public BaseResponse queryListBreweryProductionLine(@Validated QueryListBreweryProductionLineReq req) {
+    public BaseResponse<QueryListBreweryProductionLineRes> queryListBreweryProductionLine(@Validated QueryListBreweryProductionLineReq req) {
         QueryListBreweryProductionLineRes res = breweryProductionLineService.queryListBreweryProductionLine(req);
         return BaseResponse.create(res);
     }

+ 7 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/wx/WxLoginController.java

@@ -41,6 +41,13 @@ public class WxLoginController {
         LoginActivateRes login = loginService.loginActivate(req);
         return BaseResponse.create(login);
     }
+
+    @PostMapping("updatePassword")
+    @ApiOperation("修改密码")
+    public BaseResponse<LoginActivateRes> updatePassword(@Validated @RequestBody UpdatePasswordReq req) {
+        loginService.updatePassword(req);
+        return BaseResponse.create();
+    }
 }
 
 

+ 64 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/wx/WxUserInfoController.java

@@ -0,0 +1,64 @@
+package com.abi.qms.platform.controller.wx;
+
+import com.abi.qms.platform.dto.req.UpdatePhoneEmailWxReq;
+import com.abi.qms.platform.dto.res.GetUserInfoWxRes;
+import com.abi.qms.platform.dto.res.ListSubAccountWxRes;
+import com.abi.qms.platform.service.UserManagerService;
+import com.abi.task.common.api.base.BaseResponse;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+/**
+ * @author Eurus
+ * @date 2021/6/9 10:13
+ * @Description:
+ */
+@Slf4j
+@RestController
+@RequestMapping("/wxQrPackage")
+@Api(tags = "个人信息")
+public class WxUserInfoController {
+
+    @Autowired
+    private UserManagerService userManagerService;
+
+    @ApiOperation("查询个人信息")
+    @GetMapping("getUserInfoWx/{userId}")
+    public BaseResponse<GetUserInfoWxRes> getUserInfoWx(@PathVariable("userId") Long userId){
+        //查询单个用户信息
+        GetUserInfoWxRes result = userManagerService.getUserInfoWx(userId);
+        //包装出参
+        return BaseResponse.create(result);
+    }
+
+    @ApiOperation("修改手机号邮箱")
+    @PostMapping("updatePhoneEmailWx")
+    public BaseResponse<GetUserInfoWxRes> updatePhoneEmailWx(@RequestBody @Valid UpdatePhoneEmailWxReq userId){
+        userManagerService.updatePhoneEmailWx(userId);
+        //包装出参
+        return BaseResponse.create();
+    }
+
+    @ApiOperation("查询子账号列表")
+    @GetMapping("listSubAccountWx")
+    public BaseResponse<ListSubAccountWxRes> listSubAccountWx(){
+        ListSubAccountWxRes result = userManagerService.listSubAccountWx();
+        //包装出参
+        return BaseResponse.create(result);
+    }
+
+    @ApiOperation("查询子账号详情")
+    @GetMapping("subAccountDetailWx/{subUserInfoId}")
+    public BaseResponse<ListSubAccountWxRes.SubAccount> subAccountDetailWx(@PathVariable("subUserInfoId") Long subUserInfoId){
+        ListSubAccountWxRes.SubAccount result = userManagerService.subAccountDetailWx(subUserInfoId);
+        //包装出参
+        return BaseResponse.create(result);
+    }
+
+
+}

+ 2 - 2
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/enums/QrFormatUniqueStatusEunm.java

@@ -21,8 +21,8 @@ public enum QrFormatUniqueStatusEunm {
 
 	UN_VERIFY(0,"未验证"),
 	VERIFYING(1,"验证中"),
-	VERIFY_FAIL(2,"验证通过"),
-	VERIFY_SUCCESS(3,"验证不通过");
+	VERIFY_SUCCESS(2,"验证通过"),
+	VERIFY_FAIL(3,"验证不通过");
 
 	@EnumValue
 	private Integer code;

+ 2 - 2
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/BaseActiveMapper.java

@@ -22,8 +22,8 @@ public interface BaseActiveMapper extends BaseMapper<BaseActive> {
 
     /**
      * 通过物料ID查询对应一个活动
-     * @param materialId 物料ID
+     * @param id 活动ID
      * @return
      */
-    PackageActiveVO getPackageActive(@Param("materialId") Long materialId);
+    PackageActiveVO getPackageActive(@Param("id") Long id);
 }

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

@@ -1,6 +1,7 @@
 package com.abi.qms.platform.dao.mapper;
 
 import com.abi.qms.platform.dao.entity.UserInfo;
+import com.abi.qms.platform.dao.vo.result.ListSubAccountVO;
 import com.abi.qms.platform.dto.req.BatchEnableUserReq;
 import com.abi.qms.platform.dto.req.ListUserReq;
 import com.abi.qms.platform.dto.res.entity.UserInfoResp;
@@ -34,4 +35,18 @@ public interface UserInfoMapper extends BaseMapper<UserInfo> {
      * @return
      */
     List<UserInfo> selectUserInfoByRoleCodeEnable(@Param("roleCode") String roleCode);
+
+    /**
+     * 查询子账号列表(小程序)
+     * @param factoryId
+     * @return
+     */
+    List<ListSubAccountVO> selectSubAccountList(@Param("factoryId")Long factoryId);
+
+    /**
+     * 根据子账号id查询子账号详情
+     * @param userId
+     * @return
+     */
+    ListSubAccountVO selectSubAccountDetail(@Param("userId")Long userId);
 }

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

@@ -0,0 +1,23 @@
+package com.abi.qms.platform.dao.vo.result;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Eurus
+ * @date 2021/6/9 17:58
+ * @Description: 产线名称List 映射返回
+ */
+@Data
+@ApiModel
+public class ListProductionLineNameVO implements Serializable {
+
+    @ApiModelProperty(value = "啤酒厂员工产线关联id")
+    private Long id;
+
+    @ApiModelProperty(value = "产线名称")
+    private String productionLineName;
+}

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

@@ -0,0 +1,36 @@
+package com.abi.qms.platform.dao.vo.result;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author Eurus
+ * @date 2021/6/9 17:22
+ * @Description: 子账号查询映射结果(小程序)
+ */
+@Data
+@ApiModel
+public class ListSubAccountVO implements Serializable {
+
+    @ApiModelProperty(value = "用户id")
+    private Long id;
+
+    @ApiModelProperty(value = "用户名")
+    private String userName;
+
+    @ApiModelProperty(value = "工号")
+    private String employeeNo;
+
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+
+    @ApiModelProperty(value = "邮箱")
+    private String email;
+
+    @ApiModelProperty(value = "产线名称列表")
+    private List<ListProductionLineNameVO> productionLineNameList;
+}

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

@@ -69,5 +69,8 @@ public class QrSingleCheckVO implements Serializable {
 	@ApiModelProperty("条码序号")
 	private String boxCode;
 
+	@ApiModelProperty("活动ID")
+	private Long activeId;
+
 
 }

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

@@ -22,7 +22,7 @@ public class ListFactorySelectReq implements Serializable {
 
     @NotNull(message = "是否数据隔离为空")
     @ApiModelProperty(value = "是否数据隔离")
-    private Integer dataLimit;
+    private Integer dataLimit = 1;
 
     @ApiModelProperty(value = "是否一级包材厂")
     private Integer isFirstFactory;

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

@@ -0,0 +1,22 @@
+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 java.io.Serializable;
+
+/**
+ * @author Eurus
+ * @date 2021/6/10 17:24
+ * @Description: 查询子账号详情 出参
+ */
+@Data
+@ApiModel
+public class SubAccountDetailWxReq implements Serializable {
+
+    @NotNull(message = "子账号不能为空")
+    @ApiModelProperty(value = "子账号id")
+    private Long id;
+}

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

@@ -0,0 +1,36 @@
+package com.abi.qms.platform.dto.req;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.Email;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import java.io.Serializable;
+
+/**
+ * @author Eurus
+ * @date 2021/6/9 11:47
+ * @Description: 更新手机号和邮箱(小程序) 入参
+ */
+@Data
+@ApiModel
+public class UpdatePhoneEmailWxReq implements Serializable {
+
+    @NotNull(message = "用户id为空")
+    @ApiModelProperty(value = "用户id")
+    private Long id;
+
+    @NotEmpty(message = "手机号为空")
+    @Pattern(regexp = "^1[0-9]{10}$", message = "手机格式不正确,请重新输入")
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+
+    @NotEmpty(message = "邮箱为空")
+    @Email(message = "邮件格式不正确,请重新输入")
+    @ApiModelProperty(value = "邮箱")
+    private String email;
+
+}

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

@@ -0,0 +1,36 @@
+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 Eurus
+ * @date 2021/6/9 10:29
+ * @Description: 查询个人信息(微信)
+ */
+@Data
+@ApiModel
+public class GetUserInfoWxRes implements Serializable {
+
+    @ApiModelProperty(value = "用户id")
+    private Long id;
+
+    @ApiModelProperty(value = "用户名")
+    private String userName;
+
+    @ApiModelProperty(value = "工号")
+    private String employeeNo;
+
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+
+    @ApiModelProperty(value = "邮箱")
+    private String email;
+
+    @ApiModelProperty(value = "是否主账号")
+    private Integer isMainAccount;
+
+}

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

@@ -0,0 +1,70 @@
+package com.abi.qms.platform.dto.res;
+
+import com.abi.qms.platform.dao.vo.result.ListProductionLineNameVO;
+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 Eurus
+ * @date 2021/6/9 18:23
+ * @Description: 查询子账号列表(小程序) 出参
+ */
+@Data
+@ApiModel
+public class ListSubAccountWxRes implements Serializable {
+
+    @ApiModelProperty(value = "子账号列表")
+    private List<SubAccount> subAccountList;
+
+    /**
+     * 产线bean
+     */
+    @Data
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ToString
+    @ApiModel(value = "ListSubAccountRes_ProductionLineName")
+    public static class ProductionLineName implements Serializable {
+        @ApiModelProperty(value = "啤酒厂员工产线关联id")
+        private Long id;
+
+        @ApiModelProperty(value = "产线名称")
+        private String productionLineName;
+    }
+
+    /**
+     * 子账号bean
+     */
+    @Data
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ToString
+    @ApiModel(value = "ListSubAccountRes_SubAccount")
+    public static class SubAccount implements Serializable {
+        @ApiModelProperty(value = "用户id")
+        private Long id;
+
+        @ApiModelProperty(value = "用户名")
+        private String userName;
+
+        @ApiModelProperty(value = "工号")
+        private String employeeNo;
+
+        @ApiModelProperty(value = "手机号")
+        private String phone;
+
+        @ApiModelProperty(value = "邮箱")
+        private String email;
+
+        @ApiModelProperty(value = "产线名称列表")
+        private List<ProductionLineName> productionLineNameList;
+    }
+
+}

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

@@ -411,9 +411,11 @@ public class GenerateCodeConsumer {
 						Long qrRepertoryColumnId = qrRepertoryColumn.getId();
 						//声明拆分数量
 						int splitNum = 0;
-						Integer splitNum1 = splitCache.get(qrRepertoryColumnId).getSplitNum();
-						if(null != splitNum1){
-							splitNum = splitNum1;
+						if(splitCache.size() != 0 && !splitCache.isEmpty()){
+							Integer splitNum1 = splitCache.get(qrRepertoryColumnId).getSplitNum();
+							if(null != splitNum1){
+								splitNum = splitNum1;
+							}
 						}
 						// 非clone列,设置code和url
 						String code = buildUniqueCode(uniqueSet, qrRepertoryColumn, codeSb, paramMap, qrRepertorySerialNumberMap, 0);

+ 29 - 4
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/UserManagerService.java

@@ -2,10 +2,7 @@ package com.abi.qms.platform.service;
 
 
 import com.abi.qms.platform.dto.req.*;
-import com.abi.qms.platform.dto.res.GetUserInfoRes;
-import com.abi.qms.platform.dto.res.ListRoleTreeRes;
-import com.abi.qms.platform.dto.res.ListUserRes;
-import com.abi.task.common.api.base.BaseResponse;
+import com.abi.qms.platform.dto.res.*;
 
 
 /**
@@ -70,4 +67,32 @@ public interface UserManagerService {
      * @throws Exception
      */
     void batchEnableUser(BatchEnableUserReq req)throws Exception;
+
+    /**
+     * 根据id查询单个用户信息(小程序)
+     *
+     * @param userInfoId
+     * @return
+     * @throws Exception
+     */
+    GetUserInfoWxRes getUserInfoWx(Long userInfoId);
+
+    /**
+     * 更新手机号和邮箱(小程序)
+     * @param updatePhoneEmailWxReq
+     */
+    void updatePhoneEmailWx(UpdatePhoneEmailWxReq updatePhoneEmailWxReq);
+
+    /**
+     * 查询子账号列表(小程序)
+     * @return
+     */
+    ListSubAccountWxRes listSubAccountWx();
+
+    /**
+     * 查询子账号详情
+     * @param subUserInfoId
+     * @return
+     */
+    ListSubAccountWxRes.SubAccount subAccountDetailWx(Long subUserInfoId);
 }

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

@@ -23,6 +23,7 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 
@@ -140,6 +141,7 @@ public class MaterialServiceImpl implements MaterialService {
      * 物料启用
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void enableMaterial(EnableMaterialReq req){
         List<Long> ids = req.getIds();
 
@@ -163,6 +165,7 @@ public class MaterialServiceImpl implements MaterialService {
      * 物料禁用
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void disableMaterial(DisableMaterialReq req){
         List<Long> ids = req.getIds();
 

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

@@ -150,6 +150,7 @@ public class QrBoxCodeFormatImpl implements QrBoxCodeFormatService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void enableBoxCodeFormat(EnableBoxCodeFormatReq req) {
 
         List<Long> ids = req.getIds();
@@ -170,6 +171,7 @@ public class QrBoxCodeFormatImpl implements QrBoxCodeFormatService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void disableBoxCodeFormat(DisableBoxCodeFormatReq req) {
 
         List<Long> ids = req.getIds();

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

@@ -28,6 +28,7 @@ import com.abi.task.common.api.exception.BusinessException;
 import com.abi.task.common.utils.PojoConverterUtils;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -43,6 +44,7 @@ import java.util.concurrent.ExecutorService;
  * @date 2021-04-19
  */
 @Service
+@Slf4j
 public class QrFormatServiceImpl implements QrFormatService {
 
     @Autowired
@@ -71,6 +73,10 @@ public class QrFormatServiceImpl implements QrFormatService {
     public void saveQrFormat(SaveQrFormatReq req) {
         Long qrFormatId = req.getId();
         //1-校验入参
+        //码格式位数不在规定区间内
+        if (null == req.getDigit() || req.getDigit() <= 0 || req.getDigit() > 32){
+            throw new BusinessException("码格式位数不在0~32位之内");
+        }
         // 修改码格式时的条件限制
         QrFormat qrFormat;
         if (qrFormatId != null) {
@@ -179,22 +185,36 @@ public class QrFormatServiceImpl implements QrFormatService {
     public void enableQrFormat(EnableQrFormatReq req) {
         List<Long> idList = req.getIds();
         for (Long id : idList) {
-            QrFormat qrFormat = qrFormatMapper.selectById(id);
-            AssertUtil.isNull(qrFormat, "码格式不存在");
-            // 如果不是停用状态的码格式,跳过循环
-            if (!QrFormatUseStatusEnum.DISABLE.is(qrFormat.getUseStatus())) {
-                continue;
+            try{
+                QrFormat qrFormat = qrFormatMapper.selectById(id);
+                AssertUtil.isNull(qrFormat, "码格式不存在");
+                // 如果不是停用状态的码格式,跳过循环
+                if (!QrFormatUseStatusEnum.DISABLE.is(qrFormat.getUseStatus())) {
+                    continue;
+                }
+                //不是验证通过的码格式,跳过循环,不可启用
+                if (!QrFormatUniqueStatusEunm.VERIFY_SUCCESS.is(qrFormat.getUniqueStatus())){
+                    throw new BusinessException("码格式不是验证通过,不可启用");
+                }
+
+                // 根据是否被码库使用,决定更新状态为未使用还是使用中
+                QueryWrapper<QrRepertoryColumn> qrRepertoryColumnQw = new QueryWrapper<>();
+                qrRepertoryColumnQw.eq("is_delete", 0);
+                qrRepertoryColumnQw.eq("qr_format_id", id);
+                Integer count = qrRepertoryColumnMapper.selectCount(qrRepertoryColumnQw);
+                Integer useStatus = count.compareTo(0) > 0 ? QrFormatUseStatusEnum.USING.getCode() : QrFormatUseStatusEnum.UN_USE.getCode();
+
+                QrFormat update = new QrFormat().setId(id).setUseStatus(useStatus);
+                qrFormatMapper.updateById(update);
+            }catch(BusinessException e){
+                //单条不通过通知前端
+                if (idList.size() == 1){
+                    throw e;
+                }else{
+                    log.info("批量处理发现异常",e);
+                }
             }
 
-            // 根据是否被码库使用,决定更新状态为未使用还是使用中
-            QueryWrapper<QrRepertoryColumn> qrRepertoryColumnQw = new QueryWrapper<>();
-            qrRepertoryColumnQw.eq("is_delete", 0);
-            qrRepertoryColumnQw.eq("qr_format_id", id);
-            Integer count = qrRepertoryColumnMapper.selectCount(qrRepertoryColumnQw);
-            Integer useStatus = count.compareTo(0) > 0 ? QrFormatUseStatusEnum.USING.getCode() : QrFormatUseStatusEnum.UN_USE.getCode();
-
-            QrFormat update = new QrFormat().setId(id).setUseStatus(useStatus);
-            qrFormatMapper.updateById(update);
         }
     }
 
@@ -205,22 +225,36 @@ public class QrFormatServiceImpl implements QrFormatService {
     @Transactional(rollbackFor = Exception.class)
     public void disableQrFormat(DisableQrFormatReq req) {
         List<Long> idList = req.getIds();
-        for (Long id : idList) {
-            QrFormat qrFormat = qrFormatMapper.selectById(id);
-            AssertUtil.isNull(qrFormat, "码格式不存在");
-            // 如果是停用状态的码格式,跳过循环
-            if (QrFormatUseStatusEnum.DISABLE.is(qrFormat.getUseStatus())) {
-                continue;
+        try{
+            for (Long id : idList) {
+                QrFormat qrFormat = qrFormatMapper.selectById(id);
+                AssertUtil.isNull(qrFormat, "码格式不存在");
+                // 如果是停用状态的码格式,跳过循环
+                if (QrFormatUseStatusEnum.DISABLE.is(qrFormat.getUseStatus())) {
+                    continue;
+                }
+
+                //不是验证通过的码格式,跳过循环,不可禁用
+                if (!QrFormatUniqueStatusEunm.VERIFY_SUCCESS.is(qrFormat.getUniqueStatus())){
+                    throw new BusinessException("码格式不是验证通过,不可禁用");
+                }
+
+                // 判断该码格式关联的码库是否全部停用,若否,停用失败
+                List<String> notDisabledQrRepertoryList = qrRepertoryMapper.selectNotDisabledQrRepertory(id);
+                if (!CollectionUtils.isEmpty(notDisabledQrRepertoryList)) {
+                    throw new BusinessException("该码格式已与码库" + notDisabledQrRepertoryList + "关联,请停用码库后再试");
+                }
+
+                QrFormat update = new QrFormat().setId(id).setUseStatus(QrFormatUseStatusEnum.DISABLE.getCode());
+                qrFormatMapper.updateById(update);
             }
-
-            // 判断该码格式关联的码库是否全部停用,若否,停用失败
-            List<String> notDisabledQrRepertoryList = qrRepertoryMapper.selectNotDisabledQrRepertory(id);
-            if (!CollectionUtils.isEmpty(notDisabledQrRepertoryList)) {
-                throw new BusinessException("该码格式已与码库" + notDisabledQrRepertoryList + "关联,请停用码库后再试");
+        }catch(BusinessException e){
+            //单条不通过通知前端
+            if (idList.size() == 1){
+                throw e;
+            }else{
+                log.info("批量处理发现异常",e);
             }
-
-            QrFormat update = new QrFormat().setId(id).setUseStatus(QrFormatUseStatusEnum.DISABLE.getCode());
-            qrFormatMapper.updateById(update);
         }
     }
 
@@ -251,7 +285,7 @@ public class QrFormatServiceImpl implements QrFormatService {
         ListFormatSelectRes res = new ListFormatSelectRes();
 
         QueryWrapper<QrFormat> qw = new QueryWrapper<>();
-        qw.eq("unique_status", QrFormatUniqueStatusEunm.VERIFY_FAIL.getCode());
+        qw.eq("unique_status", QrFormatUniqueStatusEunm.VERIFY_SUCCESS.getCode());
         qw.eq("is_delete", 0);
         qw.eq("is_sys",0);
         List<QrFormat> formatList = qrFormatMapper.selectList(qw);

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

@@ -816,17 +816,18 @@ public class QrPackageServiceImpl implements QrPackageService {
         QrRepertoryColumn qrRepertoryColumn = repertoryColumnMapper.selectById(qrCode.getQrRepertoryColumnId());
 
         //存在别名(隐形码)
-        if (ObjectUtils.isNotEmpty(qrRepertoryColumn)) {
+        if (!ObjectUtils.isEmpty(qrRepertoryColumn)) {
             qrSingleCheckVO.setAlias(qrRepertoryColumn.getAlias());//隐形码
         }
 
         //查询码包对应活动单条数据
-        PackageActiveVO packageActive = baseActiveMapper.getPackageActive(qrCode.getPackageId());
-
-        //存在活动数据
-        if (ObjectUtils.isNotEmpty(packageActive)) {
-            qrSingleCheckVO.setActiveName(packageActive.getActiveName());
-            qrSingleCheckVO.setActiveUrl(packageActive.getActiveUrl());
+        if(null != qrSingleCheckVO.getActiveId()) {
+            //存在活动数据
+            PackageActiveVO packageActive = baseActiveMapper.getPackageActive(qrSingleCheckVO.getActiveId());
+            if (!ObjectUtils.isEmpty(packageActive)) {
+                qrSingleCheckVO.setActiveName(packageActive.getActiveName());
+                qrSingleCheckVO.setActiveUrl(packageActive.getActiveUrl());
+            }
         }
 
         //查询批次号id

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

@@ -1,21 +1,12 @@
 package com.abi.qms.platform.service.impl;
 
-import com.abi.qms.platform.dao.entity.BaseFactory;
-import com.abi.qms.platform.dao.entity.UserInfo;
-import com.abi.qms.platform.dao.entity.UserMappingInfoRole;
-import com.abi.qms.platform.dao.entity.UserRole;
+import cn.hutool.core.collection.CollectionUtil;
+import com.abi.qms.platform.dao.entity.*;
 import com.abi.qms.platform.dao.enums.TrueFalseEnum;
-import com.abi.qms.platform.dao.mapper.BaseFactoryMapper;
-import com.abi.qms.platform.dao.mapper.UserInfoMapper;
-import com.abi.qms.platform.dao.mapper.UserMappingInfoRoleMapper;
-import com.abi.qms.platform.dao.mapper.UserRoleMapper;
-import com.abi.qms.platform.dto.req.BatchEnableUserReq;
-import com.abi.qms.platform.dto.req.CreateUserReq;
-import com.abi.qms.platform.dto.req.ListUserReq;
-import com.abi.qms.platform.dto.req.UpdateUserReq;
-import com.abi.qms.platform.dto.res.GetUserInfoRes;
-import com.abi.qms.platform.dto.res.ListRoleTreeRes;
-import com.abi.qms.platform.dto.res.ListUserRes;
+import com.abi.qms.platform.dao.mapper.*;
+import com.abi.qms.platform.dao.vo.result.ListSubAccountVO;
+import com.abi.qms.platform.dto.req.*;
+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;
@@ -27,11 +18,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 
@@ -64,6 +55,9 @@ public class UserManagerServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo
     @Autowired
     private UserUtil userUtil;
 
+    @Autowired
+    private UserRoleDetailMapper userRoleDetailMapper;
+
     /**
      * 创建用户
      **/
@@ -266,5 +260,61 @@ public class UserManagerServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo
         userInfoMapper.batchEnableUser(req);
     }
 
+    @Override
+    public GetUserInfoWxRes getUserInfoWx(Long userInfoId) {
+        //查询用户
+        UserInfo userInfo = userInfoMapper.selectById(userInfoId);
+
+        //构造出参
+        GetUserInfoWxRes getUserInfoWxRes = PojoConverterUtils.copy(userInfo,GetUserInfoWxRes.class);
+        getUserInfoWxRes.setIsMainAccount(userUtil.getWholeUser().getIsMainAccount());
+
+        return getUserInfoWxRes;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updatePhoneEmailWx(UpdatePhoneEmailWxReq req) {
+        //0-校验入参
+        UserInfo userInfo = userInfoMapper.selectById(req.getId());
+        if(Objects.isNull(userInfo)){
+            throw new BusinessException("该用户不存在。");
+        }
+        userInfo.setEmail(req.getEmail());
+        userInfo.setPhone(req.getPhone());
+        userInfo.setUpdateBy(userUtil.getWholeUser().getId());
+        userInfoMapper.updateById(userInfo);
+    }
+
+    @Override
+    public ListSubAccountWxRes listSubAccountWx() {
+        ListSubAccountWxRes listSubAccountWxRes = new ListSubAccountWxRes();
+        List<ListSubAccountVO> listSubAccountVOList = userInfoMapper.selectSubAccountList(userUtil.getWholeUser().getFactoryId());
+        if (CollectionUtil.isNotEmpty(listSubAccountVOList)) {
+            List<ListSubAccountWxRes.SubAccount> subAccountList = new ArrayList<>();
+            //循环构造出参
+            listSubAccountVOList.forEach(listSubAccountVO -> {
+                ListSubAccountWxRes.SubAccount subAccount = PojoConverterUtils.copy(listSubAccountVO, ListSubAccountWxRes.SubAccount.class);
+                List<ListSubAccountWxRes.ProductionLineName> productionLineNames = PojoConverterUtils.copyList(listSubAccountVO.getProductionLineNameList(), ListSubAccountWxRes.ProductionLineName.class);
+                subAccount.setProductionLineNameList(productionLineNames);
+                subAccountList.add(subAccount);
+            });
+            listSubAccountWxRes.setSubAccountList(subAccountList);
+        }
+        return listSubAccountWxRes;
+    }
+
+    @Override
+    public ListSubAccountWxRes.SubAccount subAccountDetailWx(Long subUserInfoId) {
+        ListSubAccountVO listSubAccountVO = userInfoMapper.selectSubAccountDetail(subUserInfoId);
+        if(Objects.nonNull(listSubAccountVO)){
+            ListSubAccountWxRes.SubAccount subAccount = PojoConverterUtils.copy(listSubAccountVO, ListSubAccountWxRes.SubAccount.class);
+            List<ListSubAccountWxRes.ProductionLineName> productionLineNames = PojoConverterUtils.copyList(listSubAccountVO.getProductionLineNameList(), ListSubAccountWxRes.ProductionLineName.class);
+            subAccount.setProductionLineNameList(productionLineNames);
+            return subAccount;
+        }
+        return null;
+    }
+
 
 }

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

@@ -59,20 +59,19 @@
     </select>
 
     <select id="getPackageActive" resultType="com.abi.qms.platform.dao.vo.result.PackageActiveVO">
+         SELECT
+             ba.id,
+             ba.active_code,
+             ba.active_name,
+             ba.active_url,
+             ba.active_type,
+             ba.begin_time,
+             ba.end_time,
+             ba.brand_code
+         FROM
+             base_active ba
+         WHERE
+         ba.id = #{id} limit 1
     </select>
 
 

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

@@ -166,7 +166,8 @@
         qp.generate_time,
         bm.material_name,
         bfa.factory_name AS factory_cover_name,
-        bfb.factory_name AS factory_beer_name
+        bfb.factory_name AS factory_beer_name,
+        bm.active_id
         FROM
         qr_package qp
         LEFT JOIN base_material bm ON qp.material_id = bm.id

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

@@ -24,6 +24,21 @@
         <result column="UPDATE_BY" property="updateBy" />
     </resultMap>
 
+    <!--子账号查询映射结果(小程序)-->
+    <resultMap id="SubAccountResultMap" type="com.abi.qms.platform.dao.vo.result.ListSubAccountVO">
+        <id column="ID" property="id"/>
+        <result column="USER_NAME" property="userName"/>
+        <result column="EMPLOYEE_NO" property="employeeNo"/>
+        <result column="PHONE" property="phone"/>
+        <result column="EMAIL" property="email"/>
+
+        <collection property="productionLineNameList" javaType="java.util.List"
+                    ofType="com.abi.qms.platform.dao.vo.result.ListProductionLineNameVO">
+            <result property="id" column="production_line_id"/>
+            <result property="productionLineName" column="production_line_name"/>
+        </collection>
+    </resultMap>
+
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id, user_name, employee_no, phone, email, login_name, password, is_abi, factory_id, factory_type, role_code, is_enable, create_time, create_by, update_time, is_delete,update_by
@@ -78,4 +93,39 @@
         from user_info
         WHERE role_code = #{roleCode} AND is_enable = 1 and is_delete = 0
     </select>
+
+    <!--查询子账号列表(小程序)-->
+    <select id="selectSubAccountList" resultMap="SubAccountResultMap">
+        SELECT
+        ui.id,
+        ui.USER_NAME,
+        ui.EMPLOYEE_NO,
+        ui.PHONE,
+        ui.EMAIL,
+        bpl.id as production_line_id,
+        bpl.production_line_name
+        from user_info ui
+        inner JOIN user_role_detail urd ON ui.role_code = urd.role_code
+        LEFT JOIN brewery_production_line bpl ON ui.id = bpl.user_name
+        WHERE  ui.factory_id = #{factoryId}
+        and ui.is_enable = 1 and ui.is_delete = 0
+        and urd.is_activate_mini_app_main_account = 0
+        and urd.is_activate_mini_app_sub_account = 1
+    </select>
+
+    <!--查询子账号详情-->
+    <select id="selectSubAccountDetail" resultMap="SubAccountResultMap">
+        SELECT
+        ui.id,
+        ui.USER_NAME,
+        ui.EMPLOYEE_NO,
+        ui.PHONE,
+        ui.EMAIL,
+        bpl.id as production_line_id,
+        bpl.production_line_name
+        from user_info ui
+        inner JOIN user_role_detail urd ON ui.role_code = urd.role_code
+        LEFT JOIN brewery_production_line bpl ON ui.id = bpl.user_name
+        WHERE  ui.id = #{userId}
+    </select>
 </mapper>