Browse Source

Merge remote-tracking branch 'remotes/origin/dev'

dev_shibei_match
jianjun 4 years ago
parent
commit
b160b16758
  1. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectProcessAttachmentDao.java
  2. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectProcessDao.java
  3. 71
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectProcessServiceImpl.java
  4. 11
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectProcessAttachmentDao.xml
  5. 11
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectProcessDao.xml

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectProcessAttachmentDao.java

@ -38,4 +38,6 @@ public interface ScreenProjectProcessAttachmentDao extends BaseDao<ScreenProject
void insertBatch(@Param("list")List<ScreenProjectProcessAttachmentDTO> list); void insertBatch(@Param("list")List<ScreenProjectProcessAttachmentDTO> list);
int deleteByProcessIds(@Param("customerId") String customerId, @Param("list") List<String> list);
} }

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectProcessDao.java

@ -41,4 +41,6 @@ public interface ScreenProjectProcessDao extends BaseDao<ScreenProjectProcessEnt
int countByCustomerId(@Param("customerId") String customerId); int countByCustomerId(@Param("customerId") String customerId);
void insertBatch(@Param("list") List<ScreenProjectProcessDTO> list); void insertBatch(@Param("list") List<ScreenProjectProcessDTO> list);
int deleteByProcessIds(@Param("customerId") String customerId, @Param("list") List<String> list);
} }

71
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectProcessServiceImpl.java

@ -21,30 +21,33 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.constant.DataSourceConstant; import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.evaluationindex.screen.ScreenProjectProcessAttachmentDao; import com.epmet.dao.evaluationindex.screen.ScreenProjectProcessAttachmentDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectProcessDao; import com.epmet.dao.evaluationindex.screen.ScreenProjectProcessDao;
import com.epmet.dto.screen.ScreenProjectProcessAttachmentDTO;
import com.epmet.dto.screen.ScreenProjectProcessDTO; import com.epmet.dto.screen.ScreenProjectProcessDTO;
import com.epmet.dto.screen.form.ScreenProjectProcessFormDTO; import com.epmet.dto.screen.form.ScreenProjectProcessFormDTO;
import com.epmet.dto.screencoll.ScreenCollFormDTO; import com.epmet.dto.screencoll.ScreenCollFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectProcessAttachmentEntity; import com.epmet.entity.evaluationindex.screen.ScreenProjectProcessAttachmentEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectProcessEntity; import com.epmet.entity.evaluationindex.screen.ScreenProjectProcessEntity;
import com.epmet.service.evaluationindex.screen.ScreenProjectProcessAttachmentService;
import com.epmet.service.evaluationindex.screen.ScreenProjectProcessService; import com.epmet.service.evaluationindex.screen.ScreenProjectProcessService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/** /**
* 中央区-项目数据项目处理进展表 * 中央区-项目数据项目处理进展表
@ -58,6 +61,8 @@ public class ScreenProjectProcessServiceImpl extends BaseServiceImpl<ScreenProje
@Resource @Resource
private ScreenProjectProcessAttachmentDao screenProjectProcessAttachmentDao; private ScreenProjectProcessAttachmentDao screenProjectProcessAttachmentDao;
@Resource
private ScreenProjectProcessAttachmentService screenProjectProcessAttachmentService;
@Override @Override
public PageData<ScreenProjectProcessDTO> page(Map<String, Object> params) { public PageData<ScreenProjectProcessDTO> page(Map<String, Object> params) {
IPage<ScreenProjectProcessEntity> page = baseDao.selectPage( IPage<ScreenProjectProcessEntity> page = baseDao.selectPage(
@ -114,45 +119,47 @@ public class ScreenProjectProcessServiceImpl extends BaseServiceImpl<ScreenProje
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true) @DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
public void collect(ScreenCollFormDTO<ScreenProjectProcessFormDTO> param) { public void collect(ScreenCollFormDTO<ScreenProjectProcessFormDTO> param) {
if (CollectionUtils.isEmpty(param.getDataList())){
return;
}
if (param.getIsFirst()) { if (param.getIsFirst()) {
int affectedRows = baseDao.deleteByDateIdAndCustomerId(param.getCustomerId(), param.getDateId()); int affectedRows = baseDao.deleteByDateIdAndCustomerId(param.getCustomerId(), param.getDateId());
while (affectedRows > 0) { while (affectedRows > 0) {
affectedRows = baseDao.deleteByDateIdAndCustomerId(param.getCustomerId(), param.getDateId()); affectedRows = baseDao.deleteByDateIdAndCustomerId(param.getCustomerId(), param.getDateId());
} }
} }
param.getDataList().forEach(item -> { List<String> processIdList =
//先删除旧数据 param.getDataList().stream().map(ScreenProjectProcessFormDTO :: getProcessId).collect(Collectors.toList()).stream().distinct()
QueryWrapper<ScreenProjectProcessEntity> screenProjectProcessEntityQueryWrapper = new QueryWrapper<>(); .collect(Collectors.toList());
screenProjectProcessEntityQueryWrapper.eq(StringUtils.isNotBlank(item.getProjectId()), "project_id", item.getProjectId()) if (CollectionUtils.isEmpty(processIdList)){
.eq(StringUtils.isNotBlank(param.getCustomerId()), "customer_id", param.getCustomerId()) return;
.eq(StringUtils.isNotBlank(item.getProcessId()), "process_id", item.getProcessId()); }
baseDao.delete(screenProjectProcessEntityQueryWrapper); //删除旧数据
baseDao.deleteByProcessIds(param.getCustomerId(), processIdList);
QueryWrapper<ScreenProjectProcessAttachmentEntity> screenProjectProcessAttachmentEntityQueryWrapper = new QueryWrapper<>(); screenProjectProcessAttachmentDao.deleteByProcessIds(param.getCustomerId(), processIdList);
screenProjectProcessAttachmentEntityQueryWrapper.eq(StringUtils.isNotBlank(item.getProjectId()), "project_id", item.getProjectId())
.eq(StringUtils.isNotBlank(param.getCustomerId()), "customer_id", param.getCustomerId()) List<ScreenProjectProcessAttachmentEntity> attachmentList = new ArrayList<>();
.eq(StringUtils.isNotBlank(item.getProcessId()), "process_id", item.getProcessId());
screenProjectProcessAttachmentDao.delete(screenProjectProcessAttachmentEntityQueryWrapper); List<ScreenProjectProcessEntity> processList = param.getDataList().stream().map(item -> {
//插入 ScreenProjectProcessEntity entity = ConvertUtils.sourceToTarget(item, ScreenProjectProcessEntity.class);
ScreenProjectProcessEntity screenProjectProcessEntity = ConvertUtils.sourceToTarget(item, ScreenProjectProcessEntity.class); entity.setCustomerId(param.getCustomerId());
screenProjectProcessEntity.setCustomerId(param.getCustomerId()); entity.setDataEndTime(param.getDateId());
screenProjectProcessEntity.setDataEndTime(param.getDateId()); AtomicInteger i = new AtomicInteger(0);
baseDao.insert(screenProjectProcessEntity); List<ScreenProjectProcessAttachmentEntity> attachments = item.getAttachments().stream().map(attachment -> {
ScreenProjectProcessAttachmentEntity attachmentEntity = ConvertUtils.sourceToTarget(attachment, ScreenProjectProcessAttachmentEntity.class);
List<ScreenProjectProcessAttachmentDTO> attachments = item.getAttachments();
if (!CollectionUtils.isEmpty(attachments)){
for (int i = 0; i < attachments.size(); i++) {
ScreenProjectProcessAttachmentEntity attachmentEntity = ConvertUtils.sourceToTarget(attachments.get(i), ScreenProjectProcessAttachmentEntity.class);
attachmentEntity.setCustomerId(param.getCustomerId()); attachmentEntity.setCustomerId(param.getCustomerId());
attachmentEntity.setProcessId(item.getProcessId()); attachmentEntity.setProcessId(item.getProcessId());
attachmentEntity.setProjectId(item.getProjectId()); attachmentEntity.setProjectId(item.getProjectId());
if (attachmentEntity.getSort() == null) { if (attachmentEntity.getSort() == null) {
attachmentEntity.setSort(i); attachmentEntity.setSort(i.getAndIncrement());
} }
screenProjectProcessAttachmentDao.insert(attachmentEntity); return attachmentEntity;
} }).collect(Collectors.toList());
} attachmentList.addAll(attachments);
}); return entity;
}).collect(Collectors.toList());
this.insertBatch(processList);
screenProjectProcessAttachmentService.insertBatch(attachmentList);
} }

11
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectProcessAttachmentDao.xml

@ -85,4 +85,15 @@
) )
</foreach> </foreach>
</insert> </insert>
<delete id="deleteByProcessIds">
delete from screen_project_process_attachment
where customer_id = #{customerId}
<if test="list != null and list.size() > 0">
AND
<foreach collection="list" item="processId" separator="or" open="(" close=")">
PROCESS_ID = #{processId}
</foreach>
</if>
</delete>
</mapper> </mapper>

11
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectProcessDao.xml

@ -22,6 +22,17 @@
where del_flag = '0' and customer_id = #{customerId} where del_flag = '0' and customer_id = #{customerId}
</select> </select>
<delete id="deleteByProcessIds">
delete from screen_project_process
where customer_id = #{customerId}
<if test="list != null and list.size() > 0">
AND
<foreach collection="list" item="processId" separator="or" open="(" close=")">
PROCESS_ID = #{processId}
</foreach>
</if>
</delete>
<insert id="insertBatch" parameterType="java.util.List"> <insert id="insertBatch" parameterType="java.util.List">
INSERT INTO screen_project_process INSERT INTO screen_project_process
( (

Loading…
Cancel
Save