huanglizhi há 11 meses atrás
pai
commit
9781616926
21 ficheiros alterados com 118 adições e 152 exclusões
  1. 2 1
      framework/src/main/java/com/hys/app/framework/context/user/AdminUserContext.java
  2. 1 1
      module-erp/src/main/java/com/hys/app/controller/erp/use/AdminUserOperationManagerController.java
  3. 1 1
      module-erp/src/main/java/com/hys/app/controller/erp/use/DeptController.java
  4. 3 0
      module-erp/src/main/java/com/hys/app/controller/erp/use/ProductManagerController.java
  5. 2 2
      module-erp/src/main/java/com/hys/app/controller/erp/use/RoleManagerController.java
  6. 13 9
      module-erp/src/main/java/com/hys/app/controller/erp/use/SmsMailController.java
  7. 5 6
      module-erp/src/main/java/com/hys/app/controller/erp/use/WarehouseAreaController.java
  8. 4 9
      module-erp/src/main/java/com/hys/app/controller/erp/use/msg/AliSmsUtil.java
  9. 2 2
      module-erp/src/main/java/com/hys/app/controller/erp/use/msg/MessageReceiveTypeEnum.java
  10. 6 7
      module-erp/src/main/java/com/hys/app/controller/erp/use/msg/MsgUtilClient.java
  11. 2 0
      module-erp/src/main/java/com/hys/app/controller/system/SystemLogsManagerController.java
  12. 2 0
      module-erp/src/main/java/com/hys/app/mapper/goods/ProductMapper.java
  13. 1 1
      module-erp/src/main/java/com/hys/app/model/erp/dos/MessageReceiveDO.java
  14. 1 0
      module-erp/src/main/java/com/hys/app/model/support/validator/validator/LogAspect.java
  15. 0 1
      module-erp/src/main/java/com/hys/app/model/system/dos/AdminUser.java
  16. 3 0
      module-erp/src/main/java/com/hys/app/model/system/dos/SystemLogs.java
  17. 3 68
      module-erp/src/main/java/com/hys/app/model/system/dto/SystemLogsParam.java
  18. 20 9
      module-erp/src/main/java/com/hys/app/model/system/vo/AdminUserVO.java
  19. 5 4
      module-erp/src/main/java/com/hys/app/service/erp/impl/CompanyErpManagerImpl.java
  20. 39 31
      module-erp/src/main/java/com/hys/app/service/system/impl/AdminUserManagerImpl.java
  21. 3 0
      module-erp/src/main/java/com/hys/app/service/system/impl/SystemLogsManagerImpl.java

+ 2 - 1
framework/src/main/java/com/hys/app/framework/context/user/AdminUserContext.java

@@ -144,7 +144,8 @@ public class AdminUserContext {
         Admin admin = getAdmin();
         if (admin.getFounder() == 1 && ObjectUtil.isNull(companyId)) {
             throw new ServiceException("平台管理员查看业务数据请先选择公司");
+        }else if (admin.getFounder() == 1 && ObjectUtil.isNotNull(companyId)){
+            admin.setCompanyId(companyId);
         }
-        admin.setCompanyId(companyId);
     }
 }

+ 1 - 1
module-erp/src/main/java/com/hys/app/controller/erp/use/AdminUserOperationManagerController.java

@@ -60,7 +60,7 @@ public class AdminUserOperationManagerController {
     @ApiOperation(value = "修改平台管理员", response = AdminUser.class)
     @Log(client = LogClient.admin, detail = "修改ID为[${id}]的管理员信息")
     public AdminUser edit(@Valid AdminUserVO adminUserVO, @PathVariable Long id) {
-        if (Objects.equals(AdminUserContext.getAdminUserId(), id)) {
+        if (!Objects.equals(AdminUserContext.getAdminUserId(), id)) {
             throw new ServiceException("只能修改自己的账号");
         }
         return this.adminUserManager.edit(adminUserVO, id);

+ 1 - 1
module-erp/src/main/java/com/hys/app/controller/erp/use/DeptController.java

@@ -69,7 +69,7 @@ public class DeptController {
 
     @PutMapping("update/{id}")
     @ApiOperation(value = "更新部门")
-    @Log(client = LogClient.admin, detail = "修改名称为[${reqVO.name}]的部门信息")
+    @Log(client = LogClient.admin, detail = "修改id为[${id}]的部门信息")
     public void updateDept(@Valid @RequestBody DeptBaseVO reqVO, @PathVariable Long id) {
         AdminUserContext.hasAdmin();
         deptManager.updateDept(reqVO,id);

+ 3 - 0
module-erp/src/main/java/com/hys/app/controller/erp/use/ProductManagerController.java

@@ -50,6 +50,7 @@ public class ProductManagerController {
 
     @ApiOperation(value = "新增产品")
     @PostMapping("/addProduct")
+    @Log(client = LogClient.admin, detail = "添加名称为[${productDTO.name}]的商品信息")
     public void productGroup(@RequestBody @Valid ProductDTO productDTO) {
         AdminUserContext.hasCompany();
         productManager.addProduct(productDTO);
@@ -57,6 +58,7 @@ public class ProductManagerController {
 
     @ApiOperation(value = "修改产品")
     @PostMapping("/updateProduct/{id}")
+    @Log(client = LogClient.admin, detail = "修改id为[${id}]的商品信息")
     public void updateProduct(@RequestBody @Valid ProductDTO productDTO, @PathVariable Long id) {
         AdminUserContext.hasCompany();
         productManager.updateProduct(productDTO, id);
@@ -64,6 +66,7 @@ public class ProductManagerController {
 
     @ApiOperation(value = "删除产品")
     @PostMapping("/deletedProduct/{id}")
+    @Log(client = LogClient.admin, detail = "删除id为[${id}]的商品信息")
     public void deletedProduct(@PathVariable Long id) {
         AdminUserContext.hasCompany();
         productManager.deletedProduct(id);

+ 2 - 2
module-erp/src/main/java/com/hys/app/controller/erp/use/RoleManagerController.java

@@ -57,8 +57,8 @@ public class RoleManagerController {
 
     @ApiOperation(value = "角色列表分页", response = RoleDO.class)
     @GetMapping("packageSuper")
-    public WebPage packageSuper(@ApiIgnore @NotEmpty(message = "页码不能为空") Long pageNo, @ApiIgnore @NotEmpty(message = "每页数量不能为空") Long pageSize, @ApiIgnore String keyword) {
-        return this.roleManager.list(pageNo, pageSize, keyword,"packageSuper");
+    public IPage packageSuper(@ApiIgnore @NotEmpty(message = "页码不能为空") Long pageNo, @ApiIgnore @NotEmpty(message = "每页数量不能为空") Long pageSize, @ApiIgnore String keyword) {
+        return roleManager.page(new Page<>(pageNo, pageSize), new LambdaQueryWrapper<RoleDO>().isNull(RoleDO::getCompanyId));
     }
 
 

+ 13 - 9
module-erp/src/main/java/com/hys/app/controller/erp/use/SmsMailController.java

@@ -2,6 +2,7 @@ package com.hys.app.controller.erp.use;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.ListUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -129,6 +130,7 @@ public class SmsMailController {
 
     @PostMapping("updateSelectMsg")
     @ApiOperation(value = "公司选中的模板")
+    @Log(client = LogClient.admin, detail = "修改了消息配置")
     public void updateSeletMsg(@RequestBody BandTemplateDTO dto) {
         AdminUserContext.hasSuperAdminQuery(dto.getCompanyId());
         AdminUser model = adminUserManager.getModel(AdminUserContext.getAdminUserId());
@@ -159,7 +161,7 @@ public class SmsMailController {
         }
         companyBandMsgManager.remove(new LambdaQueryWrapper<CompanyBandMsg>().eq(CompanyBandMsg::getCompanyId,AdminUserContext.getCompanyId()));
         companyBandMsgManager.saveBatch(list);
-        redisTemplate.opsForHash().delete("companyTemplate", AdminUserContext.getCompanyId().toString());
+        redisTemplate.opsForHash().delete("companyTemplate", model.getCompanyId().toString());
         redisTemplate.opsForHash().put("companyTemplate",AdminUserContext.getCompanyId().toString(),list.stream().filter(CompanyBandMsg::getHasSelect).collect(Collectors.toList()));
     }
 
@@ -172,11 +174,11 @@ public class SmsMailController {
 
 
 
-    @GetMapping("getMessageByTypeCompany/{type}")
-    @ApiOperation(value = "获取各公司发的消息记录")
-    public IPage<MessageReceiveDO> getMessageByTypeCompany(BaseQueryParam query, @PathVariable String type) {
-        return messageReceiveManager.getPage(query, type);
-    }
+//    @GetMapping("getMessageByTypeCompany/{type}")
+//    @ApiOperation(value = "获取各公司发的消息记录")
+//    public IPage<MessageReceiveDO> getMessageByTypeCompany(BaseQueryParam query, @PathVariable String type) {
+//        return messageReceiveManager.getPage(query, type);
+//    }
 
     @GetMapping("countNotReadSys")
     @ApiOperation(value = "统计自己账号所有未读的消息")
@@ -187,9 +189,9 @@ public class SmsMailController {
                 .eq(MessageReceiveDO::getStatus, false));
     }
 
-    @GetMapping("getSysMsgByOwn")
+    @GetMapping("getSysMsgByOwn/{type}")
     @ApiOperation(value = "获取自己所有的消息")
-    public IPage<MessageReceiveDO> getMessageByTypeCompany(BaseQueryParam query) {
+    public IPage<MessageReceiveDO> getMessageByTypeCompany(BaseQueryParam query ,  @PathVariable String type) {
         //把自己所有的消息全部设置为已读
         MessageReceiveDO messageReceiveDO = new MessageReceiveDO();
         messageReceiveDO.setStatus(true);
@@ -198,7 +200,9 @@ public class SmsMailController {
                 .eq(MessageReceiveDO::getType, MessageReceiveTypeEnum.SYSTEM));
         return messageReceiveManager.page(new Page<>(query.getPageNo(), query.getPageSize()), new LambdaQueryWrapper<MessageReceiveDO>()
                 .eq(MessageReceiveDO::getUserId, AdminUserContext.getAdminUserId())
-                .eq(MessageReceiveDO::getType, MessageReceiveTypeEnum.SYSTEM));
+                .eq(StrUtil.isNotBlank(type),MessageReceiveDO::getType,type)
+                .eq(MessageReceiveDO::getType, MessageReceiveTypeEnum.SYSTEM)
+                .orderByAsc(MessageReceiveDO::getStatus));
     }
 
 

+ 5 - 6
module-erp/src/main/java/com/hys/app/controller/erp/use/WarehouseAreaController.java

@@ -61,7 +61,7 @@ public class WarehouseAreaController {
 
     @ApiOperation(value = "更新")
     @PostMapping("/update")
-    @Log(client = LogClient.admin, detail = "创建库位信息")
+    @Log(client = LogClient.admin, detail = "修改id为[${id}]的库位信息")
     public void update(@RequestBody @Valid WarehouseAreaDO warehouseAreaDO) {
         AdminUserContext.hasCompany();
         warehouseAreaManager.edit(warehouseAreaDO);
@@ -69,7 +69,6 @@ public class WarehouseAreaController {
 
     @ApiOperation(value = "库位详情")
     @PostMapping("/info")
-    @Log(client = LogClient.admin, detail = "查看库位信息")
     public WarehouseAreaVO info(@RequestBody @Valid WarehouseAreaRequest request) {
         return warehouseAreaManager.getDetail(request.getId());
     }
@@ -77,7 +76,7 @@ public class WarehouseAreaController {
 
     @ApiOperation(value = "删除")
     @DeleteMapping("/delete")
-    @Log(client = LogClient.admin, detail = "创建库位信息")
+    @Log(client = LogClient.admin, detail = "删除id为[${id}]的库位信息")
     public void delete(@RequestBody @Valid WarehouseAreaRequest request) {
         AdminUserContext.hasCompany();
         warehouseAreaManager.delete(request.getId());
@@ -85,7 +84,7 @@ public class WarehouseAreaController {
 
     @ApiOperation(value = "添加库位类型")
     @PostMapping("/createAreaType")
-    @Log(client = LogClient.admin, detail = "创建库位信息")
+    @Log(client = LogClient.admin, detail = "添加名称为[${warehouseAreaTypeDO.name}]的库位信息")
     public void createAreaType(@RequestBody @Valid WarehouseAreaTypeDO warehouseAreaTypeDO) {
         AdminUserContext.hasCompany();
         warehouseAreaTypeDO.setCompanyId(AdminUserContext.getCompanyId());
@@ -94,7 +93,7 @@ public class WarehouseAreaController {
 
     @ApiOperation(value = "删除库位类型")
     @DeleteMapping("/removeAreaType/{id}")
-    @Log(client = LogClient.admin, detail = "删除库位信息")
+    @Log(client = LogClient.admin, detail = "删除id为为[${id}]的库位信息")
     public void removeAreaType(@PathVariable Long id) {
         AdminUserContext.hasCompany();
         warehouseAreaTypeManager.removeById(id);
@@ -102,7 +101,7 @@ public class WarehouseAreaController {
 
     @ApiOperation(value = "修改库位类型")
     @PutMapping("/updateAreaType/{id}")
-    @Log(client = LogClient.admin, detail = "创建库位信息")
+    @Log(client = LogClient.admin, detail = "修改id为[${id}]的库位信息")
     public void updateAreaType(@RequestBody @Valid WarehouseAreaTypeDO warehouseAreaTypeDO, @PathVariable(value = "id") Long id) {
         AdminUserContext.hasCompany();
         warehouseAreaTypeDO.setId(id);

+ 4 - 9
module-erp/src/main/java/com/hys/app/controller/erp/use/msg/AliSmsUtil.java

@@ -3,6 +3,7 @@ package com.hys.app.controller.erp.use.msg;
 
 import cn.hutool.json.JSON;
 import cn.hutool.json.JSONUtil;
+import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
 import com.aliyun.tea.TeaException;
 import com.aliyun.teautil.models.RuntimeOptions;
 import com.aliyuncs.DefaultAcsClient;
@@ -64,16 +65,10 @@ public class AliSmsUtil {
                     .setTemplateParam(map)
                     .setSignName(signName);
             // 复制代码运行请自行打印 API 的返回值
-            client.sendSmsWithOptions(sendSmsRequest, new RuntimeOptions());
+            SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, new RuntimeOptions());
             return true;
-        } catch (Exception _error) {
-            TeaException error = new TeaException(_error.getMessage(), _error);
-            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
-            // 错误 message
-            System.out.println(error.getMessage());
-            // 诊断地址
-            System.out.println(error.getData().get("Recommend"));
-            com.aliyun.teautil.Common.assertAsString(error.message);
+        } catch (Exception e) {
+            e.printStackTrace();
             return false;
         }
     }

+ 2 - 2
module-erp/src/main/java/com/hys/app/controller/erp/use/msg/MessageReceiveTypeEnum.java

@@ -13,8 +13,8 @@ import lombok.Getter;
 public enum MessageReceiveTypeEnum {
 
     SYSTEM("SYSTEM", "系统消息"),
-    SMS("SMS", "手机短"),
-    OFFICIAL("OFFICIAL", "手机短息"),
+    SMS("SMS", "手机短"),
+    OFFICIAL("OFFICIAL", "公众号"),
     MAIL("MAIL", "邮件消息");
 
     MessageReceiveTypeEnum(String value, String label) {

+ 6 - 7
module-erp/src/main/java/com/hys/app/controller/erp/use/msg/MsgUtilClient.java

@@ -72,9 +72,9 @@ public class MsgUtilClient {
     /**
      * 发公众号
      */
-    public void sendOfficial(String templateCode, AdminUser adminUser, Object... format) {
+    public void sendOfficial(String code, AdminUser adminUser, Object... format) {
         try {
-            SmsMailTemplate one = smsMailManager.getOne(new LambdaQueryWrapper<SmsMailTemplate>().eq(SmsMailTemplate::getTemplateCode, templateCode));
+            SmsMailTemplate one = smsMailManager.getOne(new LambdaQueryWrapper<SmsMailTemplate>().eq(SmsMailTemplate::getTemplateCode, code));
             if (ObjectUtil.isNull(one)) {
                 throw new ServiceException("未找到公众号消息模板");
             }
@@ -83,13 +83,12 @@ public class MsgUtilClient {
             }
             WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
                     .toUser(adminUser.getOpenid())
-                    .templateId(templateCode)
+                    .templateId(one.getTemplateCode())
                     .build();
 
             //"character_string6--{}--#173177"  {}里面就是需要替换的内容
-            String formatContent = StrUtil.format(one.getContent(), format);
-
-            List<String> strings = JSON.parseArray(JSON.toJSONString(formatContent), String.class);
+            String formatContent = StrUtil.format(one.getRemark(), format);
+            String[] strings = formatContent.split(",");
 
             for (String string : strings) {
                 String[] split = string.split("--");
@@ -120,7 +119,7 @@ public class MsgUtilClient {
      * 发短信
      */
     public void sendSms(String templateCode, AdminUser adminUser, Object... format) {
-        SmsMailTemplate one = smsMailManager.getOne(new LambdaQueryWrapper<SmsMailTemplate>().eq(SmsMailTemplate::getTemplateCode, templateCode));
+        SmsMailTemplate one = smsMailManager.getOne(new LambdaQueryWrapper<SmsMailTemplate>().eq(SmsMailTemplate::getCode, templateCode));
         if (ObjectUtil.isNull(one)) {
             throw new ServiceException("未找到短信消息模板");
         }

+ 2 - 0
module-erp/src/main/java/com/hys/app/controller/system/SystemLogsManagerController.java

@@ -1,5 +1,6 @@
 package com.hys.app.controller.system;
 
+import com.hys.app.framework.context.user.AdminUserContext;
 import com.hys.app.framework.database.WebPage;
 import com.hys.app.model.system.dos.SystemLogs;
 import com.hys.app.model.system.dto.SystemLogsParam;
@@ -36,6 +37,7 @@ public class SystemLogsManagerController {
 	@ApiOperation(value = "查询系统日志列表", response = SystemLogs.class)
 	@GetMapping
 	public WebPage<SystemLogs> list(@Valid SystemLogsParam param)	{
+		AdminUserContext.hasSuperAdminQuery(param.getCompanyId());
 		return	this.systemLogsManager.list(param,"admin");
 	}
 

+ 2 - 0
module-erp/src/main/java/com/hys/app/mapper/goods/ProductMapper.java

@@ -1,5 +1,6 @@
 package com.hys.app.mapper.goods;
 
+import com.hys.app.framework.context.user.AdminUserContext;
 import com.hys.app.framework.util.StringUtil;
 import com.hys.app.framework.database.mybatisplus.base.BaseMapperX;
 import com.hys.app.model.erp.dos.ProductDO;
@@ -16,6 +17,7 @@ public interface ProductMapper extends BaseMapperX<ProductDO> {
 
     default WebPage<ProductDO> selectPage(ProductQueryParams params) {
         return lambdaQuery()
+                .eqIfPresent(ProductDO::getCompanyId, AdminUserContext.getCompanyId())
                 .andX(StringUtil.notEmpty(params.getKeyword()),
                         w -> w.like(ProductDO::getName, params.getKeyword()).or())
                 .likeIfPresent(ProductDO::getSku, params.getSku())

+ 1 - 1
module-erp/src/main/java/com/hys/app/model/erp/dos/MessageReceiveDO.java

@@ -34,7 +34,7 @@ public class MessageReceiveDO extends BaseDO implements Serializable {
 
 
     @ApiModelProperty(name = "status", value = "状态")
-    private Boolean status;
+    private Boolean status =false;
 
     private Long userId;
 

+ 1 - 0
module-erp/src/main/java/com/hys/app/model/support/validator/validator/LogAspect.java

@@ -98,6 +98,7 @@ public class LogAspect {
         systemLogs.setOperateIp(StringUtil.getIpAddress());
 //        systemLogs.setParams(StringUtil.arrayToString(args,"&"));
         systemLogs.setMethod(method);
+        systemLogs.setCompanyId(AdminUserContext.getCompanyId());
         systemLogs.setOperateTime(DateUtil.getDateline());
         systemLogs.setOperatorId(operatorId);
         systemLogs.setOperatorName(operatorName);

+ 0 - 1
module-erp/src/main/java/com/hys/app/model/system/dos/AdminUser.java

@@ -102,7 +102,6 @@ public class AdminUser implements Serializable {
     private Long deptId;
 
     @ApiModelProperty(name = "dept_id", value = "是否是部门主管", required = false)
-    @NotNull(message = "是否是部门主管不能为空")
     private Boolean hasDeptManager;
     /**
      * 所属岗位id

+ 3 - 0
module-erp/src/main/java/com/hys/app/model/system/dos/SystemLogs.java

@@ -90,4 +90,7 @@ public class SystemLogs implements Serializable {
 
     @ApiModelProperty(name = "user_id", value = "登录人id")
     private Long userId;
+
+    @ApiModelProperty(name = "user_id", value = "公司id")
+    private Long companyId;
 }

+ 3 - 68
module-erp/src/main/java/com/hys/app/model/system/dto/SystemLogsParam.java

@@ -3,6 +3,7 @@ package com.hys.app.model.system.dto;
 import com.fasterxml.jackson.databind.PropertyNamingStrategy;
 import com.fasterxml.jackson.databind.annotation.JsonNaming;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 /**
  * 系统日志查询条件
@@ -12,6 +13,7 @@ import io.swagger.annotations.ApiModelProperty;
  * 2021-03-22 16:05:59
  */
 @JsonNaming(value = PropertyNamingStrategy.SnakeCaseStrategy.class)
+@Data
 public class SystemLogsParam {
 
     @ApiModelProperty(value = "页码", name = "page_no")
@@ -35,72 +37,5 @@ public class SystemLogsParam {
     @ApiModelProperty(value = "商家id", name = "seller_id", hidden = true)
     private Long sellerId;
 
-    public String getLevel() {
-        return level;
-    }
-
-    public void setLevel(String level) {
-        this.level = level;
-    }
-
-    public Long getPageNo() {
-        return pageNo;
-    }
-
-    public void setPageNo(Long pageNo) {
-        this.pageNo = pageNo;
-    }
-
-    public Long getPageSize() {
-        return pageSize;
-    }
-
-    public void setPageSize(Long pageSize) {
-        this.pageSize = pageSize;
-    }
-
-    public String getKeyword() {
-        return keyword;
-    }
-
-    public void setKeyword(String keyword) {
-        this.keyword = keyword;
-    }
-
-    public Long getStartTime() {
-        return startTime;
-    }
-
-    public void setStartTime(Long startTime) {
-        this.startTime = startTime;
-    }
-
-    public Long getEndTime() {
-        return endTime;
-    }
-
-    public void setEndTime(Long endTime) {
-        this.endTime = endTime;
-    }
-
-    public Long getSellerId() {
-        return sellerId;
-    }
-
-    public void setSellerId(Long sellerId) {
-        this.sellerId = sellerId;
-    }
-
-    @Override
-    public String toString() {
-        return "SystemLogsParam{" +
-                "pageNo=" + pageNo +
-                ", pageSize=" + pageSize +
-                ", keyword='" + keyword + '\'' +
-                ", startTime=" + startTime +
-                ", endTime=" + endTime +
-                ", level='" + level + '\'' +
-                ", sellerId=" + sellerId +
-                '}';
-    }
+    private Long companyId;
 }

+ 20 - 9
module-erp/src/main/java/com/hys/app/model/system/vo/AdminUserVO.java

@@ -26,6 +26,15 @@ public class AdminUserVO {
      */
     @ApiModelProperty(name = "password", value = "管理员密码", required = false)
     private String password;
+
+    public String getFirstPassword() {
+        return firstPassword;
+    }
+
+    public void setFirstPassword(String firstPassword) {
+        this.firstPassword = firstPassword;
+    }
+
     /**
      * 部门
      */
@@ -34,8 +43,8 @@ public class AdminUserVO {
     /**
      * 权限id
      */
-    @Min(message = "权限id必须为数字", value = 0)
-    @NotNull(message = "权限不能为空")
+//    @Min(message = "权限id必须为数字", value = 0)
+//    @NotNull(message = "权限不能为空")
     @ApiModelProperty(name = "role_id", value = "权限id", required = false)
     private Long roleId;
     /**
@@ -58,9 +67,9 @@ public class AdminUserVO {
     /**
      * 是否为超级管理员
      */
-    @Min(message = "必须为数字且,1为超级管理员,0为其他", value = 0)
-    @Max(message = "必须为数字且,1为超级管理员,0为其他", value = 1)
-    @NotNull(message = "是否为超级管理员不能为空")
+//    @Min(message = "必须为数字且,1为超级管理员,0为其他", value = 0)
+//    @Max(message = "必须为数字且,1为超级管理员,0为其他", value = 1)
+//    @NotNull(message = "是否为超级管理员不能为空")
     @ApiModelProperty(name = "founder", value = "是否为超级管理员,1为超级管理员,0为其他", required = false)
     private Integer founder;
 
@@ -73,13 +82,13 @@ public class AdminUserVO {
      * 所属部门id
      */
     @ApiModelProperty(name = "dept_id", value = "所属部门id", required = false)
-    @NotNull(message = "所属部门不能为空")
+//    @NotNull(message = "所属部门不能为空")
     private Long deptId;
     /**
      * 所属部门id
      */
     @ApiModelProperty(name = "dept_id", value = "是否是部门主管", required = false)
-    @NotNull(message = "是否是部门主管不能为空")
+//    @NotNull(message = "是否是部门主管不能为空")
     private Boolean hasDeptManager;
     /**
      * 所属岗位id
@@ -97,13 +106,15 @@ public class AdminUserVO {
 
 
     @ApiModelProperty(name = "email", value = "昵称", required = false)
-    @NotBlank(message = "邮件不能为空")
+//    @NotBlank(message = "邮件不能为空")
     private String email;
 
     @ApiModelProperty(name = "phone", value = "昵称", required = false)
-    @NotBlank(message = "电话不能为空")
+//    @NotBlank(message = "电话不能为空")
     private String phone;
 
+    private String firstPassword;
+
 
     public String getEmail() {
         return email;

+ 5 - 4
module-erp/src/main/java/com/hys/app/service/erp/impl/CompanyErpManagerImpl.java

@@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -143,12 +144,12 @@ public class CompanyErpManagerImpl extends ServiceImpl<CompanyErpMapper, Company
 
 
         //  发消息
-        msgUtilClient.sendSys(MsgContant.CREATE_COMPANY_SYSTEM, adminUser, password, calendar.getTime(),"13127911751");
-        msgUtilClient.sendMail(MsgContant.CREATE_COMPANY_MAIL, adminUser, password, calendar.getTime(),"13127911751");
+        msgUtilClient.sendSys(MsgContant.CREATE_COMPANY_SYSTEM, adminUser, "admin",password, LocalDateTime.now().plusDays(15).format(DateTimeFormatter.ISO_LOCAL_DATE),"13127911751");
+        msgUtilClient.sendMail(MsgContant.CREATE_COMPANY_MAIL, adminUser, "admin",password, LocalDateTime.now().plusDays(15).format(DateTimeFormatter.ISO_LOCAL_DATE),"13127911751");
         //todo 模板没审核通过
-//        msgUtilClient.sendSms(MsgContant.CREATE_COMPANY_SMS, adminUser, password, calendar.getTime(),"13127911751");
+        msgUtilClient.sendSms(MsgContant.CREATE_COMPANY_SMS, adminUser, "admin",password, LocalDateTime.now().plusDays(15).format(DateTimeFormatter.ISO_LOCAL_DATE),"13127911751");
 
-        List<String> companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(convert.getId());
+//        List<String> companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(convert.getId());
 
         return password;
     }

+ 39 - 31
module-erp/src/main/java/com/hys/app/service/system/impl/AdminUserManagerImpl.java

@@ -92,18 +92,19 @@ public class AdminUserManagerImpl implements AdminUserManager {
      * @return AdminUser 平台管理员
      */
     @Override
-    @Transactional(value = "systemTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    @Transactional( propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public AdminUser add(AdminUserVO adminUserVO) {
-        //校验密码格式
-        boolean bool = Pattern.matches("[a-fA-F0-9]{32}", adminUserVO.getPassword());
-        if (!bool) {
-            throw new ServiceException(SystemErrorCode.E917.code(), "密码格式不正确");
-        }
-        DeptDO deptDO = deptMapper.selectById(adminUserVO.getDeptId());
-        if (ObjectUtil.isNull(deptDO)) {
-            throw new ServiceException("部门不存在");
-        }
-        adminUserVO.setRoleId(deptDO.getRoleId());
+//        //校验密码格式
+//        boolean bool = Pattern.matches("[a-fA-F0-9]{32}", adminUserVO.getPassword());
+//        if (!bool) {
+//            throw new ServiceException(SystemErrorCode.E917.code(), "密码格式不正确");
+//        }
+        String psd = adminUserVO.getPassword();
+//        DeptDO deptDO = deptMapper.selectById(adminUserVO.getDeptId());
+//        if (ObjectUtil.isNull(deptDO)) {
+//            throw new ServiceException("部门不存在");
+//        }
+//        adminUserVO.setRoleId(deptDO.getRoleId());
 
         //校验用户名称是否重复
         QueryWrapper<AdminUser> wrapper = new QueryWrapper<>();
@@ -130,22 +131,23 @@ public class AdminUserManagerImpl implements AdminUserManager {
         AdminUser adminUser = new AdminUser();
         adminUser.setCompanyId(company.getId());
         BeanUtil.copyProperties(adminUserVO, adminUser);
-        adminUser.setPassword(StringUtil.md5(password));
+        adminUser.setPassword(StringUtil.md5(adminUserVO.getUsername()+password).toLowerCase());
         adminUser.setDateLine(DateUtil.getDateline());
         adminUser.setUserState(0);
+        adminUser.setFirstPassword(psd);
         adminUser.setFounder(0);
         adminUserMapper.insert(adminUser);
         //发消息
         List<String> companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(adminUser.getCompanyId());
-            msgUtilClient.sendSys(MsgContant.CREATE_USER_SYSTEM, adminUser, adminUser.getUsername(),adminUser.getPassword());
+            msgUtilClient.sendSys(MsgContant.CREATE_USER_SYSTEM, adminUser, adminUser.getUsername(),psd);
         if (companyBandMsg.contains(MsgContant.CREATE_USER_MAIL)){
-            msgUtilClient.sendMail(MsgContant.CREATE_USER_MAIL, adminUser, adminUser.getUsername(),adminUser.getPassword());
+            msgUtilClient.sendMail(MsgContant.CREATE_USER_MAIL, adminUser, adminUser.getUsername(),psd);
         }
         if (companyBandMsg.contains(MsgContant.CREATE_USER_SMS)){
-            msgUtilClient.sendSms(MsgContant.CREATE_USER_SMS, adminUser, adminUser.getUsername(),adminUser.getPassword());
+            msgUtilClient.sendSms(MsgContant.CREATE_USER_SMS, adminUser, adminUser.getUsername(),psd);
         }
         if (companyBandMsg.contains(MsgContant.CREATE_USER_OFFICIAL)){
-            msgUtilClient.sendOfficial(MsgContant.CREATE_USER_OFFICIAL, adminUser, adminUser.getUsername(),adminUser.getPassword());
+            msgUtilClient.sendOfficial(MsgContant.CREATE_USER_OFFICIAL, adminUser, adminUser.getUsername(),psd);
         }
         return adminUser;
     }
@@ -165,11 +167,12 @@ public class AdminUserManagerImpl implements AdminUserManager {
         if (adminUser == null) {
             throw new ResourceNotFoundException("需要修改的账号不存在");
         }
-        if ("admin".equals(adminUser.getUsername()) && !"admin".equals(adminUserVO.getUsername())) {
-            throw new ServiceException("admin 登录名称不允许修改");
-        }
+//        if ("admin".equals(adminUser.getUsername()) && !"admin".equals(adminUserVO.getUsername())) {
+//            throw new ServiceException("admin 登录名称不允许修改");
+//        }
         //管理员原密码
         String password = adminUser.getPassword();
+        String newPassword ;
         //对管理员是否修改密码进行校验
         if (!StringUtil.isEmpty(adminUserVO.getPassword())) {
             boolean bool = Pattern.matches("[a-fA-F0-9]{32}", adminUserVO.getPassword());
@@ -177,26 +180,31 @@ public class AdminUserManagerImpl implements AdminUserManager {
                 throw new ServiceException(SystemErrorCode.E917.code(), "密码格式不正确");
             }
             adminUserVO.setPassword(StringUtil.md5(adminUserVO.getPassword()));
+            adminUserVO.setFirstPassword(adminUserVO.getPassword());
+            newPassword=adminUserVO.getPassword();
         } else {
+            newPassword=adminUser.getFirstPassword();
             adminUserVO.setPassword(password);
         }
         //修改管理员名称
         adminUserVO.setUsername(adminUser.getUsername());
-        BeanUtil.copyProperties(adminUserVO, adminUser);
-        adminUserMapper.updateById(adminUser);
-
         //发消息
-        List<String> companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(adminUser.getCompanyId());
+        List<String> companyBandMsg =new ArrayList<>();
+        if (ObjectUtil.isNotNull(adminUser.getCompanyId())){
+            companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(adminUser.getCompanyId());
+        }
             msgUtilClient.sendSys(MsgContant.UPDATE_USER_SYSTEM, adminUser, adminUser.getUsername(),adminUser.getPassword());
-        if (companyBandMsg.contains(MsgContant.UPDATE_USER_MAIL)){
-            msgUtilClient.sendMail(MsgContant.UPDATE_USER_MAIL, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),adminUser.getPassword());
+        if (companyBandMsg.contains(MsgContant.UPDATE_USER_MAIL) || AdminUserContext.hasFound()){
+            msgUtilClient.sendMail(MsgContant.UPDATE_USER_MAIL, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),newPassword);
         }
-        if (companyBandMsg.contains(MsgContant.UPDATE_USER_SMS)){
-            msgUtilClient.sendSms(MsgContant.UPDATE_USER_SMS, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),adminUser.getPassword());
+        if (companyBandMsg.contains(MsgContant.UPDATE_USER_SMS) || AdminUserContext.hasFound()){
+            msgUtilClient.sendSms(MsgContant.UPDATE_USER_SMS, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),newPassword);
         }
-        if (companyBandMsg.contains(MsgContant.UPDATE_USER_OFFICIAL)){
-            msgUtilClient.sendOfficial(MsgContant.UPDATE_USER_OFFICIAL, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),adminUser.getPassword());
+        if (companyBandMsg.contains(MsgContant.UPDATE_USER_OFFICIAL) || AdminUserContext.hasFound()){
+            msgUtilClient.sendOfficial(MsgContant.UPDATE_USER_OFFICIAL, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),newPassword);
         }
+        BeanUtil.copyProperties(adminUserVO, adminUser);
+        adminUserMapper.updateById(adminUser);
         return adminUser;
     }
 
@@ -207,7 +215,7 @@ public class AdminUserManagerImpl implements AdminUserManager {
      * @param id 平台管理员主键
      */
     @Override
-    @Transactional(value = "systemTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    @Transactional( propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public void delete(Long id) {
         //校验当前管理员是否存在
         AdminUser adminUser = this.getModel(id);
@@ -268,7 +276,7 @@ public class AdminUserManagerImpl implements AdminUserManager {
         //查询管理员信息
         LambdaQueryWrapper<AdminUser> queryWrapper = new LambdaQueryWrapper<AdminUser>()
                 .eq(AdminUser::getUsername, name)
-                .eq(AdminUser::getPassword, password).eq(AdminUser::getUserState, 0);
+                .eq(AdminUser::getPassword, StringUtil.md5(name+password).toLowerCase()).eq(AdminUser::getUserState, 0);
         if ("com".equals(type) && ObjectUtil.isNotNull(companyId)) {
             queryWrapper.eq(AdminUser::getCompanyId, companyId);
         }

+ 3 - 0
module-erp/src/main/java/com/hys/app/service/system/impl/SystemLogsManagerImpl.java

@@ -1,8 +1,10 @@
 package com.hys.app.service.system.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.hys.app.framework.context.user.AdminUserContext;
 import com.hys.app.framework.database.WebPage;
 import com.hys.app.framework.util.PageConvert;
 import com.hys.app.framework.util.StringUtil;
@@ -37,6 +39,7 @@ public class SystemLogsManagerImpl implements SystemLogsManager {
 
         //如果开始时间不为空,则查询操作时间大于等于开始时间的记录
         wrapper.eq("client", client)
+                .eq(ObjectUtil.isNotNull(AdminUserContext.getCompanyId()),"company_id",AdminUserContext.getCompanyId())
                 .eq(param.getLevel() != null, "level", param.getLevel())
                 .ge(param.getStartTime() != null, "operate_time", param.getStartTime())
                 //如果结束时间不为空,则查询操作时间小于等于结束时间的记录