Bläddra i källkod

feature(项目升级):
1、项目升级上传文件问题改走文件服务器
2、创建项目添加招标信息

ZZH-wl 2 år sedan
förälder
incheckning
914517e672

+ 6 - 0
opms_parent/app/dao/proj/internal/proj_business.go

@@ -61,6 +61,8 @@ type projBusinessColumns struct {
 	SaleName                  string // 销售姓名
 	DistributorId             string // 经销商/代理商ID
 	DistributorName           string // 经销商/代理商名称
+	BidId                     string // 客户招标ID
+	BidInfo                   string // 招标信息
 	FilingTime                string // 项目备案时间
 	FinalFollowId             string // 最新跟进人
 	FinalFollowName           string // 最新跟进人名称
@@ -142,6 +144,8 @@ var (
 			SaleName:                  "sale_name",
 			DistributorId:             "distributor_id",
 			DistributorName:           "distributor_name",
+			BidId:                     "bid_id",
+			BidInfo:                   "bid_info",
 			FilingTime:                "filing_time",
 			FinalFollowId:             "final_follow_id",
 			FinalFollowName:           "final_follow_name",
@@ -225,6 +229,8 @@ func NewProjBusinessDao(tenant string) ProjBusinessDao {
 			SaleName:                  "sale_name",
 			DistributorId:             "distributor_id",
 			DistributorName:           "distributor_name",
+			BidId:                     "bid_id",
+			BidInfo:                   "bid_info",
 			FilingTime:                "filing_time",
 			FinalFollowId:             "final_follow_id",
 			FinalFollowName:           "final_follow_name",

+ 6 - 0
opms_parent/app/handler/proj/business.go

@@ -165,6 +165,12 @@ func (p *BusinessHandler) BusinessUpgrade(ctx context.Context, req *projModel.Bu
 	if req.NboType != projSrv.StatusC && req.NboBudget <= 0 {
 		return myerrors.TipsError("项目预算不能小于0")
 	}
+	if (req.NboType == projSrv.StatusA || req.NboType == projSrv.StatusB) && req.QuotationFile == "" {
+		return myerrors.TipsError("请上传报价单文件")
+	}
+	if req.NboType == projSrv.StatusA && req.IsAdoptDashoo == "10" && req.DashooParamFile == "" {
+		return myerrors.TipsError("请上传大数技术参数文件")
+	}
 	businessService, err := projSrv.NewBusinessService(ctx)
 	if err != nil {
 		return err

+ 2 - 0
opms_parent/app/model/proj/internal/proj_business.go

@@ -42,6 +42,8 @@ type ProjBusiness struct {
 	SaleName                  string      `orm:"sale_name"                   json:"saleName"`                  // 销售姓名
 	DistributorId             int         `orm:"distributor_id"              json:"distributorId"`             // 经销商/代理商ID
 	DistributorName           string      `orm:"distributor_name"            json:"distributorName"`           // 经销商/代理商名称
+	BidId                     int         `orm:"bid_id"                      json:"bidId"`                     // 客户招标ID
+	BidInfo                   string      `orm:"bid_info"                    json:"bidInfo"`                   // 招标信息
 	FilingTime                *gtime.Time `orm:"filing_time"                 json:"filingTime"`                // 项目备案时间
 	FinalFollowId             int         `orm:"final_follow_id"             json:"finalFollowId"`             // 最新跟进人
 	FinalFollowName           string      `orm:"final_follow_name"           json:"finalFollowName"`           // 最新跟进人名称

+ 6 - 0
opms_parent/app/model/proj/proj_business.go

@@ -67,6 +67,9 @@ type AddProjBusinessReq struct {
 	Intervention     string      `json:"intervention"`     // 介入情况
 	Remark           string      `json:"remark"`           // 备注
 
+	BidId   int    `json:"bidId"`   // 客户招标Id
+	BidInfo string `json:"bidInfo"` // 客户招标信息
+
 	// 跟进日程
 	//FollowTime     *gtime.Time `json:"followTime"       v:"required#跟进时间不能为空"`    // 跟进时间
 	//FollowUserId   int         `json:"followUserId"`                              // 关联跟进负责人
@@ -142,6 +145,9 @@ type BusinessUpgradeReq struct {
 	Accendant                 string      `json:"accendant"`                                                       // 维护部门及人员
 	Remark                    string      `json:"remark"`                                                          // 备注
 	ProjConversionReason      string      `json:"projConversionReason"   v:"required-if:nboType,30#转化原因不能为空"`      // 项目转化原因
+
+	QuotationFile   string `json:"quotationFile"`   // 报价单文件
+	DashooParamFile string `json:"dashooParamFile"` // 大数参数文件
 }
 
 // BusinessDowngradeReq 项目降级请求

+ 40 - 0
opms_parent/app/service/base.go

@@ -2,8 +2,14 @@ package service
 
 import (
 	"context"
+	"dashoo.cn/opms_libary/multipart"
 	"fmt"
+	"github.com/gogf/gf/text/gstr"
+	"github.com/gogf/gf/util/guid"
+	"io/ioutil"
 	"log"
+	"net/http"
+	"os"
 	"reflect"
 
 	"dashoo.cn/opms_libary/myerrors"
@@ -394,3 +400,37 @@ func SliceIntDeduplication(elems []int) []int {
 	}
 	return ret
 }
+
+// DownloadTempFile 下载临时文件
+func DownloadTempFile(url string) (*multipart.FileHeader, error) {
+	r, err := http.Get(url)
+	if err != nil {
+		g.Log().Error(err)
+		return nil, err
+	}
+	if r.StatusCode != http.StatusOK {
+		return nil, fmt.Errorf("DownloadFile from %s StatusCode %d", url, r.StatusCode)
+	}
+	defer r.Body.Close()
+	bytes, err := ioutil.ReadAll(r.Body)
+	if err != nil {
+		g.Log().Error(err)
+		return nil, err
+	}
+	names := gstr.Split(r.Header.Get("Content-Disposition"), "filename=")
+	fileName := guid.S()
+	if len(names) > 1 {
+		fileName = gstr.TrimStr(names[1], `"`)
+	}
+	file, err := os.CreateTemp("", fileName)
+	if err != nil {
+		g.Log().Error(err)
+	}
+	file.Write(bytes)
+	fmt.Println(file.Name())
+	fileData := new(multipart.FileHeader)
+	fileData.FileName = fileName
+	fileData.FileSize = gconv.Int64(r.Header.Get("Content-Length"))
+	fileData.File = file
+	return fileData, nil
+}

+ 20 - 3
opms_parent/app/service/proj/business.go

@@ -2,6 +2,7 @@ package proj
 
 import (
 	"context"
+	"os"
 
 	contractDao "dashoo.cn/micro/app/dao/contract"
 	custDao "dashoo.cn/micro/app/dao/cust"
@@ -638,9 +639,7 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq, fileMap
 	if err != nil {
 		return err
 	}
-	businessMap := g.Map{
-		p.Dao.C.ApproStatus: ApprovalWaiting,
-	}
+	businessMap := g.Map{p.Dao.C.ApproStatus: ApprovalWaiting}
 	service.SetUpdatedInfo(businessMap, p.GetCxtUserId(), p.GetCxtUserName())
 
 	opnContent := gconv.Map(req)
@@ -648,6 +647,24 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq, fileMap
 	opnContent["approStatus"] = ApprovalWaiting
 	service.SetUpdatedInfo(opnContent, p.GetCxtUserId(), p.GetCxtUserName())
 
+	if fileMap == nil {
+		fileMap = make(map[string]*multipart.FileHeader)
+	}
+	if req.NboType == StatusA || req.NboType == StatusB {
+		fileMap["quotationFile"], err = service.DownloadTempFile(req.QuotationFile)
+		if err != nil {
+			return err
+		}
+		defer os.Remove(fileMap["quotationFile"].File.Name())
+	}
+	if req.NboType == StatusA && req.IsAdoptDashoo == "10" {
+		fileMap["dashooParamFile"], err = service.DownloadTempFile(req.DashooParamFile)
+		if err != nil {
+			return err
+		}
+		defer os.Remove(fileMap["dashooParamFile"].File.Name())
+	}
+
 	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
 		// 更新项目调级
 		_, err = p.Dao.TX(tx).WherePri(req.Id).Data(businessMap).Update()