92fbd6dd0ac830624f4adee15ad0f85a0d4b8118.svn-base 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package cn.com.goldenwater.dcproj.controller.rsml;
  2. import cn.com.goldenwater.dcproj.model.*;
  3. import cn.com.goldenwater.dcproj.param.BisInspRsmlRgstrPresParam;
  4. import cn.com.goldenwater.dcproj.service.AttRsBaseService;
  5. import cn.com.goldenwater.dcproj.service.BisInspRsmlRgstrPresService;
  6. import cn.com.goldenwater.core.web.BaseController;
  7. import cn.com.goldenwater.core.web.BaseResponse;
  8. import cn.com.goldenwater.dcproj.service.BisInspRsmlRgstrService;
  9. import cn.com.goldenwater.id.util.UuidUtil;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import io.swagger.annotations.ApiParam;
  13. import org.apache.commons.lang3.StringUtils;
  14. import com.github.pagehelper.PageInfo;
  15. import org.slf4j.Logger;
  16. import org.slf4j.LoggerFactory;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.web.bind.annotation.PathVariable;
  19. import org.springframework.web.bind.annotation.RequestBody;
  20. import org.springframework.web.bind.annotation.RequestMapping;
  21. import org.springframework.web.bind.annotation.RequestMethod;
  22. import org.springframework.web.bind.annotation.RestController;
  23. import javax.servlet.http.HttpServletRequest;
  24. import java.util.Date;
  25. import java.util.List;
  26. /**
  27. * @author lune
  28. * @date 2020-3-9
  29. */
  30. @Api(value = "BIS 三个责任人落实情况管理",tags="BIS 三个责任人落实情况管理")
  31. @RestController
  32. @RequestMapping("/bis/insp/rsml/rgstr/pres")
  33. public class BisInspRsmlRgstrPresController extends BaseController {
  34. private Logger logger = LoggerFactory.getLogger(getClass());
  35. @Autowired
  36. private BisInspRsmlRgstrPresService bisInspRsmlRgstrPresService;
  37. @Autowired
  38. private BisInspRsmlRgstrService bisInspRsmlRgstrService;
  39. @Autowired
  40. private AttRsBaseService attRsBaseService;
  41. @ApiOperation(value = "添加/修改三个责任人落实情况")
  42. @RequestMapping(value = "", method = RequestMethod.POST)
  43. public BaseResponse<BisInspRsmlRgstrPres> insert(@ApiParam(name = "bisInspRsmlRgstrPres", value = "BisInspRsmlRgstrPres", required = true) @RequestBody BisInspRsmlRgstrPres bisInspRsmlRgstrPres) {
  44. if(StringUtils.isBlank(bisInspRsmlRgstrPres.getId())) {
  45. BisInspRsmlRgstrPresParam presParam = new BisInspRsmlRgstrPresParam();
  46. presParam.setRgstrId(bisInspRsmlRgstrPres.getRgstrId());
  47. List<BisInspRsmlRgstrPres> list = bisInspRsmlRgstrPresService.findList(presParam);
  48. if (list.size() > 0) {
  49. bisInspRsmlRgstrPres.setId(list.get(0).getId());
  50. bisInspRsmlRgstrPres.setUptm(new Date());
  51. bisInspRsmlRgstrPresService.update(bisInspRsmlRgstrPres);
  52. } else {
  53. String uuid = UuidUtil.uuid(); // 生成uuid
  54. bisInspRsmlRgstrPres.setIntm(new Date());
  55. bisInspRsmlRgstrPres.setUptm(new Date());
  56. bisInspRsmlRgstrPres.setId(uuid);
  57. bisInspRsmlRgstrPresService.insert(bisInspRsmlRgstrPres);
  58. }
  59. }else{
  60. bisInspRsmlRgstrPres.setUptm(new Date());
  61. bisInspRsmlRgstrPresService.update(bisInspRsmlRgstrPres);
  62. }
  63. if (StringUtils.isNotBlank(bisInspRsmlRgstrPres.getRgstrId())) {
  64. BisInspRsmlRgstr rgstr = bisInspRsmlRgstrService.get(bisInspRsmlRgstrPres.getRgstrId());
  65. if (rgstr != null) {
  66. rgstr.setPresState(bisInspRsmlRgstrPres.getStatus());
  67. if (!"2".equals(rgstr.getState())) {
  68. rgstr.setState("1");
  69. }
  70. bisInspRsmlRgstrService.update(rgstr);
  71. }
  72. }
  73. return buildSuccessResponse(bisInspRsmlRgstrPres);
  74. }
  75. @ApiOperation(value = "根据ID删除三个责任人落实情况")
  76. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  77. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  78. int ret = bisInspRsmlRgstrPresService.delete(id);
  79. return buildSuccessResponse();
  80. }
  81. @ApiOperation(value = "根据ID获取三个责任人落实情况(单表)")
  82. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  83. public BaseResponse<BisInspRsmlRgstrPres> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  84. BisInspRsmlRgstrPres bisInspRsmlRgstrPres = bisInspRsmlRgstrPresService.get(id);
  85. return buildSuccessResponse(bisInspRsmlRgstrPres);
  86. }
  87. @ApiOperation(value = "获取三个责任人落实情况(列表所有)")
  88. @RequestMapping(value = "/list", method = RequestMethod.POST)
  89. public BaseResponse<List<BisInspRsmlRgstrPres>> list(@ApiParam(name = "bisInspRsmlRgstrPresParam", value = "bisInspRsmlRgstrPresParam", required = true) @RequestBody BisInspRsmlRgstrPresParam bisInspRsmlRgstrPresParam) {
  90. List<BisInspRsmlRgstrPres> bisInspRsmlRgstrPresList = bisInspRsmlRgstrPresService.findList(bisInspRsmlRgstrPresParam);
  91. return buildSuccessResponse(bisInspRsmlRgstrPresList);
  92. }
  93. @ApiOperation(value = "获取三个责任人落实情况(列表--分页)")
  94. @RequestMapping(value = "/page", method = RequestMethod.POST)
  95. public BaseResponse<PageInfo<BisInspRsmlRgstrPres>> page(@ApiParam(name = "bisInspRsmlRgstrPresParam", value = "bisInspRsmlRgstrPresParam", required = true) @RequestBody BisInspRsmlRgstrPresParam bisInspRsmlRgstrPresParam) {
  96. PageInfo<BisInspRsmlRgstrPres> bisInspRsmlRgstrPresList = bisInspRsmlRgstrPresService.findPageInfo(bisInspRsmlRgstrPresParam);
  97. return buildSuccessResponse(bisInspRsmlRgstrPresList);
  98. }
  99. @ApiOperation(value = "根据rgstrId获取三个责任人落实情况")
  100. @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET)
  101. public BaseResponse<BisInspRsmlRgstrPres> getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId, HttpServletRequest request) {
  102. BisInspRsmlRgstrPresParam presParam = new BisInspRsmlRgstrPresParam();
  103. presParam.setRgstrId(rgstrId);
  104. BisInspRsmlRgstrPres pres = bisInspRsmlRgstrPresService.getBy(presParam);
  105. if (pres == null) {
  106. pres = new BisInspRsmlRgstrPres();
  107. BisInspRsmlRgstr rgstr = bisInspRsmlRgstrService.get(rgstrId);
  108. AttRsBase rsBase = attRsBaseService.get(rgstr.getRsCode());
  109. if (rsBase != null) {
  110. pres.setWiunWaoLegPers(rsBase.getWiunWaoLegPers());
  111. pres.setWiunWaoLegPersTel(rsBase.getWiunWaoLegPersTel());
  112. pres.setWiunWaoLegPersDuty(rsBase.getWiunWaoLegPersDuty());
  113. pres.setTechPers(rsBase.getTechPers());
  114. pres.setTechPersTel(rsBase.getTechPersTel());
  115. pres.setTechPersDuty(rsBase.getTechPersDuty());
  116. pres.setPatrolPers(rsBase.getPatrolPers());
  117. pres.setPatrolPersTel(rsBase.getPatrolPersTel());
  118. }
  119. }
  120. return buildSuccessResponse(pres);
  121. }
  122. }