jzh пре 1 година
родитељ
комит
7165c5885d

+ 33 - 0
client_h5/src/pages/contract-invoice/index.scss

@@ -0,0 +1,33 @@
+.van-cell-group {
+  margin: 0px;
+}
+.van-overlay {
+  background: rgba(0,0,0,0.3);
+}
+.add_btn {
+  background-color: #1989fa;
+  padding: 5px 10px;
+  border: 0px;
+  outline: none;
+  font-size: 13px;
+  color: #fff;
+  border-radius: 2px;
+}
+.detail-popup {
+  >.title {
+    font-size: 15px;
+    padding-left: 10px;
+  }
+  >.fixed-btn {
+    padding: 15px;
+  }
+}
+  :deep(.van-swipe-cell__right) {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+    >button {
+      height: 50%;
+    }
+  }

+ 502 - 0
client_h5/src/pages/contract-invoice/index.vue

@@ -0,0 +1,502 @@
+<template>
+  <flow-form :data="formData" @submit="submitNextActivity">
+    <card title="合同信息" style="height: auto">
+      <van-form required="true" ref="form">
+        <van-cell-group inset>
+          <van-field
+              v-model="formData.contract.name"
+              name="合同名称"
+              label="合同名称"
+              placeholder="合同名称"
+              readonly
+              :rules="[{ required: true, message: '未获取合同名称' }]"
+          />
+          <van-field
+              v-model="formData.contract.contractNumber"
+              name="合同编号"
+              label="合同编号"
+              placeholder="合同编号"
+              readonly
+              :rules="[{ required: true, message: '未获取合同编号' }]"
+          />
+          <van-field
+              v-model="formData.contract.mainTypeText"
+              name="合同主类型"
+              label="合同主类型"
+              placeholder="合同主类型"
+              readonly
+              :rules="[{ required: true, message: '未获取合同主类型' }]"
+          />
+          <van-field
+              v-model="formData.contract.secondTypeText"
+              name="合同次类型"
+              label="合同次类型"
+              placeholder="合同次类型"
+              readonly
+              :rules="[{ required: true, message: '未获取合同次类型' }]"
+          />
+          <van-field
+              v-model="formData.contractMilestoneName"
+              name="关联合同里程碑"
+              label="关联合同里程碑"
+              placeholder="关联合同里程碑"
+              readonly
+              :rules="[{ required: true, message: '未获取关联合同里程碑' }]"
+          />
+        </van-cell-group>
+      </van-form>
+    </card>
+    <card title="项目信息" style="height: auto">
+      <van-form required="true" ref="form">
+        <van-cell-group inset>
+          <van-field
+              v-model="formData.project.xmmc"
+              name="项目名称"
+              label="项目名称"
+              placeholder="项目名称"
+              readonly
+              :rules="[{ required: true, message: '未获取项目名称' }]"
+          />
+          <van-field
+              v-model="formData.project.xmbh"
+              name="项目编号"
+              label="项目编号"
+              placeholder="项目编号"
+              readonly
+              :rules="[{ required: true, message: '未获取项目编号' }]"
+          />
+          <van-field
+              v-model="formData.project.projectTypeName"
+              name="项目类型"
+              label="项目类型"
+              placeholder="项目类型"
+              readonly
+              :rules="[{ required: true, message: '未获取项目类型' }]"
+          />
+          <van-field
+              v-model="formData.project.zrbm"
+              name="项目责任部门"
+              label="项目责任部门"
+              placeholder="项目责任部门"
+              readonly
+              :rules="[{ required: true, message: '未获取项目责任部门' }]"
+          />
+          <van-field
+              v-model="formData.project.xsry"
+              name="销售经理"
+              label="销售经理"
+              placeholder="销售经理"
+              readonly
+              :rules="[{ required: true, message: '未获取销售经理' }]"
+          />
+          <van-field
+              v-model="formData.project.zrbm"
+              name="责任部门"
+              label="责任部门"
+              placeholder="责任部门"
+              readonly
+              :rules="[{ required: true, message: '未获取责任部门' }]"
+          />
+
+        </van-cell-group>
+      </van-form>
+    </card>
+    <card title="基本信息" style="height: auto">
+      <van-form required="true" ref="form">
+        <van-cell-group inset>
+          <van-field
+              v-model="formData.applyWorkerName"
+              name="开票申请人"
+              label="开票申请人"
+              placeholder="开票申请人"
+              readonly
+              :rules="[{ required: true, message: '未获取开票申请人' }]"
+          />
+          <van-field
+              v-model="formData.applyWorkerDept"
+              name="所在部门"
+              label="所在部门"
+              placeholder="所在部门"
+              readonly
+              :rules="[{ required: true, message: '未获取所在部门' }]"
+          />
+          <van-field
+              v-model="formData.applyDate"
+              name="申请时间"
+              label="申请时间"
+              placeholder="申请时间"
+              readonly
+              :rules="[{ required: true, message: '未获取申请时间' }]"
+          />
+          <van-field
+              v-model="formData.invoiceNumber"
+              name="开票单号"
+              label="开票单号"
+              placeholder="开票单号"
+              readonly
+              :rules="[{ required: true, message: '未获取开票单号' }]"
+          />
+          <van-field
+              v-model="formData.customerName"
+              name="客户名称"
+              label="客户名称"
+              placeholder="客户名称"
+              readonly
+              :rules="[{ required: true, message: '未获取客户名称' }]"
+          />
+          <van-field
+              v-model="formData.taxNumber"
+              name="税号"
+              label="税号"
+              placeholder="税号"
+              readonly
+              :rules="[{ required: true, message: '未获取税号' }]"
+          />
+          <van-field
+              v-model="formData.bank"
+              name="开户行"
+              label="开户行"
+              placeholder="开户行"
+              readonly
+              :rules="[{ required: true, message: '未获取开户行' }]"
+          />
+          <van-field
+              v-model="formData.bankAccount"
+              name="账号"
+              label="账号"
+              placeholder="账号"
+              readonly
+              :rules="[{ required: true, message: '未获取账号' }]"
+          />
+          <van-field
+              v-model="formData.invoiceCompany"
+              name="开票单位"
+              label="开票单位"
+              placeholder="开票单位"
+              readonly
+              :rules="[{ required: true, message: '未获取开票单位' }]"
+          />
+          <van-field
+              v-model="formData.invoiceAmount"
+              name="开票金额"
+              label="开票金额"
+              placeholder="开票金额"
+              readonly
+              :rules="[{ required: true, message: '未获取开票金额' }]"
+          />
+          <van-field
+              v-model="formData.invoiceTypeText"
+              name="发票类型"
+              label="发票类型"
+              placeholder="发票类型"
+              readonly
+              :rules="[{ required: true, message: '未获取发票类型' }]"
+          />
+          <van-field
+              v-model="formData.invoiceContent"
+              name="开票内容"
+              label="开票内容"
+              placeholder="开票内容"
+              readonly
+              :rules="[{ required: true, message: '未获取开票内容' }]"
+          />
+          <van-field
+              v-model="formData.gg"
+              name="规格"
+              label="规格"
+              placeholder="规格"
+              readonly
+              :rules="[{ required: true, message: '未获取规格' }]"
+          />
+          <van-field
+              v-model="formData.sl"
+              name="数量"
+              label="数量"
+              placeholder="数量"
+              readonly
+              :rules="[{ required: true, message: '未获取数量' }]"
+          />
+          <van-field
+              v-model="formData.dj"
+              name="单价"
+              label="单价"
+              placeholder="单价"
+              readonly
+              :rules="[{ required: true, message: '未获取单价' }]"
+          />
+          <van-field
+              v-model="formData.payCompany"
+              name="付款单位"
+              label="付款单位"
+              placeholder="付款单位"
+              readonly
+              :rules="[{ required: true, message: '未获取付款单位' }]"
+          />
+          <van-field
+              v-model="formData.payTaxNumber"
+              name="付款税号"
+              label="付款税号"
+              placeholder="付款税号"
+              readonly
+              :rules="[{ required: true, message: '未获取付款税号' }]"
+          />
+          <van-field
+              v-model="formData.payAddress"
+              name="付款地址及电话"
+              label="付款地址及电话"
+              placeholder="付款地址及电话"
+              readonly
+              :rules="[{ required: true, message: '未获取付款地址及电话' }]"
+          />
+          <van-field
+              v-model="formData.payBank"
+              name="付款开户行及账号"
+              label="付款开户行及账号"
+              placeholder="付款开户行及账号"
+              readonly
+              :rules="[{ required: true, message: '未获取付款开户行及账号' }]"
+          />
+          <van-field
+              v-model="formData.receiveBankaccount"
+              name="收款银行账户"
+              label="收款银行账户"
+              placeholder="收款银行账户"
+              readonly
+              :rules="[{ required: true, message: '未获取收款银行账户' }]"
+          />
+          <van-field
+              v-model="formData.eleInvReceivePhone"
+              name="电子发票接收人手机号"
+              label="电子发票接收人手机号"
+              placeholder="电子发票接收人手机号"
+              readonly
+              :rules="[{ required: true, message: '未获取电子发票接收人手机号' }]"
+          />
+          <van-field
+              v-model="formData.eleInvReceiveEmail"
+              name="电子发票接收人邮箱"
+              label="电子发票接收人邮箱"
+              placeholder="电子发票接收人邮箱"
+              readonly
+              :rules="[{ required: true, message: '未获取电子发票接收人邮箱' }]"
+          />
+          <van-field
+              v-model="formData.invoiceBz"
+              name="开票备注"
+              label="开票备注"
+              placeholder="开票备注"
+              readonly
+              :rules="[{ required: true, message: '未获取开票备注' }]"
+          />
+
+        </van-cell-group>
+      </van-form>
+    </card>
+    <card title="回款信息" style="height: auto">
+      <van-form required="true" ref="form">
+        <van-cell-group inset>
+          <van-field
+              v-model="formData.contract.contractAmount"
+              name="合同金额"
+              label="合同金额"
+              placeholder="合同金额"
+              readonly
+              :rules="[{ required: true, message: '未获取合同金额' }]"
+          />
+          <van-field
+              v-model="formData.projectAmount.invoiceAmount"
+              name="已开票金额"
+              label="已开票金额"
+              placeholder="已开票金额"
+              readonly
+              :rules="[{ required: true, message: '未获取已开票金额' }]"
+          />
+          <van-field
+              v-model="formData.projectAmount.returnAmount"
+              name="已回款金额"
+              label="已回款金额"
+              placeholder="已回款金额"
+              readonly
+              :rules="[{ required: true, message: '未获取已回款金额' }]"
+          />
+          <van-field
+              v-model="formData.projectAmount.receivableAmount"
+              name="应收账款"
+              label="应收账款"
+              placeholder="应收账款"
+              readonly
+              :rules="[{ required: true, message: '未获取应收账款' }]"
+          />
+          <van-field
+              v-model="formData.projectAmount.contractBalance"
+              name="合同余额"
+              label="合同余额"
+              placeholder="合同余额"
+              readonly
+              :rules="[{ required: true, message: '未获取合同余额' }]"
+          />
+          <van-field
+              v-model="formData.contract.paymentTerms"
+              name="付款条件"
+              label="付款条件"
+              placeholder="付款条件"
+              readonly
+              :rules="[{ required: true, message: '未获取付款条件' }]"
+          />
+        </van-cell-group>
+      </van-form>
+    </card>
+    <card title="开票信息" style="height: auto">
+      <van-form required="true" ref="form">
+        <van-cell-group inset>
+          <van-field
+              v-model="formData.invoicePerson"
+              name="开票人"
+              label="开票人"
+              placeholder="开票人"
+              readonly
+              :rules="[{ required: true, message: '未获取开票人' }]"
+          />
+          <van-field
+              v-model="formData.lpr"
+              name="领票人"
+              label="领票人"
+              placeholder="领票人"
+              readonly
+              :rules="[{ required: true, message: '未获取领票人' }]"
+          />
+          <van-field
+              v-model="formData.invoiceDate"
+              name="开票日期"
+              label="开票日期"
+              placeholder="开票日期"
+              readonly
+              :rules="[{ required: true, message: '未获取开票日期' }]"
+          />
+          <van-field
+              v-model="formData.invoiceNo"
+              name="发票号码"
+              label="发票号码"
+              placeholder="发票号码"
+              readonly
+              :rules="[{ required: true, message: '未获取发票号码' }]"
+          />
+        </van-cell-group>
+      </van-form>
+    </card>
+    <card title="子项目信息">
+      <template #default>
+        <div v-for="(item,index) in formData.contractInvoiceRelations" :key="index">
+          <van-swipe-cell>
+            <card-cell>
+              <van-cell title="类型" :value="item.type"/>
+              <van-cell title="责任部门" :value="item.zrbm"/>
+              <van-cell title="项目经理" :value="item.xmjl"/>
+              <van-cell title="合同额" :value="item.virtualAmount"/>
+              <van-cell title="本次开票金额" :value="item.invoiceAmount"/>
+              <van-cell title="回款金额" :value="item.returnAmount"/>
+            </card-cell>
+            <template #right>
+              <van-button square type="primary" text="编辑" @click="detailView(index,item)"/>
+              <van-button square type="danger" text="删除" @click="detailDelte(index)"/>
+            </template>
+          </van-swipe-cell>
+        </div>
+      </template>
+    </card>
+  </flow-form>
+</template>
+
+<script setup lang="ts">
+import {useRoute} from 'vue-router';
+import {FlowDTO, getNextActivity} from '@/service/flow';
+import reqest from "@/utils/request";
+import FlowForm from '@/components/flowForm.vue';
+import Card from '@/components/card.vue';
+import CardCell from '@/components/cardCell.vue';
+import {DICT_TYPE, getDictLabel} from "@/utils/dict";
+
+const route = useRoute();
+const form = ref(null);
+
+interface FormDataType {
+}
+
+const formData = ref<FormDataType>({
+  contract: {},
+  project: {},
+  projectAmount: {},
+  returnMoneyList: [],
+  contractInvoiceRelations: [],
+
+})
+const detailData = ref({})
+
+
+const {activityInstanceId, participant, flowInstanceId, read} = route.query as {
+  activityInstanceId: string;
+  participant: string;
+  flowInstanceId: string;
+  read: string;
+};
+const activityData: FlowDTO = {
+  activityInstanceId,
+  participantId: participant,
+  flowOpinion: ''
+}
+const submitNextActivity = async (activeOpinion: any) => {
+  form.value.validate().then(async () => {
+    //工作流转件
+    activityData.activityInstanceId = activityInstanceId
+    activityData.participantId = participant
+    activityData.flowOpinion = JSON.stringify(activeOpinion)
+    const result = await getNextActivity(jsonToFormData(activityData))
+  });
+}
+const jsonToFormData = (json: any): FormData | null => {
+  const keys: string[] = Object.keys(json)
+  if (keys.length > 0) {
+    const formData = new FormData();
+    keys.forEach((key) => {
+      formData.append(key, (json[key] instanceof Object) ? JSON.stringify(json[key]) : json[key]);
+    });
+    return formData;
+  }
+  return null;
+}
+
+
+/** 初始化表单数据 */
+const initFormData = async () => {
+  const result = await reqest.get(`/business/flow/invoice/mobileAdd?flowInstanceId=${flowInstanceId}`)
+
+
+  formData.value = result.data;
+  formData.project = result.data.project;
+  formData.contract = result.data.contract;
+  formData.projectAmount = result.data.projectAmount;
+
+
+  formData.contract.mainTypeText = getDictLabel(DICT_TYPE.CONTRACT_MAIN_TYPE, formData.contract.mainType);
+  formData.contract.secondTypeText = getDictLabel(DICT_TYPE.CONTRACT_SECOND_TYPE, formData.contract.secondType);
+  formData.value.invoiceTypeText = getDictLabel(DICT_TYPE.INVOICE_TYPE, formData.value.invoiceType);
+}
+
+
+/** 初始化 */
+onMounted(() => {
+  initFormData()
+})
+</script>
+
+<style lang="scss" scoped>
+@import "./index.scss";
+
+::v-deep .van-field__label {
+  width: auto;
+}
+
+::v-deep .van-field__control {
+  text-align: right;
+}
+</style>

+ 9 - 1
client_h5/src/router/routes.ts

@@ -197,6 +197,14 @@ const routes: RouteRecordRaw[] = [
         },
         component: () => import("@/pages/outsourcing-apply/index.vue"),
       },
+      {
+        path: "contract-invoice",
+        name: "contract-invoice",
+        meta: {
+          title: "开票申请",
+        },
+        component: () => import("@/pages/contract-invoice/index.vue"),
+      },
       {
         path: "asset",
         name: "asset",
@@ -237,7 +245,7 @@ const routes: RouteRecordRaw[] = [
         },
         component: () => import("@/pages/projectstatus/indexJx.vue"),
       },
-      
+
     ] as RouteRecordRaw[],
   },
 ] as RouteRecordRaw[];

+ 4 - 0
zjugis-business/src/main/java/com/zjugis/business/converter/contract/ContractConvert.java

@@ -2,10 +2,12 @@ package com.zjugis.business.converter.contract;
 
 import com.zjugis.business.bean.entity.Contract;
 import com.zjugis.business.bean.entity.ContractApply;
+import com.zjugis.business.bean.entity.ContractInvoice;
 import com.zjugis.business.bean.entity.ContractSub;
 import com.zjugis.business.flow.contract.controller.vo.ContractVO;
 import com.zjugis.business.flow.contractApply.controller.vo.ContractSubApplyVO;
 import com.zjugis.business.flow.contractSub.controller.vo.ContractSubVO;
+import com.zjugis.business.flow.contractinvoice.controller.vo.ContractInvoiceVO;
 import org.mapstruct.Mapper;
 import org.mapstruct.factory.Mappers;
 
@@ -25,4 +27,6 @@ public interface ContractConvert {
     ContractSubApplyVO convertSub(ContractApply entity);
 
     ContractSubVO convert01(ContractSub entity);
+
+    ContractInvoiceVO convertInvoice(ContractInvoice entity);
 }

+ 7 - 0
zjugis-business/src/main/java/com/zjugis/business/flow/contractinvoice/controller/FlowContractInvoiceController.java

@@ -1,9 +1,12 @@
 package com.zjugis.business.flow.contractinvoice.controller;
 
 import com.zjugis.business.bean.entity.ContractInvoice;
+import com.zjugis.business.flow.contract.controller.vo.ContractVO;
+import com.zjugis.business.flow.contractinvoice.controller.vo.ContractInvoiceVO;
 import com.zjugis.business.flow.contractinvoice.service.FlowContractInvoiceService;
 import com.zjugis.business.service.ContractInvoiceRelationService;
 import com.zjugis.business.service.ContractReturnMoneyService;
+import com.zjugis.framework.common.pojo.CommonResult;
 import com.zjugis.framework.workflow.model.BaseController;
 import com.zjugis.framework.workflow.spring.resovler.ParamModel;
 import com.zjugis.framework.workflow.workflow.WorkFlow;
@@ -41,6 +44,10 @@ public class FlowContractInvoiceController extends BaseController {
     }
 
 
+    @GetMapping("/mobileAdd")
+    public CommonResult<ContractInvoiceVO> mobileAdd(String activityTemplateId, String flowInstanceId, String userId){
+        return CommonResult.success(invoiceFlowService.flowAdd(flowInstanceId, userId));
+    }
 
     @PostMapping("/update")
     public String update(@ParamModel ContractInvoice contractInvoice) {

+ 233 - 0
zjugis-business/src/main/java/com/zjugis/business/flow/contractinvoice/controller/vo/ContractInvoiceVO.java

@@ -0,0 +1,233 @@
+package com.zjugis.business.flow.contractinvoice.controller.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.zjugis.business.bean.dto.ContractInvoiceRelationDto;
+import com.zjugis.business.bean.entity.Contract;
+import com.zjugis.business.bean.entity.ContractReturnMoney;
+import com.zjugis.business.bean.entity.Project;
+import com.zjugis.business.bean.entity.ProjectAmount;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @author jzh
+ * @since 2024/5/11 9:08
+ */
+@Data
+public class ContractInvoiceVO {
+    private String id;
+
+    /**
+     * 合同ID
+     */
+    private String contractId;
+
+    /**
+     * 关联合同阶段
+     */
+    private String contractMilestoneId;
+
+    private String contractMilestoneName;
+
+    /**
+     * 流程实例ID
+     */
+    private String instanceId;
+
+    /**
+     * 申请人ID
+     */
+    private String workerId;
+
+    /**
+     * 申请人ID
+     */
+    private String applyWorkerName;
+
+    /**
+     * 申请人部门
+     */
+    private String applyWorkerDept;
+
+    /**
+     * 申请人部门ID
+     */
+    private String applyWorkerDeptId;
+    /**
+     * 申请时间
+     */
+    private LocalDate applyDate;
+
+    /**
+     * 项目ID
+     */
+    private String projectId;
+    /**
+     * 发票号码
+     */
+    private String invoiceNo;
+    /**
+     * 开票单号
+     */
+    private String invoiceNumber;
+    /**
+     * 开票金额
+     */
+    private BigDecimal invoiceAmount;
+    /**
+     * 开票内容
+     */
+    private String invoiceContent;
+    /**
+     * 开票日期
+     */
+    private LocalDate invoiceDate;
+    /**
+     * 领票人
+     */
+    private String invoicePerson;
+    /**
+     * 领票人ID
+     */
+    private String invoicePersonId;
+    /**
+     * 发票类型 1-增值税专用发票 2-增值税普通发票 3-服务业通用机打发票 4-统一收款收据
+     */
+    private Integer invoiceType;
+    /**
+     * 开票单位ID
+     */
+    private String invoiceCompanyId;
+    /**
+     * 开票单位
+     */
+    private String invoiceCompany;
+    /**
+     * 开票备注
+     */
+    private String invoiceBz;
+    /**
+     * 流程状态 1-开票申请 101-回款完成 102-已开票 103-票已送达 104-部分回款 90-开票申请完成
+     */
+    private Integer flowStatus;
+
+    private LocalDateTime flowFinishtime;
+    /**
+     * 客户名称
+     */
+    private String customerName;
+    /**
+     * 领票人
+     */
+    private String lpr;
+    /**
+     * 领票人ID
+     */
+    private String lprId;
+    /**
+     * 领票时间
+     */
+    private LocalDate lpsj;
+    /**
+     * 税号
+     */
+    private String taxNumber;
+    /**
+     * 开户银行
+     */
+    private String bank;
+    /**
+     * 帐号
+     */
+    private String bankaccount;
+    /**
+     * 联系人及电话
+     */
+    private String contactPerson;
+    /**
+     * 单位地址
+     */
+    private String address;
+    /**
+     * 规格
+     */
+    private String gg;
+    /**
+     * 数量
+     */
+    private BigDecimal sl;
+    /**
+     * 单价
+     */
+    private BigDecimal dj;
+    /**
+     * 送票人ID
+     */
+    private String sprId;
+    /**
+     * 送票人
+     */
+    private String spr;
+    /**
+     * 客户签收人
+     */
+    private String khqsr;
+    /**
+     * 签收日期
+     */
+    private LocalDate qsrq;
+    /**
+     * 送达方式
+     */
+    private String sdfs;
+    /**
+     * 回执备注
+     */
+    private String hzbz;
+    /**
+     * 付款单位
+     */
+    private String payCompany;
+    /**
+     * 付款单位ID
+     */
+    private String payCompanyId;
+    /**
+     * 付款单位税号
+     */
+    private String payTaxNumber;
+    /**
+     * 付款开户银行
+     */
+    private String payBank;
+    /**
+     * 付款单位地址电话
+     */
+    private String payAddress;
+    /**
+     * 收款银行账户
+     */
+    private String receiveBankaccount;
+    /**
+     * 电子发票接收人手机号
+     */
+    private String eleInvReceivePhone;
+    /**
+     * 电子发票接收人邮箱
+     */
+    private String eleInvReceiveEmail;
+
+    private BigDecimal invoiceReceivable;
+    List<ContractReturnMoney> returnMoneyList;
+    List<ContractInvoiceRelationDto> contractInvoiceRelations;
+    private Contract contract;
+    private Project project;
+    private ProjectAmount projectAmount;
+
+}

+ 50 - 22
zjugis-business/src/main/java/com/zjugis/business/flow/contractinvoice/service/FlowContractInvoiceService.java

@@ -7,6 +7,8 @@ import com.zjugis.business.bean.entity.*;
 import com.zjugis.business.constants.DictConstants;
 import com.zjugis.business.constants.FlowStatusConstants;
 import com.zjugis.business.converter.common.SelectConvert;
+import com.zjugis.business.converter.contract.ContractConvert;
+import com.zjugis.business.flow.contractinvoice.controller.vo.ContractInvoiceVO;
 import com.zjugis.business.mapper.ContractInvoiceMapper;
 import com.zjugis.business.service.*;
 import com.zjugis.framework.common.pojo.CommonResult;
@@ -67,12 +69,12 @@ public class FlowContractInvoiceService {
     @Autowired
     AdminUserApi adminUserApi;
 
-    public Map<String, Object>  getFormParams(String flowInstanceId,Integer isKp) {
+    public Map<String, Object> getFormParams(String flowInstanceId, Integer isKp) {
         String userId = SecurityFrameworkUtils.getLoginUserId();
         CommonResult<IFlowInstance> flowResult = workflowClient.flowInstance(flowInstanceId);
-        if(flowResult.isSuccess()){
+        if (flowResult.isSuccess()) {
             ContractInvoice entity = contractInvoiceService.selectByInstanceId(flowInstanceId);
-            if(Objects.isNull(entity)){
+            if (Objects.isNull(entity)) {
                 entity = new ContractInvoice();
                 entity.setInstanceId(flowInstanceId);
                 entity.setWorkerId(userId);
@@ -84,11 +86,11 @@ public class FlowContractInvoiceService {
                 entity.setApplyWorkerDeptId(result.getCheckedData().getDeptId());
                 contractInvoiceService.insert(entity);
             }
-            if(isKp != null && isKp == 1){
-                if(entity.getInvoiceDate() == null){
+            if (isKp != null && isKp == 1) {
+                if (entity.getInvoiceDate() == null) {
                     entity.setInvoiceDate(LocalDate.now());
                 }
-                if(StringUtils.isNotBlank(userId) && StringUtils.isBlank(entity.getInvoicePersonId())){
+                if (StringUtils.isNotBlank(userId) && StringUtils.isBlank(entity.getInvoicePersonId())) {
                     CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(userId);
                     entity.setInvoicePerson(user.getCheckedData().getNickname());
                     entity.setInvoicePersonId(userId);
@@ -105,31 +107,31 @@ public class FlowContractInvoiceService {
         return map;
     }
 
-    private Map<String, Object>  createMap(ContractInvoice entity) {
+    private Map<String, Object> createMap(ContractInvoice entity) {
         Map<String, Object> map = new HashMap<>();
         List<ContractReturnMoney> returnMoneyList = contractReturnMoneyService.selectByInoviceId(entity.getId());
         BigDecimal totalReturn = returnMoneyList.stream().map(ContractReturnMoney::getReturnAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
-        map.put("invoiceReceivable",entity.getInvoiceAmount() == null? BigDecimal.ZERO: entity.getInvoiceAmount().subtract(totalReturn));
+        map.put("invoiceReceivable", entity.getInvoiceAmount() == null ? BigDecimal.ZERO : entity.getInvoiceAmount().subtract(totalReturn));
         List<ContractInvoiceRelationDto> contractInvoiceRelations = contractInvoiceRelationService.selectByInvoiceId(entity.getId());
-        map.put("returnMoneyListJson",JSON.toJSONString(returnMoneyList));
-        map.put("contractListJson",JSON.toJSONString(contractInvoiceRelations));
-        if(StringUtils.isNotBlank(entity.getContractId())){
+        map.put("returnMoneyListJson", JSON.toJSONString(returnMoneyList));
+        map.put("contractListJson", JSON.toJSONString(contractInvoiceRelations));
+        if (StringUtils.isNotBlank(entity.getContractId())) {
             Contract contract = contractService.selectByPrimaryKey(entity.getContractId());
-            map.put("contract",contract);
-            if(contract != null){
-                if(StringUtils.isNotBlank(contract.getProjectId())){
+            map.put("contract", contract);
+            if (contract != null) {
+                if (StringUtils.isNotBlank(contract.getProjectId())) {
                     Project project = projectService.selectById(contract.getProjectId());
-                    map.put("project",project);
+                    map.put("project", project);
                     ProjectAmount projectAmount = projectAmountService.selectById(contract.getProjectId());
-                    if(projectAmount != null){
-                        map.put("amount",projectAmount);
+                    if (projectAmount != null) {
+                        map.put("amount", projectAmount);
                     }
                 }
-                if(contract.getMainType() != null){
+                if (contract.getMainType() != null) {
                     CommonResult<DictDataRespDTO> result = dictDataApi.getDictData(DictConstants.TYPE_CONTRACT_MAIN_TYPE, String.valueOf(contract.getMainType()));
                     map.put("mainType", result.getCheckedData().getLabel());
                 }
-                if(contract.getSecondType() != null){
+                if (contract.getSecondType() != null) {
                     CommonResult<DictDataRespDTO> result = dictDataApi.getDictData(DictConstants.TYPE_CONTRACT_SECOND_TYPE, String.valueOf(contract.getSecondType()));
                     map.put("secondType", result.getCheckedData().getLabel());
                 }
@@ -138,9 +140,9 @@ public class FlowContractInvoiceService {
         map.put("formEntity", entity);
         List<Select> invoiceTypeList = SelectConvert.INSTANCE.convertList(dictDataApi.getDictDataList(DictConstants.TYPE_INVOICE).getCheckedData());
         map.put("invoiceTypeList", JSON.toJSONString(invoiceTypeList));
-        if(entity.getInvoiceType() != null){
+        if (entity.getInvoiceType() != null) {
             CommonResult<DictDataRespDTO> result = dictDataApi.getDictData(DictConstants.TYPE_INVOICE, String.valueOf(entity.getInvoiceType()));
-            if(result.isSuccess()){
+            if (result.isSuccess()) {
                 map.put("invoiceType", result.getData().getLabel());
             }
         }
@@ -151,11 +153,37 @@ public class FlowContractInvoiceService {
     public int updateById(ContractInvoice entity) {
         int res = contractInvoiceMapper.updateById(entity);
         List<ContractInvoiceRelation> relations = contractInvoiceRelationService.selectDOByInvoiceId(entity.getId());
-        if(relations.size() == 1){
+        if (relations.size() == 1) {
             ContractInvoiceRelation relation = relations.get(0);
             relation.setInvoiceAmount(entity.getInvoiceAmount());
             contractInvoiceRelationService.updateById(relation);
         }
         return res;
     }
+
+    public ContractInvoiceVO flowAdd(String flowInstanceId, String userId) {
+        ContractInvoice entity = contractInvoiceService.selectByInstanceId(flowInstanceId);
+        ContractInvoiceVO vo = ContractConvert.INSTANCE.convertInvoice(entity);
+        List<ContractReturnMoney> returnMoneyList = contractReturnMoneyService.selectByInoviceId(entity.getId());
+        BigDecimal totalReturn = returnMoneyList.stream().map(ContractReturnMoney::getReturnAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+        vo.setInvoiceReceivable(entity.getInvoiceAmount() == null ? BigDecimal.ZERO : entity.getInvoiceAmount().subtract(totalReturn));
+        List<ContractInvoiceRelationDto> contractInvoiceRelations = contractInvoiceRelationService.selectByInvoiceId(entity.getId());
+        vo.setReturnMoneyList(returnMoneyList);
+        vo.setContractInvoiceRelations(contractInvoiceRelations);
+        if (StringUtils.isNotBlank(entity.getContractId())) {
+            Contract contract = contractService.selectByPrimaryKey(entity.getContractId());
+            vo.setContract(contract);
+            if (contract != null) {
+                if (StringUtils.isNotBlank(contract.getProjectId())) {
+                    Project project = projectService.selectById(contract.getProjectId());
+                    vo.setProject(project);
+                    ProjectAmount projectAmount = projectAmountService.selectById(contract.getProjectId());
+                    if (projectAmount != null) {
+                        vo.setProjectAmount(projectAmount);
+                    }
+                }
+            }
+        }
+        return vo;
+    }
 }