8ecfd4fda8915399b86e0090269bd5fa75cfcf9d.svn-base 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. package cn.com.goldenwater.dcproj.service.impl.tac;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.dao.TacInspYearBatchGroupPersDao;
  4. import cn.com.goldenwater.dcproj.dao.TacWorkerBDao;
  5. import cn.com.goldenwater.dcproj.dto.TacInspYearBatchGroupDto;
  6. import cn.com.goldenwater.dcproj.model.BisInspAllRlation;
  7. import cn.com.goldenwater.dcproj.model.TacInspYearBatchGroupPers;
  8. import cn.com.goldenwater.dcproj.model.TacWorkerB;
  9. import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupPersParam;
  10. import cn.com.goldenwater.dcproj.param.TacWorkerBParam;
  11. import cn.com.goldenwater.dcproj.service.TacInspYearBatchGroupPersService;
  12. import cn.com.goldenwater.dcproj.utils.BeanUtil;
  13. import cn.com.goldenwater.dcproj.utils.DateUtils;
  14. import cn.com.goldenwater.id.util.UuidUtil;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.stereotype.Service;
  20. import org.springframework.transaction.annotation.Transactional;
  21. import java.util.Calendar;
  22. import java.util.Date;
  23. import java.util.List;
  24. import java.util.Map;
  25. /**
  26. * @author lune
  27. * @date 2019-9-6
  28. */
  29. @Service
  30. @Transactional(rollbackFor = Exception.class)
  31. public class TacInspYearBatchGroupPersServiceImpl extends AbstractCrudService<TacInspYearBatchGroupPers, TacInspYearBatchGroupPersParam> implements TacInspYearBatchGroupPersService {
  32. private Logger logger = LoggerFactory.getLogger(getClass());
  33. @Autowired
  34. private TacInspYearBatchGroupPersDao tacInspYearBatchGroupPersDao;
  35. @Autowired
  36. private TacWorkerBDao tacWorkerBDao;
  37. public TacInspYearBatchGroupPersServiceImpl(TacInspYearBatchGroupPersDao tacInspYearBatchGroupPersDao) {
  38. super(tacInspYearBatchGroupPersDao);
  39. this.tacInspYearBatchGroupPersDao = tacInspYearBatchGroupPersDao;
  40. }
  41. @Override
  42. public int updateGroupPers(TacInspYearBatchGroupDto groupDto) {
  43. if (StringUtils.isBlank(groupDto.getGroupId())) {
  44. return 0;
  45. }
  46. if (groupDto.getBs() != null) {
  47. for (TacWorkerB workerB : groupDto.getBs()) {
  48. TacInspYearBatchGroupPersParam groupPersParam = new TacInspYearBatchGroupPersParam();
  49. groupPersParam.setYearBatchId(groupDto.getBatchId());
  50. groupPersParam.setPersId(workerB.getId());
  51. groupPersParam.setRoleType(workerB.getRoleTypeList().get(0).getValue());
  52. List<TacInspYearBatchGroupPers> persList = tacInspYearBatchGroupPersDao.findList(groupPersParam);
  53. if (persList.size() == 1) {
  54. TacInspYearBatchGroupPers pers = persList.get(0);
  55. if (StringUtils.isBlank(pers.getGroupId())) {
  56. pers.setGroupId(groupDto.getGroupId());
  57. pers.setGroupNm(groupDto.getGroupNm());
  58. pers.setSendsmsTm(null);
  59. pers.setIsJoin("0");
  60. pers.setIsNotice("0");
  61. pers.setIsSms("0");
  62. tacInspYearBatchGroupPersDao.update(pers);
  63. } else {
  64. TacInspYearBatchGroupPers newPers = new TacInspYearBatchGroupPers();
  65. BeanUtil.copyObject1(pers, newPers);
  66. newPers.setId(UuidUtil.uuid());
  67. newPers.setInTm(new Date());
  68. newPers.setUpTm(new Date());
  69. newPers.setDataStat("0");
  70. newPers.setGroupId(groupDto.getGroupId());
  71. newPers.setGroupNm(groupDto.getGroupNm());
  72. pers.setIsJoin("0");
  73. pers.setIsNotice("0");
  74. pers.setIsSms("0");
  75. tacInspYearBatchGroupPersDao.insert(newPers);
  76. }
  77. } else {
  78. TacInspYearBatchGroupPers pers = persList.get(0);
  79. TacInspYearBatchGroupPers newPers = new TacInspYearBatchGroupPers();
  80. BeanUtil.copyObject1(pers, newPers);
  81. newPers.setId(UuidUtil.uuid());
  82. newPers.setInTm(new Date());
  83. newPers.setUpTm(new Date());
  84. newPers.setDataStat("0");
  85. newPers.setGroupId(groupDto.getGroupId());
  86. newPers.setGroupNm(groupDto.getGroupNm());
  87. pers.setIsJoin("0");
  88. pers.setIsNotice("0");
  89. pers.setIsSms("0");
  90. tacInspYearBatchGroupPersDao.insert(newPers);
  91. }
  92. }
  93. }
  94. if (groupDto.getUpdateBs() != null) {
  95. for (TacWorkerB workerB : groupDto.getUpdateBs()) {
  96. TacInspYearBatchGroupPersParam groupPersParam = new TacInspYearBatchGroupPersParam();
  97. groupPersParam.setYearBatchId(groupDto.getBatchId());
  98. groupPersParam.setPersId(workerB.getId());
  99. groupPersParam.setRoleType(workerB.getRoleTypeList().get(0).getValue());
  100. List<TacInspYearBatchGroupPers> persList = tacInspYearBatchGroupPersDao.findList(groupPersParam);
  101. if (persList.size() == 1) {
  102. TacInspYearBatchGroupPers pers = persList.get(0);
  103. pers.setGroupId("");
  104. pers.setGroupNm(null);
  105. pers.setSendsmsTm(null);
  106. pers.setIsJoin("0");
  107. pers.setIsNotice("0");
  108. pers.setIsSms("0");
  109. tacInspYearBatchGroupPersDao.update(pers);
  110. }
  111. else if (persList.size() > 1) {
  112. persList.forEach(tacInspYearBatchGroupPers -> {
  113. if (groupDto.getGroupId().equals(tacInspYearBatchGroupPers.getGroupId())) {
  114. tacInspYearBatchGroupPersDao.delete(tacInspYearBatchGroupPers.getId());
  115. }
  116. });
  117. }
  118. }
  119. }
  120. return 0;
  121. }
  122. @Override
  123. public List<BisInspAllRlation> findPersList(TacInspYearBatchGroupPersParam param) {
  124. List<BisInspAllRlation> list = tacInspYearBatchGroupPersDao.findPersList(param);
  125. return list;
  126. }
  127. @Override
  128. public int updateGroupPersInfo(TacInspYearBatchGroupPers group) {
  129. if (StringUtils.isNotBlank(group.getIsJoin())) {
  130. group.setDataStat(group.getIsJoin());
  131. }
  132. tacInspYearBatchGroupPersDao.update(group);
  133. return 1;
  134. }
  135. @Override
  136. public TacInspYearBatchGroupPers getGroupPerByCode(TacInspYearBatchGroupPers group) {
  137. TacWorkerBParam bParam = new TacWorkerBParam();
  138. bParam.setMobilenumb(group.getPhone());
  139. bParam.setProvince(group.getProvince());
  140. TacWorkerB b = tacWorkerBDao.getBy(bParam);
  141. if (b == null) {
  142. return null;
  143. }
  144. TacInspYearBatchGroupPersParam groupPersParam = new TacInspYearBatchGroupPersParam();
  145. groupPersParam.setYearBatchId(group.getYearBatchId());
  146. groupPersParam.setPersId(b.getId());
  147. TacInspYearBatchGroupPers groupPers = tacInspYearBatchGroupPersDao.getBy(groupPersParam);
  148. if (groupPers == null) {
  149. return null;
  150. }
  151. groupPers.setPersName(b.getName());
  152. return groupPers;
  153. }
  154. @Override
  155. public int confirmerGroupPers(Map<String,Object> contentMap) {
  156. TacInspYearBatchGroupPersParam sqlGroupPers= new TacInspYearBatchGroupPersParam();
  157. logger.info("已接收回复");
  158. //满足条件为已通知,已成功发送短信,是否参加为初始默认值
  159. sqlGroupPers.setIsSms("1");
  160. sqlGroupPers.setIsNotice("1");
  161. sqlGroupPers.setIsJoin("0");
  162. sqlGroupPers.setPhone(contentMap.get("phone_number").toString());
  163. //阿里云短信回复无法定位回复的是哪条短信。
  164. //短信回复只能通过回复内容中的电话号码找到最近24小时以内发送短信的电话号码,匹配分组专家的人员数据
  165. Calendar calendar = Calendar.getInstance();
  166. String entm = DateUtils.Calendar2Str(calendar, "yyyy-MM-dd HH:mm:ss");
  167. sqlGroupPers.setEntm(entm);
  168. calendar.add(Calendar.DAY_OF_MONTH, -1);//今天的时间减一天
  169. String sttm = DateUtils.Calendar2Str(calendar, "yyyy-MM-dd HH:mm:ss");
  170. sqlGroupPers.setSttm(sttm);
  171. logger.info("开始时间:" + sttm + "结束时间:" + entm +"开始改变是否参加数据---------");
  172. List<TacInspYearBatchGroupPers> tacInspYearBatchGroupPers = tacInspYearBatchGroupPersDao.confirmerGroupPers(sqlGroupPers);
  173. int update=0;
  174. for (TacInspYearBatchGroupPers tacInspYearBatchGroupPer : tacInspYearBatchGroupPers) {
  175. logger.info("已找到24小时内已通知已发送短信,参加为初始值的人员");
  176. if(StringUtils.isNotBlank(contentMap.get("content").toString())){//回复内容
  177. if("1".equals(contentMap.get("content").toString())){
  178. tacInspYearBatchGroupPer.setIsJoin("1");
  179. update = tacInspYearBatchGroupPersDao.update(tacInspYearBatchGroupPer);
  180. }else{//回复不为1则默认不参加,删除分组人员数据
  181. update = tacInspYearBatchGroupPersDao.deleteGroupPersInfo(tacInspYearBatchGroupPer);
  182. }
  183. }else{//回复内容为空,则默认不参加删除分组人员数据
  184. update = tacInspYearBatchGroupPersDao.deleteGroupPersInfo(tacInspYearBatchGroupPer);
  185. }
  186. }
  187. return update;
  188. }
  189. }