68004f529e4b146fbaeec664072cce8969bff136.svn-base 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package cn.com.goldenwater.dcproj.service.impl.tac;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.dao.TacEvalationInformDao;
  4. import cn.com.goldenwater.dcproj.dao.TacInspYearBatchGroupPersDao;
  5. import cn.com.goldenwater.dcproj.dto.TacEvalationInformDto;
  6. import cn.com.goldenwater.dcproj.dto.TacEvalationInformMessageDto;
  7. import cn.com.goldenwater.dcproj.model.TacEvalationInform;
  8. import cn.com.goldenwater.dcproj.model.TacInspYearBatchGroupPers;
  9. import cn.com.goldenwater.dcproj.param.TacEvalationInformParam;
  10. import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupPersParam;
  11. import cn.com.goldenwater.dcproj.service.TacEvalationInformService;
  12. import cn.com.goldenwater.dcproj.utils.HttpClientUtils;
  13. import cn.com.goldenwater.id.util.UuidUtil;
  14. import com.github.pagehelper.PageHelper;
  15. import com.github.pagehelper.PageInfo;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.stereotype.Service;
  18. import org.springframework.transaction.annotation.Transactional;
  19. import java.text.SimpleDateFormat;
  20. import java.util.Date;
  21. import java.util.HashMap;
  22. import java.util.List;
  23. import java.util.Map;
  24. /**
  25. * @author lune
  26. * @date 2019-11-12
  27. */
  28. @Service
  29. @Transactional
  30. public class TacEvalationInformServiceImpl extends AbstractCrudService<TacEvalationInform, TacEvalationInformParam> implements TacEvalationInformService {
  31. @Autowired
  32. private TacEvalationInformDao tacEvalationInformDao;
  33. @Autowired
  34. private TacInspYearBatchGroupPersDao tacInspYearBatchGroupPersDao;
  35. private static String apiKey = "1036432406699048960";
  36. private static String apiSecrect = "bbSsX1wvmaKdca5x2+yBDgeFtl9hj4zJmnegunWuLuHLwLo+QjxOr3//P4BJNrVADa7tN4w0DX1KS/VSec5G0x+ucDeAcSt9tWgFGyoBVtblybh+vzLbwH4sJa92hQfu\n";
  37. public TacEvalationInformServiceImpl(TacEvalationInformDao tacEvalationInformDao) {
  38. super(tacEvalationInformDao);
  39. this.tacEvalationInformDao = tacEvalationInformDao;
  40. }
  41. @Override
  42. public List<TacEvalationInformDto> getInformList(TacEvalationInformParam tacEvalationInformParam) {
  43. if ("1".equals(tacEvalationInformParam.getType())) {
  44. tacEvalationInformParam.setNotRoleType("'11','12','13','14','15','16'");
  45. } else if ("2".equals(tacEvalationInformParam.getType())) {
  46. tacEvalationInformParam.setNotRoleType("'19'");
  47. }
  48. List<TacEvalationInformDto> list = tacEvalationInformDao.getInformList(tacEvalationInformParam);
  49. return list;
  50. }
  51. @Override
  52. public int sendMessage(TacEvalationInformMessageDto dto) {
  53. if (dto.getDtoList() == null) {
  54. return 0;
  55. }
  56. String apiUrl = "http://10.1.198.101/gateway/api/sms/send";
  57. Map<String, String> params = new HashMap<String, String>();
  58. params.put("apiKey", apiKey);
  59. params.put("apiSecrect", apiSecrect);
  60. params.put("signName", "金水云平台");
  61. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  62. dto.getDtoList().forEach(informDto -> {
  63. params.put("mobile", informDto.getMobilenumb());
  64. if ("1".equals(dto.getType())) {
  65. params.put("templeteCode", "SMS_177536270");
  66. params.put("templateParam", "{\"name\":\"" + informDto.getName() + "\",\"number\":\""+ informDto.getBatches() + "\",\"date\":\"" + dateFormat.format(dto.getCutTime()) +"\"}");
  67. } else if ("2".equals(dto.getType())) {
  68. params.put("templeteCode", "SMS_177541310");
  69. params.put("templateParam", "{\"name\":\"" + informDto.getName() + "\",\"date\":\"" + dateFormat.format(dto.getCutTime()) +"\"}");
  70. }
  71. try {
  72. HttpClientUtils.simplePostInvoke(apiUrl+"/gateway/api/sms/send", params);
  73. } catch (Exception e) {
  74. }
  75. if (informDto.getCount() != null && informDto.getCount() != 0) {
  76. TacEvalationInformParam tacEvalationInformParam = new TacEvalationInformParam();
  77. tacEvalationInformParam.setYear(dto.getYear());
  78. tacEvalationInformParam.setType(dto.getType());
  79. tacEvalationInformParam.setPersId(informDto.getId());
  80. TacEvalationInform inform = tacEvalationInformDao.getBy(tacEvalationInformParam);
  81. inform.setInformNum(inform.getInformNum() + 1);
  82. inform.setCutTm(dto.getCutTime());
  83. inform.setUpTm(new Date());
  84. tacEvalationInformDao.update(inform);
  85. } else {
  86. TacEvalationInform inform = new TacEvalationInform();
  87. inform.setId(UuidUtil.uuid());
  88. inform.setType(dto.getType());
  89. inform.setYear(dto.getYear());
  90. inform.setBatch(dto.getBatch());
  91. inform.setCutTm(dto.getCutTime());
  92. inform.setZolPersId(informDto.getId());
  93. inform.setInformNum(new Long(1));
  94. inform.setInTm(new Date());
  95. inform.setUpTm(new Date());
  96. inform.setPersId(dto.getPersId());
  97. tacEvalationInformDao.insert(inform);
  98. }
  99. });
  100. return 0;
  101. }
  102. @Override
  103. public PageInfo<TacEvalationInformDto> getInformPage(TacEvalationInformParam tacEvalationInformParam) {
  104. PageHelper.startPage(tacEvalationInformParam);
  105. if ("1".equals(tacEvalationInformParam.getType())) {
  106. tacEvalationInformParam.setNotRoleType("'11','12','13','14','15','16'");
  107. } else if ("2".equals(tacEvalationInformParam.getType())) {
  108. tacEvalationInformParam.setNotRoleType("'19'");
  109. }
  110. List<TacEvalationInformDto> list = tacEvalationInformDao.getInformList(tacEvalationInformParam);
  111. if (list.size() > 0) {
  112. list.forEach(dto -> {
  113. TacInspYearBatchGroupPersParam persParam = new TacInspYearBatchGroupPersParam();
  114. persParam.setYear(tacEvalationInformParam.getYear());
  115. persParam.setPersId(dto.getId());
  116. List<TacInspYearBatchGroupPers> groupPersList = tacInspYearBatchGroupPersDao.findList(persParam);
  117. if (groupPersList.size() > 0) {
  118. dto.setBatches(getBatches(groupPersList));
  119. }
  120. });
  121. }
  122. PageInfo<TacEvalationInformDto> pageInfo = new PageInfo<>(list);
  123. return pageInfo;
  124. }
  125. private String getBatches(List<TacInspYearBatchGroupPers> groupPersList) {
  126. StringBuffer sb = new StringBuffer("");
  127. groupPersList.forEach(tacInspYearBatchGroupPers -> {
  128. sb.append(tacInspYearBatchGroupPers.getBatch()).append(",");
  129. });
  130. if (sb.length() > 0) {
  131. return sb.substring(0, sb.length() - 1);
  132. }
  133. return "";
  134. }
  135. }