2
3
Переглянути джерело

后端: 系统参数配置添加 增项每年申请次数配置并使用

baichengfei 4 роки тому
батько
коміт
fcb39c8dee

+ 9 - 4
src/dashoo.cn/backend/api/controllers/oilsupplier/suppliercertappend.go

@@ -217,8 +217,8 @@ func (this *OilSupplierCertAppendController) AddAppend() {
 		}
 		var cert suppliercert.OilSupplierCert
 		svc.GetEntityById(model.SupplierCertId, &cert)
+		paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
 		if cert.IsRestrict == 1 {
-			paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
 			sAddLimitMonth, _ := strconv.Atoi(paramSvc.GetBaseparameterMessage("GFGL1", "paramset", "sAddLimitMonth"))
 			fmt.Println(modeltmp[0].AuditDate)
 			ApplyDate, _ := time.Parse("2006-01-02", modeltmp[0].ApplyDate.AddDate(0, sAddLimitMonth, 0).Format("2006-01-02"))
@@ -245,8 +245,13 @@ func (this *OilSupplierCertAppendController) AddAppend() {
 					count, _ = strconv.ParseInt(string(value), 10, 64)
 					break
 				}
-				if count >= 2 {
-					errinfo.Message = "除招标准入外,增项申请每年只能申请2次!"
+				appendApplyNumsStr := paramSvc.GetBaseparameterMessage("GFGL1", "paramset", "appendApplyNums")
+				if appendApplyNumsStr == "" {
+					appendApplyNumsStr = "1"
+				}
+				appendApplyNums, _ := strconv.Atoi(appendApplyNumsStr)
+				if count >= int64(appendApplyNums) {
+					errinfo.Message = "除招标准入外,增项申请每年只能申请" + appendApplyNumsStr + "次!"
 					errinfo.Code = -1
 					errinfo.Info = model.Id
 					this.Data["json"] = &errinfo
@@ -387,7 +392,7 @@ func (this *OilSupplierCertAppendController) DeleteEntity() {
 	}
 
 	// 删除增项资质文件
-	err = svcSub.DeleteEntityBytbl(OilAppendChangeDetailName, " ParentId = " + Id)
+	err = svcSub.DeleteEntityBytbl(OilAppendChangeDetailName, " ParentId = "+Id)
 	if err != nil {
 		//回滚操作
 		session.Rollback()

+ 55 - 55
src/dashoo.cn/backend/api/controllers/setting/paramset.go

@@ -14,11 +14,12 @@ type ParamSetController struct {
 }
 
 type ParamSerModel struct {
-	IsInvestigate  bool   `json:"isInvestigate"`
-	IsGetBarCode   bool   `json:"isGetBarCode"`
-	SAddLimitMonth string `json:"sAddLimitMonth"`
-	SFlupLastDay   int    `json:"sFlupLastDay"`
-	STestFrontDay  int    `json:"sTestFrontDay"`
+	IsInvestigate   bool   `json:"isInvestigate"`
+	IsGetBarCode    bool   `json:"isGetBarCode"`
+	SAddLimitMonth  string `json:"sAddLimitMonth"`
+	AppendApplyNums string `json:"appendApplyNums"`
+	SFlupLastDay    int    `json:"sFlupLastDay"`
+	STestFrontDay   int    `json:"sTestFrontDay"`
 }
 type ParamModel struct {
 	// 每次新增变量参数时在这继续添加即可
@@ -37,66 +38,65 @@ type ParamModel struct {
 func (this *ParamSetController) ParamSetPost() {
 
 	var model ParamSerModel
-	var jsonblob = this.Ctx.Input.RequestBody
-	json.Unmarshal(jsonblob, &model)
-	var paramentity baseparameter.Base_Parameter
-	var paramentitylist []baseparameter.Base_Parameter
+	var jsonBlob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonBlob, &model)
 
 	svc := baseparameter.GetBaseparameterService(utils.DBE)
-	AccCode := "GFGL1"
-	svc.DeleteParam(AccCode, "paramset") //删除所有的参数
 
+	// 公共参数
+	cols := []string{
+		"Parametercontent",
+	}
+	where := "Categoryid='GFGL1' and Parameterid='paramset' and Parametercode="
+
+	// 是否需要现场考察报告
 	var sisInvestigate string
 	if model.IsInvestigate {
 		sisInvestigate = "true"
 	} else {
 		sisInvestigate = "false"
 	}
-	paramentity.Categoryid = AccCode
-	paramentity.Parameterid = "paramset"
-	paramentity.Parametercode = "isInvestigate"
-	paramentity.Parametercontent = sisInvestigate
-	paramentity.Createuserid, _ = utils.StrTo(this.User.Id).Int()
-	paramentity.Createby = this.User.Realname
-	paramentitylist = append(paramentitylist, paramentity)
-
-	//paramentity.Parametercode = "isGetBarCode"
-	//fmt.Println(this.GetString("isGetBarCode"))
-	//if model.IsGetBarCode {
-	//	paramentity.Parametercontent = "true"
-	//} else {
-	//	paramentity.Parametercontent = "false"
-	//}
-	//paramentitylist = append(paramentitylist, paramentity)
-	//
-	paramentity.Parametercode = "sAddLimitMonth"
-	sAddLimitMonth := utils.ToStr(model.SAddLimitMonth)
-	paramentity.Parametercontent = sAddLimitMonth
-	paramentitylist = append(paramentitylist, paramentity)
-	//
-	//paramentity.Parametercode = "sFlupLastDay"
-	//sFlupLastDay := utils.ToStr(model.SFlupLastDay)
-	//paramentity.Parametercontent = sFlupLastDay
-	//paramentitylist = append(paramentitylist, paramentity)
-	//
-	//paramentity.Parametercode = "sTestFrontDay"
-	//sTestFrontDay := utils.ToStr(model.STestFrontDay)
-	//paramentity.Parametercontent = sTestFrontDay
-	//paramentitylist = append(paramentitylist, paramentity)
-
-	_, err := svc.InsertEntity(&paramentitylist)
-	var errinfo ErrorInfo
-	if err == nil {
-		errinfo.Message = utils.AlertProcess("参数设置成功!")
-		errinfo.Code = 0
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	} else {
-		errinfo.Message = utils.AlertProcess("参数设置失败!" + err.Error())
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
+	var isInvEntity baseparameter.Base_Parameter
+	svc.GetEntity(&isInvEntity, where+"'isInvestigate'")
+	if isInvEntity.Id > 0 {
+		isInvEntity.Parametercontent = sisInvestigate
+		isInvEntity.Modifieduserid, _ = utils.StrTo(this.User.Id).Int()
+		isInvEntity.Modifiedby = this.User.Realname
+		svc.UpdateEntityByIdCols(isInvEntity.Id, isInvEntity, cols)
+	}
+
+	// 增项申请时间间隔
+	var lmEntity baseparameter.Base_Parameter
+	svc.GetEntity(&lmEntity, where+"'sAddLimitMonth'")
+	if lmEntity.Id > 0 {
+		if model.SAddLimitMonth == "" {
+			model.SAddLimitMonth = "0"
+		}
+		lmEntity.Parametercontent = model.SAddLimitMonth
+		lmEntity.Modifieduserid, _ = utils.StrTo(this.User.Id).Int()
+		lmEntity.Modifiedby = this.User.Realname
+		svc.UpdateEntityByIdCols(lmEntity.Id, lmEntity, cols)
+	}
+
+	// 增项申请次数 每年
+	var applyNumEntity baseparameter.Base_Parameter
+	svc.GetEntity(&applyNumEntity, where+"'appendApplyNums'")
+	if applyNumEntity.Id > 0 {
+		if model.AppendApplyNums == "" {
+			model.AppendApplyNums = "2"
+		}
+		applyNumEntity.Parametercontent = model.AppendApplyNums
+		applyNumEntity.Modifieduserid, _ = utils.StrTo(this.User.Id).Int()
+		applyNumEntity.Modifiedby = this.User.Realname
+		svc.UpdateEntityByIdCols(applyNumEntity.Id, applyNumEntity, cols)
 	}
+
+	//_, err := svc.InsertEntity(&paramEntityList)
+	var errInfo ErrorInfo
+	errInfo.Message = utils.AlertProcess("参数设置成功!")
+	errInfo.Code = 0
+	this.Data["json"] = &errInfo
+	this.ServeJSON()
 }
 
 // @Title 读取参数