|
@@ -6,6 +6,9 @@ import (
|
|
|
"dashoo.cn/backend/api/business/register"
|
|
"dashoo.cn/backend/api/business/register"
|
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
|
|
+ "github.com/tealeg/xlsx"
|
|
|
|
|
+ "log"
|
|
|
|
|
+ "os"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
"strings"
|
|
"strings"
|
|
|
"time"
|
|
"time"
|
|
@@ -498,7 +501,6 @@ func (this *OilSupplierController) GetJoinCertEntityList() {
|
|
|
where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
|
|
where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//企业用户只看自己的数据记录
|
|
//企业用户只看自己的数据记录
|
|
|
/*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
|
|
/*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
|
|
|
extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
|
|
extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
|
|
@@ -508,10 +510,10 @@ func (this *OilSupplierController) GetJoinCertEntityList() {
|
|
|
svc := supplier.GetOilSupplierService(utils.DBE)
|
|
svc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
var registerUser register.OilCorporateInfo
|
|
var registerUser register.OilCorporateInfo
|
|
|
sql := " UserName='" + this.User.Username + "'"
|
|
sql := " UserName='" + this.User.Username + "'"
|
|
|
- svc.GetEntity(®isterUser,sql)
|
|
|
|
|
|
|
+ svc.GetEntity(®isterUser, sql)
|
|
|
//企业用户必须加创建人条件
|
|
//企业用户必须加创建人条件
|
|
|
if this.User.IsCompanyUser == 1 {
|
|
if this.User.IsCompanyUser == 1 {
|
|
|
- where = where + " and (a.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='"+registerUser.CommercialNo+"')"
|
|
|
|
|
|
|
+ where = where + " and (a.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
|
|
|
} else {
|
|
} else {
|
|
|
//超级管理员和有查看所有数据权限的用户不加条件
|
|
//超级管理员和有查看所有数据权限的用户不加条件
|
|
|
svcPerm := permission.GetPermissionService(utils.DBE)
|
|
svcPerm := permission.GetPermissionService(utils.DBE)
|
|
@@ -522,7 +524,6 @@ func (this *OilSupplierController) GetJoinCertEntityList() {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
var list []supplier.OilSupplierView
|
|
var list []supplier.OilSupplierView
|
|
|
|
|
|
|
|
total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
|
|
total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
|
|
@@ -536,7 +537,6 @@ func (this *OilSupplierController) GetJoinCertEntityList() {
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// @Title 获取集中评审列表
|
|
// @Title 获取集中评审列表
|
|
|
// @Description get user by token
|
|
// @Description get user by token
|
|
|
// @Success 200 {object} []supplier.OilSupplier
|
|
// @Success 200 {object} []supplier.OilSupplier
|
|
@@ -688,16 +688,16 @@ func (this *OilSupplierController) GetJZPSJoinCertEntityList() {
|
|
|
var certIdList string
|
|
var certIdList string
|
|
|
ids := actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
|
|
ids := actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
|
|
|
if len(strings.Trim(ids, ",")) > 0 {
|
|
if len(strings.Trim(ids, ",")) > 0 {
|
|
|
- certIdList += strings.Trim(ids, ",")+ ","
|
|
|
|
|
|
|
+ certIdList += strings.Trim(ids, ",") + ","
|
|
|
}
|
|
}
|
|
|
ids = actisvc.GetAllMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
|
|
ids = actisvc.GetAllMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
|
|
|
if len(strings.Trim(ids, ",")) > 0 {
|
|
if len(strings.Trim(ids, ",")) > 0 {
|
|
|
- certIdList += strings.Trim(ids, ",")+ ","
|
|
|
|
|
|
|
+ certIdList += strings.Trim(ids, ",") + ","
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ids = actisvc.GetAllMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
|
|
ids = actisvc.GetAllMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
|
|
|
if len(strings.Trim(ids, ",")) > 0 {
|
|
if len(strings.Trim(ids, ",")) > 0 {
|
|
|
- certIdList += strings.Trim(ids, ",")+ ","
|
|
|
|
|
|
|
+ certIdList += strings.Trim(ids, ",") + ","
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//ids = actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
|
|
//ids = actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
|
|
@@ -1418,7 +1418,6 @@ func (this *OilSupplierController) GetDictListByStatus() {
|
|
|
dictList["MgrUnit"] = false
|
|
dictList["MgrUnit"] = false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
var datainfo DataInfo
|
|
var datainfo DataInfo
|
|
|
datainfo.Items = dictList
|
|
datainfo.Items = dictList
|
|
|
this.Data["json"] = &datainfo
|
|
this.Data["json"] = &datainfo
|
|
@@ -1479,13 +1478,13 @@ func (this *OilSupplierController) GetEntityByName() {
|
|
|
sqlsus += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id`
|
|
sqlsus += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id`
|
|
|
sqlsus += ` where a.SupplierName ='` + name + `' and b.InFlag='2' and b.SupplierTypeCode='` + typecode + `'`
|
|
sqlsus += ` where a.SupplierName ='` + name + `' and b.InFlag='2' and b.SupplierTypeCode='` + typecode + `'`
|
|
|
var tempMap []map[string]string
|
|
var tempMap []map[string]string
|
|
|
- tempMap,_=svc.DBE.QueryString(sqlsus)
|
|
|
|
|
|
|
+ tempMap, _ = svc.DBE.QueryString(sqlsus)
|
|
|
|
|
|
|
|
- if tempMap!=nil && tempMap[0]["1"] !=""{
|
|
|
|
|
|
|
+ if tempMap != nil && tempMap[0]["1"] != "" {
|
|
|
datainfo.Code = -1
|
|
datainfo.Code = -1
|
|
|
this.Data["json"] = &datainfo
|
|
this.Data["json"] = &datainfo
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
var sql string
|
|
var sql string
|
|
|
sql = `select a.*,b.InStyle,b.Status from ` + OilSupplierName + ` a `
|
|
sql = `select a.*,b.InStyle,b.Status from ` + OilSupplierName + ` a `
|
|
|
sql += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id and b.SupplierTypeCode='` + typecode + `'`
|
|
sql += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id and b.SupplierTypeCode='` + typecode + `'`
|
|
@@ -1509,7 +1508,7 @@ func (this *OilSupplierController) GetEntityByName() {
|
|
|
this.Data["json"] = &datainfo
|
|
this.Data["json"] = &datainfo
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
datainfo.Code = 0
|
|
datainfo.Code = 0
|
|
|
datainfo.Item = model
|
|
datainfo.Item = model
|
|
|
this.Data["json"] = &datainfo
|
|
this.Data["json"] = &datainfo
|
|
@@ -1533,7 +1532,7 @@ func (this *OilSupplierController) AddEntity() {
|
|
|
serviceCert := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
serviceCert := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
var registerUser register.OilCorporateInfo
|
|
var registerUser register.OilCorporateInfo
|
|
|
sql := " UserName='" + this.User.Username + "'"
|
|
sql := " UserName='" + this.User.Username + "'"
|
|
|
- serviceCert.GetEntity(®isterUser,sql)
|
|
|
|
|
|
|
+ serviceCert.GetEntity(®isterUser, sql)
|
|
|
canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
|
|
canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
|
|
|
var errinfo ErrorDataInfo
|
|
var errinfo ErrorDataInfo
|
|
|
if !canApply {
|
|
if !canApply {
|
|
@@ -1671,7 +1670,7 @@ func (this *OilSupplierController) UpdateEntity() {
|
|
|
updateCols := svc.GetUpdateCols(OilSupplierCertName, typeCode, model.Id)
|
|
updateCols := svc.GetUpdateCols(OilSupplierCertName, typeCode, model.Id)
|
|
|
err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, updateCols)
|
|
err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, updateCols)
|
|
|
if err == nil {
|
|
if err == nil {
|
|
|
- svc.DBE.Exec("update OilSupplierCert set Instyle="+instyle+" where SupplierId="+id+" and SupplierTypeCode="+typeCode+"")
|
|
|
|
|
|
|
+ svc.DBE.Exec("update OilSupplierCert set Instyle=" + instyle + " where SupplierId=" + id + " and SupplierTypeCode=" + typeCode + "")
|
|
|
errinfo.Message = "修改成功!"
|
|
errinfo.Message = "修改成功!"
|
|
|
errinfo.Code = 0
|
|
errinfo.Code = 0
|
|
|
this.Data["json"] = &errinfo
|
|
this.Data["json"] = &errinfo
|
|
@@ -1797,19 +1796,19 @@ func (this *OilSupplierController) DeleteAllEntity() {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
svc := supplier.GetOilSupplierService(utils.DBE)
|
|
svc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
- err:=svc.DeleteEntityBytbl(OilSupplierCertName,"SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
|
|
|
|
|
- err =svc.DeleteEntityBytbl(OilSupplierCert2FileName,"SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
|
|
|
|
|
- err =svc.DeleteEntityBytbl(OilSupplierFileName,"SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
|
|
|
|
|
|
|
+ err := svc.DeleteEntityBytbl(OilSupplierCertName, "SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
|
|
|
|
|
+ err = svc.DeleteEntityBytbl(OilSupplierCert2FileName, "SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
|
|
|
|
|
+ err = svc.DeleteEntityBytbl(OilSupplierFileName, "SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
|
|
|
|
|
|
|
|
var model1 suppliercertsub.OilSupplierCert2File
|
|
var model1 suppliercertsub.OilSupplierCert2File
|
|
|
count1, _ := svc.GetCount(&model1, "SupplierId="+Id)
|
|
count1, _ := svc.GetCount(&model1, "SupplierId="+Id)
|
|
|
- if count1==0{
|
|
|
|
|
- err=svc.DeleteEntityBytbl(OilSupplierFileName,"SupplierId="+Id)
|
|
|
|
|
|
|
+ if count1 == 0 {
|
|
|
|
|
+ err = svc.DeleteEntityBytbl(OilSupplierFileName, "SupplierId="+Id)
|
|
|
}
|
|
}
|
|
|
var model2 suppliercert.OilSupplierCert
|
|
var model2 suppliercert.OilSupplierCert
|
|
|
count2, _ := svc.GetCount(&model2, "SupplierId="+Id)
|
|
count2, _ := svc.GetCount(&model2, "SupplierId="+Id)
|
|
|
- if count2==0{
|
|
|
|
|
- err=svc.DeleteEntityBytbl(OilSupplierName,"Id="+Id)
|
|
|
|
|
|
|
+ if count2 == 0 {
|
|
|
|
|
+ err = svc.DeleteEntityBytbl(OilSupplierName, "Id="+Id)
|
|
|
}
|
|
}
|
|
|
if err == nil {
|
|
if err == nil {
|
|
|
errinfo.Message = "删除成功"
|
|
errinfo.Message = "删除成功"
|
|
@@ -1823,6 +1822,7 @@ func (this *OilSupplierController) DeleteAllEntity() {
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// @Title 判断是否可以申请准入
|
|
// @Title 判断是否可以申请准入
|
|
|
// @Description
|
|
// @Description
|
|
|
// @Success 200 {string} Count
|
|
// @Success 200 {string} Count
|
|
@@ -1842,27 +1842,27 @@ func (this *OilSupplierController) IsCanApply() {
|
|
|
svc := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
svc := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
var registerUser register.OilCorporateInfo
|
|
var registerUser register.OilCorporateInfo
|
|
|
sql := " UserName='" + this.User.Username + "'"
|
|
sql := " UserName='" + this.User.Username + "'"
|
|
|
- svc.GetEntity(®isterUser,sql)
|
|
|
|
|
|
|
+ svc.GetEntity(®isterUser, sql)
|
|
|
canApply := svc.IsCanApplyByExtOrganizeUser(Type, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
|
|
canApply := svc.IsCanApplyByExtOrganizeUser(Type, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
|
|
|
|
|
|
|
|
if canApply {
|
|
if canApply {
|
|
|
//判断是否是暂停
|
|
//判断是否是暂停
|
|
|
- if this.User.IsCompanyUser==1{
|
|
|
|
|
|
|
+ if this.User.IsCompanyUser == 1 {
|
|
|
var tempMap []map[string]string
|
|
var tempMap []map[string]string
|
|
|
- sql:= "select 1 from OilSupplier a left join OilSupplierCert b on a.Id=b.SupplierId where (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='"+ registerUser.CommercialNo+"') and b.InFlag='2' and b.SupplierTypeCode='"+Type+"'"
|
|
|
|
|
- tempMap,_=svc.DBE.QueryString(sql)
|
|
|
|
|
- if tempMap!=nil && tempMap[0]["1"] !="" {
|
|
|
|
|
|
|
+ sql := "select 1 from OilSupplier a left join OilSupplierCert b on a.Id=b.SupplierId where (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "') and b.InFlag='2' and b.SupplierTypeCode='" + Type + "'"
|
|
|
|
|
+ tempMap, _ = svc.DBE.QueryString(sql)
|
|
|
|
|
+ if tempMap != nil && tempMap[0]["1"] != "" {
|
|
|
errinfo.Message = "已暂停,不可申请"
|
|
errinfo.Message = "已暂停,不可申请"
|
|
|
errinfo.Code = -2
|
|
errinfo.Code = -2
|
|
|
this.Data["json"] = &errinfo
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
errinfo.Message = "无申请记录,可以申请"
|
|
errinfo.Message = "无申请记录,可以申请"
|
|
|
errinfo.Code = 0
|
|
errinfo.Code = 0
|
|
|
this.Data["json"] = &errinfo
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
errinfo.Message = "无申请记录,可以申请"
|
|
errinfo.Message = "无申请记录,可以申请"
|
|
|
errinfo.Code = 0
|
|
errinfo.Code = 0
|
|
|
this.Data["json"] = &errinfo
|
|
this.Data["json"] = &errinfo
|
|
@@ -1965,7 +1965,7 @@ func (this *OilSupplierController) GetFirAuditerByDept() {
|
|
|
userIds := strings.Replace(tempstr, "uid_", "", -1)
|
|
userIds := strings.Replace(tempstr, "uid_", "", -1)
|
|
|
userIds = strings.Trim(userIds, ",")
|
|
userIds = strings.Trim(userIds, ",")
|
|
|
if userIds != "" {
|
|
if userIds != "" {
|
|
|
- where := "Id in (" + userIds + ")" + "and (UnitId=" + Id + " or Departmentid in (" + alldep +")) "
|
|
|
|
|
|
|
+ where := "Id in (" + userIds + ")" + "and (UnitId=" + Id + " or Departmentid in (" + alldep + ")) "
|
|
|
svc.GetEntities(&userlist, where)
|
|
svc.GetEntities(&userlist, where)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2042,7 +2042,6 @@ func (this *OilSupplierController) GetAuditerByDeptAndNoLogin() {
|
|
|
svc.GetEntities(&userlist, where)
|
|
svc.GetEntities(&userlist, where)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
//certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
//var users []userRole.Base_RoleList
|
|
//var users []userRole.Base_RoleList
|
|
|
//certSrv.GetAuditUser(Id, auditstepcode, &users)
|
|
//certSrv.GetAuditUser(Id, auditstepcode, &users)
|
|
@@ -2053,8 +2052,6 @@ func (this *OilSupplierController) GetAuditerByDeptAndNoLogin() {
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
// @Title
|
|
// @Title
|
|
|
// @Description
|
|
// @Description
|
|
|
// @router /getjurisdiction [get]
|
|
// @router /getjurisdiction [get]
|
|
@@ -2072,7 +2069,7 @@ func (this *OilSupplierController) GetJurisdiction() {
|
|
|
// @Description get user by token
|
|
// @Description get user by token
|
|
|
// @Success 200 {object} []supplier.OilSupplier
|
|
// @Success 200 {object} []supplier.OilSupplier
|
|
|
// @router /certlistinterface [get]
|
|
// @router /certlistinterface [get]
|
|
|
-func (this *OilSupplierController) GetEntityListInterface () {
|
|
|
|
|
|
|
+func (this *OilSupplierController) GetEntityListInterface() {
|
|
|
|
|
|
|
|
//获取分页信息
|
|
//获取分页信息
|
|
|
//page := this.GetPageInfoForm()
|
|
//page := this.GetPageInfoForm()
|
|
@@ -2091,9 +2088,9 @@ func (this *OilSupplierController) GetEntityListInterface () {
|
|
|
|
|
|
|
|
if status == "1" {
|
|
if status == "1" {
|
|
|
where += "b.InStyle='1'"
|
|
where += "b.InStyle='1'"
|
|
|
- } else if status == "2" {
|
|
|
|
|
|
|
+ } else if status == "2" {
|
|
|
where += "b.InStyle='4'"
|
|
where += "b.InStyle='4'"
|
|
|
- } else if status == "3" {
|
|
|
|
|
|
|
+ } else if status == "3" {
|
|
|
where += "b.InStyle='5'"
|
|
where += "b.InStyle='5'"
|
|
|
} else if status == "4" {
|
|
} else if status == "4" {
|
|
|
where += "b.InStyle=''"
|
|
where += "b.InStyle=''"
|
|
@@ -2102,7 +2099,7 @@ func (this *OilSupplierController) GetEntityListInterface () {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
svc := supplier.GetOilSupplierService(utils.DBE)
|
|
svc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
- var interfaceData []supplier.InterfaceData
|
|
|
|
|
|
|
+ var interfaceData []supplier.InterfaceData
|
|
|
err := svc.GetInterfaceData(OilSupplierName, OilSupplierFileName, &interfaceData, where)
|
|
err := svc.GetInterfaceData(OilSupplierName, OilSupplierFileName, &interfaceData, where)
|
|
|
|
|
|
|
|
var errinfo ErrorDataInfo
|
|
var errinfo ErrorDataInfo
|
|
@@ -2136,7 +2133,6 @@ func (this *OilSupplierController) GetEntityByCommercialNo() {
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// @Title 更新文件上传
|
|
// @Title 更新文件上传
|
|
|
// @Description 更新文件上传
|
|
// @Description 更新文件上传
|
|
|
// @Param id path string true
|
|
// @Param id path string true
|
|
@@ -2163,7 +2159,7 @@ func (this *OilSupplierController) EditSubfile() {
|
|
|
model.CreateBy = this.User.Realname
|
|
model.CreateBy = this.User.Realname
|
|
|
model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
|
|
|
|
|
- _,err := svc.InsertEntity(&model)
|
|
|
|
|
|
|
+ _, err := svc.InsertEntity(&model)
|
|
|
|
|
|
|
|
if err == nil {
|
|
if err == nil {
|
|
|
errinfo.Message = "操作成功!"
|
|
errinfo.Message = "操作成功!"
|
|
@@ -2178,21 +2174,82 @@ func (this *OilSupplierController) EditSubfile() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// @Title get 导入excel
|
|
|
|
|
+// @Description get SampleType by token
|
|
|
|
|
+// @Success 200 {object} sampletype.SampleType
|
|
|
|
|
+// @router /importexcel [get]
|
|
|
|
|
+func (this *OilSupplierController) ImportExcel() {
|
|
|
|
|
+
|
|
|
|
|
+ url := this.GetString("ExcelUrl")
|
|
|
|
|
+ var errorinfo ErrorInfo
|
|
|
|
|
+ if url == "" {
|
|
|
|
|
+ errorinfo.Code = -2
|
|
|
|
|
+ errorinfo.Message = "导入失败!"
|
|
|
|
|
+ this.Data["json"] = &errorinfo
|
|
|
|
|
+ this.ServeJSON()
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ svc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
|
|
|
|
|
|
|
+ _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
|
|
|
|
|
+ filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
|
|
|
|
|
+ utils.DownloadFile(url, filename, _dir)
|
|
|
|
|
+ t := time.Now()
|
|
|
|
|
+ filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
|
|
|
|
|
+ xlFile, err := xlsx.OpenFile(filePath)
|
|
|
|
|
|
|
|
|
|
+ //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Printf("open failed: %s\n", err)
|
|
|
|
|
+ }
|
|
|
|
|
+ var sheet = xlFile.Sheets[0]
|
|
|
|
|
|
|
|
|
|
+ var errLineNum string
|
|
|
|
|
|
|
|
|
|
+ for i := 1; i < len(sheet.Rows); i++ {
|
|
|
|
|
+ lineNo := strconv.Itoa(i + 1)
|
|
|
|
|
+ if len(sheet.Rows[i].Cells) != 0 {
|
|
|
|
|
+ this.OperationCell(svc, lineNo, sheet.Rows[i].Cells, &errLineNum)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ os.Remove(filePath)
|
|
|
|
|
|
|
|
|
|
+ if errLineNum != "" {
|
|
|
|
|
+ errorinfo.Code = -1
|
|
|
|
|
+ errorinfo.Message = "导入失败!错误行号:" + errLineNum
|
|
|
|
|
+ this.Data["json"] = &errorinfo
|
|
|
|
|
+ this.ServeJSON()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ elapsed := time.Since(t)
|
|
|
|
|
+ log.Println(elapsed)
|
|
|
|
|
+ errorinfo.Code = 0
|
|
|
|
|
+ errorinfo.Message = "导入成功!"
|
|
|
|
|
+ this.Data["json"] = &errorinfo
|
|
|
|
|
+ this.ServeJSON()
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
+func (this *OilSupplierController) OperationCell(svc *supplier.OilSupplierService, lineNo string, cellsArr []*xlsx.Cell, errLineNum *string) {
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ defer func() {
|
|
|
|
|
+ if err := recover(); err != nil {
|
|
|
|
|
+ log.Println("err"+lineNo, err)
|
|
|
|
|
+ *errLineNum += lineNo + ","
|
|
|
|
|
+ }
|
|
|
|
|
+ }()
|
|
|
|
|
+
|
|
|
|
|
+ cells := cellsArr
|
|
|
|
|
+ supplierName := strings.TrimSpace(cells[0].Value)
|
|
|
|
|
+ oilCertificateNo := ""
|
|
|
|
|
+ if len(cells) >= 2 {
|
|
|
|
|
+ oilCertificateNo = strings.TrimSpace(cells[1].Value)
|
|
|
|
|
+ }
|
|
|
|
|
+ cols := []string{"PACNumber"}
|
|
|
|
|
+ var entity supplier.OilSupplier
|
|
|
|
|
+ entity.PACNumber = oilCertificateNo
|
|
|
|
|
+ where := "SupplierName='" + supplierName + "'"
|
|
|
|
|
+ err := svc.UpdateEntityBywheretbl(OilSupplierName, &entity, cols, where)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ panic(err)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|