|
@@ -1,6 +1,7 @@
|
|
|
package com.bizmatics.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.bizmatics.common.core.bean.CommonPage;
|
|
|
import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
@@ -10,12 +11,13 @@ import com.bizmatics.model.vo.*;
|
|
|
import com.bizmatics.persistence.mapper.DevopsWorkOrderMapper;
|
|
|
import com.bizmatics.service.*;
|
|
|
import com.bizmatics.service.util.SecurityUtils;
|
|
|
+import org.junit.jupiter.api.Order;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 运维管理-工单管理
|
|
@@ -37,6 +39,12 @@ public class DevopsWorkOrderServiceImpl extends AbstractCrudService<DevopsWorkOr
|
|
|
@Autowired
|
|
|
private PatrolRecordRouteService patrolRecordRouteService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectorsService patrolInspectorsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionTeamService patrolInspectionTeamService;
|
|
|
+
|
|
|
@Override
|
|
|
public void devopsWorkOrderAdd(DevopsWorkOrderVo devopsWorkOrderVo) {
|
|
|
DevopsWorkOrder devopsWorkOrder = new DevopsWorkOrder();
|
|
@@ -223,15 +231,15 @@ public class DevopsWorkOrderServiceImpl extends AbstractCrudService<DevopsWorkOr
|
|
|
devopsWorkOrderList.get(0).setPatrolInspectionDeviceDetailsVo(PatrolInspectionDeviceList);
|
|
|
devopsWorkOrderList.get(0).setPatrolInspectorsVo(patrolInspectorsList);
|
|
|
|
|
|
- if(devopsWorkOrderList.get(0).getGenerationMode()==1){
|
|
|
+ if (devopsWorkOrderList.get(0).getGenerationMode() == 1) {
|
|
|
LambdaQueryWrapper<PatrolInspectionRecord> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(PatrolInspectionRecord::getId, devopsWorkOrderList.get(0).getInspectionRecordId());
|
|
|
List<PatrolInspectionRecord> patrolInspectionRecordList = patrolInspectionRecordService.list(queryWrapper);
|
|
|
List<PatrolRouteContentListVo> patrolRouteContentList = baseMapper.patrolRouteContentList(patrolInspectionRecordList.get(0).getSiteId(), patrolInspectionRecordList.get(0).getInspectionSchemeId());
|
|
|
- for (int i= 0; i<patrolRouteContentList.size();i++){
|
|
|
+ for (int i = 0; i < patrolRouteContentList.size(); i++) {
|
|
|
LambdaQueryWrapper<PatrolRecordRoute> queryWrapperTwo = Wrappers.lambdaQuery();
|
|
|
queryWrapperTwo.eq(PatrolRecordRoute::getInspectionRecordId, patrolInspectionRecordList.get(0).getId())
|
|
|
- .eq(PatrolRecordRoute::getInspectionContentId,patrolRouteContentList.get(i).getInspectionContentId());
|
|
|
+ .eq(PatrolRecordRoute::getInspectionContentId, patrolRouteContentList.get(i).getInspectionContentId());
|
|
|
List<PatrolRecordRoute> patrolInspectionSchemeList = patrolRecordRouteService.list(queryWrapperTwo);
|
|
|
|
|
|
PatrolRouteContentListVo patrolRouteContentListVo = new PatrolRouteContentListVo();
|
|
@@ -245,7 +253,7 @@ public class DevopsWorkOrderServiceImpl extends AbstractCrudService<DevopsWorkOr
|
|
|
patrolRouteContentListVo.setStatus(patrolRouteContentList.get(i).getStatus());
|
|
|
patrolRouteContentListVo.setPatrolRecordRoute(patrolInspectionSchemeList);
|
|
|
List inspectionDeviceAbnormalList = new ArrayList();
|
|
|
- for (int j = 0;j<patrolInspectionSchemeList.size();j++){
|
|
|
+ for (int j = 0; j < patrolInspectionSchemeList.size(); j++) {
|
|
|
inspectionDeviceAbnormalList.add(patrolInspectionSchemeList.get(j).getStatus());
|
|
|
}
|
|
|
patrolRouteContentListVoList.add(patrolRouteContentListVo);
|
|
@@ -256,4 +264,285 @@ public class DevopsWorkOrderServiceImpl extends AbstractCrudService<DevopsWorkOr
|
|
|
|
|
|
return devopsWorkOrderList;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PatrolInspectors> patrolInspectorsDroplist() {
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ LambdaQueryWrapper<PatrolInspectors> queryWrapperTwo = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperTwo.eq(PatrolInspectors::getStatus, 1)
|
|
|
+ .eq(PatrolInspectors::getUserId, user.getUserId());
|
|
|
+ List<PatrolInspectors> patrolInspectorsList = patrolInspectorsService.list(queryWrapperTwo);
|
|
|
+ return patrolInspectorsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PatrolInspectionTeamOneVo> PatrolInspectionTeamList() {
|
|
|
+ List<PatrolInspectionTeamOneVo> patrolInspectionTeamOneVoList = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<PatrolInspectionTeam> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectionTeam::getStatus, 1);
|
|
|
+ List<PatrolInspectionTeam> patrolInspectionTeamList = patrolInspectionTeamService.list(queryWrapper);
|
|
|
+ List<PatrolInspectorsOneVo> patrolInspectorsOneVoList = baseMapper.patrolInspectorsOneVoList();
|
|
|
+ if (patrolInspectionTeamList.size() > 0) {
|
|
|
+ for (int i = 0; i < patrolInspectionTeamList.size(); i++) {
|
|
|
+ List<Object> List = new ArrayList<>();
|
|
|
+ PatrolInspectionTeamOneVo patrolInspectionTeamOneVo = new PatrolInspectionTeamOneVo();
|
|
|
+ patrolInspectionTeamOneVo.setTeamType(patrolInspectionTeamList.get(i).getTeamType());
|
|
|
+ patrolInspectionTeamOneVo.setInspectorsId(patrolInspectionTeamList.get(i).getInspectorsId());
|
|
|
+ patrolInspectionTeamOneVo.setTeamName(patrolInspectionTeamList.get(i).getTeamName());
|
|
|
+ patrolInspectionTeamOneVo.setCreator(patrolInspectionTeamList.get(i).getCreator());
|
|
|
+ patrolInspectionTeamOneVo.setCreateTime(patrolInspectionTeamList.get(i).getCreateTime());
|
|
|
+ patrolInspectionTeamOneVo.setStatus(patrolInspectionTeamList.get(i).getStatus());
|
|
|
+ patrolInspectionTeamOneVo.setId(patrolInspectionTeamList.get(i).getId());
|
|
|
+ patrolInspectionTeamOneVo.setUserId(patrolInspectionTeamList.get(i).getUserId());
|
|
|
+ patrolInspectionTeamOneVo.setReservedField(patrolInspectionTeamList.get(i).getReservedField());
|
|
|
+
|
|
|
+ if (patrolInspectorsOneVoList.size() > 0) {
|
|
|
+ for (int j = 0; j < patrolInspectorsOneVoList.size(); j++) {
|
|
|
+ if (patrolInspectionTeamList.get(i).getId() == patrolInspectorsOneVoList.get(j).getTeamId()) {
|
|
|
+ List.add(patrolInspectorsOneVoList.get(j));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ patrolInspectionTeamOneVo.setPatrolInspectorsOneVo(List);
|
|
|
+
|
|
|
+ patrolInspectionTeamOneVoList.add(patrolInspectionTeamOneVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return patrolInspectionTeamOneVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void operationCensus(String type) {
|
|
|
+ String firstDay;
|
|
|
+ String lastDay;
|
|
|
+ Date startDate;
|
|
|
+ Date endDate;
|
|
|
+ String startTime;
|
|
|
+ String endTime;
|
|
|
+ int days = 0;
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat yearFormatter = new SimpleDateFormat("yyyy");
|
|
|
+ Date date = new Date();
|
|
|
+ String year = yearFormatter.format(date);
|
|
|
+ String startHms = "00:00:00";
|
|
|
+ String endHms = "23:59:59";
|
|
|
+ Integer stayGrabOrdersCount = 0;
|
|
|
+ Integer stayAppointCount = 0;
|
|
|
+ Integer stayOrderTakingCount = 0;
|
|
|
+ Integer stayManageCount = 0;
|
|
|
+ Integer stayCustomsClearanceCount = 0;
|
|
|
+ Integer completedCount = 0;
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+ case "thisMonth":
|
|
|
+ Calendar calendar = new GregorianCalendar();
|
|
|
+ calendar.setTime(date);
|
|
|
+ //获得本月第一天
|
|
|
+ calendar.add(Calendar.MONTH, 0);
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ firstDay = sdf.format(calendar.getTime());
|
|
|
+ startDate = calendar.getTime();
|
|
|
+ //获得本月最后一天
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
+ lastDay = sdf.format(calendar.getTime());
|
|
|
+ startTime = firstDay + " " + startHms;
|
|
|
+ endTime = lastDay + " " + endHms;
|
|
|
+ days = (int) ((date.getTime() - startDate.getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "lastMonth":
|
|
|
+ //获取前一个月第一天
|
|
|
+ Calendar calendar1 = Calendar.getInstance();
|
|
|
+ calendar1.add(Calendar.MONTH, -1);
|
|
|
+ calendar1.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ firstDay = sdf.format(calendar1.getTime());
|
|
|
+ startDate = calendar1.getTime();
|
|
|
+ //获取前一个月最后一天
|
|
|
+ Calendar calendar2 = Calendar.getInstance();
|
|
|
+ calendar2.set(Calendar.DAY_OF_MONTH, 0);
|
|
|
+ lastDay = sdf.format(calendar2.getTime());
|
|
|
+ endDate = calendar2.getTime();
|
|
|
+ startTime = firstDay + " " + startHms;
|
|
|
+ endTime = lastDay + " " + endHms;
|
|
|
+
|
|
|
+ days = (int) ((endDate.getTime() - startDate.getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
+ break;
|
|
|
+ case "thisQuarter":
|
|
|
+ //获取本季度第一天
|
|
|
+ startDate = getCurrentQuarterStartTime();
|
|
|
+ firstDay = sdf.format(startDate);
|
|
|
+ //获取本季度最后一天
|
|
|
+ endDate = getCurrentQuarterEndTime();
|
|
|
+ lastDay = sdf.format(endDate);
|
|
|
+ startTime = firstDay + " " + startHms;
|
|
|
+ endTime = lastDay + " " + endHms;
|
|
|
+ days = (int) ((date.getTime() - startDate.getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
+ break;
|
|
|
+ case "lastQuarter":
|
|
|
+ startDate = getCurrentQuarterStartTime();
|
|
|
+ endDate = getCurrentQuarterEndTime();
|
|
|
+ Calendar calendar3 = Calendar.getInstance(); //得到日历
|
|
|
+ calendar3.setTime(startDate);//把当前时间赋给日历
|
|
|
+ calendar3.add(calendar3.MONTH, -3); //设置为前3月
|
|
|
+ date = calendar3.getTime(); //得到前3月的时间
|
|
|
+ firstDay = sdf.format(date);
|
|
|
+ calendar3.setTime(endDate);//把当前时间赋给日历
|
|
|
+ calendar3.add(calendar3.MONTH, -3); //设置为前3月
|
|
|
+ date = calendar3.getTime(); //得到前3月的时间
|
|
|
+ lastDay = sdf.format(date);
|
|
|
+ startTime = firstDay + " " + startHms;
|
|
|
+ endTime = lastDay + " " + endHms;
|
|
|
+ days = (int) ((endDate.getTime() - startDate.getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
+ break;
|
|
|
+ case "thisYear":
|
|
|
+ //获取本年时间
|
|
|
+ startTime = year + "-01-01 " + startHms;
|
|
|
+ endTime = year + "-12-31 " + endHms;
|
|
|
+
|
|
|
+ try {
|
|
|
+ startDate = sdf.parse(year + "-01-01");
|
|
|
+ days = (int) ((date.getTime() - startDate.getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "lastYear":
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.add(Calendar.YEAR, -1);
|
|
|
+ Date yearDate = c.getTime();
|
|
|
+ String yearTime = yearFormatter.format(yearDate);
|
|
|
+ startTime = yearTime + "-01-01 " + startHms;
|
|
|
+ endTime = yearTime + "-12-31 " + endHms;
|
|
|
+ try {
|
|
|
+ startDate = sdf.parse(year + "-01-01");
|
|
|
+ endDate = sdf.parse(yearTime + "-12-31");
|
|
|
+ days = (int) ((endDate.getTime() - startDate.getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ String[] time = type.split(",");
|
|
|
+ startTime = time[0] + " " + startHms;
|
|
|
+ endTime = time[1] + " " + endHms;
|
|
|
+ try {
|
|
|
+ startDate = sdf.parse(time[0]);
|
|
|
+ endDate = sdf.parse(time[1]);
|
|
|
+ days = (int) ((endDate.getTime() - startDate.getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //新建工单数量
|
|
|
+ LambdaQueryWrapper<DevopsWorkOrder> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(DevopsWorkOrder::getStatus, 1)
|
|
|
+ .between(DevopsWorkOrder::getCreateTime, startTime, endTime);
|
|
|
+ Integer newWorkOrderCount = this.count(queryWrapper);
|
|
|
+
|
|
|
+ //已完成工单
|
|
|
+ LambdaQueryWrapper<DevopsWorkOrder> queryWrapperOne = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperOne.eq(DevopsWorkOrder::getStatus, 1)
|
|
|
+ .eq(DevopsWorkOrder::getWorkOrderStatus, 6)
|
|
|
+ .between(DevopsWorkOrder::getCreateTime, startTime, endTime);
|
|
|
+ Integer completedWorkOrder = this.count(queryWrapperOne);
|
|
|
+
|
|
|
+ //平均响应时间
|
|
|
+ Double average_ResponseTime = 0.30;
|
|
|
+
|
|
|
+ //日均工单数
|
|
|
+ double workOrderAveCount = newWorkOrderCount / days;
|
|
|
+
|
|
|
+ //工作状态
|
|
|
+ QueryWrapper<DevopsWorkOrder> queryWrapperTwo = new QueryWrapper<>();
|
|
|
+ queryWrapperTwo.select("work_order_status", "count(*) as count")
|
|
|
+ .between("create_time", startTime, endTime)
|
|
|
+ .groupBy("work_order_status");
|
|
|
+ List<DevopsWorkOrder> groupingQueryVoList = this.list(queryWrapperTwo);
|
|
|
+ for (int i = 0; i < groupingQueryVoList.size(); i++) {
|
|
|
+ switch (groupingQueryVoList.get(i).getWorkOrderStatus()) {
|
|
|
+ case 1:
|
|
|
+ stayGrabOrdersCount = groupingQueryVoList.get(i).getCount();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ stayAppointCount = groupingQueryVoList.get(i).getCount();
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ stayOrderTakingCount = groupingQueryVoList.get(i).getCount();
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ stayManageCount = groupingQueryVoList.get(i).getCount();
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ stayCustomsClearanceCount = groupingQueryVoList.get(i).getCount();
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ completedCount = groupingQueryVoList.get(i).getCount();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据当前日期获取本季度第一天
|
|
|
+ public static Date getCurrentQuarterStartTime() {
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ int currentMonth = c.get(Calendar.MONTH) + 1;
|
|
|
+ SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat shortSdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date now = null;
|
|
|
+ try {
|
|
|
+ if (currentMonth <= 3)
|
|
|
+ c.set(Calendar.MONTH, 0);
|
|
|
+ else if (currentMonth <= 6)
|
|
|
+ c.set(Calendar.MONTH, 3);
|
|
|
+ else if (currentMonth <= 9)
|
|
|
+ c.set(Calendar.MONTH, 6);
|
|
|
+ else if (currentMonth <= 12)
|
|
|
+ c.set(Calendar.MONTH, 9);
|
|
|
+ c.set(Calendar.DATE, 1);
|
|
|
+ now = longSdf.parse(shortSdf.format(c.getTime()) + " 00:00:00");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return now;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //根据当前日期获取本季度最后一天
|
|
|
+ public static Date getCurrentQuarterEndTime() {
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(getCurrentQuarterStartTime());
|
|
|
+ cal.add(Calendar.MONTH, 2);
|
|
|
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
+ cal.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
+ cal.set(Calendar.MINUTE, 59);
|
|
|
+ cal.set(Calendar.SECOND, 59);
|
|
|
+ cal.set(Calendar.MILLISECOND, 999);
|
|
|
+ return cal.getTime();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getQuarter() {
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ int month = c.get(c.MONTH) + 1;
|
|
|
+ int quarter = 0;
|
|
|
+ if (month >= 1 && month <= 3) {
|
|
|
+ quarter = 1;
|
|
|
+ } else if (month >= 4 && month <= 6) {
|
|
|
+ quarter = 2;
|
|
|
+ } else if (month >= 7 && month <= 9) {
|
|
|
+ quarter = 3;
|
|
|
+ } else {
|
|
|
+ quarter = 4;
|
|
|
+ }
|
|
|
+ return quarter + "";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|