package com.ibeetl.jlw.service; import cn.jlw.util.ToolUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.ibeetl.admin.core.service.CoreBaseService; import com.ibeetl.admin.core.util.PlatformException; import com.ibeetl.admin.core.web.JsonResult; import com.ibeetl.admin.core.web.JsonReturnCode; import com.ibeetl.jlw.dao.HandsOnDao; import com.ibeetl.jlw.entity.HandsOn; import com.ibeetl.jlw.entity.HandsOnSimulationTasks; import com.ibeetl.jlw.web.query.HandsOnQuery; import org.apache.commons.lang3.StringUtils; import org.beetl.sql.core.SqlId; import org.beetl.sql.core.engine.PageQuery; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * HandsOn Service * 当分布式ID开启后请勿使用insert(*,true) */ @Service @Transactional public class HandsOnService extends CoreBaseService{ @Autowired private HandsOnDao handsOnDao; @Autowired private HandsOnSimulationTasksService handsOnSimulationTasksService; public PageQueryqueryByCondition(PageQuery query){ PageQuery ret = handsOnDao.queryByCondition(query); queryListAfter(ret.getList()); return ret; } public PageQueryqueryByConditionQuery(PageQuery query){ PageQuery ret = handsOnDao.queryByConditionQuery(query); queryListAfter(ret.getList()); return ret; } public void deleteByList(List list){ String ids = ""; ToolUtils.deleteNullList(list); for(int i=0;null != list && i handsOnList = new ArrayList<>(); try { handsOnList = JSON.parseArray(handsOnQuery.getHandsOnJsonStr(), HandsOn.class); } catch (Exception e) { try { handsOnList.add(JSONObject.parseObject(handsOnQuery.getHandsOnJsonStr(), HandsOn.class)); } catch (Exception e1) {} } ToolUtils.deleteNullList(handsOnList); if(null != handsOnList && handsOnList.size()>0){ for(int i=0;i 0; if(!flag){ msg = "更新指定参数失败"; } }else{ msg = "指定参数为空"; } return msg; } public List getValues (Object paras){ return sqlManager.select(SqlId.of("jlw.handsOn.getHandsOnValues"), HandsOn.class, paras); } public List getValuesByQuery (HandsOnQuery handsOnQuery){ return handsOnDao.getValuesByQuery(handsOnQuery); } public HandsOn getInfo (Long handsOnId){ HandsOnQuery handsOnQuery = new HandsOnQuery(); handsOnQuery.setHandsOnId(handsOnId); List list = handsOnDao.getValuesByQuery(handsOnQuery); if(null != list && list.size()>0){ return list.get(0); }else{ return null; } } public HandsOn getInfo (HandsOnQuery handsOnQuery){ List list = handsOnDao.getValuesByQuery(handsOnQuery); if(null != list && list.size()>0){ return list.get(0); }else{ return null; } } /** * 学生端-查询课程实操首页 * @param teacherOpenCourseId */ public void getHandonListByTeacherOpenCourseId(Long teacherOpenCourseId) { HandsOnQuery handsOnQuery = new HandsOnQuery(); handsOnQuery.setTeacherOpenCourseId(teacherOpenCourseId); List handsOnList = handsOnDao.getValuesByQuery(handsOnQuery); List handsOnIds = handsOnList.stream().map(HandsOn::getHandsOnId).distinct().collect(Collectors.toList()); List handsOnSimulationTasks = handsOnSimulationTasksService.queryObjectByHandsOnIds(handsOnIds); for (HandsOn handsOn : handsOnList) { List collect = handsOnSimulationTasks.stream().filter(v -> v.getHandsOnId().equals(handsOn.getHandsOnId())).collect(Collectors.toList()); handsOn.set("handsOnSimulationTasks", collect); } } }