|
@@ -0,0 +1,95 @@
|
|
|
+package com.usky.fire.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.usky.common.core.bean.CommonPage;
|
|
|
+import com.usky.common.core.util.StringUtils;
|
|
|
+import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.fire.domain.BaseCompanyPerson;
|
|
|
+import com.usky.fire.mapper.BaseCompanyPersonMapper;
|
|
|
+import com.usky.fire.mapper.MhPostInspectMapper;
|
|
|
+import com.usky.fire.service.BaseCompanyPersonService;
|
|
|
+import com.usky.fire.service.BaseUserCompanyService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 联网单位消防人员信息 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author JCB
|
|
|
+ * @since 2022-08-24
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class BaseCompanyPersonServiceImpl extends AbstractCrudService<BaseCompanyPersonMapper, BaseCompanyPerson> implements BaseCompanyPersonService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BaseUserCompanyService baseUserCompanyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MhPostInspectMapper mhPostInspectMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonPage<BaseCompanyPerson> baseCompanyPersonList(String companyCode, String companyName, Integer pageNum, Integer pageSize) {
|
|
|
+ List<String> companyIdList = baseUserCompanyService.companyIdList();
|
|
|
+ IPage<BaseCompanyPerson> page = new Page<>(pageNum, pageSize);
|
|
|
+ if (CollectionUtils.isNotEmpty(companyIdList)) {
|
|
|
+ LambdaQueryWrapper<BaseCompanyPerson> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(companyCode), BaseCompanyPerson::getCompanyCode, companyCode)
|
|
|
+ .like(StringUtils.isNotBlank(companyName), BaseCompanyPerson::getCompanyName, companyName)
|
|
|
+ .in(BaseCompanyPerson::getCompanyId, companyIdList)
|
|
|
+ .orderByDesc(BaseCompanyPerson::getId);
|
|
|
+ page = this.page(page, queryWrapper);
|
|
|
+ if (page.getTotal() > 0) {
|
|
|
+ List<BaseCompanyPerson> baseCompanyPeople = mhPostInspectMapper.inspectStatistics(companyIdList);
|
|
|
+ for (int i = 0; i < page.getRecords().size(); i++) {
|
|
|
+ for (int j = 0; j < baseCompanyPeople.size(); j++) {
|
|
|
+ if (page.getRecords().get(i).getCompanyId().equals(baseCompanyPeople.get(j).getCompanyId())) {
|
|
|
+ page.getRecords().get(i).setInspectCount(baseCompanyPeople.get(j).getInspectCount());
|
|
|
+ page.getRecords().get(i).setAnswerCount(baseCompanyPeople.get(j).getAnswerCount());
|
|
|
+ page.getRecords().get(i).setInspectTime(baseCompanyPeople.get(j).getInspectTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new CommonPage<>(page.getRecords(), page.getTotal(), pageSize, pageNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> postInspectStatistics() {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = new Date();
|
|
|
+ String format = simpleDateFormat.format(date);
|
|
|
+ String startTime = format + " 00:00:00";
|
|
|
+ String endTime = format + " 23:59:59";
|
|
|
+ List<String> companyIdList = baseUserCompanyService.companyIdList();
|
|
|
+ String spentTime = "--:--";
|
|
|
+ Integer answeredCount = 0;
|
|
|
+ Integer notAnsweredCount = 0;
|
|
|
+ Integer count = 0;
|
|
|
+ if (CollectionUtils.isNotEmpty(companyIdList)) {
|
|
|
+ Integer spentTimeAvg = mhPostInspectMapper.mhPostInspectStatistics(" AVG(spent_time) ", 1, startTime, endTime, companyIdList, null);
|
|
|
+ answeredCount = mhPostInspectMapper.mhPostInspectStatistics(" count(*) ", 1, startTime, endTime, companyIdList, null);
|
|
|
+ notAnsweredCount = mhPostInspectMapper.mhPostInspectStatistics(" count(*) ", 0, startTime, endTime, companyIdList, null);
|
|
|
+ count = answeredCount + notAnsweredCount;
|
|
|
+ spentTime = spentTimeAvg / 60 + ":" + spentTimeAvg % 60;
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("spentTimeAvg", spentTime);
|
|
|
+ map.put("count", count);
|
|
|
+ map.put("answeredCount", answeredCount);
|
|
|
+ map.put("notAnsweredCount", notAnsweredCount);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+}
|