|
@@ -8,15 +8,20 @@ import com.usky.common.security.utils.SecurityUtils;
|
|
|
import com.usky.fire.domain.*;
|
|
|
import com.usky.fire.mapper.PatrolInspectionPlanMapper;
|
|
|
import com.usky.fire.mapper.PatrolInspectionPlanSonMapper;
|
|
|
+import com.usky.fire.mapper.PatrolInspectionRecordMapper;
|
|
|
import com.usky.fire.service.*;
|
|
|
+import com.usky.fire.service.util.OnlineMethod;
|
|
|
import com.usky.fire.service.vo.DataCountVo;
|
|
|
import com.usky.fire.service.vo.PatrolInspectionContentVo;
|
|
|
import com.usky.fire.service.vo.PatrolInspectionPlanSonVo;
|
|
|
+import com.usky.fire.service.vo.PlanRecordVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -53,6 +58,18 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
|
|
|
@Autowired
|
|
|
private PatrolInspectionContentOptionService patrolInspectionContentOptionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionRecordMapper patrolInspectionRecordMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionAreaService patrolInspectionAreaService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionRecordOptionService patrolInspectionRecordOptionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionRecordPictureService patrolInspectionRecordPictureService;
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> appPlanStatistics(Integer personnelId, String currentDate) {
|
|
|
LambdaQueryWrapper<PatrolInspectionPlanSchedule> queryWrapper = Wrappers.lambdaQuery();
|
|
@@ -181,8 +198,93 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- public void updatePlan(){
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void updatePlan(PlanRecordVo planRecordVo) {
|
|
|
+ DateTimeFormatter df1 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectionPlanSon::getId, planRecordVo.getPlanSonId());
|
|
|
+ List<PatrolInspectionPlanSon> planSonList = this.list(queryWrapper);
|
|
|
+ if (planSonList.size() <= 0) {
|
|
|
+ throw new BusinessException("计划不存在,可能已被删除,请联系管理人员");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<PatrolInspectionArea> queryWrapperOne = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperOne.select(PatrolInspectionArea::getId, PatrolInspectionArea::getAreaName)
|
|
|
+ .eq(PatrolInspectionArea::getId, planSonList.get(0).getAreaId());
|
|
|
+ List<PatrolInspectionArea> areaList = patrolInspectionAreaService.list(queryWrapperOne);
|
|
|
+
|
|
|
+ PatrolInspectionRecord patrolInspectionRecord = new PatrolInspectionRecord();
|
|
|
+ patrolInspectionRecord.setSiteNubmber(planRecordVo.getSiteNubmber());
|
|
|
+ patrolInspectionRecord.setSiteType(planRecordVo.getSiteType());
|
|
|
+ patrolInspectionRecord.setAreaName(areaList.get(0).getAreaName());
|
|
|
+ patrolInspectionRecord.setSiteName(planRecordVo.getSiteName());
|
|
|
+ patrolInspectionRecord.setName(SecurityUtils.getUsername());
|
|
|
+ patrolInspectionRecord.setPhone("人员表缺少");
|
|
|
+ patrolInspectionRecord.setPlanType(planSonList.get(0).getPlanType());
|
|
|
+ patrolInspectionRecord.setSiteStatus(planRecordVo.getSiteStatus());
|
|
|
+ patrolInspectionRecord.setLongitude(planRecordVo.getLongitude());
|
|
|
+ patrolInspectionRecord.setLatitude(planRecordVo.getLatitude());
|
|
|
+ String startDate = null;
|
|
|
+ String endDate = null;
|
|
|
+ if (planSonList.get(0).getPlanType() == 1) {
|
|
|
+ startDate = df1.format(planSonList.get(0).getInspectionDate()) + "T" + planSonList.get(0).getStartTime();
|
|
|
+ endDate = df1.format(planSonList.get(0).getInspectionDate()) + "T" + planSonList.get(0).getEndTime();
|
|
|
+ } else {
|
|
|
+ startDate = df1.format(planSonList.get(0).getStartDate()) + "T" + planSonList.get(0).getStartTime();
|
|
|
+ endDate = df1.format(planSonList.get(0).getEndDate()) + "T" + planSonList.get(0).getEndTime();
|
|
|
+ }
|
|
|
+ patrolInspectionRecord.setStartDate(LocalDateTime.parse(startDate));
|
|
|
+ patrolInspectionRecord.setEndDate(LocalDateTime.parse(endDate));
|
|
|
+ patrolInspectionRecord.setCreateTime(LocalDateTime.now());
|
|
|
+ patrolInspectionRecord.setPlanId(planSonList.get(0).getPlanId());
|
|
|
+ patrolInspectionRecord.setPlanSonId(planRecordVo.getPlanSonId());
|
|
|
+ patrolInspectionRecord.setSiteId(planRecordVo.getSiteId());
|
|
|
+ patrolInspectionRecord.setTenantId(SecurityUtils.getTenantId());
|
|
|
+ patrolInspectionRecord.setCompanyId(planRecordVo.getCompanyId());
|
|
|
+ patrolInspectionRecord.setCreator(SecurityUtils.getUsername());
|
|
|
+ patrolInspectionRecordMapper.insert(patrolInspectionRecord);
|
|
|
+ Integer recordId = patrolInspectionRecord.getId();
|
|
|
+ List<PatrolInspectionRecordPicture> recordPictureList = planRecordVo.getRecordPictureList();
|
|
|
+ List<PatrolInspectionRecordOption> recordOptionList = planRecordVo.getRecordOptionList();
|
|
|
+ for (int i = 0; i < recordPictureList.size(); i++) {
|
|
|
+ recordPictureList.get(i).setRecordId(recordId);
|
|
|
+ patrolInspectionRecordPictureService.save(recordPictureList.get(i));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < recordOptionList.size(); i++) {
|
|
|
+ recordOptionList.get(i).setRecordId(recordId);
|
|
|
+ patrolInspectionRecordOptionService.save(recordOptionList.get(i));
|
|
|
+ }
|
|
|
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlanSiteSon> queryWrapperTwo = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperTwo.eq(PatrolInspectionPlanSiteSon::getPlanId, planRecordVo.getPlanSonId())
|
|
|
+ .eq(PatrolInspectionPlanSiteSon::getSiteId, planRecordVo.getSiteId());
|
|
|
+ List<PatrolInspectionPlanSiteSon> planSiteSonList = patrolInspectionPlanSiteSonService.list(queryWrapperTwo);
|
|
|
+ PatrolInspectionPlanSiteSon planSiteSon = new PatrolInspectionPlanSiteSon();
|
|
|
+ planSiteSon.setId(planSiteSonList.get(0).getId());
|
|
|
+ planSiteSon.setInspectionStatus(2);
|
|
|
+ planSiteSon.setCreateTime(LocalDateTime.now());
|
|
|
+ patrolInspectionPlanSiteSonService.updateById(planSiteSon);
|
|
|
+ Integer patrolledCount = this.planSiteSonCount(planRecordVo.getPlanSonId(), 2);
|
|
|
+ Integer undetectedCount = this.planSiteSonCount(planRecordVo.getPlanSonId(), 1);
|
|
|
+ Integer siteCount = patrolledCount + undetectedCount;
|
|
|
+ String rad = OnlineMethod.myPercent(patrolledCount, siteCount).replace("%", "");
|
|
|
+ Double d = Double.parseDouble(rad); // 先转换成double类型
|
|
|
+ Integer completion = d.intValue(); // 再转换成int类型(会损失精度)
|
|
|
+ PatrolInspectionPlanSon planSon = new PatrolInspectionPlanSon();
|
|
|
+ planSon.setId(planRecordVo.getPlanSonId());
|
|
|
+ planSon.setCompletion(completion);
|
|
|
+ this.updateById(planSon);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer planSiteSonCount(Integer planSonId, Integer inspectionStatus) {
|
|
|
+ LambdaQueryWrapper<PatrolInspectionPlanSiteSon> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectionPlanSiteSon::getPlanId, planSonId)
|
|
|
+ .eq(PatrolInspectionPlanSiteSon::getInspectionStatus, inspectionStatus);
|
|
|
+ Integer planSiteSonCount = patrolInspectionPlanSiteSonService.count(queryWrapper);
|
|
|
+ return planSiteSonCount;
|
|
|
}
|
|
|
|
|
|
|