36938388c2503981d272bc2f05414efd5383c978.svn-base 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package cn.com.goldenwater.dcproj.controller.swhs;
  2. import cn.com.goldenwater.dcproj.model.BisInspSwhsRgstr;
  3. import cn.com.goldenwater.dcproj.model.BisInspSwhsRgstrSafety;
  4. import cn.com.goldenwater.dcproj.param.BisInspSwhsRgstrSafetyParam;
  5. import cn.com.goldenwater.dcproj.service.BisInspSwhsRgstrSafetyService;
  6. import cn.com.goldenwater.core.web.BaseController;
  7. import cn.com.goldenwater.core.web.BaseResponse;
  8. import cn.com.goldenwater.dcproj.service.BisInspSwhsRgstrService;
  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 2019-8-7
  29. */
  30. @Api(value = "BIS 安全保障达标落实情况管理",tags="BIS 安全保障达标落实情况管理")
  31. @RestController
  32. @RequestMapping("/bis/insp/swhs/rgstr/safety")
  33. public class BisInspSwhsRgstrSafetyController extends BaseController {
  34. private Logger logger = LoggerFactory.getLogger(getClass());
  35. @Autowired
  36. private BisInspSwhsRgstrSafetyService bisInspSwhsRgstrSafetyService;
  37. @Autowired
  38. private BisInspSwhsRgstrService swhsRgstrService;
  39. @ApiOperation(value = "添加/修改安全保障达标落实情况")
  40. @RequestMapping(value = "", method = RequestMethod.POST)
  41. public BaseResponse<BisInspSwhsRgstrSafety> insert(@ApiParam(name = "bisInspSwhsRgstrSafety", value = "BisInspSwhsRgstrSafety", required = true) @RequestBody BisInspSwhsRgstrSafety bisInspSwhsRgstrSafety) {
  42. if(StringUtils.isBlank(bisInspSwhsRgstrSafety.getId())) {
  43. BisInspSwhsRgstrSafetyParam param = new BisInspSwhsRgstrSafetyParam();
  44. param.setRgstrId(bisInspSwhsRgstrSafety.getRgstrId());
  45. List<BisInspSwhsRgstrSafety> list = bisInspSwhsRgstrSafetyService.findList(param);
  46. if (list.size() > 0 ){
  47. return buildFailResponse();
  48. }
  49. bisInspSwhsRgstrSafety.setInTm(new Date());
  50. bisInspSwhsRgstrSafety.setUpTm(new Date());
  51. String uuid = UuidUtil.uuid(); // 生成uuid
  52. bisInspSwhsRgstrSafety.setId(uuid);
  53. bisInspSwhsRgstrSafetyService.insert(bisInspSwhsRgstrSafety);
  54. }else{
  55. bisInspSwhsRgstrSafety.setUpTm(new Date());
  56. bisInspSwhsRgstrSafetyService.update(bisInspSwhsRgstrSafety);
  57. }
  58. if (StringUtils.isNotBlank(bisInspSwhsRgstrSafety.getRgstrId())) {
  59. BisInspSwhsRgstr rgstr = swhsRgstrService.get(bisInspSwhsRgstrSafety.getRgstrId());
  60. if (rgstr != null) {
  61. rgstr.setSafetyStat(bisInspSwhsRgstrSafety.getDataStat());
  62. if (!"2".equals(rgstr.getState())) {
  63. rgstr.setState("1");
  64. }
  65. swhsRgstrService.update(rgstr);
  66. }
  67. }
  68. return buildSuccessResponse(bisInspSwhsRgstrSafety);
  69. }
  70. @ApiOperation(value = "根据ID删除安全保障达标落实情况")
  71. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  72. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  73. int ret = bisInspSwhsRgstrSafetyService.delete(id);
  74. return buildSuccessResponse();
  75. }
  76. @ApiOperation(value = "根据ID获取安全保障达标落实情况(单表)")
  77. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  78. public BaseResponse<BisInspSwhsRgstrSafety> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  79. BisInspSwhsRgstrSafety bisInspSwhsRgstrSafety = bisInspSwhsRgstrSafetyService.get(id);
  80. return buildSuccessResponse(bisInspSwhsRgstrSafety);
  81. }
  82. @ApiOperation(value = "获取安全保障达标落实情况(列表所有)")
  83. @RequestMapping(value = "/list", method = RequestMethod.POST)
  84. public BaseResponse<List<BisInspSwhsRgstrSafety>> list(@ApiParam(name = "bisInspSwhsRgstrSafetyParam", value = "bisInspSwhsRgstrSafetyParam", required = true) @RequestBody BisInspSwhsRgstrSafetyParam bisInspSwhsRgstrSafetyParam) {
  85. List<BisInspSwhsRgstrSafety> bisInspSwhsRgstrSafetyList = bisInspSwhsRgstrSafetyService.findList(bisInspSwhsRgstrSafetyParam);
  86. return buildSuccessResponse(bisInspSwhsRgstrSafetyList);
  87. }
  88. @ApiOperation(value = "获取安全保障达标落实情况(列表--分页)")
  89. @RequestMapping(value = "/page", method = RequestMethod.POST)
  90. public BaseResponse<PageInfo<BisInspSwhsRgstrSafety>> page(@ApiParam(name = "bisInspSwhsRgstrSafetyParam", value = "bisInspSwhsRgstrSafetyParam", required = true) @RequestBody BisInspSwhsRgstrSafetyParam bisInspSwhsRgstrSafetyParam) {
  91. PageInfo<BisInspSwhsRgstrSafety> bisInspSwhsRgstrSafetyList = bisInspSwhsRgstrSafetyService.findPageInfo(bisInspSwhsRgstrSafetyParam);
  92. return buildSuccessResponse(bisInspSwhsRgstrSafetyList);
  93. }
  94. @ApiOperation(value = "根据注册表id获取安全保证信息")
  95. @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET)
  96. public BaseResponse<BisInspSwhsRgstrSafety> getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId,HttpServletRequest request) {
  97. if (StringUtils.isBlank(rgstrId)) {
  98. return buildFailResponse();
  99. }
  100. BisInspSwhsRgstrSafetyParam param = new BisInspSwhsRgstrSafetyParam();
  101. param.setRgstrId(rgstrId);
  102. BisInspSwhsRgstrSafety swhsRgstrSafety = this.bisInspSwhsRgstrSafetyService.getBy(param);
  103. return buildSuccessResponse(swhsRgstrSafety);
  104. }
  105. }