|
|
|
@ -10,10 +10,13 @@ import com.foreverwin.mesnac.anomaly.service.AbnormalMessageService;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.service.AnomalyJobService;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.util.ActiveMQUtil;
|
|
|
|
|
import com.foreverwin.mesnac.common.util.StringUtil;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.mapper.UserGroupMapper;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.NwaUser;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.service.NwaUserService;
|
|
|
|
|
import com.foreverwin.modular.core.util.CommonMethods;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -24,6 +27,8 @@ import java.util.UUID;
|
|
|
|
|
* @Author zhaojiawei
|
|
|
|
|
* @Since 2021-07-22
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@ -44,6 +49,10 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private NwaUserService nwaUserService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserGroupMapper userGroupMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void anomalyJobProcess(String site) {
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
@ -51,7 +60,7 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
//找到状态为N,并且升级时间大于当前时间
|
|
|
|
|
QueryWrapper<AbnormalMessage> abnormalMessageQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
abnormalMessageQueryWrapper.eq("STATUS","N");
|
|
|
|
|
abnormalMessageQueryWrapper.gt("UP_DATE_TIME",now);
|
|
|
|
|
abnormalMessageQueryWrapper.lt("UP_DATE_TIME",now);
|
|
|
|
|
List<AbnormalMessage> abnormalMessages = abnormalMessageMapper.selectList(abnormalMessageQueryWrapper);
|
|
|
|
|
for(AbnormalMessage _abnormalMessage : abnormalMessages){
|
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
@ -59,7 +68,7 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
//设置abnormalMessage的handle
|
|
|
|
|
abnormalMessage.setHandle(uuid);
|
|
|
|
|
//设置abnormalMessage的site
|
|
|
|
|
abnormalMessage.setSite(_abnormalMessage.getSite());
|
|
|
|
|
abnormalMessage.setSite(site);
|
|
|
|
|
//设置abnormalMessage的异常单Bo
|
|
|
|
|
abnormalMessage.setAbnormalBillBo(_abnormalMessage.getAbnormalBillBo());
|
|
|
|
|
//设置abnormalMessage的type
|
|
|
|
@ -69,14 +78,14 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
//设置发送用户组和升级用户组
|
|
|
|
|
if(!StringUtil.isBlank(_abnormalMessage.getUpUserGroup())){
|
|
|
|
|
//当前发送用户组就等于升级用户组,升级用户组就等于空
|
|
|
|
|
abnormalMessage.setSendUserGroup(abnormalMessage.getUpUserGroup());
|
|
|
|
|
abnormalMessage.setSendUserGroup(_abnormalMessage.getUpUserGroup());
|
|
|
|
|
abnormalMessage.setUpUserGroup(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置发送用户和升级用户
|
|
|
|
|
if(!StringUtil.isBlank(abnormalMessage.getUpUser())){
|
|
|
|
|
if(!StringUtil.isBlank(_abnormalMessage.getUpUser())){
|
|
|
|
|
//当前发送用户就等于升级用户,升级用户就等于空
|
|
|
|
|
abnormalMessage.setSendUser(abnormalMessage.getUpUser());
|
|
|
|
|
abnormalMessage.setSendUser(_abnormalMessage.getUpUser());
|
|
|
|
|
abnormalMessage.setUpUser(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -84,16 +93,17 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
|
|
|
|
|
String message = abnormalBillService.formatMessage(abnormalBill,abnormalMessage.getMessageType(),site);
|
|
|
|
|
|
|
|
|
|
abnormalMessage.setContent(message);
|
|
|
|
|
abnormalMessage.setContent(message+",It's Job send");
|
|
|
|
|
|
|
|
|
|
//设置UP_DATE_TIME、UP_MESSAGE_TYPE、GRADE、RESPONSE_DATE_TIME、ABNORMAL_NODE、STATUS
|
|
|
|
|
abnormalMessage.setUpMessageType(null);
|
|
|
|
|
abnormalMessage.setUpDateTime(null);
|
|
|
|
|
|
|
|
|
|
abnormalMessage.setGrade(abnormalMessage.getGrade() + 1);
|
|
|
|
|
abnormalMessage.setGrade(_abnormalMessage.getGrade() + 1);
|
|
|
|
|
abnormalMessage.setResponseDateTime(now);
|
|
|
|
|
abnormalMessage.setAbnormalNode(_abnormalMessage.getAbnormalNode());
|
|
|
|
|
abnormalMessage.setStatus("Y");
|
|
|
|
|
_abnormalMessage.setStatus("Y");
|
|
|
|
|
|
|
|
|
|
//设置时间
|
|
|
|
|
abnormalMessage.setCreatedUser(user);
|
|
|
|
@ -105,7 +115,9 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
// String sendUsers = abnormalMessage.getSendUser().replace(',', '|');
|
|
|
|
|
// activeMQUtil.wechatSendMessage(sendUsers,abnormalMessage.getContent());
|
|
|
|
|
// }else if(!Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getAbnormalNode())){
|
|
|
|
|
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(abnormalMessage.getSendUserGroup());
|
|
|
|
|
//判断是否有该用户组
|
|
|
|
|
|
|
|
|
|
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup());
|
|
|
|
|
StringBuilder sendUsers = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < nwaUsers.size(); i++) {
|
|
|
|
|
if(i == (nwaUsers.size() - 1)){
|
|
|
|
@ -117,6 +129,7 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
activeMQUtil.wechatSendMessage(sendUsers.toString(),abnormalMessage.getContent());
|
|
|
|
|
// }
|
|
|
|
|
abnormalMessageService.saveOrUpdate(abnormalMessage);
|
|
|
|
|
abnormalMessageService.saveOrUpdate(_abnormalMessage);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|