diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java index cf3c06b7..7ae139f8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java @@ -3,6 +3,7 @@ package com.bonus.material.clz.controller; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.material.basic.domain.BmProject; import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; import com.bonus.material.clz.service.ClzSltAgreementInfoService; @@ -50,6 +51,12 @@ public class ClzSltAgreementInfoController extends BaseController { return getDataTable(list); } + @ApiOperation(value = "工程下拉选根据材料站单位查询") + @PostMapping("getProjectListByUnitIds") + public AjaxResult getProjectListByUnitIds(@RequestBody BmProject bmProject) { + return clzSltAgreementInfoService.getProjectListByUnitIds(bmProject); + } + @ApiOperation(value = "根据协议获取结算清单") @PostMapping("/getSltInfo") public AjaxResult getSltInfo(@RequestBody List list) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java index cbab6cb9..4fdabf03 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java @@ -1,5 +1,6 @@ package com.bonus.material.clz.mapper; +import com.bonus.common.biz.domain.ProjectTreeNode; import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; import com.bonus.material.settlement.domain.SltAgreementReduce; @@ -20,6 +21,11 @@ public interface ClzSltAgreementInfoMapper { */ List getSltAgreementInfo4Project(MaterialSltAgreementInfo bean); + Integer[] getProjectListByUnitIds(int unitId); + + List getProjectList(int projectId); + + /** * 获取租赁列表 * @param info diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java index f33c8eea..6a2967b0 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java @@ -1,5 +1,7 @@ package com.bonus.material.clz.service; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.basic.domain.BmProject; import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; @@ -25,6 +27,14 @@ public interface ClzSltAgreementInfoService { */ MaterialSltInfoVo getSltInfo(MaterialSltAgreementInfo info); + /** + * 工程下拉框 + * + * @param bmProject 工程下拉框 + * @return 工程下拉框 + */ + AjaxResult getProjectListByUnitIds(BmProject bmProject); + /** * 提交结算清单 * @param sltInfoVo diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java index d4d8389c..300e8ba6 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java @@ -1,21 +1,24 @@ package com.bonus.material.clz.service.impl; +import com.bonus.common.biz.domain.ProjectTreeBuild; +import com.bonus.common.biz.domain.ProjectTreeNode; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; +import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.basic.domain.BmProject; import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; import com.bonus.material.clz.mapper.ClzSltAgreementInfoMapper; import com.bonus.material.clz.service.ClzSltAgreementInfoService; import com.bonus.material.settlement.domain.SltAgreementReduce; import com.bonus.material.settlement.domain.SltAgreementRelation; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -103,6 +106,64 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic return sltInfoVo; } + /** + * 工程下拉框 + * + * @param bmProject 工程下拉框 + * @return 工程下拉框 + */ + @Override + public AjaxResult getProjectListByUnitIds(BmProject bmProject) { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + try { + if (bmProject.getUnitIds()!=null) { + Map map= new HashMap<>(); + for (int i = 0; i < bmProject.getUnitIds().length; i++) { + int id = bmProject.getUnitIds()[i]; + Integer[] projectIds= clzSltAgreementInfoMapper.getProjectListByUnitIds(bmProject.getUnitIds()[i]); + Map mapTemp = new HashMap<>(); + for (int projectId : projectIds) { + mapTemp.put(projectId, 1); + } + mapTemp.forEach((k,v) -> { + if (map.containsKey(k)) { + map.put(k, map.get(k) + v); + } else { + map.put(k, v); + } + }); + } + if (!map.isEmpty()) { + List keys = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue() == bmProject.getUnitIds().length) { + keys.add(entry.getKey()); + } + } + for (Integer key : keys) { + List listTemp = clzSltAgreementInfoMapper.getProjectList(key); + for (ProjectTreeNode node : listTemp) { + if (!list.contains(node)) { + list.add(node); + } + } + } + } + } + + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + ProjectTreeBuild treeBuild = new ProjectTreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + return AjaxResult.error(e+"工程下拉树查询失败"); + } + return AjaxResult.success(groupList); + } + /** * 提交结算清单 * @param sltInfoVo diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml index 3a447bb5..8ef10673 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml @@ -50,8 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where agreement_id = #{agreementId} - SELECT bai.agreement_id as agreementId, bai.agreement_code as agreementCode, bui.unit_id as unitId,bui.unit_name as unitName, bp.pro_id as projectId , bp.pro_name as projectName, saa.remark,bai.protocol,saa.cost as costs, @@ -115,8 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where sai.agreement_id = #{agreementId} - select sai.id, sai.agreement_id as agreementId, bui.unit_name as unitName, @@ -173,4 +171,67 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from clz_slt_agreement_apply saa where saa.agreement_id = #{agreementId} + + + + + + \ No newline at end of file