170 lines
6.5 KiB
Java
170 lines
6.5 KiB
Java
package com.hivekion.statistic.service.impl;
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.hivekion.baseData.entity.Fightpowerstaff;
|
|
import com.hivekion.baseData.entity.OrgSupplier;
|
|
import com.hivekion.baseData.service.FightpowerstaffService;
|
|
import com.hivekion.baseData.service.OrgSupplierService;
|
|
import com.hivekion.scenario.bean.BattleSuppleVo;
|
|
import com.hivekion.scenario.entity.BattleSupplier;
|
|
import com.hivekion.scenario.entity.ScenarioOrgPost;
|
|
import com.hivekion.scenario.entity.ScenarioResource;
|
|
import com.hivekion.scenario.service.IBattleSupplierService;
|
|
import com.hivekion.scenario.service.IScenarioOrgPostService;
|
|
import com.hivekion.scenario.service.ScenarioResourceService;
|
|
import com.hivekion.statistic.bean.StatisticBean;
|
|
import com.hivekion.statistic.service.StatisticService;
|
|
import com.hivekion.supplier.entity.SuppliesDict;
|
|
import com.hivekion.supplier.service.SuppliesDictService;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import javax.annotation.Resource;
|
|
|
|
import com.hivekion.team.entity.Teaminfo;
|
|
import com.hivekion.team.service.ITeaminfoService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
/**
|
|
* [类的简要说明]
|
|
* <p>
|
|
* [详细描述,可选]
|
|
* <p>
|
|
*
|
|
* @author LiDongYU
|
|
* @since 2025/7/22
|
|
*/
|
|
@Service
|
|
@Slf4j
|
|
public class StatisticServiceImpl implements StatisticService {
|
|
|
|
@Resource
|
|
private ScenarioResourceService scenarioResourceService;
|
|
@Resource
|
|
private OrgSupplierService orgSupplierService;
|
|
@Resource
|
|
private SuppliesDictService suppliesDictService;
|
|
@Resource
|
|
private IScenarioOrgPostService scenarioOrgPostService;
|
|
@Resource
|
|
private FightpowerstaffService fightpowerstaffService;
|
|
|
|
@Resource
|
|
private IBattleSupplierService battleSupplierService;
|
|
|
|
@Resource
|
|
private ITeaminfoService teamInfoService;
|
|
|
|
@Resource
|
|
private ScenarioResourceService resourceService;
|
|
|
|
|
|
@Override
|
|
public StatisticBean statistic(String resourceId) {
|
|
StatisticBean statisticBean = new StatisticBean();
|
|
//获取分队信息
|
|
ScenarioResource resourceInstance = scenarioResourceService.getById(resourceId);
|
|
if(resourceInstance == null){
|
|
log.info("==========================");
|
|
return statisticBean;
|
|
}
|
|
Map<Integer, Teaminfo> map = teamInfoService.teamInfoMap();
|
|
Map<String, ScenarioResource> resourceMap = resourceService.resourceMap();
|
|
List<BattleSupplier> battleSuppliers = battleSupplierService.list(new QueryWrapper<BattleSupplier>()
|
|
.eq("BATTLE_RESOURCE_ID",resourceId).or().eq("SUPPLIER_RESOURCE_ID",resourceId));
|
|
if(CollectionUtil.isEmpty(battleSuppliers)) {
|
|
battleSuppliers = new ArrayList<>();
|
|
}
|
|
List<BattleSuppleVo> qryList = new ArrayList<>();
|
|
battleSuppliers.stream().forEach(battleSupplier -> {
|
|
BattleSuppleVo battleSuppleVo = new BattleSuppleVo();
|
|
BeanUtil.copyProperties(battleSupplier,battleSuppleVo);
|
|
if (resourceMap.get(battleSupplier.getBattleResourceId()) != null) {
|
|
ScenarioResource resource = resourceMap.get(battleSupplier.getBattleResourceId());
|
|
if (map.get(resource.getResourceId()) != null) {
|
|
battleSuppleVo.setBattleResourceName(map.get(resource.getResourceId()).getName());
|
|
}
|
|
}
|
|
if (resourceMap.get(battleSupplier.getSupplierResourceId()) != null) {
|
|
ScenarioResource resource = resourceMap.get(battleSupplier.getSupplierResourceId());
|
|
if (map.get(resource.getResourceId()) != null) {
|
|
battleSuppleVo.setSupplierResourceName(map.get(resource.getResourceId()).getName());
|
|
}
|
|
}
|
|
qryList.add(battleSuppleVo);
|
|
});
|
|
|
|
statisticBean.setBattleSuppliers(qryList);
|
|
statisticBean.getTeam().setType(resourceInstance.getType());
|
|
statisticBean.getTeam().setLat(resourceInstance.getLat());
|
|
statisticBean.getTeam().setLng(resourceInstance.getLng());
|
|
statisticBean.getTeam().setTeamName(resourceInstance.getResourceName());
|
|
//获取关联的组织机构信息
|
|
ScenarioOrgPost post = new ScenarioOrgPost();
|
|
post.setResourceId(resourceId);
|
|
List<ScenarioOrgPost> orgPostList = scenarioOrgPostService.selectByCondition(post);
|
|
List<Integer> orgList = orgPostList.stream().map(ScenarioOrgPost::getOrgId)
|
|
.collect(Collectors.toList());
|
|
if(CollectionUtil.isEmpty(orgList)){
|
|
return statisticBean;
|
|
}
|
|
//获取人员信息
|
|
if(!orgList.isEmpty()){
|
|
List<Fightpowerstaff> staffList = fightpowerstaffService.queryByOrgIds(orgList);
|
|
int sum = staffList.stream()
|
|
.mapToInt(Fightpowerstaff::getNumber)
|
|
.sum();
|
|
statisticBean.getPerson().setCurrent(sum);
|
|
statisticBean.getPerson().setTotal(sum);
|
|
}else{
|
|
return statisticBean;
|
|
}
|
|
|
|
//获取物资信息
|
|
List<OrgSupplier> suppliers = orgSupplierService.selectByOrgIds(orgList);
|
|
|
|
Map<String, SuppliesDict> supplierMap = suppliesDictService.supplierDictMap();
|
|
|
|
suppliers.forEach(supplier -> {
|
|
|
|
SuppliesDict dict = supplierMap.get(supplier.getSupplierId());
|
|
|
|
if (dict != null) {
|
|
switch (dict.getCode()) {
|
|
case "FOOD":
|
|
statisticBean.getFood().setTotal(statisticBean.getFood().getTotal()+supplier.getAccount());
|
|
statisticBean.getFood().setCurrent(statisticBean.getFood().getCurrent()+supplier.getAccount());
|
|
break;
|
|
case "WATER":
|
|
statisticBean.getWater().setTotal(statisticBean.getWater().getTotal()+supplier.getAccount());
|
|
statisticBean.getWater().setCurrent(statisticBean.getWater().getCurrent()+supplier.getAccount());
|
|
break;
|
|
case "FUEL":
|
|
statisticBean.getFuel().setTotal(statisticBean.getFuel().getTotal()+supplier.getAccount());
|
|
statisticBean.getFuel().setCurrent(statisticBean.getFuel().getCurrent()+supplier.getAccount());
|
|
break;
|
|
case "MEDICAL":
|
|
statisticBean.getMedical().setTotal( statisticBean.getMedical().getTotal()+supplier.getAccount());
|
|
statisticBean.getMedical().setCurrent( statisticBean.getMedical().getCurrent()+supplier.getAccount());
|
|
break;
|
|
|
|
case "AMMUNITION":
|
|
statisticBean.getAmmunition().setTotal( statisticBean.getAmmunition().getTotal()+supplier.getAccount());
|
|
statisticBean.getAmmunition().setCurrent(statisticBean.getAmmunition().getCurrent()+supplier.getAccount());
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
return statisticBean;
|
|
}
|
|
|
|
}
|