package com.gx.obe.server.management.boq.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gx.obe.server.common.enumeration.EngineerConstants; import com.gx.obe.server.common.utils.IDUtils; import com.gx.obe.server.common.utils.ObjectUtils; import com.gx.obe.server.common.utils.StringUtils; import com.gx.obe.server.management.boq.dao.ObeMeasureTableMapper; import com.gx.obe.server.management.boq.entity.ObeMeasureTable; import com.gx.obe.server.management.boq.service.ObeMeasureTableService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; /** * @author mazc * @Description: */ @Service @Transactional public class ObeMeasureTableServiceImpl extends ServiceImpl implements ObeMeasureTableService { @Autowired private ObeMeasureTableMapper obeMeasureTableMapper; /** * @param ObeMeasureTableList * @Description: 批量更新 * @author mazc */ @Override @Transactional(rollbackFor = Exception.class) public Integer updateByBatch(List ObeMeasureTableList) { return obeMeasureTableMapper.updateBatchList(ObeMeasureTableList); } /** * @param ObeMeasureTableList * @Description: 批量插入 * @author mazc */ @Override @Transactional(rollbackFor = Exception.class) public Integer insertByBatch(List ObeMeasureTableList) { return obeMeasureTableMapper.insertByBatch(ObeMeasureTableList); } /** * @param ObeMeasureTable * @param attributes * @Description: 指定字段修改 * @author chenxw */ @Override public boolean updateAssignProperty(ObeMeasureTable ObeMeasureTable, String[] attributes) { return obeMeasureTableMapper.updateAssignProperty(ObeMeasureTable, attributes) > 0; } /** * @param ObeMeasureTableList * @param attributes * @Description: 批量指定字段修改 * @author chenxw */ @Override public Integer batchUpdateProperty(List ObeMeasureTableList, String[] attributes) { return obeMeasureTableMapper.batchUpdateProperty(ObeMeasureTableList, attributes); } /** * @param ObeMeasureTableList * @param attributes * @return * @Description: 批量添加或跟新 * @author chenxw */ @Override @Transactional(rollbackFor = Exception.class) public Integer batchSaveOrUpdate(List ObeMeasureTableList, String[] attributes) { List insertObeMeasureTableList = new ArrayList<>(); List updateObeMeasureTableList = new ArrayList<>(); for (ObeMeasureTable ObeMeasureTable : ObeMeasureTableList) { if (StringUtils.isEmpty(ObeMeasureTable.getId())) { ObeMeasureTable.setId(IDUtils.getId()); insertObeMeasureTableList.add(ObeMeasureTable); } else { updateObeMeasureTableList.add(ObeMeasureTable); } } int count = 0; if (insertObeMeasureTableList.size() > 0) { count += obeMeasureTableMapper.insertByBatch(insertObeMeasureTableList); } if (updateObeMeasureTableList.size() > 0) { count += obeMeasureTableMapper.batchUpdateProperty(updateObeMeasureTableList, attributes); } return count; } /** * @param tenderId * @param supplierId * @return * @Description: 根据措施项目清单列表 * @author mazc */ public List getAllMeasureTableQDList(String tenderId, String supplierId, String measureType) { return obeMeasureTableMapper.getAllMeasureTableQDList(tenderId, supplierId, measureType); } /** * @param tenderId * @param projectCode * @return * @Description: 获得招标项目的措施清单列表 * @author guoyr */ public List getTenderProjectMeasureTableQdList(String tenderId, String projectCode, String measureType) { return obeMeasureTableMapper.getTenderProjectMeasureTableQdList(tenderId, projectCode, measureType); } /** * @param projectId * @return * @Description: 获得措施的清单列表 * @author guoyr */ public List getMeasureTableQdList(String projectId) { return obeMeasureTableMapper.getMeasureTableQdList(projectId); } /** * @param projectId * @param measureType * @return * @Description: 获得措施项目(清单 、 定额 、 工料机汇总) * @author guoyr */ public List getMeasureTableListByProjectId(String projectId, String measureType) { return obeMeasureTableMapper.getMeasureTableListByProjectId(projectId, measureType); } /** * @param constructionIds * @return * @Description: 根据项目Id,获得措施项目(清单、定额、工料机汇总) * @author mazc */ public List getMeasureTableByConstructionIdsList(List constructionIds, String measureType) { return obeMeasureTableMapper.getMeasureTableByConstructionIdsList(constructionIds, measureType); } /** * @param projectId * @return * @Description: 获得措施的清单和定额列表 * @author guoyr */ public List getMeasureTableQdAndDeList(String projectId) { List result = new ArrayList<>(); List measureTableList = obeMeasureTableMapper.getMeasureTableQdAndDeList(projectId); for (ObeMeasureTable qdBill : measureTableList) { if (ObjectUtils.equals(qdBill.getKind(), EngineerConstants.QD)) { for (ObeMeasureTable deBill : measureTableList) { if (ObjectUtils.equals(deBill.getKind(), EngineerConstants.DE) && StringUtils.equals(qdBill.getId(), deBill.getParentId())) { qdBill.addChild(deBill); deBill.setParentMeasure(qdBill); } } result.add(qdBill); } } return result; } }