| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- package cn.com.goldenwater.dcproj.controller.tac;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.dto.TacInspYearBatchObjDto;
- import cn.com.goldenwater.dcproj.dto.TacObjDto;
- import cn.com.goldenwater.dcproj.model.AttAdBase;
- import cn.com.goldenwater.dcproj.model.BisInspAllNode;
- import cn.com.goldenwater.dcproj.model.TacAttPawpBase;
- import cn.com.goldenwater.dcproj.model.TacInspYearBatchObj;
- import cn.com.goldenwater.dcproj.param.TacInspYearBatchObjParam;
- import cn.com.goldenwater.dcproj.service.AttAdBaseService;
- import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
- import cn.com.goldenwater.dcproj.service.TacInspYearBatchObjService;
- import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
- 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.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 java.util.ArrayList;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Set;
- /**
- * @author lune
- * @date 2019-9-6
- */
- @Api(value = "TAC 稽察对象名录表管理", tags = "TAC 稽察对象名录表管理")
- @RestController
- @RequestMapping("/tac/insp/year/batch/obj")
- public class TacInspYearBatchObjController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private TacInspYearBatchObjService tacInspYearBatchObjService;
- @Autowired
- private OlBisInspOrgService olBisInspOrgService;
- @ApiOperation(value = "添加/修改稽察对象名录表")
- @RequestMapping(value = "", method = RequestMethod.POST)
- public BaseResponse<TacInspYearBatchObj> insert(@ApiParam(name = "tacInspYearBatchObj", value = "TacInspYearBatchObj", required = true) @RequestBody TacInspYearBatchObj tacInspYearBatchObj) {
- tacInspYearBatchObj.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- if (StringUtils.isBlank(tacInspYearBatchObj.getId())) {
- String uuid = UuidUtil.uuid(); // 生成uuid
- tacInspYearBatchObj.setId(uuid);
- tacInspYearBatchObjService.insert(tacInspYearBatchObj);
- } else {
- tacInspYearBatchObjService.update(tacInspYearBatchObj);
- }
- return buildSuccessResponse(tacInspYearBatchObj);
- }
- @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 = tacInspYearBatchObjService.delete(id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据ID获取稽察对象名录表(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<TacInspYearBatchObj> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- TacInspYearBatchObj tacInspYearBatchObj = tacInspYearBatchObjService.get(id);
- return buildSuccessResponse(tacInspYearBatchObj);
- }
- @ApiOperation(value = "获取稽察对象名录表(列表所有)")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- public BaseResponse<List<TacInspYearBatchObj>> list(@ApiParam(name = "tacInspYearBatchObjParam", value = "tacInspYearBatchObjParam", required = true) @RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
- tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- List<TacInspYearBatchObj> tacInspYearBatchObjList = tacInspYearBatchObjService.findList(tacInspYearBatchObjParam);
- return buildSuccessResponse(tacInspYearBatchObjList);
- }
- @ApiOperation(value = "获取稽察批次下包含对象名录列表")
- @RequestMapping(value = "/objsListByBatch", method = RequestMethod.POST)
- public BaseResponse<List<TacInspYearBatchObjDto>> objslistbybatch(@ApiParam(name = "tacInspYearBatchObjParam", value = "tacInspYearBatchObjParam", required = true) @RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
- tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- List<TacInspYearBatchObjDto> tacInspYearBatchAreaList = tacInspYearBatchObjService.objslistbybatch(tacInspYearBatchObjParam);
- return buildSuccessResponse(tacInspYearBatchAreaList);
- }
- @ApiOperation(value = "获取稽察对象名录表(列表--分页)")
- @RequestMapping(value = "/page", method = RequestMethod.POST)
- public BaseResponse<PageInfo<TacInspYearBatchObj>> page(@ApiParam(name = "tacInspYearBatchObjParam", value = "tacInspYearBatchObjParam", required = true) @RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
- tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- PageInfo<TacInspYearBatchObj> tacInspYearBatchObjList = tacInspYearBatchObjService.findPageInfo(tacInspYearBatchObjParam);
- return buildSuccessResponse(tacInspYearBatchObjList);
- }
- @ApiOperation(value = "获取稽察对象名录列表list")
- @RequestMapping(value = "/getObjList", method = RequestMethod.POST)
- public BaseResponse<List<TacInspYearBatchObjDto>> getObjList(@RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
- tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- List<TacInspYearBatchObjDto> list = tacInspYearBatchObjService.getObjList(tacInspYearBatchObjParam);
- return buildSuccessResponse(list);
- }
- @ApiOperation(value = "获取稽察对象名录列表分页列表")
- @RequestMapping(value = "/getObjPage", method = RequestMethod.POST)
- public BaseResponse<PageInfo<TacInspYearBatchObjDto>> getObjPage(@RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
- tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- PageInfo<TacInspYearBatchObjDto> pageInfo = tacInspYearBatchObjService.getObjPage(tacInspYearBatchObjParam);
- return buildSuccessResponse(pageInfo);
- }
- @ApiOperation(value = "添加督查对象")
- @RequestMapping(value = "/inesrtBatchObj", method = RequestMethod.POST)
- public BaseResponse inesrtBatchObj(@RequestBody TacObjDto dto) {
- if (dto == null) {
- return buildFailResponse();
- }
- dto.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- int a = tacInspYearBatchObjService.insertBatchObj(dto);
- return buildSuccessResponse();
- }
- @ApiOperation("根据督查对象删除对象所有信息")
- @RequestMapping(value = "/cleanObjById", method = RequestMethod.POST)
- public BaseResponse cleanObjById(@RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
- if (StringUtils.isBlank(tacInspYearBatchObjParam.getOjbId())) {
- return buildFailResponse(10009, "删除失败");
- }
- tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- int a = tacInspYearBatchObjService.cleanObjById(tacInspYearBatchObjParam);
- return buildSuccessResponse();
- }
- @ApiOperation("获取不在组下面的基础信息")
- @RequestMapping(value = "/getBaseNotInGroupByGroupId", method = RequestMethod.POST)
- public BaseResponse<List<TacAttPawpBase>> getBaseNotInGroupByGroupId(@RequestBody TacInspYearBatchObjParam param) {
- param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- List<TacAttPawpBase> list = tacInspYearBatchObjService.getBaseNotInGroupByGroupId(param);
- return buildSuccessResponse(list);
- }
- @ApiOperation("获取不在组下面的基础信息")
- @RequestMapping(value = "/getBaseNotInGroupPageByGroupId", method = RequestMethod.POST)
- public BaseResponse<PageInfo<TacAttPawpBase>> getBaseNotInGroupPageByGroupId(@RequestBody TacInspYearBatchObjParam param) {
- param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- PageInfo<TacAttPawpBase> pageInfo = tacInspYearBatchObjService.getBaseNotInGroupPageByGroupId(param);
- return buildSuccessResponse(pageInfo);
- }
- @ApiOperation("获取左侧机构数")
- @RequestMapping(value = "/getObjTreeList", method = RequestMethod.POST)
- public BaseResponse getObjTreeList(@RequestBody TacInspYearBatchObjParam param) {
- if (StringUtils.isBlank(param.getPersId())) {
- return buildFailResponse(17001, "人员id不能为空");
- }
- param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- BisInspAllNode node = tacInspYearBatchObjService.getObjTreeList(param);
- return buildSuccessResponse(node);
- }
- @Autowired
- private AttAdBaseService xBaseService;
- @ApiOperation("获取左侧机构数")
- @RequestMapping(value = "/getObjTreeListV2", method = RequestMethod.POST)
- public BaseResponse getObjTreeListV2(@RequestBody TacInspYearBatchObjParam param) {
- if (StringUtils.isBlank(param.getPersId())) {
- return buildFailResponse(17001, "人员id不能为空");
- }
- param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- BisInspAllNode node = tacInspYearBatchObjService.getObjTreeList(param);
- //获取所有省 ,市,县的行政区数据 前两位
- List<AttAdBase> attAdBases = xBaseService.getAllChildByCode(AdLevelUtil.getAddvcd(param.getProvince()));
- if (node != null) {
- //年度
- List<BisInspAllNode> nodeList = node.getChildren();
- //批次
- List<BisInspAllNode> piciList = new ArrayList<>();
- //市级
- List<BisInspAllNode> cityList = new ArrayList<>();
- if (nodeList == null) {
- return buildSuccessResponse(node);
- }
- for (BisInspAllNode n : nodeList) {
- piciList.addAll(n.getChildren());
- }
- for (BisInspAllNode n : piciList) {
- cityList.addAll(n.getChildren());
- }
- //市级分组
- for (BisInspAllNode n : cityList) {
- List<BisInspAllNode> leafList = n.getChildren();
- Set<String> adCodes = new HashSet<>();
- List<BisInspAllNode> xianList = new ArrayList<>();
- //获取县级单位
- for (BisInspAllNode inspAllNode : leafList) {
- if (inspAllNode.getAdCode().contains(",")) {
- String[] array = inspAllNode.getAdCode().split(",");
- for (String str : array) {
- adCodes.add(str);
- }
- } else {
- adCodes.add(inspAllNode.getAdCode());
- }
- }
- //构建县级单位和子模块
- for (String str : adCodes) {
- BisInspAllNode inspAllNode = new BisInspAllNode();
- List<BisInspAllNode> newleafList = new ArrayList<>();
- inspAllNode.setPid(n.getId());
- String cityId = UuidUtil.uuid();
- inspAllNode.setId(cityId);
- AttAdBase xBase = null;
- for (AttAdBase ad : attAdBases) {
- if (ad.getAdCode().equals(str)) {
- xBase = ad;
- break;
- }
- }
- if (xBase == null) {
- xBaseService.get(str);
- }
- inspAllNode.setPnm(xBase.getAdName());
- for (BisInspAllNode leaf : leafList) {
- if (leaf.getAdCode().equals(str)) {
- leaf.setPid(cityId);
- leaf.setAdName(xBase.getAdName());
- newleafList.add(leaf);
- }
- }
- inspAllNode.setAdCode(str);
- if (!newleafList.isEmpty()) {
- inspAllNode.setChildren(newleafList);
- }
- xianList.add(inspAllNode);
- }
- n.setChildren(xianList);
- }
- }
- return buildSuccessResponse(node);
- }
- @ApiOperation("稽察一张图获取项目接口")
- @RequestMapping(value = "/getObjListByPersId", method = RequestMethod.POST)
- public BaseResponse<List<TacInspYearBatchObjDto>> getObjListByPersId(@RequestBody TacInspYearBatchObjParam param) {
- if (StringUtils.isBlank(param.getPersId())) {
- return buildFailResponse(17001, "人员id不能为空");
- }
- param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- List<TacInspYearBatchObjDto> list = tacInspYearBatchObjService.getObjListByPersId(param);
- return buildSuccessResponse(list);
- }
- @ApiOperation("稽察一张图获取项目接口分页")
- @RequestMapping(value = "/getObjPageByPersId", method = RequestMethod.POST)
- public BaseResponse<PageInfo<TacInspYearBatchObjDto>> getObjPageByPersId(@RequestBody TacInspYearBatchObjParam param) {
- if (StringUtils.isBlank(param.getPersId())) {
- return buildFailResponse(17001, "人员id不能为空");
- }
- param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- PageInfo<TacInspYearBatchObjDto> pageInfo = tacInspYearBatchObjService.getObjPageByPersId(param);
- return buildSuccessResponse(pageInfo);
- }
- }
|