|
@@ -5,41 +5,52 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.rongwe.scentity.domian.AspEvaluationRecordDo;
|
|
|
+import com.rongwe.scentity.domian.AspEvaluationRecordHistoryDo;
|
|
|
import com.rongwe.scentity.domian.AspRiskSourceDo;
|
|
|
+import com.rongwe.scentity.domian.AspRiskSourceHistoryDo;
|
|
|
import com.rongwei.rwadmincommon.system.domain.SysOrganizationDo;
|
|
|
import com.rongwei.rwadmincommon.system.domain.SysUserDo;
|
|
|
import com.rongwei.rwadmincommon.system.service.SysOrganizationService;
|
|
|
import com.rongwei.rwadmincommon.system.service.SysUserService;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.sfcommon.sys.dao.AspRiskSourceDao;
|
|
|
+import com.rongwei.sfcommon.sys.service.AspEvaluationRecordService;
|
|
|
import com.rongwei.sfcommon.sys.service.AspRiskSourceService;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class AspRiskSourceServiceImpl extends ServiceImpl<AspRiskSourceDao, AspRiskSourceDo> implements AspRiskSourceService {
|
|
|
-
|
|
|
+ private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
|
|
|
@Autowired
|
|
|
private SysUserService sysUserService;
|
|
|
@Autowired
|
|
|
private SysOrganizationService sysOrganizationService;
|
|
|
+ @Autowired
|
|
|
+ private AspEvaluationRecordService aspEvaluationRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AspRiskSourceHistoryServiceImpl aspRiskSourceHistoryService;
|
|
|
+ @Autowired
|
|
|
+ private AspEvaluationRecordHistoryServiceImpl aspEvaluationRecordHistoryService;
|
|
|
@Override
|
|
|
public void test(Boolean haveJob,String filePath,String category) {
|
|
|
// //获取文件目录
|
|
@@ -180,21 +191,78 @@ public class AspRiskSourceServiceImpl extends ServiceImpl<AspRiskSourceDao, AspR
|
|
|
this.saveBatch(resList);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 将以评估的非历史记录 变为历史记录并生成新的数据
|
|
|
+ */
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public void resetInfo() {
|
|
|
- List<AspRiskSourceDo> list = this.list(new LambdaQueryWrapper<AspRiskSourceDo>().eq(BaseDo::getDeleted, "0"));
|
|
|
+ // 获取所有以评估的数据
|
|
|
+ List<AspRiskSourceDo> list = this.list(new LambdaQueryWrapper<AspRiskSourceDo>()
|
|
|
+ .eq(BaseDo::getDeleted, "0")
|
|
|
+ .eq(AspRiskSourceDo::getAssessstatus,"ypg"));
|
|
|
if(list.isEmpty()){
|
|
|
log.debug("暂无需要重置信息的风险源信息");
|
|
|
return;
|
|
|
}
|
|
|
- List<String> ids = list.stream().map(AspRiskSourceDo::getId).collect(Collectors.toList());
|
|
|
- this.update(new LambdaUpdateWrapper<AspRiskSourceDo>()
|
|
|
- .in(AspRiskSourceDo::getId,ids)
|
|
|
- .set(AspRiskSourceDo::getAssessstatus,"dpg")
|
|
|
- .set(AspRiskSourceDo::getAvgsalary,null)
|
|
|
- .set(AspRiskSourceDo::getRating,null)
|
|
|
- .set(AspRiskSourceDo::getRiskranking,null)
|
|
|
- );
|
|
|
+ // 将原来的数据变为 历史记录
|
|
|
+ List<String> oldIds = list.stream().map(AspRiskSourceDo::getId).collect(Collectors.toList());
|
|
|
+ // 更新历史记录信息
|
|
|
+ oldIds.forEach(id->{
|
|
|
+ updateHistory(id);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 删除子表数据
|
|
|
+ aspEvaluationRecordService.remove(new LambdaQueryWrapper<AspEvaluationRecordDo>().in(AspEvaluationRecordDo::getMasterid,oldIds));
|
|
|
+ // 删除主表信息
|
|
|
+ this.removeByIds(oldIds);
|
|
|
|
|
|
+ // 重新生成新的数据
|
|
|
+ list.forEach(info->{
|
|
|
+ info.setAssessstatus("dpg");
|
|
|
+ info.setAvgsalary(null);
|
|
|
+ info.setRating(null);
|
|
|
+ info.setRiskranking(null);
|
|
|
+ info.setSerialnumber(null);
|
|
|
+ info.setId(SecurityUtil.getUUID());
|
|
|
+ });
|
|
|
+ this.saveBatch(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新风险源的历史评估记录
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R updateHistory(String id) {
|
|
|
+ log.info("开始更新风险源的历史评估记录");
|
|
|
+ AspRiskSourceDo aspRiskSourceDo = this.getById(id);
|
|
|
+ if(aspRiskSourceDo==null){
|
|
|
+ log.error("无法通过ID:{}获取到风险源评估信息",id);
|
|
|
+ return R.error("无法获取到风险评估信息");
|
|
|
+ }
|
|
|
+ // 主表
|
|
|
+ AspRiskSourceHistoryDo saveData = new AspRiskSourceHistoryDo();
|
|
|
+ BeanUtils.copyProperties(aspRiskSourceDo,saveData);
|
|
|
+
|
|
|
+ // 子表
|
|
|
+ List<AspEvaluationRecordDo> recordHistoryDos = aspEvaluationRecordService.list(new LambdaQueryWrapper<AspEvaluationRecordDo>()
|
|
|
+ .eq(AspEvaluationRecordDo::getMasterid, id)
|
|
|
+ .eq(BaseDo::getDeleted, "0"));
|
|
|
+ List<AspEvaluationRecordHistoryDo> historySaveList = new ArrayList<>();
|
|
|
+ recordHistoryDos.forEach(data->{
|
|
|
+ AspEvaluationRecordHistoryDo aspEvaluationRecordHistoryDo = new AspEvaluationRecordHistoryDo();
|
|
|
+ BeanUtils.copyProperties(data,aspEvaluationRecordHistoryDo);
|
|
|
+ historySaveList.add(aspEvaluationRecordHistoryDo);
|
|
|
+ });
|
|
|
+ // 删除历史表的记录
|
|
|
+ aspRiskSourceHistoryService.getBaseMapper().removeById(id);
|
|
|
+ aspEvaluationRecordHistoryService.getBaseMapper().removeByMasterId(id);
|
|
|
+ // 保存;
|
|
|
+ aspRiskSourceHistoryService.save(saveData);
|
|
|
+ if(!historySaveList.isEmpty()){
|
|
|
+ aspEvaluationRecordHistoryService.saveBatch(historySaveList);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
}
|