package cn.com.goldenwater.dcproj.controller.rsml; import cn.com.goldenwater.dcproj.model.*; import cn.com.goldenwater.dcproj.param.BisInspRsmlRgstrPresParam; import cn.com.goldenwater.dcproj.service.AttRsBaseService; import cn.com.goldenwater.dcproj.service.BisInspRsmlRgstrPresService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.service.BisInspRsmlRgstrService; 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 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.HttpServletRequest; import java.util.Date; import java.util.List; /** * @author lune * @date 2020-3-9 */ @Api(value = "BIS 三个责任人落实情况管理",tags="BIS 三个责任人落实情况管理") @RestController @RequestMapping("/bis/insp/rsml/rgstr/pres") public class BisInspRsmlRgstrPresController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspRsmlRgstrPresService bisInspRsmlRgstrPresService; @Autowired private BisInspRsmlRgstrService bisInspRsmlRgstrService; @Autowired private AttRsBaseService attRsBaseService; @ApiOperation(value = "添加/修改三个责任人落实情况") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspRsmlRgstrPres", value = "BisInspRsmlRgstrPres", required = true) @RequestBody BisInspRsmlRgstrPres bisInspRsmlRgstrPres) { if(StringUtils.isBlank(bisInspRsmlRgstrPres.getId())) { BisInspRsmlRgstrPresParam presParam = new BisInspRsmlRgstrPresParam(); presParam.setRgstrId(bisInspRsmlRgstrPres.getRgstrId()); List list = bisInspRsmlRgstrPresService.findList(presParam); if (list.size() > 0) { bisInspRsmlRgstrPres.setId(list.get(0).getId()); bisInspRsmlRgstrPres.setUptm(new Date()); bisInspRsmlRgstrPresService.update(bisInspRsmlRgstrPres); } else { String uuid = UuidUtil.uuid(); // 生成uuid bisInspRsmlRgstrPres.setIntm(new Date()); bisInspRsmlRgstrPres.setUptm(new Date()); bisInspRsmlRgstrPres.setId(uuid); bisInspRsmlRgstrPresService.insert(bisInspRsmlRgstrPres); } }else{ bisInspRsmlRgstrPres.setUptm(new Date()); bisInspRsmlRgstrPresService.update(bisInspRsmlRgstrPres); } if (StringUtils.isNotBlank(bisInspRsmlRgstrPres.getRgstrId())) { BisInspRsmlRgstr rgstr = bisInspRsmlRgstrService.get(bisInspRsmlRgstrPres.getRgstrId()); if (rgstr != null) { rgstr.setPresState(bisInspRsmlRgstrPres.getStatus()); if (!"2".equals(rgstr.getState())) { rgstr.setState("1"); } bisInspRsmlRgstrService.update(rgstr); } } return buildSuccessResponse(bisInspRsmlRgstrPres); } @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 = bisInspRsmlRgstrPresService.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) { BisInspRsmlRgstrPres bisInspRsmlRgstrPres = bisInspRsmlRgstrPresService.get(id); return buildSuccessResponse(bisInspRsmlRgstrPres); } @ApiOperation(value = "获取三个责任人落实情况(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspRsmlRgstrPresParam", value = "bisInspRsmlRgstrPresParam", required = true) @RequestBody BisInspRsmlRgstrPresParam bisInspRsmlRgstrPresParam) { List bisInspRsmlRgstrPresList = bisInspRsmlRgstrPresService.findList(bisInspRsmlRgstrPresParam); return buildSuccessResponse(bisInspRsmlRgstrPresList); } @ApiOperation(value = "获取三个责任人落实情况(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspRsmlRgstrPresParam", value = "bisInspRsmlRgstrPresParam", required = true) @RequestBody BisInspRsmlRgstrPresParam bisInspRsmlRgstrPresParam) { PageInfo bisInspRsmlRgstrPresList = bisInspRsmlRgstrPresService.findPageInfo(bisInspRsmlRgstrPresParam); return buildSuccessResponse(bisInspRsmlRgstrPresList); } @ApiOperation(value = "根据rgstrId获取三个责任人落实情况") @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET) public BaseResponse getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId, HttpServletRequest request) { BisInspRsmlRgstrPresParam presParam = new BisInspRsmlRgstrPresParam(); presParam.setRgstrId(rgstrId); BisInspRsmlRgstrPres pres = bisInspRsmlRgstrPresService.getBy(presParam); if (pres == null) { pres = new BisInspRsmlRgstrPres(); BisInspRsmlRgstr rgstr = bisInspRsmlRgstrService.get(rgstrId); AttRsBase rsBase = attRsBaseService.get(rgstr.getRsCode()); if (rsBase != null) { pres.setWiunWaoLegPers(rsBase.getWiunWaoLegPers()); pres.setWiunWaoLegPersTel(rsBase.getWiunWaoLegPersTel()); pres.setWiunWaoLegPersDuty(rsBase.getWiunWaoLegPersDuty()); pres.setTechPers(rsBase.getTechPers()); pres.setTechPersTel(rsBase.getTechPersTel()); pres.setTechPersDuty(rsBase.getTechPersDuty()); pres.setPatrolPers(rsBase.getPatrolPers()); pres.setPatrolPersTel(rsBase.getPatrolPersTel()); } } return buildSuccessResponse(pres); } }