package cn.com.goldenwater.dcproj.controller.mend; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.controller.mend.bpm.RespDTO; import cn.com.goldenwater.dcproj.model.BisInspPblmPlist; import cn.com.goldenwater.dcproj.model.BisInspPblmPlistFormDTO; import cn.com.goldenwater.dcproj.param.BisInspPblmPlistParam; import cn.com.goldenwater.dcproj.service.BisInspPblmPlistFormService; import cn.com.goldenwater.dcproj.service.OlBisInspOrgService; import cn.com.goldenwater.dcproj.utils.AdLevelUtil; 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.hateoas.Link; import org.springframework.hateoas.mvc.ControllerLinkBuilder; import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; /** * @author lhc * @date 2020-11-4 */ @Api(value = "督查问题整改", tags = "督查问题整改") @RestController @RequestMapping("/bis/insp/pblm/plist/form") public class BisInspPblmlistFormController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspPblmPlistFormService formService; @Autowired private OlBisInspOrgService olBisInspOrgService; @ApiOperation(value = "发起-问题整改-一键下发") @RequestMapping(value = "/allStartup", method = RequestMethod.POST) public BaseResponse allStartup(@ApiParam(name = "bisInspPblmPlistParam", value = "BisInspPblmPlistParam", required = true) @RequestBody BisInspPblmPlistParam bisInspPblmPlistParam) { String orgId = getCurrentOrgId(); String province = olBisInspOrgService.getProvince(orgId); bisInspPblmPlistParam.setProvince(AdLevelUtil.getAddvcd(province)); bisInspPblmPlistParam.setOrgId(orgId); bisInspPblmPlistParam.setPersId(getCurrentPersId()); Map params = new HashMap<>(3); params.put("orgId", orgId); params.put("province", province); params.put("persId", getCurrentPersId()); formService.allStartup(bisInspPblmPlistParam, params); return buildSuccessResponse(); } @ApiOperation(value = "发起-问题整改-审批") @RequestMapping(value = "/", method = RequestMethod.POST) public BaseResponse startup(@ApiParam(name = "bisInspPblmPlist", value = "BisInspPblmPlist", required = true) @RequestBody List dtos) { String province = olBisInspOrgService.getProvince(getCurrentOrgId()); for (int i = 0; i < dtos.size(); i++) { formService.saveFormsAndStartFlow(dtos.get(i), getCurrentPersId(), getCurrentOrgId(), province); } return buildSuccessResponse(); } /** * 提交/下发 */ @ApiOperation(value = "提交") @PostMapping("/submit") public BaseResponse submit(@RequestBody BisInspPblmPlistFormDTO dto) { logger.info("=============================================提交====================================================="); return formService.submitForm(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 反馈 */ @ApiOperation(value = "反馈") @PostMapping("/feedback") public BaseResponse feedback(@RequestBody BisInspPblmPlistFormDTO dto) { logger.info("=============================================反馈====================================================="); return formService.feedbackForm(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 退回 */ @ApiOperation(value = "退回") @PostMapping("/backward") public BaseResponse backward(@RequestBody BisInspPblmPlistFormDTO dto) { logger.info("=============================================退回====================================================="); return formService.backwardForm(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 完成 */ @ApiOperation(value = "完成") @PostMapping("/complete") public BaseResponse complete(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.complete(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 下发 */ @ApiOperation(value = "下发到县 根据网关要跳转到县反馈") @PostMapping("/sendCounty") public BaseResponse sendCounty(@RequestBody BisInspPblmPlistFormDTO dto) { logger.info("=============================================根据网关要跳转到县反馈====================================================="); return formService.sendCountyForm(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 转省本级反馈 */ @ApiOperation(value = "转省本级反馈") @PostMapping("/sendProvince") public BaseResponse sendProvince(@RequestBody BisInspPblmPlistFormDTO dto) { logger.info("=============================================转省本级反馈====================================================="); return formService.sendProvinceForm(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 市转本级反馈 */ @ApiOperation(value = "下发 市转本级反馈") @PostMapping("/feedbackCity") public BaseResponse feedbackCity(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.feedbackCityForm(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 暂存反馈 */ @ApiOperation(value = "暂存反馈") @PostMapping("/holdSave") public BaseResponse holdSave(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.holdSave(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 流程表单-详情明细 */ @ApiOperation(value = "流程表单-详情明细") @GetMapping("/{applyFormId}") public BaseResponse> getDetail(@PathVariable(value = "applyFormId") String applyFormId) { RespDTO result = new RespDTO<>(); result.setContent(formService.getProblemListInfo(applyFormId)); return buildSuccessResponse(buildLinks(result)); } /** * 转 水利工程建设处 审核 山东 */ @ApiOperation(value = "转 水利工程建设处 审核 山东") @PostMapping("/sendBuild") public BaseResponse sendBuild(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.sendBuild(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 转 运行管理处 审核 山东 */ @ApiOperation(value = "转 运行管理处 审核 山东") @PostMapping("/sendRunMgr") public BaseResponse sendRunMgr(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.sendRunMgr(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 转 水旱灾害防御处 审核 山东 */ @ApiOperation(value = "转 水旱灾害防御处 审核 山东") @PostMapping("/sendFloods") public BaseResponse sendFloods(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.sendFloods(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 转 农村水利处 审核 山东 */ @ApiOperation(value = "转 农村水利处 审核 山东") @PostMapping("/sendWater") public BaseResponse sendWater(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.sendWater(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 转 监督处 审核 山东 */ @ApiOperation(value = "转 监督处 审核 山东") @PostMapping("/sendSupervise") public BaseResponse sendSupervise(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.sendSupervise(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 转 南水北调工程管理处 审核 山东 */ @ApiOperation(value = "转 河湖管理处 审核 山东") @PostMapping("/sendSouth") public BaseResponse sendSouth(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.sendSouth(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 转 河湖管理处 审核 山东 */ @ApiOperation(value = "转 河湖管理处 审核 山东") @PostMapping("/sendLakes") public BaseResponse sendLakes(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.sendLakes(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * 转 行政许可处 审核 山东 */ @ApiOperation(value = "转 河湖管理处 审核 山东") @PostMapping("/sendPermissions") public BaseResponse sendPermissions(@RequestBody BisInspPblmPlistFormDTO dto) { return formService.sendPermissions(dto, getCurrentPersId(), getCurrentOrgId()) ? buildSuccessResponse() : buildFailResponse(); } /** * _links */ private RespDTO buildLinks(RespDTO result) { Link submitLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).submit(null)).withRel("submit"); Link feedbackLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).feedback(null)).withRel("feedback"); Link backwardLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).backward(null)).withRel("backward"); Link sendCountyLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).sendCounty(null)).withRel("sendCounty"); Link feedbackCityLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).feedbackCity(null)).withRel("feedbackCity"); Link completeLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).complete(null)).withRel("complete"); Link sendProvinceLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).sendProvince(null)).withRel("sendProvince"); Link holdSaveLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).holdSave(null)).withRel("holdSave"); //山东构建发送不同业务处室 Link sendBuildLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).sendBuild(null)).withRel("sendBuild"); Link sendRunMgrLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).sendRunMgr(null)).withRel("sendRunMgr"); Link sendFloodsLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).sendFloods(null)).withRel("sendFloods"); Link sendWaterLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).sendWater(null)).withRel("sendWater"); Link sendSuperviseLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).sendSupervise(null)).withRel("sendSupervise"); Link sendSouthLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).sendSouth(null)).withRel("sendSouth"); Link sendLakesLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).sendLakes(null)).withRel("sendLakes"); Link sendPermissionsLink = linkTo(ControllerLinkBuilder.methodOn(BisInspPblmlistFormController.class).sendPermissions(null)).withRel("sendPermissions"); Map linkMap = new HashMap<>(); linkMap.put("submit", submitLink.getHref().substring(submitLink.getHref().indexOf("/bis/"))); linkMap.put("feedback", feedbackLink.getHref().substring(feedbackLink.getHref().indexOf("/bis/"))); linkMap.put("backward", backwardLink.getHref().substring(backwardLink.getHref().indexOf("/bis/"))); linkMap.put("sendCounty", sendCountyLink.getHref().substring(sendCountyLink.getHref().indexOf("/bis/"))); linkMap.put("feedbackCity", feedbackCityLink.getHref().substring(feedbackCityLink.getHref().indexOf("/bis/"))); linkMap.put("complete", completeLink.getHref().substring(completeLink.getHref().indexOf("/bis/"))); linkMap.put("sendProvince", sendProvinceLink.getHref().substring(sendProvinceLink.getHref().indexOf("/bis/"))); linkMap.put("holdSave", holdSaveLink.getHref().substring(holdSaveLink.getHref().indexOf("/bis/"))); linkMap.put("sendBuild", sendBuildLink.getHref().substring(sendBuildLink.getHref().indexOf("/bis/"))); linkMap.put("sendRunMgr", sendRunMgrLink.getHref().substring(sendRunMgrLink.getHref().indexOf("/bis/"))); linkMap.put("sendFloods", sendFloodsLink.getHref().substring(sendFloodsLink.getHref().indexOf("/bis/"))); linkMap.put("sendWater", sendWaterLink.getHref().substring(sendWaterLink.getHref().indexOf("/bis/"))); linkMap.put("sendSupervise", sendSuperviseLink.getHref().substring(sendSuperviseLink.getHref().indexOf("/bis/"))); linkMap.put("sendSouth", sendSouthLink.getHref().substring(sendSouthLink.getHref().indexOf("/bis/"))); linkMap.put("sendLakes", sendLakesLink.getHref().substring(sendLakesLink.getHref().indexOf("/bis/"))); linkMap.put("sendPermissions", sendPermissionsLink.getHref().substring(sendPermissionsLink.getHref().indexOf("/bis/"))); result.set_links(linkMap); return result; } }