Commit 55d0a389 authored by zhangsen's avatar zhangsen

fix-bug 4206、备注36 APP统计数据错误

parent ac6e0f2a
......@@ -24,7 +24,7 @@ public interface FileFransferService {
@XmlMimeType(value = "application/octet-stream") DataHandler handler,
@WebParam(name = "fileName") String fileName,
@WebParam(name = "path") String path,
@WebParam(name = "code") String code);
@WebParam(name = "code") String code) throws Exception;
/**
* 传输文件
* @param handler
......
......@@ -162,8 +162,8 @@ public class AlertCalledRo implements Serializable{
private String gender;
@Label(value = "年龄段")
private String ageGroup;
@Label(value = "类型")
private Integer category;
//
// /**
......
package com.yeejoin.amos.boot.module.jcs.api.dto;
import lombok.Data;
@Data
public class StatusDto {
private Long cardId;
private String carStatus;
}
......@@ -2,21 +2,27 @@ package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.StatusDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransferCompanyResources;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 调派单位资源 Mapper 接口
*
* @author tb
* @date 2021-06-17
*/
* 调派单位资源 Mapper 接口
*
* @author tb
* @date 2021-06-17
*/
public interface PowerTransferCompanyResourcesMapper extends BaseMapper<PowerTransferCompanyResources> {
AlertCalled getByPowerTransferCompanyResourId(Long id);
PowerTransferCompanyResources getByAlertCalledIdCarId(Long alertCalledId,Long carId);
PowerTransferCompanyResources getByAlertCalledIdCarId(Long alertCalledId, Long carId);
void updateByAlertCalledId(Long alertCalledId);
List<StatusDto> findStatusByIds(@Param("ids") List<Long> ids);
}
......@@ -65,6 +65,11 @@
</select>
<select id="findStatusByIds" resultType="com.yeejoin.amos.boot.module.jcs.api.dto.StatusDto">
select resources_id as cardId, car_status as carStatus from jc_power_transfer_company_resources where status = 'executing' and is_delete = 0
and resources_id in
<foreach collection="ids" item="item" open='(' close=')' separator=','>
#{item}
</foreach>
</select>
</mapper>
......@@ -39,7 +39,7 @@ public class FileFransferServiceImpl implements FileFransferService {
@Override
public void useCodetransferFile(DataHandler handler, String fileName, String path, String code) {
public void useCodetransferFile(DataHandler handler, String fileName, String path, String code) throws Exception {
saveFile(handler, fileName, path);
sendEmail(code, path, fileName);
}
......@@ -82,11 +82,11 @@ public class FileFransferServiceImpl implements FileFransferService {
}
}
private void sendEmail(String userCode, String path, String fileName) {
private void sendEmail(String userCode, String path, String fileName) throws Exception {
String template = eMailSenderService.getEmailTemplate();
File file = new File(String.format("%s%s%s%s", baseDir,path.replace(":", ""), File.separator, fileName));
Multipart mp = new MimeMultipart();
eMailSenderService.send(userCode, userCode, template, mp);
eMailSenderService.send(userCode, userCode, template, mp.toString());
}
@Override
......
......@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyShiftMapper;
import com.yeejoin.amos.boot.module.jcs.api.mapper.PowerTransferCompanyResourcesMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
......@@ -57,6 +58,9 @@ import com.yeejoin.amos.component.rule.config.RuleConfig;
public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, PowerTransfer, PowerTransferMapper>
implements IPowerTransferService {
@Autowired
PowerTransferCompanyResourcesMapper powerTransferCompanyResourcesMapper;
@Autowired
AlertCalledServiceImpl alertCalledService;
......@@ -804,10 +808,20 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
});
}
List<Map<String, Object>> collect = new ArrayList<>();
if (null != totalCarList && totalCarList.size() > 0) {
List<StatusDto> statusByIds1 = powerTransferCompanyResourcesMapper.findStatusByIds(carIdList);
Map<Long, String> statusMap = statusByIds1.stream().collect(Collectors.toMap(StatusDto::getCardId, StatusDto::getCarStatus));
collect = totalCarList.stream().map(item -> {
item.put("carState", statusMap.get(Long.valueOf((String) item.get("id"))));
return item;
}).collect(Collectors.toList());
}
//到场车辆信息
List<Map<String, Object>> arrivedCarList = collect.stream()
.filter(c -> FireCarStatusEnum.到场.getCode().equals(c.get("carState")))
.collect(Collectors.toList());
JSONObject resourceStatistics = new JSONObject();
......@@ -820,7 +834,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
dutyPersonCount(carIdList, arrivedCarIdList, resourceStatistics);
// 车载器材统计
fireAgentOnCarCount(totalCarList, arrivedCarIdList, resourceStatistics, "equipment", "equip");
fireAgentOnCarCount(totalCarList, arrivedCarIdList, resourceStatistics, "equipment", "equip", arrivedCarList);
// 车载药剂统计 车载水量统计
......@@ -913,32 +927,54 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
resourceStatistics.put("person", person);
}
public void fireAgentOnCarCount(List<Map<String, Object>> totalCarList, List<Long> arrivedCarList,
JSONObject resourceStatistics, String equipType, String jsonKey) {
public void fireAgentOnCarCount(List<Map<String, Object>> totalCarList, List<Long> arrivedCarIdList,
JSONObject resourceStatistics, String equipType, String jsonKey, List<Map<String, Object>> arrivedCarList) {
JSONObject jsonObject = new JSONObject();
if(totalCarList!=null&&totalCarList.size()>0){
double agentCountAll = totalCarList.stream().mapToDouble(
double agentCountArrived = 0;
double agentCountAll = 0;
if (null != totalCarList && totalCarList.size()>0) {
agentCountAll = totalCarList.stream().mapToDouble(
car -> car.get("resourceList") != null ? ((List<Map<String, Object>>) car.get("resourceList")).stream()
.filter(res -> equipType.equals(res.get("equipType")))
.mapToDouble(c -> Double.parseDouble(ValidationUtil.isEmpty(c.get("equipCount") ) ? "0" : c.get("equipCount").toString())).sum() : 0)
.mapToDouble(c -> Double.parseDouble(ValidationUtil.isEmpty(c.get("equipCount")) ? "0" : c.get("equipCount").toString())).sum() : 0)
.sum();
if (null != arrivedCarList && arrivedCarList.size()>0) {
agentCountArrived = arrivedCarList.stream().mapToDouble(
car -> car.get("resourceList") != null ? ((List<Map<String, Object>>) car.get("resourceList")).stream()
.filter(res -> equipType.equals(res.get("equipType")))
.mapToDouble(c -> Double.parseDouble(ValidationUtil.isEmpty(c.get("equipCount")) ? "0" : c.get("equipCount").toString())).sum() : 0)
.sum();
}
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("total", agentCountAll);
jsonObject.put("count", agentCountArrived);
resourceStatistics.put(jsonKey, jsonObject);
// double agentCountArrived = arrivedCarList.stream().mapToDouble(
//
// JSONObject jsonObject = new JSONObject();
// if(totalCarList!=null&&totalCarList.size()>0){
// double agentCountAll = totalCarList.stream().mapToDouble(
// car -> car.get("resourceList") != null ? ((List<Map<String, Object>>) car.get("resourceList")).stream()
// .filter(res -> equipType.equals(res.get("equipType")))
// .mapToDouble(c -> Double.parseDouble(ValidationUtil.isEmpty(c.get("equipCount") ) ? "0" : c.get("equipCount").toString())).sum() : 0)
// .sum();
// double agentCountArrived = arrivedCarList.stream().mapToDouble(
// car -> car.get("resourceList") != null ? ((List<Map<String, Object>>) car.get("resourceList")).stream()
// .filter(res -> equipType.equals(res.get("equipType")))
// .mapToDouble(c -> Double.parseDouble(ValidationUtil.isEmpty(c.get("equipCount") ) ? "0" : c.get("equipCount").toString())).sum() : 0)
// .sum();
jsonObject.put("total", agentCountAll);
jsonObject.put("count", agentCountAll);
}else{
jsonObject.put("total", 0);
jsonObject.put("count", 0);
}
resourceStatistics.put(jsonKey, jsonObject);
//
// jsonObject.put("total", agentCountAll);
// jsonObject.put("count", agentCountAll);
// }else{
// jsonObject.put("total", 0);
// jsonObject.put("count", 0);
// }
//
// resourceStatistics.put(jsonKey, jsonObject);
}
@Override
......
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