4415 lines
128 KiB
Go
4415 lines
128 KiB
Go
package approval
|
||
|
||
import (
|
||
"context"
|
||
"encoding/json"
|
||
"errors"
|
||
"fmt"
|
||
account2 "github.com/fonchain_enterprise/fonchain-main/api/account"
|
||
"github.com/fonchain_enterprise/fonchain-main/api/artist"
|
||
"github.com/fonchain_enterprise/fonchain-main/api/artwork_third_party"
|
||
department2 "github.com/fonchain_enterprise/fonchain-main/api/department"
|
||
"github.com/fonchain_enterprise/fonchain-main/api/paybill"
|
||
"github.com/fonchain_enterprise/fonchain-main/api/position"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/cache"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/common"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/config"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/model/login"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/model/oa_model"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/model/vo"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/serializer"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/service/account"
|
||
model2 "github.com/fonchain_enterprise/fonchain-main/pkg/service/approval/model"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/service/auth/department"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/service/es_service/approval/logic"
|
||
"github.com/fonchain_enterprise/utils/utils"
|
||
"github.com/jinzhu/copier"
|
||
"go.uber.org/zap"
|
||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||
"strconv"
|
||
"strings"
|
||
"time"
|
||
|
||
"dubbo.apache.org/dubbo-go/v3/common/logger"
|
||
api "github.com/fonchain_enterprise/fonchain-main/api/approval"
|
||
artShow "github.com/fonchain_enterprise/fonchain-main/api/artShow"
|
||
"github.com/fonchain_enterprise/fonchain-main/api/artwork_query"
|
||
"github.com/fonchain_enterprise/fonchain-main/api/rule"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/e"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/model"
|
||
"github.com/fonchain_enterprise/fonchain-main/pkg/service"
|
||
"github.com/gin-gonic/gin"
|
||
"github.com/gin-gonic/gin/binding"
|
||
)
|
||
|
||
const (
|
||
TypeContent = "content"
|
||
TypeWork = "work"
|
||
TypeExhibition = "exhibition"
|
||
TypeShow = "show"
|
||
TypeBundle = "bundle"
|
||
TypeBundlePayPrice = "bundlePayPrice"
|
||
TypeArtExhibitionReward = "artExhibitionReward"
|
||
TypeStaffSupply = "staffSupply"
|
||
TypeShowUpdate = "showUpdate"
|
||
)
|
||
|
||
func Create(c *gin.Context) {
|
||
var req api.CreateRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
// TODO 创建审批 防止重复提交
|
||
lockKey := fmt.Sprintf("create_approval_%v_%v", userInfo.ID, req.Type)
|
||
reply := cache.RedisClient.SetNX(lockKey, 0, 3*time.Second)
|
||
if !reply.Val() {
|
||
service.Error(c, e.Error, nil, e.ErrorCreateApproval)
|
||
return
|
||
}
|
||
|
||
//提交人
|
||
req.SubmitterName = userInfo.NickName
|
||
req.SubmitterID = userInfo.ID
|
||
|
||
fmt.Println("____________________ 打印 请求参数 createRequest 1 ________________________")
|
||
fmt.Printf("req 1 : %+v\n", req)
|
||
fmt.Println("____________________ 打印 请求参数 createRequest 1 ________________________")
|
||
|
||
if req.Type == oa_model.TypeDayOff {
|
||
if req.ApprovalOA.Leave.Hours < 1 {
|
||
service.Error(c, e.Error, errors.New(e.ErrDayoffNotLessOneHour))
|
||
return
|
||
}
|
||
}
|
||
|
||
if req.Type == oa_model.TypeMakeUp {
|
||
err := CheckMakeUpApplyApproval(&req, userInfo)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if req.Type == oa_model.TypeOverTime {
|
||
err := CheckOverTimeApplyApproval(&req, userInfo)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if req.Type == oa_model.TypeOutWork {
|
||
err := CheckLeaveTime(&req, userInfo)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
err = CheckOutWorkTime(&req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if oa_model.LeaveApplyMap[req.Type] != "" {
|
||
err := CheckLeaveTime(&req, userInfo)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if oa_model.LeaveApplyMap[req.Type] != "" && req.Type != oa_model.TypeOverTime && req.Type != oa_model.TypeLeave {
|
||
err := CheckLeaveApproval(&req, userInfo)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
if oa_model.LeaveBalanceApplyMap[req.Type] != "" {
|
||
err := CheckLeaveApply(&req, userInfo)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if strings.Contains(req.Type, "employ") {
|
||
if req.Employ.ResumeID == "" {
|
||
service.Error(c, e.Error, errors.New(e.ErrorResumeID))
|
||
return
|
||
}
|
||
resumeID, _ := strconv.ParseInt(req.Employ.ResumeID, 10, 64)
|
||
err := resumeHireJudge(userInfo, resumeID)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if oa_model.LeaveBalanceApplyMap[req.Type] != "" {
|
||
err := CheckLeaveApply(&req, userInfo)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
req.ApprovalUsers, req.IsLeader = DepartmentBosses(c, req.DepartmentID, req.SubmitterID)
|
||
if userInfo.DepartmentName == "管理部" || userInfo.DepartmentName == "人事行政部" {
|
||
req.IsLeader = true
|
||
}
|
||
|
||
// start 针对 艺邑 特殊处理 且 只有 oa 申请才是
|
||
departmentName := ""
|
||
if len(userInfo.PositionUsers) == 1 {
|
||
for i := 0; i < len(userInfo.PositionUsers); i++ {
|
||
if userInfo.PositionUsers[i].DepartmentName == "艺邑" {
|
||
departmentName = "艺邑"
|
||
}
|
||
}
|
||
} else if len(userInfo.PositionUsers) > 1 {
|
||
for i := 0; i < len(userInfo.PositionUsers); i++ {
|
||
if userInfo.PositionUsers[i].DepartmentId == uint64(req.DepartmentID) && userInfo.PositionUsers[i].DepartmentName == "艺邑" {
|
||
departmentName = "艺邑"
|
||
}
|
||
}
|
||
}
|
||
|
||
if departmentName == "艺邑" && (oa_model.LeaveApplyMap[req.Type] != "" || oa_model.LeaveBalanceApplyMap[req.Type] != "" || req.Type == oa_model.TypeOutWork || req.Type == oa_model.TypeTurnover || req.Type == oa_model.TypeMakeUp) {
|
||
req.ApprovalUsers = nil
|
||
if req.SubmitterName == "董辰琦" {
|
||
req.IsLeader = true
|
||
}
|
||
req.Domain = "out"
|
||
}
|
||
// end
|
||
|
||
fmt.Println("____________________ 打印 请求参数 createRequest 2 ________________________")
|
||
fmt.Printf("req 2 : %+v\n", req)
|
||
fmt.Println("____________________ 打印 请求参数 createRequest 2 ________________________")
|
||
|
||
res, err := service.ApprovalProvider.Create(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
//此处同步到画展包的数据
|
||
if req.Type == "exhibition" {
|
||
applyId, err := synToArtShow(c, &req, res)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
upReq := &api.UpdateEhApplyIDRequest{
|
||
ApplyId: applyId,
|
||
ApprovalID: res.ID,
|
||
}
|
||
|
||
_, upErr := service.ApprovalProvider.UpdateExhibitionApplyID(c, upReq)
|
||
if upErr != nil {
|
||
service.Error(c, e.Error, upErr)
|
||
return
|
||
}
|
||
}
|
||
|
||
// 同步 oa 审批到 oa
|
||
if e.TypeMap[req.Type] == "oa" {
|
||
fmt.Println("同步 oa系统 ")
|
||
|
||
// 查询 审批状态已经 更新的 审批信息
|
||
createReq := api.DetailRequest{ID: res.ID}
|
||
createDetail, detailErr := service.ApprovalProvider.Detail(c, &createReq)
|
||
if detailErr != nil {
|
||
service.Error(c, e.Error, detailErr)
|
||
return
|
||
}
|
||
|
||
oaRes, err := SyncApprovalToOA(createDetail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
fmt.Println("更新 oa系统 UUID ")
|
||
// 获取到 OA审批的 UUID 更新 approvalOA 中的 UUID
|
||
updateUUID := &api.UpdateApprovalOAUUIDReq{
|
||
UUID: oaRes.ID, // OA 返回
|
||
ApplyType: req.Type,
|
||
ApprovalID: res.ID, // approval 返回
|
||
}
|
||
_, updateUUIDErr := service.ApprovalProvider.UpdateApprovalOAUUID(context.Background(), updateUUID)
|
||
if updateUUIDErr != nil {
|
||
service.Error(c, e.Error, updateUUIDErr)
|
||
return
|
||
}
|
||
}
|
||
|
||
// 人才招聘
|
||
if strings.Contains(req.Type, "staffSupply") {
|
||
err = createPostApprove(c, userInfo, res, req.DepartmentID)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if strings.Contains(req.Type, "employ") {
|
||
err = createOfferApprove(c, userInfo, res, req.DepartmentID)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
service.Success(c, res)
|
||
}
|
||
|
||
// DepartmentBosses 获取部门主管列表
|
||
func DepartmentBosses(c *gin.Context, departmentID int64, submitterID uint64) ([]*api.ApprovalUser, bool) {
|
||
|
||
var approvalUsers []*api.ApprovalUser
|
||
var departmentIds []uint64
|
||
var isLeader bool
|
||
isLeader = false
|
||
|
||
if departmentID == 0 {
|
||
return approvalUsers, isLeader
|
||
}
|
||
|
||
departmentIds = append(departmentIds, uint64(departmentID))
|
||
|
||
if len(departmentIds) <= 0 {
|
||
return approvalUsers, isLeader
|
||
}
|
||
|
||
req := rule.FindByUrlRequest{
|
||
Url: e.DepartmentKey,
|
||
DepartmentIds: departmentIds,
|
||
}
|
||
|
||
//fmt.Println("=============================== FindByUrlRequest ==================================")
|
||
//fmt.Printf("req : %+v\n", req)
|
||
|
||
res, err := service.RuleProvider.FindUsersByUrl(c, &req)
|
||
|
||
if err == nil && len(res.List) > 0 {
|
||
fmt.Println("================================耿阳接口获取到的直属审批人")
|
||
fmt.Println(res.List)
|
||
for _, tt := range res.List {
|
||
temp := &api.ApprovalUser{
|
||
ID: tt.UserId,
|
||
Name: tt.UserName,
|
||
}
|
||
//fmt.Println("=============================== FindByUrlResponse ==================================")
|
||
//fmt.Printf("temp : %+v\n", temp)
|
||
approvalUsers = append(approvalUsers, temp)
|
||
}
|
||
for _, tt := range res.List {
|
||
if tt.UserId == submitterID {
|
||
isLeader = true
|
||
}
|
||
}
|
||
}
|
||
fmt.Println("================================获取到的直属审批人")
|
||
fmt.Println(approvalUsers)
|
||
return approvalUsers, isLeader
|
||
}
|
||
|
||
func DepartmentBossesV3(c *gin.Context, domain string, departmentID int64, submitterID uint64) ([]*api.ApprovalUser, bool) {
|
||
|
||
var approvalUsers []*api.ApprovalUser
|
||
var departmentIds []uint64
|
||
var isLeader bool
|
||
isLeader = false
|
||
|
||
if departmentID == 0 {
|
||
return approvalUsers, isLeader
|
||
}
|
||
|
||
departmentIds = append(departmentIds, uint64(departmentID))
|
||
|
||
if len(departmentIds) <= 0 {
|
||
return approvalUsers, isLeader
|
||
}
|
||
|
||
req := &department2.MyDirectLeadersRequest{
|
||
UserId: uint32(submitterID),
|
||
DepartmentId: uint32(departmentID),
|
||
Domain: domain,
|
||
}
|
||
|
||
res, err := service.DepartmentProvider.MyDirectLeaders(c, req)
|
||
if err != nil {
|
||
return nil, false
|
||
}
|
||
|
||
if err == nil && len(res.List) > 0 {
|
||
fmt.Println("==========================获取上级新接口返回的数据")
|
||
fmt.Println(res.List)
|
||
for _, tt := range res.List {
|
||
temp := &api.ApprovalUser{
|
||
ID: uint64(tt.UserId),
|
||
Name: tt.UserName,
|
||
}
|
||
approvalUsers = append(approvalUsers, temp)
|
||
}
|
||
fmt.Println(req)
|
||
boolean, err := service.DepartmentProvider.UserIsLeader(c, req)
|
||
if err != nil {
|
||
fmt.Println("==========================当前人是否是主管报错")
|
||
fmt.Println(err.Error())
|
||
return nil, false
|
||
}
|
||
isLeader = boolean.IsLeader
|
||
}
|
||
return approvalUsers, isLeader
|
||
}
|
||
|
||
func DepartmentBossesV1(c *gin.Context, positionUsers []*rule.PositionUser) []*api.ApprovalUser {
|
||
|
||
var approvalUsers []*api.ApprovalUser
|
||
var departmentIds []uint64
|
||
departmentIdsMap := make(map[uint64]struct{})
|
||
|
||
if len(positionUsers) == 0 {
|
||
return approvalUsers
|
||
}
|
||
|
||
for _, tt := range positionUsers {
|
||
|
||
//我如果是boss,则过滤掉
|
||
if isHave := IsHaveBossAuth(c, tt.UserId, tt.DepartmentId); isHave == true {
|
||
continue
|
||
}
|
||
|
||
if _, ok := departmentIdsMap[tt.DepartmentId]; ok == false {
|
||
departmentIdsMap[tt.DepartmentId] = struct{}{}
|
||
departmentIds = append(departmentIds, tt.DepartmentId)
|
||
}
|
||
}
|
||
|
||
if len(departmentIds) <= 0 {
|
||
return approvalUsers
|
||
}
|
||
|
||
req := rule.FindByUrlRequest{
|
||
Url: e.DepartmentKey,
|
||
DepartmentIds: departmentIds,
|
||
}
|
||
|
||
res, err := service.RuleProvider.FindUsersByUrl(c, &req)
|
||
|
||
if err == nil && len(res.List) > 0 {
|
||
for _, tt := range res.List {
|
||
temp := &api.ApprovalUser{
|
||
ID: tt.UserId,
|
||
Name: tt.UserName,
|
||
}
|
||
|
||
approvalUsers = append(approvalUsers, temp)
|
||
}
|
||
|
||
}
|
||
return approvalUsers
|
||
}
|
||
|
||
func IsHaveBossAuth(c *gin.Context, ID uint64, DepartmentID uint64) bool {
|
||
isLeader := false
|
||
|
||
req := position.DoIHavaAuthRequest{
|
||
UserId: ID,
|
||
Url: e.DepartmentKey,
|
||
DepartmentID: DepartmentID,
|
||
}
|
||
|
||
res, err := service.PositionProvider.DoIHavaAuth(c, &req)
|
||
|
||
fmt.Println("查看返回", res)
|
||
if err == nil && res.Hava == true {
|
||
isLeader = true
|
||
}
|
||
|
||
return isLeader
|
||
}
|
||
|
||
// 创建附带
|
||
func synToArtShow(c *gin.Context, req *api.CreateRequest, res *api.ApprovalResponse) (string, error) {
|
||
|
||
now := time.Now()
|
||
datestr := now.Format("2006-01-02 15:04:05")
|
||
showRels := make([]*artShow.ShowRel, 0)
|
||
|
||
showApplyReq := &artShow.SaveApplyReq{
|
||
|
||
Applicant: req.SubmitterName,
|
||
ApplicantID: strconv.FormatUint(req.SubmitterID, 10),
|
||
Num: int32(len(req.Exhibition.ApprovalExhibitions)),
|
||
ApplyTime: datestr,
|
||
Status: 1,
|
||
Remark: "",
|
||
}
|
||
|
||
for index, tt := range req.Exhibition.ApprovalExhibitions {
|
||
|
||
temp := &artShow.ShowRel{
|
||
ShowUID: tt.PackageID,
|
||
Index: int32((index + 1)),
|
||
Address: tt.Address,
|
||
ShowTime: tt.ShowDate,
|
||
}
|
||
showRels = append(showRels, temp)
|
||
|
||
}
|
||
|
||
showApplyReq.Rel = showRels
|
||
|
||
showApplyRes, err := service.GrpcArtShowImpl.CreateApply(c, showApplyReq)
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
return showApplyRes.ApplyUID, nil
|
||
|
||
}
|
||
|
||
func passSynToArtShowNotLogin(c *gin.Context, ID uint64, UserId uint64) (string, error) {
|
||
|
||
var detailReq api.DetailRequest
|
||
|
||
detailReq.UserId = UserId
|
||
detailReq.ID = ID
|
||
|
||
detailRes, err3 := service.ApprovalProvider.Detail(c, &detailReq)
|
||
if err3 != nil {
|
||
return "", err3
|
||
}
|
||
if detailRes.Type != "exhibition" {
|
||
return "", nil
|
||
}
|
||
|
||
if detailRes.Status != 2 { // 不等于2 表示 此审批 未通过
|
||
return "", nil
|
||
}
|
||
|
||
// 审批 通过 通知 画展包微服务 记录
|
||
req := detailRes
|
||
|
||
now := time.Now()
|
||
datestr := now.Format("2006-01-02 15:04:05")
|
||
showRels := make([]*artShow.ShowRel, 0)
|
||
showUIDs := make([]string, 0)
|
||
var UpdateArtShowAgentList []*artShow.ArtShowAgent
|
||
|
||
showApplyReq := &artShow.SaveApplyReq{
|
||
ApplyUID: req.Exhibition.ApplyID,
|
||
Applicant: req.SubmitterName,
|
||
ApplicantID: strconv.FormatUint(req.SubmitterID, 10),
|
||
Num: int32(len(req.Exhibition.ApprovalExhibitions)),
|
||
ApplyTime: datestr,
|
||
Status: int32(req.Status),
|
||
}
|
||
|
||
for index, tt := range req.Exhibition.ApprovalExhibitions {
|
||
temp := &artShow.ShowRel{
|
||
ShowUID: tt.PackageID,
|
||
Index: int32((index + 1)),
|
||
Address: tt.Address,
|
||
ShowTime: tt.ShowDate,
|
||
ApplyUID: req.Exhibition.ApplyID,
|
||
}
|
||
|
||
UpdateArtShowAgentList = append(UpdateArtShowAgentList, &artShow.ArtShowAgent{
|
||
ShowUID: tt.PackageID,
|
||
Agent: tt.ArtExhibitionDetail.Agent,
|
||
})
|
||
|
||
showRels = append(showRels, temp)
|
||
showUIDs = append(showUIDs, tt.PackageID)
|
||
}
|
||
|
||
showDetail := new(artShow.ShowDetailReq)
|
||
showDetail.ShowUID = showUIDs
|
||
showDetailRes, err := service.GrpcArtShowImpl.ShowDetail(c, showDetail)
|
||
if err != nil {
|
||
return "", errors.New(e.ErrorQueryArtShowInfo)
|
||
}
|
||
//使用邀请函中的数据更新出行信息
|
||
defer func() {
|
||
var showUids []string
|
||
for _, v := range showDetailRes.Data {
|
||
showUids = append(showUids, v.ShowUID)
|
||
}
|
||
fmt.Println("EntertainmentSetDefaultValue start---showUids:", showUids)
|
||
if len(showUids) > 0 {
|
||
go func() {
|
||
err = EntertainmentSetDefaultValue(showUids...)
|
||
fmt.Println("EntertainmentSetDefaultValue end---err:", err)
|
||
if err != nil {
|
||
zap.L().Error("更新招待数据中的出行信息失败", zap.Error(err))
|
||
}
|
||
}()
|
||
}
|
||
}()
|
||
policys := make([]*artShow.PricePolicy, 0)
|
||
for i := 0; i < len(showDetailRes.Data); i++ {
|
||
if showDetailRes.Data[i].HasFormula == e.HasFormula {
|
||
policy := new(artShow.PricePolicy)
|
||
policy.ShowUID = showDetailRes.Data[i].ShowUID
|
||
policy.ArtistUID = showDetailRes.Data[i].ArtistUID
|
||
policy.ArtistName = showDetailRes.Data[i].ArtistName
|
||
policy.Factor = new(artShow.PricePolicyFactor)
|
||
honorCountReq := new(artist.HonorCountReq)
|
||
honorCountReq.ArtistUid = showDetailRes.Data[i].ArtistUID
|
||
honorCountResp, err := service.GrpcArtistImpl.HonorCount(c, honorCountReq)
|
||
if err != nil {
|
||
return "", errors.New(e.ErrorQueryHonorInfo)
|
||
}
|
||
//policy.Factor.PaintingCount = showDetailRes.Data[i].ArtworkNum
|
||
//policy.Factor.AverageCanvasSize = float32(math.Round(float64(showDetailRes.Data[i].Ruler / showDetailRes.Data[i].ArtworkNum)))
|
||
//policy.Factor.TaifengExhibitionCount = float32(honorCountResp.CaaJoinYear)
|
||
policy.Factor.MeixieYears = float32(honorCountResp.CaaJoinYear)
|
||
policy.Factor.ExternalExhibitionCount = float32(honorCountResp.Exhibition)
|
||
policy.Factor.ArtistProfessionalismIndex = float32(honorCountResp.Professionalism)
|
||
policy.Factor.ArtistCollectibilityIndex = float32(honorCountResp.Collectible)
|
||
policy.Factor.ArtistExperienceEducationIndex = float32(honorCountResp.Education)
|
||
policy.Factor.ArtistInfluencePopularityIndex = float32(honorCountResp.Influence)
|
||
policy.Factor.StudyAbroadExperienceCount = float32(honorCountResp.StudyTourCount)
|
||
policy.Factor.AwardExperienceCount = float32(honorCountResp.AwardCount)
|
||
policy.Factor.NationalTitleCount = float32(honorCountResp.NationTitleCount)
|
||
policy.Factor.ProvincialTitleCount = float32(honorCountResp.ProvinceTitleCount)
|
||
policy.Factor.OtherTitleCount = float32(honorCountResp.OtherTitleCount)
|
||
policy.Factor.PublishedPaintingCount = float32(honorCountResp.ArtworkPublishCount)
|
||
policy.Factor.ExternalExhibitionCount = float32(honorCountResp.OutsidePublishCount)
|
||
policy.Factor.AcademicPublicationCount = float32(honorCountResp.AcademicPublishCount)
|
||
policy.Factor.ThirdPartyCuratorComment = float32(honorCountResp.ThirdCommentCount)
|
||
policys = append(policys, policy)
|
||
fmt.Println("================================= policy --------------------------------------")
|
||
fmt.Printf("policy %+v\n", policy)
|
||
fmt.Println("================================= policy --------------------------------------")
|
||
}
|
||
}
|
||
|
||
showApplyReq.Rel = showRels
|
||
showApplyReq.PricePolicy = policys
|
||
|
||
fmt.Println("================================= showApplyReq --------------------------------------")
|
||
fmt.Printf("showApplyReq %+v\n", showApplyReq)
|
||
fmt.Println("================================= showApplyReq --------------------------------------")
|
||
|
||
showApplyRes, err := service.GrpcArtShowImpl.UpdateApply(c, showApplyReq)
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
fmt.Println("画展经纪人请求", UpdateArtShowAgentList)
|
||
updateArtShowAgentRes, err := service.GrpcArtShowImpl.UpdateArtShowAgent(c, &artShow.UpdateArtShowAgentReq{Data: UpdateArtShowAgentList})
|
||
fmt.Println("画展经纪人请求后", updateArtShowAgentRes, err)
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 添加 画作销售站点
|
||
err = AddSaleAddress(detailRes)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 通过 rabbitmq 发送 到 画家系统 用于 确认 是否 参加画展
|
||
//artistUIDs := make([]string, 0)
|
||
//
|
||
//for i := 0; i < len(detailRes.Exhibition.ApprovalExhibitions); i++ {
|
||
// artistUIDs = append(artistUIDs, detailRes.Exhibition.ApprovalExhibitions[i].ArtExhibitionDetail.ArtistUID)
|
||
//}
|
||
|
||
//bt, err := json.Marshal(&artistUIDs)
|
||
//fmt.Println("========================== send =====================")
|
||
//fmt.Printf("send msg to mq : %+v", artistUIDs)
|
||
//fmt.Println("========================== send =====================")
|
||
//fmt.Println()
|
||
//mq.SendToArtShowPass(bt)
|
||
|
||
return showApplyRes.ApplyUID, nil
|
||
|
||
}
|
||
|
||
func passSynToArtShow(c *gin.Context, ID uint64) (string, error) {
|
||
|
||
var detailReq api.DetailRequest
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
detailReq.UserId = userInfo.ID
|
||
detailReq.ID = ID
|
||
fmt.Println("passSynToArtShow---1")
|
||
detailRes, err3 := service.ApprovalProvider.Detail(c, &detailReq)
|
||
if err3 != nil {
|
||
return "", err3
|
||
}
|
||
fmt.Println("passSynToArtShow---2")
|
||
if detailRes.Type != "exhibition" {
|
||
return "", nil
|
||
}
|
||
|
||
fmt.Println("passSynToArtShow---3")
|
||
if detailRes.Status != 2 { // 2 表示 此审批 未通过
|
||
return "", nil
|
||
}
|
||
|
||
fmt.Println("passSynToArtShow---4")
|
||
// 审批 通过 通知 画展包微服务 记录
|
||
req := detailRes
|
||
|
||
now := time.Now()
|
||
datestr := now.Format("2006-01-02 15:04:05")
|
||
showRels := make([]*artShow.ShowRel, 0)
|
||
showUIDs := make([]string, 0)
|
||
var UpdateArtShowAgentList []*artShow.ArtShowAgent
|
||
|
||
fmt.Println("passSynToArtShow---5")
|
||
showApplyReq := &artShow.SaveApplyReq{
|
||
ApplyUID: req.Exhibition.ApplyID,
|
||
Applicant: req.SubmitterName,
|
||
ApplicantID: strconv.FormatUint(req.SubmitterID, 10),
|
||
Num: int32(len(req.Exhibition.ApprovalExhibitions)),
|
||
ApplyTime: datestr,
|
||
Status: int32(req.Status),
|
||
}
|
||
showApplyReq.PricePolicy = make([]*artShow.PricePolicy, 0)
|
||
|
||
fmt.Println("passSynToArtShow---6")
|
||
for index, tt := range req.Exhibition.ApprovalExhibitions {
|
||
temp := &artShow.ShowRel{
|
||
ShowUID: tt.PackageID,
|
||
Index: int32((index + 1)),
|
||
Address: tt.Address,
|
||
ShowTime: tt.ShowDate,
|
||
ApplyUID: req.Exhibition.ApplyID,
|
||
}
|
||
|
||
UpdateArtShowAgentList = append(UpdateArtShowAgentList, &artShow.ArtShowAgent{
|
||
ShowUID: tt.PackageID,
|
||
Agent: tt.ArtExhibitionDetail.Agent,
|
||
})
|
||
|
||
showRels = append(showRels, temp)
|
||
showUIDs = append(showUIDs, tt.PackageID)
|
||
}
|
||
fmt.Println("passSynToArtShow---7")
|
||
showDetail := new(artShow.ShowDetailReq)
|
||
showDetail.ShowUID = showUIDs
|
||
showDetailRes, err := service.GrpcArtShowImpl.ShowDetail(c, showDetail)
|
||
if err != nil {
|
||
return "", errors.New(e.ErrorQueryArtShowInfo)
|
||
}
|
||
|
||
//使用邀请函中的数据更新出行信息
|
||
defer func() {
|
||
fmt.Println("passSynToArtShow---8")
|
||
var showUids []string
|
||
for _, v := range showDetailRes.Data {
|
||
showUids = append(showUids, v.ShowUID)
|
||
}
|
||
fmt.Println("EntertainmentSetDefaultValue start---showUids:", showUids)
|
||
if len(showUids) > 0 {
|
||
go func() {
|
||
err = EntertainmentSetDefaultValue(showUids...)
|
||
fmt.Println("EntertainmentSetDefaultValue end---err:", err)
|
||
if err != nil {
|
||
zap.L().Error("更新招待数据中的出行信息失败", zap.Error(err))
|
||
}
|
||
}()
|
||
}
|
||
}()
|
||
policys := make([]*artShow.PricePolicy, 0)
|
||
for i := 0; i < len(showDetailRes.Data); i++ {
|
||
if showDetailRes.Data[i].HasFormula == e.HasFormula {
|
||
policy := new(artShow.PricePolicy)
|
||
policy.ShowUID = showDetailRes.Data[i].ShowUID
|
||
policy.ArtistUID = showDetailRes.Data[i].ArtistUID
|
||
policy.ArtistName = showDetailRes.Data[i].ArtistName
|
||
policy.Factor = new(artShow.PricePolicyFactor)
|
||
honorCountReq := new(artist.HonorCountReq)
|
||
honorCountReq.ArtistUid = showDetailRes.Data[i].ArtistUID
|
||
honorCountResp, err := service.GrpcArtistImpl.HonorCount(c, honorCountReq)
|
||
if err != nil {
|
||
return "", errors.New(e.ErrorQueryHonorInfo)
|
||
}
|
||
//policy.Factor.PaintingCount = showDetailRes.Data[i].ArtworkNum
|
||
//policy.Factor.AverageCanvasSize = float32(math.Round(float64(showDetailRes.Data[i].Ruler / showDetailRes.Data[i].ArtworkNum)))
|
||
//policy.Factor.TaifengExhibitionCount = float32(honorCountResp.CaaJoinYear)
|
||
policy.Factor.MeixieYears = float32(honorCountResp.CaaJoinYear)
|
||
policy.Factor.ExternalExhibitionCount = float32(honorCountResp.Exhibition)
|
||
policy.Factor.ArtistProfessionalismIndex = float32(honorCountResp.Professionalism)
|
||
policy.Factor.ArtistCollectibilityIndex = float32(honorCountResp.Collectible)
|
||
policy.Factor.ArtistExperienceEducationIndex = float32(honorCountResp.Education)
|
||
policy.Factor.ArtistInfluencePopularityIndex = float32(honorCountResp.Influence)
|
||
policy.Factor.StudyAbroadExperienceCount = float32(honorCountResp.StudyTourCount)
|
||
policy.Factor.AwardExperienceCount = float32(honorCountResp.AwardCount)
|
||
policy.Factor.NationalTitleCount = float32(honorCountResp.NationTitleCount)
|
||
policy.Factor.ProvincialTitleCount = float32(honorCountResp.ProvinceTitleCount)
|
||
policy.Factor.OtherTitleCount = float32(honorCountResp.OtherTitleCount)
|
||
policy.Factor.PublishedPaintingCount = float32(honorCountResp.ArtworkPublishCount)
|
||
policy.Factor.ExternalExhibitionCount = float32(honorCountResp.OutsidePublishCount)
|
||
policy.Factor.AcademicPublicationCount = float32(honorCountResp.AcademicPublishCount)
|
||
policy.Factor.ThirdPartyCuratorComment = float32(honorCountResp.ThirdCommentCount)
|
||
policys = append(policys, policy)
|
||
fmt.Println("================================= policy --------------------------------------")
|
||
fmt.Printf("policy %+v\n", policy)
|
||
fmt.Println("================================= policy --------------------------------------")
|
||
}
|
||
}
|
||
|
||
showApplyReq.Rel = showRels
|
||
showApplyReq.PricePolicy = policys
|
||
|
||
fmt.Println("================================= showApplyReq --------------------------------------")
|
||
fmt.Printf("showApplyReq %+v\n", showApplyReq)
|
||
fmt.Println("================================= showApplyReq --------------------------------------")
|
||
|
||
showApplyRes, err := service.GrpcArtShowImpl.UpdateApply(c, showApplyReq)
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
fmt.Println("画展经纪人请求", UpdateArtShowAgentList)
|
||
updateArtShowAgentRes, err := service.GrpcArtShowImpl.UpdateArtShowAgent(c, &artShow.UpdateArtShowAgentReq{Data: UpdateArtShowAgentList})
|
||
fmt.Println("画展经纪人请求后", updateArtShowAgentRes, err)
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 添加 画作销售站点
|
||
err = AddSaleAddress(detailRes)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 通过 rabbitmq 发送 到 画家系统 用于 确认 是否 参加画展
|
||
//artistUIDs := make([]string, 0)
|
||
//
|
||
//for i := 0; i < len(detailRes.Exhibition.ApprovalExhibitions); i++ {
|
||
// artistUIDs = append(artistUIDs, detailRes.Exhibition.ApprovalExhibitions[i].ArtExhibitionDetail.ArtistUID)
|
||
//}
|
||
//
|
||
//bt, err := json.Marshal(&artistUIDs)
|
||
//fmt.Println("========================== send =====================")
|
||
//fmt.Printf("send msg to mq : %+v", artistUIDs)
|
||
//fmt.Println("========================== send =====================")
|
||
//fmt.Println()
|
||
//mq.SendToArtShowPass(bt)
|
||
|
||
return showApplyRes.ApplyUID, nil
|
||
|
||
}
|
||
|
||
func UsedNumByUser(c *gin.Context) {
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
|
||
levelReq := api.UsedNumByUserRequest{
|
||
SubmitterID: userInfo.ID,
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.UsedNumByUser(c, &levelReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
service.Success(c, res)
|
||
}
|
||
|
||
// SetStatusEx ID Status UserId
|
||
func SetStatusEx(c *gin.Context) {
|
||
var req api.StatusRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
infoReq := account2.InfoRequest{ID: req.UserId}
|
||
|
||
infoRes, err := service.AccountProvider.Info(context.Background(), &infoReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, errors.New(e.GetMsg(e.ErrorGetUserInfo)))
|
||
return
|
||
}
|
||
|
||
if infoRes.Info.ID == 0 || infoRes.Info.NickName == "" || infoRes.Info.Domain == "" {
|
||
service.Error(c, e.Error, errors.New(e.GetMsg(e.ErrorGetUserInfo)))
|
||
return
|
||
}
|
||
|
||
userInfo := login.Info{
|
||
ID: req.UserId,
|
||
NickName: infoRes.Info.NickName,
|
||
}
|
||
|
||
levelReq := api.NowLevelByInfoRequest{
|
||
ApprovalID: req.ID,
|
||
}
|
||
|
||
levelRes, err := service.ApprovalProvider.NowLevelByInfo(c, &levelReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if req.UserId != levelRes.UserID {
|
||
service.Error(c, e.Error, errors.New("本次审批人出现错误"))
|
||
return
|
||
}
|
||
|
||
req.WorkFlowId = levelRes.ID
|
||
|
||
beforeApproval := QueryApprovalSetStatusBefore(req.ID)
|
||
|
||
res, err := service.ApprovalProvider.SetStatus(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
detailReq := api.DetailRequest{ID: req.ID}
|
||
detail, err := service.ApprovalProvider.Detail(c, &detailReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if detail.TypeName == "任命审批" {
|
||
StoreBaiduChainApprovalFile(req.ID)
|
||
}
|
||
|
||
// 审批成功查询用户部门的信息,提交画作服修改画作仓库状态
|
||
|
||
if detail.TypeName == "画作申请审批" {
|
||
var ids []int32
|
||
for _, tt := range detail.Work.ApprovalWorks {
|
||
ids = append(ids, int32(tt.ArtworkID))
|
||
}
|
||
|
||
fmt.Println("请求画作申请审批", ids)
|
||
if len(ids) > 0 {
|
||
err = submitArtwork(req.UserId, ids)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
// approval 审批状态 同步到 oa 审批
|
||
if e.TypeMap[detail.Type] == "oa" {
|
||
// 查询 审批状态已经 更新的 审批信息
|
||
updatedReq := api.DetailRequest{ID: req.ID}
|
||
updatedDetail, detailErr := service.ApprovalProvider.Detail(c, &updatedReq)
|
||
if detailErr != nil {
|
||
service.Error(c, e.Error, detailErr)
|
||
return
|
||
}
|
||
|
||
if req.LeaveBalance != 0 && updatedDetail.ApprovalOA.LeaveApply != nil {
|
||
//leaveBalance, _ := strconv.ParseFloat(req.LeaveBalance, 10)
|
||
updatedDetail.ApprovalOA.LeaveApply.LeaveBalance = req.LeaveBalance
|
||
}
|
||
|
||
_, updateErr := UpdateApprovalStatusToOAStatus(updatedDetail)
|
||
if updateErr != nil {
|
||
service.Error(c, e.Error, updateErr)
|
||
return
|
||
}
|
||
}
|
||
|
||
if _, err := passSynToArtShowNotLogin(c, req.ID, req.UserId); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if _, err := passSynToShowRelUpdateNotLogin(c, req.ID, req.UserId); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if detail.Type == TypeExhibition && beforeApproval.Status == e.ApprovalWorkStatusDoing && req.Status == e.ApprovalWorkStatusFail { //取消通知画展包
|
||
err = CancelArtShowApply(detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
_ = PassUpdate(c, req.ID)
|
||
|
||
if detail.TypeName == "人员增补申请" {
|
||
//userInfo := login.GetUserInfoFromC(c)
|
||
if req.Status == e.ApprovalWorkStatusFail {
|
||
err = rejectPostApprove(userInfo, req.ID, req.Reply)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
} else if req.Status == e.ApprovalWorkStatusOk {
|
||
err = passPostApprove(userInfo, req.ID)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
if strings.Contains(detail.Type, "employ") {
|
||
err := offerApproveSetStatusEnter(c, userInfo, &req, detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
//if detail.Type == "employ" {
|
||
// //userInfo := login.GetUserInfoFromC(c)
|
||
// if req.Status == e.ApprovalWorkStatusFail {
|
||
// err = rejectOfferApprove(userInfo, req.ID, req.Reply)
|
||
// if err != nil {
|
||
// service.Error(c, e.Error, err)
|
||
// return
|
||
// }
|
||
// } else if req.Status == e.ApprovalWorkStatusOk {
|
||
// err = passOfferApproveNotFinish(userInfo, req.ID)
|
||
// if err != nil {
|
||
// service.Error(c, e.Error, err)
|
||
// return
|
||
// }
|
||
// }
|
||
|
||
//if detail.Status == e.ApprovalWorkStatusOk {
|
||
//
|
||
// registerUser := union.User{
|
||
// NickName: detail.Employ.Name,
|
||
// TelNum: detail.Employ.Mobile,
|
||
// EnterDate: detail.Employ.EntryTime,
|
||
// PositionUsers: nil,
|
||
// JobNum: detail.Employ.EmployeeNo,
|
||
// Password: InitPassword,
|
||
// }
|
||
// registerUser.PositionUsers = make([]*position.PositionUser, 0)
|
||
// registerUser.PositionUsers = append(registerUser.PositionUsers, &position.PositionUser{PositionName: detail.Employ.Post, DepartmentName: detail.Employ.BelongDepartment})
|
||
// err, _ = account.UserRegisters(c, registerUser)
|
||
// if err != nil {
|
||
// service.Error(c, e.Error, err)
|
||
// return
|
||
// }
|
||
//}
|
||
//}
|
||
|
||
if detail.Type == "checkIn" && detail.Status == e.ApprovalWorkStatusOk {
|
||
err = passSendInfoToSiteSignIn(detail.CheckIn)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func SetStatus(c *gin.Context) {
|
||
var req vo.SetStatus
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
|
||
levelReq := api.NowLevelByInfoRequest{
|
||
ApprovalID: req.ID,
|
||
}
|
||
|
||
levelRes, err := service.ApprovalProvider.NowLevelByInfo(c, &levelReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if userInfo.ID != levelRes.UserID {
|
||
service.Error(c, e.Error, errors.New("本次审批人出现错误"))
|
||
return
|
||
}
|
||
|
||
req.WorkFlowId = levelRes.ID
|
||
fmt.Println("============== 打印 StatusRequest内容 ========== 开始 =========")
|
||
fmt.Printf("StatusRequest is : %+v \n", req)
|
||
fmt.Println("============== 打印 StatusRequest内容 ========== 结束 =========")
|
||
|
||
// 查询 未审批前的审批
|
||
beforeApproval := QueryApprovalSetStatusBefore(req.ID)
|
||
|
||
newReq := new(api.StatusRequest)
|
||
newReq.Status = req.Status
|
||
newReq.ID = req.ID
|
||
newReq.WorkFlowId = req.WorkFlowId
|
||
newReq.LeaveBalance = req.LeaveBalance
|
||
newReq.Title = req.Title
|
||
newReq.Reply = req.Reply
|
||
newReq.Tips = req.Tips
|
||
|
||
res, err := service.ApprovalProvider.SetStatus(c, newReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
detailReq := api.DetailRequest{ID: req.ID}
|
||
detail, err := service.ApprovalProvider.Detail(c, &detailReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if req.Title == "任命审批" {
|
||
StoreBaiduChainApprovalFile(req.ID)
|
||
}
|
||
|
||
// 审批成功查询用户部门的信息,提交画作服修改画作仓库状态
|
||
var artworkReq artwork_query.UpdateAwStockStatusRequest
|
||
if err = c.ShouldBindBodyWith(&artworkReq, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if req.Title == "画作申请审批" {
|
||
err = submitArtwork(userInfo.ID, artworkReq.ArtworkIds)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if _, err := passSynToArtShow(c, req.ID); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
// approval 审批状态 同步到 oa 审批
|
||
if e.TypeMap[detail.Type] == "oa" {
|
||
// 查询 审批状态已经 更新的 审批信息
|
||
updatedReq := api.DetailRequest{ID: req.ID}
|
||
updatedDetail, detailErr := service.ApprovalProvider.Detail(c, &updatedReq)
|
||
if detailErr != nil {
|
||
service.Error(c, e.Error, detailErr)
|
||
return
|
||
}
|
||
|
||
if req.LeaveBalance != 0 && updatedDetail.ApprovalOA.LeaveApply != nil {
|
||
//leaveBalance, _ := strconv.ParseFloat(req.LeaveBalance, 10)
|
||
updatedDetail.ApprovalOA.LeaveApply.LeaveBalance = req.LeaveBalance
|
||
}
|
||
|
||
_, updateErr := UpdateApprovalStatusToOAStatus(updatedDetail)
|
||
if updateErr != nil {
|
||
service.Error(c, e.Error, updateErr)
|
||
return
|
||
}
|
||
}
|
||
|
||
if _, err := passSynToShowRelUpdate(c, req.ID); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if detail.Type == TypeExhibition && beforeApproval.Status == e.ApprovalWorkStatusDoing && req.Status == e.ApprovalWorkStatusFail { //取消通知画展包
|
||
err = CancelArtShowApply(detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
_ = PassUpdate(c, req.ID)
|
||
|
||
if req.Title == "人员增补申请" {
|
||
if req.Status == e.ApprovalWorkStatusFail {
|
||
err = rejectPostApprove(userInfo, req.ID, req.Reply)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
} else if req.Status == e.ApprovalWorkStatusOk {
|
||
err = passPostApprove(userInfo, req.ID)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
if strings.Contains(detail.Type, "employ") {
|
||
if req.Status == e.ApprovalWorkStatusFail {
|
||
err = rejectOfferApprove(userInfo, req.ID, req.Reply)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
} else if req.Status == e.ApprovalWorkStatusOk {
|
||
err = passOfferApproveNotFinish(userInfo, req.ID)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if detail.Status == e.ApprovalWorkStatusOk {
|
||
/*
|
||
registerUser := union.User{
|
||
NickName: detail.Employ.Name,
|
||
TelNum: detail.Employ.Mobile,
|
||
EnterDate: detail.Employ.EntryTime,
|
||
PositionUsers: nil,
|
||
JobNum: detail.Employ.EmployeeNo,
|
||
Password: InitPassword,
|
||
}
|
||
registerUser.PositionUsers = make([]*position.PositionUser, 0)
|
||
registerUser.PositionUsers = append(registerUser.PositionUsers, &position.PositionUser{PositionName: detail.Employ.Post, DepartmentName: detail.Employ.BelongDepartment})
|
||
err, _ = account.UserRegisters(c, registerUser)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
*/
|
||
}
|
||
}
|
||
|
||
if detail.Type == "checkIn" && detail.Status == e.ApprovalWorkStatusOk {
|
||
err = passSendInfoToSiteSignIn(detail.CheckIn)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if req.Status == e.ApprovalWorkStatusFail {
|
||
workReq := api.ListRequest{
|
||
ApprovedBossId: userInfo.ID,
|
||
ApprovalStatus: req.RetStatus,
|
||
Type: detail.Type,
|
||
}
|
||
|
||
if workReq.OrderBy == "" {
|
||
workReq.OrderBy = "desc"
|
||
}
|
||
|
||
workRes, err := service.ApprovalProvider.MyWork(c, &workReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
service.Success(c, workRes)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
// PassUpdate 通过去修改画展信息
|
||
func PassUpdate(c *gin.Context, id uint64) error {
|
||
|
||
detailReq := api.DetailRequest{ID: id}
|
||
detail, err := service.ApprovalProvider.Detail(c, &detailReq)
|
||
|
||
if err != nil {
|
||
fmt.Println("查询失败", err)
|
||
return nil
|
||
}
|
||
|
||
if detail.Status != e.ApprovalWorkStatusOk {
|
||
return nil
|
||
}
|
||
|
||
if detail.Exhibition == nil || len(detail.Exhibition.ApprovalExhibitions) <= 0 {
|
||
fmt.Println("不存在绑定画展包内容")
|
||
return nil
|
||
}
|
||
|
||
//是exhibition
|
||
/* if detail.Type == TypeExhibition { //
|
||
|
||
var UpdateArtworkSaleAddressList []*artShow.ArtworkSaleAddress
|
||
var UpdateArtShowAgentList []*artShow.ArtShowAgent
|
||
var artWorks []*artwork_third_party.UpdateAwSaleInfoReq_Info
|
||
for _, t := range detail.Exhibition.ApprovalExhibitions {
|
||
for _, tt := range t.Artworks {
|
||
temp := &artShow.ArtworkSaleAddress{ArtworkPriceUid: tt.ArtworkPriceUID, SaleAddress: tt.SaleAddress}
|
||
UpdateArtworkSaleAddressList = append(UpdateArtworkSaleAddressList, temp)
|
||
intNum, err := strconv.ParseInt(tt.SaleAddressID, 10, 32)
|
||
if err != nil {
|
||
intNum = 0
|
||
}
|
||
arwTemp := &artwork_third_party.UpdateAwSaleInfoReq_Info{ArtworkUuid: tt.ArtworkUID, SaleAddress: tt.SaleAddress, SaleId: int32(intNum)}
|
||
artWorks = append(artWorks, arwTemp)
|
||
}
|
||
|
||
UpdateArtShowAgentList = append(UpdateArtShowAgentList, &artShow.ArtShowAgent{
|
||
ShowUID: t.PackageID,
|
||
Agent: t.ArtExhibitionDetail.Agent,
|
||
})
|
||
}
|
||
|
||
if len(UpdateArtworkSaleAddressList) <= 0 {
|
||
return nil
|
||
}
|
||
|
||
//通知画展
|
||
UpdateArtworkSaleAddressReq := &artShow.UpdateArtworkSaleAddressReq{Data: UpdateArtworkSaleAddressList}
|
||
|
||
fmt.Println("画展请求", UpdateArtworkSaleAddressReq)
|
||
UpdateArtworkSaleAddressRes, err := service.GrpcArtShowImpl.UpdateArtworkSaleAddress(c, UpdateArtworkSaleAddressReq)
|
||
fmt.Println("画展请求后", UpdateArtworkSaleAddressRes, err)
|
||
|
||
fmt.Println("画展经纪人请求", UpdateArtShowAgentList)
|
||
updateArtShowAgentRes, err := service.GrpcArtShowImpl.UpdateArtShowAgent(c, &artShow.UpdateArtShowAgentReq{Data: UpdateArtShowAgentList})
|
||
fmt.Println("画展经纪人请求后", updateArtShowAgentRes, err)
|
||
|
||
//通知画作
|
||
saleReq := &artwork_third_party.UpdateAwSaleInfoReq{Data: artWorks}
|
||
|
||
fmt.Println("画作请求", saleReq)
|
||
saleRes, err := service.GrpcArtworkThirdPartyImpl.UpdateAwSaleInfo(c, saleReq)
|
||
fmt.Println("画作请求后", saleRes, err)
|
||
|
||
} */
|
||
if detail.Type == TypeArtExhibitionReward { //价格
|
||
|
||
//通知画展
|
||
var list []*artShow.ArtworkReward
|
||
var artWorks []*artwork_third_party.UpdateAwInfoReq_Info
|
||
|
||
for _, t := range detail.Exhibition.ApprovalExhibitions {
|
||
for _, tt := range t.Artworks {
|
||
temp := &artShow.ArtworkReward{ArtworkPriceUid: tt.ArtworkPriceUID, Reward: tt.Reward}
|
||
list = append(list, temp)
|
||
|
||
distFloat, err := strconv.ParseFloat(tt.Reward, 32)
|
||
|
||
if err != nil {
|
||
distFloat = 0
|
||
}
|
||
|
||
arwTemp := &artwork_third_party.UpdateAwInfoReq_Info{ArtworkUuid: tt.ArtworkUID, PriceRun: wrapperspb.Float(float32(distFloat))}
|
||
artWorks = append(artWorks, arwTemp)
|
||
}
|
||
}
|
||
|
||
if len(list) <= 0 {
|
||
return nil
|
||
}
|
||
|
||
req := &artShow.UpdateArtworkRewardReq{Data: list}
|
||
|
||
fmt.Println("请求", req)
|
||
res, err := service.GrpcArtShowImpl.UpdateArtworkReward(c, req)
|
||
fmt.Println("请求后", res, err)
|
||
fmt.Println(res, err)
|
||
//通知画作
|
||
|
||
//通知画作
|
||
saleReq := &artwork_third_party.UpdateAwInfoReq{Data: artWorks}
|
||
|
||
fmt.Println("画作请求", saleReq)
|
||
saleRes, err := service.GrpcArtworkThirdPartyImpl.UpdateAwInfo(c, saleReq)
|
||
fmt.Println("画作请求后", saleRes, err)
|
||
|
||
}
|
||
|
||
return nil
|
||
}
|
||
|
||
func cancelApply(c *gin.Context, detail *api.CreateRequest) (err error) {
|
||
|
||
fmt.Println("取消画展包", detail)
|
||
if detail.Type != TypeExhibition {
|
||
return nil
|
||
}
|
||
|
||
if detail.Exhibition == nil {
|
||
return nil
|
||
}
|
||
|
||
if detail.Exhibition.ApplyID == "" {
|
||
return nil
|
||
}
|
||
|
||
delReq := artShow.DelApplyReq{ApplyUID: []string{detail.Exhibition.ApplyID}}
|
||
|
||
fmt.Println("取消画展包:req", delReq)
|
||
r, err := service.GrpcArtShowImpl.DelApply(c, &delReq)
|
||
fmt.Println("取消画展包:res", r, err)
|
||
return err
|
||
}
|
||
|
||
func submitArtwork(adminId uint64, artworkIds []int32) (err error) {
|
||
uReq := rule.RulesRequest{
|
||
AccountID: adminId,
|
||
}
|
||
//获取用户信息
|
||
posResp, err := service.RuleProvider.UserInfo(context.Background(), &uReq)
|
||
if err != nil {
|
||
logger.Errorf("submitArtwork UserInfo err", err)
|
||
err = errors.New(e.GetMsg(e.ErrorGetUserInfo))
|
||
return
|
||
}
|
||
if posResp == nil || posResp.PositionUsers == nil {
|
||
err = errors.New(e.GetMsg(e.ErrorGetDepart))
|
||
return
|
||
}
|
||
var postName string
|
||
for _, v := range posResp.PositionUsers {
|
||
if v.PositionName == model.DepartDigiName {
|
||
postName = model.DepartDigiName
|
||
goto SendAwSto
|
||
} else if v.PositionName == model.DepartAuthName {
|
||
postName = model.DepartDigiName
|
||
goto SendAwSto
|
||
}
|
||
}
|
||
SendAwSto:
|
||
//发送画作状态
|
||
awReq := artwork_query.UpdateAwStockStatusRequest{
|
||
AdminId: int32(adminId),
|
||
PostName: postName,
|
||
ArtworkIds: artworkIds,
|
||
ActionType: model.AwStockStatusApproval,
|
||
}
|
||
_, err = service.GrpcArtworkQueryImpl.UpdateAwStockStatus(context.Background(), &awReq)
|
||
logger.Errorf("UpdateAwStockStatus err", err)
|
||
if err != nil {
|
||
err = errors.New(err.Error())
|
||
return
|
||
}
|
||
return
|
||
}
|
||
|
||
func Remove(c *gin.Context) {
|
||
var req api.RemoveRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
for i := 0; i < len(req.IDs); i++ {
|
||
// approval 审批状态 同步到 oa 审批
|
||
|
||
// 查询 审批状态已经 更新的 审批信息
|
||
updatedReq := api.DetailRequest{ID: req.IDs[i]}
|
||
updatedDetail, detailErr := service.ApprovalProvider.Detail(c, &updatedReq)
|
||
if detailErr != nil {
|
||
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
||
Msg: "获取审批信息失败",
|
||
Status: e.Failed,
|
||
})
|
||
return
|
||
}
|
||
|
||
if updatedDetail.ApprovalOA != nil {
|
||
_, updateErr := DeleteApproval(updatedDetail)
|
||
if updateErr != nil {
|
||
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
||
Msg: "更新OA审批信息失败",
|
||
Status: e.Failed,
|
||
})
|
||
return
|
||
}
|
||
}
|
||
|
||
if updatedDetail.StaffSupply != nil {
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
err := rollbackPost(userInfo, updatedDetail.ID)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if updatedDetail.Employ != nil {
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
if updatedDetail.Employ.ResumeID != "" {
|
||
err := rollbackOffer(userInfo, updatedDetail.ID)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
deleteApproval := req.IDs[i]
|
||
// 同步至 es
|
||
go func() {
|
||
updateErr := logic.DeleteIndexApprovalDoc(config.ApprovalIndex, deleteApproval)
|
||
if updateErr != nil {
|
||
zap.L().Error("同步至 es 失败 更新", zap.Error(updateErr))
|
||
return
|
||
}
|
||
}()
|
||
// 年假扣除清零
|
||
if strings.Contains(updatedDetail.Type, "turnover") {
|
||
updateDeductAnnualLeaveZeroClearing(updatedDetail.ApprovalOA.Turnover)
|
||
}
|
||
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.Remove(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
// PrintDetail 打印的信息详情
|
||
func PrintDetail(c *gin.Context) {
|
||
var req api.DetailRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
req.UserId = userInfo.ID
|
||
|
||
res, err := service.ApprovalProvider.Detail(c, &req)
|
||
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
accountInfo, err := account.GetUserInfoById(c, res.SubmitterID, "")
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
submitterInfo := vo.SubmitterInfo{
|
||
Name: accountInfo.NickName,
|
||
DepartmentName: accountInfo.DepartmentName,
|
||
TelNum: accountInfo.TelNum,
|
||
}
|
||
|
||
printerInfo := vo.PrinterInfo{
|
||
Name: userInfo.NickName,
|
||
TelNum: userInfo.TelNum,
|
||
}
|
||
|
||
var userIds []uint64
|
||
var copyUsers []string
|
||
var approvalUsers []string
|
||
var content []vo.ContentInfo
|
||
|
||
for _, tt := range res.CopyUsers {
|
||
userIds = append(userIds, tt.ID)
|
||
}
|
||
|
||
for _, tt := range res.WorkFlows {
|
||
userIds = append(userIds, tt.ID)
|
||
}
|
||
|
||
fmt.Println("1----查看", userIds)
|
||
departmentUserMap, err := department.GetDepartmentUsersMap(c, userIds)
|
||
fmt.Println("2----查看", departmentUserMap)
|
||
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
detailReq := api.TypeResponse{
|
||
Keyword: res.Type,
|
||
}
|
||
|
||
detailRes, err := service.ApprovalProvider.DetailType(c, &detailReq)
|
||
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
fmt.Println("2----查看", res)
|
||
for i, tt := range res.CopyUsers {
|
||
if _, ok := departmentUserMap[tt.ID]; ok {
|
||
temp := fmt.Sprintf("第%s抄送人: %s %s", common.TransferNum(i+1), departmentUserMap[tt.ID], tt.Name)
|
||
copyUsers = append(copyUsers, temp)
|
||
} else {
|
||
temp := fmt.Sprintf("第%s抄送人: %s", common.TransferNum(i+1), tt.Name)
|
||
copyUsers = append(copyUsers, temp)
|
||
}
|
||
}
|
||
|
||
//fmt.Println(res.WorkFlows)
|
||
//fmt.Println(departmentUserMap)
|
||
for i, tt := range res.WorkFlows {
|
||
passString := "审批中"
|
||
greetString := ""
|
||
if tt.Status == e.ApprovalWorkStatusOk {
|
||
passString = "通过"
|
||
greetString = "同意"
|
||
} else if tt.Status == e.ApprovalWorkStatusFail {
|
||
passString = "未通过"
|
||
greetString = "不同意"
|
||
}
|
||
if _, ok := departmentUserMap[tt.UserID]; ok {
|
||
temp := fmt.Sprintf("第%s审批人: %s %s %s %s %s", common.TransferNum(i+1), departmentUserMap[tt.ID], tt.Name, passString, tt.OperatedAt, greetString)
|
||
approvalUsers = append(approvalUsers, temp)
|
||
} else {
|
||
temp := fmt.Sprintf("第%s审批人: %s %s %s %s", common.TransferNum(i+1), tt.Name, passString, tt.OperatedAt, greetString)
|
||
approvalUsers = append(approvalUsers, temp)
|
||
}
|
||
}
|
||
|
||
if res.Type == e.TypeContent {
|
||
temp := vo.ContentInfo{
|
||
Info: res.Content,
|
||
Type: "string",
|
||
Title: "内容",
|
||
}
|
||
content = append(content, temp)
|
||
} else if res.Type == e.TypeShow {
|
||
temp := vo.ContentInfo{
|
||
Info: res.Content,
|
||
Type: "string",
|
||
Title: "具体内容",
|
||
}
|
||
content = append(content, temp)
|
||
} else if res.Type == e.TypeWork {
|
||
if res.Work != nil {
|
||
title := ""
|
||
for _, t := range res.Work.ApprovalWorks {
|
||
title = title + " " + t.ArtworkName
|
||
}
|
||
content = append(content, vo.ContentInfo{
|
||
Info: title,
|
||
Type: "string",
|
||
Title: "申请内容",
|
||
})
|
||
|
||
}
|
||
|
||
temp1 := vo.ContentInfo{
|
||
Info: res.Content,
|
||
Type: "string",
|
||
Title: "具体内容",
|
||
}
|
||
|
||
content = append(content, temp1)
|
||
} else if res.Type == e.TypeBundle {
|
||
if res.Bundle != nil {
|
||
temp := vo.ContentInfo{
|
||
Info: res.Bundle.ApplicationsNum,
|
||
Type: "num",
|
||
Title: "申请数量",
|
||
}
|
||
|
||
content = append(content, temp)
|
||
|
||
}
|
||
|
||
temp1 := vo.ContentInfo{
|
||
Info: res.Content,
|
||
Type: "string",
|
||
Title: "具体内容",
|
||
}
|
||
|
||
content = append(content, temp1)
|
||
} else if res.Type == e.TypeExhibition {
|
||
if res.Exhibition != nil {
|
||
|
||
for i, t := range res.Exhibition.ApprovalExhibitions {
|
||
content = append(content, vo.ContentInfo{
|
||
Info: t.ArtExhibitionDetail.ShowName,
|
||
Type: "string",
|
||
Title: "名称" + fmt.Sprintf("%d", i+1),
|
||
})
|
||
|
||
content = append(content, vo.ContentInfo{
|
||
Info: t.ShowDate,
|
||
Type: "string",
|
||
Title: "画展时间",
|
||
})
|
||
|
||
content = append(content, vo.ContentInfo{
|
||
Info: t.Address,
|
||
Type: "string",
|
||
Title: "画展地址",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: t.ArtExhibitionDetail.ArtistShowCount,
|
||
Type: "string",
|
||
Title: "画家名称",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: t.ArtExhibitionDetail.ArtworkNum,
|
||
Type: "string",
|
||
Title: "包含画作数量",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: t.ArtExhibitionDetail.Ruler,
|
||
Type: "string",
|
||
Title: "包含画作总平尺",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: t.ArtExhibitionDetail.Price,
|
||
Type: "string",
|
||
Title: "画作总价",
|
||
})
|
||
type ArtworkList struct {
|
||
Artworks []*api.Artwork `json:"Artworks"`
|
||
}
|
||
var artworkList ArtworkList
|
||
artworkList.Artworks = make([]*api.Artwork, 0)
|
||
artworkList.Artworks = t.Artworks
|
||
marshal, err := json.Marshal(artworkList)
|
||
if err != nil {
|
||
return
|
||
}
|
||
content = append(content, vo.ContentInfo{
|
||
Info: string(marshal),
|
||
Type: "artworkList",
|
||
Title: "画作列表",
|
||
})
|
||
//for _, artwork := range t.Artworks {
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: artwork.ArtworkName,
|
||
// Type: "string",
|
||
// Title: "画作名称",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: artwork.Tfnum,
|
||
// Type: "string",
|
||
// Title: "画作编号",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: artwork.ArtistShowCount,
|
||
// Type: "string",
|
||
// Title: "画家名称",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: artwork.Length,
|
||
// Type: "num",
|
||
// Title: "长",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: artwork.Width,
|
||
// Type: "num",
|
||
// Title: "宽",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: artwork.Ruler,
|
||
// Type: "num",
|
||
// Title: "平尺数",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: artwork.SaleAddress,
|
||
// Type: "string",
|
||
// Title: "销售站点",
|
||
// })
|
||
//}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
temp1 := vo.ContentInfo{
|
||
Info: res.Content,
|
||
Type: "string",
|
||
Title: "具体内容",
|
||
}
|
||
|
||
content = append(content, temp1)
|
||
} else if strings.Contains(res.Type, "turnover") {
|
||
if res.ApprovalOA != nil {
|
||
if res.ApprovalOA.Turnover != nil {
|
||
detail := res.ApprovalOA.Turnover
|
||
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ActionTime,
|
||
Type: "string",
|
||
Title: "申请日期",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.StaffName,
|
||
Type: "string",
|
||
Title: "申请人",
|
||
})
|
||
departments := ""
|
||
positions := ""
|
||
for index, applyPosition := range detail.Positions {
|
||
if index == 0 {
|
||
departments = applyPosition.DepartmentName
|
||
positions = applyPosition.PositionName
|
||
} else {
|
||
departments = departments + "|" + applyPosition.DepartmentName
|
||
positions = positions + "|" + applyPosition.PositionName
|
||
}
|
||
}
|
||
content = append(content, vo.ContentInfo{
|
||
Info: departments,
|
||
Type: "string",
|
||
Title: "部门",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: positions,
|
||
Type: "string",
|
||
Title: "岗位",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.StaffNum,
|
||
Type: "string",
|
||
Title: "工号",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.JoinTime,
|
||
Type: "string",
|
||
Title: "入职日期",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.LeftTime,
|
||
Type: "string",
|
||
Title: "离职日期",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Address,
|
||
Type: "string",
|
||
Title: "离职后住址",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ContactInfo,
|
||
Type: "string",
|
||
Title: "联系电话",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Reason,
|
||
Type: "string",
|
||
Title: "离职原因",
|
||
})
|
||
|
||
}
|
||
|
||
}
|
||
} else if strings.Contains(res.Type, "handover") {
|
||
if res.ApprovalOA != nil {
|
||
if res.ApprovalOA.Turnover != nil {
|
||
detail := res.ApprovalOA.Turnover
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.StaffName,
|
||
Type: "string",
|
||
Title: "申请人",
|
||
})
|
||
departments := ""
|
||
positions := ""
|
||
for index, applyPosition := range detail.Positions {
|
||
if index == 0 {
|
||
departments = applyPosition.DepartmentName
|
||
positions = applyPosition.PositionName
|
||
} else {
|
||
departments = departments + "|" + applyPosition.DepartmentName
|
||
positions = positions + "|" + applyPosition.PositionName
|
||
}
|
||
}
|
||
content = append(content, vo.ContentInfo{
|
||
Info: departments,
|
||
Type: "string",
|
||
Title: "部门",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: positions,
|
||
Type: "string",
|
||
Title: "岗位",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.StaffNum,
|
||
Type: "string",
|
||
Title: "工号",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.JoinTime,
|
||
Type: "string",
|
||
Title: "入职日期",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.LeftTime,
|
||
Type: "string",
|
||
Title: "离职日期",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Address,
|
||
Type: "string",
|
||
Title: "离职后住址",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ContactInfo,
|
||
Type: "string",
|
||
Title: "联系电话",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.HandoverName,
|
||
Type: "string",
|
||
Title: "交接人",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.SuperviseName,
|
||
Type: "string",
|
||
Title: "监交人",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.WorkItems,
|
||
Type: "string",
|
||
Title: "工作交接事项",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.FinanceItems,
|
||
Type: "string",
|
||
Title: "财务交接事项",
|
||
})
|
||
}
|
||
|
||
}
|
||
} else if strings.Contains(res.Type, "employ") {
|
||
if res.Employ != nil {
|
||
detail := res.Employ
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.BelongDepartment,
|
||
Type: "string",
|
||
Title: "归属部门",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Post,
|
||
Type: "string",
|
||
Title: "岗位名称",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Name,
|
||
Type: "string",
|
||
Title: "姓名",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Mobile,
|
||
Type: "string",
|
||
Title: "手机号",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.EmployeeType,
|
||
Type: "string",
|
||
Title: "员工类型",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.EntryTime,
|
||
Type: "string",
|
||
Title: "预计入职时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.EmployeeNo,
|
||
Type: "string",
|
||
Title: "工号",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Remark,
|
||
Type: "string",
|
||
Title: "备注",
|
||
})
|
||
}
|
||
|
||
} else if strings.Contains(res.Type, "staffSupply") {
|
||
if res.StaffSupply != nil {
|
||
detail := res.StaffSupply
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.DepartmentName,
|
||
Type: "string",
|
||
Title: "归属部门",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.PositionName,
|
||
Type: "string",
|
||
Title: "岗位名称",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Num,
|
||
Type: "num",
|
||
Title: "申请增补人数",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.JobAsk,
|
||
Type: "string",
|
||
Title: "岗位需求",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.JoinInTime,
|
||
Type: "string",
|
||
Title: "期待到职日期",
|
||
})
|
||
}
|
||
} else if strings.Contains(res.Type, "position") {
|
||
for _, tt := range res.CustomizeInfo {
|
||
if strings.Contains(tt.ApprovalType, "position") {
|
||
type PositionJson struct {
|
||
DepartmentID int32
|
||
DepartmentName string
|
||
PositionName string
|
||
}
|
||
var posi PositionJson
|
||
if err := json.Unmarshal([]byte(tt.ApprovalValue), &posi); err != nil {
|
||
return
|
||
}
|
||
temp := vo.ContentInfo{
|
||
Info: posi.DepartmentName + "-" + posi.PositionName,
|
||
Type: tt.ApprovalType,
|
||
Title: tt.ApprovalName,
|
||
}
|
||
content = append(content, temp)
|
||
} else {
|
||
temp := vo.ContentInfo{
|
||
Info: tt.ApprovalValue,
|
||
Type: tt.ApprovalType,
|
||
Title: tt.ApprovalName,
|
||
}
|
||
content = append(content, temp)
|
||
}
|
||
}
|
||
} else if res.Type == "promotion" {
|
||
if res.Promotion != nil {
|
||
detail := res.Promotion
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.StaffName + "(" + detail.StaffNum + ")",
|
||
Type: "string",
|
||
Title: "姓名",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.OldJob,
|
||
Type: "string",
|
||
Title: "原职务",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.NewJob,
|
||
Type: "string",
|
||
Title: "任命职务",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.EffectiveTime,
|
||
Type: "string",
|
||
Title: "生效日期",
|
||
})
|
||
}
|
||
} else if res.Type == "leave" ||
|
||
res.Type == "sick" ||
|
||
res.Type == "annualLeave" ||
|
||
res.Type == "dayOff" ||
|
||
res.Type == "maritalLeave" ||
|
||
res.Type == "matingCheckLeave" ||
|
||
res.Type == "maternityLeave" ||
|
||
res.Type == "paternityLeave" ||
|
||
res.Type == "parentalLeave" ||
|
||
res.Type == "nursingLeave" ||
|
||
res.Type == "funeralLeave" ||
|
||
res.Type == "abortLeave" ||
|
||
res.Type == "breastFeedingLeave" {
|
||
if res.ApprovalOA.Leave != nil {
|
||
detail := res.ApprovalOA.Leave
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ApplyTimes[0].Date + detail.ApplyTimes[0].Hour + detail.ApplyTimes[0].M,
|
||
Type: "string",
|
||
Title: "开始时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ApplyTimes[1].Date + detail.ApplyTimes[1].Hour + detail.ApplyTimes[1].M,
|
||
Type: "string",
|
||
Title: "结束时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Reason,
|
||
Type: "string",
|
||
Title: "理由",
|
||
})
|
||
}
|
||
|
||
} else if res.Type == "makeUp" {
|
||
if res.ApprovalOA.MakeUp != nil {
|
||
detail := res.ApprovalOA.MakeUp
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ApplyTimes[0].Date + detail.ApplyTimes[0].Hour + detail.ApplyTimes[0].M,
|
||
Type: "string",
|
||
Title: "补卡时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Reason,
|
||
Type: "string",
|
||
Title: "理由",
|
||
})
|
||
}
|
||
|
||
} else if res.Type == "overTime" {
|
||
if res.ApprovalOA.OverTime != nil {
|
||
detail := res.ApprovalOA.OverTime
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ApplyTimes[0].Date + detail.ApplyTimes[0].Hour + detail.ApplyTimes[0].M,
|
||
Type: "string",
|
||
Title: "开始时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ApplyTimes[1].Date + detail.ApplyTimes[1].Hour + detail.ApplyTimes[1].M,
|
||
Type: "string",
|
||
Title: "结束时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Reason,
|
||
Type: "string",
|
||
Title: "理由",
|
||
})
|
||
}
|
||
|
||
} else if res.Type == "outWork" {
|
||
if res.ApprovalOA.OutWork != nil {
|
||
detail := res.ApprovalOA.OutWork
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ApplyTimes[0].Date + detail.ApplyTimes[0].Hour + detail.ApplyTimes[0].M,
|
||
Type: "string",
|
||
Title: "开始时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ApplyTimes[1].Date + detail.ApplyTimes[1].Hour + detail.ApplyTimes[1].M,
|
||
Type: "string",
|
||
Title: "结束时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Reason,
|
||
Type: "string",
|
||
Title: "理由",
|
||
})
|
||
}
|
||
|
||
} else if res.Type == "businessTrip" {
|
||
if res.ApprovalOA.BusinessTrip != nil {
|
||
detail := res.ApprovalOA.BusinessTrip
|
||
for _, itinerary := range detail.ItineraryList {
|
||
content = append(content, vo.ContentInfo{
|
||
Info: itinerary.Vehicle,
|
||
Type: "string",
|
||
Title: "交通工具",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: itinerary.StartAddress,
|
||
Type: "string",
|
||
Title: "出发地",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: itinerary.EndAddress,
|
||
Type: "string",
|
||
Title: "目的地",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: itinerary.ApplyTimes[0].Date + itinerary.ApplyTimes[0].Hour + itinerary.ApplyTimes[0].M,
|
||
Type: "string",
|
||
Title: "开始时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: itinerary.ApplyTimes[1].Date + itinerary.ApplyTimes[1].Hour + itinerary.ApplyTimes[1].M,
|
||
Type: "string",
|
||
Title: "结束时间",
|
||
})
|
||
}
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Reason,
|
||
Type: "string",
|
||
Title: "理由",
|
||
})
|
||
|
||
}
|
||
|
||
} else if res.Type == "goOut" {
|
||
if res.ApprovalOA.GoOut != nil {
|
||
detail := res.ApprovalOA.GoOut
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ApplyTimes[0].Date + detail.ApplyTimes[0].Hour + detail.ApplyTimes[0].M,
|
||
Type: "string",
|
||
Title: "开始时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ApplyTimes[1].Date + detail.ApplyTimes[1].Hour + detail.ApplyTimes[1].M,
|
||
Type: "string",
|
||
Title: "结束时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Reason,
|
||
Type: "string",
|
||
Title: "理由",
|
||
})
|
||
|
||
}
|
||
|
||
} else if res.Type == "parentalLeaveApply" || res.Type == "nursingLeaveApply" {
|
||
if res.ApprovalOA.LeaveApply != nil {
|
||
detail := res.ApprovalOA.LeaveApply
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.LeaveBalance,
|
||
Type: "num",
|
||
Title: "申请天数",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.Reason,
|
||
Type: "string",
|
||
Title: "理由",
|
||
})
|
||
|
||
}
|
||
|
||
} else if res.Type == "bundlePayPrice" {
|
||
if res.BundlePayPrice != nil {
|
||
detail := res.BundlePayPrice
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ShowName,
|
||
Type: "string",
|
||
Title: "画展包名称",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ShowDate,
|
||
Type: "string",
|
||
Title: "画展时间",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ShowLowPrice,
|
||
Type: "string",
|
||
Title: "画展包底价",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ShowAddress,
|
||
Type: "string",
|
||
Title: "画展地址",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ArtistShowCount,
|
||
Type: "string",
|
||
Title: "画家名称",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ArtworkNum,
|
||
Type: "num",
|
||
Title: "作品数量",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: detail.ArtworkSize,
|
||
Type: "string",
|
||
Title: "作品总平尺",
|
||
})
|
||
|
||
}
|
||
|
||
} else if res.Type == "showUpdate" {
|
||
if res.ExhibitionHis != nil {
|
||
detail := res.ExhibitionHis
|
||
for _, hiss := range detail.ApprovalExhibitionHiss {
|
||
content = append(content, vo.ContentInfo{
|
||
Info: hiss.PackageName,
|
||
Type: "string",
|
||
Title: "画展包",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: hiss.ArtExhibitionDetail.ArtistShowCount,
|
||
Type: "string",
|
||
Title: "画家",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: hiss.ArtExhibitionDetail.Price,
|
||
Type: "num",
|
||
Title: "价格",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: hiss.ArtExhibitionDetail.Reward,
|
||
Type: "num",
|
||
Title: "润格",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: hiss.PackageSize,
|
||
Type: "num",
|
||
Title: "平尺数",
|
||
})
|
||
content = append(content, vo.ContentInfo{
|
||
Info: hiss.ShowDate,
|
||
Type: "string",
|
||
Title: "画展时间",
|
||
})
|
||
}
|
||
|
||
}
|
||
|
||
} else {
|
||
for _, tt := range res.CustomizeInfo {
|
||
temp := vo.ContentInfo{
|
||
Info: tt.ApprovalValue,
|
||
Type: tt.ApprovalType,
|
||
Title: tt.ApprovalName,
|
||
}
|
||
content = append(content, temp)
|
||
}
|
||
}
|
||
approvalInfo := vo.ApprovalPrintInfo{
|
||
Status: res.Status,
|
||
ApprovalNum: common.GenerateCode(res.ID),
|
||
CreatedAt: res.CreatedAt,
|
||
TypeString: detailRes.Title,
|
||
SubmitterInfo: submitterInfo,
|
||
PrinterInfo: printerInfo,
|
||
CopyUsers: copyUsers,
|
||
ApprovalUsers: approvalUsers,
|
||
ContentMap: content,
|
||
}
|
||
|
||
//switch res.Type {
|
||
//case e.TypeContent: //
|
||
// temp := vo.ContentInfo{
|
||
// Info: res.Content,
|
||
// Type: "string",
|
||
// Title: "内容",
|
||
// }
|
||
// content = append(content, temp)
|
||
//
|
||
//case e.TypeShow:
|
||
//
|
||
// temp := vo.ContentInfo{
|
||
// Info: res.Content,
|
||
// Type: "string",
|
||
// Title: "具体内容",
|
||
// }
|
||
// content = append(content, temp)
|
||
//
|
||
//case e.TypeWork:
|
||
//
|
||
// if res.Work != nil {
|
||
// temp := vo.ContentInfo{
|
||
// Info: res.Work.ReceivedAt,
|
||
// Type: "string",
|
||
// Title: "领取时间",
|
||
// }
|
||
//
|
||
// content = append(content, temp)
|
||
// title := ""
|
||
// for _, t := range res.Work.ApprovalWorks {
|
||
// title = title + " " + t.ArtworkName
|
||
// }
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: title,
|
||
// Type: "string",
|
||
// Title: "申请内容",
|
||
// })
|
||
//
|
||
// }
|
||
//
|
||
// temp1 := vo.ContentInfo{
|
||
// Info: res.Content,
|
||
// Type: "string",
|
||
// Title: "具体内容",
|
||
// }
|
||
//
|
||
// content = append(content, temp1)
|
||
//
|
||
//case e.TypeBundle:
|
||
// if res.Bundle != nil {
|
||
// temp := vo.ContentInfo{
|
||
// Info: res.Bundle.ApplicationsNum,
|
||
// Type: "num",
|
||
// Title: "申请数量",
|
||
// }
|
||
//
|
||
// content = append(content, temp)
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: res.Bundle.ReceivedAt,
|
||
// Type: "string",
|
||
// Title: "领取时间",
|
||
// })
|
||
//
|
||
// }
|
||
//
|
||
// temp1 := vo.ContentInfo{
|
||
// Info: res.Content,
|
||
// Type: "string",
|
||
// Title: "具体内容",
|
||
// }
|
||
//
|
||
// content = append(content, temp1)
|
||
//
|
||
//case e.TypeExhibition:
|
||
//
|
||
// if res.Exhibition != nil {
|
||
//
|
||
// for i, t := range res.Exhibition.ApprovalExhibitions {
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: t.ArtExhibitionDetail.ShowName,
|
||
// Type: "string",
|
||
// Title: "名称" + fmt.Sprintf("%d", i+1),
|
||
// })
|
||
//
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: t.ShowDate,
|
||
// Type: "string",
|
||
// Title: "画展时间",
|
||
// })
|
||
//
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: t.Address,
|
||
// Type: "string",
|
||
// Title: "画展地址",
|
||
// })
|
||
// }
|
||
//
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: res.Exhibition.ReceivedAt,
|
||
// Type: "string",
|
||
// Title: "领取时间",
|
||
// })
|
||
//
|
||
// }
|
||
//
|
||
// temp1 := vo.ContentInfo{
|
||
// Info: res.Content,
|
||
// Type: "string",
|
||
// Title: "具体内容",
|
||
// }
|
||
//
|
||
// content = append(content, temp1)
|
||
//
|
||
//case "turnover":
|
||
// if res.ApprovalOA != nil {
|
||
// if res.ApprovalOA.Turnover != nil {
|
||
// detail := res.ApprovalOA.Turnover
|
||
//
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.ActionTime,
|
||
// Type: "string",
|
||
// Title: "申请日期",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.StaffName,
|
||
// Type: "string",
|
||
// Title: "申请人",
|
||
// })
|
||
// departments := ""
|
||
// positions := ""
|
||
// for index, applyPosition := range detail.Positions {
|
||
// if index == 0 {
|
||
// departments = applyPosition.DepartmentName
|
||
// positions = applyPosition.PositionName
|
||
// } else {
|
||
// departments = departments + "|" + applyPosition.DepartmentName
|
||
// positions = positions + "|" + applyPosition.PositionName
|
||
// }
|
||
// }
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: departments,
|
||
// Type: "string",
|
||
// Title: "部门",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: positions,
|
||
// Type: "string",
|
||
// Title: "岗位",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.StaffNum,
|
||
// Type: "string",
|
||
// Title: "工号",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.JoinTime,
|
||
// Type: "string",
|
||
// Title: "入职日期",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.LeftTime,
|
||
// Type: "string",
|
||
// Title: "离职日期",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.Address,
|
||
// Type: "string",
|
||
// Title: "离职后住址",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.ContactInfo,
|
||
// Type: "string",
|
||
// Title: "联系电话",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.Reason,
|
||
// Type: "string",
|
||
// Title: "离职原因",
|
||
// })
|
||
//
|
||
// }
|
||
//
|
||
// }
|
||
//
|
||
//case "handover":
|
||
// if res.ApprovalOA != nil {
|
||
// if res.ApprovalOA.Turnover != nil {
|
||
// detail := res.ApprovalOA.Turnover
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.StaffName,
|
||
// Type: "string",
|
||
// Title: "申请人",
|
||
// })
|
||
// departments := ""
|
||
// positions := ""
|
||
// for index, applyPosition := range detail.Positions {
|
||
// if index == 0 {
|
||
// departments = applyPosition.DepartmentName
|
||
// positions = applyPosition.PositionName
|
||
// } else {
|
||
// departments = departments + "|" + applyPosition.DepartmentName
|
||
// positions = positions + "|" + applyPosition.PositionName
|
||
// }
|
||
// }
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: departments,
|
||
// Type: "string",
|
||
// Title: "部门",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: positions,
|
||
// Type: "string",
|
||
// Title: "岗位",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.StaffNum,
|
||
// Type: "string",
|
||
// Title: "工号",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.JoinTime,
|
||
// Type: "string",
|
||
// Title: "入职日期",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.LeftTime,
|
||
// Type: "string",
|
||
// Title: "离职日期",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.Address,
|
||
// Type: "string",
|
||
// Title: "离职后住址",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.ContactInfo,
|
||
// Type: "string",
|
||
// Title: "联系电话",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.HandoverName,
|
||
// Type: "string",
|
||
// Title: "交接人",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.SuperviseName,
|
||
// Type: "string",
|
||
// Title: "监交人",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.WorkItems,
|
||
// Type: "string",
|
||
// Title: "工作交接事项",
|
||
// })
|
||
// content = append(content, vo.ContentInfo{
|
||
// Info: detail.FinanceItems,
|
||
// Type: "string",
|
||
// Title: "财务交接事项",
|
||
// })
|
||
// }
|
||
//
|
||
// }
|
||
//default: //其它json
|
||
// for _, tt := range res.CustomizeInfo {
|
||
// temp := vo.ContentInfo{
|
||
// Info: tt.ApprovalValue,
|
||
// Type: tt.ApprovalType,
|
||
// Title: tt.ApprovalName,
|
||
// }
|
||
// content = append(content, temp)
|
||
// }
|
||
//}
|
||
|
||
service.Success(c, approvalInfo)
|
||
}
|
||
|
||
// Send 催办
|
||
func Send(c *gin.Context) {
|
||
var req api.DetailRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.Detail(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
nowUserInfo, err := account.GetUserInfoById(c, res.NowUserId, "")
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
url := fmt.Sprintf("https://erpapi.fontree.cn/approval7524164487E?id=%d&userId=%d", req.ID, res.NowUserId)
|
||
|
||
//todo 拉取了dev分支后,这个方法没有
|
||
shortUrl, err := utils.CreateShortUrl(url)
|
||
if err == nil {
|
||
url = shortUrl
|
||
}
|
||
|
||
msgReq := account2.SendCustomMsgRequest{
|
||
ID: res.NowUserId,
|
||
TelNum: nowUserInfo.TelNum,
|
||
MId: 136784,
|
||
SigNo: uint32(config.DefaultSignNo),
|
||
}
|
||
|
||
//亲爱用户,您有【】审批催办已经发送,请点击查看【】
|
||
fmt.Println("发送短信")
|
||
if err == nil {
|
||
msgReq.Url = res.TypeName + "|" + url
|
||
fmt.Println("发送短信", msgReq)
|
||
mres, err := service.AccountProvider.SendCustomMsg(c, &msgReq)
|
||
fmt.Println("发送短信返回", mres, err)
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func DetailEx(c *gin.Context) {
|
||
var st api.StatusRequest
|
||
if err := c.ShouldBindBodyWith(&st, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
req := api.DetailRequest{
|
||
ID: st.ID,
|
||
UserId: st.UserId,
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.Detail(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func Detail(c *gin.Context) {
|
||
var req api.DetailRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
req.UserId = userInfo.ID
|
||
|
||
res, err := service.ApprovalProvider.Detail(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func Update(c *gin.Context) {
|
||
var req api.CreateRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.Update(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
//修改附带
|
||
if _, err := passSynToArtShow(c, req.ID); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func MyWork(c *gin.Context) {
|
||
var req api.ListRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
req.UserID = userInfo.ID
|
||
|
||
if req.Status == 0 {
|
||
for i := 0; i < len(userInfo.PositionUsers); i++ {
|
||
if userInfo.PositionUsers[i].DepartmentName == "超级管理员" {
|
||
req.UserID = 0
|
||
}
|
||
}
|
||
}
|
||
|
||
if req.OrderBy == "" {
|
||
req.OrderBy = "desc"
|
||
}
|
||
|
||
if req.StartTime != "" && req.EndTime != "" {
|
||
req.StartTime = req.StartTime + " 00:00:00"
|
||
req.EndTime = req.EndTime + " 23:59:59"
|
||
req.OrderBy = "asc"
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.MyWork(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
// CheckBundlePay 画展包付款单申请下载的权限
|
||
func CheckBundlePay(c *gin.Context) {
|
||
var req api.IsExistPayRightRequest
|
||
resObj := vo.IsExist{IsPass: false}
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
req.UserId = userInfo.ID //我审批过的
|
||
|
||
res, err := service.ApprovalProvider.IsExistPayRight(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
resObj.IsPass = res.IsPass
|
||
|
||
service.Success(c, resObj)
|
||
|
||
return
|
||
}
|
||
|
||
func Approved(c *gin.Context) {
|
||
var req api.ListRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
//req.UserID = userInfo.ID
|
||
req.ApprovedBossId = userInfo.ID //我审批过的
|
||
|
||
if req.OrderBy == "" {
|
||
req.OrderBy = "desc"
|
||
}
|
||
|
||
if req.StartTime != "" && req.EndTime != "" {
|
||
req.StartTime = req.StartTime + " 00:00:00"
|
||
req.EndTime = req.EndTime + " 23:59:59"
|
||
req.OrderBy = "asc"
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.MyWork(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
//全局搜索过滤
|
||
if len(res.Data) > 0 && req.AllQuery != "" {
|
||
fmt.Println("========================全局搜索过滤==============================")
|
||
filterData := make([]*api.CreateRequest, 0)
|
||
for _, approvalItem := range res.Data {
|
||
flag := 0
|
||
if strings.Contains(approvalItem.Content, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Reply, req.AllQuery) ||
|
||
strings.Contains(approvalItem.SubmitterName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.NowUserName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.CreatedAt, req.AllQuery) ||
|
||
strings.Contains(approvalItem.TypeName, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
if approvalItem.Work != nil {
|
||
if len(approvalItem.Work.ApprovalWorks) > 0 {
|
||
for _, work := range approvalItem.Work.ApprovalWorks {
|
||
if strings.Contains(work.ArtworkName, req.AllQuery) ||
|
||
strings.Contains(work.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(work.ArtworkCover, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if len(approvalItem.Show) > 0 {
|
||
for _, show := range approvalItem.Show {
|
||
if strings.Contains(show.Address, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.Exhibition != nil {
|
||
if strings.Contains(approvalItem.Exhibition.Address, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
if len(approvalItem.Exhibition.ApprovalExhibitions) > 0 {
|
||
|
||
for _, exhibition := range approvalItem.Exhibition.ApprovalExhibitions {
|
||
if len(exhibition.Artworks) > 0 {
|
||
for _, artwork := range exhibition.Artworks {
|
||
if strings.Contains(artwork.ArtworkName, req.AllQuery) ||
|
||
strings.Contains(artwork.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(artwork.SaleAddress, req.AllQuery) ||
|
||
strings.Contains(artwork.Reward, req.AllQuery) ||
|
||
strings.Contains(artwork.Tfnum, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if exhibition.ArtExhibitionDetail != nil {
|
||
if strings.Contains(exhibition.ArtExhibitionDetail.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.ShowTime, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.ShowName, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.Address, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if len(approvalItem.WorkFlows) > 0 {
|
||
for _, user := range approvalItem.WorkFlows {
|
||
if strings.Contains(user.Name, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if len(approvalItem.CopyUsers) > 0 {
|
||
for _, copyUser := range approvalItem.CopyUsers {
|
||
if strings.Contains(copyUser.Name, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if len(approvalItem.CustomizeInfo) > 0 {
|
||
for _, keyInfo := range approvalItem.CustomizeInfo {
|
||
if strings.Contains(keyInfo.ApprovalValue, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.BundlePayPrice != nil {
|
||
if strings.Contains(approvalItem.BundlePayPrice.ShowName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.BundlePayPrice.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(approvalItem.BundlePayPrice.ShowLowPrice, req.AllQuery) ||
|
||
strings.Contains(approvalItem.BundlePayPrice.ArtworkSize, req.AllQuery) ||
|
||
strings.Contains(approvalItem.BundlePayPrice.ShowAddress, req.AllQuery) ||
|
||
strings.Contains(approvalItem.BundlePayPrice.ShowDate, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.RevokeReason, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
if approvalItem.ApprovalOA.LeaveApply != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.LeaveApply.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.LeaveApply.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.LeaveApply.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.LeaveApply.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.OutWork != nil {
|
||
|
||
if strings.Contains(approvalItem.ApprovalOA.OutWork.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OutWork.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OutWork.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OutWork.OutWorkAddress, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OutWork.Vehicle, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OutWork.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.OutWork.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.MakeUp != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.MakeUp.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.MakeUp.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.MakeUp.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.MakeUp.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.MakeUp.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.Turnover != nil {
|
||
fmt.Println("=====================turnover=====================")
|
||
fmt.Println(approvalItem.ApprovalOA.Turnover)
|
||
if strings.Contains(approvalItem.ApprovalOA.Turnover.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.HandoverName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.JoinTime, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.LeftTime, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.ContactInfo, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.HandoverNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.Address, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.SuperviseName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.SuperviseNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.WorkItems, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.FinanceItems, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.Turnover.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
fmt.Println("=====================flag=====================")
|
||
fmt.Println(flag)
|
||
}
|
||
if approvalItem.ApprovalOA.OverTime != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.OverTime.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OverTime.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OverTime.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OverTime.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.OverTime.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.Leave != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.Leave.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Leave.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Leave.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Leave.DateOfBrith, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Leave.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.Leave.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.GoOut != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.GoOut.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.GoOut.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.GoOut.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.GoOut.DateOfBrith, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.GoOut.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.GoOut.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.BusinessTrip != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.BusinessTrip.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.BusinessTrip.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.BusinessTrip.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.BusinessTrip.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, itinerary := range approvalItem.ApprovalOA.BusinessTrip.ItineraryList {
|
||
if strings.Contains(itinerary.Vehicle, req.AllQuery) ||
|
||
strings.Contains(itinerary.EndAddress, req.AllQuery) ||
|
||
strings.Contains(itinerary.StartAddress, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.FinancialForm != nil {
|
||
if strings.Contains(approvalItem.FinancialForm.PaymentCompany, req.AllQuery) ||
|
||
strings.Contains(approvalItem.FinancialForm.TransactionDepartment, req.AllQuery) ||
|
||
strings.Contains(approvalItem.FinancialForm.Payee, req.AllQuery) ||
|
||
strings.Contains(approvalItem.FinancialForm.BeneficiaryBank, req.AllQuery) ||
|
||
strings.Contains(approvalItem.FinancialForm.BankNo, req.AllQuery) ||
|
||
strings.Contains(approvalItem.FinancialForm.PaymentMethod, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, costInfo := range approvalItem.FinancialForm.CostInfo {
|
||
if strings.Contains(costInfo.Description, req.AllQuery) ||
|
||
strings.Contains(costInfo.UnitPrice, req.AllQuery) ||
|
||
strings.Contains(costInfo.CostUnit, req.AllQuery) ||
|
||
strings.Contains(costInfo.UsedDepartment, req.AllQuery) ||
|
||
strings.Contains(costInfo.TotalPrice, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
for _, invoiceInfo := range approvalItem.FinancialForm.InvoiceInfo {
|
||
if strings.Contains(invoiceInfo.InvoiceDate, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.InvoiceNo, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.InvoiceProvider, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.Amount, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.Applicant, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.PaymentMethod, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.PaymentObj, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.InvoiceType, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.Notes, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.UseTo, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ExhibitionHis != nil {
|
||
if strings.Contains(approvalItem.ExhibitionHis.Address, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
if len(approvalItem.ExhibitionHis.ApprovalExhibitionHiss) > 0 {
|
||
for _, exhibition := range approvalItem.ExhibitionHis.ApprovalExhibitionHiss {
|
||
if len(exhibition.Artworks) > 0 {
|
||
for _, artwork := range exhibition.Artworks {
|
||
if strings.Contains(artwork.ArtworkName, req.AllQuery) ||
|
||
strings.Contains(artwork.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(artwork.SaleAddress, req.AllQuery) ||
|
||
strings.Contains(artwork.Reward, req.AllQuery) ||
|
||
strings.Contains(artwork.Tfnum, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if exhibition.ArtExhibitionDetail != nil {
|
||
if strings.Contains(exhibition.ArtExhibitionDetail.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.ShowTime, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.ShowName, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.Address, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.Promotion != nil {
|
||
if strings.Contains(approvalItem.Promotion.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Promotion.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Promotion.FileName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Promotion.NewJob, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Promotion.EffectiveTime, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Promotion.OldJob, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
|
||
}
|
||
if approvalItem.StaffSupply != nil {
|
||
if strings.Contains(approvalItem.StaffSupply.PositionName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.StaffSupply.JobAsk, req.AllQuery) ||
|
||
strings.Contains(approvalItem.StaffSupply.JoinInTime, req.AllQuery) ||
|
||
strings.Contains(approvalItem.StaffSupply.DepartmentName, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
|
||
}
|
||
if approvalItem.Employ != nil {
|
||
if strings.Contains(approvalItem.Employ.Post, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.BelongDepartment, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.Name, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.EmployeeType, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.EmployeeNo, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.EntryTime, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.CloseReason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.ConfirmDate, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.Remark, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.Mobile, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
|
||
}
|
||
if approvalItem.CheckIn != nil {
|
||
if strings.Contains(approvalItem.CheckIn.SaleAddress, req.AllQuery) ||
|
||
strings.Contains(approvalItem.CheckIn.DetailAddress, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
|
||
}
|
||
if flag > 0 {
|
||
filterData = append(filterData, approvalItem)
|
||
}
|
||
}
|
||
fmt.Println("========================匹配所有字段结束,匹配结果==============================")
|
||
fmt.Println(filterData)
|
||
res.Data = filterData
|
||
|
||
}
|
||
if len(res.Data) > 0 {
|
||
lang := c.Request.Header.Get("Accept-Language")
|
||
for _, one := range res.Data {
|
||
one.TypeName = model2.GetLanguageType(lang, one.TypeName)
|
||
|
||
if one.ApprovalOA != nil {
|
||
if one.ApprovalOA.Leave != nil {
|
||
for _, applyTime := range one.ApprovalOA.Leave.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
if one.ApprovalOA.Turnover != nil {
|
||
for _, applyTime := range one.ApprovalOA.Turnover.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
if one.ApprovalOA.BusinessTrip != nil {
|
||
for _, itinerary := range one.ApprovalOA.BusinessTrip.ItineraryList {
|
||
for _, applyTime := range itinerary.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
}
|
||
if one.ApprovalOA.GoOut != nil {
|
||
for _, applyTime := range one.ApprovalOA.GoOut.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
if one.ApprovalOA.OutWork != nil {
|
||
for _, applyTime := range one.ApprovalOA.OutWork.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
if one.ApprovalOA.OverTime != nil {
|
||
for _, applyTime := range one.ApprovalOA.OverTime.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
if one.ApprovalOA.MakeUp != nil {
|
||
for _, applyTime := range one.ApprovalOA.MakeUp.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
service.Success(c, res)
|
||
|
||
return
|
||
}
|
||
|
||
func MySubmit(c *gin.Context) {
|
||
var req api.ListRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
req.UserID = userInfo.ID
|
||
|
||
if req.OrderBy == "" {
|
||
req.OrderBy = "desc"
|
||
}
|
||
res, err := service.ApprovalProvider.MySubmit(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
//全局搜索过滤
|
||
if len(res.Data) > 0 && req.AllQuery != "" {
|
||
fmt.Println("========================全局搜索过滤==============================")
|
||
filterData := make([]*api.CreateRequest, 0)
|
||
for _, approvalItem := range res.Data {
|
||
flag := 0
|
||
if strings.Contains(approvalItem.Content, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Reply, req.AllQuery) ||
|
||
strings.Contains(approvalItem.SubmitterName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.NowUserName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.CreatedAt, req.AllQuery) ||
|
||
strings.Contains(approvalItem.TypeName, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
if approvalItem.Work != nil {
|
||
if len(approvalItem.Work.ApprovalWorks) > 0 {
|
||
for _, work := range approvalItem.Work.ApprovalWorks {
|
||
if strings.Contains(work.ArtworkName, req.AllQuery) ||
|
||
strings.Contains(work.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(work.ArtworkCover, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if len(approvalItem.Show) > 0 {
|
||
for _, show := range approvalItem.Show {
|
||
if strings.Contains(show.Address, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.Exhibition != nil {
|
||
if strings.Contains(approvalItem.Exhibition.Address, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
if len(approvalItem.Exhibition.ApprovalExhibitions) > 0 {
|
||
|
||
for _, exhibition := range approvalItem.Exhibition.ApprovalExhibitions {
|
||
if len(exhibition.Artworks) > 0 {
|
||
for _, artwork := range exhibition.Artworks {
|
||
if strings.Contains(artwork.ArtworkName, req.AllQuery) ||
|
||
strings.Contains(artwork.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(artwork.SaleAddress, req.AllQuery) ||
|
||
strings.Contains(artwork.Reward, req.AllQuery) ||
|
||
strings.Contains(artwork.Tfnum, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if exhibition.ArtExhibitionDetail != nil {
|
||
if strings.Contains(exhibition.ArtExhibitionDetail.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.ShowTime, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.ShowName, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.Address, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if len(approvalItem.WorkFlows) > 0 {
|
||
for _, user := range approvalItem.WorkFlows {
|
||
if strings.Contains(user.Name, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if len(approvalItem.CopyUsers) > 0 {
|
||
for _, copyUser := range approvalItem.CopyUsers {
|
||
if strings.Contains(copyUser.Name, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if len(approvalItem.CustomizeInfo) > 0 {
|
||
for _, keyInfo := range approvalItem.CustomizeInfo {
|
||
if strings.Contains(keyInfo.ApprovalValue, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.BundlePayPrice != nil {
|
||
if strings.Contains(approvalItem.BundlePayPrice.ShowName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.BundlePayPrice.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(approvalItem.BundlePayPrice.ShowLowPrice, req.AllQuery) ||
|
||
strings.Contains(approvalItem.BundlePayPrice.ArtworkSize, req.AllQuery) ||
|
||
strings.Contains(approvalItem.BundlePayPrice.ShowAddress, req.AllQuery) ||
|
||
strings.Contains(approvalItem.BundlePayPrice.ShowDate, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.RevokeReason, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
if approvalItem.ApprovalOA.LeaveApply != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.LeaveApply.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.LeaveApply.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.LeaveApply.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.LeaveApply.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.OutWork != nil {
|
||
|
||
if strings.Contains(approvalItem.ApprovalOA.OutWork.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OutWork.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OutWork.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OutWork.OutWorkAddress, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OutWork.Vehicle, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OutWork.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.OutWork.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.MakeUp != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.MakeUp.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.MakeUp.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.MakeUp.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.MakeUp.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.MakeUp.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.Turnover != nil {
|
||
fmt.Println("=====================turnover=====================")
|
||
fmt.Println(approvalItem.ApprovalOA.Turnover)
|
||
if strings.Contains(approvalItem.ApprovalOA.Turnover.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.HandoverName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.JoinTime, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.LeftTime, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.ContactInfo, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.HandoverNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.Address, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.SuperviseName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.SuperviseNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.WorkItems, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.FinanceItems, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Turnover.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.Turnover.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
fmt.Println("=====================flag=====================")
|
||
fmt.Println(flag)
|
||
}
|
||
if approvalItem.ApprovalOA.OverTime != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.OverTime.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OverTime.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OverTime.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.OverTime.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.OverTime.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.Leave != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.Leave.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Leave.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Leave.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Leave.DateOfBrith, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.Leave.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.Leave.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.GoOut != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.GoOut.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.GoOut.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.GoOut.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.GoOut.DateOfBrith, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.GoOut.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, applyTime := range approvalItem.ApprovalOA.GoOut.ApplyTimes {
|
||
if strings.Contains(applyTime.Date, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ApprovalOA.BusinessTrip != nil {
|
||
if strings.Contains(approvalItem.ApprovalOA.BusinessTrip.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.BusinessTrip.Reason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.BusinessTrip.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.ApprovalOA.BusinessTrip.ActionTime, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, itinerary := range approvalItem.ApprovalOA.BusinessTrip.ItineraryList {
|
||
if strings.Contains(itinerary.Vehicle, req.AllQuery) ||
|
||
strings.Contains(itinerary.EndAddress, req.AllQuery) ||
|
||
strings.Contains(itinerary.StartAddress, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.FinancialForm != nil {
|
||
if strings.Contains(approvalItem.FinancialForm.PaymentCompany, req.AllQuery) ||
|
||
strings.Contains(approvalItem.FinancialForm.TransactionDepartment, req.AllQuery) ||
|
||
strings.Contains(approvalItem.FinancialForm.Payee, req.AllQuery) ||
|
||
strings.Contains(approvalItem.FinancialForm.BeneficiaryBank, req.AllQuery) ||
|
||
strings.Contains(approvalItem.FinancialForm.BankNo, req.AllQuery) ||
|
||
strings.Contains(approvalItem.FinancialForm.PaymentMethod, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
for _, costInfo := range approvalItem.FinancialForm.CostInfo {
|
||
if strings.Contains(costInfo.Description, req.AllQuery) ||
|
||
strings.Contains(costInfo.UnitPrice, req.AllQuery) ||
|
||
strings.Contains(costInfo.CostUnit, req.AllQuery) ||
|
||
strings.Contains(costInfo.UsedDepartment, req.AllQuery) ||
|
||
strings.Contains(costInfo.TotalPrice, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
for _, invoiceInfo := range approvalItem.FinancialForm.InvoiceInfo {
|
||
if strings.Contains(invoiceInfo.InvoiceDate, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.InvoiceNo, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.InvoiceProvider, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.Amount, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.Applicant, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.PaymentMethod, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.PaymentObj, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.InvoiceType, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.Notes, req.AllQuery) ||
|
||
strings.Contains(invoiceInfo.UseTo, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.ExhibitionHis != nil {
|
||
if strings.Contains(approvalItem.ExhibitionHis.Address, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
if len(approvalItem.ExhibitionHis.ApprovalExhibitionHiss) > 0 {
|
||
for _, exhibition := range approvalItem.ExhibitionHis.ApprovalExhibitionHiss {
|
||
if len(exhibition.Artworks) > 0 {
|
||
for _, artwork := range exhibition.Artworks {
|
||
if strings.Contains(artwork.ArtworkName, req.AllQuery) ||
|
||
strings.Contains(artwork.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(artwork.SaleAddress, req.AllQuery) ||
|
||
strings.Contains(artwork.Reward, req.AllQuery) ||
|
||
strings.Contains(artwork.Tfnum, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
if exhibition.ArtExhibitionDetail != nil {
|
||
if strings.Contains(exhibition.ArtExhibitionDetail.ArtistShowCount, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.ShowTime, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.ShowName, req.AllQuery) ||
|
||
strings.Contains(exhibition.ArtExhibitionDetail.Address, req.AllQuery) {
|
||
flag = flag + 1
|
||
break
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if approvalItem.Promotion != nil {
|
||
if strings.Contains(approvalItem.Promotion.StaffName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Promotion.StaffNum, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Promotion.FileName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Promotion.NewJob, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Promotion.EffectiveTime, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Promotion.OldJob, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
|
||
}
|
||
if approvalItem.StaffSupply != nil {
|
||
if strings.Contains(approvalItem.StaffSupply.PositionName, req.AllQuery) ||
|
||
strings.Contains(approvalItem.StaffSupply.JobAsk, req.AllQuery) ||
|
||
strings.Contains(approvalItem.StaffSupply.JoinInTime, req.AllQuery) ||
|
||
strings.Contains(approvalItem.StaffSupply.DepartmentName, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
|
||
}
|
||
if approvalItem.Employ != nil {
|
||
if strings.Contains(approvalItem.Employ.Post, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.BelongDepartment, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.Name, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.EmployeeType, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.EmployeeNo, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.EntryTime, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.CloseReason, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.ConfirmDate, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.Remark, req.AllQuery) ||
|
||
strings.Contains(approvalItem.Employ.Mobile, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
|
||
}
|
||
if approvalItem.CheckIn != nil {
|
||
if strings.Contains(approvalItem.CheckIn.SaleAddress, req.AllQuery) ||
|
||
strings.Contains(approvalItem.CheckIn.DetailAddress, req.AllQuery) {
|
||
flag = flag + 1
|
||
}
|
||
|
||
}
|
||
if flag > 0 {
|
||
filterData = append(filterData, approvalItem)
|
||
}
|
||
}
|
||
fmt.Println("========================匹配所有字段结束,匹配结果==============================")
|
||
fmt.Println(filterData)
|
||
res.Data = filterData
|
||
|
||
}
|
||
|
||
//国际化
|
||
if len(res.Data) > 0 {
|
||
lang := c.Request.Header.Get("Accept-Language")
|
||
for _, one := range res.Data {
|
||
one.TypeName = model2.GetLanguageType(lang, one.TypeName)
|
||
|
||
if one.ApprovalOA != nil {
|
||
if one.ApprovalOA.Leave != nil {
|
||
for _, applyTime := range one.ApprovalOA.Leave.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
if one.ApprovalOA.Turnover != nil {
|
||
for _, applyTime := range one.ApprovalOA.Turnover.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
if one.ApprovalOA.BusinessTrip != nil {
|
||
for _, itinerary := range one.ApprovalOA.BusinessTrip.ItineraryList {
|
||
for _, applyTime := range itinerary.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
}
|
||
if one.ApprovalOA.GoOut != nil {
|
||
for _, applyTime := range one.ApprovalOA.GoOut.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
if one.ApprovalOA.OutWork != nil {
|
||
for _, applyTime := range one.ApprovalOA.OutWork.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
if one.ApprovalOA.OverTime != nil {
|
||
for _, applyTime := range one.ApprovalOA.OverTime.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
if one.ApprovalOA.MakeUp != nil {
|
||
for _, applyTime := range one.ApprovalOA.MakeUp.ApplyTimes {
|
||
applyTime.M = model2.GetLanguageType(lang, applyTime.M)
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func Viewed(c *gin.Context) {
|
||
var req api.ViewedRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
req.UserID = userInfo.ID
|
||
|
||
res, err := service.ApprovalProvider.Viewed(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
detailReq := api.DetailRequest{ID: req.ID}
|
||
detail, err := service.ApprovalProvider.Detail(c, &detailReq)
|
||
|
||
if detail.TypeName == "人员增补申请" {
|
||
err = checkPostApprove(userInfo, detail.ID)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if detail.TypeName == "录用申请" {
|
||
err = checkOfferApprove(userInfo, detail.ID)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func Information(c *gin.Context) {
|
||
var req api.InformationRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.Information(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func UpdateSetting(c *gin.Context) {
|
||
var req api.SettingRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.UpdateSetting(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func DetailSetting(c *gin.Context) {
|
||
var req api.DetailSettingRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.DetailSetting(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
//当类型是离职交接时,验证是否有审批通过的离职申请,如果没有返回错误,如果有,把离职申请的相关内容塞到detail里面
|
||
if strings.Contains(req.KeyWord, "handover") {
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
reqList := &api.ListRequest{}
|
||
reqList.Domain = req.Domain
|
||
reqList.Type = "turnover"
|
||
reqList.UserID = userInfo.ID
|
||
reqList.Status = 2
|
||
submitRes2, err := service.ApprovalProvider.MySubmit(context.Background(), reqList)
|
||
if err != nil {
|
||
service.Error(c, e.Error, errors.New("查询已提交的离职审批失败"))
|
||
return
|
||
}
|
||
reqList.Status = 1
|
||
submitRes1, err := service.ApprovalProvider.MySubmit(context.Background(), reqList)
|
||
if err != nil {
|
||
service.Error(c, e.Error, errors.New("查询已提交的离职审批失败"))
|
||
return
|
||
}
|
||
list := make([]*api.CreateRequest, 0)
|
||
list = append(list, submitRes1.Data...)
|
||
list = append(list, submitRes2.Data...)
|
||
|
||
if len(list) > 0 {
|
||
turnOver := &api.TurnoverApply{}
|
||
turnOver = list[len(list)-1].ApprovalOA.Turnover
|
||
res.Turnover = turnOver
|
||
}
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
// RevokeLeaveApply
|
||
// 撤销 请假申请
|
||
func RevokeLeaveApply(c *gin.Context) {
|
||
/*
|
||
1、待审批
|
||
直接取消
|
||
2、未通过
|
||
撤销审批 审批人 根据 撤销的审批中的 审批人是否已审批 设置
|
||
3、通过
|
||
撤销审批 审批人 为 撤销的审批中的审批人
|
||
*/
|
||
revokeReq := new(api.RevokeApprovalReq)
|
||
if err := c.ShouldBindBodyWith(&revokeReq, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
beforeRevokeDetailReq := new(api.DetailRequest)
|
||
beforeRevokeDetailReq.ID = revokeReq.ID
|
||
beforeRevokeDetailRes, err := service.ApprovalProvider.Detail(context.Background(), beforeRevokeDetailReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if beforeRevokeDetailRes.Type == oa_model.TypeNursingLeaveApply || beforeRevokeDetailRes.Type == oa_model.TypeParentalLeaveApply {
|
||
err = CheckLeaveApplyIsUse(beforeRevokeDetailRes)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
// 审批 撤销
|
||
_, err = service.ApprovalProvider.RevokeMyApproval(context.Background(), revokeReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
detailReq := new(api.DetailRequest)
|
||
detailReq.ID = revokeReq.ID
|
||
detailRes, err := service.ApprovalProvider.Detail(context.Background(), detailReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if detailRes.Status != e.ApprovalWorkStatusRevoking {
|
||
service.Error(c, e.Error, errors.New("撤销失败"))
|
||
return
|
||
}
|
||
|
||
// oa 撤销
|
||
if oa_model.TypeZhCN[detailRes.Type] != "" {
|
||
_, err = RevokeOaApproval(detailRes)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
service.Success(c)
|
||
}
|
||
|
||
func passSynToShowRelUpdateNotLogin(c *gin.Context, ID uint64, UserId uint64) (string, error) {
|
||
|
||
var detailReq api.DetailRequest
|
||
|
||
detailReq.UserId = UserId
|
||
detailReq.ID = ID
|
||
|
||
detailRes, err3 := service.ApprovalProvider.Detail(c, &detailReq)
|
||
if err3 != nil {
|
||
return "", err3
|
||
}
|
||
if detailRes.Type != "showUpdate" {
|
||
return "", nil
|
||
}
|
||
|
||
if detailRes.Status != 2 { // 不等于2 表示 此审批 未通过
|
||
return "", nil
|
||
}
|
||
|
||
// 审批 通过 通知 画展包微服务 记录
|
||
req := detailRes
|
||
|
||
updateShowTimeAndAddress := new(artShow.UpdateShowTimeAndAddressReq)
|
||
updateShowTimeAndAddress.Data = make([]*artShow.ShowTimeAndAddress, 0)
|
||
|
||
payBillUpdateAddress := paybill.UpdateAddressreq{}
|
||
payBillUpdateAddress.Data = make([]*paybill.UpdateAddressreq_Info, 0)
|
||
|
||
for _, tt := range req.ExhibitionHis.ApprovalExhibitionHiss {
|
||
temp := &artShow.ShowTimeAndAddress{
|
||
ShowUid: tt.PackageID,
|
||
Address: tt.Address,
|
||
ShowTime: tt.ShowDate,
|
||
}
|
||
updateShowTimeAndAddress.Data = append(updateShowTimeAndAddress.Data, temp)
|
||
|
||
payBillUpdateAddress.Data = append(payBillUpdateAddress.Data, &paybill.UpdateAddressreq_Info{
|
||
ShowUid: tt.PackageID,
|
||
ShowDate: tt.ShowDate,
|
||
Address: tt.Address,
|
||
ApprovalId: req.ExhibitionHis.ApplyID,
|
||
ShowName: tt.PackageName,
|
||
})
|
||
}
|
||
|
||
_, err := service.GrpcArtShowImpl.UpdateShowTimeAndAddress(c, updateShowTimeAndAddress)
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
_, err = service.GrpcPayBillImpl.UpdateAddress(c, &payBillUpdateAddress)
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 修改 画作销售站点
|
||
err = UpdateSaleAddress(detailRes)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
return "", nil
|
||
|
||
}
|
||
|
||
func passSynToShowRelUpdate(c *gin.Context, ID uint64) (string, error) {
|
||
|
||
var detailReq api.DetailRequest
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
detailReq.UserId = userInfo.ID
|
||
detailReq.ID = ID
|
||
|
||
detailRes, err3 := service.ApprovalProvider.Detail(c, &detailReq)
|
||
if err3 != nil {
|
||
return "", err3
|
||
}
|
||
if detailRes.Type != "showUpdate" {
|
||
return "", nil
|
||
}
|
||
|
||
if detailRes.Status != 2 { // 2 表示 此审批 未通过
|
||
return "", nil
|
||
}
|
||
|
||
// 审批 通过 通知 画展包微服务 记录
|
||
req := detailRes
|
||
|
||
updateShowTimeAndAddress := new(artShow.UpdateShowTimeAndAddressReq)
|
||
updateShowTimeAndAddress.Data = make([]*artShow.ShowTimeAndAddress, 0)
|
||
|
||
payBillUpdateAddress := paybill.UpdateAddressreq{}
|
||
payBillUpdateAddress.Data = make([]*paybill.UpdateAddressreq_Info, 0)
|
||
|
||
for _, tt := range req.ExhibitionHis.ApprovalExhibitionHiss {
|
||
temp := &artShow.ShowTimeAndAddress{
|
||
ShowUid: tt.PackageID,
|
||
Address: tt.Address,
|
||
ShowTime: tt.ShowDate,
|
||
}
|
||
updateShowTimeAndAddress.Data = append(updateShowTimeAndAddress.Data, temp)
|
||
|
||
payBillUpdateAddress.Data = append(payBillUpdateAddress.Data, &paybill.UpdateAddressreq_Info{
|
||
ShowUid: tt.PackageID,
|
||
ShowDate: tt.ShowDate,
|
||
Address: tt.Address,
|
||
ApprovalId: strconv.FormatUint(req.ID, 10),
|
||
ShowName: tt.PackageName,
|
||
})
|
||
}
|
||
|
||
_, err := service.GrpcArtShowImpl.UpdateShowTimeAndAddress(c, updateShowTimeAndAddress)
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
_, err = service.GrpcPayBillImpl.UpdateAddress(c, &payBillUpdateAddress)
|
||
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 修改 画作销售站点
|
||
err = UpdateSaleAddress(detailRes)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
/* // 通过 rabbitmq 发送 到 画家系统 用于 确认 是否 参加画展
|
||
artistUIDs := make([]string, 0)
|
||
|
||
for i := 0; i < len(detailRes.Exhibition.ApprovalExhibitions); i++ {
|
||
artistUIDs = append(artistUIDs, detailRes.Exhibition.ApprovalExhibitions[i].ArtExhibitionDetail.ArtistUID)
|
||
}
|
||
|
||
bt, err := json.Marshal(&artistUIDs)
|
||
fmt.Println("========================== send =====================")
|
||
fmt.Printf("send msg to mq : %+v", artistUIDs)
|
||
fmt.Println("========================== send =====================")
|
||
fmt.Println()
|
||
mq.SendToArtShowPass(bt)*/
|
||
|
||
return "", nil
|
||
|
||
}
|
||
|
||
func MakeApprovalAndUser(c *gin.Context) {
|
||
var req api.CreateRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
|
||
//提交人
|
||
req.SubmitterName = userInfo.NickName
|
||
req.SubmitterID = userInfo.ID
|
||
|
||
req.ApprovalUsers, req.IsLeader = DepartmentBosses(c, req.DepartmentID, req.SubmitterID)
|
||
if userInfo.DepartmentName == "管理部" || userInfo.DepartmentName == "人事行政部" {
|
||
req.IsLeader = true
|
||
}
|
||
|
||
// start 针对 艺邑 特殊处理 且 只有 oa 申请才是
|
||
departmentName := ""
|
||
if len(userInfo.PositionUsers) == 1 {
|
||
for i := 0; i < len(userInfo.PositionUsers); i++ {
|
||
if userInfo.PositionUsers[i].DepartmentName == "艺邑" {
|
||
departmentName = "艺邑"
|
||
}
|
||
}
|
||
} else if len(userInfo.PositionUsers) > 1 {
|
||
for i := 0; i < len(userInfo.PositionUsers); i++ {
|
||
if userInfo.PositionUsers[i].DepartmentId == uint64(req.DepartmentID) && userInfo.PositionUsers[i].DepartmentName == "艺邑" {
|
||
departmentName = "艺邑"
|
||
}
|
||
}
|
||
}
|
||
|
||
if departmentName == "艺邑" && (oa_model.LeaveApplyMap[req.Type] != "" || oa_model.LeaveBalanceApplyMap[req.Type] != "" || req.Type == oa_model.TypeOutWork || req.Type == oa_model.TypeTurnover || req.Type == oa_model.TypeMakeUp) {
|
||
req.ApprovalUsers = nil
|
||
if req.SubmitterName == "董辰琦" {
|
||
req.IsLeader = true
|
||
}
|
||
req.Domain = "out"
|
||
}
|
||
// end
|
||
|
||
res, err := service.ApprovalProvider.MakeApprovalAndCopy(context.Background(), &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
// Send 批量催办
|
||
func ListSend(c *gin.Context) {
|
||
var req api.ListRequest
|
||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
req.UserID = userInfo.ID
|
||
|
||
nowUserInfo, err := account.GetUserInfoById(c, req.ApprovedBossId, "")
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
//开始
|
||
cacheKey := cache.SendDateOneApprovalMsg(uint(req.ApprovedBossId), req.Title, time.Now().Format(model.DateFormat), uint(req.UserID))
|
||
|
||
isExist, err := cache.RedisClient.Exists(cacheKey).Result()
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if isExist == 1 {
|
||
service.Error(c, e.Error, errors.New(e.ErrorOVerSendBossMsg))
|
||
return
|
||
}
|
||
|
||
if req.Domain == "" {
|
||
req.Domain = "all"
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.MySubmit(c, &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, errors.New(e.GetMsg(e.ErrorSelect)))
|
||
return
|
||
}
|
||
|
||
ids := make([]string, 0)
|
||
for i := 0; i < len(res.Data); i++ {
|
||
ids = append(ids, strconv.FormatUint(res.Data[i].ID, 10))
|
||
}
|
||
|
||
url := fmt.Sprintf("https://erpapi.fontree.cn/approval7524164487E/multiple.html?id=%v&userId=%d", strings.Join(ids, ","), req.ApprovedBossId)
|
||
devUrl := fmt.Sprintf("http://114.218.158.24:9050/approval7524164487E/multiple.html?id=%v&userId=%d", strings.Join(ids, ","), req.ApprovedBossId)
|
||
|
||
//todo 拉取了dev分支后,这个方法没有
|
||
|
||
if config.AppMode == "debug" {
|
||
url = devUrl
|
||
} else {
|
||
shortUrl, err := utils.CreateShortUrl(url)
|
||
if err == nil {
|
||
url = shortUrl
|
||
}
|
||
}
|
||
|
||
msgReq := account2.SendCustomMsgRequest{
|
||
ID: req.ApprovedBossId,
|
||
TelNum: nowUserInfo.TelNum,
|
||
MId: 136784,
|
||
SigNo: uint32(config.DefaultSignNo),
|
||
}
|
||
|
||
//亲爱用户,您有【】审批催办已经发送,请点击查看【】
|
||
fmt.Println("发送短信")
|
||
if err == nil {
|
||
msgReq.Url = req.Title + "|" + url
|
||
fmt.Println("发送短信", msgReq)
|
||
mres, err := service.AccountProvider.SendCustomMsg(c, &msgReq)
|
||
fmt.Println("发送短信返回", mres, err)
|
||
}
|
||
|
||
cache.RedisClient.Set(cacheKey, 1, 1*time.Hour)
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func ListEx(c *gin.Context) {
|
||
var list api.ListByID
|
||
if err := c.ShouldBindBodyWith(&list, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
res, err := service.ApprovalProvider.ListApprovalByID(c, &list)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func SetStatusBatchEx(c *gin.Context) {
|
||
var setStatusBatchReq vo.SetStatusBatchReq
|
||
if err := c.ShouldBindBodyWith(&setStatusBatchReq, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if len(setStatusBatchReq.Batch) < 1 {
|
||
service.Error(c, e.Error, errors.New("当前无审批"))
|
||
return
|
||
}
|
||
|
||
for i := 0; i < len(setStatusBatchReq.Batch); i++ {
|
||
req := api.StatusRequest{}
|
||
_ = copier.CopyWithOption(&req, setStatusBatchReq.Batch[i], copier.Option{DeepCopy: false})
|
||
|
||
infoReq := account2.InfoRequest{ID: req.UserId}
|
||
|
||
infoRes, err := service.AccountProvider.Info(context.Background(), &infoReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, errors.New(e.GetMsg(e.ErrorGetUserInfo)))
|
||
return
|
||
}
|
||
|
||
if infoRes.Info.ID == 0 || infoRes.Info.NickName == "" || infoRes.Info.Domain == "" {
|
||
service.Error(c, e.Error, errors.New(e.GetMsg(e.ErrorGetUserInfo)))
|
||
return
|
||
}
|
||
|
||
userInfo := login.Info{
|
||
ID: req.UserId,
|
||
NickName: infoRes.Info.NickName,
|
||
}
|
||
|
||
levelReq := api.NowLevelByInfoRequest{
|
||
ApprovalID: req.ID,
|
||
}
|
||
|
||
levelRes, err := service.ApprovalProvider.NowLevelByInfo(context.Background(), &levelReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if req.UserId != levelRes.UserID {
|
||
service.Error(c, e.Error, errors.New("本次审批人出现错误"))
|
||
return
|
||
}
|
||
|
||
req.WorkFlowId = levelRes.ID
|
||
|
||
// 查询 未审批前的审批
|
||
beforeApproval := QueryApprovalSetStatusBefore(req.ID)
|
||
if beforeApproval == nil {
|
||
service.Error(c, e.Error, errors.New(e.ErrorQueryApprovalContent))
|
||
return
|
||
}
|
||
|
||
_, err = service.ApprovalProvider.SetStatus(context.Background(), &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
detailReq := api.DetailRequest{ID: req.ID}
|
||
detail, err := service.ApprovalProvider.Detail(context.Background(), &detailReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if detail.TypeName == "任命审批" {
|
||
StoreBaiduChainApprovalFile(req.ID)
|
||
}
|
||
|
||
// 审批成功查询用户部门的信息,提交画作服修改画作仓库状态
|
||
|
||
if detail.TypeName == "画作申请审批" {
|
||
var ids []int32
|
||
for _, tt := range detail.Work.ApprovalWorks {
|
||
ids = append(ids, int32(tt.ArtworkID))
|
||
}
|
||
|
||
fmt.Println("请求画作申请审批", ids)
|
||
if len(ids) > 0 {
|
||
err = submitArtwork(req.UserId, ids)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
// approval 审批状态 同步到 oa 审批
|
||
if e.TypeMap[detail.Type] == "oa" {
|
||
// 查询 审批状态已经 更新的 审批信息
|
||
updatedReq := api.DetailRequest{ID: req.ID}
|
||
updatedDetail, detailErr := service.ApprovalProvider.Detail(context.Background(), &updatedReq)
|
||
if detailErr != nil {
|
||
service.Error(c, e.Error, detailErr)
|
||
return
|
||
}
|
||
|
||
if req.LeaveBalance != 0 && updatedDetail.ApprovalOA.LeaveApply != nil {
|
||
//leaveBalance, _ := strconv.ParseFloat(req.LeaveBalance, 10)
|
||
updatedDetail.ApprovalOA.LeaveApply.LeaveBalance = req.LeaveBalance
|
||
}
|
||
|
||
_, updateErr := UpdateApprovalStatusToOAStatus(updatedDetail)
|
||
if updateErr != nil {
|
||
service.Error(c, e.Error, updateErr)
|
||
return
|
||
}
|
||
}
|
||
|
||
// 画展包审批
|
||
if detail.Type == TypeExhibition {
|
||
err = ExhibitionApproveEnter(beforeApproval, detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
// 画展包润格审批
|
||
if detail.Type == TypeArtExhibitionReward {
|
||
err = ExhibitionRewordApproveEnter(beforeApproval, detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
// 画展包修改审批
|
||
if detail.Type == TypeShowUpdate {
|
||
err = ShowUpdateApproveEnter(beforeApproval, detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if detail.TypeName == "人员增补申请" {
|
||
err = postApproveSetStatusEnter(userInfo, beforeApproval)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if strings.Contains(detail.Type, "employ") {
|
||
err := offerApproveSetStatusEnter(c, userInfo, &req, detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if detail.Type == "checkIn" && detail.Status == e.ApprovalWorkStatusOk {
|
||
err = passSendInfoToSiteSignIn(detail.CheckIn)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
||
Status: e.Ok,
|
||
})
|
||
}
|
||
|
||
func SameApprovalList(c *gin.Context) {
|
||
var list api.ListRequest
|
||
if err := c.ShouldBindBodyWith(&list, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
|
||
list.ApprovedBossId = userInfo.ID
|
||
|
||
res, err := service.ApprovalProvider.MyWork(c, &list)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
service.Success(c, res)
|
||
}
|
||
|
||
func SetStatusBatch(c *gin.Context) {
|
||
//var setStatusBatchReq vo.SetStatusBatchReq
|
||
setStatusBatchReq := make([]vo.SetStatus, 0)
|
||
if err := c.ShouldBindBodyWith(&setStatusBatchReq, binding.JSON); err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
fmt.Println("============ 获取 审批 批量 审批 ==============")
|
||
fmt.Printf("batch %+v\n", setStatusBatchReq)
|
||
fmt.Println("============ 获取 审批 批量 审批 ==============")
|
||
|
||
if len(setStatusBatchReq) < 1 {
|
||
service.Error(c, e.Error, errors.New("当前无审批"))
|
||
return
|
||
}
|
||
|
||
userInfo := login.GetUserInfoFromC(c)
|
||
for i := 0; i < len(setStatusBatchReq); i++ {
|
||
req := api.StatusRequest{}
|
||
req.Domain = setStatusBatchReq[i].Domain
|
||
req.ID = setStatusBatchReq[i].ID
|
||
req.Reply = setStatusBatchReq[i].Reply
|
||
req.WorkFlowId = setStatusBatchReq[i].WorkFlowId
|
||
req.Status = setStatusBatchReq[i].Status
|
||
req.Level = setStatusBatchReq[i].Level
|
||
req.Title = setStatusBatchReq[i].Title
|
||
req.UserId = userInfo.ID
|
||
req.LeaveBalance = setStatusBatchReq[i].LeaveBalance
|
||
req.Tips = setStatusBatchReq[i].Tips
|
||
|
||
levelReq := api.NowLevelByInfoRequest{
|
||
ApprovalID: req.ID,
|
||
}
|
||
|
||
levelRes, err := service.ApprovalProvider.NowLevelByInfo(context.Background(), &levelReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if req.UserId != levelRes.UserID {
|
||
service.Error(c, e.Error, errors.New("本次审批人出现错误"))
|
||
return
|
||
}
|
||
|
||
req.WorkFlowId = levelRes.ID
|
||
|
||
// 查询 未审批前的审批
|
||
beforeApproval := QueryApprovalSetStatusBefore(req.ID)
|
||
if beforeApproval == nil {
|
||
service.Error(c, e.Error, errors.New(e.ErrorQueryApprovalContent))
|
||
return
|
||
}
|
||
|
||
_, err = service.ApprovalProvider.SetStatus(context.Background(), &req)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
detailReq := api.DetailRequest{ID: req.ID}
|
||
detail, err := service.ApprovalProvider.Detail(context.Background(), &detailReq)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
|
||
if detail.TypeName == "任命审批" {
|
||
StoreBaiduChainApprovalFile(req.ID)
|
||
}
|
||
|
||
// 审批成功查询用户部门的信息,提交画作服修改画作仓库状态
|
||
|
||
if detail.TypeName == "画作申请审批" {
|
||
var ids []int32
|
||
for _, tt := range detail.Work.ApprovalWorks {
|
||
ids = append(ids, int32(tt.ArtworkID))
|
||
}
|
||
|
||
fmt.Println("请求画作申请审批", ids)
|
||
if len(ids) > 0 {
|
||
err = submitArtwork(req.UserId, ids)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
// approval 审批状态 同步到 oa 审批
|
||
if e.TypeMap[detail.Type] == "oa" {
|
||
// 查询 审批状态已经 更新的 审批信息
|
||
updatedReq := api.DetailRequest{ID: req.ID}
|
||
updatedDetail, detailErr := service.ApprovalProvider.Detail(context.Background(), &updatedReq)
|
||
if detailErr != nil {
|
||
service.Error(c, e.Error, detailErr)
|
||
return
|
||
}
|
||
|
||
if req.LeaveBalance != 0 && updatedDetail.ApprovalOA.LeaveApply != nil {
|
||
//leaveBalance, _ := strconv.ParseFloat(req.LeaveBalance, 10)
|
||
updatedDetail.ApprovalOA.LeaveApply.LeaveBalance = req.LeaveBalance
|
||
}
|
||
|
||
_, updateErr := UpdateApprovalStatusToOAStatus(updatedDetail)
|
||
if updateErr != nil {
|
||
service.Error(c, e.Error, updateErr)
|
||
return
|
||
}
|
||
}
|
||
|
||
// 画展包审批
|
||
if detail.Type == TypeExhibition {
|
||
err = ExhibitionApproveEnter(beforeApproval, detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
// 画展包润格审批
|
||
if detail.Type == TypeArtExhibitionReward {
|
||
err = ExhibitionRewordApproveEnter(beforeApproval, detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
// 画展包修改审批
|
||
if detail.Type == TypeShowUpdate {
|
||
err = ShowUpdateApproveEnter(beforeApproval, detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if detail.TypeName == "人员增补申请" {
|
||
err = postApproveSetStatusEnter(userInfo, beforeApproval)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if strings.Contains(detail.Type, "employ") {
|
||
err := offerApproveSetStatusEnter(c, userInfo, &req, detail)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
|
||
if detail.Type == "checkIn" && detail.Status == e.ApprovalWorkStatusOk {
|
||
err = passSendInfoToSiteSignIn(detail.CheckIn)
|
||
if err != nil {
|
||
service.Error(c, e.Error, err)
|
||
return
|
||
}
|
||
}
|
||
}
|
||
|
||
service.ResponseMsg(c, e.SUCCESS, serializer.Response{
|
||
Status: e.Ok,
|
||
})
|
||
}
|