Commit 96443c92 authored by tianbo's avatar tianbo

bug修改

parent d7de4e3b
...@@ -63,13 +63,13 @@ public class DateUtils { ...@@ -63,13 +63,13 @@ public class DateUtils {
} }
/** /**
* 获取现在时间字符串 * 获取现在日期字符串
* *
* @return返回字符串格式 yyyy-MM-dd HH:mm:ss * @return返回字符串格式 yyyy-MM-dd
*/ */
public static String getNowStrLong() { public static String getDateNowShortStr() {
Date currentTime = new Date(); Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat formatter = new SimpleDateFormat(DATE_PATTERN);
String dateString = formatter.format(currentTime); String dateString = formatter.format(currentTime);
return dateString; return dateString;
} }
......
...@@ -79,4 +79,11 @@ public interface IDutyCommonService { ...@@ -79,4 +79,11 @@ public interface IDutyCommonService {
* @return List<Map < String, Object>> * @return List<Map < String, Object>>
*/ */
List<Map<String, Object>> listOnDutyPerson(); List<Map<String, Object>> listOnDutyPerson();
/**
* 根据当前时间获取值班班次id列表
*
* @return
*/
List<Long> getDutyShiftIdList();
} }
...@@ -9,12 +9,11 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCompanyCountDto; ...@@ -9,12 +9,11 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCompanyCountDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto; import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferDto; import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferResourceDto; import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferResourceDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferSimpleDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ResourceStatisticsDto; import com.yeejoin.amos.boot.module.jcs.api.dto.ResourceStatisticsDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransfer; import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransfer;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferSimpleDto;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 力量调派 服务类 * 力量调派 服务类
......
...@@ -996,7 +996,10 @@ public class CommandController extends BaseController { ...@@ -996,7 +996,10 @@ public class CommandController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "app-更新车辆状态", notes = "app-更新车辆状态") @ApiOperation(httpMethod = "PUT", value = "app-更新车辆状态", notes = "app-更新车辆状态")
@PutMapping(value = "/app/carStatus") @PutMapping(value = "/app/carStatus")
public ResponseModel<Boolean> updateCarStatus(@RequestParam CarStatusInfoDto carStatusInfoDto) { public ResponseModel<Boolean> updateCarStatus(@RequestParam String carId, @RequestParam String carStatus) {
CarStatusInfoDto carStatusInfoDto = new CarStatusInfoDto();
carStatusInfoDto.setSequenceNbr(carId);
carStatusInfoDto.setStatus(carStatus);
try { try {
equipFeignClient.updateCarStatus(Lists.newArrayList(carStatusInfoDto)); equipFeignClient.updateCarStatus(Lists.newArrayList(carStatusInfoDto));
} catch (Exception e) { } catch (Exception e) {
...@@ -1028,7 +1031,6 @@ public class CommandController extends BaseController { ...@@ -1028,7 +1031,6 @@ public class CommandController extends BaseController {
public ResponseModel<Object> selectByAlertCalledId(@PathVariable Long id) { public ResponseModel<Object> selectByAlertCalledId(@PathVariable Long id) {
return ResponseHelper.buildResponse(iAlertCalledService.queryAlertCalledById(id)); return ResponseHelper.buildResponse(iAlertCalledService.queryAlertCalledById(id));
} }
/** /**
* app-根据id查询警情力量统计 * app-根据id查询警情力量统计
**/ **/
......
...@@ -379,4 +379,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -379,4 +379,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
return shiftIds; return shiftIds;
} }
@Override
public List<Long> getDutyShiftIdList() {
return getOnDuty(new DateTime());
}
} }
...@@ -6,11 +6,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -6,11 +6,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.module.common.api.dto.DutyShiftDto; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.common.api.dto.FireBrigadeResourceDto; import com.yeejoin.amos.boot.module.common.api.dto.FireBrigadeResourceDto;
import com.yeejoin.amos.boot.module.common.api.entity.FireTeam; import com.yeejoin.amos.boot.module.common.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient; import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyShiftServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyCarServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.dto.CarStatusInfoDto; import com.yeejoin.amos.boot.module.jcs.api.dto.CarStatusInfoDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCarCountDto; import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCarCountDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCompanyCountDto; import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCompanyCountDto;
...@@ -42,7 +42,6 @@ import org.springframework.stereotype.Service; ...@@ -42,7 +42,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -53,6 +52,7 @@ import java.util.ArrayList; ...@@ -53,6 +52,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -98,7 +98,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe ...@@ -98,7 +98,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
private String topic; private String topic;
@Autowired @Autowired
private DutyShiftServiceImpl dutyShiftServiceImpl; private DutyCarServiceImpl dutyCarService;
@Override @Override
public PowerTransferSimpleDto getPowerTransferList(Long alertCalledId) { public PowerTransferSimpleDto getPowerTransferList(Long alertCalledId) {
...@@ -464,51 +464,81 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe ...@@ -464,51 +464,81 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
IPage<PowerTransferResourceDto> carResourcePage = IPage<PowerTransferResourceDto> carResourcePage =
powerTransferMapper.getPowerTransferCarResource(new Page<>(1L, Long.MAX_VALUE), powerTransferMapper.getPowerTransferCarResource(new Page<>(1L, Long.MAX_VALUE),
alertCalledId); alertCalledId);
// 调派的车辆id // 调派的车辆id列表
List<Long> carIdList = Lists.transform(carResourcePage.getRecords(), PowerTransferResourceDto::getSequenceNbr); List<Long> carIdList = Lists.transform(carResourcePage.getRecords(), PowerTransferResourceDto::getSequenceNbr);
// 调派的车辆信息列表 // 调派的车辆信息列表
List<Map<String, Object>> totalCarList = List<Map<String, Object>> totalCarList =
carList.stream().filter(c -> carIdList.contains(c.get("id"))).collect(Collectors.toList()); carList.stream().filter(c -> carIdList.contains(Long.valueOf((String) c.get("id")))).collect(Collectors.toList());
// TODO 车辆枚举后期修改为已到达状态 // TODO 车辆枚举后期修改为已到达状态车辆
List<Map<String, Object>> arrivedCarList = List<Map<String, Object>> arrivedCarList =
carList.stream().filter(c -> carIdList.contains(c.get("id")) && FireCarStatusEnum.出动.getCode().equals(c.get( carList.stream().filter(c -> carIdList.contains(Long.valueOf((String) c.get("id"))) && FireCarStatusEnum.出动.getCode().equals(c.get(
"carState"))).collect(Collectors.toList()); "carState"))).collect(Collectors.toList());
// 车辆统计 // 调派-已到达车辆id列表
Long carTotal = carResourcePage.getTotal(); List<Long> arrivedCarIdList = Lists.newArrayList();
arrivedCarList.forEach(c -> {
if (FireCarStatusEnum.出动.getCode().equals(c.get("carState"))) {
arrivedCarIdList.add(Long.valueOf((String) c.get("id")));
}
});
JSONObject resourceStatistics = new JSONObject(); JSONObject resourceStatistics = new JSONObject();
Long carTotal = carResourcePage.getTotal();
// 车辆统计
carCount(arrivedCarList, resourceStatistics, carTotal, "car");
// 车辆人员统计
dutyPersonCount(carIdList, arrivedCarIdList, resourceStatistics);
// 车载器材统计
fireAgentOnCarCount(totalCarList, arrivedCarList, resourceStatistics, "equipment", "equip");
// TODO 车载水量统计
carCount(arrivedCarList, resourceStatistics, carTotal, "water");
// 车载药剂统计
fireAgentOnCarCount(totalCarList, arrivedCarList, resourceStatistics, "fireAgent", "medicament");
return resourceStatistics;
}
public void carCount(List<Map<String, Object>> arrivedCarList, JSONObject resourceStatistics, Long carTotal, String jsoKey) {
JSONObject car = new JSONObject(); JSONObject car = new JSONObject();
car.put("total", carTotal); car.put("total", carTotal);
car.put("count", arrivedCarList.size()); car.put("count", arrivedCarList.size());
car.put("percent", arrivedCarList.size() / carTotal); resourceStatistics.put(jsoKey, car);
resourceStatistics.put("car", car); }
// 车辆人员统计 public void dutyPersonCount(List<Long> carIdList, List<Long> arrivedCarIdList, JSONObject resourceStatistics) {
// 当前时间所在班次 // 当前时间所在班次
List<DutyShiftDto> dutyList = dutyShiftServiceImpl.queryForDutyShiftList(RequestContext.getAppKey(), false); List<Long> shiftIdList = dutyCarService.getDutyShiftIdList();
// 车辆值班 List<Map<String, Object>> allDutyPersonList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(shiftIdList)) {
allDutyPersonList = dutyCarService.dayDutyPersonList(DateUtils.getDateNowShortStr(),
shiftIdList.get(0), null);
}
// 当前车辆执勤人员
List<Map<String, Object>> allTransferDutyPerson =
allDutyPersonList.stream().filter(c -> carIdList.contains(Long.valueOf((String) c.get("carId")))).collect(Collectors.toList());
// 当前已到达车辆执勤人员
List<Map<String, Object>> allArrivedTransferDutyPerson =
allDutyPersonList.stream().filter(c -> arrivedCarIdList.contains(Long.valueOf((String) c.get("carId")))).collect(Collectors.toList());
JSONObject person = new JSONObject(); JSONObject person = new JSONObject();
person.put("total", carTotal); person.put("total", allTransferDutyPerson.size());
person.put("count", arrivedCarList.size()); person.put("count", allArrivedTransferDutyPerson.size());
person.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("person", person); resourceStatistics.put("person", person);
// TODO 车载器材统计 }
JSONObject equip = new JSONObject();
equip.put("total", carTotal); public void fireAgentOnCarCount(List<Map<String, Object>> totalCarList, List<Map<String, Object>> arrivedCarList,
equip.put("count", arrivedCarList.size()); JSONObject resourceStatistics, String equipType, String jsonKey) {
equip.put("percent", arrivedCarList.size() / carTotal); double agentCountAll = totalCarList.stream().mapToDouble(car -> ((List<Map<String, Object>>) car.get(
resourceStatistics.put("equip", equip); "resourceList")).stream().filter(res -> equipType.equals(res.get(
// TODO 车载水量统计 "equipType"))).mapToDouble(c -> (double) c.get("equipCount")).sum()).sum();
JSONObject water = new JSONObject(); double agentCountArrived = arrivedCarList.stream().mapToDouble(car -> ((List<Map<String, Object>>) car.get(
water.put("total", carTotal); "resourceList")).stream().filter(res -> equipType.equals(res.get(
water.put("count", arrivedCarList.size()); "equipType"))).mapToDouble(c -> (double) c.get("equipCount")).sum()).sum();
water.put("percent", arrivedCarList.size() / carTotal); JSONObject jsonObject = new JSONObject();
resourceStatistics.put("water", water); jsonObject.put("total", agentCountAll);
// TODO 车载药剂统计 jsonObject.put("count", agentCountArrived);
JSONObject medicament = new JSONObject(); resourceStatistics.put(jsonKey, jsonObject);
medicament.put("total", carTotal);
medicament.put("count", arrivedCarList.size());
medicament.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("medicament", medicament);
return resourceStatistics;
} }
} }
...@@ -163,11 +163,7 @@ ...@@ -163,11 +163,7 @@
</changeSet> </changeSet>
<changeSet author="litengwei" id="2021-09-01-litengwei-1"> <changeSet author="litengwei" id="2021-09-01-litengwei-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<tableExists tableName="cb_data_dictionary" /> <tableExists tableName="cb_data_dictionary" />
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions> </preConditions>
<comment>add data cb_data_dictionary</comment> <comment>add data cb_data_dictionary</comment>
<sql> <sql>
...@@ -190,11 +186,7 @@ ...@@ -190,11 +186,7 @@
</changeSet> </changeSet>
<changeSet author="litengwei" id="2021-09-01-litengwei-2"> <changeSet author="litengwei" id="2021-09-01-litengwei-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<tableExists tableName="jc_alert_form" /> <tableExists tableName="jc_alert_form" />
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions> </preConditions>
<comment>add data jc_alert_form</comment> <comment>add data jc_alert_form</comment>
<sql> <sql>
...@@ -206,11 +198,7 @@ ...@@ -206,11 +198,7 @@
</changeSet> </changeSet>
<changeSet author="litengwei" id="2021-09-01-litengwei-3"> <changeSet author="litengwei" id="2021-09-01-litengwei-3">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<tableExists tableName="jc_alert_form" /> <tableExists tableName="jc_alert_form" />
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions> </preConditions>
<comment>update data jc_alert_form</comment> <comment>update data jc_alert_form</comment>
<sql> <sql>
...@@ -282,7 +270,6 @@ ...@@ -282,7 +270,6 @@
<changeSet author="chenhao" id="2021-09-06-chenhao-1"> <changeSet author="chenhao" id="2021-09-06-chenhao-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<tableExists tableName="cb_data_dictionary" /> <tableExists tableName="cb_data_dictionary" />
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions> </preConditions>
<comment>insert data cb_data_dictionary</comment> <comment>insert data cb_data_dictionary</comment>
<sql> <sql>
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<!-- 日志输出级别 --> <!-- 日志输出级别 -->
<root level="INFO"> <root level="INFO">
<!--<appender-ref ref="FILE" />--> <appender-ref ref="FILE" />
<appender-ref ref="STDOUT" /> <appender-ref ref="STDOUT" />
</root> </root>
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<!-- 日志输出级别 --> <!-- 日志输出级别 -->
<root level="DEBUG"> <root level="DEBUG">
<!--<appender-ref ref="FILE" /> --> <appender-ref ref="FILE" />
<appender-ref ref="STDOUT" /> <appender-ref ref="STDOUT" />
</root> </root>
</configuration> </configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment