55221073bb56411c7e1737b3c924d2db2eb74050.svn-base 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. package cn.com.goldenwater.dcproj.controller.tac;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.constValue.SmsCodeEnum;
  5. import cn.com.goldenwater.dcproj.dto.TacInspYearBatchGroupDto;
  6. import cn.com.goldenwater.dcproj.dto.TacInspYearBatchGroupExportDto;
  7. import cn.com.goldenwater.dcproj.model.TacInspYearBatchArea;
  8. import cn.com.goldenwater.dcproj.model.TacInspYearBatchGroup;
  9. import cn.com.goldenwater.dcproj.model.TacInspYearBatchObj;
  10. import cn.com.goldenwater.dcproj.model.TacWorkerB;
  11. import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupParam;
  12. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  13. import cn.com.goldenwater.dcproj.service.TacInspYearBatchGroupService;
  14. import cn.com.goldenwater.dcproj.utils.expExcel.ExportUtil;
  15. import cn.com.goldenwater.id.util.UuidUtil;
  16. import com.github.pagehelper.PageInfo;
  17. import io.swagger.annotations.Api;
  18. import io.swagger.annotations.ApiOperation;
  19. import io.swagger.annotations.ApiParam;
  20. import org.apache.commons.lang3.StringUtils;
  21. import org.slf4j.Logger;
  22. import org.slf4j.LoggerFactory;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.web.bind.annotation.PathVariable;
  25. import org.springframework.web.bind.annotation.RequestBody;
  26. import org.springframework.web.bind.annotation.RequestMapping;
  27. import org.springframework.web.bind.annotation.RequestMethod;
  28. import org.springframework.web.bind.annotation.RestController;
  29. import javax.servlet.http.HttpServletResponse;
  30. import java.time.LocalDateTime;
  31. import java.util.ArrayList;
  32. import java.util.Calendar;
  33. import java.util.Date;
  34. import java.util.List;
  35. /**
  36. * @author lune
  37. * @date 2019-9-6
  38. */
  39. @Api(value = "TAC 稽察年度批次稽察组表管理", tags = "TAC 稽察年度批次稽察组表管理")
  40. @RestController
  41. @RequestMapping("/tac/insp/year/batch/group")
  42. public class TacInspYearBatchGroupController extends BaseController {
  43. private Logger logger = LoggerFactory.getLogger(getClass());
  44. @Autowired
  45. private TacInspYearBatchGroupService tacInspYearBatchGroupService;
  46. @Autowired
  47. private OlBisInspOrgService olBisInspOrgService;
  48. @ApiOperation(value = "添加/修改稽察年度批次稽察组表")
  49. @RequestMapping(value = "", method = RequestMethod.POST)
  50. public BaseResponse<TacInspYearBatchGroup> insert(@ApiParam(name = "tacInspYearBatchGroup", value = "TacInspYearBatchGroup", required = true) @RequestBody TacInspYearBatchGroup tacInspYearBatchGroup) {
  51. if (StringUtils.isBlank(tacInspYearBatchGroup.getId())) {
  52. String uuid = UuidUtil.uuid(); // 生成uuid
  53. tacInspYearBatchGroup.setId(uuid);
  54. tacInspYearBatchGroupService.insert(tacInspYearBatchGroup);
  55. } else {
  56. tacInspYearBatchGroupService.update(tacInspYearBatchGroup);
  57. }
  58. return buildSuccessResponse(tacInspYearBatchGroup);
  59. }
  60. @ApiOperation(value = "根据ID删除稽察年度批次稽察组表")
  61. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  62. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  63. int ret = tacInspYearBatchGroupService.deleteGroupById(id, olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  64. return buildSuccessResponse();
  65. }
  66. @ApiOperation(value = "删除督查组")
  67. @RequestMapping(value = "/deleteGroupList", method = RequestMethod.POST)
  68. public BaseResponse deleteGroupList(@RequestBody TacInspYearBatchGroupDto dto) {
  69. dto.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  70. int a = tacInspYearBatchGroupService.deleteGroupList(dto);
  71. return buildSuccessResponse(a);
  72. }
  73. @ApiOperation(value = "修改督查组区域列表")
  74. @RequestMapping(value = "/updateGroupArea", method = RequestMethod.POST)
  75. public BaseResponse<TacInspYearBatchGroup> updateGroupArea(@RequestBody TacInspYearBatchGroup group) {
  76. group.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  77. int a = tacInspYearBatchGroupService.updateGroupArea(group);
  78. return buildSuccessResponse(group);
  79. }
  80. @ApiOperation(value = "根据ID获取稽察年度批次稽察组表(单表)")
  81. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  82. public BaseResponse<TacInspYearBatchGroup> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  83. TacInspYearBatchGroup tacInspYearBatchGroup = tacInspYearBatchGroupService.get(id);
  84. return buildSuccessResponse(tacInspYearBatchGroup);
  85. }
  86. @ApiOperation(value = "根据ID获取稽察年度批次稽察组表")
  87. @RequestMapping(value = "/getGroupById/{id}", method = RequestMethod.GET)
  88. public BaseResponse<TacInspYearBatchGroup> getGroupById(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  89. TacInspYearBatchGroup tacInspYearBatchGroup = tacInspYearBatchGroupService.getGroupById(id, olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  90. return buildSuccessResponse(tacInspYearBatchGroup);
  91. }
  92. @ApiOperation(value = "获取稽察年度批次稽察组表(列表所有)")
  93. @RequestMapping(value = "/list", method = RequestMethod.POST)
  94. public BaseResponse<List<TacInspYearBatchGroup>> list(@ApiParam(name = "tacInspYearBatchGroupParam", value = "tacInspYearBatchGroupParam", required = true) @RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
  95. tacInspYearBatchGroupParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  96. List<TacInspYearBatchGroup> tacInspYearBatchGroupList = tacInspYearBatchGroupService.findList(tacInspYearBatchGroupParam);
  97. return buildSuccessResponse(tacInspYearBatchGroupList);
  98. }
  99. @ApiOperation(value = "获取稽察年度批次稽察组表(列表--分页)")
  100. @RequestMapping(value = "/page", method = RequestMethod.POST)
  101. public BaseResponse<PageInfo<TacInspYearBatchGroup>> page(@ApiParam(name = "tacInspYearBatchGroupParam", value = "tacInspYearBatchGroupParam", required = true) @RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
  102. tacInspYearBatchGroupParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  103. PageInfo<TacInspYearBatchGroup> tacInspYearBatchGroupList = tacInspYearBatchGroupService.findPageInfo(tacInspYearBatchGroupParam);
  104. return buildSuccessResponse(tacInspYearBatchGroupList);
  105. }
  106. @ApiOperation(value = "保存督查组")
  107. @RequestMapping(value = "/insertGroupList", method = RequestMethod.POST)
  108. public BaseResponse insertGroupList(TacInspYearBatchGroupDto groupDto) {
  109. groupDto.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  110. int a = this.tacInspYearBatchGroupService.insertGroupList(groupDto);
  111. return buildSuccessResponse();
  112. }
  113. @ApiOperation(value = "获取组列表")
  114. @RequestMapping(value = "/getGroupList", method = RequestMethod.POST)
  115. public BaseResponse<List<TacInspYearBatchGroup>> getGroupList(@RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam, HttpServletResponse response) {
  116. tacInspYearBatchGroupParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  117. List<TacInspYearBatchGroup> list = tacInspYearBatchGroupService.getGroupList(tacInspYearBatchGroupParam);
  118. if ("1".equals(tacInspYearBatchGroupParam.getIsExport())) {
  119. List<TacInspYearBatchGroupExportDto> dtoList = new ArrayList<TacInspYearBatchGroupExportDto>(list.size());
  120. List<String> columns = new ArrayList<>();
  121. columns.add("orgId");
  122. columns.add("province");
  123. columns.add("rgstrId");
  124. columns.add("groupId");
  125. columns.add("objId");
  126. if (list.size() > 0) {
  127. for(TacInspYearBatchGroup group: list){
  128. TacInspYearBatchGroupExportDto dto = new TacInspYearBatchGroupExportDto();
  129. dto.setYear(group.getYear());
  130. dto.setBatch(group.getBatch());
  131. dto.setGroupNm(group.getGroupNm());
  132. dto.setSttm(convertDateToLocalDateTime(group.getStTm()));
  133. dto.setEntm(convertDateToLocalDateTime(group.getEnTm()));
  134. String areas = "";
  135. if(group.getAreaList() != null && group.getAreaList().size() > 0){
  136. for (TacInspYearBatchArea area : group.getAreaList()) {
  137. areas = area.getAdName() + "," + areas;
  138. }
  139. if (areas.length() > 0) {
  140. areas = areas.substring(0, areas.lastIndexOf(","));
  141. }
  142. }
  143. dto.setAreas(areas);
  144. String objNms = "";
  145. String types = "";
  146. if(group.getObjList() != null && group.getObjList().size() > 0){
  147. for (TacInspYearBatchObj batchObj : group.getObjList()) {
  148. objNms = batchObj.getOjbNm() + "," + objNms;
  149. types = batchObj.getType() + "," + types;
  150. }
  151. if (objNms.length() > 0) {
  152. objNms = objNms.substring(0, objNms.lastIndexOf(","));
  153. types = types.substring(0, types.lastIndexOf(","));
  154. }
  155. }
  156. dto.setObjNms(objNms);
  157. dto.setTypes(types);
  158. String worker20s = "";
  159. String worker19s = "";
  160. String worker11s = "";
  161. String worker12s = "";
  162. String worker13s = "";
  163. String worker14s = "";
  164. String worker15s = "";
  165. String worker16s = "";
  166. if (group.getWorkersList() != null && group.getWorkersList().size() > 0) {
  167. for (TacWorkerB b : group.getWorkersList()) {
  168. String roleType = b.getRoleType();
  169. if("20".equals(roleType)){
  170. worker20s = b.getName() + "," + worker20s;
  171. }else if("19".equals(roleType)){
  172. worker19s = b.getName() + "," + worker19s;
  173. }else if("11".equals(roleType)){
  174. worker11s = b.getName() + "," + worker11s;
  175. }else if("12".equals(roleType)){
  176. worker12s = b.getName() + "," + worker12s;
  177. }else if("13".equals(roleType)){
  178. worker13s = b.getName() + "," + worker13s;
  179. }else if("14".equals(roleType)){
  180. worker14s = b.getName() + "," + worker14s;
  181. }else if("15".equals(roleType)){
  182. worker15s = b.getName() + "," + worker15s;
  183. }else if("16".equals(roleType)){
  184. worker16s = b.getName() + "," + worker16s;
  185. }
  186. }
  187. if (worker20s.length() > 0) {
  188. worker20s = worker20s.substring(0, worker20s.lastIndexOf(","));
  189. }
  190. if (worker19s.length() > 0) {
  191. worker19s = worker19s.substring(0, worker19s.lastIndexOf(","));
  192. }
  193. if (worker11s.length() > 0) {
  194. worker11s = worker11s.substring(0, worker11s.lastIndexOf(","));
  195. }
  196. if (worker12s.length() > 0) {
  197. worker12s = worker12s.substring(0, worker12s.lastIndexOf(","));
  198. }
  199. if (worker13s.length() > 0) {
  200. worker13s = worker13s.substring(0, worker13s.lastIndexOf(","));
  201. }
  202. if (worker14s.length() > 0) {
  203. worker14s = worker14s.substring(0, worker14s.lastIndexOf(","));
  204. }
  205. if (worker15s.length() > 0) {
  206. worker15s = worker15s.substring(0, worker15s.lastIndexOf(","));
  207. }
  208. if (worker16s.length() > 0) {
  209. worker16s = worker16s.substring(0, worker16s.lastIndexOf(","));
  210. }
  211. }
  212. dto.setWorker20(worker20s);
  213. dto.setWorker19(worker19s);
  214. dto.setWorker11(worker11s);
  215. dto.setWorker12(worker12s);
  216. dto.setWorker13(worker13s);
  217. dto.setWorker14(worker14s);
  218. dto.setWorker15(worker15s);
  219. dto.setWorker16(worker16s);
  220. dto.setRemark(group.getRemark());
  221. dtoList.add(dto);
  222. }
  223. }
  224. ExportUtil.exportExcel(dtoList, response, "稽察历史计划列表", columns, TacInspYearBatchGroupExportDto.class);
  225. }
  226. return buildSuccessResponse(list);
  227. }
  228. private String convertDateToLocalDateTime(Date date){
  229. if(null == date){
  230. return "";
  231. }
  232. Calendar calendar = Calendar.getInstance();
  233. calendar.setTime(date);
  234. LocalDateTime localDateTime = LocalDateTime.of(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH),0,0,0);
  235. if(null != localDateTime){
  236. String dateStr = String.format("%d年%d月%d日",localDateTime.getYear(),localDateTime.getMonthValue(),localDateTime.getDayOfMonth());
  237. return dateStr;
  238. }else {
  239. return "";
  240. }
  241. }
  242. @ApiOperation(value = "获取组列表app")
  243. @RequestMapping(value = "/getGroupListApp", method = RequestMethod.POST)
  244. public BaseResponse<List<TacInspYearBatchGroup>> getGroupListApp(@RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
  245. tacInspYearBatchGroupParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  246. List<TacInspYearBatchGroup> list = tacInspYearBatchGroupService.getGroupListApp(tacInspYearBatchGroupParam);
  247. return buildSuccessResponse(list);
  248. }
  249. @ApiOperation(value = "批量修改组列表")
  250. @RequestMapping(value = "/updateGroupList", method = RequestMethod.POST)
  251. public BaseResponse updateGroupList(@RequestBody TacInspYearBatchGroupDto dto) {
  252. dto.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  253. int a = tacInspYearBatchGroupService.updateGroupList(dto);
  254. return buildSuccessResponse();
  255. }
  256. @ApiOperation(value = "根据分组id发送短信")
  257. @RequestMapping(value = "/sendGroupMessage", method = RequestMethod.POST)
  258. public BaseResponse sendGroupMessage(@RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam) {
  259. if (StringUtils.isBlank(tacInspYearBatchGroupParam.getYearBatchId())) {
  260. return buildFailResponse(17001, "批次id不能为空");
  261. }
  262. if (StringUtils.isBlank(tacInspYearBatchGroupParam.getId())) {
  263. return buildFailResponse(17001, "组id不能为空");
  264. }
  265. try{
  266. tacInspYearBatchGroupParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  267. String resultCode = tacInspYearBatchGroupService.sendGroupMessage(tacInspYearBatchGroupParam);
  268. if (SmsCodeEnum.SUCCESS.getKey().equals(resultCode)) {
  269. return buildSuccessResponse(SmsCodeEnum.SUCCESS.getDesc());
  270. } else if (SmsCodeEnum.NO_USER.getKey().equals(resultCode)) {
  271. return buildFailResponse(10002, SmsCodeEnum.NO_USER.getDesc());
  272. } else if (SmsCodeEnum.NO_MEET.getKey().equals(resultCode)) {
  273. return buildFailResponse(10003, SmsCodeEnum.NO_MEET.getDesc());
  274. } else if (SmsCodeEnum.NO_COVERAGE.getKey().equals(resultCode)) {
  275. return buildFailResponse(10005, SmsCodeEnum.NO_COVERAGE.getDesc());
  276. }else{
  277. return buildSuccessResponse(SmsCodeEnum.SUCCESS.getDesc());
  278. }
  279. }catch (Exception e) {
  280. return buildFailResponse("系统异常请联系管理员");
  281. }
  282. }
  283. @ApiOperation(value = "固定分组人员")
  284. @RequestMapping(value = "/confirmerGroup", method = RequestMethod.POST)
  285. public BaseResponse confirmerGroup(@RequestBody TacInspYearBatchGroupParam tacInspYearBatchGroupParam) throws Exception {
  286. // 固定分组人员后不能对该组人员进行人员分配,人员刷新,人员单角色刷新操作,可对人员单独添加,修改,删除
  287. if (StringUtils.isBlank(tacInspYearBatchGroupParam.getId())) {
  288. return buildFailResponse(17001, "组别id不能为空");
  289. }
  290. return buildSuccessResponse(tacInspYearBatchGroupService.confirmerGroup(tacInspYearBatchGroupParam));
  291. }
  292. }