diff --git a/bonus-business/src/main/java/com/bonus/digital/controller/InspectionStationController.java b/bonus-business/src/main/java/com/bonus/digital/controller/InspectionStationController.java index 69727a8..cf7829d 100644 --- a/bonus-business/src/main/java/com/bonus/digital/controller/InspectionStationController.java +++ b/bonus-business/src/main/java/com/bonus/digital/controller/InspectionStationController.java @@ -77,6 +77,10 @@ public class InspectionStationController extends BaseController { return AjaxResult.success(); } else if (res == 2) { return AjaxResult.error("已绑定人员"); + } else if (res == 3) { + return AjaxResult.error("运检站下有计划,请勿删除"); + } else if (res == 4) { + return AjaxResult.error("请先删除填报人员"); } else { return AjaxResult.error("删除失败"); } diff --git a/bonus-business/src/main/java/com/bonus/digital/controller/PlanManagementController.java b/bonus-business/src/main/java/com/bonus/digital/controller/PlanManagementController.java index b3e6ad9..1b9e9ce 100644 --- a/bonus-business/src/main/java/com/bonus/digital/controller/PlanManagementController.java +++ b/bonus-business/src/main/java/com/bonus/digital/controller/PlanManagementController.java @@ -140,7 +140,11 @@ public class PlanManagementController extends BaseController { ExcelUtil util = new ExcelUtil(PlanManagementVo.class); List planManagementList = util.importExcel(file.getInputStream()); String message = planManagementService.importPlanManagement(planManagementList); - return success(message); + if ("导入成功".equals(message)) { + return success(message); + }else { + return AjaxResult.error(message); + } } catch (Exception e) { log.error(e.getMessage()); return AjaxResult.error("模板错误"); diff --git a/bonus-business/src/main/java/com/bonus/digital/mapper/PersonnelMapper.java b/bonus-business/src/main/java/com/bonus/digital/mapper/PersonnelMapper.java index 811eefc..7707184 100644 --- a/bonus-business/src/main/java/com/bonus/digital/mapper/PersonnelMapper.java +++ b/bonus-business/src/main/java/com/bonus/digital/mapper/PersonnelMapper.java @@ -1,5 +1,6 @@ package com.bonus.digital.mapper; +import com.bonus.common.core.domain.entity.SysUser; import com.bonus.digital.dao.InspectionStationVo; import com.bonus.digital.dao.PersonnelClassificationVo; import com.bonus.digital.dao.PersonnelVo; @@ -39,4 +40,6 @@ public interface PersonnelMapper { PersonnelVo getPersonnelListByPhone(PersonnelVo personnelVo); List getPersonnelByInspection(InspectionStationVo inspectionStationVo); + + List getUserList(SysUser sysUser); } diff --git a/bonus-business/src/main/java/com/bonus/digital/service/impl/InspectionStationServiceImpl.java b/bonus-business/src/main/java/com/bonus/digital/service/impl/InspectionStationServiceImpl.java index e907dab..a3fc839 100644 --- a/bonus-business/src/main/java/com/bonus/digital/service/impl/InspectionStationServiceImpl.java +++ b/bonus-business/src/main/java/com/bonus/digital/service/impl/InspectionStationServiceImpl.java @@ -1,11 +1,14 @@ package com.bonus.digital.service.impl; +import com.bonus.common.core.domain.entity.SysUser; import com.bonus.common.utils.SecurityUtils; import com.bonus.common.utils.StringUtils; import com.bonus.digital.dao.InspectionStationVo; import com.bonus.digital.dao.PersonnelVo; +import com.bonus.digital.dao.PlanManagementVo; import com.bonus.digital.mapper.InspectionStationMapper; import com.bonus.digital.mapper.PersonnelMapper; +import com.bonus.digital.mapper.PlanManagementMapper; import com.bonus.digital.service.InspectionStationService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -30,6 +33,9 @@ public class InspectionStationServiceImpl implements InspectionStationService { @Resource private PersonnelMapper personnelMapper; + @Resource + private PlanManagementMapper planManagementMapper; + /** * 获取0:运检站1:项目部 */ @@ -59,10 +65,25 @@ public class InspectionStationServiceImpl implements InspectionStationService { */ @Override public int delInspectionStation(InspectionStationVo inspectionStationVo) { + //查看运检站是否绑定人员 List personnelVoList = personnelMapper.getPersonnelByInspection(inspectionStationVo); if (StringUtils.isNotEmpty(personnelVoList)) { return 2; } + //查看该运检站是否有计划 + PlanManagementVo planManagementVo = new PlanManagementVo(); + planManagementVo.setInspectionStationId(inspectionStationVo.getInspectionStationId()); + List res = planManagementMapper.getPlanManagementList(planManagementVo); + if (StringUtils.isNotEmpty(res)) { + return 3; + } + SysUser sysUser = new SysUser(); + sysUser.setDeptId((long) inspectionStationVo.getInspectionStationId()); + //查看是否存在填报人 + List userList = personnelMapper.getUserList(sysUser); + if (StringUtils.isNotEmpty(userList)) { + return 4; + } return inspectionStationMapper.delInspectionStation(inspectionStationVo); } diff --git a/bonus-business/src/main/java/com/bonus/digital/service/impl/PlanManagementServiceImpl.java b/bonus-business/src/main/java/com/bonus/digital/service/impl/PlanManagementServiceImpl.java index 012af1c..b1d672a 100644 --- a/bonus-business/src/main/java/com/bonus/digital/service/impl/PlanManagementServiceImpl.java +++ b/bonus-business/src/main/java/com/bonus/digital/service/impl/PlanManagementServiceImpl.java @@ -2,6 +2,7 @@ package com.bonus.digital.service.impl; import com.bonus.common.core.domain.model.LoginUser; import com.bonus.common.utils.SecurityUtils; +import com.bonus.common.utils.StringUtils; import com.bonus.digital.dao.InspectionStationVo; import com.bonus.digital.dao.MonthlyPlanVo; import com.bonus.digital.dao.PlanManagementVo; @@ -85,17 +86,27 @@ public class PlanManagementServiceImpl implements PlanManagementService { public String importPlanManagement(List planManagementList) { for (PlanManagementVo planManagementVo : planManagementList) { - //获取当前 + //对必填项进行校验 + if(StringUtils.isEmpty(planManagementVo.getPlanManagementMonth()) + || StringUtils.isEmpty(planManagementVo.getProjectName()) + || StringUtils.isEmpty(planManagementVo.getWorkContent()) + || StringUtils.isEmpty(planManagementVo.getInspectionStationName()) + || StringUtils.isEmpty(planManagementVo.getStareDate()) + || StringUtils.isEmpty(planManagementVo.getEndDate()) + || StringUtils.isEmpty(planManagementVo.getRiskLevel()) + ){ + return "缺少必填项"; + } + + //获取运检站信息 InspectionStationVo inspectionStationVo = new InspectionStationVo(); inspectionStationVo.setInspectionStationName(planManagementVo.getInspectionStationName()); InspectionStationVo inspectionStationOld =inspectionStationMapper.getInspectionStationDetail(inspectionStationVo); - if (inspectionStationOld!=null){ - planManagementVo.setInspectionStationId(inspectionStationOld.getInspectionStationId()); - Long userId = SecurityUtils.getUserId(); - planManagementVo.setCreateUser(userId.toString()); - planManagementVo.setCreateTime(new Date()); - planManagementMapper.addPlanManagement(planManagementVo); - } + planManagementVo.setInspectionStationId(inspectionStationOld.getInspectionStationId()); + Long userId = SecurityUtils.getUserId(); + planManagementVo.setCreateUser(userId.toString()); + planManagementVo.setCreateTime(new Date()); + planManagementMapper.addPlanManagement(planManagementVo); } return "导入成功"; } diff --git a/bonus-business/src/main/resources/mapper/DayPlanMapper.xml b/bonus-business/src/main/resources/mapper/DayPlanMapper.xml index 543fa68..2cc9393 100644 --- a/bonus-business/src/main/resources/mapper/DayPlanMapper.xml +++ b/bonus-business/src/main/resources/mapper/DayPlanMapper.xml @@ -258,7 +258,10 @@ tb_day_plan tdp left join tb_monthly_plan tmp on tdp.monthly_plan_id = tmp.monthly_plan_id left join tb_plan_major tpm on tmp.plan_major_id = tpm.plan_major_id - where tdp.day_plan_id = #{dayPlanId} and tdp.is_active = '1' + where tdp.is_active = '1' + + AND tdp.day_plan_id = #{dayPlanId} + AND tdp.day_plan = #{dayPlan} diff --git a/bonus-business/src/main/resources/mapper/PersonnalMapper.xml b/bonus-business/src/main/resources/mapper/PersonnalMapper.xml index 162dad5..500b3fb 100644 --- a/bonus-business/src/main/resources/mapper/PersonnalMapper.xml +++ b/bonus-business/src/main/resources/mapper/PersonnalMapper.xml @@ -136,4 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" tis.create_user from tb_personnel tis where tis.is_active='1' and tis.inspection_station_id = #{inspectionStationId} +