Commit bed2a8ee authored by tangwei's avatar tangwei

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents e5abb305 bb09a3c3
......@@ -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();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat formatter = new SimpleDateFormat(DATE_PATTERN);
String dateString = formatter.format(currentTime);
return dateString;
}
......
......@@ -30,11 +30,25 @@ public class FormValue implements Serializable{
private String value;
@ApiModelProperty(value = "是否一行显示")
private boolean block;
@ApiModelProperty(value = "value 所对应的字符名称")
private String valueName;
public FormValue() {
}
public FormValue(String key, String label, String type, String value,boolean block,String valueName) {
super();
this.key = key;
this.label = label;
this.type = type;
this.value = value;
this.block = block;
this.valueName =valueName;
}
public FormValue(String key, String label, String type, String value,boolean block) {
super();
this.key = key;
......
......@@ -79,4 +79,11 @@ public interface IDutyCommonService {
* @return List<Map < String, Object>>
*/
List<Map<String, Object>> listOnDutyPerson();
/**
* 根据当前时间获取值班班次id列表
*
* @return
*/
List<Long> getDutyShiftIdList();
}
......@@ -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.PowerTransferDto;
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.entity.PowerTransfer;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferSimpleDto;
import java.util.List;
import java.util.Map;
/**
* 力量调派 服务类
......
......@@ -1063,7 +1063,10 @@ public class CommandController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "app-更新车辆状态", notes = "app-更新车辆状态")
@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 {
equipFeignClient.updateCarStatus(Lists.newArrayList(carStatusInfoDto));
} catch (Exception e) {
......@@ -1095,7 +1098,6 @@ public class CommandController extends BaseController {
public ResponseModel<Object> selectByAlertCalledId(@PathVariable Long id) {
return ResponseHelper.buildResponse(iAlertCalledService.queryAlertCalledById(id));
}
/**
* app-根据id查询警情力量统计
**/
......
......@@ -379,4 +379,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
return shiftIds;
}
@Override
public List<Long> getDutyShiftIdList() {
return getOnDuty(new DateTime());
}
}
......@@ -365,15 +365,17 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
List<DynamicFormInstanceDto> list = alertFormValueServiceImpl.listByCalledId(id);
List<FormValue> formValue = new ArrayList<>();
for (DynamicFormInstanceDto alertFormValue : list) {
if (alertFormValue.getFieldValueLabel() != null) {
/*修改为动态表单返回的数据参数量 2021-09-08 陈浩 开始 */
// if (alertFormValue.getFieldValueLabel() != null) {
// FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(),
// alertFormValue.getFieldType(), alertFormValue.getFieldValueLabel(), alertFormValue.getBlock());
// formValue.add(value);
// } else {
/*修改为动态表单返回的数据参数量 2021-09-08 陈浩 结束 */
FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(),
alertFormValue.getFieldType(), alertFormValue.getFieldValueLabel(), alertFormValue.getBlock());
alertFormValue.getFieldType(), alertFormValue.getFieldValue(), alertFormValue.getBlock(),alertFormValue.getFieldValueLabel());
formValue.add(value);
} else {
FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(),
alertFormValue.getFieldType(), alertFormValue.getFieldValue(), alertFormValue.getBlock());
formValue.add(value);
}
// }
}
return formValue;
/*BUG2580 返回值为code值 修改为类型名称 2021-08-31 陈召 结束 */
......@@ -385,7 +387,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
List<FormValue> formValue = new ArrayList<>();
for (DynamicFormInstanceDto alertFormValue : list) {
FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(),
alertFormValue.getFieldType(), alertFormValue.getFieldValue(), alertFormValue.getBlock());
alertFormValue.getFieldType(), alertFormValue.getFieldValue(), alertFormValue.getBlock(),alertFormValue.getFieldValueLabel());//陈浩 添加getFieldValueLabel的属性值 2021-09-08
formValue.add(value);
}
return formValue;
......
......@@ -6,11 +6,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
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.entity.FireTeam;
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.PowerCarCountDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCompanyCountDto;
......@@ -42,7 +42,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
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.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
......@@ -53,6 +52,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -98,7 +98,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
private String topic;
@Autowired
private DutyShiftServiceImpl dutyShiftServiceImpl;
private DutyCarServiceImpl dutyCarService;
@Override
public PowerTransferSimpleDto getPowerTransferList(Long alertCalledId) {
......@@ -464,51 +464,81 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
IPage<PowerTransferResourceDto> carResourcePage =
powerTransferMapper.getPowerTransferCarResource(new Page<>(1L, Long.MAX_VALUE),
alertCalledId);
// 调派的车辆id
// 调派的车辆id列表
List<Long> carIdList = Lists.transform(carResourcePage.getRecords(), PowerTransferResourceDto::getSequenceNbr);
// 调派的车辆信息列表
List<Map<String, Object>> totalCarList =
carList.stream().filter(c -> carIdList.contains(c.get("id"))).collect(Collectors.toList());
// TODO 车辆枚举后期修改为已到达状态
carList.stream().filter(c -> carIdList.contains(Long.valueOf((String) c.get("id")))).collect(Collectors.toList());
// TODO 车辆枚举后期修改为已到达状态车辆
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());
// 车辆统计
Long carTotal = carResourcePage.getTotal();
// 调派-已到达车辆id列表
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();
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();
car.put("total", carTotal);
car.put("count", arrivedCarList.size());
car.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("car", car);
resourceStatistics.put(jsoKey, 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();
person.put("total", carTotal);
person.put("count", arrivedCarList.size());
person.put("percent", arrivedCarList.size() / carTotal);
person.put("total", allTransferDutyPerson.size());
person.put("count", allArrivedTransferDutyPerson.size());
resourceStatistics.put("person", person);
// TODO 车载器材统计
JSONObject equip = new JSONObject();
equip.put("total", carTotal);
equip.put("count", arrivedCarList.size());
equip.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("equip", equip);
// TODO 车载水量统计
JSONObject water = new JSONObject();
water.put("total", carTotal);
water.put("count", arrivedCarList.size());
water.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("water", water);
// TODO 车载药剂统计
JSONObject medicament = new JSONObject();
medicament.put("total", carTotal);
medicament.put("count", arrivedCarList.size());
medicament.put("percent", arrivedCarList.size() / carTotal);
resourceStatistics.put("medicament", medicament);
return resourceStatistics;
}
public void fireAgentOnCarCount(List<Map<String, Object>> totalCarList, List<Map<String, Object>> arrivedCarList,
JSONObject resourceStatistics, String equipType, String jsonKey) {
double agentCountAll = totalCarList.stream().mapToDouble(car -> ((List<Map<String, Object>>) car.get(
"resourceList")).stream().filter(res -> equipType.equals(res.get(
"equipType"))).mapToDouble(c -> (double) c.get("equipCount")).sum()).sum();
double agentCountArrived = arrivedCarList.stream().mapToDouble(car -> ((List<Map<String, Object>>) car.get(
"resourceList")).stream().filter(res -> equipType.equals(res.get(
"equipType"))).mapToDouble(c -> (double) c.get("equipCount")).sum()).sum();
JSONObject jsonObject = new JSONObject();
jsonObject.put("total", agentCountAll);
jsonObject.put("count", agentCountArrived);
resourceStatistics.put(jsonKey, jsonObject);
}
}
......@@ -163,11 +163,7 @@
</changeSet>
<changeSet author="litengwei" id="2021-09-01-litengwei-1">
<preConditions onFail="MARK_RAN">
<tableExists tableName="cb_data_dictionary" />
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions>
<comment>add data cb_data_dictionary</comment>
<sql>
......@@ -190,11 +186,7 @@
</changeSet>
<changeSet author="litengwei" id="2021-09-01-litengwei-2">
<preConditions onFail="MARK_RAN">
<tableExists tableName="jc_alert_form" />
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions>
<comment>add data jc_alert_form</comment>
<sql>
......@@ -206,11 +198,7 @@
</changeSet>
<changeSet author="litengwei" id="2021-09-01-litengwei-3">
<preConditions onFail="MARK_RAN">
<tableExists tableName="jc_alert_form" />
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions>
<comment>update data jc_alert_form</comment>
<sql>
......@@ -282,7 +270,6 @@
<changeSet author="chenhao" id="2021-09-06-chenhao-1">
<preConditions onFail="MARK_RAN">
<tableExists tableName="cb_data_dictionary" />
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions>
<comment>insert data cb_data_dictionary</comment>
<sql>
......
......@@ -42,7 +42,7 @@
<!-- 日志输出级别 -->
<root level="INFO">
<!--<appender-ref ref="FILE" />-->
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
......
......@@ -46,7 +46,7 @@
<!-- 日志输出级别 -->
<root level="DEBUG">
<!--<appender-ref ref="FILE" /> -->
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</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