浏览代码

后:导入优化

dubch 4 年之前
父节点
当前提交
07b08f7871

+ 2 - 1
src/dashoo.cn/backend/api/controllers/oilcontract/contract.go

@@ -642,7 +642,8 @@ func (this *OilContractController) ImportExcel() {
 			con.EndDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[9].Value), time.Local)
 			con.YearDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[9].Value), time.Local)
 			var supp supplier.OilSupplier
-			svc.GetEntityByWhere(OilSupplierName, "SupplierName = '"+con.ImportSupplierName+"'", &supp)
+			//svc.GetEntityByWhere(OilSupplierName, "SupplierName = '"+con.ImportSupplierName+"'", &supp)
+			svc.GetJoinBySelect("b.SupplierTypeCode='" + con.ContractClass + "' AND a.SupplierName = '"+con.ImportSupplierName+"'", &supp)
 			if supp.Id > 0 {
 				con.SupplierId = supp.Id
 			}

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

@@ -822,3 +822,12 @@ func (s *MyServiceBase) DeleteTableBySelect(tableName, tableName2, where string,
 	s.DBE.SQL(sql).Find(entityPtr)
 	return
 }
+
+func (s *MyServiceBase) GetJoinBySelect(where string, entityPtr interface{}) {
+	sql := "select a.Id from OilSupplier a left join OilSupplierCert  b ON a.Id = b.SupplierId "
+	if where != "" {
+		sql = sql + " Where " + where
+	}
+	s.DBE.SQL(sql).Find(entityPtr)
+	return
+}