Commit 55d0a389 authored by zhangsen's avatar zhangsen

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

parent ac6e0f2a
...@@ -24,7 +24,7 @@ public interface FileFransferService { ...@@ -24,7 +24,7 @@ public interface FileFransferService {
@XmlMimeType(value = "application/octet-stream") DataHandler handler, @XmlMimeType(value = "application/octet-stream") DataHandler handler,
@WebParam(name = "fileName") String fileName, @WebParam(name = "fileName") String fileName,
@WebParam(name = "path") String path, @WebParam(name = "path") String path,
@WebParam(name = "code") String code); @WebParam(name = "code") String code) throws Exception;
/** /**
* 传输文件 * 传输文件
* @param handler * @param handler
......
...@@ -162,8 +162,8 @@ public class AlertCalledRo implements Serializable{ ...@@ -162,8 +162,8 @@ public class AlertCalledRo implements Serializable{
private String gender; private String gender;
@Label(value = "年龄段") @Label(value = "年龄段")
private String ageGroup; 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; ...@@ -2,21 +2,27 @@ package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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.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.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransferCompanyResources; import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransferCompanyResources;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
/** /**
* 调派单位资源 Mapper 接口 * 调派单位资源 Mapper 接口
* *
* @author tb * @author tb
* @date 2021-06-17 * @date 2021-06-17
*/ */
public interface PowerTransferCompanyResourcesMapper extends BaseMapper<PowerTransferCompanyResources> { public interface PowerTransferCompanyResourcesMapper extends BaseMapper<PowerTransferCompanyResources> {
AlertCalled getByPowerTransferCompanyResourId(Long id); AlertCalled getByPowerTransferCompanyResourId(Long id);
PowerTransferCompanyResources getByAlertCalledIdCarId(Long alertCalledId,Long carId); PowerTransferCompanyResources getByAlertCalledIdCarId(Long alertCalledId, Long carId);
void updateByAlertCalledId(Long alertCalledId); void updateByAlertCalledId(Long alertCalledId);
List<StatusDto> findStatusByIds(@Param("ids") List<Long> ids);
} }
...@@ -65,6 +65,11 @@ ...@@ -65,6 +65,11 @@
</select> </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> </mapper>
...@@ -39,7 +39,7 @@ public class FileFransferServiceImpl implements FileFransferService { ...@@ -39,7 +39,7 @@ public class FileFransferServiceImpl implements FileFransferService {
@Override @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); saveFile(handler, fileName, path);
sendEmail(code, path, fileName); sendEmail(code, path, fileName);
} }
...@@ -82,11 +82,11 @@ public class FileFransferServiceImpl implements FileFransferService { ...@@ -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(); String template = eMailSenderService.getEmailTemplate();
File file = new File(String.format("%s%s%s%s", baseDir,path.replace(":", ""), File.separator, fileName)); File file = new File(String.format("%s%s%s%s", baseDir,path.replace(":", ""), File.separator, fileName));
Multipart mp = new MimeMultipart(); Multipart mp = new MimeMultipart();
eMailSenderService.send(userCode, userCode, template, mp); eMailSenderService.send(userCode, userCode, template, mp.toString());
} }
@Override @Override
......
...@@ -7,6 +7,7 @@ import java.util.stream.Collectors; ...@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; 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.DutyPersonShiftMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyShiftMapper; 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.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
...@@ -57,6 +58,9 @@ import com.yeejoin.amos.component.rule.config.RuleConfig; ...@@ -57,6 +58,9 @@ import com.yeejoin.amos.component.rule.config.RuleConfig;
public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, PowerTransfer, PowerTransferMapper> public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, PowerTransfer, PowerTransferMapper>
implements IPowerTransferService { implements IPowerTransferService {
@Autowired
PowerTransferCompanyResourcesMapper powerTransferCompanyResourcesMapper;
@Autowired @Autowired
AlertCalledServiceImpl alertCalledService; AlertCalledServiceImpl alertCalledService;
...@@ -804,10 +808,20 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe ...@@ -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(); JSONObject resourceStatistics = new JSONObject();
...@@ -820,7 +834,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe ...@@ -820,7 +834,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
dutyPersonCount(carIdList, arrivedCarIdList, resourceStatistics); 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 ...@@ -913,32 +927,54 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
resourceStatistics.put("person", person); resourceStatistics.put("person", person);
} }
public void fireAgentOnCarCount(List<Map<String, Object>> totalCarList, List<Long> arrivedCarList, public void fireAgentOnCarCount(List<Map<String, Object>> totalCarList, List<Long> arrivedCarIdList,
JSONObject resourceStatistics, String equipType, String jsonKey) { JSONObject resourceStatistics, String equipType, String jsonKey, List<Map<String, Object>> arrivedCarList) {
JSONObject jsonObject = new JSONObject(); double agentCountArrived = 0;
if(totalCarList!=null&&totalCarList.size()>0){ double agentCountAll = 0;
double agentCountAll = totalCarList.stream().mapToDouble( 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)
.sum();
if (null != arrivedCarList && arrivedCarList.size()>0) {
agentCountArrived = arrivedCarList.stream().mapToDouble(
car -> car.get("resourceList") != null ? ((List<Map<String, Object>>) car.get("resourceList")).stream() car -> car.get("resourceList") != null ? ((List<Map<String, Object>>) car.get("resourceList")).stream()
.filter(res -> equipType.equals(res.get("equipType"))) .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(); .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() // car -> car.get("resourceList") != null ? ((List<Map<String, Object>>) car.get("resourceList")).stream()
// .filter(res -> equipType.equals(res.get("equipType"))) // .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(); // .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); // jsonObject.put("total", agentCountAll);
}else{ // jsonObject.put("count", agentCountAll);
jsonObject.put("total", 0); // }else{
jsonObject.put("count", 0); // jsonObject.put("total", 0);
} // jsonObject.put("count", 0);
// }
resourceStatistics.put(jsonKey, jsonObject); //
// resourceStatistics.put(jsonKey, jsonObject);
} }
@Override @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