|
|
@@ -6,7 +6,6 @@ import (
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/supplierdataentry"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/supplierfile"
|
|
|
- "dashoo.cn/backend/api/business/oilsupplier/supplierpausereason"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/tableheader"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
@@ -1795,11 +1794,6 @@ func (this *OilGoodsAptitudeController) InsertGoodsAptitude() {
|
|
|
}
|
|
|
// TODO 更新certsub表的subclassid
|
|
|
|
|
|
- svc1 := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
|
|
|
- var list2 []supplier.OilSupplierContrast
|
|
|
- where := " (Checked = '0' or MinClassId = '0') and SupplierTypeCode = '01'"
|
|
|
- svc1.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrast", 0, 0, "Id", false, &list2, where)
|
|
|
- err = svc.TruncateTable("OilSupplierContrastNew")
|
|
|
if err != nil {
|
|
|
session.Rollback()
|
|
|
errinfo.Code = -1
|
|
|
@@ -1807,16 +1801,6 @@ func (this *OilGoodsAptitudeController) InsertGoodsAptitude() {
|
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
- for _, item := range list2 {
|
|
|
- _, err := svc.InsertEntityBytbl("OilSupplierContrastNew", item)
|
|
|
- if err != nil {
|
|
|
- session.Rollback()
|
|
|
- errinfo.Code = -1
|
|
|
- errinfo.Message = "更新失败!"
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
session.Commit()
|
|
|
errinfo.Code = 0
|
|
|
@@ -3047,117 +3031,103 @@ func (this *OilGoodsAptitudeController) DeleteSuspend() {
|
|
|
var list []supplier.OilSupplierContrast
|
|
|
svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
|
|
|
//svc.GetEntitysByWhere("OilSupplierContrast", "TwoOneCount = 0", &list)
|
|
|
- svc.GetEntitysByWhere("OilSupplierContrast", "1=1", &list)
|
|
|
- for _,item := range list{
|
|
|
- var sub []suppliercertsub.OilSupplierCertSub
|
|
|
- svc.GetEntitysByWhere("OilSupplierCertSub", "SupplierTypeCode = '01' and SupplierId = " + strconv.Itoa(item.Id), &sub)
|
|
|
- for _, itemSub := range sub {
|
|
|
- sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46)) AS Codes,a.GoodsLevel,class.Name FROM OilGoodsAptitude a LEFT JOIN OilGoodsAptitudeClass class ON a.ClassId = class.Id"
|
|
|
- sql += " where class.Code = '"+ itemSub.Code + "'"
|
|
|
- model, _ := svc.DBE.QueryString(sql)
|
|
|
- var subDelete suppliercertsub.OilSupplierCertSub1
|
|
|
- if model != nil {
|
|
|
- code := strings.Split(model[0]["Codes"], ",")
|
|
|
- cols := []string{"GoodsLevel", "Name"}
|
|
|
- subDelete.GoodsLevel = model[0]["GoodsLevel"]
|
|
|
- subDelete.Name = model[0]["Name"]
|
|
|
-
|
|
|
- //2升1不变
|
|
|
- if model[0]["GoodsLevel"] == "1" && itemSub.GoodsLevel == "2" {
|
|
|
- colsC := []string{"IsDelete"}
|
|
|
- colsS := []string{"IsQuestion"}
|
|
|
- item.IsDelete = 1
|
|
|
- itemSub.IsQuestion = 1
|
|
|
- svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &itemSub, colsS, "Id = "+strconv.Itoa(itemSub.Id))
|
|
|
- svc.UpdateEntityBywheretbl("OilSupplierContrast", &item, colsC, "Id = "+strconv.Itoa(item.Id))
|
|
|
- continue
|
|
|
- }
|
|
|
+ go func() {
|
|
|
+ svc.GetEntitysByWhere("OilSupplierContrast", "1=1", &list)
|
|
|
+ for _,item := range list{
|
|
|
+ var sub []suppliercertsub.OilSupplierCertSub
|
|
|
+ svc.GetEntitysByWhere("OilSupplierCertSub", "SupplierTypeCode = '01' and SupplierId = " + strconv.Itoa(item.Id), &sub)
|
|
|
+ for _, itemSub := range sub {
|
|
|
+ //sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46)) AS Codes,a.GoodsLevel,class.Name FROM OilGoodsAptitude a LEFT JOIN OilGoodsAptitudeClass class ON a.ClassId = class.Id"
|
|
|
+ sql := "SELECT a.GoodsLevel,class.Name FROM OilGoodsAptitude a LEFT JOIN OilGoodsAptitudeClass class ON a.ClassId = class.Id"
|
|
|
+ sql += " where class.Code = '"+ itemSub.Code + "'"
|
|
|
+ model, _ := svc.DBE.QueryString(sql)
|
|
|
+ var subDelete suppliercertsub.OilSupplierCertSub1
|
|
|
+ if model != nil {
|
|
|
+ //2升1删除
|
|
|
+ if model[0]["GoodsLevel"] == "1" && itemSub.GoodsLevel == "2" {
|
|
|
+ err = svc.DeleteTable ("OilSupplierCertSub", "Id = " + strconv.Itoa(itemSub.Id))
|
|
|
+ }
|
|
|
|
|
|
- // 1降2修改
|
|
|
- if item.OneTwoCount > 0 {
|
|
|
- err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id))
|
|
|
- }
|
|
|
- cols = append(cols, "DueTime")
|
|
|
- cols = append(cols, "CertSubStatus")
|
|
|
- subDelete.CertSubStatus = "2"
|
|
|
- //subDelete.DueTime = "2021-06-06 00:00:00"
|
|
|
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
|
- DueTimeStr := paramSvc.GetBaseparameterMessage("GFZT", "paramset", "Suspend")
|
|
|
- //fmt.Println("返回的时间", DueTimeStr)
|
|
|
- //local, _ := time.LoadLocation("Local")
|
|
|
- //theTime, _ := time.ParseInLocation("2006-01-02", DueTimeStr, local)
|
|
|
- currentTime := time.Now()
|
|
|
- days,_ := strconv.Atoi(DueTimeStr)
|
|
|
- subDelete.DueTime = currentTime.AddDate(0, 0, days)
|
|
|
- i := 1
|
|
|
- //暂停
|
|
|
- for _, value := range code {
|
|
|
- if i == 36 || i == 37 || i == 1 {
|
|
|
- if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[35] == "1" && strings.Index(item.HeaderCodes, "F36") < 0) && (code[36] == "1" && strings.Index(item.HeaderCodes, "F37") < 0) {
|
|
|
- err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
|
|
|
- var model1 supplierpausereason.OilSupplierPauseReason
|
|
|
- model1.SupplierId = item.Id
|
|
|
- model1.CertSubId = itemSub.Id
|
|
|
- model1.CertSubStatus = "2"
|
|
|
- model1.SupplierCertId = itemSub.SupplierCertId
|
|
|
- model1.BackReason = "老数据导入缺资质"
|
|
|
- model1.CreateOn = time.Now()
|
|
|
- model1.CreateBy = this.User.Realname
|
|
|
- model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
- svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
|
|
|
- break
|
|
|
- }
|
|
|
- } else if i > 10 {
|
|
|
- if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
|
|
|
- err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
|
|
|
- var model1 supplierpausereason.OilSupplierPauseReason
|
|
|
- model1.SupplierId = item.Id
|
|
|
- model1.CertSubId = itemSub.Id
|
|
|
- model1.CertSubStatus = "2"
|
|
|
- model1.SupplierCertId = itemSub.SupplierCertId
|
|
|
- model1.BackReason = "老数据导入缺资质"
|
|
|
- model1.CreateOn = time.Now()
|
|
|
- model1.CreateBy = this.User.Realname
|
|
|
- model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
- svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
|
|
|
- break
|
|
|
- }
|
|
|
- } else {
|
|
|
- if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
|
|
|
- err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
|
|
|
- var model1 supplierpausereason.OilSupplierPauseReason
|
|
|
- model1.SupplierId = item.Id
|
|
|
- model1.CertSubId = itemSub.Id
|
|
|
- model1.CertSubStatus = "2"
|
|
|
- model1.SupplierCertId = itemSub.SupplierCertId
|
|
|
- model1.BackReason = "老数据导入缺资质"
|
|
|
- model1.CreateOn = time.Now()
|
|
|
- model1.CreateBy = this.User.Realname
|
|
|
- model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
- svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
|
|
|
- break
|
|
|
- }
|
|
|
+ //code := strings.Split(model[0]["Codes"], ",")
|
|
|
+ cols := []string{"GoodsLevel", "Name"}
|
|
|
+ subDelete.GoodsLevel = model[0]["GoodsLevel"]
|
|
|
+ subDelete.Name = model[0]["Name"]
|
|
|
+ // 1降2修改
|
|
|
+ if model[0]["GoodsLevel"] == "2" && itemSub.GoodsLevel == "1" {
|
|
|
+ err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id))
|
|
|
}
|
|
|
- i += 1
|
|
|
+ //cols = append(cols, "DueTime")
|
|
|
+ //cols = append(cols, "CertSubStatus")
|
|
|
+ //subDelete.CertSubStatus = "2"
|
|
|
+ //paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
|
+ //DueTimeStr := paramSvc.GetBaseparameterMessage("GFZT", "paramset", "Suspend")
|
|
|
+ //currentTime := time.Now()
|
|
|
+ //days,_ := strconv.Atoi(DueTimeStr)
|
|
|
+ //subDelete.DueTime = currentTime.AddDate(0, 0, days)
|
|
|
+ //i := 1
|
|
|
+ //暂停
|
|
|
+ //for _, value := range code {
|
|
|
+ // if i == 36 || i == 37 || i == 1 {
|
|
|
+ // if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[35] == "1" && strings.Index(item.HeaderCodes, "F36") < 0) && (code[36] == "1" && strings.Index(item.HeaderCodes, "F37") < 0) {
|
|
|
+ // err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
|
|
|
+ // var model1 supplierpausereason.OilSupplierPauseReason
|
|
|
+ // model1.SupplierId = item.Id
|
|
|
+ // model1.CertSubId = itemSub.Id
|
|
|
+ // model1.CertSubStatus = "2"
|
|
|
+ // model1.SupplierCertId = itemSub.SupplierCertId
|
|
|
+ // model1.BackReason = "老数据导入缺资质"
|
|
|
+ // model1.CreateOn = time.Now()
|
|
|
+ // model1.CreateBy = this.User.Realname
|
|
|
+ // model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ // svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ // } else if i > 10 {
|
|
|
+ // if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
|
|
|
+ // err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
|
|
|
+ // var model1 supplierpausereason.OilSupplierPauseReason
|
|
|
+ // model1.SupplierId = item.Id
|
|
|
+ // model1.CertSubId = itemSub.Id
|
|
|
+ // model1.CertSubStatus = "2"
|
|
|
+ // model1.SupplierCertId = itemSub.SupplierCertId
|
|
|
+ // model1.BackReason = "老数据导入缺资质"
|
|
|
+ // model1.CreateOn = time.Now()
|
|
|
+ // model1.CreateBy = this.User.Realname
|
|
|
+ // model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ // svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
|
|
|
+ // err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
|
|
|
+ // var model1 supplierpausereason.OilSupplierPauseReason
|
|
|
+ // model1.SupplierId = item.Id
|
|
|
+ // model1.CertSubId = itemSub.Id
|
|
|
+ // model1.CertSubStatus = "2"
|
|
|
+ // model1.SupplierCertId = itemSub.SupplierCertId
|
|
|
+ // model1.BackReason = "老数据导入缺资质"
|
|
|
+ // model1.CreateOn = time.Now()
|
|
|
+ // model1.CreateBy = this.User.Realname
|
|
|
+ // model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ // svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // i += 1
|
|
|
+ //}
|
|
|
+ } else {
|
|
|
+ // 删除
|
|
|
+ err = svc.DeleteTable ("OilSupplierCertSub", "Id = " + strconv.Itoa(itemSub.Id))
|
|
|
}
|
|
|
- } else {
|
|
|
- // 删除
|
|
|
- err = svc.DeleteEntityById(itemSub.Id, &subDelete)
|
|
|
}
|
|
|
+ //if item.TwoOneCount == 0 {
|
|
|
+ // err = svc.DeleteTable("OilSupplierContrast", "Id = " + strconv.Itoa(item.Id))
|
|
|
+ //}
|
|
|
}
|
|
|
- if item.TwoOneCount == 0 {
|
|
|
- err = svc.DeleteTable("OilSupplierContrast", "Id = " + strconv.Itoa(item.Id))
|
|
|
- }
|
|
|
- }
|
|
|
- if err == nil {
|
|
|
- errinfo.Message = "修改成功!"
|
|
|
- errinfo.Code = 0
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- } else {
|
|
|
- errinfo.Message = "修改失败!"
|
|
|
- errinfo.Code = -1
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- }
|
|
|
+ this.CreateContrast()
|
|
|
+ }()
|
|
|
+ errinfo.Message = "更新中,请勿重复更新!"
|
|
|
+ errinfo.Code = 0
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
}
|