| | |
| | | import cn.cetc54.platform.zhyl.service.ISubsidyLogService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | @Slf4j |
| | | @RestController |
| | | @Api(description = "补贴页面接口") |
| | | @RequestMapping("/api/subsidy") |
| | | @RequestMapping("/api2/subsidy") |
| | | @CrossOrigin("*") |
| | | public class SubsidyAPIController { |
| | | @Autowired |
| | | private ISubsidyLogService iSubsidyLogService; |
| | |
| | | @ApiOperation(value = "年度月度统计数据") |
| | | public Result getStatistics(String areaId,Integer type){ |
| | | Map<String,Object> resMap = new HashMap<>(); |
| | | resMap.put("monthStatistics",iSubsidyLogService.getMonthTotal(areaId,type)); |
| | | resMap.put("yearStatistics",iSubsidyLogService.getYearTotal(areaId,type)); |
| | | List<Map<String,Object>> monthList = iSubsidyLogService.getMonthTotal(areaId,type); |
| | | List<Map<String,Object>> yearList = iSubsidyLogService.getYearTotal(areaId,type); |
| | | |
| | | List<String> month = new ArrayList<>(); |
| | | List<Double> mSum = new ArrayList<>(); |
| | | monthList.forEach(e->{ |
| | | String d = (String) e.get("time"); |
| | | double s = (double) e.get("sum"); |
| | | month.add(0,d.split("-")[1]); |
| | | mSum.add(0,s); |
| | | }); |
| | | StatisticsVo mS = new StatisticsVo(); |
| | | mS.setTime(month); |
| | | mS.setSum(mSum); |
| | | |
| | | List<String> year = new ArrayList<>(); |
| | | List<Double> ySum = new ArrayList<>(); |
| | | yearList.forEach(e->{ |
| | | String d = (String) e.get("time"); |
| | | double s = (double) e.get("sum"); |
| | | year.add(0,d); |
| | | ySum.add(0,s); |
| | | }); |
| | | StatisticsVo yS = new StatisticsVo(); |
| | | yS.setTime(year); |
| | | yS.setSum(ySum); |
| | | |
| | | |
| | | resMap.put("monthStatistics",mS); |
| | | resMap.put("yearStatistics",yS); |
| | | return ResultUtil.data(resMap); |
| | | |
| | | } |
| | | @Data |
| | | class StatisticsVo{ |
| | | Object time; |
| | | Object sum; |
| | | } |
| | | |
| | | } |