1385bb28406acaa079fffd85aa188837e2bb112c.svn-base 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package cn.com.goldenwater.dcproj.controller.keyreg;
  2. import cn.com.goldenwater.dcproj.constValue.StateEnum;
  3. import cn.com.goldenwater.dcproj.model.BisInspKeyRegister;
  4. import cn.com.goldenwater.dcproj.model.BisInspKeyRegisterSection;
  5. import cn.com.goldenwater.dcproj.service.BisInspKeyRegisterSectionService;
  6. import cn.com.goldenwater.core.web.BaseController;
  7. import cn.com.goldenwater.core.web.BaseResponse;
  8. import cn.com.goldenwater.dcproj.service.BisInspKeyRegisterService;
  9. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  10. import cn.com.goldenwater.dcproj.utils.GeoUtil;
  11. import cn.com.goldenwater.id.util.UuidUtil;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import io.swagger.annotations.ApiParam;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.util.Assert;
  20. import org.springframework.web.bind.annotation.PathVariable;
  21. import org.springframework.web.bind.annotation.RequestBody;
  22. import org.springframework.web.bind.annotation.RequestMapping;
  23. import org.springframework.web.bind.annotation.RequestMethod;
  24. import org.springframework.web.bind.annotation.RestController;
  25. import java.util.Date;
  26. import java.util.List;
  27. import java.util.Map;
  28. /**
  29. * @author lhc
  30. * @date 2019-4-20
  31. */
  32. @Api(value = "172重点水利项目登记表标段管理", tags = "172重点水利项目登记表标段管理")
  33. @RestController
  34. @RequestMapping("/bis/insp/key/register/section")
  35. public class BisInspKeyRegisterSectionController extends BaseController {
  36. private Logger logger = LoggerFactory.getLogger(getClass());
  37. @Autowired
  38. private BisInspKeyRegisterSectionService bisInspKeyRegisterSectionService;
  39. @Autowired
  40. private BisInspKeyRegisterService bisInspKeyRegisterService;
  41. @Autowired
  42. private OlBisInspOrgService olBisInspOrgService;
  43. @ApiOperation(value = "添加172重点水利项目登记表标段")
  44. @RequestMapping(value = "/add", method = RequestMethod.POST)
  45. public BaseResponse<BisInspKeyRegisterSection> insert(@ApiParam(name = "bisInspKeyRegisterSection", value = "BisInspKeyRegisterSection", required = true) @RequestBody BisInspKeyRegisterSection bisInspKeyRegisterSection) {
  46. String uuid = UuidUtil.uuid(); // 生成uuid
  47. bisInspKeyRegisterSection.setId(uuid);
  48. if(StringUtils.isBlank(bisInspKeyRegisterSection.getOrgId())) {
  49. bisInspKeyRegisterSection.setOrgId(getCurrentOrgId());
  50. }
  51. if (bisInspKeyRegisterSection.getLgtd() != null && bisInspKeyRegisterSection.getLttd() != null) {
  52. Map<String, Double> map = GeoUtil.gcj02towgs84(bisInspKeyRegisterSection.getLgtd(), bisInspKeyRegisterSection.getLttd());
  53. bisInspKeyRegisterSection.setLttdPc(map.get("lon"));
  54. bisInspKeyRegisterSection.setLttdPc(map.get("lat"));
  55. }
  56. bisInspKeyRegisterSection.setIntm(new Date());
  57. bisInspKeyRegisterSection.setUptm(new Date());
  58. //塞入objid
  59. BisInspKeyRegister bisInspKeyRegisterExist = bisInspKeyRegisterService.get(bisInspKeyRegisterSection.getRegId());
  60. bisInspKeyRegisterSection.setObjId(bisInspKeyRegisterExist.getObjId());
  61. if(StringUtils.isBlank(bisInspKeyRegisterSection.getAdCode())) {
  62. bisInspKeyRegisterSection.setAdCode(olBisInspOrgService.getProvince(getCurrentOrgId()));
  63. }
  64. int ret = bisInspKeyRegisterSectionService.insert(bisInspKeyRegisterSection);
  65. //更新登记表的标段状态及登记表状态
  66. BisInspKeyRegister bisInspKeyRegister = new BisInspKeyRegister();
  67. bisInspKeyRegister.setId(bisInspKeyRegisterSection.getRegId());
  68. bisInspKeyRegister.setState(StateEnum.EXWASTSTATE.getKey());
  69. bisInspKeyRegister.setSecStat(StateEnum.EXWASTSTATE.getKey());
  70. bisInspKeyRegister.setIntm(new Date());
  71. bisInspKeyRegisterService.update(bisInspKeyRegister);
  72. return buildSuccessResponse(bisInspKeyRegisterSection);
  73. }
  74. @ApiOperation(value = "根据ID删除172重点水利项目登记表标段")
  75. @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
  76. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  77. int ret = bisInspKeyRegisterSectionService.delete(id);
  78. return buildSuccessResponse();
  79. }
  80. @ApiOperation(value = "更新172重点水利项目登记表标段信息")
  81. @RequestMapping(value = "/update", method = RequestMethod.POST)
  82. public BaseResponse<BisInspKeyRegisterSection> update(@ApiParam(name = "bisInspKeyRegisterSection", value = "BisInspKeyRegisterSection", required = true) @RequestBody BisInspKeyRegisterSection bisInspKeyRegisterSection) {
  83. Assert.notNull(bisInspKeyRegisterSection.getId(), "主键id为必填参数");
  84. bisInspKeyRegisterSection.setUptm(new Date());
  85. int ret = bisInspKeyRegisterSectionService.update(bisInspKeyRegisterSection);
  86. return buildSuccessResponse(bisInspKeyRegisterSection);
  87. }
  88. @ApiOperation(value = "根据ID获取172重点水利项目登记表标段(单表)")
  89. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  90. public BaseResponse<BisInspKeyRegisterSection> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  91. BisInspKeyRegisterSection bisInspKeyRegisterSection = bisInspKeyRegisterSectionService.get(id);
  92. return buildSuccessResponse(bisInspKeyRegisterSection);
  93. }
  94. @ApiOperation(value = "根据登记表ID查询标段列表")
  95. @RequestMapping(value = "/getByRegId/{regId}", method = RequestMethod.GET)
  96. public BaseResponse<List<BisInspKeyRegisterSection>> getByRegId(@ApiParam(name = "regId", value = "regId", required = true) @PathVariable String regId) {
  97. List<BisInspKeyRegisterSection> bisInspKeyRegisterSections = bisInspKeyRegisterSectionService.getByRegId(regId);
  98. return buildSuccessResponse(bisInspKeyRegisterSections);
  99. }
  100. }