package cn.com.goldenwater.dcproj.controller.ducha; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.model.BisInspBaseChkLog; import cn.com.goldenwater.dcproj.param.AttRsBaseParam; import cn.com.goldenwater.dcproj.param.BisInspBaseChkLogParam; import cn.com.goldenwater.dcproj.service.BisInspBaseChkLogService; import cn.com.goldenwater.id.util.UuidUtil; import com.github.pagehelper.PageInfo; 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.transaction.annotation.Transactional; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * @author litf * @date 2019-3-14 */ @Api(value = "0314基础信息审核管理", tags = "基础信息审核管理") @RestController @RequestMapping("/dc/insp/baseChk") public class BisInspBaseChkLogController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspBaseChkLogService bisInspBaseChkLogService; @ApiIgnore @ApiOperation(value = "添加审核信息") @RequestMapping(value = "/insert", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspBaseChkLog", value = "BisInspBaseChkLog", required = true) @RequestBody BisInspBaseChkLog bisInspBaseChkLog) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspBaseChkLog.setChkId(uuid); int ret = bisInspBaseChkLogService.insert(bisInspBaseChkLog); return buildSuccessResponse(uuid); } @ApiOperation(value = "根据ID删除审核信息") @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = bisInspBaseChkLogService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "更新审核信息") @RequestMapping(value = "/update", method = RequestMethod.POST) public BaseResponse update(@ApiParam(name = "bisInspBaseChkLog", value = "BisInspBaseChkLog", required = true) @RequestBody BisInspBaseChkLog bisInspBaseChkLog) { Assert.notNull(bisInspBaseChkLog.getChkId(), "主键id为必填参数"); int ret = bisInspBaseChkLogService.update(bisInspBaseChkLog); return buildSuccessResponse(); } @ApiOperation(value = "根据ID获取审核(单表)") @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspBaseChkLog bisInspBaseChkLog = bisInspBaseChkLogService.get(id); return buildSuccessResponse(bisInspBaseChkLog); } @ApiOperation(value = "审核信息列表查询") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@RequestBody BisInspBaseChkLogParam param) { PageInfo list = bisInspBaseChkLogService.findPageInfo(param); return buildSuccessResponse(list); } @ApiOperation(value = "获取待审核水库") @RequestMapping(value = "/list/chkRes", method = RequestMethod.POST) public BaseResponse>> getRes(@RequestBody AttRsBaseParam param) { PageInfo> list = bisInspBaseChkLogService.getReviewRes(param); return buildSuccessResponse(list); } @Transactional @ApiOperation(value = "水库信息审核(通过/不通过)") @RequestMapping(value = "/res/insert", method = RequestMethod.POST) public BaseResponse resInsert(@ApiParam(name = "bisInspBaseChkLog", value = "BisInspBaseChkLog", required = true) @RequestBody BisInspBaseChkLog bisInspBaseChkLog) { Assert.notNull(bisInspBaseChkLog.getObjCode(), "审核对象代码为必填参数"); Assert.notNull(bisInspBaseChkLog.getChkIn(), "审核状态为必填参数"); String id = bisInspBaseChkLogService.insertRes(bisInspBaseChkLog); if (id != null) { return buildSuccessResponse(id); } return buildFailResponse(1001, "审核流程发生异常"); } @ApiOperation(value = "获取更新水库差异性") @RequestMapping(value = "/getResChange", method = RequestMethod.POST) public BaseResponse>> getResChange(@RequestParam String rsCode) { List> oldList = bisInspBaseChkLogService.getResByRsCode("ATT_RS_BASE", rsCode); List> newList = bisInspBaseChkLogService.getResByRsCode("ATT_RS_BASE_CRRCT", rsCode); HashMap oldRes = new HashMap<>(10); HashMap newRes = new HashMap<>(10); oldRes.put("oldRes", oldList.get(0)); newRes.put("newRes", newList.get(0)); List> res = new ArrayList<>(); res.add(oldRes); res.add(newRes); return buildSuccessResponse(res); } @ApiOperation(value = "审核通过") @RequestMapping(value = "/setPass", method = RequestMethod.GET) public BaseResponse setPass(@ApiParam(name = "rsCode", value = "rsCode", required = true) @PathVariable String rsCode) { BisInspBaseChkLog bisInspBaseChkLog = bisInspBaseChkLogService.get(rsCode); return buildSuccessResponse(bisInspBaseChkLog); } public boolean equals(Object oldObj, Object newObj) { if (oldObj == null && newObj == null) { return true; // 都为null } else if (oldObj == null && newObj != null) { return false; } else if (newObj == null && oldObj != null) { return false; } else if (oldObj.equals(newObj)) { return true; } return false; } }