|
|
@@ -5,6 +5,7 @@ import (
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/supplier"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/suppliercert"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/supplierpausereason"
|
|
|
+ "dashoo.cn/backend/api/business/oilsupplier/tableheader"
|
|
|
"dashoo.cn/backend/api/business/organize"
|
|
|
"dashoo.cn/business2/parameter"
|
|
|
"encoding/json"
|
|
|
@@ -363,7 +364,6 @@ func (this *OilSupplierCertSubController) AddGoodsBus() {
|
|
|
svcSupplier := supplier.GetOilSupplierService(utils.DBE)
|
|
|
svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
|
|
|
|
|
|
-LABEL1:
|
|
|
for n := 0; n < len(dataother.CheckList); n++ {
|
|
|
where_sub := "SupplierTypeCode = 01 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
|
|
|
where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
|
|
|
@@ -396,22 +396,21 @@ LABEL1:
|
|
|
needList := filesvc.GetGoodsNeedFileList(dataother.CheckList[n].Id, strconv.Itoa(datamain.IsManufacturer)) // 需要的资质
|
|
|
paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
|
|
|
|
- //isContinue := false
|
|
|
+ isContinue := false
|
|
|
if datamain.IsManufacturer == 2 {
|
|
|
needList1 := filesvc.GetGoodsNeedFileList(dataother.CheckList[n].Id, "1") // 需要的资质--制造类
|
|
|
// 中油集团公司产品质量认可证书
|
|
|
CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
|
|
|
for _, item := range needList1 {
|
|
|
if item.FileName == CNPCrenkezhengshu {
|
|
|
- continue LABEL1
|
|
|
- //isContinue = true
|
|
|
- //break
|
|
|
+ isContinue = true
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //if isContinue {
|
|
|
- // break
|
|
|
- //}
|
|
|
+ if isContinue {
|
|
|
+ break
|
|
|
+ }
|
|
|
svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
|
|
|
|
|
|
if supplierCertModel.InStyle == "4" {
|
|
|
@@ -486,6 +485,127 @@ LABEL1:
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
|
|
|
+// @Title 批量添加准入范围--物资类
|
|
|
+// @Description 批量添加准入范围
|
|
|
+// @Success 200 {object} business.device.DeviceChannels
|
|
|
+// @router /add-goods-certsub-filter [post]
|
|
|
+func (this *OilSupplierCertSubController) AddGoodsByFilter() {
|
|
|
+ var jsonblob = this.Ctx.Input.RequestBody
|
|
|
+ var datamain suppliercertsub.OilSupplierCertSub
|
|
|
+ var dataother suppliercertsub.SupplierCertSubModel
|
|
|
+
|
|
|
+ json.Unmarshal(jsonblob, &datamain)
|
|
|
+ json.Unmarshal(jsonblob, &dataother)
|
|
|
+
|
|
|
+ var supplierCertModel suppliercert.OilSupplierCert
|
|
|
+ svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
+ svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
|
|
|
+
|
|
|
+ // 查询出已有哪些资质
|
|
|
+ supplierId := dataother.SupplierId
|
|
|
+ supplierTypeCode := dataother.SupplierTypeCode
|
|
|
+ var tableheaderList []tableheader.BaseTableheader
|
|
|
+
|
|
|
+ fileSql := "SELECT b.* from OilSupplierFile a LEFT JOIN Base_TableHeader b on a.NeedFileType=b.Name AND "
|
|
|
+ fileSql += " a.SupplierTypeCode=b.CategoryCode WHERE a.SupplierId='" + strconv.Itoa(supplierId) + "'"
|
|
|
+ fileSql += " AND (a.SupplierTypeCode='" + supplierTypeCode + "' or a.SupplierTypeCode='000')"
|
|
|
+
|
|
|
+ svcHeader := tableheader.GetTableHeaderService(utils.DBE)
|
|
|
+ svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
|
|
|
+ var companyHasHeaders string
|
|
|
+ for _, tableheader := range tableheaderList {
|
|
|
+ companyHasHeaders += tableheader.Name + ","
|
|
|
+ }
|
|
|
+ var supplierModel supplier.OilSupplier
|
|
|
+ svcSupplier := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+ svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
|
|
|
+
|
|
|
+ // 记录缺少的证件
|
|
|
+ invalidCertMsg := ""
|
|
|
+ // 记录保存条数
|
|
|
+ vaildCnt := 0
|
|
|
+ //逐条检查需要的资质,符合才会保存
|
|
|
+ for n := 0; n < len(dataother.CheckList); n++ {
|
|
|
+ where_sub := "SupplierTypeCode = 01 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
|
|
|
+ where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
|
|
|
+ where_sub += " and SubClassId = '" + dataother.CheckList[n].Id + "'"
|
|
|
+ var model suppliercertsub.OilSupplierCertSub
|
|
|
+ svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
|
|
|
+ has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
|
|
|
+ if !has {
|
|
|
+ if supplierModel.OperType == "制造商" {
|
|
|
+ datamain.IsManufacturer = 1
|
|
|
+ } else {
|
|
|
+ datamain.IsManufacturer = 2
|
|
|
+ }
|
|
|
+ //检查是否资质全面
|
|
|
+ paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
|
+ filesvc := supplierfile.GetSupplierfileService(utils.DBE)
|
|
|
+ needList := filesvc.GetGoodsNeedFileList(dataother.CheckList[n].Id, strconv.Itoa(datamain.IsManufacturer)) // 需要的资质
|
|
|
+ //三证合一或五证合一不需要的字段
|
|
|
+ mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
|
|
|
+ if supplierCertModel.InStyle == "4" {
|
|
|
+ var needFile supplierfile.FileList
|
|
|
+ //战略合作协议扫描件
|
|
|
+ needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
|
|
|
+ needList = append(needList, needFile)
|
|
|
+ }
|
|
|
+ if datamain.IsManufacturer == 2 { //非制造商
|
|
|
+ var needFile supplierfile.FileList
|
|
|
+ // 中油集团公司产品质量认可证书
|
|
|
+ CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
|
|
|
+ needFile.FileName = CNPCrenkezhengshu
|
|
|
+ needList = append(needList, needFile)
|
|
|
+ }
|
|
|
+
|
|
|
+ certsValid := true
|
|
|
+ for _, needHeader := range needList {
|
|
|
+ if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") &&
|
|
|
+ strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
|
|
|
+ //三证合一或五证合一的证件,不需要验证了
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if !strings.Contains(companyHasHeaders, needHeader.FileName + ",") {
|
|
|
+ //缺少资质,不会保存
|
|
|
+ invalidCertMsg += dataother.CheckList[n].Code + " " + dataother.CheckList[n].Name + "(缺少:" + needHeader.FileName + ") ,"
|
|
|
+ certsValid = false
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !certsValid {
|
|
|
+ //缺少资质,不会保存
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ datamain.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
|
|
|
+ datamain.Code = dataother.CheckList[n].Code
|
|
|
+ datamain.Name = dataother.CheckList[n].Name
|
|
|
+ datamain.GoodsLevel = dataother.CheckList[n].GoodsLevel
|
|
|
+ datamain.Remark = dataother.Remark
|
|
|
+ datamain.IsDelete = 0
|
|
|
+ datamain.CreateBy = this.User.Realname
|
|
|
+ datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ unitsvc := organize.GetOrganizeService(utils.DBE)
|
|
|
+ unitid := unitsvc.GetMyUnitDepartmentId(this.User.DepartmentId)
|
|
|
+ if unitid == "100000095" { // 100000095 企管法规处(内控与风险管理处)
|
|
|
+ datamain.CertSubStatus = "1"
|
|
|
+ }
|
|
|
+ svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
|
|
|
+ vaildCnt++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var errinfo ErrorDataInfo
|
|
|
+ if invalidCertMsg == "" {
|
|
|
+ errinfo.Message = "操作成功!"
|
|
|
+ } else if vaildCnt > 0 {
|
|
|
+ errinfo.Message = "部分成功!" + invalidCertMsg
|
|
|
+ } else {
|
|
|
+ errinfo.Message = invalidCertMsg
|
|
|
+ }
|
|
|
+ errinfo.Code = 0
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
// @Title 批量添加准入范围--技术服务类
|
|
|
// @Description 批量添加准入范围
|
|
|
// @Success 200 {object} business.device.DeviceChannels
|