Ver Fonte

后:确认更新

dubch há 5 anos atrás
pai
commit
5643025a5e

+ 6 - 0
src/dashoo.cn/backend/api/business/oilsupplier/goodsaptitude/oilgoodsaptitude.go

@@ -290,6 +290,12 @@ type GoodsBusiness struct {
 	DeletionStateCode int
 }
 
+type GoodsBusiness1 struct {
+	Code              string
+	Name              string
+	GoodsLevel		  string
+}
+
 type OrganizeSet struct {
 	ClassId     int
 	OrganizeIds []string

+ 98 - 81
src/dashoo.cn/backend/api/controllers/oilsupplier/goodsaptitude.go

@@ -6,6 +6,7 @@ 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"
@@ -3021,110 +3022,126 @@ func (this *OilGoodsAptitudeController) PdfExport() {
 
 }
 
-// @Title 确认更新后的删除/暂停企业准入范围 2020-12-18
+// @Title 确认更新后的删除/更新 2020-12-18
 // @Description 修改实体
 // @Success	200	{object} controllers.Request
-// @router /delete-suspend [post]
-func (this *OilGoodsAptitudeController) DeleteSuspend() {
+// @router /deleteUpdate [post]
+func (this *OilGoodsAptitudeController) DeleteUpdate() {
+	var errinfo ErrorInfo
+	var err error
+	go func() {
+		svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
+		var list1 []goodsaptitude.GoodsBusiness1
+		svc.GetEntityJoin(&list1)
+		for _,item := range list1{
+			var subDelete suppliercertsub.OilSupplierCertSub1
+			cols := []string{"GoodsLevel", "Name"}
+			subDelete.GoodsLevel = item.GoodsLevel
+			subDelete.Name = item.Name
+			if item.GoodsLevel == "1" {
+				// 1降2修改
+				err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "SupplierTypeCode = '01' and Code = '" + item.Code + "'")
+			} else {
+				err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "SupplierTypeCode = '01' and GoodsLevel = '2' and Code = '" + item.Code + "'")
+				//2升1删除
+				err = svc.DeleteTable (OilSupplierCertSubName, "SupplierTypeCode = '01' and GoodsLevel = '1' and Code = '" + item.Code + "'")
+			}
+		}
+		err = svc.DeleteTableBySelect(OilSupplierCertSubName, OilGoodsAptitudeClassName, "a.SupplierTypeCode='02' AND b.Id IS NULL")
+	}()
+	errinfo.Message = "更新中,请勿重复更新!"
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+}
+
+// @Title 暂停企业准入范围 2020-12-18
+// @Description 修改实体
+// @Success	200	{object} controllers.Request
+// @router /suspend [post]
+func (this *OilGoodsAptitudeController) Suspend() {
 	var errinfo ErrorInfo
 	var err error
 	var list []supplier.OilSupplierContrast
 	svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
-	//svc.GetEntitysByWhere("OilSupplierContrast", "TwoOneCount = 0", &list)
+	svc.GetEntitysByWhere("OilSupplierContrast", "1=1", &list)
 	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 := "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 {
-					//2升1删除
-					if model[0]["GoodsLevel"] == "1" && itemSub.GoodsLevel == "2" {
-						err = svc.DeleteTable ("OilSupplierCertSub", "Id = " + strconv.Itoa(itemSub.Id))
-					}
-
-					//code := strings.Split(model[0]["Codes"], ",")
+					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))
-					}
-					//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
+					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))
+					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
+					}
 				}
 			}
-			//if item.TwoOneCount == 0 {
-			//	err = svc.DeleteTable("OilSupplierContrast", "Id = " + strconv.Itoa(item.Id))
-			//}
 		}
-		this.CreateContrast()
 	}()
 	errinfo.Message = "更新中,请勿重复更新!"
 	errinfo.Code = 0

+ 38 - 1
src/dashoo.cn/backend/api/controllers/oilsupplier/technologyservice.go

@@ -2127,7 +2127,44 @@ func (this *OilTechnologyServiceController) GetDelCertSubList() {
 // @Title 确认更新后的删除/暂停企业准入范围 2020-12-18
 // @Description 修改实体
 // @Success	200	{object} controllers.Request
-// @router /delete-suspend [post]
+// @router /deleteUpdate [post]
+func (this *OilTechnologyServiceController) DeleteUpdate() {
+	var errinfo ErrorInfo
+	var err error
+	var list []supplier.OilSupplierContrast
+	svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
+	//svc.GetEntitysByWhere("OilSupplierContrast", "TwoOneCount = 0", &list)
+	svc.GetEntitysByWhere("OilSupplierTecContrast", "1=1", &list)
+	go func() {
+		svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
+		var list1 []goodsaptitude.GoodsBusiness1
+		svc.GetEntityJoin(&list1)
+		for _,item := range list1{
+			var subDelete suppliercertsub.OilSupplierCertSub1
+			cols := []string{"GoodsLevel", "Name"}
+			subDelete.GoodsLevel = item.GoodsLevel
+			subDelete.Name = item.Name
+			if item.GoodsLevel == "1" {
+				// 1降2修改
+				err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "SupplierTypeCode = '03' and Code = '" + item.Code + "'")
+			} else {
+				err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "SupplierTypeCode = '03' and GoodsLevel = '2' and Code = '" + item.Code + "'")
+				//2升1删除
+				err = svc.DeleteTable (OilSupplierCertSubName, "SupplierTypeCode = '01' and GoodsLevel = '1' and Code = '" + item.Code + "'")
+			}
+		}
+		err = svc.DeleteTableBySelect(OilSupplierCertSubName, OilGoodsAptitudeClassName, "a.SupplierTypeCode='02' AND b.Id IS NULL")
+	}()
+	errinfo.Message = "更新中,请勿重复更新!"
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+}
+
+// @Title 确认更新后的删除/暂停企业准入范围 2020-12-18
+// @Description 修改实体
+// @Success	200	{object} controllers.Request
+// @router /suspend [post]
 func (this *OilTechnologyServiceController) DeleteSuspend() {
 	var errinfo ErrorInfo
 	var err error

+ 16 - 0
src/dashoo.cn/backend/api/mydb/myServiceBase.go

@@ -812,3 +812,19 @@ func (s *MyServiceBase) FindFileByCompany(tablename string, where string,entitie
 	LogError(err)
 	return
 }
+
+// delete + left join
+func (s *MyServiceBase) DeleteTableBySelect(tableName, tableName2, where string) error {
+	sql := "DELETE a from " + tableName + " a left join " + tableName2 + " b ON a.Code=b.Code "
+	if where != "" {
+		sql = sql + " Where " + where
+	}
+	_,err := s.DBE.Query(sql)
+	return err
+}
+
+func (s *MyServiceBase) GetEntityJoin(entityPtr interface{}) (has bool) {
+	sql := "SELECT a.GoodsLevel, class.Code, class.Name FROM OilGoodsAptitude a LEFT JOIN OilGoodsAptitudeClass class ON a.ClassId = class.Id "
+	s.DBE.SQL(sql).Find(entityPtr)
+	return
+}