package cn.com.goldenwater.dcproj.controller.rsvr; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.constValue.SplitValue; import cn.com.goldenwater.dcproj.dao.BisInspOrgDao; import cn.com.goldenwater.dcproj.model.BisInspOrg; import cn.com.goldenwater.dcproj.model.BisInspRsvrPblmMend; import cn.com.goldenwater.dcproj.model.GwComFile; import cn.com.goldenwater.dcproj.param.BisInspRsvrPblmMendParam; import cn.com.goldenwater.dcproj.param.GwComFileParam; import cn.com.goldenwater.dcproj.service.BisInspRsvrPblmMendService; import cn.com.goldenwater.dcproj.service.GwComFileService; import cn.com.goldenwater.dcproj.utils.AdLevelUtil; import cn.com.goldenwater.dcproj.utils.HttpClientUtils; 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.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author lune * @date 2020-7-7 */ @Api(value = "BIS 小水库问题清单整改情况管理", tags = "BIS 小水库问题清单整改情况管理") @RestController @RequestMapping("/bis/insp/rsvr/pblm/mend") public class BisInspRsvrPblmMendController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspRsvrPblmMendService bisInspRsvrPblmMendService; @Autowired private BisInspOrgDao bisInspOrgDao; @Value("${mwr.ducha.url}") private String quanguoUrl; @Autowired private GwComFileService gwComFileService; @ApiOperation(value = "添加/修改小水库问题清单整改情况") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspRsvrPblmMend", value = "BisInspRsvrPblmMend", required = true) @RequestBody List bisInspRsvrPblmMendList) { for (BisInspRsvrPblmMend bisInspRsvrPblmMend : bisInspRsvrPblmMendList) { bisInspRsvrPblmMendService.update(bisInspRsvrPblmMend); } return buildSuccessResponse(); } @ApiOperation(value = "修改小水库问题清单整改情况") @RequestMapping(value = "/2021/update", method = RequestMethod.POST) public BaseResponse update2021(@ApiParam(name = "bisInspRsvrPblmMend", value = "BisInspRsvrPblmMend", required = true) @RequestBody BisInspRsvrPblmMend bisInspRsvrPblmMend) { if (StringUtils.isBlank(bisInspRsvrPblmMend.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspRsvrPblmMend.setId(uuid); bisInspRsvrPblmMend.setIntm(new Date()); bisInspRsvrPblmMendService.insert2021(bisInspRsvrPblmMend); } else { bisInspRsvrPblmMend.setUptm(new Date()); int a = bisInspRsvrPblmMendService.update2021(bisInspRsvrPblmMend); } return buildSuccessResponse(bisInspRsvrPblmMend); } @ApiOperation(value = "单条或批量反馈水利部") @RequestMapping(value = "/updateMwr", method = RequestMethod.POST) public BaseResponse updateMwr(@ApiParam(name = "bisInspRsvrPblmMend", value = "BisInspRsvrPblmMend", required = true) @RequestBody List bisInspRsvrPblmMendList) { for (BisInspRsvrPblmMend bisInspRsvrPblmMend : bisInspRsvrPblmMendList) { String url = quanguoUrl + "/bis/insp/rsvr/pblm/mend"; Map map = new HashMap<>(); map.put("id", bisInspRsvrPblmMend.getId()); map.put("rectConc", bisInspRsvrPblmMend.getRectConc()); map.put("rectMsrs", bisInspRsvrPblmMend.getRectMsrs()); try { HttpClientUtils.doHttpsPost2(url, map, new HashMap()); bisInspRsvrPblmMend.setIsRect("2"); } catch (Exception e) { logger.error("部里整改状态修改失败!:{}", e.getMessage()); bisInspRsvrPblmMend.setIsRect("3");//反馈失败 } finally { bisInspRsvrPblmMendService.update(bisInspRsvrPblmMend); } } return buildSuccessResponse(); } @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 = bisInspRsvrPblmMendService.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) { BisInspRsvrPblmMend bisInspRsvrPblmMend = bisInspRsvrPblmMendService.get(id); return buildSuccessResponse(bisInspRsvrPblmMend); } @ApiOperation(value = "根据ID获取小水库问题清单整改情况(单表)及附件") @RequestMapping(value = "/getWithExtras", method = RequestMethod.POST) public BaseResponse getWithExtras(@ApiParam(name = "param", value = "param", required = true) @RequestBody GwComFileParam param) { BisInspRsvrPblmMend bisInspRsvrPblmMend = bisInspRsvrPblmMendService.get(param.getId()); if (bisInspRsvrPblmMend != null) { param.setId(""); List list = gwComFileService.findList(param); bisInspRsvrPblmMend.setGwComFiles(list); } return buildSuccessResponse(bisInspRsvrPblmMend); } @ApiOperation(value = "获取小水库问题清单整改情况(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspRsvrPblmMendParam", value = "bisInspRsvrPblmMendParam", required = true) @RequestBody BisInspRsvrPblmMendParam bisInspRsvrPblmMendParam, HttpServletResponse response) { //bisInspRsvrPblmMendParam.setPersGuid(getCurrentPersId()); bisInspRsvrPblmMendParam.setOrgId(getCurrentOrgId()); BisInspOrg org = bisInspOrgDao.get(bisInspRsvrPblmMendParam.getOrgId()); if (StringUtils.isNotBlank(org.getRlcode())) { bisInspRsvrPblmMendParam.setRelCode(AdLevelUtil.SubAd(org.getAdCode()).get(SplitValue.SUBAD).toString()); } PageInfo bisInspRsvrPblmMendList = bisInspRsvrPblmMendService.findRsvrPblmPage(bisInspRsvrPblmMendParam); return buildSuccessResponse(bisInspRsvrPblmMendList); } @ApiOperation(value = "获取小水库问题清单整改情况(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspRsvrPblmMendParam", value = "bisInspRsvrPblmMendParam", required = true) @RequestBody BisInspRsvrPblmMendParam bisInspRsvrPblmMendParam) { List bisInspRsvrPblmMendList = bisInspRsvrPblmMendService.findList(bisInspRsvrPblmMendParam); return buildSuccessResponse(bisInspRsvrPblmMendList); } @ApiOperation(value = "Pc获取小水库问题清单整改情况(列表--分页)") @RequestMapping(value = "/pagePc", method = RequestMethod.POST) public BaseResponse> pagePc(@ApiParam(name = "bisInspRsvrPblmMendParam", value = "bisInspRsvrPblmMendParam", required = true) @RequestBody BisInspRsvrPblmMendParam bisInspRsvrPblmMendParam, HttpServletResponse response) { PageInfo pc = bisInspRsvrPblmMendService.pagerPc(bisInspRsvrPblmMendParam); return buildSuccessResponse(pc); } }