Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
46b23fe23a
|
|
@ -3,6 +3,7 @@ package com.bonus.common.core.domain;
|
|||
import com.bonus.common.core.constant.HttpStatus;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
/**
|
||||
* @author : 阮世耀
|
||||
|
|
@ -71,15 +72,34 @@ public final class ResultBean<T> implements java.io.Serializable{
|
|||
/**
|
||||
* 删除/修改/新增操作 根据影响条数返回响应内容
|
||||
*
|
||||
* @param msg 消息
|
||||
* @return 构建的ResultBean实例
|
||||
*/
|
||||
public static <T> ResultBean<T> toIsSuccess(int record, String msg) {
|
||||
// 检查msg是否为null
|
||||
if (msg == null) {
|
||||
if (record > 0) {
|
||||
return new ResultBean<>(HttpStatus.SUCCESS, "success", null);
|
||||
} else {
|
||||
return new ResultBean<>(HttpStatus.NOT_MODIFIED, "资源没有被修改", null);
|
||||
}
|
||||
}
|
||||
return new ResultBean<>(record > 0 ? HttpStatus.SUCCESS : HttpStatus.NOT_MODIFIED, msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除/修改/新增操作 根据影响条数返回响应内容
|
||||
*
|
||||
* @param msg 消息
|
||||
* @param data 数据
|
||||
* @return 构建的ResultBean实例
|
||||
*/
|
||||
public static <T> ResultBean<T> toIsSuccess(int record,T data) {
|
||||
public static <T> ResultBean<T> toIsSuccess(int record, String msg, T data) {
|
||||
// 检查data是否为null
|
||||
if (data == null) {
|
||||
return new ResultBean<>(record > 0 ? HttpStatus.SUCCESS : HttpStatus.NO_CONTENT, "success", null);
|
||||
return new ResultBean<>(record > 0 ? HttpStatus.SUCCESS : HttpStatus.NO_CONTENT, msg, null);
|
||||
}
|
||||
return new ResultBean<>(record > 0 ? HttpStatus.SUCCESS : HttpStatus.NO_CONTENT, "error", data);
|
||||
return new ResultBean<>(record > 0 ? HttpStatus.SUCCESS : HttpStatus.NOT_MODIFIED, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -47,9 +47,8 @@ public class BpmNoticeUserController extends BaseController {
|
|||
* 通知--发起验收
|
||||
*/
|
||||
@PostMapping(value = "/startAccept")
|
||||
public ResultBean<Boolean> startAccept(@RequestBody @Valid NoticeDto noticeDto) {
|
||||
this.bpmNoticeUserService.startAccept(noticeDto);
|
||||
return ResultBean.success(true);
|
||||
public ResultBean<String> startAccept(@RequestBody @Valid NoticeDto noticeDto) {
|
||||
return this.bpmNoticeUserService.startAccept(noticeDto);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.purchase.service.impl;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.bonus.common.core.domain.ResultBean;
|
||||
import com.bonus.common.core.utils.sms.SmsUtils;
|
||||
import com.bonus.purchase.domain.BpmNoticeUser;
|
||||
import com.bonus.purchase.dto.NoticeDto;
|
||||
|
|
@ -11,6 +13,8 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static com.bonus.purchase.utils.Constants.PENDING_ACCEPTANCE;
|
||||
|
||||
/**
|
||||
*@PackagePath: com.bonus.purchase
|
||||
*@author : 阮世耀
|
||||
|
|
@ -30,22 +34,34 @@ public class BpmNoticeUserService{
|
|||
/**
|
||||
* 发起验收
|
||||
*/
|
||||
public int startAccept(NoticeDto noticeDto) {
|
||||
public ResultBean<String> startAccept(NoticeDto noticeDto) {
|
||||
// 1. 拿到DTO中所有的手机号码
|
||||
String[] phoneArray = noticeDto.getPhoneArray();
|
||||
// 2. 根据任务ID查待验收机具信息
|
||||
List<PurchaseAcceptVo> deviceArray = bpmPurchaseInfoMapper.getDetailsList(noticeDto.getTaskId());
|
||||
if (CollectionUtil.isEmpty(deviceArray)) {
|
||||
return ResultBean.error("该任务下没有待验收的机具信息");
|
||||
}
|
||||
// 3. 组装短信发送内容
|
||||
StringBuilder content = new StringBuilder("【机具系统】各位同事您好,机具验收任务已发起,请及时进行机具验收。验收内容如下:");
|
||||
for (PurchaseAcceptVo device : deviceArray) {
|
||||
content.append("机具类型:").append(device.getMaterialName()).append(",机具规格:").append(device.getMaterialModel());
|
||||
if (device == null || device.getPurchaseNum() == null || device.getPurchaseNum() == 0) {
|
||||
continue;
|
||||
}
|
||||
content.append("机具类型:")
|
||||
.append(device.getMaterialName()).append(",规格型号:")
|
||||
.append(device.getMaterialModel())
|
||||
.append(",数量:")
|
||||
.append(Double.valueOf(device.getPurchaseNum()) / 100);
|
||||
}
|
||||
// 4. 遍历数组,调用短信发送业务
|
||||
for (String phone : phoneArray) {
|
||||
// 3. 发送短信
|
||||
SmsUtils.smsToken(phone, content.toString(),"");
|
||||
// 4. 调用工具类发送短信
|
||||
try {
|
||||
SmsUtils.smsToken(String.join(",", phoneArray), String.valueOf(content),"");
|
||||
} catch (Exception e) {
|
||||
System.out.println("新购发起验收短信发送失败:" + e.getMessage());
|
||||
}
|
||||
return 1;
|
||||
// 5. 修改任务状态
|
||||
return ResultBean.toIsSuccess(bpmPurchaseInfoMapper.updateStatusByTaskId(PENDING_ACCEPTANCE, noticeDto.getTaskId()));
|
||||
}
|
||||
|
||||
public int deleteByPrimaryKey(Integer id) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue