通知模块调整

This commit is contained in:
syruan 2024-08-22 16:19:02 +08:00
parent fe6b5da279
commit 94a00eae2c
6 changed files with 102 additions and 16 deletions

View File

@ -3,7 +3,9 @@ import com.bonus.common.core.domain.ResultBean;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.purchase.domain.BpmNoticeUser;
import com.bonus.purchase.dto.NoticeDto;
import com.bonus.purchase.service.impl.BpmNoticeUserService;
import com.bonus.task.service.BpmTaskService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
@ -14,11 +16,11 @@ import java.util.List;
/**
* 短信人员(bpm_notice_user)表控制层
* 新购到货通知业务
* 新购到货通知
* @author 阮世耀
*/
@RestController
@RequestMapping("/notice")
@RequestMapping("/purchase/notice")
public class BpmNoticeUserController extends BaseController {
/**
@ -27,6 +29,9 @@ public class BpmNoticeUserController extends BaseController {
@Autowired
private BpmNoticeUserService bpmNoticeUserService;
@Autowired
private BpmTaskService bpmTaskService;
/**
* 分页查询数据
@ -38,13 +43,23 @@ public class BpmNoticeUserController extends BaseController {
return getDataTable(list);
}
/**
* 通知--发起验收
*/
@PostMapping(value = "/startAccept")
public ResultBean<Boolean> startAccept(@RequestBody @Valid NoticeDto noticeDto) {
this.bpmNoticeUserService.startAccept(noticeDto);
return ResultBean.success(true);
}
/**
* 根据任务ID查询数据
*/
@GetMapping(value = "/listByTaskId/{taskId}")
public ResultBean<Object> getListByTaskId(@PathVariable("taskId") Integer taskId) {
@GetMapping(value = "/getUserList/{taskId}")
public TableDataInfo getListByTaskId(@PathVariable("taskId") Integer taskId) {
startPage();
List<BpmNoticeUser> list = this.bpmNoticeUserService.selectByTaskId(taskId);
return ResultBean.success(list);
return getDataTable(list);
}

View File

@ -0,0 +1,31 @@
package com.bonus.purchase.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.purchase.dto
* @CreateTime: 2024-08-22 15:49
* @Description: 通知DTO
*/
@Data
public class NoticeDto {
@ApiModelProperty(value = "任务ID")
@NotEmpty(message = "任务ID不能为空")
private Integer taskId;
@ApiModelProperty(value = "类型")
private String type;
@ApiModelProperty(value = "用户ID数组")
private Integer[] userIdArray;
@ApiModelProperty(value = "手机号数组")
@NotEmpty(message = "手机号数组不能为空")
private String[] phoneArray;
}

View File

@ -47,6 +47,14 @@ public interface BpmPurchaseInfoMapper {
*/
List<PurchaseAcceptVo> getDetailsList(PurchaseDto record);
/**
* 查询---根据任务ID详情设备列表
*
* @param taskId 任务id
* @return 详情列表
*/
List<PurchaseAcceptVo> getDetailsList(Integer taskId);
/**
* 根据ID查询领用明细
@ -109,7 +117,6 @@ public interface BpmPurchaseInfoMapper {
int updateStatusByTaskIdIn(@Param("updatedStatus") Integer updatedStatus,@Param("taskIdCollection")Collection<Integer> taskIdCollection);
/**
* update record
* @param record the updated record

View File

@ -1,8 +1,12 @@
package com.bonus.purchase.service.impl;
import java.util.List;
import com.bonus.common.core.utils.sms.SmsUtils;
import com.bonus.purchase.domain.BpmNoticeUser;
import com.bonus.purchase.dto.NoticeDto;
import com.bonus.purchase.mapper.BpmNoticeUserMapper;
import com.bonus.purchase.mapper.BpmPurchaseInfoMapper;
import com.bonus.purchase.vo.PurchaseAcceptVo;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,6 +24,29 @@ public class BpmNoticeUserService{
@Autowired
private BpmNoticeUserMapper bpmNoticeUserMapper;
@Autowired
private BpmPurchaseInfoMapper bpmPurchaseInfoMapper;
/**
* 发起验收
*/
public int startAccept(NoticeDto noticeDto) {
// 1. 拿到DTO中所有的手机号码
String[] phoneArray = noticeDto.getPhoneArray();
// 2. 根据任务ID查待验收机具信息
List<PurchaseAcceptVo> deviceArray = bpmPurchaseInfoMapper.getDetailsList(noticeDto.getTaskId());
// 3. 组装短信发送内容
StringBuilder content = new StringBuilder("【机具系统】各位同事您好,机具验收任务已发起,请及时进行机具验收。验收内容如下:");
for (PurchaseAcceptVo device : deviceArray) {
content.append("机具类型:").append(device.getMaterialName()).append(",机具规格:").append(device.getMaterialModel());
}
// 4. 遍历数组调用短信发送业务
for (String phone : phoneArray) {
// 3. 发送短信
SmsUtils.smsToken(phone, content.toString(),"");
}
return 1;
}
public int deleteByPrimaryKey(Integer id) {
return bpmNoticeUserMapper.deleteByPrimaryKey(id);
@ -27,10 +54,14 @@ public class BpmNoticeUserService{
public int insert(BpmNoticeUser record) {
setDefaultType(record);
return bpmNoticeUserMapper.insert(record);
}
private static void setDefaultType(BpmNoticeUser record) {
record.setType("1");
}
public int insertOrUpdate(BpmNoticeUser record) {
return bpmNoticeUserMapper.insertOrUpdate(record);
}
@ -42,7 +73,7 @@ public class BpmNoticeUserService{
public int insertSelective(BpmNoticeUser record) {
record.setType("1");
setDefaultType(record);
return bpmNoticeUserMapper.insertSelective(record);
}
@ -71,9 +102,4 @@ public class BpmNoticeUserService{
}

View File

@ -22,7 +22,6 @@ public class Constants {
*/
public static final Integer PENDING_CONFIRMATION = 48;
/**
* 待通知
*/

View File

@ -2,18 +2,21 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.purchase.mapper.BpmNoticeUserMapper">
<resultMap id="BaseResultMap" type="com.bonus.purchase.domain.BpmNoticeUser">
<!--@mbg.generated-->
<!--@Table bpm_notice_user-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="user_role" jdbcType="VARCHAR" property="userRole" />
<result column="task_id" jdbcType="INTEGER" property="taskId" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="type" jdbcType="VARCHAR" property="type" />
</resultMap>
<sql id="Base_Column_List">
bpm_notice_user.id, bpm_notice_user.user_id, bpm_notice_user.task_id, bpm_notice_user.phone,
bpm_notice_user.`type`
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
@ -194,8 +197,13 @@
<!--by syruan on 2024-08-20-->
<select id="selectByTaskId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
<include refid="Base_Column_List"/>,
sys_user.user_name,
sys_role.role_name as user_role
from bpm_notice_user
left join sys_user on bpm_notice_user.user_id = sys_user.user_id
left join sys_user_role on sys_user.user_id = sys_user_role.user_id
left join sys_role on sys_user_role.role_id = sys_role.role_id
where bpm_notice_user.task_id = #{taskId,jdbcType=INTEGER}
</select>
</mapper>