glj-代码提交

This commit is contained in:
glj 2023-11-17 17:18:28 +08:00
parent e75f984007
commit 3832d2d547
7 changed files with 68 additions and 4 deletions

View File

@ -142,6 +142,18 @@ public class EntityData implements Serializable {
@TableField(exist = false)
private String geometry;
/**
* 受灾地区
*/
@TableField(exist = false)
private String disasterCountry;
/**
* 受灾类型
*/
@TableField(exist = false)
private String disasterType;
@TableField(exist = false)
private static final long serialVersionUID = 1L;

View File

@ -232,6 +232,7 @@ public class RemoteSensingSourceData implements Serializable {
//结束时间
@TableField(exist = false)
private String endTime;
//标志灾前灾后字段 0-灾前1-灾后
@TableField(exist = false)
private Integer beforeOrAfter =1;

View File

@ -82,5 +82,15 @@ public class EntityDataController {
public R getStatisticsByUserId(Long id, String year) {
return R.data(entityDataService.getStatisticsByUserId(id, year));
}
/**
* 饼状图统计
* @param id
* @return
*/
@GetMapping("/getStatisticsByUserIdPancake")
public R getStatisticsByUserIdPancake(Long id) {
return R.data(entityDataService.getStatisticsByUserIdPancake(id));
}
}

View File

@ -25,4 +25,6 @@ public interface EntityDataMapper extends BaseMapper<EntityData> {
List<UserTenantVo> getEntityDataSourceOrganization(@Param("disasterId") Long disasterId);
List<Map<String, Long>> getStatisticsByUserId(@Param("id") Long id,@Param("year") String year);
List<EntityData> getStatisticsByUserIdPancake(@Param("id") Long id);
}

View File

@ -245,4 +245,17 @@
GROUP BY d.`key`
ORDER BY d.`key`
</select>
<select id="getStatisticsByUserIdPancake" resultType="com.kening.vordm.entity.EntityData">
select ed.id, ed.title, ed.disaster_id, ed.uploader_id, di.disaster_country AS disasterCountry, bdb.dict_value AS disasterType
FROM entity_data ed
LEFT JOIN disaster_info di on di.id = ed.disaster_id
LEFT JOIN blade_dict_biz bdb ON bdb.dict_key = di.disaster_type and bdb.code = 'disaster'
<where>
di.disaster_country IS NOT NUll
<if test="id != null and id != ''">
and ed.uploader_id = #{id}
</if>
</where>
</select>
</mapper>

View File

@ -38,4 +38,6 @@ public interface EntityDataService extends IService<EntityData> {
* @return
*/
List<Map<String, Long>> getStatisticsByUserId(Long id, String year);
Map<String, Object> getStatisticsByUserIdPancake(Long id);
}

View File

@ -29,10 +29,8 @@ import org.springframework.web.multipart.MultipartFile;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author G1393
@ -153,4 +151,30 @@ public class EntityDataServiceImpl extends ServiceImpl<EntityDataMapper, EntityD
return baseMapper.getStatisticsByUserId(id, year);
}
@Override
public Map<String, Object> getStatisticsByUserIdPancake(Long id) {
List<EntityData> entityDataList = baseMapper.getStatisticsByUserIdPancake(id);
Map<String, List<EntityData>> collectDisasterCountry = entityDataList.stream().collect(Collectors.groupingBy(EntityData::getDisasterCountry));
Map<String, List<EntityData>> collectDisasterType = entityDataList.stream().collect(Collectors.groupingBy(EntityData::getDisasterType));
List<Map<String, Object>> disasterCountryList = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
for(String mapKey : collectDisasterCountry.keySet()){
List<EntityData> entityData = collectDisasterCountry.get(mapKey);
map.put(mapKey,entityData.size());
disasterCountryList.add(map);
}
List<Map<String, Object>> disasterTypeList = new ArrayList<>();
Map<String, Object> map2 = new HashMap<>();
for(String mapKey : collectDisasterType.keySet()){
List<EntityData> entityData = collectDisasterType.get(mapKey);
map2.put(mapKey,entityData.size());
disasterTypeList.add(map2);
}
Map<String, Object> map3 = new HashMap<>();
map3.put("DisasterCountry",disasterCountryList);
map3.put("DisasterType",disasterTypeList);
return map3;
}
}