sangwenwei 1 سال پیش
والد
کامیت
5d19eaa216

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

@@ -419,6 +419,16 @@ public class CwFinanceInvoiceController {
     }
 
 
+    /**
+     * 根据发票编号查询是否与预开票项目下的报告完成关联
+     */
+    @ApiLog("根据发票编号查询是否与预开票项目下的报告完成关联")
+    @GetMapping("getByNo")
+    public Boolean getByNo(String no){
+        boolean data = cwFinanceInvoiceService.getByNo(no);
+        return data;
+    }
+
 
 
 

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

@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jeeplus.finance.invoice.domain.CwFinanceInvoice;
+import com.jeeplus.finance.invoice.domain.CwFinanceInvoiceBase;
+import com.jeeplus.finance.invoice.service.dto.CwFinanceInvoiceBaseDTO;
 import com.jeeplus.finance.invoice.service.dto.CwFinanceInvoiceDTO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -51,6 +53,10 @@ public interface CwFinanceInvoiceMapper extends BaseMapper<CwFinanceInvoice> {
     void updateInfoById(CwFinanceInvoice cwFinanceInvoice);
 
     IPage<CwFinanceInvoiceDTO> listByProgramId(Page<CwFinanceInvoiceDTO> page,@Param(Constants.WRAPPER) QueryWrapper<CwFinanceInvoiceDTO> queryWrapper);
+
+    CwFinanceInvoiceBase getByNo(String invoiceNumber);
+
+    Integer getCountByNo(@Param("no") String no);
 }
 
 

+ 36 - 7
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/mapper/xml/CwFinanceInvoiceMapper.xml

@@ -283,6 +283,7 @@
                  when a.type = '0' then (concat('其他:',a.program_name))
                  when a.type = '1' then (select rpr.project_name from cw_project_records rpr where id = a.program_id)
                  when a.type = '2' then (select rpr.project_name from cw_project_records rpr where id = (select project_id from cw_project_report where id = a.program_id))
+                 when a.type = '4' then (select rpr.project_name from cw_project_records rpr where id = a.program_id)
             else '' end
         ) as programName,
 
@@ -290,6 +291,7 @@
         case
                  when a.type = '0' then (fi.report_type)
                  when a.type = '1' then (select rpr.report_type from cw_project_records rpr where id = a.program_id)
+                 when a.type = '4' then (select rpr.report_type from cw_project_records rpr where id = a.program_id)
                  when a.type = '2' then (select rpr.report_type from cw_project_records rpr where id = (select project_id from cw_project_report where id = a.program_id))
             else '' end
         ) as reportType,
@@ -297,6 +299,7 @@
         case
             when a.type = '0' then ("")
             when a.type = '1' then (select rpr.project_classification from cw_project_records rpr where id = a.program_id)
+            when a.type = '4' then (select rpr.project_classification from cw_project_records rpr where id = a.program_id)
             when a.type = '2' then (select rpr.project_classification from cw_project_records rpr where id = (select project_id from cw_project_report where id = a.program_id))
             else '' end
         ) as projectClassification,
@@ -309,7 +312,11 @@
         WHEN a.type = '2' THEN (
         select cprnlz.report_no from cw_project_report cprz
         left join cw_project_report_new_line cprnlz on cprz.id = cprnlz.report_id
-        where cprz.id = a.program_id) ELSE ''
+        where cprz.id = a.program_id)
+        WHEN a.type = '4' THEN ( select GROUP_CONCAT(cprnlz.report_no) from cw_project_report cprz
+        left join cw_project_report_new_line cprnlz on cprz.id = cprnlz.report_id
+        left join cw_project_records cprsz on cprz.project_id= cprsz.id
+        where cprsz.id = a.program_id )ELSE ''
         END
         ) AS reportNos,
         cfid.number as "number",
@@ -343,6 +350,7 @@
                  when a.type = '0' then (concat('其他:',a.program_name))
                  when a.type = '1' then (select rpr.project_name from cw_project_records rpr where id = a.program_id)
                  when a.type = '2' then (select rpr.project_name from cw_project_records rpr where id = (select project_id from cw_project_report where id = a.program_id))
+                 when a.type = '4' then (select rpr.project_name from cw_project_records rpr where id = a.program_id)
             else '' end
         ) as programName,
 
@@ -351,13 +359,15 @@
                  when a.type = '0' then (fi.report_type)
                  when a.type = '1' then (select rpr.report_type from cw_project_records rpr where id = a.program_id)
                  when a.type = '2' then (select rpr.report_type from cw_project_records rpr where id = (select project_id from cw_project_report where id = a.program_id))
-            else '' end
+                 when a.type = '4' then (select rpr.report_type from cw_project_records rpr where id = a.program_id)
+    else '' end
         ) as reportType,
     (
     case
     when a.type = '0' then ("")
     when a.type = '1' then (select rpr.project_classification from cw_project_records rpr where id = a.program_id)
     when a.type = '2' then (select rpr.project_classification from cw_project_records rpr where id = (select project_id from cw_project_report where id = a.program_id))
+    when a.type = '4' then (select rpr.project_classification from cw_project_records rpr where id = a.program_id)
     else '' end
     ) as projectClassification,
     (
@@ -369,7 +379,9 @@
     WHEN a.type = '2' THEN (
     select cprnlz.report_no from cw_project_report cprz
     left join cw_project_report_new_line cprnlz on cprz.id = cprnlz.report_id
-    where cprz.id = a.program_id) ELSE ''
+    where cprz.id = a.program_id)
+    WHEN a.type = '4' THEN ("")
+     ELSE ''
     END
     ) AS reportNos,
         cfid.number as "number",
@@ -377,10 +389,9 @@
         a.program_id,
         a.type as 'recordType',
         (case when a.type = '1' then (select 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 SUBSTR(GROUP_CONCAT( pr.is_complete_invoice),1,1 ) from cw_project_report pr where pr.project_id = a.program_id)
-        else '' end) as isCompleteInvoice
+        when a.type = '2' then (select rpr.is_pre_invoice from cw_project_records rpr where id = (select project_id from cw_project_report where id = a.program_id))
+        when a.type = '4' then (select pr.is_pre_invoice from cw_project_records pr where pr.id = a.program_id)
+        else '' end ) as isPreInvoice
         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'
@@ -566,4 +577,22 @@
         left join sys_user su on fi.create_by_id = su.id
         ${ew.customSqlSegment}
     </select>
+
+    <select id="getByNo" resultType="com.jeeplus.finance.invoice.domain.CwFinanceInvoiceBase">
+        select
+        DISTINCT
+        <include refid="FIB_Column_List"></include>
+        from cw_finance_invoice fi
+        left join cw_finance_invoice_base fib on fib.invoice_id = fi.id
+        where fi.no = #{invoiceNumber}
+    </select>
+
+    <select id="getCountByNo" resultType="integer">
+        SELECT COUNT(*)
+        FROM cw_finance_invoice fi
+        LEFT JOIN cw_project_report pr ON pr.invoice_number = fi.no AND pr.del_flag = '0'
+        LEFT JOIN cw_project_records cpr ON cpr.id = pr.project_id AND cpr.del_flag = '0'
+        WHERE fi.no = #{no} AND cpr.is_pre_invoice = '1';
+    </select>
+
 </mapper>

+ 30 - 2
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/CwFinanceInvoiceService.java

@@ -330,7 +330,14 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
         IPage<CwFinanceInvoiceDTO> list = null;
         if(StringUtils.isNotBlank(export) && "export".equals(export)){
             list = cwFinanceInvoiceMapper.findExportList(page, queryWrapper);
-
+            list.getRecords().forEach(item->{
+                //预开票且报告与发票关联完成的则已完成关联
+                if(StringUtils.isNotBlank(item.getIsPreInvoice()) && StringUtils.isNotBlank(item.getReportNos()) && StringUtils.isNotBlank(item.getNo())){
+                    if ("1".equals(item.getIsPreInvoice())){
+                        item.setIsCompleteInvoice("2");
+                    }
+                }
+            });
         }else{
             list = cwFinanceInvoiceMapper.findList(page, queryWrapper);
         }
@@ -465,7 +472,9 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
                         cwFinanceInvoiceBaseMapper.insert(cwFinanceInvoiceBase);
                     }
                     if (StringUtils.isNotEmpty(cwFinanceInvoiceBase.getProgramId())){
-                        if (null!=cwProjectRecordsMapper.queryById(cwFinanceInvoiceBase.getProgramId())){
+                        CwProjectRecordsDTO projectRecordsDTO = cwProjectRecordsMapper.queryById(cwFinanceInvoiceBase.getProgramId());
+                        //普通项目
+                        if (null!=projectRecordsDTO){
                             cwFinanceInvoiceBase.setType("1");
                             cwFinanceInvoiceBaseMapper.updateById(cwFinanceInvoiceBase);
                             cwFinanceInvoice.setRecordType(cwFinanceInvoiceBase.getType());
@@ -475,6 +484,12 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
                             cwFinanceInvoiceBaseMapper.updateById(cwFinanceInvoiceBase);
                             cwFinanceInvoice.setRecordType(cwFinanceInvoiceBase.getType());
                         }
+                        //预开票项目
+                        if (null != projectRecordsDTO && "1".equals(projectRecordsDTO.getIsPreInvoice())){
+                            cwFinanceInvoiceBase.setType("4");
+                            cwFinanceInvoiceBaseMapper.updateById(cwFinanceInvoiceBase);
+                            cwFinanceInvoice.setRecordType(cwFinanceInvoiceBase.getType());
+                        }
                     }else {
                         cwFinanceInvoiceBase.setType("0");
                         cwFinanceInvoiceBaseMapper.updateById(cwFinanceInvoiceBase);
@@ -876,4 +891,17 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
         list.setTotal(filteredList.size());
         return list;
     }
+
+    /**
+     * 根据发票编号查询是否与预开票项目下的报告完成关联
+     * @param no
+     * @return
+     */
+    public boolean getByNo(String no) {
+        Integer data = cwFinanceInvoiceMapper.getCountByNo(no);
+        if (data != 0){
+            return true;
+        }
+        return false;
+    }
 }

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

@@ -47,7 +47,7 @@ public class CwFinanceInvoiceBaseDTO extends BaseDTO {
 
     private String reportType;
     /**
-     * 类型 项目1,报告2,其他0
+     * 类型 项目1,报告2,其他0, 预开票4
      */
     private String type;
 

+ 26 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/service/CwProjectReportNumberApplyService.java

@@ -5,6 +5,11 @@ import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jeeplus.common.TokenProvider;
+import com.jeeplus.finance.invoice.domain.CwFinanceInvoiceBase;
+import com.jeeplus.finance.invoice.mapper.CwFinanceInvoiceBaseMapper;
+import com.jeeplus.finance.invoice.mapper.CwFinanceInvoiceMapper;
+import com.jeeplus.finance.invoice.service.dto.CwFinanceInvoiceBaseDTO;
+import com.jeeplus.finance.invoice.service.dto.CwFinanceInvoiceDTO;
 import com.jeeplus.finance.projectRecords.domain.CwProjectRecords;
 import com.jeeplus.finance.projectReport.domain.*;
 import com.jeeplus.finance.projectReport.mapper.CwProjectInfoMapper;
@@ -47,6 +52,12 @@ public class CwProjectReportNumberApplyService extends ServiceImpl<CwProjectRepo
     @Resource
     private CwProjectReportService cwProjectReportService;
 
+    @Resource
+    private CwFinanceInvoiceMapper cwFinanceInvoiceMapper;
+
+    @Resource
+    private CwFinanceInvoiceBaseMapper cwFinanceInvoiceBaseMapper;
+
     public CwProjectReportData queryByReportId(String id) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
         CwProjectReportData data = mapper.selectByPortId(id);
         //查询复核相关信息
@@ -233,6 +244,21 @@ public class CwProjectReportNumberApplyService extends ServiceImpl<CwProjectRepo
                     cwProjectReportService.updateCwProjectReportDataById(report);
                 }
             }
+            //当开票编号不为空的时候则将发票表中的programId改为报告id  type改为报告值->2
+            if (StringUtils.isNotBlank(reportData.getInvoiceNumber())){
+                //根据开票编号查询开票信息
+                CwFinanceInvoiceBase cwFinanceInvoiceBase=cwFinanceInvoiceMapper.getByNo(reportData.getInvoiceNumber());
+                if (ObjectUtil.isNotEmpty(cwFinanceInvoiceBase)){
+                    CwFinanceInvoiceBase invoiceBase = new CwFinanceInvoiceBase();
+                    invoiceBase.setId(cwFinanceInvoiceBase.getId());
+                    invoiceBase.setProgramId(reportData.getId());
+                    invoiceBase.setProgramName(reportData.getReportName());
+                    invoiceBase.setType("2");
+                    cwFinanceInvoiceBaseMapper.updateById(invoiceBase);
+                }
+            }
+
+
         }
         mapper.updateReviewById(review);
         //对复核数据进行持久化操作