Преглед на файлове

违规登记发送短信

shudonghui преди 1 година
родител
ревизия
6bc59fed90

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/TBViolationResult.java

@@ -29,6 +29,9 @@ public class TBViolationResult extends TBViolation implements Serializable {
     @ApiModelProperty(value = "负责人")
     private String userName;
 
+    @ApiModelProperty(value = "负责人联系方式")
+    private String mobileNumber;
+
     @ApiModelProperty(value = "客户名称")
     private String custom;
 
@@ -88,4 +91,12 @@ public class TBViolationResult extends TBViolation implements Serializable {
     public void setCreateName(String createName) {
         this.createName = createName;
     }
+
+    public String getMobileNumber() {
+        return mobileNumber;
+    }
+
+    public void setMobileNumber(String mobileNumber) {
+        this.mobileNumber = mobileNumber;
+    }
 }

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBViolation.java

@@ -35,6 +35,10 @@ public class TBViolation extends BaseEntity implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long serviceId;
 
+    @ApiModelProperty(value = "编号")
+//    @NotBlank(message = "编号不能为空")
+    private String code;
+
     @ApiModelProperty(value = "负责人id")
     @JsonSerialize(using = ToStringSerializer.class)
     @NotNull(message = "负责人id不能为空")
@@ -118,4 +122,12 @@ public class TBViolation extends BaseEntity implements Serializable {
     public void setAttachmentIds(String attachmentIds) {
         this.attachmentIds = attachmentIds;
     }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
 }

+ 46 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBViolationServiceImpl.java

@@ -1,23 +1,29 @@
 package com.qmth.sop.business.service.impl;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.sop.business.bean.result.TBViolationResult;
+import com.qmth.sop.business.entity.SysMessage;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBViolation;
 import com.qmth.sop.business.mapper.TBViolationMapper;
+import com.qmth.sop.business.service.SequenceService;
+import com.qmth.sop.business.service.SysMessageService;
 import com.qmth.sop.business.service.TBViolationService;
-import com.qmth.sop.common.enums.ExceptionResultEnum;
-import com.qmth.sop.common.enums.FieldUniqueEnum;
-import com.qmth.sop.common.enums.ViolationStatusEnum;
-import com.qmth.sop.common.enums.ViolationTypeEnum;
+import com.qmth.sop.business.util.SmsSendUtil;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.*;
 import com.qmth.sop.common.util.ResultUtil;
 import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 
@@ -33,6 +39,13 @@ import java.util.Objects;
 @Service
 public class TBViolationServiceImpl extends ServiceImpl<TBViolationMapper, TBViolation> implements TBViolationService {
 
+    @Resource
+    SysMessageService sysMessageService;
+    @Resource
+    SmsSendUtil smsSendUtil;
+
+    @Resource
+    SequenceService sequenceService;
 
     /**
      * 查询列表
@@ -44,7 +57,7 @@ public class TBViolationServiceImpl extends ServiceImpl<TBViolationMapper, TBVio
 
     @Override
     public IPage<TBViolationResult> query(IPage<Map> iPage, Long serviceId, ViolationTypeEnum type, ViolationStatusEnum status, Long userId, String custom, String sopNo, Long createId, Long startTime, Long endTime, Long id) {
-        return this.baseMapper.query(iPage,serviceId,Objects.nonNull(type)?type.name():null,Objects.nonNull(status)?status.name():null,userId,custom,sopNo,createId,startTime,endTime,id);
+        return this.baseMapper.query(iPage, serviceId, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(status) ? status.name() : null, userId, custom, sopNo, createId, startTime, endTime, id);
     }
 
     /**
@@ -56,13 +69,39 @@ public class TBViolationServiceImpl extends ServiceImpl<TBViolationMapper, TBVio
     @Transactional
     public Boolean saveTBViolation(TBViolation tBViolation) {
         try {
-            SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+             SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
             if (Objects.isNull(tBViolation.getId())) {// 新增
+                tBViolation.setCode(sequenceService.selectNextVal("violationFlow").toString());
                 tBViolation.insertInfo(sysUser.getId());
+                saveOrUpdate(tBViolation);
+                IPage<TBViolationResult> resultIPage = this.query(new Page<>(1, 1), null, null, null, null, null, null, null, null, null, tBViolation.getId());
+                TBViolationResult tbViolationResult = resultIPage.getRecords().get(0);
+
+//                String content = MessageEnum.NOTICE_OF_VIOLATION_REMIND.getTemplate();
+//                content = content.replaceAll("\\$\\{userName\\}", tbViolationResult.getUserName());
+//                content = content.replaceAll("\\$\\{serviceName\\}", tbViolationResult.getService());
+//                content = content.replaceAll("\\$\\{customName\\}", tbViolationResult.getCustom());
+//                content = content.replaceAll("\\$\\{createUserName\\}", tbViolationResult.getCreateName());
+//                content = content.replaceAll("\\$\\{violationType\\}", tbViolationResult.getType().getTitle());
+
+                String configKey = SystemConstant.SMS_VIOLATION_REMIND_CODE;
+                Map<String, Object> templateParam = new HashMap<>();
+                templateParam.put("userName", tbViolationResult.getUserName());
+                templateParam.put("serviceName", tbViolationResult.getService());
+                templateParam.put("customName", tbViolationResult.getCustom());
+                templateParam.put("createUserName", tbViolationResult.getCreateName());
+                templateParam.put("violationType", tbViolationResult.getType().getTitle());
+
+                SysMessage sysMessage = new SysMessage(tBViolation.getCrmNo(), tBViolation.getCode(),
+                        MessageTypeEnum.VIOLATION, tBViolation.getType().name(), tBViolation.getServiceId(), tBViolation.getUserId(), tBViolation.getContent());
+                sysMessageService.saveSysMessage(Collections.singletonList(sysMessage));
+                //发送短信
+                smsSendUtil.sendSms(tbViolationResult.getMobileNumber(), configKey, templateParam);
             } else { // 修改
                 tBViolation.updateInfo(sysUser.getId());
+                saveOrUpdate(tBViolation);
             }
-            return saveOrUpdate(tBViolation);
+            return true;
         } catch (Exception e) {
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();

+ 6 - 1
sop-business/src/main/resources/db/log/shudonghui_update_log.sql

@@ -226,4 +226,9 @@ INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1043, '考勤明细查询', '/api/admin/tb/ding/attendance/query', 'URL', 1044, 1, 'AUTH', NULL, 1, 1, 0);
 INSERT INTO `sys_privilege` ( `id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display` )
 VALUES
-    ( 1044, '考勤明细查询', 'dingDetail', 'MENU', 24, 1, NULL, '1041,1042,1043', 1, 0, 1 );
+    ( 1044, '考勤明细查询', 'dingDetail', 'MENU', 24, 1, NULL, '1041,1042,1043', 1, 0, 1 );
+
+---20023.8.24
+ALTER TABLE `t_b_violation`
+    ADD COLUMN `code` varchar(200) CHARACTER SET utf8mb4 NOT NULL COMMENT '编号' AFTER `sop_no`;
+INSERT INTO `sop_db`.`sequence` (`name`, `current_value`, `increment`) VALUES ('violationFlow', 0, 1);

+ 1 - 0
sop-business/src/main/resources/mapper/TBViolationMapper.xml

@@ -7,6 +7,7 @@
         a.*,
         s.NAME service,
         u.real_name user_name,
+        u.mobile_number,
         sc.NAME custom,
         sc.type custom_type,
         c.NAME crm_name,

+ 2 - 1
sop-server/src/main/java/com/qmth/sop/server/api/TBViolationController.java

@@ -2,6 +2,7 @@ package com.qmth.sop.server.api;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.result.TBViolationResult;
 import com.qmth.sop.business.entity.TBViolation;
@@ -98,7 +99,7 @@ public class TBViolationController {
     @RequestMapping(value = "/get", method = RequestMethod.GET)
     @ApiResponses({@ApiResponse(code = 200, message = "sop违规登记表信息", response = TBViolationResult.class)})
     public Result get(@ApiParam(value = "sop违规登记表id", required = true) @RequestParam long id) {
-        IPage<TBViolationResult> resultIPage = tBViolationService.query(new Page<>(1, 1), null, null, null, null, null, null, null, null, null, null);
+        IPage<TBViolationResult> resultIPage = tBViolationService.query(new Page<>(1, 1), null, null, null, null, null, null, null, null, null, id);
         return ResultUtil.ok(resultIPage.getRecords().get(0));
     }