فهرست منبع

单位积分导入功能开发

huangpeng 6 روز پیش
والد
کامیت
7c282cb0cb
15فایلهای تغییر یافته به همراه524 افزوده شده و 13 حذف شده
  1. 7 0
      qhse-common/src/main/java/com/rongwei/bscommon/system/dao/QhsePointsUnitRecordDao.java
  2. 101 0
      qhse-common/src/main/java/com/rongwei/bscommon/system/excelImportListener/UnitPointsRegistrationListener.java
  3. 2 1
      qhse-common/src/main/java/com/rongwei/bscommon/system/service/QhsePointsUnitDetailsService.java
  4. 4 0
      qhse-common/src/main/java/com/rongwei/bscommon/system/service/QhsePointsUnitRecordService.java
  5. 23 0
      qhse-common/src/main/java/com/rongwei/bscommon/system/service/impl/ExcelImportServiceImpl.java
  6. 185 1
      qhse-common/src/main/java/com/rongwei/bscommon/system/service/impl/QhsePointsUnitDetailsServiceImpl.java
  7. 11 8
      qhse-common/src/main/java/com/rongwei/bscommon/system/service/impl/QhsePointsUnitRecordServiceImpl.java
  8. 41 0
      qhse-common/src/main/resources/mybatis/system/QhsePointsUnitRecordDao.xml
  9. 20 0
      qhse-entity/src/main/java/com/rongwei/bsentity/Dto/UnitPointsImportValidationResult.java
  10. 45 0
      qhse-entity/src/main/java/com/rongwei/bsentity/Dto/UnitPointsRegistrationImportDto.java
  11. 2 0
      qhse-entity/src/main/java/com/rongwei/bsentity/domain/QhsePointsUnitDetailsDo.java
  12. 2 3
      qhse-entity/src/main/java/com/rongwei/bsentity/domain/QhsePointsUnitRecordDo.java
  13. 36 0
      qhse-entity/src/main/java/com/rongwei/bsentity/vo/QhsePointsUnitDetailsVo.java
  14. 30 0
      qhse-entity/src/main/java/com/rongwei/bsentity/vo/QhsePointsUnitRecordVo.java
  15. 15 0
      qhse-server/src/main/java/com/rongwei/controller/ExcelImportController.java

+ 7 - 0
qhse-common/src/main/java/com/rongwei/bscommon/system/dao/QhsePointsUnitRecordDao.java

@@ -1,10 +1,13 @@
 package com.rongwei.bscommon.system.dao;
 
 import com.rongwei.bsentity.domain.QhsePointsUnitRecordDo;
+import com.rongwei.bsentity.vo.QhsePointsUnitDetailsVo;
+import com.rongwei.bsentity.vo.QhsePointsUnitRecordVo;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Set;
 
 
 public interface QhsePointsUnitRecordDao extends QHSEMapper<QhsePointsUnitRecordDo> {
@@ -15,4 +18,8 @@ public interface QhsePointsUnitRecordDao extends QHSEMapper<QhsePointsUnitRecord
     int updateScoreInfo(@Param("list") List<QhsePointsUnitRecordDo> list, @Param("currentUser")  SysUserVo currentUser);
 
     int addUnitFiles(@Param("list") List<String> ids,@Param("attachment") String attachment);
+
+    List<QhsePointsUnitRecordVo> getRecordByYear(@Param("years") List<String> years);
+
+  List<QhsePointsUnitDetailsVo> getDetailsByYear(@Param("years")  List<String> years);
 }

+ 101 - 0
qhse-common/src/main/java/com/rongwei/bscommon/system/excelImportListener/UnitPointsRegistrationListener.java

@@ -0,0 +1,101 @@
+package com.rongwei.bscommon.system.excelImportListener;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.rongwei.bsentity.domain.QhsePointsUnitDetailsDo;
+import com.rongwei.bsentity.dto.UnitPointsRegistrationImportDto;
+import com.rongwei.bsentity.vo.QhsePointsUnitDetailsVo;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import static com.rongwei.bscommon.system.utils.QHSEConstant.DatePattern.DATE_PATTERN_YMD;
+
+/**
+ * UserPointsEegistrationListener class
+ *
+ * @author XH
+ * @date 2025/09/10
+ */
+public class UnitPointsRegistrationListener extends AnalysisEventListener<UnitPointsRegistrationImportDto> {
+    private static final Logger log = LoggerFactory.getLogger(UnitPointsRegistrationListener.class);
+    private final List<QhsePointsUnitDetailsVo> saveList = new ArrayList<>();
+    public static LocalDate now = LocalDate.now();
+    private static final SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN_YMD);
+
+
+
+    @Override
+    public void invoke(UnitPointsRegistrationImportDto currentRowDto, AnalysisContext analysisContext) {
+
+        // 必填项校验
+        if (StringUtils.isBlank(currentRowDto.getUnitname()) ||
+                StringUtils.isBlank(currentRowDto.getDepartmentname()) ||
+                StringUtils.isBlank(currentRowDto.getDescription()) ||
+                currentRowDto.getPoints() == null ||
+                currentRowDto.getHappentime() == null
+        ) {
+            log.error("第{}行的数据,存在必填项未填的数据", analysisContext.readRowHolder().getRowIndex());
+            throw new RuntimeException("存在必填字段为空的数据");
+        }
+        // 发送时间比当前时间晚 抛出异常
+        if (currentRowDto.getHappentime().isAfter(now)) {
+            throw new RuntimeException("存在发生日期大于当前日期的数据");
+        }
+
+        /**
+         * 发生时间校验
+         *  当前时间为1月份 可以导入 前一年的数据
+         *  为其他月份只可以导入当前年份的数据
+         */
+        if (now.getMonth().getValue() == 1) {
+            if (!(currentRowDto.getHappentime().getYear() + 1 == now.getYear() || currentRowDto.getHappentime().getYear() == now.getYear())) {
+                throw new RuntimeException("发生日期不能早于" + (now.getYear() - 1));
+            }
+        } else {
+            if (currentRowDto.getHappentime().getYear() != now.getYear()) {
+                throw new RuntimeException("存在发生日期所在的年份和当前年份不一致的数据");
+            }
+        }
+
+
+        Instant instant = currentRowDto.getHappentime().atTime(LocalTime.MIDNIGHT).atZone(ZoneId.systemDefault()).toInstant();
+        QhsePointsUnitDetailsVo qhsePointsUnitDetailsVo = new QhsePointsUnitDetailsVo();
+
+        qhsePointsUnitDetailsVo.setPoints(currentRowDto.getPoints())
+                .setDescription(currentRowDto.getDescription())
+                .setHappentime(Date.from(instant));
+        qhsePointsUnitDetailsVo.setUnitname(currentRowDto.getUnitname());
+        qhsePointsUnitDetailsVo.setDepartmentname(currentRowDto.getDepartmentname());
+
+        //年份
+        String format1 = format.format(qhsePointsUnitDetailsVo.getHappentime());
+        qhsePointsUnitDetailsVo.setHappentimestr(format1);
+        qhsePointsUnitDetailsVo.setPointsyear(format1.split("-")[0]);
+        saveList.add(qhsePointsUnitDetailsVo);
+
+
+              ;
+
+    }
+
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+    }
+
+    // 获取Excel 中的数据
+    public List<QhsePointsUnitDetailsVo> getData() {
+        return saveList;
+    }
+
+}

+ 2 - 1
qhse-common/src/main/java/com/rongwei/bscommon/system/service/QhsePointsUnitDetailsService.java

@@ -2,7 +2,7 @@ package com.rongwei.bscommon.system.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.domain.QhsePointsUnitDetailsDo;
-import com.rongwei.bsentity.domain.QhsePointsUnitRecordDo;
+import com.rongwei.bsentity.vo.QhsePointsUnitDetailsVo;
 import com.rongwei.rwcommon.base.R;
 
 import java.util.List;
@@ -17,5 +17,6 @@ import java.util.List;
 public interface QhsePointsUnitDetailsService extends IService<QhsePointsUnitDetailsDo> {
 
 
+    R ProcessImportedData(List<QhsePointsUnitDetailsVo> parsedData);
 }
 

+ 4 - 0
qhse-common/src/main/java/com/rongwei/bscommon/system/service/QhsePointsUnitRecordService.java

@@ -3,6 +3,7 @@ package com.rongwei.bscommon.system.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.domain.QhsePointsUnitRecordDo;
 import com.rongwei.bsentity.dto.QhsePointsUnitFileDto;
+import com.rongwei.bsentity.vo.QhsePointsUnitDetailsVo;
 import com.rongwei.rwcommon.base.R;
 
 import java.util.List;
@@ -24,5 +25,8 @@ public interface QhsePointsUnitRecordService extends IService<QhsePointsUnitReco
     R addUnitFiles(QhsePointsUnitFileDto qhsePointsUnitFileDto);
 
     R delUnitScore(List<String> ids);
+
+
+
 }
 

+ 23 - 0
qhse-common/src/main/java/com/rongwei/bscommon/system/service/impl/ExcelImportServiceImpl.java

@@ -3,13 +3,17 @@ package com.rongwei.bscommon.system.service.impl;
 import com.alibaba.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.common.collect.Lists;
+import com.rongwei.bscommon.system.excelImportListener.UnitPointsRegistrationListener;
 import com.rongwei.bscommon.system.excelImportListener.UserPointsRegistrationListener;
 import com.rongwei.bscommon.system.service.ExcelImportService;
+import com.rongwei.bscommon.system.service.QhsePointsUnitDetailsService;
 import com.rongwei.bscommon.system.utils.QHSEUtils;
 import com.rongwei.bsentity.domain.QhseContractWorkersDo;
 import com.rongwei.bsentity.domain.QhsePointsDetailsUserDo;
 import com.rongwei.bsentity.domain.QhsePointsRecordUserDo;
+import com.rongwei.bsentity.dto.UnitPointsRegistrationImportDto;
 import com.rongwei.bsentity.dto.UserPointsRegistrationImportDto;
+import com.rongwei.bsentity.vo.QhsePointsUnitDetailsVo;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.BaseDo;
 import com.rongwei.rwcommon.base.R;
@@ -53,6 +57,8 @@ public class ExcelImportServiceImpl implements ExcelImportService {
     private QhsePointsRecordUserServiceImpl qhsePointsRecordUserService;
     @Autowired
     private PointServiceImpl pointServiceImpl;
+    @Autowired
+    private QhsePointsUnitDetailsService qhsePointsUnitDetailsService;
 
     @Override
     public R userPointsRegistration(MultipartFile file) {
@@ -170,4 +176,21 @@ public class ExcelImportServiceImpl implements ExcelImportService {
     }
 
 
+    public R unitPointsRegistration(MultipartFile file) {
+        UnitPointsRegistrationListener listener = new UnitPointsRegistrationListener();
+
+        try {
+            EasyExcel.read(file.getInputStream())
+                    .head(UnitPointsRegistrationImportDto.class)
+                    .registerReadListener(listener)
+                    .sheet()
+                    .doRead();
+        }catch (Exception e){
+            throw new RuntimeException("读取单位积分文件失败");
+        }
+
+        // 3. 读取完成后获取数据(此时数据已完整)
+        List<QhsePointsUnitDetailsVo> parsedData = listener.getData();
+        return qhsePointsUnitDetailsService.ProcessImportedData(parsedData);
+    }
 }

+ 185 - 1
qhse-common/src/main/java/com/rongwei/bscommon/system/service/impl/QhsePointsUnitDetailsServiceImpl.java

@@ -2,16 +2,200 @@ package com.rongwei.bscommon.system.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bscommon.system.dao.QhsePointsUnitDetailsDao;
+import com.rongwei.bscommon.system.dao.QhsePointsUnitRecordDao;
 import com.rongwei.bscommon.system.service.QhsePointsUnitDetailsService;
+import com.rongwei.bscommon.system.utils.QHSEUtils;
 import com.rongwei.bsentity.domain.QhsePointsUnitDetailsDo;
+import com.rongwei.bsentity.domain.QhsePointsUnitRecordDo;
+import com.rongwei.bsentity.dto.UnitPointsImportValidationResult;
+import com.rongwei.bsentity.vo.QhsePointsUnitDetailsVo;
+import com.rongwei.bsentity.vo.QhsePointsUnitRecordVo;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.utils.SecurityUtil;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
-import java.util.List;
+import java.time.LocalDate;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class QhsePointsUnitDetailsServiceImpl extends
         ServiceImpl<QhsePointsUnitDetailsDao, QhsePointsUnitDetailsDo> implements QhsePointsUnitDetailsService {
 
+    @Autowired
+    private QhsePointsUnitRecordDao qhsePointsUnitRecordDao;
+
+
+
+
+    @Override
+    @Transactional
+    public R ProcessImportedData(List<QhsePointsUnitDetailsVo> parsedData) {
+
+        if (parsedData.isEmpty()) {
+            return R.error("无有效数据需要处理");
+        }
+
+        SysUserVo currentUser = QHSEUtils.getCurrentUser();
+
+        //校验数据
+        UnitPointsImportValidationResult unitPointsImportValidationResult=  validateImportedData(parsedData,currentUser);
+        if (unitPointsImportValidationResult.isValid()){
+            return R.error(unitPointsImportValidationResult.getErrorMsg());
+        }
+
+        //根据加入的子表记录计算应该修改的加扣分信息
+        List<QhsePointsUnitRecordDo> qhsePointsUnitRecordDos = calMainTablePoint(unitPointsImportValidationResult.getValidData());
+
+        //更新子表
+        this.getBaseMapper().insertBatchSomeColumn( unitPointsImportValidationResult.getValidData());
+
+        //更新主表.
+        qhsePointsUnitRecordDao.updateScoreInfo(qhsePointsUnitRecordDos,currentUser);
+        return R.ok();
+
+    }
+
+    private List<QhsePointsUnitRecordDo> calMainTablePoint(List<QhsePointsUnitDetailsDo> validData) {
+
+        //获取对应的加分记录数据
+        Map<String, List<QhsePointsUnitDetailsDo>> details =validData.stream().collect(Collectors.groupingBy(
+                QhsePointsUnitDetailsDo::getPointsunitid
+        ));
+
+        QhsePointsUnitRecordDo qhsePointsUnitRecordDo =null;
+        List<QhsePointsUnitRecordDo> mainUpdates =new ArrayList<>();
+
+        for (String key: details.keySet()){
+            qhsePointsUnitRecordDo = new QhsePointsUnitRecordDo();
+            qhsePointsUnitRecordDo.setId(key);
+            qhsePointsUnitRecordDo.setBonuspoints(0);
+            qhsePointsUnitRecordDo.setBonusdescription("");
+            qhsePointsUnitRecordDo.setDeductionpoints(0);
+            qhsePointsUnitRecordDo.setDeductiondescription("");
+            qhsePointsUnitRecordDo.setCumulativescore(0);
+            //分值大于0 累加到 加分分值,加分描述追加 ,反之 累加 扣分分值,扣分描述
+            for (QhsePointsUnitDetailsDo qhsePointsUnitDetailsDo : details.get(key)) {
+                if (qhsePointsUnitDetailsDo.getPoints()>0){
+                    qhsePointsUnitRecordDo.setBonuspoints(qhsePointsUnitDetailsDo.getPoints()+qhsePointsUnitRecordDo.getBonuspoints());
+                }else{
+                    qhsePointsUnitRecordDo.setDeductionpoints(qhsePointsUnitDetailsDo.getPoints()+qhsePointsUnitRecordDo.getDeductionpoints());
+                }
+                qhsePointsUnitRecordDo.setCumulativescore(qhsePointsUnitRecordDo.getCumulativescore() + qhsePointsUnitDetailsDo.getPoints());
+            }
+
+            mainUpdates.add(qhsePointsUnitRecordDo);
+        }
+        return mainUpdates;
+    }
+
+    /**
+     * 校验数据
+     *
+     * @param parsedData
+     * @param currentUser
+     * @return
+     */
+    private UnitPointsImportValidationResult validateImportedData(List<QhsePointsUnitDetailsVo> parsedData, SysUserVo currentUser) {
+
+        UnitPointsImportValidationResult unitPointsImportValidationResult = new UnitPointsImportValidationResult();
+        List<QhsePointsUnitDetailsDo> insertList = new ArrayList<>();
+        QhsePointsUnitDetailsDo detailsDo;
+        String recordKey ="",detailKey ="";
+
+        //1.查询 主表 年度+单位名称记录 分组
+        Map<String, List<QhsePointsUnitRecordVo>> recordMap = loadAnnualUnits();
+        //2.查询子表已存在的记录  单位名称+ 描述 + 发生时间 分组
+        Map<String, List<QhsePointsUnitDetailsVo>> detailMap = loadAnnualDetails();
+
+        //是否有相同的单位名称,子表是否有相同的记录
+        boolean notSameUnitName =false,sameDetail =false;
+        StringBuilder errors = new StringBuilder();
+        //循环校验
+        for (QhsePointsUnitDetailsVo vo:parsedData){
+            //校验单位名称 年度 + 单位名称
+            recordKey = vo.getPointsyear()+"-"+vo.getUnitname();
+            if (recordMap.get(recordKey)==null && !sameDetail){
+                errors.append("【").append(vo.getUnitname()).append("】");
+                notSameUnitName=true;
+                continue;
+            }
+
+            //校验子表唯一值  单位+描述 +时间
+            detailKey = vo.getUnitname()+"-"+vo.getDescription()+"-"+vo.getHappentimestr();
+            if (detailMap.get(detailKey)!=null && !notSameUnitName){
+                errors.append("【").append(vo.getUnitname()).append(vo.getDescription()).append(vo.getHappentimestr()).append("】");
+                sameDetail =true;
+                continue;
+            }
+
+            //生成新的实体DO
+            detailsDo =new QhsePointsUnitDetailsDo();
+            convertToDo(detailsDo,vo,currentUser,recordMap.get(recordKey).get(0).getId());
+            insertList.add(detailsDo);
+        }
+
+        if(notSameUnitName || sameDetail){
+            unitPointsImportValidationResult.setValid(true);
+        }
+
+        if(notSameUnitName ){
+            errors.append("单位不在对应年度清单中,请检查再导入");
+            unitPointsImportValidationResult.setErrorMsg(errors.toString());
+        }
+
+        if(sameDetail ){
+            errors.append("加扣分说明已存在,请重新维护");
+            unitPointsImportValidationResult.setErrorMsg("该年度"+errors);
+        }
+
+        unitPointsImportValidationResult.setValidData(insertList);
+
+        return unitPointsImportValidationResult;
+    }
+
+    private void convertToDo(QhsePointsUnitDetailsDo detailsDo, QhsePointsUnitDetailsVo vo, SysUserVo currentUser, String pointsunitid) {
+        BeanUtils.copyProperties(vo,detailsDo);
+        detailsDo.setId(SecurityUtil.getUUID());
+        detailsDo.setDeleted("0");
+        detailsDo.setSource("1"); //人工导入
+        detailsDo.setPointsunitid(pointsunitid);
+        detailsDo.setState("1"); //默认生成了 主表信息
+        QHSEUtils.initModelGeneralParameters(detailsDo, currentUser);
+    }
+
+    private List<String> getValidYears() {
+        List<String> years = new ArrayList<>();
+        int currentYear = LocalDate.now().getYear();
+        years.add(String.valueOf(currentYear));
+
+        if (LocalDate.now().getMonthValue() == 1) {
+            years.add(String.valueOf(currentYear - 1));
+        }
+        return years;
+    }
+
+    private Map<String, List<QhsePointsUnitRecordVo>> loadAnnualUnits() {
+        List<String> years = getValidYears();
+        return Optional.ofNullable(qhsePointsUnitRecordDao.getRecordByYear(years))
+                .filter(list -> !list.isEmpty())
+                .map(list -> list.stream()
+                        .collect(Collectors.groupingBy(QhsePointsUnitRecordVo::getUniquevalue)))
+                .orElse(Collections.emptyMap());
+    }
+
+    private Map<String, List<QhsePointsUnitDetailsVo>> loadAnnualDetails() {
+        List<String> years = getValidYears();
+        return Optional.ofNullable(qhsePointsUnitRecordDao.getDetailsByYear(years))
+                .filter(list -> !list.isEmpty())
+                .map(list -> list.stream()
+                        .collect(Collectors.groupingBy(QhsePointsUnitDetailsVo::getUniquevalue)))
+                .orElse(Collections.emptyMap());
+    }
 
 }

+ 11 - 8
qhse-common/src/main/java/com/rongwei/bscommon/system/service/impl/QhsePointsUnitRecordServiceImpl.java

@@ -9,22 +9,20 @@ import com.rongwei.bscommon.system.dao.QhsePointsUnitRecordDao;
 import com.rongwei.bscommon.system.service.QhsePointsUnitDetailsService;
 import com.rongwei.bscommon.system.service.QhsePointsUnitRecordService;
 import com.rongwei.bscommon.system.utils.QHSEUtils;
-import com.rongwei.bsentity.domain.QhsePointsDetailsUserDo;
 import com.rongwei.bsentity.domain.QhsePointsUnitDetailsDo;
 import com.rongwei.bsentity.domain.QhsePointsUnitRecordDo;
 import com.rongwei.bsentity.dto.QhsePointsUnitFileDto;
+import com.rongwei.bsentity.vo.QhsePointsUnitDetailsVo;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.utils.SecurityUtil;
+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.time.LocalDate;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -39,8 +37,8 @@ public class QhsePointsUnitRecordServiceImpl extends ServiceImpl<QhsePointsUnitR
 
     @Autowired
     private QhsePointsUnitRecordDao qhsePointsUnitRecordDao;
-
-
+    @Autowired
+    private QhsePointsUnitDetailsDao qhsePointsUnitDetailsDao;
 
 
     @Autowired
@@ -62,7 +60,7 @@ public class QhsePointsUnitRecordServiceImpl extends ServiceImpl<QhsePointsUnitR
             qhsePointsUnitRecordDo = new QhsePointsUnitRecordDo();
             QHSEUtils.initModelGeneralParameters(qhsePointsUnitRecordDo, currentUser);
             qhsePointsUnitRecordDo.setSubcontractorid(uninitializedDatum.getId());
-            qhsePointsUnitRecordDo.setPointsyear(year);
+            qhsePointsUnitRecordDo.setPointsyear(String.valueOf(year));
             qhsePointsUnitRecordDo.setId(SecurityUtil.getUUID());
             saveList.add(qhsePointsUnitRecordDo);
         }
@@ -176,5 +174,10 @@ public class QhsePointsUnitRecordServiceImpl extends ServiceImpl<QhsePointsUnitR
 
         return R.ok();
     }
+
+
+
+
+
 }
 

+ 41 - 0
qhse-common/src/main/resources/mybatis/system/QhsePointsUnitRecordDao.xml

@@ -94,4 +94,45 @@
 
     </update>
 
+
+    <select id="getRecordByYear" resultType="com.rongwei.bsentity.vo.QhsePointsUnitRecordVo">
+
+            SELECT
+            a.*,
+            b.UNITNAME,
+            CONCAT_WS('-', a.POINTSYEAR,b.UNITNAME ) AS UNIQUEVALUE
+            FROM
+            qhse_points_unit_record a
+            INNER JOIN "qhse_subcontractor_outsourcing" b   ON b.ID = a.SUBCONTRACTORID  AND b.DELETED = '0'
+            WHERE
+            a.DELETED = '0'
+            AND  a.POINTSYEAR IN
+            <foreach collection="years" item="year" open="(" separator="," close=")">
+                #{year}
+            </foreach>
+
+    </select>
+    <select id="getDetailsByYear" resultType="com.rongwei.bsentity.vo.QhsePointsUnitDetailsVo">
+
+
+        SELECT
+        a.*,
+        b.UNITNAME,
+        b.DEPARTMENTNAME,
+        CONCAT_WS('-', b.UNITNAME, a.DESCRIPTION,  DATE_FORMAT(a.HAPPENTIME, '%Y-%m-%d')) AS UNIQUEVALUE
+        FROM
+        qhse_points_unit_details a
+        INNER JOIN qhse_points_unit_record c ON c.DELETED='0' and a.POINTSUNITID= c.ID
+        INNER JOIN "qhse_subcontractor_outsourcing" b   ON b.ID = c.SUBCONTRACTORID  AND b.DELETED = '0'
+        WHERE
+        a.DELETED = '0'
+        AND  a.POINTSYEAR IN
+        <foreach collection="years" item="year" open="(" separator="," close=")">
+            #{year}
+        </foreach>
+
+
+    </select>
+
+
 </mapper>

+ 20 - 0
qhse-entity/src/main/java/com/rongwei/bsentity/Dto/UnitPointsImportValidationResult.java

@@ -0,0 +1,20 @@
+package com.rongwei.bsentity.dto;
+
+import com.rongwei.bsentity.domain.QhsePointsUnitDetailsDo;
+import com.rongwei.bsentity.vo.QhsePointsUnitDetailsVo;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 积分单位导入校验返回结果
+ */
+@Data
+public class UnitPointsImportValidationResult {
+
+    private  boolean valid = false;
+
+    private  List<QhsePointsUnitDetailsDo> validData;
+
+    private String errorMsg;
+}

+ 45 - 0
qhse-entity/src/main/java/com/rongwei/bsentity/Dto/UnitPointsRegistrationImportDto.java

@@ -0,0 +1,45 @@
+package com.rongwei.bsentity.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+import java.time.LocalDate;
+
+/**
+ * UserPointsRegistrationImportDto class
+ *
+ * @author XH
+ * @date 2025/09/10
+ */
+@Data
+public class UnitPointsRegistrationImportDto {
+    /**
+     * 单位名称
+     */
+    @ExcelProperty(index = 0)
+    private String unitname;
+    /**
+     * 所属部门
+     */
+    @ExcelProperty(index = 1)
+    private String departmentname;
+
+
+    /**
+     * 加扣分说明
+     */
+    @ExcelProperty(index = 2)
+    private String description;
+
+    /**
+     * 加扣分分值
+     */
+    @ExcelProperty(index = 3)
+    private Integer points;
+
+    /**
+     * 发生时间
+     */
+    @ExcelProperty(index = 4)
+    private LocalDate happentime;
+}

+ 2 - 0
qhse-entity/src/main/java/com/rongwei/bsentity/domain/QhsePointsUnitDetailsDo.java

@@ -7,12 +7,14 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.rongwei.rwcommon.base.BaseDo;
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 import java.util.Date;
 
 @Data
 @TableName(value = "qhse_points_unit_details")
+@Accessors(chain = true)
 public class QhsePointsUnitDetailsDo extends BaseDo implements Serializable {
     /**
      * 主键

+ 2 - 3
qhse-entity/src/main/java/com/rongwei/bsentity/domain/QhsePointsUnitRecordDo.java

@@ -14,10 +14,9 @@ import java.util.Date;
  * @author makejava
  * @since 2025-09-05 15:15:03
  */
-@SuppressWarnings("serial")
+
 @Data
 @TableName(value ="qhse_points_unit_record")
-
 public class QhsePointsUnitRecordDo extends BaseDo {
     /**
      * 主键
@@ -48,7 +47,7 @@ public class QhsePointsUnitRecordDo extends BaseDo {
     /**
      * 积分年度
      */
-    private Integer pointsyear;
+    private String pointsyear;
 
     /**
      * 分包商ID

+ 36 - 0
qhse-entity/src/main/java/com/rongwei/bsentity/vo/QhsePointsUnitDetailsVo.java

@@ -0,0 +1,36 @@
+package com.rongwei.bsentity.vo;
+
+import com.rongwei.bsentity.domain.QhsePointsUnitDetailsDo;
+import com.rongwei.bsentity.domain.QhsePointsUnitRecordDo;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+public class QhsePointsUnitDetailsVo extends QhsePointsUnitDetailsDo {
+
+    /**
+     * 单位名称
+     */
+    private String unitname;
+
+    /**
+     * 所属部门
+     */
+    private String departmentname;
+
+    /**
+     * 唯一key
+     */
+    private String uniquevalue;
+
+
+    /**
+     * 发生时间 年月日
+     */
+    private String happentimestr;
+
+
+
+
+}

+ 30 - 0
qhse-entity/src/main/java/com/rongwei/bsentity/vo/QhsePointsUnitRecordVo.java

@@ -0,0 +1,30 @@
+package com.rongwei.bsentity.vo;
+
+import com.rongwei.bsentity.domain.QhsePointsUnitDetailsDo;
+import com.rongwei.bsentity.domain.QhsePointsUnitRecordDo;
+import lombok.Data;
+
+@Data
+public class QhsePointsUnitRecordVo extends QhsePointsUnitRecordDo {
+
+    /**
+     * 单位名称
+     */
+    private String unitname;
+
+    /**
+     * 所属部门
+     */
+    private String departmentname;
+
+
+    /**
+     * 唯一key
+     */
+    private String uniquevalue;
+
+
+
+
+
+}

+ 15 - 0
qhse-server/src/main/java/com/rongwei/controller/ExcelImportController.java

@@ -1,6 +1,8 @@
 package com.rongwei.controller;
 
+import com.rongwei.bscommon.system.service.QhsePointsUnitDetailsService;
 import com.rongwei.bscommon.system.service.impl.ExcelImportServiceImpl;
+import com.rongwei.bscommon.system.service.impl.QhsePointsUnitDetailsServiceImpl;
 import com.rongwei.rwcommon.base.R;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -22,6 +24,9 @@ public class ExcelImportController {
     @Autowired
     private ExcelImportServiceImpl excelImportService;
 
+    @Autowired
+    private QhsePointsUnitDetailsServiceImpl qhsePointsUnitDetailsService;
+
     /**
      * 开始用户积分兑换
      *
@@ -33,4 +38,14 @@ public class ExcelImportController {
         log.info("开始用户积分兑换");
         return excelImportService.userPointsRegistration(file);
     }
+
+    /**
+     * 开始单位积分导入
+     * @return 结果
+     */
+    @PostMapping("/unit/point")
+    public R unitPointsRegistration(@RequestParam("file") MultipartFile file){
+        log.info("开始单位积分导入");
+        return excelImportService.unitPointsRegistration(file);
+    }
 }