diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/BaseService.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/BaseService.java index c82dce8253..9f5a388ab2 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/BaseService.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/BaseService.java @@ -123,5 +123,31 @@ public interface BaseService { */ boolean deleteBatchIds(Collection idList); + /** + *

+ * 存在更新记录,否插入一条记录 + *

+ * + * @param entity 实体对象 + */ + boolean saveOrUpdate(T entity); + + /** + *

+ * 批量修改插入 + *

+ * + * @param entityList 实体对象集合 + */ + boolean saveOrUpdateBatch(Collection entityList); + /** + *

+ * 批量修改插入 + *

+ * + * @param entityList 实体对象集合 + * @param batchSize 更新批次数量 + */ + boolean saveOrUpdateBatch(Collection entityList, int batchSize); } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/impl/BaseServiceImpl.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/impl/BaseServiceImpl.java index fc89437e03..445f5a6e40 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/impl/BaseServiceImpl.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/impl/BaseServiceImpl.java @@ -13,6 +13,8 @@ import com.baomidou.mybatisplus.core.enums.SqlMethod; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.core.metadata.TableInfo; +import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; import com.baomidou.mybatisplus.core.toolkit.*; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; @@ -31,6 +33,7 @@ import java.io.Serializable; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Objects; /** * 基础服务类,所有Service都要继承 @@ -298,4 +301,56 @@ public abstract class BaseServiceImpl, T> implements Bas public boolean deleteBatchIds(Collection idList) { return SqlHelper.delBool(baseDao.deleteBatchIds(idList)); } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean saveOrUpdate(T entity) { + if (null != entity) { + Class cls = entity.getClass(); + TableInfo tableInfo = TableInfoHelper.getTableInfo(cls); + Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!"); + String keyProperty = tableInfo.getKeyProperty(); + Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!"); + Object idVal = ReflectionKit.getMethodValue(cls, entity, tableInfo.getKeyProperty()); + return StringUtils.checkValNull(idVal) || Objects.isNull(selectById((Serializable) idVal)) ? insert(entity) : updateById(entity); + } + return false; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean saveOrUpdateBatch(Collection entityList) { + return saveOrUpdateBatch(entityList, 100); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean saveOrUpdateBatch(Collection entityList, int batchSize) { + Assert.notEmpty(entityList, "error: entityList must not be empty"); + Class cls = currentModelClass(); + TableInfo tableInfo = TableInfoHelper.getTableInfo(cls); + Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!"); + String keyProperty = tableInfo.getKeyProperty(); + Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!"); + try (SqlSession batchSqlSession = sqlSessionBatch()) { + int i = 0; + for (T entity : entityList) { + Object idVal = ReflectionKit.getMethodValue(cls, entity, keyProperty); + if (StringUtils.checkValNull(idVal) || Objects.isNull(selectById((Serializable) idVal))) { + batchSqlSession.insert(sqlStatement(SqlMethod.INSERT_ONE), entity); + } else { + MapperMethod.ParamMap param = new MapperMethod.ParamMap<>(); + param.put(Constants.ENTITY, entity); + batchSqlSession.update(sqlStatement(SqlMethod.UPDATE_BY_ID), param); + } + // 不知道以后会不会有人说更新失败了还要执行插入 😂😂😂 + if (i >= 1 && i % batchSize == 0) { + batchSqlSession.flushStatements(); + } + i++; + } + batchSqlSession.flushStatements(); + } + return true; + } } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/DisputeProcessMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/DisputeProcessMQMsg.java index 30a1700054..bed6aa4bf5 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/DisputeProcessMQMsg.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/DisputeProcessMQMsg.java @@ -4,6 +4,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import java.io.Serializable; +import java.util.List; /** * @Description @@ -14,7 +15,7 @@ import java.io.Serializable; @AllArgsConstructor public class DisputeProcessMQMsg implements Serializable { private String customerId; - private String projectId; + private List projectId; /** * 操作类型【新增:add 修改删除:edit】 */ diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/CompartmentResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/CompartmentResultDTO.java index 9e941152e4..52b0f9fa36 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/CompartmentResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/CompartmentResultDTO.java @@ -16,6 +16,11 @@ public class CompartmentResultDTO implements Serializable { private static final long serialVersionUID = 7963177476365327829L; + /** + * 组织对应的客户Id + */ + private String customerId = ""; + /** * 当前所选组织 */ diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java index 80d2161ebb..04000c6e57 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java @@ -305,7 +305,7 @@ public class FactIndexServiceImpl implements FactIndexService { //3.根据组织级别拼接查询条件,判断查询不同数据表 //区县级、乡镇街道级 if ("district".equals(agency.getAgencyLevel()) || "street".equals(agency.getAgencyLevel())) { - if ("district".equals(agency.getAgencyLevel())) { + if ("district".equals(agency.getAgencyLevel()) && !"2fe0065f70ca0e23ce4c26fca5f1d933".equals(agency.getCustomerId())) { formDTO.setAllParentIndexCode(FactConstant.QUAN_QU_XIANG_GUAN + ":" + formDTO.getIndexCode()); } else { formDTO.setAllParentIndexCode(FactConstant.JIE_DAO_XIANG_GUAN + ":" + formDTO.getIndexCode()); @@ -336,7 +336,7 @@ public class FactIndexServiceImpl implements FactIndexService { list.stream().filter(dto -> dto.getIndexCode().equals(result.getKey())).forEach(l -> { result.setShowType(l.getValueType()); //整数 - if (FactConstant.DECIMAL.equals(l.getValueType())) { + if (FactConstant.INTEGER.equals(l.getValueType())) { BigDecimal num = new BigDecimal(result.getValue()).setScale(0, BigDecimal.ROUND_HALF_UP); result.setValue(num.toString()); } diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml index 16c1b42383..0b619b742a 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml @@ -192,6 +192,7 @@