|
@@ -0,0 +1,130 @@
|
|
|
+package com.rongwei.bscommon.system.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.rongwei.bscommon.system.dao.QhseEmergencyDrilPlanDao;
|
|
|
+import com.rongwei.bscommon.system.dao.QhsePointsUnitRecordDao;
|
|
|
+import com.rongwei.bscommon.system.service.QhseEmergencyDrilPlanService;
|
|
|
+import com.rongwei.bscommon.system.utils.QHSEUtils;
|
|
|
+import com.rongwei.bsentity.domain.QhseEmergencyDrilPlanDo;
|
|
|
+import com.rongwei.bsentity.domain.QhsePointsUnitRecordDo;
|
|
|
+import com.rongwei.bsentity.dto.UnitPointsImportValidationResult;
|
|
|
+import com.rongwei.rwadmincommon.system.dao.SysDictDao;
|
|
|
+import com.rongwei.rwadmincommon.system.dao.SysOrganizationDao;
|
|
|
+import com.rongwei.rwadmincommon.system.domain.SysDictDo;
|
|
|
+import com.rongwei.rwadmincommon.system.domain.SysOrganizationDo;
|
|
|
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
+import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+* @author shangmi
|
|
|
+* @description 针对表【qhse_emergency_dril_plan(应急管理-演练计划)】的数据库操作Service实现
|
|
|
+* @createDate 2025-09-17 15:55:58
|
|
|
+*/
|
|
|
+@Service
|
|
|
+public class QhseEmergencyDrilPlanServiceImpl extends ServiceImpl<QhseEmergencyDrilPlanDao, QhseEmergencyDrilPlanDo>
|
|
|
+ implements QhseEmergencyDrilPlanService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QhseEmergencyDrilPlanDao qhseEmergencyDrilPlanDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysDictDao sysDictDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysOrganizationDao sysOrganizationDao;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 季度
|
|
|
+ * 应急-预案类型
|
|
|
+ * 应急-演练形式
|
|
|
+ */
|
|
|
+ private static final List<String> DICT_TYPES =
|
|
|
+ Arrays.asList(
|
|
|
+ "quarterly",
|
|
|
+ "yj-yalx",
|
|
|
+ "yj-ylxs"
|
|
|
+ );
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public R ProcessImportedData(List<QhseEmergencyDrilPlanDo> parsedData) {
|
|
|
+ if (parsedData.isEmpty()) {
|
|
|
+ return R.error("无有效数据需要处理");
|
|
|
+ }
|
|
|
+
|
|
|
+ SysUserVo currentUser = QHSEUtils.getCurrentUser();
|
|
|
+
|
|
|
+ //校验数据
|
|
|
+ validateImportedData(parsedData, currentUser);
|
|
|
+
|
|
|
+
|
|
|
+ //更新子表
|
|
|
+ this.getBaseMapper().insertBatchSomeColumn(parsedData);
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验数据
|
|
|
+ * @param parsedData
|
|
|
+ * @param currentUser
|
|
|
+ */
|
|
|
+ private void validateImportedData(List<QhseEmergencyDrilPlanDo> parsedData, SysUserVo currentUser) {
|
|
|
+ //1.匹配数据字典
|
|
|
+ Map<String, Map<String, String>> dictCollect = sysDictDao.selectList(new LambdaQueryWrapper<SysDictDo>().
|
|
|
+ eq(SysDictDo::getDeleted, "0").in(SysDictDo::getDicttype, DICT_TYPES))
|
|
|
+ .stream().collect(Collectors.groupingBy(SysDictDo::getDicttype,
|
|
|
+ Collectors.toMap(SysDictDo::getName, SysDictDo::getValue)));
|
|
|
+
|
|
|
+ //查询一级部门
|
|
|
+ Map<String, String> orgCollect = sysOrganizationDao.selectList(new LambdaQueryWrapper<SysOrganizationDo>().eq(SysOrganizationDo::getDeleted, "0")
|
|
|
+ .eq(SysOrganizationDo::getOrgtype, "1")).stream().collect(Collectors.toMap(SysOrganizationDo::getFullname, SysOrganizationDo::getId));
|
|
|
+
|
|
|
+ QhseEmergencyDrilPlanDo qhseEmergencyDrilPlanDo =null;
|
|
|
+
|
|
|
+ // 查询一级部门
|
|
|
+ for (int i = 0; i < parsedData.size(); i++) {
|
|
|
+ qhseEmergencyDrilPlanDo = parsedData.get(i);
|
|
|
+ if (dictCollect.get(DICT_TYPES.get(0)).get(qhseEmergencyDrilPlanDo.getQuarter()) == null) {
|
|
|
+ throw new RuntimeException("第:"+ (i+2 )+"行季度不匹配,请重新检查");
|
|
|
+ }else {
|
|
|
+ qhseEmergencyDrilPlanDo.setQuarter(dictCollect.get(DICT_TYPES.get(0)).get(qhseEmergencyDrilPlanDo.getQuarter()));
|
|
|
+ }
|
|
|
+ if (dictCollect.get(DICT_TYPES.get(1)).get(qhseEmergencyDrilPlanDo.getDrilltype()) == null) {
|
|
|
+ throw new RuntimeException("第:"+ (i+2 )+"行演练类型不匹配,请重新检查");
|
|
|
+ }else {
|
|
|
+ qhseEmergencyDrilPlanDo.setDrilltype(dictCollect.get(DICT_TYPES.get(1)).get(qhseEmergencyDrilPlanDo.getDrilltype()));
|
|
|
+ }
|
|
|
+ if (dictCollect.get(DICT_TYPES.get(2)).get(qhseEmergencyDrilPlanDo.getDrillform()) == null) {
|
|
|
+ throw new RuntimeException("第:"+(i+2 ) +"行演练形式不匹配,请重新检查");
|
|
|
+ }else {
|
|
|
+ qhseEmergencyDrilPlanDo.setDrillform(dictCollect.get(DICT_TYPES.get(2)).get(qhseEmergencyDrilPlanDo.getDrillform()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (orgCollect.get(qhseEmergencyDrilPlanDo.getHostdepartment()) == null) {
|
|
|
+ throw new RuntimeException("第:"+ i+2 +"主办部门不匹配,请重新检查");
|
|
|
+ }else {
|
|
|
+ qhseEmergencyDrilPlanDo.setHostdepartmentid(orgCollect.get(qhseEmergencyDrilPlanDo.getHostdepartment()));
|
|
|
+ }
|
|
|
+
|
|
|
+ QHSEUtils.initModelGeneralParameters(qhseEmergencyDrilPlanDo, currentUser);
|
|
|
+ qhseEmergencyDrilPlanDo.setId(SecurityUtil.getUUID());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|