|
@@ -8,7 +8,7 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-//合同审批单
|
|
|
+// 合同审批单
|
|
|
type ContractApproval struct {
|
|
|
ContractApprovalId int `orm:"column(contract_approval_id);pk"`
|
|
|
ApprovalType string `description:"审批单类型,枚举值,合同:contract;用印:seal;默认:contract"`
|
|
@@ -27,7 +27,7 @@ type ContractApproval struct {
|
|
|
CreateTime time.Time `description:"最近一次审批单修改时间"`
|
|
|
}
|
|
|
|
|
|
-//根据合同审批单id获取合同审批单信息
|
|
|
+// 根据合同审批单id获取合同审批单信息
|
|
|
func GetContractApprovalById(contractApprovalId int) (contractApprovalInfo *ContractApproval, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `select * from contract_approval where contract_approval_id = ? `
|
|
@@ -35,7 +35,7 @@ func GetContractApprovalById(contractApprovalId int) (contractApprovalInfo *Cont
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//根据合同id获取最近一次待审批的合同审批单信息
|
|
|
+// 根据合同id获取最近一次待审批的合同审批单信息
|
|
|
func GetLastPendingContractApprovalByContractId(contractId int) (contractApprovalInfo *ContractApproval, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `select * from contract_approval where status = "待审批" AND contract_id=? order by contract_approval_id desc`
|
|
@@ -43,7 +43,7 @@ func GetLastPendingContractApprovalByContractId(contractId int) (contractApprova
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//根据合同id获取最近一次提交的合同审批单信息
|
|
|
+// 根据合同id获取最近一次提交的合同审批单信息
|
|
|
func GetLastContractApprovalByContractId(contractId int, approvalType string) (contractApprovalInfo *ContractApproval, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `select * from contract_approval where contract_id=? and approval_type =? order by contract_approval_id desc`
|
|
@@ -51,7 +51,7 @@ func GetLastContractApprovalByContractId(contractId int, approvalType string) (c
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//根据合同id获取总共被驳回的次数
|
|
|
+// 根据合同id获取总共被驳回的次数
|
|
|
func GetRejectContractCountByContractId(contractId int) (total int64, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `select count(1) total from contract_approval where status = "已驳回" AND contract_id=? `
|
|
@@ -59,7 +59,7 @@ func GetRejectContractCountByContractId(contractId int) (total int64, err error)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取合同审批列表数据数量
|
|
|
+// 获取合同审批列表数据数量
|
|
|
func GetContractApprovalListCount(childCondition, condition, joinCondition string, childPars, pars []interface{}) (count int, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `
|
|
@@ -81,7 +81,7 @@ WHERE c.is_delete = 0 AND a.approval_type="contract" `
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//合同审批列表
|
|
|
+// 合同审批列表
|
|
|
type ContractApprovalList struct {
|
|
|
ContractApprovalId int `description:"审批单id"`
|
|
|
ContractId int `description:"合同id"`
|
|
@@ -182,7 +182,7 @@ WHERE c.is_delete = 0 AND a.approval_type="contract" `
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取客户名称
|
|
|
+// 获取客户名称
|
|
|
func GetCompanyNameListV2(childCondition, condition string, childPars, pars []interface{}) (list []*contract.CompanyNameList, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `
|
|
@@ -261,7 +261,7 @@ type CompanyNameList struct {
|
|
|
CompanyName string `description:"客户名称,甲方名称,长度32位"`
|
|
|
}
|
|
|
|
|
|
-//根据合同id获取合同审批单信息
|
|
|
+// 根据合同id获取合同审批单信息
|
|
|
func (ContractApproval) CheckPendingByContractId(contractId int, approvalType string) (has bool, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
var contractApprovalInfo ContractApproval
|
|
@@ -281,7 +281,7 @@ func (ContractApproval) CheckPendingByContractId(contractId int, approvalType st
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//发起审批(工作流)
|
|
|
+// 发起审批(工作流)
|
|
|
func (ContractApproval) Apply(contractApprovalInfo *ContractApproval, contractApprovalRecordList []*contract_approval_record.ContractApprovalRecord) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
tx, err := o.Begin()
|
|
@@ -328,7 +328,7 @@ func (ContractApproval) Apply(contractApprovalInfo *ContractApproval, contractAp
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//撤回审核单
|
|
|
+// 撤回审核单
|
|
|
func (ContractApproval) Cancel(contractApprovalInfo *ContractApproval, contractApprovalRecordList []*contract_approval_record.ContractApprovalRecord) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
tx, err := o.Begin()
|
|
@@ -374,7 +374,7 @@ func (ContractApproval) Cancel(contractApprovalInfo *ContractApproval, contractA
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//审核驳回
|
|
|
+// 审核驳回
|
|
|
func (ContractApproval) Reject(contractApprovalInfo *ContractApproval, contractApprovalRecord *contract_approval_record.ContractApprovalRecord, approveUserId int, approveUserName, remark string) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
tx, err := o.Begin()
|
|
@@ -423,14 +423,14 @@ func (ContractApproval) Reject(contractApprovalInfo *ContractApproval, contractA
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//下级审批人信息
|
|
|
+// 下级审批人信息
|
|
|
type NextApproval struct {
|
|
|
ApproveRoleTypeCode string
|
|
|
ApproveUserId int
|
|
|
ApproveUserName string
|
|
|
}
|
|
|
|
|
|
-//审核通过
|
|
|
+// 审核通过
|
|
|
func (ContractApproval) Approved(contractApprovalInfo *ContractApproval, contractApprovalRecord *contract_approval_record.ContractApprovalRecord, remark string) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
tx, err := o.Begin()
|
|
@@ -501,7 +501,7 @@ func (ContractApproval) Approved(contractApprovalInfo *ContractApproval, contrac
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//抄送
|
|
|
+// 抄送
|
|
|
func (ContractApproval) ApprovedByCc(contractApprovalInfo *ContractApproval, contractApprovalRecordList []*contract_approval_record.ContractApprovalRecord, remark string, nextNodeId int) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
tx, err := o.Begin()
|
|
@@ -575,7 +575,7 @@ func (ContractApproval) ApprovedByCc(contractApprovalInfo *ContractApproval, con
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//根据合同审批单id集合获取合同审批单信息列表
|
|
|
+// 根据合同审批单id集合获取合同审批单信息列表
|
|
|
func GetContractApprovalByIds(contractApprovalIds string) (contractApprovalList []*ContractApproval, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `select * from contract_approval where contract_approval_id in (` + contractApprovalIds + `) `
|
|
@@ -583,7 +583,7 @@ func GetContractApprovalByIds(contractApprovalIds string) (contractApprovalList
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取用印审批列表数据数量
|
|
|
+// 获取用印审批列表数据数量
|
|
|
func GetSealApprovalListCount(childCondition, condition, joinCondition string, childPars, pars []interface{}) (count int, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.create_time,a.modify_time,a.status,c.status seal_status,
|
|
@@ -603,7 +603,7 @@ WHERE c.is_delete = 0 AND a.approval_type="seal" `
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//用印审批列表
|
|
|
+// 用印审批列表
|
|
|
type SealApprovalList struct {
|
|
|
ContractApprovalId int `description:"审批单id"`
|
|
|
ContractId int `description:"合同id"`
|
|
@@ -635,12 +635,13 @@ type SealApprovalList struct {
|
|
|
ModifyTimeStr string `description:"最后一次修改的时间(字符串类型)"`
|
|
|
ApproveTimeStr string `description:"审批时间(字符串类型)"`
|
|
|
InvalidTimeStr string `description:"作废时间(字符串类型)"`
|
|
|
+ AffiliatedCompany string `description:"归属公司"`
|
|
|
}
|
|
|
|
|
|
-//获取合同审批列表数据
|
|
|
+// 获取合同审批列表数据
|
|
|
func GetSealApprovalList(childCondition, condition, joinCondition string, childPars, pars []interface{}, startSize, pageSize int) (list []*SealApprovalList, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
- sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.apply_user_id,a.apply_user_name,a.curr_node_id,a.start_node_id,a.create_time,a.modify_time,a.status approval_status,c.status,c.seal_type,c.company_name,c.user_id,c.user_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.check_back_file_time from contract_approval a
|
|
|
+ sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.apply_user_id,a.apply_user_name,a.curr_node_id,a.start_node_id,a.create_time,a.modify_time,a.status approval_status,c.status,c.seal_type,c.company_name,c.user_id,c.user_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.check_back_file_time,c.affiliated_company from contract_approval a
|
|
|
join
|
|
|
( SELECT max( contract_approval_id ) max_id,contract_id FROM contract_approval where 1=1 and approval_type="seal" `
|
|
|
sql += childCondition
|
|
@@ -654,7 +655,7 @@ WHERE c.is_delete = 0 AND a.approval_type="seal" `
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//处理后的
|
|
|
+// 处理后的
|
|
|
func GetSealApprovalListCountV2(childCondition, condition string, childPars, pars []interface{}) (count int, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.create_time,a.modify_time,a.status,c.status seal_status,
|
|
@@ -675,7 +676,7 @@ WHERE c.is_delete = 0 AND a.approval_type="seal" `
|
|
|
}
|
|
|
func GetSealApprovalListV2(childCondition, condition, orderBy string, childPars, pars []interface{}, startSize, pageSize int) (list []*SealApprovalList, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
- sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.apply_user_id,a.apply_user_name,a.curr_node_id,a.start_node_id,a.create_time,a.modify_time,a.status approval_status,c.status,c.seal_type,c.company_name,c.user_id,c.user_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.check_back_file_time from contract_approval a
|
|
|
+ sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.apply_user_id,a.apply_user_name,a.curr_node_id,a.start_node_id,a.create_time,a.modify_time,a.status approval_status,c.status,c.seal_type,c.company_name,c.user_id,c.user_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.check_back_file_time, c.affiliated_company from contract_approval a
|
|
|
join
|
|
|
( SELECT max( contract_approval_id ) max_id,contract_id FROM contract_approval where 1=1 and approval_type="seal" `
|
|
|
sql += childCondition
|
|
@@ -689,7 +690,7 @@ WHERE c.is_delete = 0 AND a.approval_type="seal" `
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//审批列表
|
|
|
+// 审批列表
|
|
|
type CompanyApprovalList struct {
|
|
|
ContractApprovalId int `description:"审批单id"`
|
|
|
ContractId int `description:"客户单id"`
|
|
@@ -780,3 +781,18 @@ from contract_approval a
|
|
|
_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func GetContractApprovalByRecordId(companyApprovalRecordIds []int) (list *ContractApproval, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `
|
|
|
+SELECT
|
|
|
+ b.*
|
|
|
+FROM
|
|
|
+ contract_approval_record AS a
|
|
|
+ INNER JOIN contract_approval AS b ON a.contract_approval_id = b.contract_approval_id
|
|
|
+WHERE
|
|
|
+ contract_approval_record_id IN (` + utils.GetOrmInReplace(len(companyApprovalRecordIds)) + `) `
|
|
|
+
|
|
|
+ _, err = o.Raw(sql, companyApprovalRecordIds).QueryRows(&list)
|
|
|
+ return
|
|
|
+}
|