...
|
...
|
@@ -35,10 +35,42 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
// CheckUndertakerTypesUncheckedAvailable TODO 校验项目承接对象是否可以删除
|
|
|
func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) ([]int32, error) {
|
|
|
|
|
|
return []int32{}, nil
|
|
|
// CheckUndertakerTypesUncheckedAvailable 校验项目承接对象是否可以删除
|
|
|
func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) (bool, error) {
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
var cooperationContractModels []*models.CooperationContract
|
|
|
// 获取和项目关联的合约
|
|
|
query := tx.Model(&cooperationContractModels)
|
|
|
if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
|
|
|
query = query.Where("cooperation_project_number = ?", cooperationProjectNumber)
|
|
|
}
|
|
|
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
|
|
|
query = query.Where(`cooperation_contract.company @> '{"companyId":"?"}'`, companyId)
|
|
|
}
|
|
|
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
|
|
|
query = query.Where(`cooperation_contract.org @> '{"orgId":"?"}'`, orgId)
|
|
|
}
|
|
|
if user, ok := queryOptions["user"]; ok && user.(bool) != false {
|
|
|
query = query.Where("user_type = ?", 1)
|
|
|
}
|
|
|
if partner, ok := queryOptions["partner"]; ok && partner.(bool) != false {
|
|
|
query = query.Where("user_type = ?", 2)
|
|
|
}
|
|
|
if count, err := query.SelectAndCount(); err != nil {
|
|
|
return false, err
|
|
|
} else {
|
|
|
if count > 0 {
|
|
|
for _, cooperationContractModel := range cooperationContractModels {
|
|
|
// 获取合约相关承接人
|
|
|
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
|
|
|
queryUndertaker := tx.Model(&cooperationContractUndertakerModels)
|
|
|
queryUndertaker.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber)
|
|
|
ok, err2 := queryUndertaker.Exists()
|
|
|
return !ok, err2
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return false, nil
|
|
|
}
|
|
|
|
|
|
// CheckProjectNumberAvailable 校验项目编号唯一性
|
...
|
...
|
|