xiatian пре 3 година
родитељ
комит
3bc9379711

+ 5 - 14
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/fill_property_code/FillPropertyCodeService.java

@@ -4,7 +4,6 @@ import java.util.Date;
 import java.util.List;
 
 import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.bson.types.ObjectId;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
@@ -32,7 +31,6 @@ public class FillPropertyCodeService {
 		int pageSize = 200;
 		int curPage = 1;
 		Date start = new Date();
-		int updateCount = 0;
 		Query query = new Query();
 		long count = this.mongoTemplate.count(query, Property.class);
 		query.limit(pageSize);
@@ -47,29 +45,22 @@ public class FillPropertyCodeService {
 			}
 			for (Property property : ps) {
 				index++;
-				if (StringUtils.isBlank(property.getCode())) {
-					updatePropertyCode(property.getId());
-					updateCount++;
-					System.out.println(String.format("处理:%s--> id:%s, code:%s", index,
-							property.getId(), property.getCode()));
-				}else {
-					System.out.println(String.format("无需处理:%s--> id:%s, code:%s", index,
-							property.getId(), property.getCode()));
-				}
+				updatePropertyCode(property.getId());
+				System.out
+						.println(String.format("处理:%s--> id:%s, code:%s", index, property.getId(), property.getCode()));
 			}
 		}
 
 		Date end = new Date();
-		System.out.println("实际修改条数:" + updateCount);
 		System.out.println("耗时:" + ((end.getTime() - start.getTime()) / (1000 * 60)) + "分钟");
 	}
 
 	public long updatePropertyCode(String id) {
 		Query query;
 		// 查询相应的题目
-		if(id.length()==24) {
+		if (id.length() == 24) {
 			query = Query.query(Criteria.where("_id").is(new ObjectId(id)));
-		}else {
+		} else {
 			query = Query.query(Criteria.where("_id").is(id));
 		}
 		Update update = new Update();