|
|
@ -4,9 +4,12 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
import com.glxp.api.dao.thrsys.DeptMaterialCategoryMapper;
|
|
|
|
import com.glxp.api.dao.thrsys.DeptMaterialCategoryMapper;
|
|
|
|
import com.glxp.api.entity.auth.SysRole;
|
|
|
|
import com.glxp.api.entity.auth.SysRole;
|
|
|
|
|
|
|
|
import com.glxp.api.entity.thrsys.DeptMaterialCategory;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrConsumeMaterialCategoryTree;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrConsumeMaterialCategoryTree;
|
|
|
|
|
|
|
|
import com.glxp.api.req.thrsys.UpdateBindCategoryRequest;
|
|
|
|
import com.glxp.api.res.chs.YbHcflEntityResponse;
|
|
|
|
import com.glxp.api.res.chs.YbHcflEntityResponse;
|
|
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
|
|
import com.glxp.api.util.TreeBuildUtils;
|
|
|
|
import com.glxp.api.util.TreeBuildUtils;
|
|
|
@ -17,6 +20,7 @@ import com.glxp.api.dao.thrsys.ThrConsumeMaterialCategoryMapper;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
@ -125,7 +129,10 @@ public class ThrConsumeMaterialCategoryService extends ServiceImpl<ThrConsumeMat
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
list.addAll(set);
|
|
|
|
list.addAll(set);
|
|
|
|
List<ThrConsumeMaterialCategory> collect = list.stream().sorted(Comparator.comparing(ThrConsumeMaterialCategory::getCategoryId)).collect(Collectors.toList());
|
|
|
|
List<ThrConsumeMaterialCategory> collect = list.stream().sorted(Comparator.comparing(ThrConsumeMaterialCategory::getCategoryId)).
|
|
|
|
|
|
|
|
collect(Collectors.collectingAndThen(
|
|
|
|
|
|
|
|
Collectors.toCollection(() -> new TreeSet<>(
|
|
|
|
|
|
|
|
Comparator.comparing(ThrConsumeMaterialCategory::getCategoryId))), ArrayList::new));
|
|
|
|
return collect;
|
|
|
|
return collect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -186,4 +193,32 @@ public class ThrConsumeMaterialCategoryService extends ServiceImpl<ThrConsumeMat
|
|
|
|
return getParentCategoryObject(allCategory,tblCategory);
|
|
|
|
return getParentCategoryObject(allCategory,tblCategory);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateBindCategory(UpdateBindCategoryRequest updateBindCategoryRequest) {
|
|
|
|
|
|
|
|
Long deptCode = updateBindCategoryRequest.getDeptCode();
|
|
|
|
|
|
|
|
Long[] deptCategory = updateBindCategoryRequest.getDeptCategory();
|
|
|
|
|
|
|
|
//删除原来的绑定
|
|
|
|
|
|
|
|
UpdateWrapper<DeptMaterialCategory> uw = new UpdateWrapper<>();
|
|
|
|
|
|
|
|
uw.eq("deptCode",deptCode);
|
|
|
|
|
|
|
|
deptMaterialCategoryMapper.delete(uw);
|
|
|
|
|
|
|
|
//插入新的绑定
|
|
|
|
|
|
|
|
List<DeptMaterialCategory> lists = new ArrayList<>(deptCategory.length);
|
|
|
|
|
|
|
|
for (Long aLong : deptCategory) {
|
|
|
|
|
|
|
|
DeptMaterialCategory deptMaterialCategory = new DeptMaterialCategory();
|
|
|
|
|
|
|
|
deptMaterialCategory.setDeptCode(deptCode);
|
|
|
|
|
|
|
|
deptMaterialCategory.setCategoryId(aLong);
|
|
|
|
|
|
|
|
lists.add(deptMaterialCategory);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
deptMaterialCategoryMapper.insertBatch(lists);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void deleteBindCategory(UpdateBindCategoryRequest updateBindCategoryRequest) {
|
|
|
|
|
|
|
|
Long deptCode = updateBindCategoryRequest.getDeptCode();
|
|
|
|
|
|
|
|
Long[] deptCategory = updateBindCategoryRequest.getDeptCategory();
|
|
|
|
|
|
|
|
//删除原来的绑定
|
|
|
|
|
|
|
|
UpdateWrapper<DeptMaterialCategory> uw = new UpdateWrapper<>();
|
|
|
|
|
|
|
|
uw.eq("deptCode",deptCode);
|
|
|
|
|
|
|
|
uw.in("categoryId",deptCategory);
|
|
|
|
|
|
|
|
deptMaterialCategoryMapper.delete(uw);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|