| | |
| | | package cn.huge.module.ctuser.service; |
| | | |
| | | import cn.huge.base.common.dto.SelectTermDTO; |
| | | import cn.huge.base.common.exception.ServiceException; |
| | | import cn.huge.base.common.utils.DateUtils; |
| | | import cn.huge.base.common.utils.IdUtils; |
| | | import cn.huge.base.config.CurrentUser; |
| | | import cn.huge.base.common.utils.ObjectUtils; |
| | | import cn.huge.base.common.utils.SelectTermUtils; |
| | | import cn.huge.module.client.api.impl.UtilsClientImpl; |
| | | import cn.huge.module.constant.BaseConsts; |
| | | import cn.huge.module.ctuser.dao.mapper.CtUnitMapper; |
| | | import cn.huge.module.ctuser.domain.po.CtDept; |
| | | import cn.huge.module.ctuser.domain.po.CtUnit; |
| | | import cn.huge.module.ctuser.domain.po.CtUser; |
| | | import cn.huge.module.ctuser.domain.po.CtUserole; |
| | | import cn.huge.module.ctuser.dto.CtUnitWeChatCountDTO; |
| | | import cn.huge.module.cust.constant.RoleBaseEnum; |
| | | import cn.huge.module.cust.dto.CtUserDTO; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.PageImpl; |
| | | import org.springframework.data.domain.PageRequest; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | if (IdUtils.checkNewId(ctUnit.getId())){ |
| | | ctUnit.setId(utilsClient.getNewTimeId()); |
| | | ctUnit.setCreateTime(nowDate); |
| | | }else { |
| | | // 1、更新单位信息时,更新调度规则指标目标组织名称 |
| | | mapper.updateDispNormCauseTargetUnitName(ctUnit.getUnitName(), ctUnit.getId()); |
| | | } |
| | | ctUnit.setUpdateTime(nowDate); |
| | | this.saveOrUpdate(ctUnit); |
| | |
| | | return ctUnit; |
| | | } |
| | | |
| | | /** |
| | | * 更新对象 |
| | | * |
| | | * @param ctUnit 对象 |
| | | */ |
| | | public void updateTerms(CtUnit ctUnit) { |
| | | mapper.updateTerms(ctUnit); |
| | | } |
| | | |
| | | /** |
| | | * 小程序统计机构数量 |
| | | * */ |
| | | public CtUnitWeChatCountDTO wechatCountUnit(){ |
| | | CtUnitWeChatCountDTO ctUnitWeChatCountDTO = new CtUnitWeChatCountDTO(); |
| | | QueryWrapper<CtUnit> unitQueryWrapper = new QueryWrapper<>(); |
| | | unitQueryWrapper.eq("unit_type", 1); |
| | | Integer zzUnitNum = mapper.selectCount(unitQueryWrapper); |
| | | if(ObjectUtils.isEmpty(zzUnitNum)){ |
| | | zzUnitNum = 0; |
| | | } |
| | | ctUnitWeChatCountDTO.setZzUnitNum(zzUnitNum); |
| | | List<Integer> unitTypeList = Arrays.asList(2,3,4,5); |
| | | QueryWrapper<CtUnit> unitQueryWrapper1 = new QueryWrapper<>(); |
| | | unitQueryWrapper1.in("unit_type", unitTypeList); |
| | | Integer tzUnitNum = mapper.selectCount(unitQueryWrapper1); |
| | | if(ObjectUtils.isEmpty(tzUnitNum)){ |
| | | tzUnitNum = 0; |
| | | } |
| | | ctUnitWeChatCountDTO.setTzUnitNum(tzUnitNum); |
| | | return ctUnitWeChatCountDTO; |
| | | } |
| | | |
| | | /** |
| | | * 按条件分页查询 |
| | | * |
| | | * @param userId 分页对象 |
| | | * @return Page |
| | | */ |
| | | public List<SelectTermDTO> unitChoose(String userId) { |
| | | // 获取当前登录用户 |
| | | CtUserDTO loginUser = ctUserService.clientGetUserAll(userId); |
| | | // 组织条件 |
| | | List<CtUnit> ctUnitList = mapper.listAllChild(loginUser.getUnitId()); |
| | | List<SelectTermDTO> unitSelectTerms = new ArrayList<>(); |
| | | |
| | | // 部门条件 |
| | | QueryWrapper<CtDept> ctDeptQueryWrapper = new QueryWrapper<>(); |
| | | ctDeptQueryWrapper.eq("unit_id", loginUser.getUnitId()).select("id", "unit_id", "name", "parent_id"); |
| | | List<CtDept> ctDeptList = ctDeptService.list(ctDeptQueryWrapper); |
| | | |
| | | for(CtUnit ctUnit: ctUnitList){ |
| | | SelectTermDTO unitSelectTerm = new SelectTermDTO(); |
| | | unitSelectTerm.setValue(ctUnit.getId()); |
| | | unitSelectTerm.setLabel(ctUnit.getUnitName()); |
| | | unitSelectTerm.setParentId(ctUnit.getParentId()); |
| | | unitSelectTerm.setCheckable(true); |
| | | List<SelectTermDTO> deptSelectTerms = new ArrayList<>(); |
| | | if(loginUser.getUnitId().equals(ctUnit.getId())){ |
| | | for(CtDept ctDept : ctDeptList){ |
| | | if(ctUnit.getId().equals(ctDept.getUnitId())){ |
| | | SelectTermDTO deptSelectTerm = new SelectTermDTO(); |
| | | deptSelectTerm.setValue(ctDept.getId()); |
| | | deptSelectTerm.setLabel(ctDept.getName()); |
| | | deptSelectTerm.setParentId(ctDept.getParentId()); |
| | | deptSelectTerm.setCheckable(true); |
| | | |
| | | deptSelectTerms.add(deptSelectTerm); |
| | | } |
| | | List<SelectTermDTO> depts = SelectTermUtils.createTreeByRoot(deptSelectTerms); |
| | | unitSelectTerm.setChildren(depts); |
| | | } |
| | | } |
| | | unitSelectTerms.add(unitSelectTerm); |
| | | } |
| | | return SelectTermUtils.createTreeByFirst(unitSelectTerms, loginUser.getUnitId()); |
| | | } |
| | | } |