Commit 3b6f5297 by DuJunLi

优化代码,减少代码冗余

parent 3a12df92
...@@ -187,6 +187,28 @@ public class CampScheduleTools extends XMBaseTest { ...@@ -187,6 +187,28 @@ public class CampScheduleTools extends XMBaseTest {
} }
} }
/**
* 根据时间和星期查询有效循环次数
* @param startDate
* @param endDate
* @param weekdaysList
* @return
*/
public int queryExpectedLoopNum(String startDate, String endDate,List<String> weekdaysList){
setUP("API_queryExpectedLoopNum");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("startDate", startDate);
body.put("endDate", endDate);
body.put("weekdays", weekdaysList);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
return Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.result"));
}
} }
\ No newline at end of file
...@@ -25,6 +25,16 @@ public class SelectTargetTrainingCampAndGetInfo extends BaseCreateTrainingData { ...@@ -25,6 +25,16 @@ public class SelectTargetTrainingCampAndGetInfo extends BaseCreateTrainingData {
public String openEndDate= CommUtil.getNDayEndTimeTamp(42);// 23:59:59,从开始到结束一共40天 public String openEndDate= CommUtil.getNDayEndTimeTamp(42);// 23:59:59,从开始到结束一共40天
public List<JSONObject> campInfo = new ArrayList<>(); public List<JSONObject> campInfo = new ArrayList<>();
public String campId="";
public String courseId="";
public String openStartDate="";
public int traineeLowerLimit;
public int traineeUpperLimit;
public int totalClassHour;
public String chiefCoachId="";
List<String> assistCoachIds;
@BeforeClass @BeforeClass
public void beforeTest() { public void beforeTest() {
super.beforeTest(); super.beforeTest();
...@@ -62,6 +72,20 @@ public class SelectTargetTrainingCampAndGetInfo extends BaseCreateTrainingData { ...@@ -62,6 +72,20 @@ public class SelectTargetTrainingCampAndGetInfo extends BaseCreateTrainingData {
.collect(Collectors.toList()); .collect(Collectors.toList());
campId= campInfo.get(0).getString("id");
courseId= campInfo.get(0).getString("courseId");
openStartDate=campInfo.get(0).getString("openStartDate");
openEndDate=campInfo.get(0).getString("openEndDate");
traineeLowerLimit=campInfo.get(0).getIntValue("traineeLowerLimit");
traineeUpperLimit=campInfo.get(0).getIntValue("traineeUpperLimit");
totalClassHour=campInfo.get(0).getIntValue("totalClassHour");
chiefCoachId = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> {
return "杜君丽".equals(e.getString("nickName"));
}).map(e -> e.getString("id")).findFirst().orElse(null);
System.out.println(id);
assistCoachIds = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> {
return !"杜君丽".equals(e.getString("nickName"));
}).map(e -> e.getString("id")).collect(Collectors.toList());
} }
......
...@@ -13,7 +13,6 @@ import org.testng.annotations.Test; ...@@ -13,7 +13,6 @@ import org.testng.annotations.Test;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 创建训练营排课 * 创建训练营排课
...@@ -40,23 +39,18 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn ...@@ -40,23 +39,18 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
public void testCreateCampRuleSchedule() { public void testCreateCampRuleSchedule() {
System.out.println("*********************" + campInfo); System.out.println("*********************" + campInfo);
//从训练营活动中获取教练信息 //从训练营活动中获取教练信息
String chiefCoachId = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> { String chiefCoachId =super.chiefCoachId;
return "杜君丽".equals(e.getString("nickName"));
}).map(e -> e.getString("id")).findFirst().orElse(null);
System.out.println(id);
//从训练营活动中获取助教信息 //从训练营活动中获取助教信息
List<String> assistCoachIds = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> { List<String> assistCoachIds = super.assistCoachIds;
return !"杜君丽".equals(e.getString("nickName"));
}).map(e -> e.getString("id")).collect(Collectors.toList());
//获取存量场地 //获取存量场地
List<String> venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地"); List<String> venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地");
String campId=campInfo.get(0).getString("id"); String campId=super.campId;
//创建训练营排课 //创建训练营排课
campScheduleTools.createCampRuleSchedule(campId, assistCoachIds, chiefCoachId, campInfo.get(0).getString("courseId"), campScheduleTools.createCampRuleSchedule(campId, assistCoachIds, chiefCoachId, super.courseId,
campInfo.get(0).getIntValue("traineeLowerLimit"), campInfo.get(0).getIntValue("traineeUpperLimit"), super.traineeLowerLimit, super.traineeUpperLimit,
"1020", campInfo.get(0).getString("openStartDate"), campInfo.get(0).getString("openEndDate"), true, "1020", super.openStartDate, super.openEndDate, true,
venueAreaIds, ""); venueAreaIds, "");
//查询排课日程:根据训练营和教练(其中一个助教)查询 //查询排课日程:根据训练营和教练(其中一个助教)查询
......
...@@ -42,21 +42,17 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo ...@@ -42,21 +42,17 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo
@Test(description = "编辑训练营排课规则") @Test(description = "编辑训练营排课规则")
public void testEditCampRuleSchedule() { public void testEditCampRuleSchedule() {
//获取选择的训练营ID //获取选择的训练营ID
campId = campInfo.get(0).getString("id"); campId = super.campId;
//获取训练营活动的指定教练ID //获取训练营活动的指定教练ID
chiefCoachId = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> { chiefCoachId =super.chiefCoachId;
return "杜君丽".equals(e.getString("nickName"));
}).map(e -> e.getString("id")).findFirst().orElse(null);
//从训练营活动中获取助教信息 //从训练营活动中获取助教信息
List<String> assistCoachIds = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> { List<String> assistCoachIds = super.assistCoachIds;
return !"杜君丽".equals(e.getString("nickName"));
}).map(e -> e.getString("id")).collect(Collectors.toList());
//创建训练营排课:按日期 //创建训练营排课:按日期
campScheduleTools.oneKeyCreateCampRuleSchedule(campId, chiefCoachId, campInfo.get(0).getString("courseId"), campScheduleTools.oneKeyCreateCampRuleSchedule(campId, chiefCoachId, super.courseId,
campInfo.get(0).getIntValue("traineeLowerLimit"), campInfo.get(0).getIntValue("traineeUpperLimit"), super.traineeLowerLimit, super.traineeUpperLimit,
"1140", campInfo.get(0).getString("openEndDate"), true, "1140", super.openEndDate, true,
""); "");
//查询排课日程:根据训练营和教练查询 //查询排课日程:根据训练营和教练查询
...@@ -71,8 +67,8 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo ...@@ -71,8 +67,8 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo
body.put("brandId", xmAppApi.getLoginInfo().getBrandId()); body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
chiefCoachId=assistCoachIds.get(0).toString(); chiefCoachId=assistCoachIds.get(0).toString();
body.put("chiefCoachId",chiefCoachId );//修改教练换人 body.put("chiefCoachId",chiefCoachId );//修改教练换人
body.put("minMemberNum", campInfo.get(0).getIntValue("traineeLowerLimit")); body.put("minMemberNum", super.traineeLowerLimit);
body.put("maxMemberNum", campInfo.get(0).getIntValue("traineeUpperLimit")); body.put("maxMemberNum", super.traineeUpperLimit);
body.put("minuteOffset", "1320"); body.put("minuteOffset", "1320");
List<String> venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地"); List<String> venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地");
body.put("venueAreaIds", venueAreaIds); //有空改为有数据 body.put("venueAreaIds", venueAreaIds); //有空改为有数据
......
...@@ -43,23 +43,19 @@ public class TestGetCampScheduleTable extends SelectTargetTrainingCampAndGetInfo ...@@ -43,23 +43,19 @@ public class TestGetCampScheduleTable extends SelectTargetTrainingCampAndGetInfo
super.beforeTest(); super.beforeTest();
venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地"); venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地");
venueAreaId = venueAreaIds.get(0).toString(); venueAreaId = venueAreaIds.get(0).toString();
campId = campInfo.get(0).getString("id"); campId = super.campId;
chiefCoachId = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> { chiefCoachId = super.chiefCoachId;
return "杜君丽".equals(e.getString("nickName"));
}).map(e -> e.getString("id")).findFirst().orElse(null);
//从训练营活动中获取助教信息 //从训练营活动中获取助教信息
List<String> assistCoachIds = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> { List<String> assistCoachIds = super.assistCoachIds;
return !"杜君丽".equals(e.getString("nickName"));
}).map(e -> e.getString("id")).collect(Collectors.toList());
//创建训练营排课:按次数 //创建训练营排课:按次数
campScheduleTools.createCampRuleSchedule(campId, assistCoachIds, chiefCoachId, campInfo.get(0).getString("courseId"), campScheduleTools.createCampRuleSchedule(campId, assistCoachIds, chiefCoachId, super.courseId,
campInfo.get(0).getIntValue("traineeLowerLimit"), campInfo.get(0).getIntValue("traineeUpperLimit"), super.traineeLowerLimit,super.traineeUpperLimit,
"1020", campInfo.get(0).getString("openStartDate"), campInfo.get(0).getString("openEndDate"), true, "1020",super.openStartDate, super.openEndDate, true,
venueAreaIds, "20"); venueAreaIds, "20");
//查询排课日程:根据训练营和教练,关联课程查询 //查询排课日程:根据训练营和教练,关联课程查询
campScheduleTools.getCampRuleScheduleList(campId,campInfo.get(0).getString("courseId"),chiefCoachId); campScheduleTools.getCampRuleScheduleList(campId,super.courseId,chiefCoachId);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result").size()==1,"排课创建成功后,日程中没查询到对应数据"); Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result").size()==1,"排课创建成功后,日程中没查询到对应数据");
ruldId=XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result").getJSONObject(0).getString("ruleId"); ruldId=XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result").getJSONObject(0).getString("ruleId");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment