|
@@ -0,0 +1,234 @@
|
|
|
|
+package com.jeeplus.modules.workreimbursement.service;
|
|
|
|
+
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import com.jeeplus.common.persistence.Page;
|
|
|
|
+import com.jeeplus.common.service.CrudService;
|
|
|
|
+import com.jeeplus.common.service.TreeService;
|
|
|
|
+import com.jeeplus.common.utils.StringUtils;
|
|
|
|
+import com.jeeplus.modules.projectAccessory.entity.ProjectAccessoryTree;
|
|
|
|
+import com.jeeplus.modules.sys.entity.Office;
|
|
|
|
+import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
|
+import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
|
|
|
|
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
|
|
|
|
+import com.jeeplus.modules.workreimbursement.dao.WorkReimbursementTypeDao;
|
|
|
|
+import com.jeeplus.modules.workreimbursement.entity.WorkReimbursementTypeInfo;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author: 大猫
|
|
|
|
+ * @create: 2020-11-30 16:27
|
|
|
|
+ **/
|
|
|
|
+@Service
|
|
|
|
+@Transactional(readOnly = true)
|
|
|
|
+public class WorkReimbursementTypeService extends TreeService<WorkReimbursementTypeDao, WorkReimbursementTypeInfo> {
|
|
|
|
+ @Autowired
|
|
|
|
+ private WorkClientAttachmentDao workClientAttachmentDao;
|
|
|
|
+
|
|
|
|
+ public WorkReimbursementTypeInfo get(String id) {
|
|
|
|
+ return super.get(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询所有数据
|
|
|
|
+ * @param workReimbursementTypeInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<WorkReimbursementTypeInfo> findList(WorkReimbursementTypeInfo workReimbursementTypeInfo) {
|
|
|
|
+ List<WorkReimbursementTypeInfo> projectAccessoryInfoList = new ArrayList<>();
|
|
|
|
+ List<WorkReimbursementTypeInfo> listReturn = Lists.newArrayList();
|
|
|
|
+ //根据条件查询数据集合
|
|
|
|
+ List<WorkReimbursementTypeInfo> listAll = super.findList(workReimbursementTypeInfo);
|
|
|
|
+ Office company = UserUtils.getSelectCompany();
|
|
|
|
+ workReimbursementTypeInfo.setCompanyId(company.getId());
|
|
|
|
+ //根据条件查询数据集合
|
|
|
|
+ List<WorkReimbursementTypeInfo> list = super.findList(workReimbursementTypeInfo);
|
|
|
|
+ //判断,数据不为空则添加到返回集合中
|
|
|
|
+ if (listAll!=null && listAll.size()!=0){
|
|
|
|
+ projectAccessoryInfoList.addAll(listAll);
|
|
|
|
+ }
|
|
|
|
+ //判断,数据不为空则添加到返回集合中
|
|
|
|
+ if (list!=null && list.size()!=0){
|
|
|
|
+ projectAccessoryInfoList.addAll(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(projectAccessoryInfoList!=null&&projectAccessoryInfoList.size()>0&&workReimbursementTypeInfo!=null&& (StringUtils.isNotBlank(workReimbursementTypeInfo.getStandardDetail())||StringUtils.isNotBlank(workReimbursementTypeInfo.getOrderNum()))){
|
|
|
|
+ //标准内容模糊查询,查询所有父节点
|
|
|
|
+ Set<String> parentIdSet = new HashSet<>();
|
|
|
|
+ for (WorkReimbursementTypeInfo projectAccessory : projectAccessoryInfoList) {
|
|
|
|
+ String parentIds = projectAccessory.getParentIds();
|
|
|
|
+ if (StringUtils.isNotBlank(parentIds)){
|
|
|
|
+ parentIdSet.addAll(Arrays.asList(parentIds.split(",")));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (WorkReimbursementTypeInfo reviewStandard : projectAccessoryInfoList) {
|
|
|
|
+ parentIdSet.remove(reviewStandard.getId());
|
|
|
|
+ }
|
|
|
|
+ projectAccessoryInfoList.addAll(0,this.fingIds(parentIdSet,"0"));
|
|
|
|
+ projectAccessoryInfoList.addAll(0,this.fingIds(parentIdSet,UserUtils.getSelectCompany().getId()));
|
|
|
|
+ }
|
|
|
|
+ sortList(listReturn,projectAccessoryInfoList,"0",true);
|
|
|
|
+ return listReturn;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void sortList(List<WorkReimbursementTypeInfo> list, List<WorkReimbursementTypeInfo> sourcelist, String parentId, boolean cascade){
|
|
|
|
+ for (int i=0; i<sourcelist.size(); i++){
|
|
|
|
+ WorkReimbursementTypeInfo e = sourcelist.get(i);
|
|
|
|
+ if (e.getParent()!=null && StringUtils.isNotBlank(e.getParent().getId()) && e.getParent().getId().equals(parentId)){
|
|
|
|
+ list.add(e);
|
|
|
|
+ if (cascade){
|
|
|
|
+ // 判断是否还有子节点, 有则继续获取子节点
|
|
|
|
+ for (int j=0; j<sourcelist.size(); j++){
|
|
|
|
+ WorkReimbursementTypeInfo child = sourcelist.get(j);
|
|
|
|
+ if (child.getParent()!=null && StringUtils.isNotBlank(child.getParent().getId()) && child.getParent().getId().equals(e.getId())){
|
|
|
|
+ sortList(list, sourcelist, e.getId(), true);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<WorkReimbursementTypeInfo> fingIds(Set<String> parentIdSet, String companyId) {
|
|
|
|
+ return dao.fingIds(parentIdSet,companyId);
|
|
|
|
+ }
|
|
|
|
+ private List<WorkReimbursementTypeInfo> fingByIds(Set<String> parentIdSet, String companyId, String parentIds) {
|
|
|
|
+ return dao.fingByIds(parentIdSet,companyId,parentIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Page<WorkReimbursementTypeInfo> findPage(Page<WorkReimbursementTypeInfo> page, WorkReimbursementTypeInfo workReimbursementTypeInfo) {
|
|
|
|
+ return super.findPage(page, workReimbursementTypeInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional(readOnly = false)
|
|
|
|
+ public void save(WorkReimbursementTypeInfo workReimbursementTypeInfo) {
|
|
|
|
+ //设置序号
|
|
|
|
+ if(workReimbursementTypeInfo.getIsNewRecord()) {
|
|
|
|
+ workReimbursementTypeInfo.setParent(this.get(workReimbursementTypeInfo.getParent().getId()));
|
|
|
|
+ String orderNum = null;
|
|
|
|
+ //判断是否选择了父级节点。没有选择则默认为第一级别
|
|
|
|
+ if(null != workReimbursementTypeInfo.getParent()){
|
|
|
|
+ orderNum = this.selectOrderNum(workReimbursementTypeInfo.getParent().getId());
|
|
|
|
+ workReimbursementTypeInfo.setCompanyId(UserUtils.getSelectCompany().getId());
|
|
|
|
+ }else{
|
|
|
|
+ orderNum = this.selectOrderNum("0");
|
|
|
|
+ workReimbursementTypeInfo.setCompanyId("0");
|
|
|
|
+ }
|
|
|
|
+ //判断是否有数据,没有数据则默认给编号01,有则在最大数据上递增1
|
|
|
|
+ if (StringUtils.isBlank(orderNum)) {
|
|
|
|
+ workReimbursementTypeInfo.setOrderNum(workReimbursementTypeInfo.getParent().getOrderNum() + "01");
|
|
|
|
+ } else {
|
|
|
|
+ workReimbursementTypeInfo.setOrderNum(String.valueOf(Integer.valueOf(orderNum) + 1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ super.save(workReimbursementTypeInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional(readOnly = false)
|
|
|
|
+ public void delete(WorkReimbursementTypeInfo workReimbursementTypeInfo) {
|
|
|
|
+ super.delete(workReimbursementTypeInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public String selectOrderNum(String parentId) {
|
|
|
|
+ return dao.selectOrderNum(parentId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询第一级数据信息
|
|
|
|
+ * @param workReimbursementTypeInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<WorkReimbursementTypeInfo> findTreeList(WorkReimbursementTypeInfo workReimbursementTypeInfo) {
|
|
|
|
+ List<WorkReimbursementTypeInfo> workReviewStandards = new ArrayList<>();
|
|
|
|
+ List<WorkReimbursementTypeInfo> listReturn = Lists.newArrayList();
|
|
|
|
+ Office company = UserUtils.getSelectCompany();
|
|
|
|
+ workReimbursementTypeInfo.setCompanyId(company.getId());
|
|
|
|
+ List<WorkReimbursementTypeInfo> listAll = super.findList(workReimbursementTypeInfo);
|
|
|
|
+ /*workReviewStandard.setCompanyId(company.getId());
|
|
|
|
+ workReviewStandard.setProofread(1);
|
|
|
|
+ List<ProjectAccessoryInfo> list = super.findList(workReviewStandard);*/
|
|
|
|
+ if (listAll!=null && listAll.size()!=0){
|
|
|
|
+ workReviewStandards.addAll(listAll);
|
|
|
|
+ }
|
|
|
|
+ /*if (list!=null && list.size()!=0){
|
|
|
|
+ workReviewStandards.addAll(list);
|
|
|
|
+ }*/
|
|
|
|
+ sortList(listReturn,workReviewStandards,"0",true);
|
|
|
|
+ this.queryProofread(listReturn);
|
|
|
|
+ return listReturn;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void queryProofread(List<WorkReimbursementTypeInfo> listReturn){
|
|
|
|
+ List<WorkReimbursementTypeInfo> standards = dao.getByDetail();
|
|
|
|
+ if(standards==null||listReturn==null){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (WorkReimbursementTypeInfo standard : standards) {
|
|
|
|
+ for (WorkReimbursementTypeInfo reviewStandard : listReturn) {
|
|
|
|
+ if(reviewStandard!=null&&((reviewStandard.getParent()!=null&&standard.getId().equals(reviewStandard.getParent().getId()))
|
|
|
|
+ ||standard.getId().equals(reviewStandard.getId())
|
|
|
|
+ || (StringUtils.isNotBlank(reviewStandard.getParentIds())&&reviewStandard.getParentIds().contains(standard.getId()))
|
|
|
|
+ )){
|
|
|
|
+ reviewStandard.setProofread(1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据信息查询附件信息
|
|
|
|
+ * @param attachmentId
|
|
|
|
+ * @param projectId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<WorkClientAttachment> getWorkAttachments(String attachmentId, String projectId){
|
|
|
|
+ WorkClientAttachment attchment = new WorkClientAttachment();
|
|
|
|
+ attchment.setAttachmentId(attachmentId);
|
|
|
|
+ attchment.setProjectId(projectId);
|
|
|
|
+ List<WorkClientAttachment> attachments = workClientAttachmentDao.getList(attchment);
|
|
|
|
+ return attachments;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增修改删除附件信息
|
|
|
|
+ * @param projectAccessory
|
|
|
|
+ */
|
|
|
|
+ @Transactional(readOnly = false)
|
|
|
|
+ public void saveWorkAttachment(ProjectAccessoryTree projectAccessory){
|
|
|
|
+ //判断附件信息是否为空
|
|
|
|
+ if(null != projectAccessory.getWorkAttachments()){
|
|
|
|
+ for (WorkClientAttachment workClientAttachment : projectAccessory.getWorkAttachments()) {
|
|
|
|
+ //判断附件信息的id是否为空
|
|
|
|
+ if (workClientAttachment.getId() == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //判断附件信息是否是删除项
|
|
|
|
+ if (WorkClientAttachment.DEL_FLAG_NORMAL.equals(workClientAttachment.getDelFlag())) {
|
|
|
|
+ //添加附件信息基本信息
|
|
|
|
+ workClientAttachment.setAttachmentId(projectAccessory.getId());
|
|
|
|
+ workClientAttachment.setProjectId(projectAccessory.getProjectId());
|
|
|
|
+ workClientAttachment.setAttachmentUser(UserUtils.getUser().getId());
|
|
|
|
+ if (StringUtils.isBlank(workClientAttachment.getId()) || "null".equals(workClientAttachment.getId())) {
|
|
|
|
+ //新增附件信息
|
|
|
|
+ workClientAttachment.preInsert();
|
|
|
|
+ workClientAttachmentDao.insert(workClientAttachment);
|
|
|
|
+ } else {
|
|
|
|
+ //修改附件信息
|
|
|
|
+ workClientAttachment.preUpdate();
|
|
|
|
+ workClientAttachmentDao.update(workClientAttachment);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //删除附件信息
|
|
|
|
+ workClientAttachmentDao.delete(workClientAttachment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|