cd7f73022309b02a2cf2245482ed7893828e15a9.svn-base 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package cn.com.goldenwater.dcproj.controller.keyreg;
  2. import cn.com.goldenwater.dcproj.model.AttEmpwtprjBase;
  3. import cn.com.goldenwater.dcproj.service.AttEmpwtprjBaseService;
  4. import cn.com.goldenwater.core.web.BaseController;
  5. import cn.com.goldenwater.core.web.BaseResponse;
  6. import cn.com.goldenwater.dcproj.service.AttEmpwtprjTrackService;
  7. import cn.com.goldenwater.dcproj.service.BisInspKeyRegisterService;
  8. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  9. import cn.com.goldenwater.dcproj.utils.GeoUtil;
  10. import cn.com.goldenwater.id.util.UuidUtil;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiOperation;
  13. import io.swagger.annotations.ApiParam;
  14. import org.slf4j.Logger;
  15. import org.slf4j.LoggerFactory;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.util.Assert;
  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 java.util.Date;
  24. import java.util.Map;
  25. /**
  26. * @author lhc
  27. * @date 2019-4-20
  28. */
  29. @Api(value = "172重点水利项目基本信息管理", tags = "172重点水利项目基本信息管理")
  30. @RestController
  31. @RequestMapping("/bis/insp/empwtprj/base")
  32. public class AttEmpwtprjBaseController extends BaseController {
  33. private Logger logger = LoggerFactory.getLogger(getClass());
  34. @Autowired
  35. private AttEmpwtprjBaseService attEmpwtprjBaseService;
  36. @Autowired
  37. private AttEmpwtprjTrackService attEmpwtprjTrackService;
  38. @Autowired
  39. private BisInspKeyRegisterService bisInspKeyRegisterService;
  40. @Autowired
  41. private OlBisInspOrgService olBisInspOrgService;
  42. @ApiOperation(value = "添加172重点水利项目基本信息")
  43. @RequestMapping(value = "/add", method = RequestMethod.POST)
  44. public BaseResponse<AttEmpwtprjBase> insert(@ApiParam(name = "attEmpwtprjBase", value = "AttEmpwtprjBase", required = true) @RequestBody AttEmpwtprjBase attEmpwtprjBase) {
  45. attEmpwtprjBase.setId(UuidUtil.uuid());
  46. if(org.apache.commons.lang3.StringUtils.isBlank(attEmpwtprjBase.getAdCode())){
  47. attEmpwtprjBase.setAdCode(olBisInspOrgService.getProvince(getCurrentOrgId()));
  48. attEmpwtprjBase.setIntm(new Date());
  49. attEmpwtprjBase.setUptm(new Date());
  50. }
  51. if (attEmpwtprjBase.getLgtd() != null && attEmpwtprjBase.getLttd() != null) {
  52. if (attEmpwtprjBase.getLgtd() == 0 || attEmpwtprjBase.getLttd() == 0) {
  53. attEmpwtprjBase.setLgtd(null);
  54. attEmpwtprjBase.setLttd(null);
  55. attEmpwtprjBase.setLgtdPc(null);
  56. attEmpwtprjBase.setLttdPc(null);
  57. } else {
  58. Map<String, Double> map = GeoUtil.gcj02towgs84(attEmpwtprjBase.getLgtd(), attEmpwtprjBase.getLttd());
  59. attEmpwtprjBase.setLttdPc(map.get("lon"));
  60. attEmpwtprjBase.setLttdPc(map.get("lat"));
  61. }
  62. }
  63. if (attEmpwtprjBase.getIntm() == null) {
  64. attEmpwtprjBase.setIntm(new Date());
  65. attEmpwtprjBase.setUptm(new Date());
  66. }
  67. int ret = attEmpwtprjBaseService.insert(attEmpwtprjBase);
  68. return buildSuccessResponse(attEmpwtprjBase);
  69. }
  70. @ApiOperation(value = "根据ID删除172重点水利项目基本信息")
  71. @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
  72. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  73. int ret = attEmpwtprjBaseService.delete(id);
  74. return buildSuccessResponse();
  75. }
  76. @ApiOperation(value = "更新172重点水利项目基本信息")
  77. @RequestMapping(value = "/update", method = RequestMethod.POST)
  78. public BaseResponse<AttEmpwtprjBase> update(@ApiParam(name = "attEmpwtprjBase", value = "AttEmpwtprjBase", required = true) @RequestBody AttEmpwtprjBase attEmpwtprjBase) {
  79. Assert.notNull(attEmpwtprjBase.getId(), "主键id为必填参数");
  80. if (attEmpwtprjBase.getUptm() == null) {
  81. attEmpwtprjBase.setUptm(new Date());
  82. }
  83. int ret = attEmpwtprjBaseService.update(attEmpwtprjBase);
  84. //添加纠错记录
  85. attEmpwtprjTrackService.insertBase(attEmpwtprjBase);
  86. //更新登记表信息
  87. bisInspKeyRegisterService.updateBaseInfo(attEmpwtprjBase);
  88. AttEmpwtprjBase attEmpwtprjBase1 = attEmpwtprjBaseService.get(attEmpwtprjBase.getId());
  89. return buildSuccessResponse(attEmpwtprjBase1);
  90. }
  91. @ApiOperation(value = "根据ID获取172重点水利项目基本信息")
  92. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  93. public BaseResponse<AttEmpwtprjBase> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  94. AttEmpwtprjBase attEmpwtprjBase = attEmpwtprjBaseService.get(id);
  95. return buildSuccessResponse(attEmpwtprjBase);
  96. }
  97. }