|
|
@@ -7,6 +7,8 @@ import (
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/supplierfile"
|
|
|
"dashoo.cn/business2/parameter"
|
|
|
"encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "reflect"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
@@ -20,6 +22,18 @@ type OilSupplierCertAppendSubController struct {
|
|
|
BaseController
|
|
|
}
|
|
|
|
|
|
+type AppendChangeItemsAll struct {
|
|
|
+ InfochangeForm []appenditems
|
|
|
+ SupplierId string
|
|
|
+ MInfoId string
|
|
|
+}
|
|
|
+type appenditems struct {
|
|
|
+ SelectItem string
|
|
|
+ SelectItemName string
|
|
|
+ BeChangeInfo string
|
|
|
+ ChangeInfo string
|
|
|
+}
|
|
|
+
|
|
|
// @Title 获取列表
|
|
|
// @Description 获取列表
|
|
|
// @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
|
|
|
@@ -890,3 +904,120 @@ func (this *OilSupplierCertAppendSubController) UpdateManufacturerAppend() {
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// @Title 获取实体
|
|
|
+// @Description 获取实体
|
|
|
+// @Success 200 {object} supplier.OilSupplier
|
|
|
+// @router /getchangelist/:id [get]
|
|
|
+func (this *OilSupplierCertAppendSubController) GetChangeEntity() {
|
|
|
+ Id := this.Ctx.Input.Param(":id")
|
|
|
+ InfoId := this.GetString("InfomainId")
|
|
|
+ var models [2]supplier.OilSupplier
|
|
|
+ var model supplier.OilSupplier
|
|
|
+ var enumModel supplier.OilSupplier
|
|
|
+ svc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+ svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
|
|
|
+ models[0] = model
|
|
|
+
|
|
|
+ var infoitems []suppliercertappendsub.OilAppendChangeItem
|
|
|
+ where := " SupplierId = " + Id +" and InfoId ="+InfoId
|
|
|
+ where = where + " and ChangeStatus = 0"
|
|
|
+ svc.GetEntitysByWhere(OilAppendChangeItemName, where, &infoitems)
|
|
|
+ tmpModel := &model
|
|
|
+ enumModel = *tmpModel
|
|
|
+ immumodel := reflect.ValueOf(&enumModel)
|
|
|
+ elem := immumodel.Elem()
|
|
|
+ if len(infoitems) == 0 {
|
|
|
+ models[1] = enumModel
|
|
|
+ this.Data["json"] = &models
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ for _, info := range infoitems {
|
|
|
+ fmt.Println(info.SelectItem)
|
|
|
+ fmt.Println(";;;;;;;;;", elem.FieldByName(info.SelectItem).Type().String())
|
|
|
+ if elem.FieldByName(info.SelectItem).Type().String() == "int64" {
|
|
|
+ intchangeinfo, _ := strconv.ParseInt(info.ChangeInfo, 10, 64)
|
|
|
+ elem.FieldByName(info.SelectItem).SetInt(intchangeinfo)
|
|
|
+ } else if elem.FieldByName(info.SelectItem).Type().String() == "float64" {
|
|
|
+ floatchangeinfo, _ := strconv.ParseFloat(info.ChangeInfo, 64)
|
|
|
+ elem.FieldByName(info.SelectItem).SetFloat(floatchangeinfo)
|
|
|
+ } else if elem.FieldByName(info.SelectItem).Type().String() == "time.Time" {
|
|
|
+ t, _ := time.Parse("2006-01-02", info.ChangeInfo[0 : 10])
|
|
|
+ elem.FieldByName(info.SelectItem).Set(reflect.ValueOf(t))
|
|
|
+ } else {
|
|
|
+ elem.FieldByName(info.SelectItem).SetString(info.ChangeInfo)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ models[1] = enumModel
|
|
|
+ this.Data["json"] = &models
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取实体
|
|
|
+// @Description 获取实体
|
|
|
+// @Success 200 {object} annualaudit.OilAnnualAudit
|
|
|
+// @router /auditget/:id [get]
|
|
|
+func (this *OilSupplierCertAppendSubController) GetEntityThen() {
|
|
|
+ InfoId := this.Ctx.Input.Param(":id")
|
|
|
+ var model []suppliercertappendsub.OilAppendChangeItem
|
|
|
+ svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
|
|
|
+ where := " InfoId = " + InfoId
|
|
|
+ svc.GetEntitysByWhere(OilAppendChangeItemName, where, &model)
|
|
|
+ var datainfo DataInfo
|
|
|
+ datainfo.Items = model
|
|
|
+ this.Data["json"] = &datainfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 添加
|
|
|
+// @Description 新增
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /addinfochangeitemch [post]
|
|
|
+func (this *OilSupplierCertAppendSubController) AddInfoChangeItemCh() {
|
|
|
+ var model AppendChangeItemsAll
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
|
|
|
+ json.Unmarshal(jsonBlob, &model)
|
|
|
+ var err error
|
|
|
+ where := " SupplierId = " + model.SupplierId
|
|
|
+ where = where + " and InfoId = " + model.MInfoId
|
|
|
+
|
|
|
+ var deleteEntity suppliercertappendsub.OilAppendChangeItem
|
|
|
+ delMainId, _ := strconv.Atoi(model.MInfoId)
|
|
|
+ deleteEntity.InfoId = delMainId
|
|
|
+ svc.DBE.Delete(deleteEntity)
|
|
|
+
|
|
|
+ var infoitementitys []suppliercertappendsub.OilAppendChangeItem
|
|
|
+ for i := 0; i < len(model.InfochangeForm); i++ {
|
|
|
+ var infoitementity suppliercertappendsub.OilAppendChangeItem
|
|
|
+ infoitementity.SelectItem = model.InfochangeForm[i].SelectItem
|
|
|
+ infoitementity.SelectItemName = model.InfochangeForm[i].SelectItemName
|
|
|
+ infoitementity.ChangeInfo = model.InfochangeForm[i].ChangeInfo
|
|
|
+ infoitementity.BeChangeInfo = model.InfochangeForm[i].BeChangeInfo
|
|
|
+ infoitementity.ChangeStatus = 0
|
|
|
+ infoitementity.SupplierId, _ = strconv.Atoi(model.SupplierId)
|
|
|
+ infoitementity.InfoId, _ = strconv.Atoi(model.MInfoId)
|
|
|
+ infoitementity.CreateOn = time.Now()
|
|
|
+ infoitementity.CreateBy = this.User.Realname
|
|
|
+ infoitementity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ infoitementitys = append(infoitementitys, infoitementity)
|
|
|
+ }
|
|
|
+ _, err = svc.InsertEntityBytbl(""+OilAppendChangeItemName, &infoitementitys)
|
|
|
+
|
|
|
+ var errinfo ErrorDataInfo
|
|
|
+ if err == nil {
|
|
|
+ //新增
|
|
|
+ errinfo.Message = "添加成功!"
|
|
|
+ errinfo.Code = 0
|
|
|
+ //errinfo.Item = model.Id
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+}
|