package cn.com.goldenwater.dcproj.controller.svwt; import cn.com.goldenwater.dcproj.constValue.CommonLabel; import cn.com.goldenwater.dcproj.dto.BisInspRgstrDto; import cn.com.goldenwater.dcproj.model.AttWuntBase; import cn.com.goldenwater.dcproj.model.BisInspAllObj; import cn.com.goldenwater.dcproj.model.BisInspSvwtWuntRgstr; import cn.com.goldenwater.dcproj.param.BisInspAllObjParam; import cn.com.goldenwater.dcproj.param.BisInspSvwtWuntRgstrParam; import cn.com.goldenwater.dcproj.service.AttWuntBaseService; import cn.com.goldenwater.dcproj.service.BisInspAllObjService; import cn.com.goldenwater.dcproj.service.BisInspSvwtWuntRgstrService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.service.OlBisInspOrgService; import cn.com.goldenwater.dcproj.target.Authority; import cn.com.goldenwater.dcproj.utils.BeanUtil; import cn.com.goldenwater.id.util.UuidUtil; import cn.com.goldenwater.util.common.SqlUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; 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 javax.servlet.http.HttpServletResponse; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import cn.com.goldenwater.dcproj.param.TypeParam; /** * @author lune * @date 2019-9-18 */ @Api(value = "BIS 用水单位督查登记表管理", tags = "BIS 用水单位督查登记表管理") @RestController @RequestMapping("/bis/insp/svwt/wunt/rgstr") public class BisInspSvwtWuntRgstrController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspSvwtWuntRgstrService bisInspSvwtWuntRgstrService; @Autowired private AttWuntBaseService wuntBaseService; @Autowired private BisInspAllObjService objService; @Autowired private OlBisInspOrgService olBisInspOrgService; @ApiOperation(value = "添加/修改用水单位督查登记表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspSvwtWuntRgstr", value = "BisInspSvwtWuntRgstr", required = true) @RequestBody BisInspSvwtWuntRgstr bisInspSvwtWuntRgstr) { bisInspSvwtWuntRgstr.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId())); if (StringUtils.isBlank(bisInspSvwtWuntRgstr.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspSvwtWuntRgstr.setId(uuid); bisInspSvwtWuntRgstrService.insert(bisInspSvwtWuntRgstr); } else { bisInspSvwtWuntRgstrService.update(bisInspSvwtWuntRgstr); if (StringUtils.isNotBlank(bisInspSvwtWuntRgstr.getObjId())) { BisInspAllObjParam param = new BisInspAllObjParam(); param.setObjId(bisInspSvwtWuntRgstr.getObjId()); BisInspAllObj obj = objService.getBy(param); obj.setNm(bisInspSvwtWuntRgstr.getUtName()); objService.update(obj); if (StringUtils.isNotBlank(obj.getCode())) { AttWuntBase base = wuntBaseService.get(obj.getCode()); if (base != null) { String id = base.getId(); BeanUtil.copyObject1(bisInspSvwtWuntRgstr, base); base.setId(id); wuntBaseService.update(base); } } } } return buildSuccessResponse(bisInspSvwtWuntRgstr); } @ApiOperation(value = "根据ID删除用水单位督查登记表") @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = bisInspSvwtWuntRgstrService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "根据ID获取用水单位督查登记表(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspSvwtWuntRgstr bisInspSvwtWuntRgstr = bisInspSvwtWuntRgstrService.get(id); return buildSuccessResponse(bisInspSvwtWuntRgstr); } @ApiOperation(value = "获取用水单位督查登记表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspSvwtWuntRgstrParam", value = "bisInspSvwtWuntRgstrParam", required = true) @RequestBody BisInspSvwtWuntRgstrParam bisInspSvwtWuntRgstrParam) { bisInspSvwtWuntRgstrParam.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId())); List bisInspSvwtWuntRgstrList = bisInspSvwtWuntRgstrService.findList(bisInspSvwtWuntRgstrParam); return buildSuccessResponse(bisInspSvwtWuntRgstrList); } @ApiOperation(value = "获取用水单位督查登记表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspSvwtWuntRgstrParam", value = "bisInspSvwtWuntRgstrParam", required = true) @RequestBody BisInspSvwtWuntRgstrParam bisInspSvwtWuntRgstrParam) { bisInspSvwtWuntRgstrParam.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId())); PageInfo bisInspSvwtWuntRgstrList = bisInspSvwtWuntRgstrService.findPageInfo(bisInspSvwtWuntRgstrParam); return buildSuccessResponse(bisInspSvwtWuntRgstrList); } @Authority @ApiOperation(value = "获取督查对象") @RequestMapping(value = "/findSvwtWuntPage", method = RequestMethod.POST) public BaseResponse> findSvwtWuntPage(@RequestBody TypeParam param, HttpServletResponse response) { param.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId())); param.setOrgId(getCurrentOrgId()); if (StringUtils.isBlank(param.getTabType())) { param.setTabType(CommonLabel.TAB_TYPE); } String nowTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); param.setNowTime(nowTime); param.setInIdsSql(SqlUtils.getinIdsSql(getCurrentPersId(), param.getProvince())); PageInfo pageInfo = bisInspSvwtWuntRgstrService.findSvwtWuntPage(param, response); return buildSuccessResponse(pageInfo); } @Authority @ApiOperation(value = "获取督查对象") @RequestMapping(value = "/findSvwtWuntList", method = {RequestMethod.POST, RequestMethod.GET}) public BaseResponse> findSvwtWuntList(TypeParam param) { param.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId())); param.setOrgId(getCurrentOrgId()); if (StringUtils.isBlank(param.getTabType())) { param.setTabType(CommonLabel.TAB_TYPE); } String nowTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); param.setNowTime(nowTime); param.setInIdsSql(SqlUtils.getinIdsSql(getCurrentPersId(), param.getProvince())); List pageInfo = bisInspSvwtWuntRgstrService.findSvwtWuntList(param); return buildSuccessResponse(pageInfo); } }