package cn.com.goldenwater.dcproj.controller.keyreg; import cn.com.goldenwater.dcproj.constValue.StateEnum; import cn.com.goldenwater.dcproj.model.BisInspKeyRegister; import cn.com.goldenwater.dcproj.model.BisInspKeyRegisterSection; import cn.com.goldenwater.dcproj.service.BisInspKeyRegisterSectionService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; 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.apache.commons.lang3.StringUtils; 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.List; import java.util.Map; /** * @author lhc * @date 2019-4-20 */ @Api(value = "172重点水利项目登记表标段管理", tags = "172重点水利项目登记表标段管理") @RestController @RequestMapping("/bis/insp/key/register/section") public class BisInspKeyRegisterSectionController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspKeyRegisterSectionService bisInspKeyRegisterSectionService; @Autowired private BisInspKeyRegisterService bisInspKeyRegisterService; @Autowired private OlBisInspOrgService olBisInspOrgService; @ApiOperation(value = "添加172重点水利项目登记表标段") @RequestMapping(value = "/add", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspKeyRegisterSection", value = "BisInspKeyRegisterSection", required = true) @RequestBody BisInspKeyRegisterSection bisInspKeyRegisterSection) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspKeyRegisterSection.setId(uuid); if(StringUtils.isBlank(bisInspKeyRegisterSection.getOrgId())) { bisInspKeyRegisterSection.setOrgId(getCurrentOrgId()); } if (bisInspKeyRegisterSection.getLgtd() != null && bisInspKeyRegisterSection.getLttd() != null) { Map map = GeoUtil.gcj02towgs84(bisInspKeyRegisterSection.getLgtd(), bisInspKeyRegisterSection.getLttd()); bisInspKeyRegisterSection.setLttdPc(map.get("lon")); bisInspKeyRegisterSection.setLttdPc(map.get("lat")); } bisInspKeyRegisterSection.setIntm(new Date()); bisInspKeyRegisterSection.setUptm(new Date()); //塞入objid BisInspKeyRegister bisInspKeyRegisterExist = bisInspKeyRegisterService.get(bisInspKeyRegisterSection.getRegId()); bisInspKeyRegisterSection.setObjId(bisInspKeyRegisterExist.getObjId()); if(StringUtils.isBlank(bisInspKeyRegisterSection.getAdCode())) { bisInspKeyRegisterSection.setAdCode(olBisInspOrgService.getProvince(getCurrentOrgId())); } int ret = bisInspKeyRegisterSectionService.insert(bisInspKeyRegisterSection); //更新登记表的标段状态及登记表状态 BisInspKeyRegister bisInspKeyRegister = new BisInspKeyRegister(); bisInspKeyRegister.setId(bisInspKeyRegisterSection.getRegId()); bisInspKeyRegister.setState(StateEnum.EXWASTSTATE.getKey()); bisInspKeyRegister.setSecStat(StateEnum.EXWASTSTATE.getKey()); bisInspKeyRegister.setIntm(new Date()); bisInspKeyRegisterService.update(bisInspKeyRegister); return buildSuccessResponse(bisInspKeyRegisterSection); } @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 = bisInspKeyRegisterSectionService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "更新172重点水利项目登记表标段信息") @RequestMapping(value = "/update", method = RequestMethod.POST) public BaseResponse update(@ApiParam(name = "bisInspKeyRegisterSection", value = "BisInspKeyRegisterSection", required = true) @RequestBody BisInspKeyRegisterSection bisInspKeyRegisterSection) { Assert.notNull(bisInspKeyRegisterSection.getId(), "主键id为必填参数"); bisInspKeyRegisterSection.setUptm(new Date()); int ret = bisInspKeyRegisterSectionService.update(bisInspKeyRegisterSection); return buildSuccessResponse(bisInspKeyRegisterSection); } @ApiOperation(value = "根据ID获取172重点水利项目登记表标段(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspKeyRegisterSection bisInspKeyRegisterSection = bisInspKeyRegisterSectionService.get(id); return buildSuccessResponse(bisInspKeyRegisterSection); } @ApiOperation(value = "根据登记表ID查询标段列表") @RequestMapping(value = "/getByRegId/{regId}", method = RequestMethod.GET) public BaseResponse> getByRegId(@ApiParam(name = "regId", value = "regId", required = true) @PathVariable String regId) { List bisInspKeyRegisterSections = bisInspKeyRegisterSectionService.getByRegId(regId); return buildSuccessResponse(bisInspKeyRegisterSections); } }