|  | @ -19,10 +19,7 @@ import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | import org.springframework.web.client.RestTemplate;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.util.ArrayList;
 | 
	
		
			
				|  |  | import java.util.Date;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | import java.util.UUID;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by wsl on 2022/7/4
 | 
	
	
		
			
				|  | @ -76,12 +73,19 @@ public class ManageSystemPushMessageService {
 | 
	
		
			
				|  |  |      * @param pushDate
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public void addPushMessage(String content, Integer pushObjectType, String pushObjectJson, Integer pushDateType, String pushDate) {
 | 
	
		
			
				|  |  |     public void addPushMessage(String content, Integer pushObjectType, String pushObjectJson, Integer pushDateType, String pushDate,Integer addType,String pushId) {
 | 
	
		
			
				|  |  |         BasePushRecordLogEntity basePushRecordLogEntity = new BasePushRecordLogEntity();
 | 
	
		
			
				|  |  |         List<BasePatientDO> basePatientDOS = null;
 | 
	
		
			
				|  |  |         List<BasePushrecordLogInfoEntity> basePushrecordLogInfoEntityList = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Date date =DateUtil.strToDate(pushDate);
 | 
	
		
			
				|  |  |         if (null!=addType&&addType==2) {
 | 
	
		
			
				|  |  |             BasePushRecordLogEntity one = basePushRecordLogDao.findOne(pushId);
 | 
	
		
			
				|  |  |             if (one.getStatus()!=1) {
 | 
	
		
			
				|  |  |                 basePushRecordLogDao.delete(pushId);
 | 
	
		
			
				|  |  |                 basePushrecordLogInfoDao.deleteByPushId(pushId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //判断发送对象类型  1签约老人  2 部分签约老人
 | 
	
		
			
				|  |  |         if (1 == pushObjectType) {
 | 
	
	
		
			
				|  | @ -95,31 +99,34 @@ public class ManageSystemPushMessageService {
 | 
	
		
			
				|  |  |             basePushRecordLogEntity.setSendObject(s);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Integer status ;
 | 
	
		
			
				|  |  |         //判断 1立即发送   2定时发送
 | 
	
		
			
				|  |  |         if (1==pushDateType) {
 | 
	
		
			
				|  |  |             SystemMessageDOListSave(basePatientDOS,content);
 | 
	
		
			
				|  |  |             basePushRecordLogEntity.setStatus(1);
 | 
	
		
			
				|  |  |             basePushRecordLogEntity.setSendTime(new Date());
 | 
	
		
			
				|  |  |             basePushRecordLogEntity.setPushType("1");
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             //创建定时任务记录
 | 
	
		
			
				|  |  |             basePatientDOS.forEach(logInfoDO->{
 | 
	
		
			
				|  |  |                 String data = content;
 | 
	
		
			
				|  |  |                 if (StringUtils.containsIgnoreCase(content,"【姓名】"))data = data.replace("【姓名】",logInfoDO.getName());
 | 
	
		
			
				|  |  |                 if (StringUtils.containsIgnoreCase(content,"【称谓】"))data = data.replace("【称谓】",logInfoDO.getSex()==1?"大爷":"大妈");
 | 
	
		
			
				|  |  |                 BasePushrecordLogInfoEntity basePushrecordLogInfoEntity = new BasePushrecordLogInfoEntity();
 | 
	
		
			
				|  |  |                 basePushrecordLogInfoEntity.setPatient(logInfoDO.getId());
 | 
	
		
			
				|  |  |                 basePushrecordLogInfoEntity.setPatientName(logInfoDO.getName());
 | 
	
		
			
				|  |  |                 basePushrecordLogInfoEntity.setContent(data);
 | 
	
		
			
				|  |  |                 basePushrecordLogInfoEntity.setStatus(0);
 | 
	
		
			
				|  |  |                 basePushrecordLogInfoEntity.setSendTime(date);
 | 
	
		
			
				|  |  |                 basePushrecordLogInfoEntityList.add(basePushrecordLogInfoEntity);
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |             status = 1;
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             basePushRecordLogEntity.setSendTime(date);
 | 
	
		
			
				|  |  |             basePushRecordLogEntity.setStatus(0);
 | 
	
		
			
				|  |  |             basePushRecordLogEntity.setPushType("2");
 | 
	
		
			
				|  |  |             status = 0;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //创建定时任务记录
 | 
	
		
			
				|  |  |         for (BasePatientDO logInfoDO : basePatientDOS) {
 | 
	
		
			
				|  |  |             String data = content;
 | 
	
		
			
				|  |  |             if (StringUtils.containsIgnoreCase(content,"【姓名】"))data = data.replace("【姓名】",logInfoDO.getName());
 | 
	
		
			
				|  |  |             if (StringUtils.containsIgnoreCase(content,"【称谓】"))data = data.replace("【称谓】",logInfoDO.getSex()==1?"大爷":"大妈");
 | 
	
		
			
				|  |  |             BasePushrecordLogInfoEntity basePushrecordLogInfoEntity = new BasePushrecordLogInfoEntity();
 | 
	
		
			
				|  |  |             basePushrecordLogInfoEntity.setPatient(logInfoDO.getId());
 | 
	
		
			
				|  |  |             basePushrecordLogInfoEntity.setPatientName(logInfoDO.getName());
 | 
	
		
			
				|  |  |             basePushrecordLogInfoEntity.setContent(data);
 | 
	
		
			
				|  |  |             basePushrecordLogInfoEntity.setStatus(status);
 | 
	
		
			
				|  |  |             basePushrecordLogInfoEntity.setSendTime(date);
 | 
	
		
			
				|  |  |             basePushrecordLogInfoEntityList.add(basePushrecordLogInfoEntity);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //日志保存
 | 
	
	
		
			
				|  | @ -173,6 +180,14 @@ public class ManageSystemPushMessageService {
 | 
	
		
			
				|  |  |         Integer count = jdbcTemplate.queryForObject(countSql + filite, Integer.class);
 | 
	
		
			
				|  |  |         result.put("count",count);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (entityList.size()>0) {
 | 
	
		
			
				|  |  |             for (BasePushRecordLogEntity logEntity : entityList) {
 | 
	
		
			
				|  |  |                 String patientListSql = "select patient from base_pushrecord_log_info where push_id = '"+logEntity.getId()+"'";
 | 
	
		
			
				|  |  |                 List<String> list = jdbcTemplate.queryForList(patientListSql, String.class);
 | 
	
		
			
				|  |  |                 logEntity.setPatientList(list);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -207,7 +222,6 @@ public class ManageSystemPushMessageService {
 | 
	
		
			
				|  |  |             messageDOS.add(systemMessageDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         systemMessageDao.save(messageDOS);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 |