diff --git a/src/main/java/cn/com/tenlion/controller/api/indexcount/IndexCountController.java b/src/main/java/cn/com/tenlion/controller/api/indexcount/IndexCountController.java index cfe0b94..2ef4ff9 100644 --- a/src/main/java/cn/com/tenlion/controller/api/indexcount/IndexCountController.java +++ b/src/main/java/cn/com/tenlion/controller/api/indexcount/IndexCountController.java @@ -178,16 +178,40 @@ public class IndexCountController extends DefaultBaseController { } - @ApiOperation(value = "统计当前登录机构分类教室", notes = "统计当前登录机构分类教室") + @ApiOperation(value = "统计当前培训机构的讲师占比", notes = "统计当前培训机构的讲师占比接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("count-teacher-num") - public SuccessResultData> countTeacher(){ - Map map = new HashMap<>(); + public SuccessResultData>> countTeacher(){ + List> list = new ArrayList<>(); + Map map0 = new HashMap<>(); + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); String institutionId = this.getInstitutionId(); if(!StringUtils.isBlank(institutionId)){ - map = teacherService.count(institutionId); + Map resultMap = teacherService.count(institutionId); + if(resultMap == null){ + map0.put("name","其他"); + map0.put("value",0); + list.add(map0); + map1.put("name","专职"); + map1.put("value",0); + list.add(map1); + map2.put("name","兼职"); + map2.put("value",0); + list.add(map2); + }else{ + map0.put("name","其他"); + map0.put("value",resultMap.get("0").toString()); + list.add(map0); + map1.put("name","专职"); + map1.put("value",resultMap.get("1").toString()); + list.add(map1); + map2.put("name","兼职"); + map2.put("value",resultMap.get("2").toString()); + list.add(map2); + } } - return new SuccessResultData<>(map); + return new SuccessResultData<>(list); } @@ -206,14 +230,38 @@ public class IndexCountController extends DefaultBaseController { @ApiOperation(value = "统计当前机构计划分类占比", notes = "统计当前机构计划分类占比") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("count-plan-type") - public SuccessResultData> countPlanType(){ - Map map = new HashMap<>(); + public SuccessResultData>> countPlanType(){ + List> list = new ArrayList<>(); + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); String institutionId = this.getInstitutionId(); if(!StringUtils.isBlank(institutionId)){ - map.put("orgId",institutionId); - map= classPlanService.countPlanType(institutionId); + Map resultMap= classPlanService.countPlanType(institutionId); + if(resultMap == null){ + map1.put("name","初训"); + map1.put("value",0); + list.add(map1); + map2.put("name","复训"); + map2.put("value",0); + list.add(map2); + map3.put("name","换证"); + map3.put("value",0); + list.add(map3); + }else{ + map1.put("name","初训"); + map1.put("value",resultMap.get("1")); + list.add(map1); + map2.put("name","复训"); + map2.put("value",resultMap.get("2")); + list.add(map2); + map3.put("name","换证"); + map3.put("value",resultMap.get("3")); + list.add(map3); + } + } - return new SuccessResultData<>(map); + return new SuccessResultData<>(list); } diff --git a/src/main/java/cn/com/tenlion/service/teacher/impl/TeacherServiceImpl.java b/src/main/java/cn/com/tenlion/service/teacher/impl/TeacherServiceImpl.java index 35a9ce4..bf97c7a 100644 --- a/src/main/java/cn/com/tenlion/service/teacher/impl/TeacherServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/teacher/impl/TeacherServiceImpl.java @@ -91,16 +91,25 @@ public class TeacherServiceImpl extends DefaultBaseService implements ITeacherSe @Override public SuccessResultData save(String token, TeacherVO teacherVO) throws Exception { - // 同机构下讲师不可重复 String idCardNumber = teacherVO.getIdCardNumber(); if(idCardNumber == null || "".equals(idCardNumber)){ throw new SaveException("讲师证件号码不允许为空值"); } + if(teacherVO.getWorkerCategoryId() == null || "".equals(teacherVO.getWorkerCategoryId())){ + throw new SaveException("讲师授课工种不能为空值"); + } Map queryMap = getHashMap(8); + // 同工种下讲师不可重复,跨工种可以重复 + String WorkerCategoryIds[] = teacherVO.getWorkerCategoryId().split(","); queryMap.put("idCardNumber",idCardNumber); - TeacherDTO teacherDTO = teacherDao.get(queryMap); - if(teacherDTO != null && !"".equals(teacherDTO.getTeacherId())){ - throw new SaveException("您不能添加证件号码相同的讲师"); + for(int i = 0; i < WorkerCategoryIds.length;i++){ + queryMap.put("workerCategoryId",WorkerCategoryIds[i]); + TeacherDTO teacherDTO = teacherDao.get(queryMap); + if(teacherDTO != null && !"".equals(teacherDTO.getTeacherId())){ + throw new SaveException("该证件号码已在 【" + + teacherDTO.getWorkerCategoryName().split(",")[i] + + "】 工种中注册讲师"); + } } String teacherId = UUIDUtil.getUUID(); Map params = HashMapUtil.beanToMap(teacherVO); diff --git a/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml b/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml index 9df318d..0ca6bb2 100644 --- a/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml +++ b/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml @@ -162,6 +162,9 @@ AND t1.org_id = #{orgId} + + AND FIND_IN_SET( #{workerCategoryId},t1.worker_category_id) + AND t1.id_card_number = #{idCardNumber} diff --git a/src/main/resources/static/route/classplan/save.html b/src/main/resources/static/route/classplan/save.html index db1d758..5708152 100644 --- a/src/main/resources/static/route/classplan/save.html +++ b/src/main/resources/static/route/classplan/save.html @@ -276,7 +276,6 @@ // 初始化内容 function initData() { - $('.layui-card').height($(window).height()); initPlanStartTimeDateTime(); initPlanEndTimeDateTime(); initTeacherList(); diff --git a/src/main/resources/templates/index1.html b/src/main/resources/templates/index1.html index 6e9700d..80a1b90 100644 --- a/src/main/resources/templates/index1.html +++ b/src/main/resources/templates/index1.html @@ -277,21 +277,7 @@ }, initTeacherEChart: function(){ top.restAjax.get('api/indexcount/count-teacher-num', {}, null, function(code, data) { - var dataList = []; - for(var i= 0;i<=2;i++){ - var datajson = {}; - if(i === 0){ - datajson['name'] = "其他" - } - if(i === 1){ - datajson['name'] = "专职" - } - if(i === 2){ - datajson['name'] = "兼职" - } - datajson['value'] = data.data[i+""] - dataList.push(datajson) - } + var dataList = data.data; self.teacherEChart = echarts.init(document.getElementById('teacherEChart')); self.teacherEChart.setOption( { @@ -304,7 +290,7 @@ }, series: [ { - name: '访问来源', + name: '讲师类型', type: 'pie', radius: '70%', data: dataList, @@ -325,22 +311,8 @@ }, initPlanEChart: function(){ top.restAjax.get('api/indexcount/count-plan-type', {}, null, function(code, data) { - var dataList = []; - for(var i= 1;i<=3;i++){ - var datajson = {}; - if(i === 1){ - datajson['name'] = "初训" - } - if(i === 2){ - datajson['name'] = "复训" - } - if(i === 3){ - datajson['name'] = "换证" - } - datajson['value'] = data.data[i+""] - dataList.push(datajson) - } - console.log(dataList) + var dataList = data.data; + self.teacherEChart = echarts.init(document.getElementById('planEChart')); self.teacherEChart.setOption( { @@ -353,7 +325,7 @@ }, series: [ { - name: '访问来源', + name: '培训类型', type: 'pie', radius: '70%', data: dataList,