瀏覽代碼

对比列表

dubch 5 年之前
父節點
當前提交
3208c03a7e

+ 95 - 60
src/dashoo.cn/backend/api/business/oilsupplier/goodsaptitude/oilgoodsaptitudeService.go

@@ -219,7 +219,7 @@ func (s *OilGoodsAptitudeService) InsertTmpGoodsAptitude(parentId, fcode, val st
 }
 
 func (s *OilGoodsAptitudeService) GetPagingCheckedEntities(pageIndex, itemsPerPage int64, orderby string,
-	asc bool, entitiesPtr interface{}, having string) (total int64) {
+	asc bool, entitiesPtr interface{}, where string) (total int64) {
 
 	var sql string
 	sql = `SELECT 
@@ -283,62 +283,64 @@ func (s *OilGoodsAptitudeService) GetPagingCheckedEntities(pageIndex, itemsPerPa
 		max(goods.F46) AS F46,
 		
 		(
-		if((max(goods.F01)='1' AND LOCATE('F01', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND 
-		if((max(goods.F02)='1' AND LOCATE('F02', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F03)='1' AND LOCATE('F03', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F04)='1' AND LOCATE('F04', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F05)='1' AND LOCATE('F05', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F06)='1' AND LOCATE('F06', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F07)='1' AND LOCATE('F07', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F08)='1' AND LOCATE('F08', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F09)='1' AND LOCATE('F09', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F10)='1' AND LOCATE('F10', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F11)='1' AND LOCATE('F12', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F13)='1' AND LOCATE('F13', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F14)='1' AND LOCATE('F14', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F15)='1' AND LOCATE('F15', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F16)='1' AND LOCATE('F16', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F17)='1' AND LOCATE('F17', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F18)='1' AND LOCATE('F18', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F19)='1' AND LOCATE('F19', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F20)='1' AND LOCATE('F20', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F21)='1' AND LOCATE('F21', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F22)='1' AND LOCATE('F22', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F23)='1' AND LOCATE('F23', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F24)='1' AND LOCATE('F24', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F25)='1' AND LOCATE('F25', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F26)='1' AND LOCATE('F26', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F27)='1' AND LOCATE('F27', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F28)='1' AND LOCATE('F28', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F29)='1' AND LOCATE('F29', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F30)='1' AND LOCATE('F30', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F31)='1' AND LOCATE('F31', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F32)='1' AND LOCATE('F32', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F33)='1' AND LOCATE('F33', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F34)='1' AND LOCATE('F34', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F35)='1' AND LOCATE('F35', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F36)='1' AND LOCATE('F36', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F37)='1' AND LOCATE('F37', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F38)='1' AND LOCATE('F38', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F39)='1' AND LOCATE('F39', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F40)='1' AND LOCATE('F40', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F41)='1' AND LOCATE('F41', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F42)='1' AND LOCATE('F42', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F43)='1' AND LOCATE('F43', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F44)='1' AND LOCATE('F44', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F45)='1' AND LOCATE('F45', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
-		if((max(goods.F46)='1' AND LOCATE('F46', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) 
-		) AS checked
+			((if((max(goods.F01)='1' AND LOCATE('F01', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F01) is null) or (max(goods.F01) = ''), TRUE, FALSE)) or 
+			(if((max(goods.F36)='1' AND LOCATE('F36',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F36) is null) or (max(goods.F36) = ''), TRUE, FALSE)) or
+			(if((max(goods.F37)='1' AND LOCATE('F37',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F37) is null) or (max(goods.F37) = ''), TRUE, FALSE))) AND 
+			if((max(goods.F02)='1' AND LOCATE('F02',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F02) is null) or (max(goods.F02) = ''), TRUE, FALSE) AND
+			if((max(goods.F03)='1' AND LOCATE('F03',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F03) is null) or (max(goods.F03) = ''), TRUE, FALSE) AND
+			if((max(goods.F04)='1' AND LOCATE('F04',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F04) is null) or (max(goods.F04) = ''), TRUE, FALSE) AND
+			if((max(goods.F05)='1' AND LOCATE('F05',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F05) is null) or (max(goods.F05) = ''), TRUE, FALSE) AND
+			if((max(goods.F06)='1' AND LOCATE('F06',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F06) is null) or (max(goods.F06) = ''), TRUE, FALSE) AND
+			if((max(goods.F07)='1' AND LOCATE('F07',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F07) is null) or (max(goods.F07) = ''), TRUE, FALSE) AND
+			if((max(goods.F08)='1' AND LOCATE('F08',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F08) is null) or (max(goods.F08) = ''), TRUE, FALSE) AND
+			if((max(goods.F09)='1' AND LOCATE('F09',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F09) is null) or (max(goods.F09) = ''), TRUE, FALSE) AND
+			if((max(goods.F10)='1' AND LOCATE('F10',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F10) is null) or (max(goods.F10) = ''), TRUE, FALSE) AND
+			if((max(goods.F11)='1' AND LOCATE('F11',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F11) is null) or (max(goods.F11) = ''), TRUE, FALSE) AND
+			if((max(goods.F12)='1' AND LOCATE('F12',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F12) is null) or (max(goods.F12) = ''), TRUE, FALSE) AND
+			if((max(goods.F13)='1' AND LOCATE('F13',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F13) is null) or (max(goods.F13) = ''), TRUE, FALSE) AND
+			if((max(goods.F14)='1' AND LOCATE('F14',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F14) is null) or (max(goods.F14) = ''), TRUE, FALSE) AND
+			if((max(goods.F15)='1' AND LOCATE('F15',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F15) is null) or (max(goods.F15) = ''), TRUE, FALSE) AND
+			if((max(goods.F16)='1' AND LOCATE('F16',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F16) is null) or (max(goods.F16) = ''), TRUE, FALSE) AND
+			if((max(goods.F17)='1' AND LOCATE('F17',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F17) is null) or (max(goods.F17) = ''), TRUE, FALSE) AND
+			if((max(goods.F18)='1' AND LOCATE('F18',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F18) is null) or (max(goods.F18) = ''), TRUE, FALSE) AND
+			if((max(goods.F19)='1' AND LOCATE('F19',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F19) is null) or (max(goods.F19) = ''), TRUE, FALSE) AND
+			if((max(goods.F20)='1' AND LOCATE('F20',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F20) is null) or (max(goods.F20) = ''), TRUE, FALSE) AND
+			if((max(goods.F21)='1' AND LOCATE('F21',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F21) is null) or (max(goods.F21) = ''), TRUE, FALSE) AND
+			if((max(goods.F22)='1' AND LOCATE('F22',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F22) is null) or (max(goods.F22) = ''), TRUE, FALSE) AND
+			if((max(goods.F23)='1' AND LOCATE('F23',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F23) is null) or (max(goods.F23) = ''), TRUE, FALSE) AND
+			if((max(goods.F24)='1' AND LOCATE('F24',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F24) is null) or (max(goods.F24) = ''), TRUE, FALSE) AND
+			if((max(goods.F25)='1' AND LOCATE('F25',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F25) is null) or (max(goods.F25) = ''), TRUE, FALSE) AND
+			if((max(goods.F26)='1' AND LOCATE('F26',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F26) is null) or (max(goods.F26) = ''), TRUE, FALSE) AND
+			if((max(goods.F27)='1' AND LOCATE('F27',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F27) is null) or (max(goods.F27) = ''), TRUE, FALSE) AND
+			if((max(goods.F28)='1' AND LOCATE('F28',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F28) is null) or (max(goods.F28) = ''), TRUE, FALSE) AND
+			if((max(goods.F29)='1' AND LOCATE('F29',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F29) is null) or (max(goods.F29) = ''), TRUE, FALSE) AND
+			if((max(goods.F30)='1' AND LOCATE('F30',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F30) is null) or (max(goods.F30) = ''), TRUE, FALSE) AND
+			if((max(goods.F31)='1' AND LOCATE('F31',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F31) is null) or (max(goods.F31) = ''), TRUE, FALSE) AND
+			if((max(goods.F32)='1' AND LOCATE('F32',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F32) is null) or (max(goods.F32) = ''), TRUE, FALSE) AND
+			if((max(goods.F33)='1' AND LOCATE('F33',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F33) is null) or (max(goods.F33) = ''), TRUE, FALSE) AND
+			if((max(goods.F34)='1' AND LOCATE('F34',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F34) is null) or (max(goods.F34) = ''), TRUE, FALSE) AND
+			if((max(goods.F35)='1' AND LOCATE('F35',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F35) is null) or (max(goods.F35) = ''), TRUE, FALSE) AND
+			if((max(goods.F38)='1' AND LOCATE('F38',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F38) is null) or (max(goods.F38) = ''), TRUE, FALSE) AND
+			if((max(goods.F39)='1' AND LOCATE('F39',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F39) is null) or (max(goods.F39) = ''), TRUE, FALSE) AND
+			if((max(goods.F40)='1' AND LOCATE('F40',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F40) is null) or (max(goods.F40) = ''), TRUE, FALSE) AND
+			if((max(goods.F41)='1' AND LOCATE('F41',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F41) is null) or (max(goods.F41) = ''), TRUE, FALSE) AND
+			if((max(goods.F42)='1' AND LOCATE('F42',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F42) is null) or (max(goods.F42) = ''), TRUE, FALSE) AND
+			if((max(goods.F43)='1' AND LOCATE('F43',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F43) is null) or (max(goods.F43) = ''), TRUE, FALSE) AND
+			if((max(goods.F44)='1' AND LOCATE('F44',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F44) is null) or (max(goods.F44) = ''), TRUE, FALSE) AND
+			if((max(goods.F45)='1' AND LOCATE('F45',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F45) is null) or (max(goods.F45) = ''), TRUE, FALSE) AND
+			if((max(goods.F46)='1' AND LOCATE('F46',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F46) is null) or (max(goods.F46) = ''), TRUE, FALSE) 
+			) AS checked
 		
 		 FROM OilSupplier a
-		 LEFT JOIN OilSupplierCert b ON a.Id=b.SupplierId
-		 LEFT JOIN OilSupplierCertSub sub ON b.Id=sub.SupplierCertId
-		 LEFT JOIN OilSupplierFile files ON a.Id=files.SupplierId
-		 LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name
-		 LEFT JOIN OilGoodsAptitude goods ON sub.SubClassId=goods.ClassId
-		 WHERE b.SupplierTypeCode='03'
-		 GROUP BY a.Id, b.Id`
-	sql += having
+			 LEFT JOIN OilSupplierCert b ON a.Id=b.SupplierId
+			 LEFT JOIN OilSupplierCertSub sub ON b.Id=sub.SupplierCertId and sub.Type in (1, 3) 
+			 LEFT JOIN OilSupplierFile files ON a.Id=files.SupplierId
+			 LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name
+			 LEFT JOIN tmp_OilGoodsAptitudeClass class ON sub.Code=class.Code
+			 LEFT JOIN tmp_OilGoodsAptitude goods ON class.Id=goods.ClassId
+			 WHERE b.SupplierTypeCode='01' and `
+	sql += where
+	sql += ` GROUP BY a.Id, b.Id `
 	if asc {
 		sql += ` order by ` + orderby + ` ASC `
 	} else {
@@ -432,8 +434,8 @@ func (s *OilGoodsAptitudeService) GetPagingTmpCheckedEntities(entitiesPtr interf
 			if((max(goods.F08)='1' AND LOCATE('F08',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F08) is null) or (max(goods.F08) = ''), TRUE, FALSE) AND
 			if((max(goods.F09)='1' AND LOCATE('F09',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F09) is null) or (max(goods.F09) = ''), TRUE, FALSE) AND
 			if((max(goods.F10)='1' AND LOCATE('F10',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F10) is null) or (max(goods.F10) = ''), TRUE, FALSE) AND
-			if((max(goods.F10)='1' AND LOCATE('F11',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F11) is null) or (max(goods.F11) = ''), TRUE, FALSE) AND
-			if((max(goods.F11)='1' AND LOCATE('F12',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F12) is null) or (max(goods.F12) = ''), TRUE, FALSE) AND
+			if((max(goods.F11)='1' AND LOCATE('F11',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F11) is null) or (max(goods.F11) = ''), TRUE, FALSE) AND
+			if((max(goods.F12)='1' AND LOCATE('F12',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F12) is null) or (max(goods.F12) = ''), TRUE, FALSE) AND
 			if((max(goods.F13)='1' AND LOCATE('F13',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F13) is null) or (max(goods.F13) = ''), TRUE, FALSE) AND
 			if((max(goods.F14)='1' AND LOCATE('F14',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F14) is null) or (max(goods.F14) = ''), TRUE, FALSE) AND
 			if((max(goods.F15)='1' AND LOCATE('F15',  group_concat(DISTINCT header.Code)) > 0) or (max(goods.F15) is null) or (max(goods.F15) = ''), TRUE, FALSE) AND
@@ -490,7 +492,7 @@ func (s *OilGoodsAptitudeService) GetPagingTmpCheckedEntities(entitiesPtr interf
 	return total
 }
 
-func (s *OilGoodsAptitudeService) GetPagingSubEntities(pageIndex, itemsPerPage int64, orderby string,
+func (s *OilGoodsAptitudeService) GetPagingTmpSubEntities(pageIndex, itemsPerPage int64, orderby string,
 	asc bool, entitiesPtr interface{}, having string) (total int64) {
 
 	var sql string
@@ -499,7 +501,7 @@ func (s *OilGoodsAptitudeService) GetPagingSubEntities(pageIndex, itemsPerPage i
 		 FROM OilSupplierCertSub a
 		 LEFT JOIN OilSupplierFile files ON a.SupplierId=files.SupplierId
 		 LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name
-		 LEFT JOIN OilGoodsAptitude goods ON a.SubClassId=goods.ClassId`
+		 LEFT JOIN tmp_OilGoodsAptitude goods ON a.SubClassId=goods.ClassId`
 	sql += " where (" + having + ")"
 	sql += ` GROUP BY a.Id `
 	if asc {
@@ -509,7 +511,40 @@ func (s *OilGoodsAptitudeService) GetPagingSubEntities(pageIndex, itemsPerPage i
 	}
 	sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
 
-	sqlCount := "SELECT count(*) as total FROM OilSupplierCertSub a"
+	sqlCount := "SELECT count(*) as total FROM OilSupplierCertSub a LEFT JOIN OilSupplierFile files ON a.SupplierId=files.SupplierId LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name LEFT JOIN tmp_OilGoodsAptitude goods ON a.SubClassId=goods.ClassId where (" + having + ")"
+	sqlCount += " where (" + having + ")"
+
+	var totalResult TotalResult
+	s.DBE.SQL(sql).Find(entitiesPtr)
+	s.DBE.SQL(sqlCount).Get(&totalResult)
+	total = totalResult.Total
+
+	return total
+}
+
+func (s *OilGoodsAptitudeService) GetPagingSubEntities(pageIndex, itemsPerPage int64, orderby string,
+	asc bool, entitiesPtr interface{}, having string) (total int64) {
+
+	var sql string
+	sql = `SELECT 
+		 a.*,group_concat(DISTINCT header.Code) AS HeaderCodes
+		 FROM OilSupplierCertSub a
+		 LEFT JOIN OilSupplierFile files ON a.SupplierId=files.SupplierId
+		 LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name
+		 LEFT JOIN OilGoodsAptitude goods ON a.SubClassId=goods.ClassId
+		 LEFT JOIN OilSupplierContrastNew con ON con.Id=a.SupplierId`
+	sql += " where (" + having + ")"
+	sql += ` GROUP BY a.Id `
+	if asc {
+		sql += ` order by ` + orderby + ` ASC `
+	} else {
+		sql += ` order by ` + orderby + ` DESC `
+	}
+	if itemsPerPage != 0 {
+		sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
+	}
+
+	sqlCount := "SELECT count(*) as total FROM OilSupplierCertSub a LEFT JOIN OilSupplierFile files ON a.SupplierId=files.SupplierId LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name LEFT JOIN OilGoodsAptitude goods ON a.SubClassId=goods.ClassId where (" + having + ")"
 	sqlCount += " where (" + having + ")"
 
 	var totalResult TotalResult

+ 189 - 21
src/dashoo.cn/backend/api/controllers/oilsupplier/goodsaptitude.go

@@ -1504,7 +1504,7 @@ func (this *OilGoodsAptitudeController) TruncateImport() {
 }
 
 // @Title 将导入的数据 导入到正式表
-// @Description get SampleType by token
+// @Description 确认更新
 // @Success 200 {object} sampletype.SampleType
 // @router /insertgoodsaptitude [get]
 func (this *OilGoodsAptitudeController) InsertGoodsAptitude() {
@@ -1555,8 +1555,30 @@ func (this *OilGoodsAptitudeController) InsertGoodsAptitude() {
 		this.ServeJSON()
 	}
 
-	session.Commit()
+	svc1 := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
+	var list2 []supplier.OilSupplierContrast
+	where := " Checked = '0' and SupplierTypeCode = '01'"
+	svc1.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrast", 0, 0, "Id", false, &list2, where)
+	err = svc.TruncateTable("OilSupplierContrastNew")
+	if err != nil {
+		session.Rollback()
+		errinfo.Code = -1
+		errinfo.Message = "更新失败!"
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+	for _, item := range list2 {
+		_, err := svc.InsertEntityBytbl("OilSupplierContrastNew", item)
+		if err != nil {
+			session.Rollback()
+			errinfo.Code = -1
+			errinfo.Message = "更新失败!"
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		}
+	}
 
+	session.Commit()
 	errinfo.Code = 0
 	errinfo.Message = "更新成功!"
 	this.Data["json"] = &errinfo
@@ -1895,7 +1917,7 @@ func (this *OilGoodsAptitudeController) GetTList() {
 
 }
 
-// @Title 获取删除的准入项
+// @Title 查看对比列表的准入范围
 // @Description get user by token
 // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
 // @router /delcertsublist [get]
@@ -1993,7 +2015,7 @@ func (this *OilGoodsAptitudeController) GetDelCertSubList() {
 	var list []suppliercertsub.OilSupplierCertSub
 	//total := svc.GetMyPagingEntitiesWithOrderBytbl(TmpOilSupplierCertSubName, page.CurrentPage, page.Size, orderby, asc, &list, where)
 	//total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierCertSubName, page.CurrentPage, page.Size, orderby, asc, &list, where)
-	total := svc.GetPagingSubEntities(page.CurrentPage, page.Size, orderby, asc, &list, where)
+	total := svc.GetPagingTmpSubEntities(page.CurrentPage, page.Size, orderby, asc, &list, where)
 	a := 0
 	for _, item := range list {
 		sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46)) AS Codes FROM tmp_OilGoodsAptitude "
@@ -2052,34 +2074,73 @@ func (this *OilGoodsAptitudeController) DelTmpSupplierCertSub() {
 
 	svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
 
-	var supplierCertSubList []suppliercertsub.Tmp_OilSupplierCertSub
-	wheredel := "1=1 and SupplierTypeCode = '01'"
+	var supplierCertSubList []suppliercertsub.OilSupplierCertSub
+	wheredel := "1=1 and a.SupplierTypeCode = '01' and a.Type in (1,3)"
 	if supplierId != "" {
-		wheredel += " and SupplierId=" + supplierId
+		wheredel += " and a.SupplierId=" + supplierId
 	}
 	if id != "" {
-		wheredel += " and Id=" + id
+		wheredel += " and a.Id=" + id
 	}
+	svc1 := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
 	//svc.GetEntitysByWhere(TmpOilSupplierCertSubName, wheredel, &supplierCertSubList)
-	svc.GetEntitysByWhere(OilSupplierCertSubName, wheredel, &supplierCertSubList)
+	//svc.GetEntitysByWhere(OilSupplierCertSubName, wheredel, &supplierCertSubList)
+	svc1.GetPagingSubEntities(0, 0, "Id", false, &supplierCertSubList, wheredel)
 
+	a := 0
 	var errinfo ErrorInfo
 	for _, item := range supplierCertSubList {
-		where := "Id = " + strconv.Itoa(item.Id)
-		err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
-		if err != nil {
-			session.Rollback()
-			errinfo.Code = -1
-			errinfo.Message = "删除失败!"
-			this.Data["json"] = &errinfo
-			this.ServeJSON()
+		sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46)) AS Codes FROM tmp_OilGoodsAptitude "
+		sql += " where ClassId = "+ strconv.Itoa(item.SubClassId)
+		model, _ := svc1.DBE.QueryString(sql)
+		code := strings.Split(model[0]["Codes"], ",")
+		i := 1
+		for _, value := range code {
+			if i == 36 || i == 37 || i == 1 {
+				if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[35] == "1" && strings.Index(item.HeaderCodes, "F36") < 0) && (code[36] == "1" && strings.Index(item.HeaderCodes, "F37") < 0) {
+					where := "Id = " + strconv.Itoa(item.Id)
+					err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
+					if err != nil {
+						session.Rollback()
+						errinfo.Code = -1
+						errinfo.Message = "删除失败!"
+						this.Data["json"] = &errinfo
+						this.ServeJSON()
+					}
+				}
+			} else if i > 10 {
+				if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
+					where := "Id = " + strconv.Itoa(item.Id)
+					err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
+					if err != nil {
+						session.Rollback()
+						errinfo.Code = -1
+						errinfo.Message = "删除失败!"
+						this.Data["json"] = &errinfo
+						this.ServeJSON()
+					}
+				}
+			} else {
+				if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
+					where := "Id = " + strconv.Itoa(item.Id)
+					err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
+					if err != nil {
+						session.Rollback()
+						errinfo.Code = -1
+						errinfo.Message = "删除失败!"
+						this.Data["json"] = &errinfo
+						this.ServeJSON()
+					}
+				}
+			}
+			i += 1
 		}
+		a += 1
 	}
 
 	for _, item := range supplierCertSubList {
-		where := "Id = " + strconv.Itoa(item.Id)
-		//err = svc.DeleteEntityBytbl(TmpOilSupplierCertSubName, where)
-		err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
+		where := "Id = " + strconv.Itoa(item.SupplierId)
+		err = svc.DeleteEntityBytbl("OilSupplierContrastNew", where)
 	}
 
 	if err == nil {
@@ -2099,7 +2160,7 @@ func (this *OilGoodsAptitudeController) DelTmpSupplierCertSub() {
 
 
 // @Title 新导入资质后,比对不合格的准入用户
-// @Description get compare tmp supplier
+// @Description 对比列表
 // @Success 200 {object} []supplier.OilSupplierSelect
 // @router /get-compare-tmp-supplier [get]
 func (this *OilGoodsAptitudeController) GetCompareTmpSupplier() {
@@ -2204,6 +2265,113 @@ func (this *OilGoodsAptitudeController) GetCompareTmpSupplier() {
 	this.ServeJSON()
 }
 
+
+// @Title 确认更新后的待删除准入范围列表
+// @Description get compare tmp supplier
+// @Success 200 {object} []supplier.OilSupplierSelect
+// @router /get-delete-supplier [get]
+func (this *OilGoodsAptitudeController) GetDeleteSupplier() {
+	//获取分页信息
+	page := this.GetPageInfoForm()
+	where := " 1=1 "
+	orderby := "Id"
+	asc := false
+	Order := this.GetString("Order")
+	Prop := this.GetString("Prop")
+	if Order != "" && Prop != "" {
+		orderby = Prop
+		if Order == "asc" {
+			asc = true
+		}
+	}
+	Id := this.GetString("Id")
+	SupplierId := this.GetString("SupplierId")
+	SupplierCertId := this.GetString("SupplierCertId")
+	SupplierTypeCode := this.GetString("SupplierTypeCode")
+	Code := this.GetString("Code")
+	Name := this.GetString("Name")
+	Remark := this.GetString("Remark")
+	IsDelete := this.GetString("IsDelete")
+	CreateOn := this.GetString("CreateOn")
+	CreateUserId := this.GetString("CreateUserId")
+	CreateBy := this.GetString("CreateBy")
+	ModifiedOn := this.GetString("ModifiedOn")
+	ModifiedUserId := this.GetString("ModifiedUserId")
+	ModifiedBy := this.GetString("ModifiedBy")
+
+	if Id != "" {
+		where = where + " and Id like '%" + Id + "%'"
+	}
+
+	if SupplierId != "" {
+		where = where + " and SupplierId like '%" + SupplierId + "%'"
+	}
+
+	if SupplierCertId != "" {
+		where = where + " and SupplierCertId = '" + SupplierCertId + "'"
+	}
+
+	if SupplierTypeCode != "" {
+		where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
+	}
+
+	if Code != "" {
+		where = where + " and Code like '%" + Code + "%'"
+	}
+
+	if Name != "" {
+		where = where + " and Name like '%" + Name + "%'"
+	}
+
+	if Remark != "" {
+		where = where + " and Remark like '%" + Remark + "%'"
+	}
+
+	if IsDelete != "" {
+		where = where + " and IsDelete like '%" + IsDelete + "%'"
+	}
+
+	if CreateUserId != "" {
+		where = where + " and CreateUserId like '%" + CreateUserId + "%'"
+	}
+
+	if CreateBy != "" {
+		where = where + " and CreateBy like '%" + CreateBy + "%'"
+	}
+
+	if ModifiedOn != "" {
+		where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
+	}
+
+	if ModifiedUserId != "" {
+		where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
+	}
+
+	if ModifiedBy != "" {
+		where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
+	}
+
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
+		}
+	}
+	svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
+	var list2 []supplier.OilSupplierContrast
+
+	total := svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrastNew", page.CurrentPage, page.Size, orderby, asc, &list2, where)
+	var datainfo DataInfo
+	datainfo.Items = list2
+	datainfo.CurrentItemCount = total
+	datainfo.PageIndex = page.CurrentPage
+	datainfo.ItemsPerPage = page.Size
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
 // @Title 导出到execl
 // @Description 导出到execl
 // @Success	200	{object} controllers.Request

+ 7 - 0
src/dashoo.cn/frontend_web/src/api/oilsupplier/goodsaptitude.js

@@ -126,6 +126,13 @@ export default {
       data: formdata
     })
   },
+  getDeleteCompanyList (params, formdata, myAxios) {
+    return myAxios({
+      url: '/goodsaptitude/get-delete-supplier',
+      method: 'GET',
+      params: params
+    })
+  },
   delTmpSupplierCertSub (params, myAxios) {
     return myAxios({
       url: '/goodsaptitude/deltmpsuppliercertsub',

+ 1 - 1
src/dashoo.cn/frontend_web/src/pages/oilsupplier/goodsaptitude/_opera/showdelcertsub.vue

@@ -699,7 +699,7 @@ export default {
         CheckUId: this.auditorg,
         FullId: this.selectDept
       }
-      api.getCompanyList(params, this.searchForm, this.$axios)
+      api.getDeleteCompanyList(params, this.searchForm, this.$axios)
         .then(res => {
           this.entityList = res.data.items
           this.currentItemCount = res.data.currentItemCount

+ 1 - 0
src/dashoo.cn/frontend_web/src/pages/oilsupplier/goodsaptitude/index.vue

@@ -844,6 +844,7 @@
       },
       contrastList () {
         this.contrastListvisible = true
+        this.showimportvisible = false
       },
       updatasuppiercertsub () {
         // this.$confirm('此操作将更新企业资质, 是否继续?', '提示', {

+ 1 - 1
src/dashoo.cn/frontend_web/src/pages/oilsupplier/goodsaptitude/tmpsuppliercheck.vue

@@ -72,7 +72,7 @@
       <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[10, 15, 20, 25]" :page-size="size"
                      layout="total, sizes, prev, pager, next, jumper" :total="currentItemCount"></el-pagination>
     </el-card>
-    <el-dialog :visible.sync="dialogVisibleCertsSub" width="90%">
+    <el-dialog :visible.sync="dialogVisibleCertsSub" width="90%" append-to-body>
       <el-card class="box-card">
         <div slot="header" class="clearfix">
           <span style="font-weight: bold">准入范围</span>