| | |
| | | package com.fzzy.igds.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.fzzy.igds.constant.Constant; |
| | | import com.fzzy.igds.domain.Dept; |
| | | import com.fzzy.igds.repository.DeptRepository; |
| | | import com.fzzy.igds.mapper.CoreDeptMapper; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | |
| | | @Resource |
| | | private ISysDeptService iSysDeptService; |
| | | @Resource |
| | | private DeptRepository deptRepository; |
| | | |
| | | private CoreDeptMapper coreDeptMapper; |
| | | @Resource |
| | | private InoutConfService inoutConfService; |
| | | |
| | | /** |
| | | * jpa查询信息 |
| | | * 根据条件查询库区信息 |
| | | * @param id |
| | | * @param companyId |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | public List<Dept> getDataByParentId(String parentId) { |
| | | return deptRepository.getDataByParentId(parentId + "%"); |
| | | public List<Dept> listDept(String id, String companyId, String parentId) { |
| | | |
| | | QueryWrapper<Dept> queryWrapper = new QueryWrapper<>(); |
| | | |
| | | if(StringUtils.isNotBlank(id)){ |
| | | queryWrapper.eq("id", id); |
| | | } |
| | | if(StringUtils.isNotBlank(companyId)){ |
| | | queryWrapper.eq("company_id", companyId); |
| | | } |
| | | if(StringUtils.isNotBlank(parentId)){ |
| | | queryWrapper.likeRight("id", parentId); |
| | | } |
| | | |
| | | return coreDeptMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * jpa查询信息 |
| | | * 查询信息 |
| | | * @return |
| | | */ |
| | | public List<Dept> getDeptData() { |
| | | SysUser user = ContextUtil.getLoginUser(); |
| | | SysDept userDept = iSysDeptService.selectDeptById(user.getDeptId()); |
| | | if (Constant.DEPT_TYPE_20.equals(userDept.getType())) { |
| | | return deptRepository.getDataById(ContextUtil.subDeptId(user)); |
| | | return this.listDept(ContextUtil.subDeptId(user),null,null); |
| | | }else { |
| | | return deptRepository.getDataByParentId(user.getDeptId() + "%"); |
| | | return this.listDept(null,null,user.getDeptId() + "%"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * jpa新增库区信息 |
| | | * 新增或更新库区信息 |
| | | * @param sysDept |
| | | * @param isAdd |
| | | * @return |
| | | */ |
| | | public void saveOrUpdate(SysDept sysDept) { |
| | | public void saveOrUpdate(SysDept sysDept, Boolean isAdd) { |
| | | if (null == sysDept) { |
| | | return; |
| | | } |
| | |
| | | dept.setKqmc(sysDept.getDeptName()); |
| | | dept.setCompanyId(sysDept.getCompanyId()); |
| | | |
| | | //创建信息 |
| | | dept.setCreateBy(ContextUtil.getLoginUserName()); |
| | | dept.setCreateTime(new Date()); |
| | | |
| | | this.update(dept); |
| | | if (isAdd) { |
| | | this.save(dept); |
| | | }else { |
| | | this.update(dept); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * jpa更新库区信息 |
| | | * 保存库区信息 |
| | | * @param data |
| | | */ |
| | | public void save(Dept data) { |
| | | if (StringUtils.isEmpty(data.getCompanyId())) { |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | //创建信息 |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | data.setCreateTime(new Date()); |
| | | |
| | | coreDeptMapper.insert(data); |
| | | |
| | | //初始化出入库流程配置信息 |
| | | inoutConfService.initSysConfData(data.getCompanyId(), data.getId()); |
| | | } |
| | | |
| | | /** |
| | | * 更新库区信息 |
| | | * @param data |
| | | */ |
| | | public void update(Dept data) { |
| | | if (StringUtils.isEmpty(data.getCompanyId())) { |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | |
| | | //更新信息 |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | |
| | | deptRepository.save(data); |
| | | coreDeptMapper.updateById(data); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | public void delData(String deptId) { |
| | | deptRepository.deleteById(deptId); |
| | | //删除库区信息 |
| | | coreDeptMapper.deleteById(deptId); |
| | | |
| | | //删除流程配置信息 |
| | | inoutConfService.delSysConfData(deptId); |
| | | } |
| | | } |