代码备份
package com.huajun.event.service.impl; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; import com.huajun.system.api.RemoteSmsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.huajun.event.mapper.EvnConsultationArrangeMapper; import com.huajun.event.domain.EvnConsultationArrange; import com.huajun.event.service.IEvnConsultationArrangeService; import org.springframework.transaction.annotation.Transactional; import com.huajun.system.api.domain.SysSms; /** * 会商安排Service业务层处理 * * @author 于吉利 * @date 2021-06-08 */ @Service public class EvnConsultationArrangeServiceImpl extends ServiceImpl<EvnConsultationArrangeMapper, EvnConsultationArrange> implements IEvnConsultationArrangeService { @Autowired private EvnConsultationArrangeMapper evnConsultationArrangeMapper; @Autowired RemoteSmsService remoteSmsService; /** * 查询会商安排列表 * * @param evnConsultationArrange 会商安排 * @return 会商安排 */ @Override public List<EvnConsultationArrange> selectEvnConsultationArrangeList(EvnConsultationArrange evnConsultationArrange) { return evnConsultationArrangeMapper.selectEvnConsultationArrangeList(evnConsultationArrange); } /** * 重写mybatis plus save 方法 * 2021-06-09 * * @param entity * @return */ @Override @Transactional public boolean save(EvnConsultationArrange entity) { super.save(entity); if (entity.getArrangeState().equals("2"))//草稿1,进行中2,完成3,进行发送短信操作 { Collection collectionSms = new ArrayList<>(); String receiverNames = entity.getArrangeReceivernames();//得到短信接收人姓名 String receiverPhoness = entity.getArrangeReceiverphones();//得到短信接收人手机 String[] phonesArray = receiverPhoness.split(","); String[] namesArray = receiverNames.split(","); for (int i = 0; i < namesArray.length; i++) { String phone= phonesArray[i]; String name = namesArray[i]; SysSms sysSms = new SysSms(); sysSms.setBusinessId(entity.getId());//业务主键 sysSms.setMessageContent(entity.getArrangeSmscontent());//短信内容 sysSms.setMessageReceiver(phone);//接收人电话 sysSms.setMessageTitle(name);//接收人 sysSms.setMessageType("2");//短信消息 sysSms.setMessageState("0");//未发送 sysSms.setMessageSender(entity.getCreateBy());//发送人 sysSms.setMessageSendtime(new Date()); collectionSms.add(sysSms); } remoteSmsService.addBatchSms(collectionSms); } return true; } /** * 重写mybatis plus updateById 方法 * 2021-06-09 * * @param entity * @return */ @Override @Transactional public boolean updateById(EvnConsultationArrange entity) { super.updateById(entity); if (entity.getArrangeState().equals("2"))//草稿1,进行中2,完成3,进行发送短信操作 { Collection collectionSms = new ArrayList<>(); String receiverNames = entity.getArrangeReceivernames();//得到短信接收人姓名 String receiverPhoness = entity.getArrangeReceiverphones();//得到短信接收人手机 String[] phonesArray = receiverPhoness.split(","); String[] namesArray = receiverNames.split(","); for (int i = 0; i < namesArray.length; i++) { String phone= phonesArray[i]; String name = namesArray[i]; SysSms sysSms = new SysSms(); sysSms.setBusinessId(entity.getId());//业务主键 sysSms.setMessageContent(entity.getArrangeSmscontent());//短信内容 sysSms.setMessageReceiver(phone);//接收人电话 sysSms.setMessageTitle(name);//接收人 sysSms.setMessageType("2");//短信消息 sysSms.setMessageState("0");//未发送 sysSms.setMessageSender(entity.getCreateBy());//发送人 sysSms.setMessageSendtime(new Date()); collectionSms.add(sysSms); } remoteSmsService.addBatchSms(collectionSms); } return true; } }