913849b10252cd9a2b516d12649f4f4fab0cc348.svn-base 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package cn.com.goldenwater.dcproj.controller.rsml;
  2. import cn.com.goldenwater.dcproj.model.BisInspRsmlRgstr;
  3. import cn.com.goldenwater.dcproj.model.BisInspRsmlRgstrRunManage;
  4. import cn.com.goldenwater.dcproj.param.BisInspRsmlRgstrRunManageParam;
  5. import cn.com.goldenwater.dcproj.service.BisInspRsmlRgstrRunManageService;
  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/run/manage")
  33. public class BisInspRsmlRgstrRunManageController extends BaseController {
  34. private Logger logger = LoggerFactory.getLogger(getClass());
  35. @Autowired
  36. private BisInspRsmlRgstrRunManageService bisInspRsmlRgstrRunManageService;
  37. @Autowired
  38. private BisInspRsmlRgstrService bisInspRsmlRgstrService;
  39. @ApiOperation(value = "添加/修改运行管理情况")
  40. @RequestMapping(value = "", method = RequestMethod.POST)
  41. public BaseResponse<BisInspRsmlRgstrRunManage> insert(@ApiParam(name = "bisInspRsmlRgstrRunManage", value = "BisInspRsmlRgstrRunManage", required = true) @RequestBody BisInspRsmlRgstrRunManage bisInspRsmlRgstrRunManage) {
  42. if(StringUtils.isBlank(bisInspRsmlRgstrRunManage.getId())) {
  43. BisInspRsmlRgstrRunManageParam runManageParam = new BisInspRsmlRgstrRunManageParam();
  44. runManageParam.setRgstrId(bisInspRsmlRgstrRunManage.getRgstrId());
  45. List<BisInspRsmlRgstrRunManage> list = bisInspRsmlRgstrRunManageService.findList(runManageParam);
  46. if (list.size() > 0) {
  47. bisInspRsmlRgstrRunManage.setId(list.get(0).getId());
  48. bisInspRsmlRgstrRunManage.setUptm(new Date());
  49. bisInspRsmlRgstrRunManageService.update(bisInspRsmlRgstrRunManage);
  50. } else {
  51. String uuid = UuidUtil.uuid(); // 生成uuid
  52. bisInspRsmlRgstrRunManage.setIntm(new Date());
  53. bisInspRsmlRgstrRunManage.setUptm(new Date());
  54. bisInspRsmlRgstrRunManage.setId(uuid);
  55. bisInspRsmlRgstrRunManageService.insert(bisInspRsmlRgstrRunManage);
  56. }
  57. }else{
  58. bisInspRsmlRgstrRunManage.setUptm(new Date());
  59. bisInspRsmlRgstrRunManageService.update(bisInspRsmlRgstrRunManage);
  60. }
  61. if (StringUtils.isNotBlank(bisInspRsmlRgstrRunManage.getRgstrId())) {
  62. BisInspRsmlRgstr rgstr = bisInspRsmlRgstrService.get(bisInspRsmlRgstrRunManage.getRgstrId());
  63. if (rgstr != null) {
  64. rgstr.setRunManageState(bisInspRsmlRgstrRunManage.getStatus());
  65. if (!"2".equals(rgstr.getState())) {
  66. rgstr.setState("1");
  67. }
  68. bisInspRsmlRgstrService.update(rgstr);
  69. }
  70. }
  71. return buildSuccessResponse(bisInspRsmlRgstrRunManage);
  72. }
  73. @ApiOperation(value = "根据ID删除运行管理情况")
  74. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  75. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  76. int ret = bisInspRsmlRgstrRunManageService.delete(id);
  77. return buildSuccessResponse();
  78. }
  79. @ApiOperation(value = "根据ID获取运行管理情况(单表)")
  80. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  81. public BaseResponse<BisInspRsmlRgstrRunManage> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  82. BisInspRsmlRgstrRunManage bisInspRsmlRgstrRunManage = bisInspRsmlRgstrRunManageService.get(id);
  83. return buildSuccessResponse(bisInspRsmlRgstrRunManage);
  84. }
  85. @ApiOperation(value = "获取运行管理情况(列表所有)")
  86. @RequestMapping(value = "/list", method = RequestMethod.POST)
  87. public BaseResponse<List<BisInspRsmlRgstrRunManage>> list(@ApiParam(name = "bisInspRsmlRgstrRunManageParam", value = "bisInspRsmlRgstrRunManageParam", required = true) @RequestBody BisInspRsmlRgstrRunManageParam bisInspRsmlRgstrRunManageParam) {
  88. List<BisInspRsmlRgstrRunManage> bisInspRsmlRgstrRunManageList = bisInspRsmlRgstrRunManageService.findList(bisInspRsmlRgstrRunManageParam);
  89. return buildSuccessResponse(bisInspRsmlRgstrRunManageList);
  90. }
  91. @ApiOperation(value = "获取运行管理情况(列表--分页)")
  92. @RequestMapping(value = "/page", method = RequestMethod.POST)
  93. public BaseResponse<PageInfo<BisInspRsmlRgstrRunManage>> page(@ApiParam(name = "bisInspRsmlRgstrRunManageParam", value = "bisInspRsmlRgstrRunManageParam", required = true) @RequestBody BisInspRsmlRgstrRunManageParam bisInspRsmlRgstrRunManageParam) {
  94. PageInfo<BisInspRsmlRgstrRunManage> bisInspRsmlRgstrRunManageList = bisInspRsmlRgstrRunManageService.findPageInfo(bisInspRsmlRgstrRunManageParam);
  95. return buildSuccessResponse(bisInspRsmlRgstrRunManageList);
  96. }
  97. @ApiOperation(value = "根据rgstrId获取运行管理情况")
  98. @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET)
  99. public BaseResponse<BisInspRsmlRgstrRunManage> getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId, HttpServletRequest request) {
  100. BisInspRsmlRgstrRunManageParam runManageParam = new BisInspRsmlRgstrRunManageParam();
  101. runManageParam.setRgstrId(rgstrId);
  102. BisInspRsmlRgstrRunManage runManage = bisInspRsmlRgstrRunManageService.getBy(runManageParam);
  103. return buildSuccessResponse(runManage);
  104. }
  105. }