|
|
@@ -5,11 +5,15 @@ import (
|
|
|
contractDao "dashoo.cn/micro/app/dao/contract"
|
|
|
custDao "dashoo.cn/micro/app/dao/cust"
|
|
|
projDao "dashoo.cn/micro/app/dao/proj"
|
|
|
+ contractModel "dashoo.cn/micro/app/model/contract"
|
|
|
model "dashoo.cn/micro/app/model/proj"
|
|
|
workflowModel "dashoo.cn/micro/app/model/workflow"
|
|
|
- "dashoo.cn/micro/app/service"
|
|
|
workflowService "dashoo.cn/micro/app/service/workflow"
|
|
|
+
|
|
|
+ "dashoo.cn/micro/app/service"
|
|
|
+ "dashoo.cn/opms_libary/multipart"
|
|
|
"dashoo.cn/opms_libary/myerrors"
|
|
|
+ "dashoo.cn/opms_libary/plugin/dingtalk"
|
|
|
"dashoo.cn/opms_libary/plugin/dingtalk/message"
|
|
|
"dashoo.cn/opms_libary/plugin/dingtalk/workflow"
|
|
|
"dashoo.cn/opms_libary/utils"
|
|
|
@@ -152,8 +156,8 @@ func (p *businessService) GetBusinessDynamicsList(req *model.BusinessDynamicsReq
|
|
|
}
|
|
|
|
|
|
// 获取项目编号
|
|
|
-func (s *businessService) getNboCode(customerCode string) (string, error) {
|
|
|
- sequence, err := service.Sequence(s.Dao.DB, "nbo_code")
|
|
|
+func (p *businessService) getNboCode(customerCode string) (string, error) {
|
|
|
+ sequence, err := service.Sequence(p.Dao.DB, "nbo_code")
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
|
@@ -507,7 +511,7 @@ func (p *businessService) BusinessGradation(busId int, nboType, busType string)
|
|
|
}
|
|
|
|
|
|
// BusinessUpgrade 项目升级
|
|
|
-func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq) error {
|
|
|
+func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq, args *multipart.MultipartFile) error {
|
|
|
business, err := p.BusinessGradation(req.Id, req.NboType, "up")
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -538,7 +542,7 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq) error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- err = p.BusUpgradeDingEvent(business, req)
|
|
|
+ err = p.BusUpgradeDingEvent(business, req, args)
|
|
|
return err
|
|
|
})
|
|
|
return err
|
|
|
@@ -566,7 +570,7 @@ func (p *businessService) getBusDingUpgradeType(dbNboType, reqNboType string) st
|
|
|
}
|
|
|
|
|
|
// BusUpgradeDingEvent 项目升级钉钉审批流调用
|
|
|
-func (p *businessService) BusUpgradeDingEvent(business *model.ProjBusiness, req *model.BusinessUpgradeReq) error {
|
|
|
+func (p *businessService) BusUpgradeDingEvent(business *model.ProjBusiness, req *model.BusinessUpgradeReq, args *multipart.MultipartFile) error {
|
|
|
upgradeType := p.getBusDingUpgradeType(business.NboType, req.NboType)
|
|
|
if upgradeType == "" {
|
|
|
return myerrors.TipsError("错误的升级类型")
|
|
|
@@ -615,11 +619,89 @@ func (p *businessService) BusUpgradeDingEvent(business *model.ProjBusiness, req
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- case StatusB, StatusA: // 目前转B、A表单提交参数一致,仅A比B多几个必填-----2023.02.27
|
|
|
+ case StatusB:
|
|
|
processCode := &BusinessUpgradeBRequestProcessCode
|
|
|
- if req.NboType == StatusA {
|
|
|
- processCode = &BusinessUpgradeARequestProcessCode
|
|
|
+ dingReq = &workflow.StartProcessInstanceRequest{
|
|
|
+ ProcessCode: processCode,
|
|
|
+ FormComponentValues: []*workflow.StartProcessInstanceRequestFormComponentValues{
|
|
|
+ {
|
|
|
+ Id: utils.String("TextField-K2AD4O5B"),
|
|
|
+ Name: utils.String("项目编码"),
|
|
|
+ Value: utils.String(business.NboCode),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("TextField_BDLSECETVSG0"),
|
|
|
+ Name: utils.String("项目名称"),
|
|
|
+ Value: utils.String(business.NboName),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("DDSelectField_VSA3U380ZK00"),
|
|
|
+ Name: utils.String("升级类型"),
|
|
|
+ Value: utils.String(upgradeType),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("TextField_1J9BJMOZ18F40"),
|
|
|
+ Name: utils.String("客户名称"),
|
|
|
+ Value: utils.String(business.CustName),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("NumberField_1F88MCD0W8KG0"),
|
|
|
+ Name: utils.String("项目预算"),
|
|
|
+ Value: utils.String(gconv.String(req.NboBudget)),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("TextField_1PWK6WHMGITC0"),
|
|
|
+ Name: utils.String("经销商/代理商"),
|
|
|
+ Value: utils.String(req.DistributorName),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("TextField_X4D3QGARU7K0"),
|
|
|
+ Name: utils.String("支持内容"),
|
|
|
+ Value: utils.String(req.TechnicalSupportContent),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("TextField_AEUWH63LJ0O0"),
|
|
|
+ Name: utils.String("销售工程师"),
|
|
|
+ Value: utils.String(business.SaleName),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("DDDateField_1FW1QZQYBZVK0"),
|
|
|
+ Name: utils.String("采购时间"),
|
|
|
+ Value: utils.String(gconv.String(req.PurchasingTime.Format("Y-m-d"))),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("DDSelectField_21ASEWDIB3MO0"),
|
|
|
+ Name: utils.String("采购方式"),
|
|
|
+ Value: utils.String(gconv.String(purchasingWayType[req.PurchasingWay])),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("DDSelectField_5R11VVM6GI00"),
|
|
|
+ Name: utils.String("是否我司参数"),
|
|
|
+ Value: utils.String(gconv.String(yesOrNoType[req.IsAdoptDashoo])),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("TextareaField_1GEL8JJL3H5S0"),
|
|
|
+ Name: utils.String("备注"),
|
|
|
+ Value: utils.String(req.Remark),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
+ case StatusA:
|
|
|
+ resp, err := dingtalk.Client.GetStorage().UploadFile(spaceId, p.GetCxtUserDingtalkId(), args.FileName, args.File.Name())
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("钉钉上传文件异常 %s", err.Error())
|
|
|
}
|
|
|
+ g.Log().Info("项目转A类提交大数参数文件", resp)
|
|
|
+ file := []contractModel.DingFileInfo{{
|
|
|
+ SpaceId: resp.Dentry.SpaceId,
|
|
|
+ FileId: resp.Dentry.Id,
|
|
|
+ FileName: resp.Dentry.Name,
|
|
|
+ FileSize: resp.Dentry.Size,
|
|
|
+ FileType: resp.Dentry.Extension,
|
|
|
+ }}
|
|
|
+
|
|
|
+ processCode := &BusinessUpgradeARequestProcessCode
|
|
|
dingReq = &workflow.StartProcessInstanceRequest{
|
|
|
ProcessCode: processCode,
|
|
|
FormComponentValues: []*workflow.StartProcessInstanceRequestFormComponentValues{
|
|
|
@@ -678,6 +760,11 @@ func (p *businessService) BusUpgradeDingEvent(business *model.ProjBusiness, req
|
|
|
Name: utils.String("是否我司参数"),
|
|
|
Value: utils.String(gconv.String(yesOrNoType[req.IsAdoptDashoo])),
|
|
|
},
|
|
|
+ {
|
|
|
+ Id: utils.String("DDAttachment_11Q7DBRKE6HC0"),
|
|
|
+ Name: utils.String("附件"),
|
|
|
+ Value: utils.String(gconv.String(file)),
|
|
|
+ },
|
|
|
{
|
|
|
Id: utils.String("TextareaField_1GEL8JJL3H5S0"),
|
|
|
Name: utils.String("备注"),
|
|
|
@@ -685,6 +772,7 @@ func (p *businessService) BusUpgradeDingEvent(business *model.ProjBusiness, req
|
|
|
},
|
|
|
},
|
|
|
}
|
|
|
+
|
|
|
default:
|
|
|
return nil
|
|
|
}
|