Преглед на файлове

会计项目导入部分代码

徐滕 преди 1 месец
родител
ревизия
ae7c170cc2
променени са 12 файла, в които са добавени 510 реда и са изтрити 15 реда
  1. 7 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/contractRegistration/mapper/ContractInfoMapper.java
  2. 29 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/contractRegistration/mapper/xml/ContractInfoMapper.xml
  3. 9 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/contractRegistration/service/ContractInfoService.java
  4. 12 5
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/CwFinanceInvoiceService.java
  5. 1 1
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/dto/CwFinanceImportDTO.java
  6. 87 3
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/controller/CwProjectRecordsController.java
  7. 4 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/mapper/CwProjectRecordsMapper.java
  8. 63 1
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/mapper/xml/CwProjectRecordsMapper.xml
  9. 176 4
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/service/CwProjectRecordsService.java
  10. 122 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/service/dto/CwProjectRecordsImportDTO.java
  11. BIN
      jeeplus-modules/jeeplus-finance/src/main/resources/dot/发票导入模板.xlsx
  12. 0 1
      jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/service/UserService.java

+ 7 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/contractRegistration/mapper/ContractInfoMapper.java

@@ -88,4 +88,11 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
     String isUseByReim(@Param("id") String id);
 
     String isUseByInvoice(@Param("id") String id);
+
+    /**
+     * 根据合同名称查询合同信息
+     * @param contractNameList
+     * @return
+     */
+    List<ContractInfo> getByContractNameList(@Param("contractNameList") List<String> contractNameList, @Param("userId") String userId);
 }

+ 29 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/contractRegistration/mapper/xml/ContractInfoMapper.xml

@@ -270,4 +270,33 @@
         left join cw_work_contract_info cw_wci on cw_wci.id = cw_fib.contract_id and cw_wci.del_flag = '0'
         where cw_fib.del_flag = '0' and cw_fib.contract_id = #{id}
     </select>
+
+
+    <select id="getByContractNameList" resultType="com.jeeplus.finance.contractRegistration.domain.ContractInfo" parameterType="string">
+        select
+            cw_wci.contract_name,
+            cw_wci.id,
+            cw_wci.contract_no,
+            cw_wci.signing_date,
+            cw_wci.contract_amount,
+            cw_wci.department,
+            cw_wci.create_time,
+            cw_wci.create_by_id as create_id,
+            su.name as create_name,
+            so.name as department_name
+        from cw_work_contract_info cw_wci
+                 left join sys_user su on su.id = cw_wci.create_by_id and su.del_flag = '0'
+                 left join sys_office so on so.id = cw_wci.department and so.del_flag = '0'
+        <where>
+            and cw_wci.del_flag = 0
+            and cw_wci.create_by_id = #{userId}
+            <if test="contractNameList != null and contractNameList.size>0">
+                and cw_wci.contract_name in
+                <foreach collection="contractNameList" item="item" separator="," open="(" close=")" index="index">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
 </mapper>

+ 9 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/contractRegistration/service/ContractInfoService.java

@@ -901,4 +901,13 @@ public class ContractInfoService {
     public void updateFileNumber(ContractInfo info) {
         paperMapper.updateFileNumber(info.getFiledNo(),info.getId());
     }
+
+    /**
+     * 根据合同名称查询合同信息
+     * @param contractNameList
+     * @return
+     */
+    public List<ContractInfo> getByContractNameList(List<String> contractNameList,String userId) {
+        return mapper.getByContractNameList(contractNameList,userId);
+    }
 }

+ 12 - 5
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/CwFinanceInvoiceService.java

@@ -1235,7 +1235,7 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
             for (CwFinanceImportDTO cwFinanceImportDTO : listA) {
                 // 1. 报告号和项目编号校验
                 if (StringUtils.isBlank(cwFinanceImportDTO.getReportNo()) && StringUtils.isBlank(cwFinanceImportDTO.getProjectNo())) {
-                    return "报告号和项目编号不能同时为空";
+                    return "报告号和项目名称不能同时为空";
                 }
                 // 4. 开票内容必填
                 if (StringUtils.isBlank(cwFinanceImportDTO.getBillingContent())) {
@@ -1402,10 +1402,17 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
 
                 //保存报告或项目信息
                 if (StringUtils.isNotBlank(cwFinanceImportDTO.getProjectNo()) && StringUtils.isBlank(cwFinanceImportDTO.getReportNo())){
-                    boolean exist = projectRecordsList.stream().anyMatch(records -> records.getProjectNumber().equals(cwFinanceImportDTO.getProjectNo()));
+
+                    //查询全部的项目信息
+                    List<CwProjectRecordsDTO> projectRecordsListByName = cwProjectRecordsMapper.selectProjectListByName(userDTO.getId(),cwFinanceImportDTO.getProjectNo());
+                    if (projectRecordsListByName.size()>1) {
+                        return "项目名称:"+cwFinanceImportDTO.getProjectNo()+" 存在多条,无法进行导入";
+                    }
+
+                    boolean exist = projectRecordsListByName.stream().anyMatch(records -> records.getProjectName().equals(cwFinanceImportDTO.getProjectNo()));
                     if (exist){
-                        for (CwProjectRecordsDTO cwProjectRecords : projectRecordsList) {
-                            if (cwProjectRecords.getProjectNumber().equals(cwFinanceImportDTO.getProjectNo())){
+                        for (CwProjectRecordsDTO cwProjectRecords : projectRecordsListByName) {
+                            if (cwProjectRecords.getProjectName().equals(cwFinanceImportDTO.getProjectNo())){
                                 cwFinanceInvoiceBase.setProgramId(cwProjectRecords.getId());
                                 cwFinanceInvoiceBase.setProgramNo(cwProjectRecords.getProjectNumber());
                                 cwFinanceInvoiceBase.setProgramName(cwProjectRecords.getProjectName());
@@ -1416,7 +1423,7 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
                             }
                         }
                     }else {
-                        return "项目编号:"+cwFinanceImportDTO.getProjectNo()+" 不是当前登录人所创建或该项目下存在报告,请重新填写";
+                        return "项目名称:"+cwFinanceImportDTO.getProjectNo()+" 不是当前登录人所创建或该项目下存在报告,请重新填写";
                     }
                 }
                 if ((StringUtils.isNotBlank(cwFinanceImportDTO.getReportNo()) && StringUtils.isBlank(cwFinanceImportDTO.getProjectNo())) ||(StringUtils.isNotBlank(cwFinanceImportDTO.getReportNo()) && StringUtils.isNotBlank(cwFinanceImportDTO.getProjectNo()))){

+ 1 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/dto/CwFinanceImportDTO.java

@@ -9,7 +9,7 @@ public class CwFinanceImportDTO extends BaseDTO {
     @Excel(name = "报告号",width = 25)
     private String reportNo;
 
-    @Excel(name = "项目编号",width = 25)
+    @Excel(name = "项目名称",width = 25)
     private String projectNo;
 
     @Excel(name = "*项目开票金额",width = 16)

+ 87 - 3
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/controller/CwProjectRecordsController.java

@@ -6,12 +6,16 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.TypeReference;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.aop.demo.annotation.DemoMode;
 import com.jeeplus.common.excel.ExcelOptions;
 import com.jeeplus.common.excel.annotation.ExportMode;
 import com.jeeplus.common.utils.ResponseUtil;
+import com.jeeplus.finance.invoice.controller.CwFinanceInvoiceController;
+import com.jeeplus.finance.invoice.service.dto.CwFinanceImportDTO;
 import com.jeeplus.finance.invoice.util.EasyPoiUtil;
 import com.jeeplus.finance.projectRecords.service.CwProjectRecordsService;
 import com.jeeplus.finance.projectRecords.service.dto.CwProjectRecordsDTO;
+import com.jeeplus.finance.projectRecords.service.dto.CwProjectRecordsImportDTO;
 import com.jeeplus.logging.annotation.ApiLog;
 import com.jeeplus.logging.constant.enums.LogTypeEnum;
 //import com.jeeplus.sys.utils.DictUtils;
@@ -20,9 +24,12 @@ import com.jeeplus.sys.feign.IDictApi;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -31,11 +38,11 @@ import javax.validation.Valid;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Type;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -51,6 +58,8 @@ public class CwProjectRecordsController {
     @Resource
     private CwProjectRecordsService cwProjectRecordsService;
 
+    private static Logger log = LoggerFactory.getLogger(CwProjectRecordsController.class);
+
     /**
      * 查询财务项目信息列表
      * @return
@@ -435,8 +444,83 @@ public class CwProjectRecordsController {
     }
 
 
+    /**
+     * 导入发票数据
+     *
+     * @return
+     */
+    @DemoMode
+    @PostMapping("/importProjectRecords")
+    @ApiLog(value = "导入发票数据excel", type = LogTypeEnum.IMPORT)
+    public ResponseEntity importProjectRecords(MultipartFile file, HttpServletRequest request) throws IOException {
+
+
+        List<CwProjectRecordsImportDTO> listA = new ArrayList<>();
+        //获取sheet
+        listA = EasyPoiUtil.importExcel(file, 1, 1, CwProjectRecordsImportDTO.class);
+        //去除excel中的空行
+        listA = getExList(listA);
+        //导入前检测数据
+        String resultA = cwProjectRecordsService.importProjectRecords(listA);
+        if(StringUtils.isNotBlank(resultA)){
+            //有返回值,说明导入的数据不正确。向用户抛提示
+            return ResponseEntity.badRequest().body  (resultA);
+        }
 
+        return ResponseEntity.ok("导入成功");
+    }
 
+    /**
+     * 去除excel中的空行
+     * @param list
+     * @return
+     */
+    public ArrayList<CwProjectRecordsImportDTO> getExList(List<CwProjectRecordsImportDTO> list){
+
+        ArrayList<CwProjectRecordsImportDTO> cwProjectRecordsImportDTOS = new ArrayList<>();
+
+        list.stream().forEach(item->{
+            if(objectCheckIsNull(item)){
+                cwProjectRecordsImportDTOS.add(item);
+            }
+        });
+
+        return cwFinanceImportDTOS;
+    }
+
+    public static boolean objectCheckIsNull(Object object) {
+        boolean flag = false; //定义返回结果,默认为true
+
+        if (Objects.isNull(object)) {
+            flag = false;
+        } else {
+            Class clazz = (Class) object.getClass(); // 得到类对象
+            Field fields[] = clazz.getDeclaredFields(); // 得到所有属性
+            for (Field field : fields) {
+                if("serialVersionUID".equals(field.getName()) || "BIZ_CODE".equalsIgnoreCase(field.getName())){
+                    continue;
+                }
+                field.setAccessible(true);
+                Object fieldValue = null;
+                try {
+                    fieldValue = field.get(object); //得到属性值
+                    Type fieldType = field.getGenericType();//得到属性类型
+                    String fieldName = field.getName(); // 得到属性名
+                    log.info("属性类型:" + fieldType + ",属性名:" + fieldName + ",属性值:" + fieldValue);
+                } catch (IllegalArgumentException e) {
+                    log.error(e.getMessage(), e);
+                } catch (IllegalAccessException e) {
+                    log.error(e.getMessage(), e);
+                }
+                if (fieldValue != null && fieldValue != "") {  //只要有一个属性值不为null 就返回false 表示对象不为null
+                    flag = true;
+                    break;
+                }
+            }
+        }
+
+        return flag;
+    }
 
 
 

+ 4 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/mapper/CwProjectRecordsMapper.java

@@ -114,4 +114,8 @@ public interface CwProjectRecordsMapper extends BaseMapper<CwProjectRecords> {
     List<String> getByProgramName(@Param("programName") String programName);
 
     List<CwProjectRecordsDTO> selectAllList(@Param("userId") String userId, @Param("projectNoList")ArrayList<String> projectNoList);
+
+    List<CwProjectRecordsDTO> selectProjectListByName(@Param("userId") String userId, @Param("projectName")String projectName);
+
+    List<CwProjectRecordsDTO> getByProjectNameList(@Param("projectNameList") List<String> projectNameList);
 }

+ 63 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/mapper/xml/CwProjectRecordsMapper.xml

@@ -747,7 +747,7 @@
         and ((a.create_time >=(SELECT dv.label FROM sys_dict_type dt LEFT JOIN sys_dict_value dv on dt.id = dv.dict_type_id where dt.type='new_project_time')
         and a.is_have_report = '0') or a.create_time &lt; (SELECT dv.label FROM sys_dict_type dt LEFT JOIN sys_dict_value dv on dt.id = dv.dict_type_id where dt.type='new_project_time'))
         <if test="projectNoList != null and projectNoList.size > 0">
-            and a.project_number in
+            and a.project_name in
             <foreach collection="projectNoList" item="item" separator="," open="(" close=")" index="index">
                 #{item}
             </foreach>
@@ -755,5 +755,67 @@
         ORDER BY a.create_time DESC
     </select>
 
+    <select id="selectProjectListByName" resultType="com.jeeplus.finance.projectRecords.service.dto.CwProjectRecordsDTO">
+        select
+        DISTINCT
+        <include refid="Base_Column_List"></include>,
+        su.name as createName,
+        cw_wci.contract_name,
+        cw_wci.contract_amount,
+        cw_wci.contract_num,
+        cw_wci.payer_subject,
+        cw_wci.payment_method,
+        cw_wcb.name as clientContactsName,
+        cw_pbt.name as business_type_name,
+        new_line.report_no as reportNo
+        from cw_project_records a
+        left join sys_user su on su.id = a.create_by_id and su.del_flag = '0'
+        left join cw_work_contract_info cw_wci on cw_wci.id = a.contract_id and cw_wci.del_flag = '0'
+        left join cw_work_client_base cw_wcb on cw_wci.client_contacts = cw_wcb.id and cw_wcb.del_flag = '0'
+        left join cw_project_business_type cw_pbt on cw_pbt.id = a.business_type and cw_pbt.del_flag = '0'
+        left join cw_project_report pr on a.id =pr.project_id and pr.del_flag = '0'
+        left join cw_project_report_new_line new_line on pr.id = new_line.report_id and new_line.del_flag = '0'
+        where a.del_flag = '0' and a.create_by_id = #{userId}
+        and ((a.create_time >=(SELECT dv.label FROM sys_dict_type dt LEFT JOIN sys_dict_value dv on dt.id = dv.dict_type_id where dt.type='new_project_time')
+        and a.is_have_report = '0') or a.create_time &lt; (SELECT dv.label FROM sys_dict_type dt LEFT JOIN sys_dict_value dv on dt.id = dv.dict_type_id where dt.type='new_project_time'))
+        <if test="projectName != null and projectName != ''">
+            and a.project_name = #{projectName}
+        </if>
+        ORDER BY a.create_time DESC
+    </select>
+
+    <select id="getByProjectNameList" resultType="com.jeeplus.finance.projectRecords.service.dto.CwProjectRecordsDTO">
+        select
+        DISTINCT
+        <include refid="Base_Column_List"></include>,
+        su.name as createName,
+        cw_wci.contract_name,
+        cw_wci.contract_amount,
+        cw_wci.contract_num,
+        cw_wci.payer_subject,
+        cw_wci.payment_method,
+        cw_wcb.name as clientContactsName,
+        cw_pbt.name as business_type_name,
+        new_line.report_no as reportNo
+        from cw_project_records a
+        left join sys_user su on su.id = a.create_by_id and su.del_flag = '0'
+        left join cw_work_contract_info cw_wci on cw_wci.id = a.contract_id and cw_wci.del_flag = '0'
+        left join cw_work_client_base cw_wcb on cw_wci.client_contacts = cw_wcb.id and cw_wcb.del_flag = '0'
+        left join cw_project_business_type cw_pbt on cw_pbt.id = a.business_type and cw_pbt.del_flag = '0'
+        left join cw_project_report pr on a.id =pr.project_id and pr.del_flag = '0'
+        left join cw_project_report_new_line new_line on pr.id = new_line.report_id and new_line.del_flag = '0'
+        where a.del_flag = '0' and a.create_by_id = #{userId}
+        and ((a.create_time >=(SELECT dv.label FROM sys_dict_type dt LEFT JOIN sys_dict_value dv on dt.id = dv.dict_type_id where dt.type='new_project_time')
+        and a.is_have_report = '0') or a.create_time &lt; (SELECT dv.label FROM sys_dict_type dt LEFT JOIN sys_dict_value dv on dt.id = dv.dict_type_id where dt.type='new_project_time'))
+        <if test="projectNameList != null and projectNameList.size > 0">
+            and a.project_name in
+            <foreach collection="projectNameList" item="item" separator="," open="(" close=")" index="index">
+                #{item}
+            </foreach>
+        </if>
+        group by a.project_name
+        ORDER BY a.create_time DESC
+    </select>
+
 
 </mapper>

+ 176 - 4
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/service/CwProjectRecordsService.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -19,15 +20,17 @@ import com.jeeplus.common.redis.RedisUtils;
 import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.finance.contractRegistration.domain.ContractInfo;
 import com.jeeplus.finance.contractRegistration.mapper.ContractInfoMapper;
+import com.jeeplus.finance.contractRegistration.service.ContractInfoService;
+import com.jeeplus.finance.invoice.domain.CwFinanceInvoice;
+import com.jeeplus.finance.invoice.domain.CwFinanceInvoiceBase;
+import com.jeeplus.finance.invoice.service.dto.CwFinanceImportDTO;
+import com.jeeplus.finance.invoice.service.dto.CwFinanceInvoiceDTO;
 import com.jeeplus.finance.projectRecords.domain.CwProjectClientContact;
 import com.jeeplus.finance.projectRecords.domain.CwProjectMembers;
 import com.jeeplus.finance.projectRecords.domain.CwProjectRecords;
 import com.jeeplus.finance.projectRecords.mapper.CwProjectClientContactMapper;
 import com.jeeplus.finance.projectRecords.mapper.CwProjectRecordsMapper;
-import com.jeeplus.finance.projectRecords.service.dto.CwProjectClientContactDTO;
-import com.jeeplus.finance.projectRecords.service.dto.CwProjectClientInfoDTO;
-import com.jeeplus.finance.projectRecords.service.dto.CwProjectMembersDTO;
-import com.jeeplus.finance.projectRecords.service.dto.CwProjectRecordsDTO;
+import com.jeeplus.finance.projectRecords.service.dto.*;
 import com.jeeplus.finance.projectRecords.service.mapstruct.CwProjectClientContactWrapper;
 import com.jeeplus.finance.projectRecords.service.mapstruct.CwProjectMembersWrapper;
 import com.jeeplus.finance.projectRecords.service.mapstruct.CwProjectRecordsWrapper;
@@ -36,10 +39,12 @@ import com.jeeplus.finance.projectReport.mapper.CwProjectReportMapper;
 import com.jeeplus.finance.workClientInfo.domain.CwWorkClientContact;
 import com.jeeplus.finance.workClientInfo.service.CwWorkClientContactService;
 import com.jeeplus.finance.workClientInfo.service.dto.CwWorkClientBaseDTO;
+import com.jeeplus.finance.workClientInfo.service.dto.CwWorkClientBillingDTO;
 import com.jeeplus.sys.domain.User;
 import com.jeeplus.sys.feign.IDictApi;
 import com.jeeplus.sys.feign.IUserApi;
 import com.jeeplus.sys.feign.IWorkAttachmentApi;
+import com.jeeplus.sys.service.dto.AreaDTO;
 import com.jeeplus.sys.service.dto.UserDTO;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.http.ResponseEntity;
@@ -83,6 +88,8 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
     private CwProjectMembersService cwProjectMembersService;
     @Resource
     private CwProjectReportMapper cwProjectReportMapper;
+    @Resource
+    private ContractInfoService contractInfoService;
 
 
     /**
@@ -1110,4 +1117,169 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
         }
         return recordsToKeep;
     }
+
+
+    /**
+     * 分组(根据项目名称)
+     * @param list
+     * @return
+     */
+    private Map<String, List<CwProjectRecordsImportDTO>> dataMessageDisposeByProjectName(List<CwProjectRecordsImportDTO> list) {
+        Map<String, List<CwProjectRecordsImportDTO>> infoMap = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(list)) {
+            // 分组
+            for (CwProjectRecordsImportDTO vo : list) {
+                List<CwProjectRecordsImportDTO> tempList = infoMap.get(vo.getProjectName());
+                /*如果取不到数据,那么直接new一个空的ArrayList**/
+                if (tempList == null) {
+                    tempList = new ArrayList<>();
+                    tempList.add(vo);
+                    infoMap.put(vo.getProjectName(), tempList);
+                }
+                else {
+                    /*某个vo之前已经存放过了,则直接追加数据到原来的List里**/
+                    tempList.add(vo);
+                }
+            }
+        }
+        return infoMap;
+    }
+
+    /**
+     * 导入发票数据
+     * @param list
+     * @return
+     */
+    public String importProjectRecords(List<CwProjectRecordsImportDTO> list) {
+
+        //获取当前登录人信息
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+        if(null == userDTO || StringUtils.isBlank(userDTO.getId())) {
+            return "登录信息已失效,请重新登录后再进行导入信息";
+        }
+        if(null == list || list.size() == 0) {
+            return "导入的数据为空,请确认后重新导入";
+        }
+
+        //根据合同名称进行去重,并根据去重后的合同名称进行查询,若查询出来的数据量小于去重后的合同量,则表示有合同没有进行录入,则不进行导入
+        LinkedHashSet contractNameSet = new LinkedHashSet();
+        for (CwProjectRecordsImportDTO cwProjectRecordsImportDTO : list) {
+            contractNameSet.add(cwProjectRecordsImportDTO.getContractName());
+        }
+        List contractNameList = Lists.newArrayList(contractNameSet);
+
+        List<ContractInfo> contractInfoList = Lists.newArrayList();
+        //根据contractList进行查询合同信息
+        //分批处理
+        if(null!=contractNameList && contractNameList.size()>0){
+            int pointsDataLimit = 10;//限制条数
+            Integer size = list.size();
+            //判断是否有必要分批
+            if(pointsDataLimit<size){
+                int part = size/pointsDataLimit;//分批数
+                //
+                for (int i = 0; i < part; i++) {
+                    //10条
+                    List<String> subContractNameList = contractNameList.subList(0, pointsDataLimit);
+                    //查询的合同信息仅自己创建的合同信息
+                    List<ContractInfo> contractList = contractInfoService.getByContractNameList(subContractNameList,userDTO.getId());
+                    contractInfoList.addAll(contractList);
+                    //剔除
+                    list.subList(0, pointsDataLimit).clear();
+                }
+                if(!list.isEmpty()){
+                    List<ContractInfo> contractList = contractInfoService.getByContractNameList(contractNameList,userDTO.getId());
+                    contractInfoList.addAll(contractList);
+                }
+            }else{
+                List<ContractInfo> contractList = contractInfoService.getByContractNameList(contractNameList,userDTO.getId());
+                contractInfoList.addAll(contractList);
+            }
+        }else{
+            return "导入数据中的合同名称不存在,请修正后重新导入";
+        }
+        //对比查询出来的合同信息,如果查询出来的合同信息比去重后的合同信息少,则表示合同信息存在没有录入系统的情况,则直接抛出
+        if(contractInfoList.size() != contractNameList.size()){
+            return "导入数据中的合同名称存在未录入系统或填写错误的情况,请修正后重新导入";
+        }
+
+
+        //根据项目名称进行去重,若去重后的数量小于原数据量,则表示项目名称有重复,则不进行导入
+
+        LinkedHashSet projectNameSet = new LinkedHashSet();
+        for (CwProjectRecordsImportDTO cwProjectRecordsImportDTO : list) {
+            projectNameSet.add(cwProjectRecordsImportDTO.getProjectName());
+        }
+        List projectNameList = Lists.newArrayList(projectNameSet);
+
+        List<CwProjectRecordsDTO> projectInfoList = Lists.newArrayList();
+        //根据contractList进行查询合同信息
+        //分批处理
+        if(null!=projectNameList && projectNameList.size()>0){
+            int pointsDataLimit = 10;//限制条数
+            Integer size = list.size();
+            //判断是否有必要分批
+            if(pointsDataLimit<size){
+                int part = size/pointsDataLimit;//分批数
+                //
+                for (int i = 0; i < part; i++) {
+                    //10条
+                    List<String> subProjectNameList = projectNameList.subList(0, pointsDataLimit);
+                    //查询的合同信息仅自己创建的合同信息
+                    List<CwProjectRecordsDTO> contractList = cwProjectRecordsMapper.getByProjectNameList(subProjectNameList);
+                    projectInfoList.addAll(contractList);
+                    //剔除
+                    list.subList(0, pointsDataLimit).clear();
+                }
+                if(!list.isEmpty()){
+                    List<CwProjectRecordsDTO> contractList = cwProjectRecordsMapper.getByProjectNameList(projectNameList);
+                    projectInfoList.addAll(contractList);
+                }
+            }else{
+                List<CwProjectRecordsDTO> contractList = cwProjectRecordsMapper.getByProjectNameList(projectNameList);
+                projectInfoList.addAll(contractList);
+            }
+        }else{
+            return "导入数据中的项目名称不存在,请修正后重新导入";
+        }
+        //对比查询出来的合同信息,如果查询出来的合同信息比去重后的合同信息少,则表示合同信息存在没有录入系统的情况,则直接抛出
+        if(projectInfoList.size()>0){
+            List<String> repeatedProjectNameList = Lists.newArrayList();
+            for (CwProjectRecordsDTO cwProjectRecordsDTO : projectInfoList) {
+                repeatedProjectNameList.add(cwProjectRecordsDTO.getProjectName());
+            }
+            String repeatedProjectNameStr = String.join(",", repeatedProjectNameList);
+            return "导入数据中的项目名称为: " + repeatedProjectNameStr + "  已存在,请修正后重新导入";
+        }
+
+        //查询风险等级字典
+        String riskLevelDatas = SpringUtil.getBean ( IDictApi.class ).getDictValueListMapByDict ("cw_project_risk_level");
+
+        //查询有无报告字典
+        String isHaveReportDatas = SpringUtil.getBean ( IDictApi.class ).getDictValueListMapByDict ("is_have_report");
+
+        //查询报备类型字典
+        String reportTypeDatas = SpringUtil.getBean ( IDictApi.class ).getDictValueListMapByDict ("cw_work_client_report_type");
+
+        for (CwProjectRecordsImportDTO cwProjectRecordsImportDTO : list) {
+            //对比风险等级的key
+
+            //对比有无报告的key
+
+            //对比报备类型的key
+
+            //现场负责人若没填写,则默认为上传人
+
+            //项目经理1 和项目经理2 至少填写一个,且必须有效,否则不进行导入
+
+            //根据客户联系人-兴民和、部门、手机号。和合同信息进行查询并嵌入
+
+        }
+
+        //批量导入功能实现
+
+
+
+        return "";
+    }
 }

+ 122 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/service/dto/CwProjectRecordsImportDTO.java

@@ -0,0 +1,122 @@
+package com.jeeplus.finance.projectRecords.service.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jeeplus.core.service.dto.BaseDTO;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+
+/**
+ * @author: 徐滕
+ * @version: 2025-3-18 10:02
+ */
+@Data
+public class CwProjectRecordsImportDTO extends BaseDTO {
+
+    private static final long serialVersionUID = 1L;
+
+    @Excel(name = "*合同名称",width = 255)
+    @NotNull(message="合同名称不可为空")
+    private String contractName;
+
+    @Excel(name = "*项目名称",width = 255)
+    @NotNull(message="项目名称不可为空")
+    private String projectName;
+
+    /**
+     * 风险等级
+     */
+    @Excel(name = "*风险等级",width = 20)
+    @NotNull(message="风险等级不可为空")
+    private String riskLevel;
+
+
+    /**
+     * 项目规模
+     */
+    @Excel(name = "*项目规模",width = 25)
+    @NotNull(message="项目规模不可为空")
+    private String projectMoney;
+
+    /**
+     * 有无报告(0:无,1:有)
+     */
+    @Excel(name = "*有无报告",width = 20)
+    @NotNull(message="有无报告不可为空")
+    private String isHaveReport;
+
+    /**
+     * 报备类型
+     */
+    @Excel(name = "*报备类型",width = 25)
+    @NotNull(message="报备类型不可为空")
+    private String reportType;
+
+    /**
+     * 审计期间
+     */
+    @Excel(name = "*审计期间",width = 25)
+    @NotNull(message="审计期间不可为空")
+    private String auditYear;
+
+    /**
+     * 项目计划开始时间
+     */
+    @Excel(name = "*项目计划开始时间",width = 50)
+    @NotNull(message="项目计划开始时间不可为空")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date planStartDate;
+
+    /**
+     * 项目计划结束时间
+     */
+    @Excel(name = "*项目计划结束时间",width = 50)
+    @NotNull(message="项目计划结束时间不可为空")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date planEndDate;
+
+    /**
+     * 现场负责人
+     */
+    @Excel(name = "*现场负责人",width = 50)
+    private String projectLeaderId;
+
+    /**
+     * 项目经理1
+     */
+    @Excel(name = "*项目经理1",width = 50)
+    private String projectMasterId;
+
+    /**
+     * 项目经理2
+     */
+    @Excel(name = "*项目经理2",width = 50)
+    private String realHeader;
+
+    /**
+     * 客户姓名
+     */
+    @Excel(name = "*客户姓名",width = 50)
+    @NotNull(message="客户姓名不可为空")
+    private String cwProjectClientName;
+
+    /**
+     * 客户部门
+     */
+    @Excel(name = "*客户部门",width = 50)
+    @NotNull(message="客户部门不可为空")
+    private String cwProjectClientOffice;
+
+    /**
+     * 客户手机号
+     */
+    @Excel(name = "*客户手机号",width = 50)
+    @NotNull(message="客户手机号不可为空")
+    private String cwProjectClientPhone;
+
+}

BIN
jeeplus-modules/jeeplus-finance/src/main/resources/dot/发票导入模板.xlsx


+ 0 - 1
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/service/UserService.java

@@ -27,7 +27,6 @@ import com.jeeplus.sys.service.dto.*;
 import com.jeeplus.sys.service.mapstruct.CertWrapper;
 import com.jeeplus.sys.service.mapstruct.UserWrapper;
 import com.jeeplus.sys.utils.UserUtils;
-import com.taobao.api.ApiException;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;