|
|
@ -25,29 +25,30 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.rocketmq.messages.BaseMQMsgDTO; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.dto.result.DictTreeResultDTO; |
|
|
|
import com.epmet.commons.tools.enums.DictTypeEnum; |
|
|
|
import com.epmet.commons.tools.enums.OrgTypeEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.SystemMessageType; |
|
|
|
import com.epmet.dao.PatrolRoutineWorkDao; |
|
|
|
import com.epmet.dao.StatsStaffPatrolRecordDailyDao; |
|
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
|
import com.epmet.dto.form.CustomerGridFormDTO; |
|
|
|
import com.epmet.dto.form.PatrolRoutineWorkFormDTO; |
|
|
|
import com.epmet.dto.form.PcWorkListFormDTO; |
|
|
|
import com.epmet.dto.form.patrol.GridMemberRoutineWorkFormDTO; |
|
|
|
import com.epmet.dto.form.patrol.PatrolQueryFormDTO; |
|
|
|
import com.epmet.dto.result.AllGridsByUserIdResultDTO; |
|
|
|
import com.epmet.dto.result.PatrolRoutineWorkResult; |
|
|
|
import com.epmet.dto.result.PcWorkListResultDTO; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.PatrolRoutineWorkEntity; |
|
|
|
import com.epmet.entity.PatrolRoutineWorkTypeEntity; |
|
|
|
import com.epmet.excel.PcWorkListExport; |
|
|
@ -61,6 +62,7 @@ import com.github.pagehelper.Page; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -68,13 +70,13 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.beans.Encoder; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; |
|
|
|
|
|
|
|
/** |
|
|
|
* 巡查例行工作 |
|
|
|
* |
|
|
@ -94,6 +96,8 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
private PatrolRoutineWorkTypeService patrolRoutineWorkTypeService; |
|
|
|
@Autowired |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private StatsStaffPatrolRecordDailyDao statsStaffPatrolRecordDailyDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
@ -347,4 +351,90 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
System.out.println(JSON.toJSONString(result)); |
|
|
|
}*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 【例行工作】网格员巡查例行工作统计数据 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public StatsdataResultDTO statsData(GridMemberRoutineWorkFormDTO formDTO) { |
|
|
|
StatsdataResultDTO resultDTO = statsStaffPatrolRecordDailyDao.getStatsData(formDTO.getGridId(), formDTO.getStaffId()); |
|
|
|
if (null == resultDTO) { |
|
|
|
return new StatsdataResultDTO(); |
|
|
|
} |
|
|
|
//秒变小时分钟
|
|
|
|
Integer minutes = (resultDTO.getTotalNum() > NumConstant.ZERO ? resultDTO.getTotalNum() / 60 : 0); |
|
|
|
String patrolDuration = (minutes / 60 > 0 ? minutes / 60 + "小时" : "") + (minutes % 60 > 0 ? minutes % 60 + "分钟" : "0分钟"); |
|
|
|
resultDTO.setTotalTime(patrolDuration); |
|
|
|
|
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 【例行工作】网格员例行工作列表 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public RoutineWorkListResultDTO list(GridMemberRoutineWorkFormDTO formDTO) { |
|
|
|
RoutineWorkListResultDTO resultDTO = new RoutineWorkListResultDTO(); |
|
|
|
//1.按条件查询网格员例行工作列表数据
|
|
|
|
PageInfo<RoutineWorkListResultDTO.RoutineWorkList> result = |
|
|
|
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.staffRoutineWorkList(formDTO.getGridId(), formDTO.getStaffId())); |
|
|
|
if (org.springframework.util.CollectionUtils.isEmpty(result.getList())) { |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
//2.查询分类编码字典数据
|
|
|
|
Result<Map<String, String>> unitTypeMap = adminOpenFeignClient.dictMap(DictTypeEnum.PATROL_WORK_TYPE.getCode()); |
|
|
|
if (!unitTypeMap.success() || MapUtils.isEmpty(unitTypeMap.getData())) { |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取例行工作类型字典表数据失败!"); |
|
|
|
} |
|
|
|
Map<String, String> map = unitTypeMap.getData(); |
|
|
|
|
|
|
|
//3.封装数据并返回
|
|
|
|
result.getList().forEach(re -> { |
|
|
|
re.setWorkTypeName(map.get(re.getWorkTypeCode()) + "-" + map.get(re.getWorkTypeCode())); |
|
|
|
}); |
|
|
|
resultDTO.setTotal((int) result.getTotal()); |
|
|
|
resultDTO.setList(result.getList()); |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 【例行工作】例行工作详情 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public RoutineWorkDetailResultDTO detail(GridMemberRoutineWorkFormDTO formDTO) { |
|
|
|
//1.查询例行工作详情数据
|
|
|
|
RoutineWorkDetailResultDTO resultDTO = baseDao.getDetail(formDTO.getRoutineWorkId()); |
|
|
|
if (null == resultDTO) { |
|
|
|
return new RoutineWorkDetailResultDTO(); |
|
|
|
} |
|
|
|
//2.获取工作人员缓存信息
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); |
|
|
|
if (null == staffInfo) { |
|
|
|
throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getStaffId())); |
|
|
|
} |
|
|
|
//3.获取网格缓存信息
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(resultDTO.getGridId()); |
|
|
|
if (null == gridInfo) { |
|
|
|
throw new EpmetException(String.format("未查询到网格{%s}信息", resultDTO.getGridId())); |
|
|
|
} |
|
|
|
if (StringUtils.isEmpty(gridInfo.getAgencyName())) { |
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(gridInfo.getPid()); |
|
|
|
gridInfo.setAgencyName(agencyInfo.getOrganizationName()); |
|
|
|
} |
|
|
|
//4.获取例行工作类型字典表数据
|
|
|
|
Result<Map<String, String>> unitTypeMap = adminOpenFeignClient.dictMap(DictTypeEnum.PATROL_WORK_TYPE.getCode()); |
|
|
|
if (!unitTypeMap.success() || MapUtils.isEmpty(unitTypeMap.getData())) { |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取例行工作类型字典表数据失败!"); |
|
|
|
} |
|
|
|
//5.封装数据并返回
|
|
|
|
resultDTO.setGridName(gridInfo.getAgencyName() + "-" + gridInfo.getGridName()); |
|
|
|
resultDTO.setStaffName(staffInfo.getRealName()); |
|
|
|
resultDTO.setWorkTypeName(unitTypeMap.getData().get(resultDTO.getAllPCode()) + "-" + unitTypeMap.getData().get(resultDTO.getWorkTypeCode())); |
|
|
|
return resultDTO; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|