OfficeOpinionApiController.java 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. package com.jpsoft.excellent.modules.open;
  2. import com.github.pagehelper.Page;
  3. import com.jpsoft.excellent.config.OSSConfig;
  4. import com.jpsoft.excellent.modules.base.entity.*;
  5. import com.jpsoft.excellent.modules.base.service.*;
  6. import com.jpsoft.excellent.modules.common.dto.MessageResult;
  7. import com.jpsoft.excellent.modules.common.dto.Sort;
  8. import com.jpsoft.excellent.modules.common.utils.OSSUtil;
  9. import com.jpsoft.excellent.modules.common.utils.SMSUtil;
  10. import com.jpsoft.excellent.modules.sys.entity.DataDictionary;
  11. import com.jpsoft.excellent.modules.sys.entity.SysLog;
  12. import com.jpsoft.excellent.modules.sys.service.DataDictionaryService;
  13. import com.jpsoft.excellent.modules.sys.service.SysLogService;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiImplicitParam;
  16. import io.swagger.annotations.ApiImplicitParams;
  17. import io.swagger.annotations.ApiOperation;
  18. import org.apache.commons.lang3.StringUtils;
  19. import org.slf4j.Logger;
  20. import org.slf4j.LoggerFactory;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.transaction.annotation.Transactional;
  23. import org.springframework.web.bind.annotation.PostMapping;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.ResponseBody;
  26. import org.springframework.web.bind.annotation.RestController;
  27. import sun.misc.BASE64Decoder;
  28. import java.io.ByteArrayInputStream;
  29. import java.text.SimpleDateFormat;
  30. import java.util.*;
  31. @RestController
  32. @RequestMapping("/open/officeOpinionApi")
  33. @Api(description = "移动端")
  34. public class OfficeOpinionApiController {
  35. private Logger logger = LoggerFactory.getLogger(getClass());
  36. @Autowired
  37. private OSSConfig ossConfig;
  38. @Autowired
  39. private SysLogService sysLogService;
  40. @Autowired
  41. private DataDictionaryService dataDictionaryService;
  42. @Autowired
  43. private WorkStationService workStationService;
  44. @Autowired
  45. private WorkWindowService workWindowService;
  46. @Autowired
  47. private OfficeService officeService;
  48. @Autowired
  49. private OfficeOpinionService officeOpinionService;
  50. @Autowired
  51. private AreaService areaService;
  52. @ApiOperation(value="添加反馈信息")
  53. @PostMapping("add")
  54. @Transactional(rollbackFor = Exception.class)
  55. @ApiImplicitParams({
  56. @ApiImplicitParam(name="connect", value="联系人", required=true, paramType="query"),
  57. @ApiImplicitParam(name="connectPhone", value="联系电话", required=true, paramType="query"),
  58. @ApiImplicitParam(name="officeId", value="单位编号", required=true, paramType="query"),
  59. @ApiImplicitParam(name="isSatisfied", value="是否满意", required=true, paramType="query", dataType="Boolean"),
  60. @ApiImplicitParam(name="content", value="内容", paramType="query"),
  61. @ApiImplicitParam(name="appendixs", value="附件", paramType="query"),
  62. })
  63. public MessageResult<OfficeOpinion> add(String connect,String connectPhone,String officeId,String isSatisfied,String content,String[] appendixs){
  64. MessageResult<OfficeOpinion> msgResult = new MessageResult<>();
  65. try {
  66. OfficeOpinion officeOpinion = new OfficeOpinion();
  67. officeOpinion.setId(UUID.randomUUID().toString());
  68. officeOpinion.setConnect(connect);
  69. officeOpinion.setConnectPhone(connectPhone);
  70. officeOpinion.setOfficeId(officeId);
  71. if("0".equals(isSatisfied)) {
  72. officeOpinion.setIsSatisfied(false);
  73. String MessageContent = "【双优督办】干部监督评议有一条投诉,请查收。";
  74. String UserNumber = "13677200818,13647155484";
  75. SMSUtil.sendSMS(MessageContent, UserNumber, null);
  76. }
  77. else{
  78. officeOpinion.setIsSatisfied(true);
  79. }
  80. officeOpinion.setContent(content);
  81. officeOpinion.setAppendix(String.join(",",appendixs));
  82. officeOpinion.setDelFlag(false);
  83. officeOpinion.setCreateTime(new Date());
  84. officeOpinion.setOpinionStatus(false);
  85. officeOpinion.setConfirmStatus(false);
  86. officeOpinionService.insert(officeOpinion);
  87. msgResult.setResult(true);
  88. msgResult.setData(officeOpinion);
  89. }
  90. catch(Exception ex){
  91. logger.error(ex.getMessage(),ex);
  92. msgResult.setResult(false);
  93. msgResult.setMessage(ex.getMessage());
  94. }
  95. return msgResult;
  96. }
  97. @ApiOperation(value="获取单位")
  98. @PostMapping("officeList")
  99. @ApiImplicitParams({
  100. @ApiImplicitParam(name="name", value="单位名", required=true, paramType="query"),
  101. })
  102. public MessageResult officeList(String name){
  103. MessageResult msgResult = new MessageResult<>();
  104. try {
  105. Map<String, Object> searchParams = new HashMap<>();
  106. if (StringUtils.isNotEmpty(name)) {
  107. searchParams.put("name","%" + name + "%");
  108. }
  109. List<Sort> sortList = new ArrayList<>();
  110. sortList.add(new Sort("name_", "asc"));
  111. Page<Office> page = officeService.pageSearch(searchParams, 1, 10000, false, sortList);
  112. msgResult.setResult(true);
  113. msgResult.setData(page.getResult());
  114. }
  115. catch(Exception ex){
  116. logger.error(ex.getMessage(),ex);
  117. msgResult.setResult(false);
  118. msgResult.setMessage(ex.getMessage());
  119. }
  120. return msgResult;
  121. }
  122. @ApiOperation(value="历史记录")
  123. @PostMapping("historyList")
  124. @ApiImplicitParams({
  125. @ApiImplicitParam(name="phone", value="手机号码", required=true, paramType="query"),
  126. })
  127. public MessageResult historyList(String phone){
  128. MessageResult msgResult = new MessageResult<>();
  129. try {
  130. Map<String, Object> searchParams = new HashMap<>();
  131. if (StringUtils.isNotEmpty(phone)) {
  132. searchParams.put("connectPhone",phone);
  133. }
  134. List<Sort> sortList = new ArrayList<>();
  135. sortList.add(new Sort("create_time", "desc"));
  136. Page<OfficeOpinion> page = officeOpinionService.pageSearch(searchParams, 1, 10000, false, sortList);
  137. msgResult.setResult(true);
  138. msgResult.setData(page.getResult());
  139. }
  140. catch(Exception ex){
  141. logger.error(ex.getMessage(),ex);
  142. msgResult.setResult(false);
  143. msgResult.setMessage(ex.getMessage());
  144. }
  145. return msgResult;
  146. }
  147. }