| | |
| | | package cn.huge.module.ctuser.controller.client; |
| | | |
| | | import cn.huge.base.common.utils.ObjectUtils; |
| | | import cn.huge.base.common.utils.ReturnFailUtils; |
| | | import cn.huge.base.common.utils.ReturnSucUtils; |
| | | import cn.huge.base.config.CurrentUser; |
| | | import cn.huge.module.ctuser.domain.po.CtUnit; |
| | | import cn.huge.module.ctuser.domain.po.CtUser; |
| | | import cn.huge.module.ctuser.service.CtUnitService; |
| | | import cn.huge.module.ctuser.service.CtUserService; |
| | | import cn.huge.module.cust.constant.UserBaseConsts; |
| | | import cn.huge.module.cust.dto.CtUnitDTO; |
| | | import cn.huge.module.cust.dto.CtUserDTO; |
| | | import cn.huge.module.region.domain.po.SyRegionGrid; |
| | | import cn.huge.module.region.service.SyRegionGridService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据id查询组织信息 |
| | | * @url {ctx}/api/client/ctUnit/getUnitById |
| | | * @param unitId 组织编号 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/getUnitById") |
| | | public Object getUnitById(@RequestParam(value = "unitId") String unitId) { |
| | | try { |
| | | CtUnit ctUnit = service.getById(unitId); |
| | | if (ObjectUtils.isNotEmpty(ctUnit)){ |
| | | CtUnitDTO ctUnitDTO = new CtUnitDTO(); |
| | | BeanUtils.copyProperties(ctUnit, ctUnitDTO); |
| | | return ReturnSucUtils.getRepInfo(ctUnitDTO); |
| | | }else { |
| | | return ReturnFailUtils.getRepInfo("查询组织不存在!"); |
| | | } |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取上级综治中心 |
| | | * @url {ctx}/api/client/ctUnit/getParentZzzxUnit |
| | | * @param unitId 组织编号 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/getParentZzzxUnit") |
| | | public Object getParentZzzxUnit(@RequestParam(value = "unitId") String unitId) { |
| | | try { |
| | | return ReturnSucUtils.getRepInfo(service.getParentZzzx(unitId)); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | private SyRegionGridService syRegionGridService; |
| | | /** |
| | | * 更新组织的地域编码 |
| | | * @url {ctx}/api/client/ctUnit/update1 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/update1") |
| | | public Object update1() { |
| | | try { |
| | | List<CtUnit> ctUnitList = service.list(); |
| | | for (CtUnit ctUnit: ctUnitList){ |
| | | ctUnit.setArea("440111"); |
| | | // 镇街级 |
| | | if (StringUtils.isNotEmpty(ctUnit.getRoad())){ |
| | | QueryWrapper<SyRegionGrid> syRegionGridQueryWrapper = new QueryWrapper<>(); |
| | | syRegionGridQueryWrapper.eq("region_id", ctUnit.getRoad()); |
| | | SyRegionGrid syRegionGrid = syRegionGridService.getOne(syRegionGridQueryWrapper); |
| | | if (ObjectUtils.isNotEmpty(syRegionGrid)){ |
| | | ctUnit.setRoad(syRegionGrid.getThirdCode()); |
| | | } |
| | | } |
| | | // 村社级 |
| | | if (UserBaseConsts.UNIT_GRADE_4 == ctUnit.getUnitGrade()){ |
| | | try{ |
| | | QueryWrapper<SyRegionGrid> syRegionGridQueryWrapper = new QueryWrapper<>(); |
| | | String thirdName = ctUnit.getUnitName().replace("居委会", "").replace("人民调解委员会", ""); |
| | | syRegionGridQueryWrapper.like("third_name", thirdName); |
| | | SyRegionGrid syRegionGrid = syRegionGridService.getOne(syRegionGridQueryWrapper); |
| | | if (ObjectUtils.isNotEmpty(syRegionGrid)){ |
| | | ctUnit.setVillage(syRegionGrid.getThirdCode()); |
| | | ctUnit.setVillageName(syRegionGrid.getThirdName()); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("报错村社:id-"+ctUnit.getId()+",name-"+ctUnit.getUnitName()); |
| | | } |
| | | } |
| | | service.updateCtUnit(ctUnit); |
| | | } |
| | | return ReturnSucUtils.getRepInfo(); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询用户所在的单位信息 |
| | | * @url {ctx}/api/client/ctUnit/getUnitByUserId |
| | | * @param userId 用户编号 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/getUnitByUserId") |
| | | public Object getUnitByUserId(@RequestParam(value = "userId") String userId) { |
| | | try { |
| | | CtUser ctUser = ctUserService.getById(userId); |
| | | CtUnit ctUnit = service.getById(ctUser.getUnitId()); |
| | | if (ObjectUtils.isNotEmpty(ctUnit)){ |
| | | CtUnitDTO ctUnitDTO = new CtUnitDTO(); |
| | | BeanUtils.copyProperties(ctUnit, ctUnitDTO); |
| | | return ReturnSucUtils.getRepInfo(ctUnitDTO); |
| | | }else { |
| | | return ReturnFailUtils.getRepInfo("查询组织不存在!"); |
| | | } |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | } |