瀏覽代碼

预开票

sangwenwei 1 年之前
父節點
當前提交
68db0ba04e
共有 20 個文件被更改,包括 760 次插入6 次删除
  1. 5 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/FinanceApiFallbackFactory.java
  2. 7 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IFinanceApi.java
  3. 16 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/controller/CwFinanceInvoiceController.java
  4. 2 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/mapper/CwFinanceInvoiceMapper.java
  5. 20 2
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/mapper/xml/CwFinanceInvoiceMapper.xml
  6. 84 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/CwFinanceInvoiceService.java
  7. 4 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/dto/CwFinanceInvoiceBaseDTO.java
  8. 13 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/dto/CwFinanceInvoiceDTO.java
  9. 43 2
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/controller/CwProjectRecordsController.java
  10. 5 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/mapper/CwProjectRecordsMapper.java
  11. 57 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/mapper/xml/CwProjectRecordsMapper.xml
  12. 127 1
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/service/CwProjectRecordsService.java
  13. 7 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/service/dto/CwProjectRecordsDTO.java
  14. 10 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/domain/CwProjectReport.java
  15. 10 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/domain/CwProjectReportData.java
  16. 2 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/CwProjectReportMapper.java
  17. 16 1
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/xml/CwProjectReportMapper.xml
  18. 8 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/service/CwProjectReportService.java
  19. 246 0
      jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/jeeplus/domain/CwProjectRecordsList.java
  20. 78 0
      jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java

+ 5 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/FinanceApiFallbackFactory.java

@@ -42,6 +42,11 @@ public class FinanceApiFallbackFactory implements FallbackFactory<IFinanceApi> {
 
             }
 
+            @Override
+            public String getCompleteCollection() {
+                return null;
+            }
+
         };
     }
 }

+ 7 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IFinanceApi.java

@@ -29,4 +29,11 @@ public interface IFinanceApi {
 
     @RequestMapping(value = "/cwProjectRecords/insertMembers", method = RequestMethod.POST)
     void insertMembers(@RequestParam(value = "projectId")String projectId,@RequestParam(value = "membersId")String membersId,@RequestParam(value = "userId")String userId);
+
+    /**
+     * 查询预开票项目
+     */
+    @GetMapping(value = "/cwProjectRecords/getCompleteCollection")
+    String getCompleteCollection();
+
 }

+ 16 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/controller/CwFinanceInvoiceController.java

@@ -403,6 +403,22 @@ public class CwFinanceInvoiceController {
         return flag;
     }
 
+    /**
+     * 根据项目id查询发票信息
+     * @param cwFinanceInvoiceDTO
+     * @param page
+     * @return
+     * @throws Exception
+     */
+    @ApiLog("根据项目id查询发票信息")
+    @GetMapping("listByProgramId")
+    public ResponseEntity<IPage<CwFinanceInvoiceDTO>> listByProgramId(CwFinanceInvoiceDTO cwFinanceInvoiceDTO, Page<CwFinanceInvoiceDTO> page) throws Exception {
+        IPage<CwFinanceInvoiceDTO> result = new Page<CwFinanceInvoiceDTO>();
+        result = cwFinanceInvoiceService.listByProgramId (page, cwFinanceInvoiceDTO);
+        return ResponseEntity.ok(result);
+    }
+
+
 
 
 

+ 2 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/mapper/CwFinanceInvoiceMapper.java

@@ -49,6 +49,8 @@ public interface CwFinanceInvoiceMapper extends BaseMapper<CwFinanceInvoice> {
      */
     @InterceptorIgnore(tenantLine = "true")
     void updateInfoById(CwFinanceInvoice cwFinanceInvoice);
+
+    IPage<CwFinanceInvoiceDTO> listByProgramId(Page<CwFinanceInvoiceDTO> page,@Param(Constants.WRAPPER) QueryWrapper<CwFinanceInvoiceDTO> queryWrapper);
 }
 
 

+ 20 - 2
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/mapper/xml/CwFinanceInvoiceMapper.xml

@@ -315,6 +315,7 @@
         cfid.number as "number",
         cfid.account as "accountDetail",
         a.program_id,
+        pr.is_pre_invoice as isPreInvoice,
         a.type as 'recordType'
         from cw_finance_invoice_base a
         left join cw_finance_invoice fi on a.invoice_id = fi.id
@@ -373,7 +374,12 @@
         cfid.number as "number",
         ifnull(cfid.account,"0") as "accountDetail",
         a.program_id,
-        a.type as 'recordType'
+        a.type as 'recordType',
+        (case when a.type = '1' then (select group_concat(pr.is_pre_invoice) from cw_project_records pr where pr.id = a.program_id)
+        else '' end ) as isPreInvoice,
+        (case when a.type = '1' then
+        (select group_concat(is_complete_invoice) from cw_project_report pr where pr.project_id = a.program_id)
+        else '' end) as isCompleteInvoice
         from cw_finance_invoice_base a
         left join cw_finance_invoice fi on a.invoice_id = fi.id
         left join cw_finance_invoice_detail cfid on cfid.invoice_id = fi.id and cfid.del_flag = '0'
@@ -381,7 +387,6 @@
         left join sys_user_manage_office sumo on sumo.office_id = su.office_id
         left join sys_office so on su.office_id = so.id and so.del_flag = '0'
         LEFT JOIN act_ru_task d ON fi.proc_ins_id = d.PROC_INST_ID_
-        LEFT JOIN cw_project_records pr on a.program_id=pr.id
         ${ew.customSqlSegment}
         ORDER BY
         fi.create_time DESC, cfid.number asc
@@ -547,4 +552,17 @@
         remarks = #{remarks}
         where id = #{id}
     </update>
+
+    <select id="listByProgramId" resultType="com.jeeplus.finance.invoice.service.dto.CwFinanceInvoiceDTO">
+        select
+        DISTINCT
+        <include refid="Base_Column_List"></include>,
+        su.name as createName,
+        fid.number as "number"
+        from cw_finance_invoice fi
+        left join cw_finance_invoice_base fib on fib.invoice_id = fi.id
+        left join cw_finance_invoice_detail fid on fi.id = fid.invoice_id
+        left join sys_user su on fi.create_by_id = su.id
+        ${ew.customSqlSegment}
+    </select>
 </mapper>

+ 84 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/CwFinanceInvoiceService.java

@@ -1,6 +1,7 @@
 package com.jeeplus.finance.invoice.service;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSON;
@@ -22,6 +23,7 @@ import com.jeeplus.finance.invoice.service.mapstruct.*;
 import com.jeeplus.finance.projectRecords.domain.CwProjectRecords;
 import com.jeeplus.finance.projectRecords.mapper.CwProjectRecordsMapper;
 import com.jeeplus.finance.projectRecords.service.dto.CwProjectRecordsDTO;
+import com.jeeplus.finance.projectReport.domain.CwProjectReportData;
 import com.jeeplus.finance.projectReport.mapper.CwProjectReportMapper;
 import com.jeeplus.finance.workClientInfo.domain.CwWorkClientBase;
 import com.jeeplus.finance.workClientInfo.domain.CwWorkClientBilling;
@@ -328,6 +330,7 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
         IPage<CwFinanceInvoiceDTO> list = null;
         if(StringUtils.isNotBlank(export) && "export".equals(export)){
             list = cwFinanceInvoiceMapper.findExportList(page, queryWrapper);
+
         }else{
             list = cwFinanceInvoiceMapper.findList(page, queryWrapper);
         }
@@ -338,7 +341,31 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
     public CwFinanceInvoiceDTO queryById(String id) {
 
         CwFinanceInvoiceDTO cwFinanceInvoiceDTO = cwFinanceInvoiceMapper.queryById(id);
+        //获取项目是否预开票
+        if (ObjectUtil.isNotEmpty(cwFinanceInvoiceDTO)){
+            for (CwFinanceInvoiceBaseDTO cwFinanceInvoiceBaseDTO : cwFinanceInvoiceDTO.getFinanceInvoiceBaseDTOList()) {
+                CwProjectRecordsDTO projectRecordsDTO = cwProjectRecordsMapper.queryById(cwFinanceInvoiceBaseDTO.getProgramId());
+                if (StringUtils.isNotBlank(projectRecordsDTO.getIsPreInvoice()) && "1".equals(projectRecordsDTO.getIsPreInvoice())){
+                    cwFinanceInvoiceBaseDTO.setIsPreInvoice(projectRecordsDTO.getIsPreInvoice());
+                }
+                List<CwProjectReportData> reportData = cwProjectReportMapper.getByProjectId(cwFinanceInvoiceBaseDTO.getProgramId());
+                if (CollectionUtils.isNotEmpty(reportData)){
+                    for (CwFinanceInvoiceDetailDTO cwFinanceInvoiceDetailDTO : cwFinanceInvoiceDTO.getFinanceInvoiceDetailDTOList()) {
+                        for (CwProjectReportData reportDatum : reportData) {
+                            if (StringUtils.isNotBlank(reportDatum.getReportNo()) &&
+                                    reportDatum.getInvoiceNumber().equals(cwFinanceInvoiceDetailDTO.getNumber())) {
+                                cwFinanceInvoiceBaseDTO.setReportNo(reportDatum.getReportNo());
+                                break;
+                            }
+                        }
+
+                    }
+                }
+                break;
+            }
 
+
+        }
         // 电话号获取
         if (ObjectUtil.isNotEmpty(cwFinanceInvoiceDTO) && StringUtils.isNotBlank(cwFinanceInvoiceDTO.getBillingId())) {
             CwWorkClientBilling cwWorkClientBilling = cwWorkClientBillingService.getById(cwFinanceInvoiceDTO.getBillingId());
@@ -788,4 +815,61 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
         return infoMap;
     }
 
+    /**
+     * 根据项目id查询开票信息
+     * @param page
+     * @param cwFinanceInvoiceDTO
+     * @return
+     */
+    public IPage<CwFinanceInvoiceDTO> listByProgramId(Page<CwFinanceInvoiceDTO> page, CwFinanceInvoiceDTO cwFinanceInvoiceDTO) {
+        QueryWrapper<CwFinanceInvoiceDTO> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("fib.del_flag",'0');
+        queryWrapper.eq("fi.del_flag",'0');
+        queryWrapper.eq("fi.status",cwFinanceInvoiceDTO.getStatus());
+        queryWrapper.eq("fib.program_id",cwFinanceInvoiceDTO.getProgramId());
+        if (StringUtils.isNotBlank(cwFinanceInvoiceDTO.getReconciliationPeopleName())) {
+            queryWrapper.eq("fi.reconciliation_people",cwFinanceInvoiceDTO.getReconciliationPeopleName());
+        }
+        if (StringUtils.isNotBlank(cwFinanceInvoiceDTO.getNo())) {
+            queryWrapper.like("fi.no",cwFinanceInvoiceDTO.getNo());
+        }
+        if (StringUtils.isNotBlank(cwFinanceInvoiceDTO.getNumber())) {
+            queryWrapper.like("fi.number",cwFinanceInvoiceDTO.getNumber());
+        }
+        // 开票日期
+        if (StringUtils.isNotBlank(cwFinanceInvoiceDTO.getBillingDateBegin()) || StringUtils.isNotBlank(cwFinanceInvoiceDTO.getBillingDateEnd())) {
+            queryWrapper.between("fi.billing_date", cwFinanceInvoiceDTO.getBillingDateBegin(), cwFinanceInvoiceDTO.getBillingDateEnd());
+        }
+
+        IPage<CwFinanceInvoiceDTO> list = null;
+        list = cwFinanceInvoiceMapper.listByProgramId(page, queryWrapper);
+        //根据项目id查询项目下的报告中是否有发票编号信息
+        ArrayList<String> strings = new ArrayList<>();
+        List<CwProjectReportData> reportData = cwProjectReportMapper.getByProjectId(cwFinanceInvoiceDTO.getProgramId());
+
+        if (CollectionUtils.isNotEmpty(reportData)){
+            for (CwProjectReportData reportDatum : reportData) {
+                if (StringUtils.isNotBlank(reportDatum.getInvoiceNumber())){
+                    strings.add(reportDatum.getInvoiceNumber());
+                }
+            }
+        }
+
+        // 创建一个Set来存储唯一的发票编号,用于检查重复
+        Set<String> uniqueInvoiceNumbers = new HashSet<>(strings);
+
+        // 创建一个新的列表来存放需要保留的CwFinanceInvoiceDTO对象
+        List<CwFinanceInvoiceDTO> filteredList = new ArrayList<>();
+
+        for (CwFinanceInvoiceDTO record : list.getRecords()) {
+            // 如果发票编号不在strings集合中,则添加到filteredList
+            if (!uniqueInvoiceNumbers.contains(record.getNumber())){
+                filteredList.add(record);
+            }
+        }
+
+        // 将filteredList设置回原来的list.getRecords()
+        list.setRecords(filteredList);
+        return list;
+    }
 }

+ 4 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/dto/CwFinanceInvoiceBaseDTO.java

@@ -55,6 +55,10 @@ public class CwFinanceInvoiceBaseDTO extends BaseDTO {
      * 报备类型
      */
     private String reportNo;
+    /**
+     * 是否预开票
+     */
+    private String isPreInvoice;
 
 
 

+ 13 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/dto/CwFinanceInvoiceDTO.java

@@ -354,6 +354,19 @@ public class CwFinanceInvoiceDTO extends BaseDTO {
      * 单选类型确认
      */
     private String checkType;
+    /**
+     * 是否预开票
+     */
+    @Excel(name = "是否预开票",width = 14, replace = {"是_1", "否_0"})
+    private String isPreInvoice;
+
+    private String createName;
+
+    /*8
+    预开票已关联
+     */
+    @Excel(name = "预开票已关联",width = 14, replace = {"是_2", "否_0"," _null"})
+    private String isCompleteInvoice;
 
 
 

+ 43 - 2
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/controller/CwProjectRecordsController.java

@@ -2,6 +2,7 @@ package com.jeeplus.finance.projectRecords.controller;
 
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.extra.spring.SpringUtil;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jeeplus.common.excel.ExcelOptions;
@@ -105,12 +106,12 @@ public class CwProjectRecordsController {
     }
 
     /**
-     * 查询财务项目信息列表(获取无报告的项目及老项目)
+     * 查询有是否预开票的项目
      * @param cwProjectRecordsDTO
      * @param page
      * @return
      */
-    @ApiLog("查询财务项目信息列表(获取无报告的项目及老项目)")
+    @ApiLog("查询有是否预开票的项目")
     // @PreAuthorize("hasAuthority('cwProjectRecords:list')")
     @GetMapping("noReportList")
     public ResponseEntity<IPage<CwProjectRecordsDTO>> noReportList(CwProjectRecordsDTO cwProjectRecordsDTO, Page<CwProjectRecordsDTO> page) throws Exception {
@@ -120,6 +121,21 @@ public class CwProjectRecordsController {
     }
 
     /**
+     * 查询预开票项目信息列表
+     * @param cwProjectRecordsDTO
+     * @param page
+     * @return
+     */
+    @ApiLog("查询预开票项目信息列表")
+    // @PreAuthorize("hasAuthority('cwProjectRecords:list')")
+    @GetMapping("preInvoiceList")
+    public ResponseEntity<IPage<CwProjectRecordsDTO>> preInvoiceList(CwProjectRecordsDTO cwProjectRecordsDTO, Page<CwProjectRecordsDTO> page) throws Exception {
+        IPage<CwProjectRecordsDTO> result = new Page<CwProjectRecordsDTO>();
+        result = cwProjectRecordsService.findPreInvoiceList (page,cwProjectRecordsDTO);
+        return ResponseEntity.ok (result);
+    }
+
+    /**
      * 查询财务项目信息列表
      * @param cwProjectRecordsDTO
      * @param page
@@ -311,6 +327,31 @@ public class CwProjectRecordsController {
         return ResponseEntity.ok(reportList);
     }
 
+    /**
+     * 查询项目下是否存在已开票信息
+     * @param id
+     * @return
+     */
+    @ApiLog("查询项目下是否存在已开票信息")
+//    @PreAuthorize ("hasAnyAuthority('cwProjectRecords:view','cwProjectRecords:add','cwProjectRecords:edit')")
+    @GetMapping("getInvoiceTotal")
+    public ResponseEntity getInvoiceTotal(@RequestParam("id") String id) {
+        CwProjectRecordsDTO cwProjectRecordsDTO = cwProjectRecordsService.getInvoiceTotal ( id );
+        return ResponseEntity.ok (cwProjectRecordsDTO);
+    }
+
+    /**
+     * 查询预开票项目下的报告是否关联完成
+     * @return
+     */
+    @ApiLog("查询预开票项目下的报告是否关联完成")
+//    @PreAuthorize ("hasAnyAuthority('cwProjectRecords:view','cwProjectRecords:add','cwProjectRecords:edit')")
+    @GetMapping("getCompleteCollection")
+    public String getCompleteCollection() {
+        List<CwProjectRecordsDTO> list=cwProjectRecordsService.getCompleteCollection ();
+        return JSON.toJSONString(list);
+    }
+
 
 
 

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

@@ -102,4 +102,9 @@ public interface CwProjectRecordsMapper extends BaseMapper<CwProjectRecords> {
 
     List<String> findAllList(@Param("id") String id);
 
+    IPage<CwProjectRecordsDTO> findPreInvoiceList(Page<CwProjectRecordsDTO> page,@Param(Constants.WRAPPER) QueryWrapper<CwProjectRecords> queryWrapper);
+
+    CwProjectRecordsDTO getInvoiceTotal(@Param("id") String id);
+
+    List<CwProjectRecordsDTO> getCompleteCollection();
 }

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

@@ -406,6 +406,30 @@
         ORDER BY a.create_time DESC
     </select>
 
+    <select id="findPreInvoiceList" 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'
+        ${ew.customSqlSegment}
+        ORDER BY a.create_time DESC
+    </select>
+
     <select id="getInfoById" resultType="com.jeeplus.finance.projectRecords.service.dto.CwProjectRecordsDTO">
         select
         DISTINCT
@@ -661,5 +685,38 @@
         select id from cw_project_records where create_by_id = #{id} and del_flag=0
     </select>
 
+    <select id="getInvoiceTotal" resultType="com.jeeplus.finance.projectRecords.service.dto.CwProjectRecordsDTO">
+        select
+        (select COUNT(*) from cw_finance_invoice fi LEFT JOIN cw_finance_invoice_base fib on fi.id = fib.invoice_id where fib.program_id = '1770254065710575618' and fib.del_flag = '0' and fi.del_flag = '0') as invoiceTotal,
+        <include refid="Base_Column_List"></include>
+        from
+            cw_project_records a
+        where del_flag = '0' and id = #{id}
+    </select>
+
+    <select id="getCompleteCollection" 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.is_pre_invoice = '1' and a.del_flag = '0'
+        ORDER BY a.create_time DESC
+    </select>
+
 
 </mapper>

+ 127 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/service/CwProjectRecordsService.java

@@ -31,6 +31,8 @@ import com.jeeplus.finance.projectRecords.service.dto.CwProjectRecordsDTO;
 import com.jeeplus.finance.projectRecords.service.mapstruct.CwProjectClientContactWrapper;
 import com.jeeplus.finance.projectRecords.service.mapstruct.CwProjectMembersWrapper;
 import com.jeeplus.finance.projectRecords.service.mapstruct.CwProjectRecordsWrapper;
+import com.jeeplus.finance.projectReport.domain.CwProjectReportData;
+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;
@@ -79,6 +81,8 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
     private CwWorkClientContactService cwWorkClientContactService;
     @Resource
     private CwProjectMembersService cwProjectMembersService;
+    @Resource
+    private CwProjectReportMapper cwProjectReportMapper;
 
 
     /**
@@ -361,7 +365,7 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
     }
 
     /**
-     * 查询无报告项目及老项目列表信息
+     * 查询报告号不为空的项目列表信息
      * @param page
      * @param cwProjectRecordsDTO
      * @return
@@ -413,6 +417,86 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
         return list;
     }
 
+    /**
+     * 查询是否有预开票的项目
+     * @param page
+     * @param cwProjectRecordsDTO
+     * @return
+     * @throws Exception
+     */
+    public IPage<CwProjectRecordsDTO> findPreInvoiceList(Page<CwProjectRecordsDTO> page, CwProjectRecordsDTO cwProjectRecordsDTO) throws Exception{
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+        QueryWrapper<CwProjectRecords> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( CwProjectRecordsWrapper.INSTANCE.toEntity(cwProjectRecordsDTO), CwProjectRecords.class );
+        queryWrapper.eq("a.del_flag","0");
+        queryWrapper.eq("a.create_by_id",userDTO.getId());
+        queryWrapper.eq("a.is_pre_invoice","1");
+        if (ObjectUtil.isNotEmpty(cwProjectRecordsDTO)) {
+            if (ArrayUtil.isNotEmpty(cwProjectRecordsDTO.getCreateDates())) {
+                queryWrapper.between("a.create_time", cwProjectRecordsDTO.getCreateDates()[0], cwProjectRecordsDTO.getCreateDates()[1]);
+            }
+            if (StringUtils.isNotBlank(cwProjectRecordsDTO.getProjectMasterName())) {
+                queryWrapper.in("a.project_master_id", cwProjectRecordsDTO.getProjectMasterName());
+            }
+            if (StringUtils.isNotBlank(cwProjectRecordsDTO.getBusinessType())){
+                queryWrapper.eq("a.business_type",cwProjectRecordsDTO.getBusinessType());
+            }
+            if (StringUtils.isNotBlank(cwProjectRecordsDTO.getProjectMasterName2())) {
+                List<User> userList = SpringUtil.getBean ( IUserApi.class ).selectListByName(cwProjectRecordsDTO.getProjectMasterName2());
+                if (CollectionUtils.isNotEmpty(userList)){
+                    List<String> ids = userList.stream().distinct().map(User::getId).collect(Collectors.toList());
+                    if (CollectionUtil.isNotEmpty(ids)) {
+                        queryWrapper.in("a.project_master_id", ids);
+                    } else {
+                        return new Page<>();
+                    }
+                } else {
+                    queryWrapper.in("a.project_master_id", cwProjectRecordsDTO.getProjectMasterName());
+                }
+            }
+            if (StringUtils.isNotBlank(cwProjectRecordsDTO.getRealHeaderName())) {
+                queryWrapper.in("a.real_header", cwProjectRecordsDTO.getRealHeaderName());
+            }
+            if (StringUtils.isNotBlank(cwProjectRecordsDTO.getCreateId())){
+                queryWrapper.eq("a.create_by_id", cwProjectRecordsDTO.getCreateId());
+            }
+            // 创建人
+            if (ObjectUtil.isNotEmpty(cwProjectRecordsDTO.getCreateBy())){
+                if (StringUtils.isNotBlank(cwProjectRecordsDTO.getCreateBy().getName())){
+                    queryWrapper.in("a.create_by_id",cwProjectRecordsDTO.getCreateBy().getName());
+                }
+            }
+        }
+
+        IPage<CwProjectRecordsDTO> list = cwProjectRecordsMapper.findPreInvoiceList(page, queryWrapper);
+        List<CwProjectRecordsDTO> recordsToKeep = new ArrayList<>();
+        Set<String> projectIdsWithPendingReports = new HashSet<>();
+        //查询出未关联完成的项目,完成替换
+        for (CwProjectRecordsDTO record : list.getRecords()) {
+            List<CwProjectReportData> reportData = cwProjectReportMapper.getByProjectId(record.getId());
+            if (CollectionUtils.isNotEmpty(reportData)) {
+                for (CwProjectReportData reportDatum : reportData) {
+                    if (!"5".equals(reportDatum.getStatus())) {
+                        // 如果找到一个状态不是 "5" 的报告,则将该记录的ID添加到集合中
+                        projectIdsWithPendingReports.add(record.getId());
+                        break; // 不需要继续检查其他报告
+                    }
+                }
+            }else {
+                projectIdsWithPendingReports.add(record.getId());
+            }
+        }
+
+        // 根据集合中的ID来过滤出需要保留的records
+        for (CwProjectRecordsDTO record : list.getRecords()) {
+            if (projectIdsWithPendingReports.contains(record.getId())) {
+                recordsToKeep.add(record);
+            }
+        }
+        // 替换原列表的内容
+        list.setRecords(recordsToKeep);
+        return list;
+    }
+
 
 
     /**
@@ -941,4 +1025,46 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
     public List<String> findAllList(String id) {
         return cwProjectRecordsMapper.findAllList(id);
     }
+
+    /**
+     * 查询项目下是否存在已开票信息
+     * @param id
+     * @return
+     */
+    public CwProjectRecordsDTO getInvoiceTotal(String id) {
+        CwProjectRecordsDTO cwProjectRecordsDTO = cwProjectRecordsMapper.getInvoiceTotal(id);
+        return cwProjectRecordsDTO;
+    }
+
+    /**
+     * 查询预开票项目下的报告是否已关联完成
+     * @return
+     */
+    public List<CwProjectRecordsDTO> getCompleteCollection() {
+        List<CwProjectRecordsDTO> list=cwProjectRecordsMapper.getCompleteCollection();
+        List<CwProjectRecordsDTO> recordsToKeep = new ArrayList<>();
+        Set<String> projectIdsWithPendingReports = new HashSet<>();
+
+        for (CwProjectRecordsDTO record : list) {
+            List<CwProjectReportData> reportData = cwProjectReportMapper.getByProjectId(record.getId());
+            if (CollectionUtils.isNotEmpty(reportData)) {
+                for (CwProjectReportData reportDatum : reportData) {
+                    if (!"5".equals(reportDatum.getStatus())) {
+                        // 如果找到一个状态不是 "5" 的报告,则将该记录的ID添加到集合中
+                        projectIdsWithPendingReports.add(record.getId());
+                        break; // 不需要继续检查其他报告
+                    }
+                }
+            }else {
+                projectIdsWithPendingReports.add(record.getId());
+            }
+        }
+        // 根据集合中的ID来过滤出需要保留的records
+        for (CwProjectRecordsDTO record : list) {
+            if (projectIdsWithPendingReports.contains(record.getId())) {
+                recordsToKeep.add(record);
+            }
+        }
+        return recordsToKeep;
+    }
 }

+ 7 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/service/dto/CwProjectRecordsDTO.java

@@ -264,6 +264,13 @@ public class CwProjectRecordsDTO extends BaseDTO {
      */
     private String isPreInvoice;
 
+    /**
+     * 项目下的开票信息数量
+     */
+    private Integer invoiceTotal;
+
+    private String createById;
+
 
 
 }

+ 10 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/domain/CwProjectReport.java

@@ -279,4 +279,14 @@ public class CwProjectReport extends BaseEntity {
     @TableField(exist = false)
     private String sigReason;
 
+    /**
+     * 发票编号
+     */
+    private String invoiceNumber;
+
+    /**
+     * 是否完成已开票(0:否,1:是,2:选择为1时审核通过后变为最终的结果)
+     */
+    private String isCompleteInvoice;
+
 }

+ 10 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/domain/CwProjectReportData.java

@@ -594,4 +594,14 @@ public class CwProjectReportData extends BaseDTO {
     //撤回签章id
     @TableField(exist = false)
     private String revocationId;
+
+    /**
+     * 发票编号
+     */
+    private String invoiceNumber;
+
+    /**
+     * 是否完成已开票(0:否,1:是,2:选择为1时审核通过后变为最终的结果)
+     */
+    private String isCompleteInvoice;
 }

+ 2 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/CwProjectReportMapper.java

@@ -246,4 +246,6 @@ public interface CwProjectReportMapper extends BaseMapper<CwProjectReport> {
     List<CwProjectReport> getReportInfoByNoList(@Param("reportNoList") List<String> reportNoList);
 
     void updatesigStatusById(CwProjectReport report);
+
+    void updateCompleteInvoice(@Param("id") String id);
 }

+ 16 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/xml/CwProjectReportMapper.xml

@@ -278,6 +278,8 @@
         a.register_address,
         a.business_location,
         a.security_business,
+        a.invoice_number,
+        a.is_complete_invoice,
         cw_prs1.proc_ins_id as proc_ins_id1,
         cw_prs1.process_definition_id as process_definition_id1,
         cw_prs1.status as status1,
@@ -607,6 +609,7 @@
         d.name as userName,
         a.create_time,
         a.audit_fees,
+        a.invoice_number,
         e.name as projectMasterName,
         cw_prs1.proc_ins_id as proc_ins_id1,
         cw_prs1.process_definition_id as process_definition_id1,
@@ -615,7 +618,8 @@
         cw_prs2.proc_ins_id as proc_ins_id2,
         cw_prs2.process_definition_id as process_definition_id2,
         cw_prs2.status as status2,
-        cw_prs2.id as sid2
+        cw_prs2.id as sid2,
+        new_line.report_no
         FROM cw_project_report a
         left join cw_project_records b on a.project_id = b.id
         LEFT JOIN sys_office c on a.office_id = c.id
@@ -623,6 +627,7 @@
         LEFT JOIN sys_user e on b.project_master_id = e.id
         LEFT JOIN cw_project_report_signature cw_prs1 on cw_prs1.report_id = a.id and cw_prs1.type = '1' and cw_prs1.del_flag = '0'
         LEFT JOIN cw_project_report_signature cw_prs2 on cw_prs2.report_id = a.id and cw_prs2.type = '2' and cw_prs2.del_flag = '0'
+        left join cw_project_report_new_line new_line on a.id = new_line.report_id and new_line.del_flag = '0'
         where a.project_id = #{projectId} and a.del_flag = '0'
     </select>
     <select id="getContainDelByProjectId" resultType="com.jeeplus.finance.projectReport.domain.CwProjectReportData">
@@ -968,6 +973,12 @@
         <if test="tenantId != null and tenantId != ''">
             tenant_id = #{tenantId},
         </if>
+        <if test="invoiceNumber != null and invoiceNumber != ''">
+            invoice_number = #{invoiceNumber},
+        </if>
+        <if test="isCompleteInvoice != null and isCompleteInvoice != ''">
+            is_complete_invoice = #{isCompleteInvoice},
+        </if>
         update_by_id = #{updateById},
         update_time = #{updateTime}
         where del_flag = 0 and id = #{id}
@@ -1152,6 +1163,10 @@
         update cw_project_report set signature_annotator1=#{signatureAnnotator1},signature_annotator2=#{signatureAnnotator2},signature_annotator_status=#{signatureAnnotatorStatus} where id=#{id}
     </update>
 
+    <update id="updateCompleteInvoice">
+        update cw_project_report set is_complete_invoice = '2' where id = #{id}
+    </update>
+
 
 
 </mapper>

+ 8 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/service/CwProjectReportService.java

@@ -237,6 +237,14 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
         report.setUpdateById(userDTO.getId());
         report.setUpdateTime(new Date());
         reportMapper.updateCwProjectReportDataById(report);
+        //当审核通过时,且该报告已完成关联,则将关联状态改为2
+        CwProjectReportData cwProjectReportData = reportMapper.queryById(reportData.getId());
+        if (StringUtils.isNotBlank(cwProjectReportData.getIsCompleteInvoice())){
+            if ("5".equals(cwProjectReportData.getStatus()) && "1".equals(cwProjectReportData.getIsCompleteInvoice())){
+                reportMapper.updateCompleteInvoice(reportData.getId());
+            }
+        }
+
         //修改新增行数据
         CwProjectInfoData infoData = infoMapper.selectInfoByReportId(report.getId());
         infoData.setServedUnitName(report.getServedUnitName());

+ 246 - 0
jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/jeeplus/domain/CwProjectRecordsList.java

@@ -0,0 +1,246 @@
+package com.jeeplus.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jeeplus.core.service.dto.BaseDTO;
+
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+import java.util.List;
+
+
+@Data
+public class CwProjectRecordsList  {
+
+    /**
+     * 项目id
+     */
+    private String id;
+
+    /**
+     * 创建人id
+     */
+    private String createById;
+
+    /**
+     * 备注信息
+     */
+    private String remarks;
+
+    /**
+     * 项目编号
+     */
+    private String projectNumber;
+
+    /**
+     * 项目名称
+     */
+    private String projectName;
+
+    /**
+     * 项目所属部门
+     */
+    private String officeId;
+
+    /**
+     * 项目金额
+     */
+    private String projectMoney;
+
+    /**
+     * 审计期间
+     */
+    private String auditYear;
+
+    /**
+     * 项目计划开始时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date planStartDate;
+
+    /**
+     * 项目计划结束时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date planEndDate;
+
+    /**
+     * 项目经理
+     */
+    private String projectMasterId;
+
+    /**
+     * 现场负责人
+     */
+    private String projectLeaderId;
+
+    /**
+     * 流程id
+     */
+    private String procInsId;
+
+    /**
+     *
+     */
+    private String processDefinitionId;
+
+    /**
+     * 状态
+     */
+    private String status;
+
+
+
+
+
+
+    /**
+     * 项目经理姓名
+     */
+    private String projectMasterName;
+
+    private String projectMasterName2;
+    /**
+     * 时间查询
+     */
+    private String[] createDates;
+
+    /**
+     * 合同id
+     */
+    private String contractId;
+
+    /**
+     * 付款方式
+     */
+    private String paymentMethod;
+
+    /**
+     * 付款主体
+     */
+    private String payerSubject;
+
+    /**
+     * 合同份数
+     */
+    private String contractNum;
+
+    /**
+     * 合同金额(元)
+     */
+    private String contractAmount;
+
+    /**
+     * 合同名称
+     */
+    private String contractName;
+
+    /**
+     * 创建人id
+     */
+    private String createId;
+
+    /**
+     * 创建人姓名
+     */
+    private String createName;
+
+    /**
+     * 创建时间
+     */
+    private String createDateT;
+
+    /**
+     * 业务类型
+     */
+    private String businessType;
+
+    /**
+     * 风险等级
+     */
+    private String riskLevel;
+
+    /**
+     * 业务类型名称
+     */
+    private String businessTypeName;
+
+    /**
+     * 项目预计时间
+     */
+    private Date[] planDate;
+
+    /**
+     * 项目实际责任人
+     */
+    private String realHeader;
+
+    /**
+     * 项目实际责任人
+     */
+    private String realHeaderName;
+
+    /**
+     * 合同委托人
+     */
+    private String clientContactsName;
+
+    /**
+     * 报备类型
+     */
+    private String reportType;
+
+    /**
+     * 项目分类(专项审计业务)
+     */
+    private String projectClassification;
+
+
+
+    /**
+     * 项目组成员数量
+     */
+    private String memberCount;
+
+    /**
+     * 报告复核 1:已开始复核/已完成复核
+     */
+    private String reportReview;
+
+    /**
+     * 查找该报告及报告对应项目下的开票列表
+     */
+    private String reportNo;
+    private String no;
+    private String number;
+    private String account;
+    private String billingPeople;
+    private String billingDate;
+
+    /**
+     * 该项目下审计收费不为0的报告信息
+     */
+    private String auditFees;
+    private String loginName;
+    private String reportId;
+
+    /**
+     * 是否有报告(0:无,1:有)
+     */
+    private String isHaveReport;
+    /**
+     * 是否预开票(0:否,1:是)
+     */
+    private String isPreInvoice;
+
+    /**
+     * 项目下的开票信息数量
+     */
+    private Integer invoiceTotal;
+
+
+
+}

+ 78 - 0
jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java

@@ -233,6 +233,84 @@ public class SampleXxlJob {
         }
     }
 
+
+    /**
+     * 预开票项目未完成关联发送通知
+     */
+    @XxlJob("noCompleteCollection")
+    public void noCompleteCollection() throws Exception {
+        //
+        String json = SpringUtil.getBean ( FinanceFeignApi.class ).getCompleteCollection();
+        List<CwProjectRecordsList> infos = JSON.parseObject(json, new TypeReference<List<CwProjectRecordsList>>() {});
+
+        for (CwProjectRecordsList info : infos) {
+            //对数据进行发送通知
+            String taskName = null;
+            String titleStr = null;
+
+            taskName = "预开票项目未关联";
+            titleStr = "预开票项目-"+ info.getProjectName()+"还未完成关联";
+
+            Set<String> noticeUserSet = new HashSet<String>();
+
+            //根据岗位获取人员信息
+            String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(info.getCreateById());
+            UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
+
+            if(null != createUser && StringUtils.isNotBlank(createUser.getId())){
+                noticeUserSet.add(createUser.getId());
+            }
+            List<String> noticeUserList = new ArrayList<String>(noticeUserSet);
+            if(noticeUserList.size()>0){
+                MyNoticeList myNotice = new MyNoticeList();
+                myNotice.setCreateById("1");
+                myNotice.setCreateTime(new Date());
+                myNotice.setUpdateById("1");
+                myNotice.setUpdateTime(new Date());
+                myNotice.setDelFlag(0);
+                //根据procInsId获取taskId
+//                String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(info.getProcInsId());
+                myNotice.setTaskId("");
+                myNotice.setDefId(info.getId());
+                myNotice.setTitle(titleStr);
+                myNotice.setTaskName(taskName);
+                myNotice.setLink("结束");
+                myNotice.setType("0");
+                myNotice.setCreateUser("管理员");
+                myNotice.setCreateTime(new Date());
+
+                for (String noticeUserId : noticeUserList) {
+                    myNotice.setNoticeId(noticeUserId);
+                    myNotice.setNoticeName(createUser.getName());
+                    //根据taskName和通知人 查询重复数量
+                    String myNoticeInfo = JSON.toJSONString(myNotice);
+                    Map<String,String> map = new HashMap();
+                    map.put("myNoticeInfo", myNoticeInfo);
+                    String jsonInfo = SpringUtil.getBean(IFlowableApi.class).getRepetitionCountBymyNoticeTitle(map);
+                    MyNoticeList repetitionCountBymyNotice = JSON.parseObject(jsonInfo, new TypeReference<MyNoticeList>() {});
+
+                    if(null == repetitionCountBymyNotice){
+                        // 生成id
+                        String id = UUID.randomUUID().toString().replace("-", "");
+                        myNotice.setId(id);
+                        myNotice.setRepetitionCount(0);
+
+                        myNoticeInfo = JSON.toJSONString(myNotice);
+                        map.put("myNoticeInfo", myNoticeInfo);
+                        SpringUtil.getBean ( IFlowableApi.class ).insertMyNotice(map);
+                    }else{
+                        myNotice.setId(repetitionCountBymyNotice.getId());
+                        myNotice.setRepetitionCount(repetitionCountBymyNotice.getRepetitionCount()+1);
+
+                        myNoticeInfo = JSON.toJSONString(myNotice);
+                        map.put("myNoticeInfo", myNoticeInfo);
+                        SpringUtil.getBean ( IFlowableApi.class ).updateMyNotice(map);
+                    }
+                }
+            }
+        }
+    }
+
     /**
      * 1、评估项目超期定时任务
      */