| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- package cn.com.goldenwater.dcproj.controller.keyreg;
- import cn.com.goldenwater.dcproj.model.AttEmpwtprjBase;
- import cn.com.goldenwater.dcproj.service.AttEmpwtprjBaseService;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.service.AttEmpwtprjTrackService;
- import cn.com.goldenwater.dcproj.service.BisInspKeyRegisterService;
- import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
- import cn.com.goldenwater.dcproj.utils.GeoUtil;
- import cn.com.goldenwater.id.util.UuidUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.util.Assert;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.Date;
- import java.util.Map;
- /**
- * @author lhc
- * @date 2019-4-20
- */
- @Api(value = "172重点水利项目基本信息管理", tags = "172重点水利项目基本信息管理")
- @RestController
- @RequestMapping("/bis/insp/empwtprj/base")
- public class AttEmpwtprjBaseController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private AttEmpwtprjBaseService attEmpwtprjBaseService;
- @Autowired
- private AttEmpwtprjTrackService attEmpwtprjTrackService;
- @Autowired
- private BisInspKeyRegisterService bisInspKeyRegisterService;
- @Autowired
- private OlBisInspOrgService olBisInspOrgService;
- @ApiOperation(value = "添加172重点水利项目基本信息")
- @RequestMapping(value = "/add", method = RequestMethod.POST)
- public BaseResponse<AttEmpwtprjBase> insert(@ApiParam(name = "attEmpwtprjBase", value = "AttEmpwtprjBase", required = true) @RequestBody AttEmpwtprjBase attEmpwtprjBase) {
- attEmpwtprjBase.setId(UuidUtil.uuid());
- if(org.apache.commons.lang3.StringUtils.isBlank(attEmpwtprjBase.getAdCode())){
- attEmpwtprjBase.setAdCode(olBisInspOrgService.getProvince(getCurrentOrgId()));
- attEmpwtprjBase.setIntm(new Date());
- attEmpwtprjBase.setUptm(new Date());
- }
- if (attEmpwtprjBase.getLgtd() != null && attEmpwtprjBase.getLttd() != null) {
- if (attEmpwtprjBase.getLgtd() == 0 || attEmpwtprjBase.getLttd() == 0) {
- attEmpwtprjBase.setLgtd(null);
- attEmpwtprjBase.setLttd(null);
- attEmpwtprjBase.setLgtdPc(null);
- attEmpwtprjBase.setLttdPc(null);
- } else {
- Map<String, Double> map = GeoUtil.gcj02towgs84(attEmpwtprjBase.getLgtd(), attEmpwtprjBase.getLttd());
- attEmpwtprjBase.setLttdPc(map.get("lon"));
- attEmpwtprjBase.setLttdPc(map.get("lat"));
- }
- }
- if (attEmpwtprjBase.getIntm() == null) {
- attEmpwtprjBase.setIntm(new Date());
- attEmpwtprjBase.setUptm(new Date());
- }
- int ret = attEmpwtprjBaseService.insert(attEmpwtprjBase);
- return buildSuccessResponse(attEmpwtprjBase);
- }
- @ApiOperation(value = "根据ID删除172重点水利项目基本信息")
- @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- int ret = attEmpwtprjBaseService.delete(id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "更新172重点水利项目基本信息")
- @RequestMapping(value = "/update", method = RequestMethod.POST)
- public BaseResponse<AttEmpwtprjBase> update(@ApiParam(name = "attEmpwtprjBase", value = "AttEmpwtprjBase", required = true) @RequestBody AttEmpwtprjBase attEmpwtprjBase) {
- Assert.notNull(attEmpwtprjBase.getId(), "主键id为必填参数");
- if (attEmpwtprjBase.getUptm() == null) {
- attEmpwtprjBase.setUptm(new Date());
- }
- int ret = attEmpwtprjBaseService.update(attEmpwtprjBase);
- //添加纠错记录
- attEmpwtprjTrackService.insertBase(attEmpwtprjBase);
- //更新登记表信息
- bisInspKeyRegisterService.updateBaseInfo(attEmpwtprjBase);
- AttEmpwtprjBase attEmpwtprjBase1 = attEmpwtprjBaseService.get(attEmpwtprjBase.getId());
- return buildSuccessResponse(attEmpwtprjBase1);
- }
- @ApiOperation(value = "根据ID获取172重点水利项目基本信息")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<AttEmpwtprjBase> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- AttEmpwtprjBase attEmpwtprjBase = attEmpwtprjBaseService.get(id);
- return buildSuccessResponse(attEmpwtprjBase);
- }
- }
|