Commit 4c27df36aa3f812344ff58c76fbd5a298059f406
1 parent
a18e9a47
11
Showing
5 changed files
with
0 additions
and
1175 deletions
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BillManageController.java deleted
1 | -package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; | |
2 | - | |
3 | -import java.math.BigDecimal; | |
4 | -import java.text.SimpleDateFormat; | |
5 | -import java.util.ArrayList; | |
6 | -import java.util.Date; | |
7 | -import java.util.List; | |
8 | -import java.util.Map; | |
9 | - | |
10 | -import javax.servlet.http.HttpServletRequest; | |
11 | -import javax.servlet.http.HttpServletResponse; | |
12 | - | |
13 | -import org.apache.poi.xssf.usermodel.XSSFSheet; | |
14 | -import org.slf4j.Logger; | |
15 | -import org.slf4j.LoggerFactory; | |
16 | -import org.springframework.beans.factory.annotation.Autowired; | |
17 | -import org.springframework.stereotype.Controller; | |
18 | -import org.springframework.web.bind.annotation.RequestBody; | |
19 | -import org.springframework.web.bind.annotation.RequestMapping; | |
20 | -import org.springframework.web.bind.annotation.RequestMethod; | |
21 | -import org.springframework.web.bind.annotation.ResponseBody; | |
22 | - | |
23 | -import com.alibaba.dubbo.common.utils.StringUtils; | |
24 | -import com.alibaba.fastjson.JSONArray; | |
25 | -import com.alibaba.fastjson.JSONObject; | |
26 | -import com.clouds.common.constants.SessionEnum; | |
27 | -import com.clouds.common.entity.UserInfo; | |
28 | -import com.clouds.common.utils.excle.ExcelUtil; | |
29 | -import com.clouds.common.utils.excle.ExcleFillDateManager; | |
30 | -import com.clouds.common.utils.excle.Layouter; | |
31 | -import com.clouds.common.web.BizController; | |
32 | -import com.clouds.common.web.SessionCommUtil; | |
33 | -import com.zteits.clouds.api.apibase.bean.BizResult; | |
34 | -import com.zteits.clouds.api.apibase.bean.PageBean; | |
35 | -import com.zteits.clouds.api.dto.clouds.dto.BillManageDTO; | |
36 | -import com.zteits.clouds.api.dto.clouds.param.BillQueryRequest; | |
37 | -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; | |
38 | -import com.zteits.clouds.api.service.clouds.BillManageForDayService; | |
39 | -import com.zteits.clouds.api.service.pay.TdCustCompanyService; | |
40 | - | |
41 | -import io.swagger.annotations.Api; | |
42 | -import io.swagger.annotations.ApiOperation; | |
43 | - | |
44 | -/** | |
45 | - * 日账单controller类.<br/> | |
46 | - * | |
47 | - * Copyright: Copyright (c) 2017 zteits | |
48 | - * | |
49 | - * @ClassName: BillManageController.java | |
50 | - * @Description: | |
51 | - * @version: v1.0.0 | |
52 | - * @author: wangfs | |
53 | - * @date: 2017年6月30日 下午1:14:16 | |
54 | - * Modification History: | |
55 | - * Date Author Version Description | |
56 | - *---------------------------------------------------------* | |
57 | - * 2017年6月30日 wangfs v1.0.0 创建 | |
58 | - */ | |
59 | - | |
60 | -@Api(value = "停车场云平台 日账单", description = "停车场云平台 日账单") | |
61 | -@Controller | |
62 | -@RequestMapping("/bill") | |
63 | -public class BillManageController extends BizController { | |
64 | - private Logger logger = LoggerFactory.getLogger(BillManageController.class); | |
65 | - @Autowired | |
66 | - private BillManageForDayService billManageForDayService; | |
67 | - | |
68 | - @Autowired | |
69 | - private TdCustCompanyService tdCustCompanyService; | |
70 | - | |
71 | - @Autowired | |
72 | - private SessionCommUtil sessionCommUtil; | |
73 | - | |
74 | - @Autowired | |
75 | - private Map<String,TdCustCompanyService> map; | |
76 | - | |
77 | - private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
78 | - | |
79 | - @ApiOperation("日账汇总单查询") | |
80 | - @RequestMapping("/queryBillforDayForPage") | |
81 | - @ResponseBody | |
82 | - public void queryBillforDayTotalForPage(@RequestBody BillQueryRequest billQueryRequest, HttpServletRequest request, | |
83 | - HttpServletResponse response) throws Exception { | |
84 | - TdCustCompanyService sert = map.get("tdCustCompanyService"); | |
85 | - logger.info("---begin--日账汇总单查询调用后场dubbo服务,入参={}", JSONObject.toJSON(billQueryRequest)); | |
86 | - System.out.println("seesionId="+request.getSession().getId()); | |
87 | - UserInfo userInfo = sessionCommUtil.getUserInfo(); | |
88 | - logger.info("从session中获取的用户信息={}" + JSONObject.toJSONString(userInfo)); | |
89 | - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest(); | |
90 | - if (userInfo != null) { | |
91 | - | |
92 | - tdCompanyParkQueryRequest.setSysCode(billQueryRequest.getSysCode()); | |
93 | - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds()); | |
94 | - tdCompanyParkQueryRequest.setSessionId(request.getSession().getId()); | |
95 | - billQueryRequest.setParkIdList(this.queryParkNoByCustIds(tdCompanyParkQueryRequest)); | |
96 | - } | |
97 | - | |
98 | - BizResult<PageBean<BillManageDTO>> result = billManageForDayService.queryBillforDayTotalForPage(billQueryRequest); | |
99 | - result.setErrMsg(billQueryRequest.getParkIdList().toString()); | |
100 | - logger.info("---end--日账汇总单查询调用后场dubbo服务,结果={}", JSONObject.toJSONString(result)); | |
101 | - this.returnJsonDataGrid(response, result); | |
102 | - } | |
103 | - | |
104 | - /** | |
105 | - * 查询日账单.<br/> | |
106 | - * | |
107 | - * @param request | |
108 | - * @param response | |
109 | - * @throws Exception | |
110 | - */ | |
111 | - @ApiOperation("日账单查看") | |
112 | - @RequestMapping(value = "/queryBillForDay", method = RequestMethod.POST) | |
113 | - @ResponseBody | |
114 | - public void queryBillForDay(@RequestBody BillQueryRequest billQueryRequest, HttpServletRequest request, | |
115 | - HttpServletResponse response) throws Exception { | |
116 | - BizResult<PageBean<BillManageDTO>> result = new BizResult<PageBean<BillManageDTO>>(); | |
117 | - logger.info("---begin---日账单查看调用后场dubbo服务,入参={}", JSONObject.toJSONString(billQueryRequest)); | |
118 | - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest(); | |
119 | - UserInfo userInfo = (UserInfo) request.getSession().getAttribute(SessionEnum.USER_INFO.key()); | |
120 | - logger.info("从session中获取的用户信息={}" + JSONObject.toJSONString(userInfo)); | |
121 | - if (userInfo != null) { | |
122 | - | |
123 | - tdCompanyParkQueryRequest.setSysCode(billQueryRequest.getSysCode()); | |
124 | - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds()); | |
125 | - tdCompanyParkQueryRequest.setSessionId(request.getSession().getId()); | |
126 | - billQueryRequest.setUserName(userInfo.getName()); | |
127 | - billQueryRequest.setParkIdList(this.queryParkNoByCustIds(tdCompanyParkQueryRequest)); | |
128 | - | |
129 | - } | |
130 | - result = billManageForDayService.queryBillforDayDeatilPage(billQueryRequest); | |
131 | - logger.info("---end---日账单查看调用后场dubbo服务,结果={}", JSONObject.toJSON(result)); | |
132 | - | |
133 | - this.returnJsonDataGrid(response, result); | |
134 | - } | |
135 | - | |
136 | - /** | |
137 | - * 获取登录用户信息.<br/> | |
138 | - * @param request | |
139 | - * @param response | |
140 | - * @throws Exception | |
141 | - */ | |
142 | - @RequestMapping(value = "/queryUserInfoForName", method = RequestMethod.POST) | |
143 | - public void queryUserInfoForName( HttpServletRequest request, | |
144 | - HttpServletResponse response) throws Exception { | |
145 | - UserInfo userInfo = (UserInfo) request.getSession().getAttribute(SessionEnum.USER_INFO.key()); | |
146 | - this.returnJson(response, userInfo); | |
147 | - } | |
148 | - | |
149 | - | |
150 | - | |
151 | - | |
152 | - | |
153 | - /** | |
154 | - * 日账单导出.<br/> | |
155 | - * | |
156 | - * @param request | |
157 | - * @param response | |
158 | - * @throws Exception | |
159 | - */ | |
160 | - @RequestMapping("/exportToExcleForBillForDay") | |
161 | - public void exportToExcleForBillForDay(String sysCode, String beginTime, String endTime, String aliTotalFee , | |
162 | - String aliDealCount,String wxTotalFee,String wxDealCount,String cashTotalFee,String cashDealCount, | |
163 | - String orderTotalFee,String orderDealCount, | |
164 | - HttpServletRequest request,String parkIds,String userName, | |
165 | - HttpServletResponse response) throws Exception { | |
166 | - | |
167 | - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
168 | - //获取session中的用户信息 | |
169 | - UserInfo userInfo = sessionCommUtil.getUserInfo(); | |
170 | - BillQueryRequest billQueryRequest = new BillQueryRequest(); | |
171 | - | |
172 | - billQueryRequest.setBeginTime(format.parse(beginTime)); | |
173 | - billQueryRequest.setEndTime(format.parse(endTime)); | |
174 | - billQueryRequest.setSysCode(sysCode); | |
175 | - billQueryRequest.getBaseRequest().setPageSize(0); | |
176 | - List<String> parkList= new ArrayList<String>(); | |
177 | - if(StringUtils.isNotEmpty(parkIds)){ | |
178 | - for(String str :parkIds.split(",")){ | |
179 | - if(StringUtils.isNotEmpty(str)){ | |
180 | - parkList.add(str.trim()); | |
181 | - } | |
182 | - } | |
183 | - } | |
184 | - billQueryRequest.setParkIdList(parkList); | |
185 | - /**查询日账单汇总信息.*/ | |
186 | - BizResult<PageBean<BillManageDTO>> result = billManageForDayService.queryBillforDayDeatilPage(billQueryRequest); | |
187 | - String[] titleOne = new String[2]; | |
188 | - titleOne[0] = "用户: " + (StringUtils.isNotEmpty(userName) ? userName : ""); | |
189 | - titleOne[1] = "时间: "+beginTime+" "+endTime; | |
190 | - String[] titleTwo = new String[] {"","现金", "微信", "支付宝", "合计"}; | |
191 | - String[] titleThree = new String[] { "停车场名称", "现金", "微信", "支付宝", "合计"}; | |
192 | - String sheetName = "日账单"; | |
193 | - String fileName = "日账单管理" + format.format(new Date()); | |
194 | - | |
195 | - | |
196 | - // 1.创建excel信息 | |
197 | - XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | |
198 | - // 2.设置excel表头和表体 | |
199 | - Layouter.buildBillForDay(workSheet, titleOne, 0, 0);//创建第一行标题 | |
200 | - Layouter.buildHeaders(workSheet, titleTwo, 0, 0);//创建第2行标题 | |
201 | - Layouter.buildHeaders(workSheet, titleThree, 3, 0);//创建第3行标题 | |
202 | - // 3.填充数据 | |
203 | - List<Object[]> contentListTwo = new ArrayList<Object[]>(); | |
204 | - for(int i = 0;i<2;i++){ | |
205 | - Object[] str = new Object[titleTwo.length]; | |
206 | - if(i == 0){ | |
207 | - str[0] = "交易笔数"; | |
208 | - str[1] = (cashDealCount == null ? "0" : cashDealCount); | |
209 | - str[2] = (wxDealCount== null ? "0" : wxDealCount); | |
210 | - str[3] = (aliDealCount== null ? "0" : aliDealCount); | |
211 | - str[4] = (orderDealCount== null ? "0" : orderDealCount); | |
212 | - }else{ | |
213 | - str[0] = "总收入(元)"; | |
214 | - str[1] = (cashTotalFee == null ? "0" : new BigDecimal(cashTotalFee).divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; | |
215 | - str[2] = (wxTotalFee== null ? "0" : new BigDecimal(wxTotalFee).divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; | |
216 | - str[3] = (aliTotalFee== null ? "0" : new BigDecimal(aliTotalFee).divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; | |
217 | - str[4] = (orderTotalFee== null ? "0" : new BigDecimal(orderTotalFee).divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; | |
218 | - } | |
219 | - contentListTwo.add(str); | |
220 | - } | |
221 | - ExcleFillDateManager fillUserManagerTwo = new ExcleFillDateManager(); | |
222 | - fillUserManagerTwo.fillSalesOrga(workSheet, titleTwo, contentListTwo, 2); //第2行标题 | |
223 | - | |
224 | - // | |
225 | - List<Object[]> contentList = new ArrayList<Object[]>(); | |
226 | - if(result != null && result.getData() != null){ | |
227 | - List<BillManageDTO> list = result.getData().getDataList(); | |
228 | - if(list != null && list.size()>0){ | |
229 | - for (int i = 0; i < list.size(); i++) { | |
230 | - BillManageDTO e = list.get(i); | |
231 | - Object[] obj = new Object[titleThree.length]; | |
232 | - int index = 0; | |
233 | - obj[index++] = e.getParkName(); | |
234 | - obj[index++] = (e.getCashTotalFee()== null ? "0" : e.getCashTotalFee().divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; | |
235 | - obj[index++] = (e.getWxTotalFee()== null ? "0" : e.getWxTotalFee().divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; | |
236 | - obj[index++] = (e.getAliTotalFee()== null ? "0" : e.getAliTotalFee().divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; | |
237 | - obj[index++] = (e.getAliTotalFee()== null ? "0" : e.getAliTotalFee().divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; | |
238 | - contentList.add(obj); | |
239 | - } | |
240 | - } | |
241 | - } | |
242 | - | |
243 | - ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); | |
244 | - fillUserManager.fillSalesOrga(workSheet, titleThree, contentList, 5); | |
245 | - // 4.excel输出配置 | |
246 | - ExcelUtil.write(response, workSheet, fileName); | |
247 | - | |
248 | - | |
249 | - } | |
250 | - | |
251 | - /** | |
252 | - * 通过session信息获取停车场编码.<br/> | |
253 | - * | |
254 | - * @param billQueryRequest | |
255 | - * @param userInfo | |
256 | - * @return | |
257 | - * @throws Exception | |
258 | - */ | |
259 | - private List<String> queryParkNoByCustIds(TdCompanyParkQueryRequest tdCompanyParkQueryRequest) throws Exception { | |
260 | - /** 查询停车场编码. */ | |
261 | - BizResult<List<String>> parkNoResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest); | |
262 | - if (parkNoResult.isSuccess() && parkNoResult != null && parkNoResult.getData() != null) { | |
263 | - logger.info("根据登录获取到对应的停车场编码=" + JSONArray.toJSONString(parkNoResult.getData())); | |
264 | - return parkNoResult.getData(); | |
265 | - } else { | |
266 | - logger.info("根据登录用户没有获取到对应的停车场编码"); | |
267 | - return null; | |
268 | - } | |
269 | - | |
270 | - } | |
271 | - | |
272 | - | |
273 | - | |
274 | -} |
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/ParkLotStatisticController.java deleted
1 | -package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; | |
2 | - | |
3 | -import java.util.List; | |
4 | -import java.util.Map; | |
5 | - | |
6 | -import javax.servlet.http.HttpSession; | |
7 | - | |
8 | -import org.apache.commons.lang3.StringUtils; | |
9 | -import org.slf4j.Logger; | |
10 | -import org.slf4j.LoggerFactory; | |
11 | -import org.springframework.beans.factory.annotation.Autowired; | |
12 | -import org.springframework.web.bind.annotation.PostMapping; | |
13 | -import org.springframework.web.bind.annotation.RequestMapping; | |
14 | -import org.springframework.web.bind.annotation.RequestParam; | |
15 | -import org.springframework.web.bind.annotation.RestController; | |
16 | - | |
17 | -import com.alibaba.dubbo.common.utils.CollectionUtils; | |
18 | -import com.clouds.common.cache.park.ParkingLotCacheUtil; | |
19 | -import com.clouds.common.entity.UserInfo; | |
20 | -import com.clouds.common.utils.ResultUtils; | |
21 | -import com.clouds.common.web.SessionCommUtil; | |
22 | -import com.clouds.common.web.vo.BizResultVO; | |
23 | -import com.google.common.collect.Lists; | |
24 | -import com.zteits.clouds.api.apibase.bean.BizResult; | |
25 | -import com.zteits.clouds.api.apibase.constants.ErrorType; | |
26 | -import com.zteits.clouds.api.apibase.exception.BizException; | |
27 | -import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; | |
28 | -import com.zteits.clouds.api.dto.park.param.ParkFreeBerthGetByPlnoRequest; | |
29 | -import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; | |
30 | -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; | |
31 | -import com.zteits.clouds.api.service.park.ParkFreeBerthService; | |
32 | -import com.zteits.clouds.api.service.park.ParkingLotQueryService; | |
33 | -import com.zteits.clouds.api.service.pay.TdCustCompanyService; | |
34 | -import com.zteits.irain.portal.vo.govclouds.ParkLotStatisticVO; | |
35 | -import com.zteits.irain.portal.web.parkinglotcloudplatform.parklotmanage.ParkLotManageController; | |
36 | - | |
37 | -import io.swagger.annotations.Api; | |
38 | -import io.swagger.annotations.ApiOperation; | |
39 | -/** | |
40 | - * | |
41 | - * Copyright: Copyright (c) 2017 zteits | |
42 | - * | |
43 | - * @ClassName: ParkLotStatisticController.java | |
44 | - * @Description: | |
45 | - * @version: v1.0.0 | |
46 | - * @author: zhaowg | |
47 | - * @date: 2017年8月7日 下午5:21:16 | |
48 | - * Modification History: | |
49 | - * Date Author Version Description | |
50 | - *---------------------------------------------------------* | |
51 | - * 2017年8月7日 zhaowg v1.0.0 创建 | |
52 | - */ | |
53 | - | |
54 | -@Api("停车场信息统计") | |
55 | -@RestController | |
56 | -@RequestMapping("parklotstatistic") | |
57 | -public class ParkLotStatisticController { | |
58 | - private Logger logger = LoggerFactory.getLogger(ParkLotManageController.class); | |
59 | - @Autowired | |
60 | - private HttpSession session; | |
61 | - @Autowired | |
62 | - private SessionCommUtil sessionCommUtil; | |
63 | - @Autowired | |
64 | - private TdCustCompanyService tdCustCompanyService; | |
65 | - @Autowired | |
66 | - private ParkingLotQueryService parkingLotQueryService; | |
67 | - @Autowired | |
68 | - private ParkFreeBerthService parkFreeBerthService; | |
69 | - | |
70 | - @ApiOperation("获取停车场信息统计") | |
71 | - @PostMapping("getParkLotStatistic") | |
72 | - public BizResultVO<List<ParkLotStatisticVO>> getParkLotStatistic(@RequestParam String sysCode) throws Exception{ | |
73 | - List<ParkLotStatisticVO> result = Lists.newArrayList(); | |
74 | - //拥有的停车场编号 | |
75 | - List<String> plNos = this.GetParkLotNosByCurrUser(sysCode); | |
76 | - //查询对应的停车场信息 | |
77 | - if(CollectionUtils.isEmpty(plNos)){ | |
78 | - return new BizResultVO<List<ParkLotStatisticVO>>().setData(result); | |
79 | - } | |
80 | - //空闲车位数 | |
81 | - ParkFreeBerthGetByPlnoRequest request = new ParkFreeBerthGetByPlnoRequest(); | |
82 | - request.setPlNos(plNos); | |
83 | - request.setSysCode(sysCode); | |
84 | - BizResult<Map<String, Integer>> freeBerthsNumBizResult = parkFreeBerthService.getParkFreeBerthByPlno(request ); | |
85 | - Map<String, Integer> freeBerthsNumMap = ResultUtils.getBizResultData(freeBerthsNumBizResult); | |
86 | - for (String plNo : plNos) { | |
87 | - //先查询缓存 | |
88 | - ParkingLotDTO lotDTO = ParkingLotCacheUtil.getParkLotByPlNo(plNo); | |
89 | - if(lotDTO == null){ | |
90 | - //查询数据库 | |
91 | - QueryParkLotInfoByPkNoRequest request1 = new QueryParkLotInfoByPkNoRequest(); | |
92 | - request1.setSysCode(sysCode); | |
93 | - request1.setPklNo(plNo); | |
94 | - BizResult<ParkingLotDTO> bizResult2 = parkingLotQueryService.QueryParkingLotByPkNo(request1); | |
95 | - lotDTO = ResultUtils.getBizResultData(bizResult2); | |
96 | - } | |
97 | - if(lotDTO == null || StringUtils.isBlank(lotDTO.getPlName()) || lotDTO.getPlName().equals("null")){ | |
98 | - continue; | |
99 | - } | |
100 | - ParkLotStatisticVO lotStatisticVO = new ParkLotStatisticVO(); | |
101 | - lotStatisticVO.setPlNo(plNo); | |
102 | - lotStatisticVO.setPlName(lotDTO.getPlName()); | |
103 | - lotStatisticVO.setFreeBerthsNum(freeBerthsNumMap.get(plNo)); | |
104 | - lotStatisticVO.setTotalBerthsNum(lotDTO.getPlBerthNum()); | |
105 | - lotStatisticVO.setUseingBerthsNum(lotDTO.getPlBerthNum()-freeBerthsNumMap.get(plNo)); | |
106 | - //设置地磁在线离线数量 | |
107 | - //TODO 临时方案,只有红山区有数据 | |
108 | - result.add(lotStatisticVO); | |
109 | - } | |
110 | - return new BizResultVO<List<ParkLotStatisticVO>>().setData(result); | |
111 | - } | |
112 | - | |
113 | - private List<String> GetParkLotNosByCurrUser(String sysCode) throws Exception { | |
114 | - logger.info("根据登录人权限获取停车场列表"); | |
115 | - List<String> plNos = Lists.newArrayList(); | |
116 | - //2.调用接口查询当前登录人管辖的停车场名称 | |
117 | - plNos.add("A320211000"); | |
118 | - plNos.add("B1504020C7"); | |
119 | - /*UserInfo userInfo = sessionCommUtil.getUserInfo(); | |
120 | - if(userInfo!=null){ | |
121 | - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest(); | |
122 | - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds()); | |
123 | - tdCompanyParkQueryRequest.setSysCode(sysCode); | |
124 | - tdCompanyParkQueryRequest.setSessionId(session.getId()); | |
125 | - BizResult<List<String>> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest ); | |
126 | - plNos = ResultUtils.getBizResultData(bizResult); | |
127 | - }else{ | |
128 | - throw new BizException(ErrorType.AUTH_TOKEN_NOT_EXISTS); | |
129 | - }*/ | |
130 | - return plNos; | |
131 | - } | |
132 | -} |
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/VehicleFlowStatisticController.java deleted
1 | -package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; | |
2 | - | |
3 | -import java.sql.Timestamp; | |
4 | -import java.text.SimpleDateFormat; | |
5 | -import java.util.ArrayList; | |
6 | -import java.util.Calendar; | |
7 | -import java.util.Date; | |
8 | -import java.util.List; | |
9 | -import java.util.Map; | |
10 | -import java.util.Map.Entry; | |
11 | - | |
12 | -import javax.servlet.http.HttpServletRequest; | |
13 | -import javax.servlet.http.HttpServletResponse; | |
14 | -import javax.servlet.http.HttpSession; | |
15 | - | |
16 | -import org.apache.poi.xssf.usermodel.XSSFSheet; | |
17 | -import org.slf4j.Logger; | |
18 | -import org.slf4j.LoggerFactory; | |
19 | -import org.springframework.beans.factory.annotation.Autowired; | |
20 | -import org.springframework.beans.factory.annotation.Value; | |
21 | -import org.springframework.stereotype.Controller; | |
22 | -import org.springframework.web.bind.annotation.GetMapping; | |
23 | -import org.springframework.web.bind.annotation.PostMapping; | |
24 | -import org.springframework.web.bind.annotation.RequestBody; | |
25 | -import org.springframework.web.bind.annotation.RequestMapping; | |
26 | -import org.springframework.web.bind.annotation.RequestParam; | |
27 | -import org.springframework.web.bind.annotation.ResponseBody; | |
28 | - | |
29 | -import com.alibaba.dubbo.common.utils.CollectionUtils; | |
30 | -import com.alibaba.fastjson.JSON; | |
31 | -import com.alibaba.fastjson.JSONObject; | |
32 | -import com.clouds.common.entity.UserInfo; | |
33 | -import com.clouds.common.utils.DateUtil; | |
34 | -import com.clouds.common.utils.ResultUtils; | |
35 | -import com.clouds.common.utils.excle.ExcelUtil; | |
36 | -import com.clouds.common.utils.excle.ExcleFillDateManager; | |
37 | -import com.clouds.common.utils.excle.Layouter; | |
38 | -import com.clouds.common.web.BizController; | |
39 | -import com.clouds.common.web.SessionCommUtil; | |
40 | -import com.clouds.common.web.vo.BizResultVO; | |
41 | -import com.clouds.common.web.vo.EasyUIDataGridVO; | |
42 | -import com.google.common.collect.Lists; | |
43 | -import com.google.common.collect.Maps; | |
44 | -import com.zteits.clouds.api.apibase.bean.BaseInfo; | |
45 | -import com.zteits.clouds.api.apibase.bean.BizResult; | |
46 | -import com.zteits.clouds.api.apibase.bean.PageBean; | |
47 | -import com.zteits.clouds.api.apibase.constants.ErrorType; | |
48 | -import com.zteits.clouds.api.apibase.exception.BizException; | |
49 | -import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; | |
50 | -import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticMaxAndMinDTO; | |
51 | -import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; | |
52 | -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; | |
53 | -import com.zteits.clouds.api.service.park.ParkingLotUseStatisticService; | |
54 | -import com.zteits.clouds.api.service.pay.TdCustCompanyService; | |
55 | -import com.zteits.irain.portal.constant.ParkConstant; | |
56 | -import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.BerthsAndFlowLineChartVO; | |
57 | -import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; | |
58 | -import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO.SerieVO; | |
59 | - | |
60 | -import io.swagger.annotations.Api; | |
61 | -import io.swagger.annotations.ApiOperation; | |
62 | - | |
63 | -/** | |
64 | - * | |
65 | - * 停车场车流量数据统计 Copyright: Copyright (c) 2017 zteits | |
66 | - * | |
67 | - * @ClassName: ParkingLotUseStatisticController.java | |
68 | - * @Description: | |
69 | - * @version: v1.0.0 | |
70 | - * @author: langlw | |
71 | - * @date: 2017年6月14日 下午3:02:39 Modification History: Date Author Version | |
72 | - * Description ---------------------------------------------------------* | |
73 | - * 2017年6月14日 langlw v1.0.0 创建 | |
74 | - */ | |
75 | -@Api(value = "停车场车流量数据统计", description = "停车场车流量数据统计") | |
76 | -@Controller | |
77 | -@RequestMapping(value = "/VehicleFlowStatistic") | |
78 | -public class VehicleFlowStatisticController extends BizController { | |
79 | - private Logger logger = LoggerFactory.getLogger(VehicleFlowStatisticController.class); | |
80 | - | |
81 | - @Value("${project.syscode}") | |
82 | - private String sysCode; | |
83 | - | |
84 | - @Autowired | |
85 | - private ParkingLotUseStatisticService parkingLotStatisticService; | |
86 | - @Autowired | |
87 | - private HttpSession session; | |
88 | - @Autowired | |
89 | - private SessionCommUtil sessionCommUtil; | |
90 | - @Autowired | |
91 | - private TdCustCompanyService tdCustCompanyService; | |
92 | - | |
93 | - @ApiOperation("分页查询车流量数据统计车位总流量") | |
94 | - @PostMapping("getVehicleFlowStatisticForPage") | |
95 | - @ResponseBody | |
96 | - public BizResultVO<EasyUIDataGridVO<ParkingLotUseStatisticDTO>> queryParkingLotUseStatisticForPage( | |
97 | - @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception { | |
98 | - if (null == request.getBeginTime() || null==request.getEndTime()) { | |
99 | - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); | |
100 | - } | |
101 | - Calendar beginc = Calendar.getInstance(); | |
102 | - beginc.setTime(request.getBeginTime()); | |
103 | - int beginYear = beginc.get(Calendar.YEAR); | |
104 | - int beginMonth = beginc.get(Calendar.MONTH) + 1; | |
105 | - int beginDay = beginc.get(Calendar.DAY_OF_MONTH); | |
106 | - | |
107 | - Calendar endc = Calendar.getInstance(); | |
108 | - endc.setTime(request.getEndTime()); | |
109 | - int endYear = endc.get(Calendar.YEAR); | |
110 | - int endMonth = endc.get(Calendar.MONTH) + 1; | |
111 | - int endDay = endc.get(Calendar.DAY_OF_MONTH); | |
112 | - | |
113 | - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { | |
114 | - // 2表示按每小时统计 | |
115 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | |
116 | - } else { | |
117 | - // 3表示按每天统计 | |
118 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | |
119 | - } | |
120 | - | |
121 | - BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService | |
122 | - .queryParkingLotUseStatisticForPage(request); | |
123 | - return returnJqGridData(bizResult, ParkingLotUseStatisticDTO.class); | |
124 | - } | |
125 | - | |
126 | - @ApiOperation("查询车流量最大值与最小值") | |
127 | - @PostMapping("getVehicleFlowMaxAndMin") | |
128 | - @ResponseBody | |
129 | - public BizResultVO<ParkingLotUseStatisticMaxAndMinDTO> QueryParkingLotUseStatisticMaxAndMin( | |
130 | - @RequestBody ParkingLotUseStatisticForPageRequest request) { | |
131 | - Calendar beginc = Calendar.getInstance(); | |
132 | - beginc.setTime(request.getBeginTime()); | |
133 | - int beginYear = beginc.get(Calendar.YEAR); | |
134 | - int beginMonth = beginc.get(Calendar.MONTH) + 1; | |
135 | - int beginDay = beginc.get(Calendar.DAY_OF_MONTH); | |
136 | - | |
137 | - Calendar endc = Calendar.getInstance(); | |
138 | - endc.setTime(request.getEndTime()); | |
139 | - int endYear = endc.get(Calendar.YEAR); | |
140 | - int endMonth = endc.get(Calendar.MONTH) + 1; | |
141 | - int endDay = endc.get(Calendar.DAY_OF_MONTH); | |
142 | - | |
143 | - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { | |
144 | - // 2表示按每小时统计 | |
145 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | |
146 | - } else { | |
147 | - // 3表示按每天统计 | |
148 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | |
149 | - } | |
150 | - BizResult<ParkingLotUseStatisticMaxAndMinDTO> bizResult = parkingLotStatisticService | |
151 | - .QueryVehicleFlowStatisticMaxAndMin(request); | |
152 | - return new BizResultVO<>(bizResult); | |
153 | - } | |
154 | - | |
155 | - @ApiOperation("导出车流量数据统计excel") | |
156 | - @GetMapping("exportVehicleFlowStatisticExcel") | |
157 | - public void excelParkingLotUseStatistic(@RequestParam String beginTime, @RequestParam String endTime, | |
158 | - @RequestParam String plNos, HttpServletRequest requests, HttpServletResponse response) { | |
159 | - ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest(); | |
160 | - request.setSysCode(sysCode); | |
161 | - request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT)); | |
162 | - request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT)); | |
163 | - List<String> plNoslist = new ArrayList<>(); | |
164 | - plNoslist.add(plNos); | |
165 | - request.setPlNos(plNoslist); | |
166 | - request.setBaseRequest(new BaseInfo(1, 0)); | |
167 | - Calendar beginc = Calendar.getInstance(); | |
168 | - beginc.setTime(request.getBeginTime()); | |
169 | - int beginYear = beginc.get(Calendar.YEAR); | |
170 | - int beginMonth = beginc.get(Calendar.MONTH) + 1; | |
171 | - int beginDay = beginc.get(Calendar.DAY_OF_MONTH); | |
172 | - | |
173 | - Calendar endc = Calendar.getInstance(); | |
174 | - endc.setTime(request.getEndTime()); | |
175 | - int endYear = endc.get(Calendar.YEAR); | |
176 | - int endMonth = endc.get(Calendar.MONTH) + 1; | |
177 | - int endDay = endc.get(Calendar.DAY_OF_MONTH); | |
178 | - | |
179 | - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { | |
180 | - // 2表示按每小时统计 | |
181 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | |
182 | - } else { | |
183 | - // 3表示按每天统计 | |
184 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | |
185 | - } | |
186 | - BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService | |
187 | - .queryParkingLotUseStatisticForPage(request); | |
188 | - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
189 | - SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); | |
190 | - String[] title = new String[] { "时间", "总车流量", "临时车流量", "固定车流量" }; | |
191 | - String sheetName = "车流量管理"; | |
192 | - String fileName = "车流量管理" + format2.format(new Date()); | |
193 | - // 1.创建excel信息 | |
194 | - XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | |
195 | - // 2.设置excel表头和表体 | |
196 | - Layouter.buildReport(workSheet, title, 0, 0); | |
197 | - // 3.填充数据 | |
198 | - List<Object[]> contentList = new ArrayList<Object[]>(); | |
199 | - List<ParkingLotUseStatisticDTO> list = new ArrayList<>(); | |
200 | - if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) { | |
201 | - list = bizResult.getData().getDataList(); | |
202 | - } | |
203 | - for (ParkingLotUseStatisticDTO e : list) { | |
204 | - Object[] obj = new Object[title.length]; | |
205 | - int index = 0; | |
206 | - obj[index++] = format.format(e.getStatisticBeginTime()); | |
207 | - obj[index++] = e.getVehicleFlow(); | |
208 | - obj[index++] = e.getTmpVehicleFlow(); | |
209 | - obj[index++] = e.getFixVehicleFlow(); | |
210 | - contentList.add(obj); | |
211 | - } | |
212 | - ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); | |
213 | - fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); | |
214 | - // 4.excel输出配置 | |
215 | - ExcelUtil.write(response, workSheet, fileName); | |
216 | - } | |
217 | - | |
218 | - /** | |
219 | - * 根据时间获取车流量折线图 | |
220 | - * | |
221 | - * @param request | |
222 | - * @return | |
223 | - * @throws Exception | |
224 | - */ | |
225 | - @ApiOperation("根据时间获取车流量折线图") | |
226 | - @PostMapping("getVehicleFlowForLineChart") | |
227 | - @ResponseBody | |
228 | - public BizResultVO<LineChartVO> getVehicleFlowForLineChart( | |
229 | - @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception { | |
230 | - | |
231 | - if (null == request.getBeginTime() || null==request.getEndTime()) { | |
232 | - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); | |
233 | - } | |
234 | - //2.调用接口查询当前登录人管辖的停车场名称 | |
235 | - UserInfo userInfo = sessionCommUtil.getUserInfo(); | |
236 | - List<String> plNos = new ArrayList<>(); | |
237 | - if(userInfo!=null){ | |
238 | - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest(); | |
239 | - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds()); | |
240 | - tdCompanyParkQueryRequest.setSessionId(session.getId()); | |
241 | - tdCompanyParkQueryRequest.setSysCode(sysCode); | |
242 | - BizResult<List<String>> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest); | |
243 | - //拥有的停车场编号 | |
244 | - plNos = ResultUtils.getBizResultData(bizResult); | |
245 | - } | |
246 | - if(CollectionUtils.isEmpty(plNos)){ | |
247 | - throw new BizException(ErrorType.PARK_LOT_NOT_EXISTS, "停车场plnos不存在"); | |
248 | - } | |
249 | - request.setPlNos(plNos); | |
250 | - | |
251 | - logger.info("根据停车场编号获取该停车场今日车流量和车位折线图"); | |
252 | - Calendar beginTime = Calendar.getInstance(); | |
253 | - beginTime.setTime(request.getBeginTime()); | |
254 | - | |
255 | - Calendar endTime = Calendar.getInstance(); | |
256 | - endTime.setTime(request.getEndTime()); | |
257 | - | |
258 | - Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()), | |
259 | - new Timestamp(request.getBeginTime().getTime())); | |
260 | - List<String> xAxisData = Lists.newArrayList(); | |
261 | - request.setBaseRequest(new BaseInfo(1, 0)); | |
262 | - String dateType=""; | |
263 | - | |
264 | - if (dayDifference == 0L) { | |
265 | - // 20分钟为一个时间戳 | |
266 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER20MINUTE); | |
267 | - int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY) * 3; | |
268 | - for (int i = 0; i < totaltimestampCount; i++) { | |
269 | - String hour = String.format("%02d", (i / 3)); | |
270 | - String minute = String.format("%02d", (i % 3) * 20); | |
271 | - xAxisData.add(hour + ":" + minute); | |
272 | - } | |
273 | - dateType="HH:mm"; | |
274 | - LineChartVO vehicleFlows=getVehicleFlows(request, xAxisData, dateType); | |
275 | - return new BizResultVO<LineChartVO>().setData(vehicleFlows); | |
276 | - | |
277 | - } else if (dayDifference <= 3L) { | |
278 | - // 1小时为一个时间戳 | |
279 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | |
280 | - int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY); | |
281 | - String day = ""; | |
282 | - String month = ""; | |
283 | - for (int i = 0; i < dayDifference.intValue(); i++) { | |
284 | - beginTime.add(Calendar.DAY_OF_MONTH, 1); | |
285 | - int beginMonth = beginTime.get(Calendar.MONTH) + 1; | |
286 | - int beginDay = beginTime.get(Calendar.DAY_OF_MONTH); | |
287 | - month = String.format("%02d", (beginMonth)); | |
288 | - day = String.format("%02d", (beginDay)); | |
289 | - for (int j = 0; j < totaltimestampCount; j++) { | |
290 | - String hour = String.format("%02d", (j)); | |
291 | - xAxisData.add(month + "-" + day + " " + hour); | |
292 | - } | |
293 | - } | |
294 | - dateType="MM-dd HH"; | |
295 | - LineChartVO vehicleFlows=getVehicleFlows(request, xAxisData, dateType); | |
296 | - return new BizResultVO<LineChartVO>().setData(vehicleFlows); | |
297 | - | |
298 | - } else { | |
299 | - // 1天为一个时间戳 | |
300 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | |
301 | - for (int i = 0; i < dayDifference.intValue(); i++) { | |
302 | - beginTime.add(Calendar.DAY_OF_MONTH, 1); | |
303 | - int beginMonth = beginTime.get(Calendar.MONTH) + 1; | |
304 | - int beginDay = beginTime.get(Calendar.DAY_OF_MONTH); | |
305 | - String month = String.format("%02d", (beginMonth)); | |
306 | - String day = String.format("%02d", (beginDay)); | |
307 | - xAxisData.add(month + "-" + day); | |
308 | - | |
309 | - } | |
310 | - dateType="MM-dd"; | |
311 | - LineChartVO vehicleFlows=getVehicleFlows(request, xAxisData, dateType); | |
312 | - return new BizResultVO<LineChartVO>().setData(vehicleFlows); | |
313 | - | |
314 | - } | |
315 | - | |
316 | - } | |
317 | - | |
318 | - | |
319 | - private LineChartVO getVehicleFlows(ParkingLotUseStatisticForPageRequest request, | |
320 | - List<String> xAxisData,String dateType){ | |
321 | - // 调用后场服务 | |
322 | - logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); | |
323 | - BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService | |
324 | - .queryParkingLotUseStatisticForPage(request); | |
325 | - PageBean<ParkingLotUseStatisticDTO> pageBean = ResultUtils.getBizResultData(bizResult); | |
326 | - List<ParkingLotUseStatisticDTO> useStatisticDTOs = Lists.newArrayList(); | |
327 | - if (pageBean != null) { | |
328 | - useStatisticDTOs = pageBean.getDataList(); | |
329 | - } | |
330 | - | |
331 | - // 保存固定车流量,时间戳和车流量对应关系 | |
332 | - Map<String, Integer> fixVehicleFlowMap = Maps.newHashMap(); | |
333 | - // 保存临时车流量,时间戳和车流量对应关系 | |
334 | - Map<String, Integer> tmpVehicleFlowMap = Maps.newHashMap(); | |
335 | - // 停车场编号和名称对应关系 | |
336 | - Map<String, String> parkNameMap = Maps.newHashMap(); | |
337 | - // 通过停车场,和统计时间分组 | |
338 | - // Map<String, Map<String, Double>> parkLotMap = Maps.newHashMap(); | |
339 | - if (!CollectionUtils.isEmpty(useStatisticDTOs)) { | |
340 | - for (ParkingLotUseStatisticDTO statisticDTO : useStatisticDTOs) { | |
341 | - String key = statisticDTO.getPlNo(); | |
342 | - parkNameMap.put(key, statisticDTO.getPlName()); | |
343 | - String statisBeginTime = DateUtil.getDateString(statisticDTO.getStatisticBeginTime(), dateType); | |
344 | - //保存固定车流量和临时车流量 | |
345 | - fixVehicleFlowMap.put(statisBeginTime, (fixVehicleFlowMap.get(statisBeginTime)==null?0:fixVehicleFlowMap.get(statisBeginTime))+statisticDTO.getFixVehicleFlow()); | |
346 | - tmpVehicleFlowMap.put(statisBeginTime, (tmpVehicleFlowMap.get(statisBeginTime)==null?0:tmpVehicleFlowMap.get(statisBeginTime))+statisticDTO.getTmpVehicleFlow()); | |
347 | - } | |
348 | - } | |
349 | - | |
350 | - // 封装车流量统计 | |
351 | - LineChartVO vehicleFlows = new LineChartVO(); | |
352 | - List<String> vehicleFlows_legendData = Lists.newArrayList(); | |
353 | - vehicleFlows_legendData.add("临时车"); | |
354 | - vehicleFlows_legendData.add("固定车"); | |
355 | - vehicleFlows.setLegendData(vehicleFlows_legendData); | |
356 | - vehicleFlows.setxAxisData(xAxisData); | |
357 | - List<SerieVO> vehicleSeries = Lists.newArrayList(); | |
358 | - // 固定车 | |
359 | - SerieVO fixSerieVo = new SerieVO(); | |
360 | - fixSerieVo.setName("固定车"); | |
361 | - List<Integer> fixSerieVoData = Lists.newArrayList(); | |
362 | - // 临时车 | |
363 | - SerieVO tmpSerieVo = new SerieVO(); | |
364 | - tmpSerieVo.setName("临时车"); | |
365 | - List<Integer> tmpSerieVoData = Lists.newArrayList(); | |
366 | - // 保存上一次的临时车值,当某个时间点没有数据时,则保持和上次一致 | |
367 | - Integer lastfixFlow = 0; | |
368 | - Integer lasttmpFlow = 0; | |
369 | - for (String timestamp : xAxisData) { | |
370 | - | |
371 | - if (fixVehicleFlowMap.containsKey(timestamp)) { | |
372 | - lastfixFlow = fixVehicleFlowMap.get(timestamp).intValue(); | |
373 | - }else{ | |
374 | - lastfixFlow =0; | |
375 | - } | |
376 | - fixSerieVoData.add(lastfixFlow); | |
377 | - | |
378 | - if (tmpVehicleFlowMap.containsKey(timestamp)) { | |
379 | - lasttmpFlow = tmpVehicleFlowMap.get(timestamp).intValue(); | |
380 | - }else{ | |
381 | - lasttmpFlow = 0; | |
382 | - } | |
383 | - tmpSerieVoData.add(lasttmpFlow); | |
384 | - } | |
385 | - fixSerieVo.setData(fixSerieVoData); | |
386 | - vehicleSeries.add(fixSerieVo); | |
387 | - tmpSerieVo.setData(tmpSerieVoData); | |
388 | - vehicleSeries.add(tmpSerieVo); | |
389 | - | |
390 | - vehicleFlows.setSeries(vehicleSeries); | |
391 | - return vehicleFlows; | |
392 | - } | |
393 | - | |
394 | - public static void main(String[] args) { | |
395 | - String json="{\"id\":\"1\",\"platform\":\"android\",\"parameter\":{\"drid\":\"177277364\",\"sex\":\"1\",\"type\":\"2\",\"creatorname\":\"Mrw\",\"username\":\"jack\",\"pwd\":\"123456\",\"remark\":\"平板用户\",\"createtime\":\"2017-07-24 23:59:59\"}}"; | |
396 | - JSONObject object =(JSONObject)JSONObject.parse(json); | |
397 | - System.out.println(object.get("id")); | |
398 | - System.out.println(object.get("platform")); | |
399 | - JSONObject parameter =(JSONObject)object.get("parameter"); | |
400 | - System.out.println(parameter.get("drid")); | |
401 | - System.out.println(parameter.get("sex")); | |
402 | - } | |
403 | - | |
404 | - | |
405 | -} |
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/YearMonthCardStatisticController.java deleted
1 | -package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; | |
2 | - | |
3 | -import java.text.SimpleDateFormat; | |
4 | -import java.util.ArrayList; | |
5 | -import java.util.Date; | |
6 | -import java.util.List; | |
7 | - | |
8 | -import javax.servlet.http.HttpServletRequest; | |
9 | -import javax.servlet.http.HttpServletResponse; | |
10 | - | |
11 | -import com.alibaba.dubbo.common.utils.CollectionUtils; | |
12 | -import com.alibaba.fastjson.JSON; | |
13 | - | |
14 | -import com.clouds.common.utils.excle.ExcelUtil; | |
15 | -import com.clouds.common.utils.excle.ExcleFillDateManager; | |
16 | -import com.clouds.common.utils.excle.Layouter; | |
17 | -import com.clouds.common.web.BizController; | |
18 | -import com.clouds.common.web.vo.BizResultVO; | |
19 | -import com.clouds.common.web.vo.EasyUIDataGridVO; | |
20 | -import com.zteits.clouds.api.apibase.bean.BaseInfo; | |
21 | -import com.zteits.clouds.api.apibase.bean.BizResult; | |
22 | -import com.zteits.clouds.api.apibase.bean.PageBean; | |
23 | -import com.zteits.clouds.api.apibase.constants.ErrorType; | |
24 | -import com.zteits.clouds.api.apibase.exception.BizException; | |
25 | -import com.zteits.clouds.api.dto.clouds.dto.YearMonthCardStatisticDTO; | |
26 | -import com.zteits.clouds.api.dto.clouds.dto.YearMonthCardStatisticSumDTO; | |
27 | -import com.zteits.clouds.api.dto.pay.param.YearMonthCardStatisticRequest; | |
28 | -import com.zteits.clouds.api.service.clouds.YearMonthCardStatisticService; | |
29 | -import io.swagger.annotations.Api; | |
30 | -import io.swagger.annotations.ApiOperation; | |
31 | -import org.apache.poi.xssf.usermodel.XSSFSheet; | |
32 | -import org.slf4j.Logger; | |
33 | -import org.slf4j.LoggerFactory; | |
34 | -import org.springframework.beans.factory.annotation.Autowired; | |
35 | -import org.springframework.beans.factory.annotation.Value; | |
36 | -import org.springframework.web.bind.annotation.GetMapping; | |
37 | -import org.springframework.web.bind.annotation.PostMapping; | |
38 | -import org.springframework.web.bind.annotation.RequestBody; | |
39 | -import org.springframework.web.bind.annotation.RequestMapping; | |
40 | -import org.springframework.web.bind.annotation.RequestParam; | |
41 | -import org.springframework.web.bind.annotation.ResponseBody; | |
42 | -import org.springframework.web.bind.annotation.RestController; | |
43 | - | |
44 | -/** | |
45 | - * 企业云平台->数据统计->年卡月卡统计。 | |
46 | - * | |
47 | - * Copyright: Copyright (c) 2017 zteits | |
48 | - * | |
49 | - * @ClassName: InOutParkStatisticController.java | |
50 | - * @Description: | |
51 | - * @version: v1.0.0 | |
52 | - * @author: langlw | |
53 | - * @date: 2017年7月26日 上午11:30:04 | |
54 | - * Modification History: | |
55 | - * Date Author Version Description | |
56 | - * ---------------------------------------------------------* | |
57 | - * 2017年7月26日 langlw v1.0.0 创建 | |
58 | - */ | |
59 | -@Api(value = "企业云平台->数据统计->年卡月卡统计", description = "企业云平台->数据统计->年卡月卡统计") | |
60 | -@RestController | |
61 | -@RequestMapping(value = "/yearMonthCardStatistic") | |
62 | -public class YearMonthCardStatisticController extends BizController { | |
63 | - | |
64 | - private static final Logger logger = LoggerFactory.getLogger(InOutParkStatisticController.class); | |
65 | - | |
66 | - @Value("${project.syscode}") | |
67 | - private String sysCode; | |
68 | - @Autowired | |
69 | - private YearMonthCardStatisticService yearMonthCardStatisticService; | |
70 | - | |
71 | - @ApiOperation("年卡月卡统计") | |
72 | - @PostMapping("queryYearMonthCardStatistic") | |
73 | - @ResponseBody | |
74 | - public BizResultVO<EasyUIDataGridVO<YearMonthCardStatisticDTO>> queryYearMonthCardStatistic( | |
75 | - @RequestBody YearMonthCardStatisticRequest request) throws Exception { | |
76 | - logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); | |
77 | - if (null == request.getBeginTime() || null == request.getEndTime()) { | |
78 | - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); | |
79 | - } | |
80 | - BizResult<PageBean<YearMonthCardStatisticDTO>> bizResult = yearMonthCardStatisticService | |
81 | - .queryYearMonthCardStatistic(request); | |
82 | - return returnJqGridData(bizResult, YearMonthCardStatisticDTO.class); | |
83 | - } | |
84 | - | |
85 | - @ApiOperation("年卡月卡统计折线图") | |
86 | - @PostMapping("queryYearMonthCardStatisticForChart") | |
87 | - @ResponseBody | |
88 | - public BizResultVO<List<YearMonthCardStatisticSumDTO>> queryYearMonthCardStatisticForChart( | |
89 | - @RequestBody YearMonthCardStatisticRequest request) throws Exception { | |
90 | - logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); | |
91 | - if (null == request.getBeginTime() || null == request.getEndTime()) { | |
92 | - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); | |
93 | - } | |
94 | - BizResult<List<YearMonthCardStatisticSumDTO>> bizResult = yearMonthCardStatisticService | |
95 | - .queryYearMonthCardStatisticSum(request); | |
96 | - logger.info("调用DUBBO服务返回结果:" + JSON.toJSONString(bizResult)); | |
97 | - return new BizResultVO<>(bizResult); | |
98 | - } | |
99 | - | |
100 | - @ApiOperation("导出年卡月卡统计excel") | |
101 | - @GetMapping("exportYearMonthStatisticExcel") | |
102 | - public void exportYearMonthStatisticExcel(@RequestParam Long beginTime, @RequestParam Long endTime, | |
103 | - @RequestParam List<String> parkIdList, @RequestParam String parkNames, | |
104 | - Integer orderType, Integer payType, Integer dataState, | |
105 | - HttpServletRequest requests, HttpServletResponse response) throws Exception { | |
106 | - | |
107 | - YearMonthCardStatisticRequest request = new YearMonthCardStatisticRequest(); | |
108 | - request.setSysCode(sysCode); | |
109 | - request.setBeginTime(new Date(beginTime)); | |
110 | - request.setEndTime(new Date(endTime)); | |
111 | - | |
112 | - request.setParkIdList(parkIdList); | |
113 | - request.setBaseRequest(new BaseInfo(1, 0)); | |
114 | - request.setOrderType(orderType); | |
115 | - request.setPayType(payType); | |
116 | - request.setDataState(dataState); | |
117 | - | |
118 | - BizResult<PageBean<YearMonthCardStatisticDTO>> bizResult = yearMonthCardStatisticService | |
119 | - .queryYearMonthCardStatistic(request); | |
120 | - BizResult<List<YearMonthCardStatisticSumDTO>> bizResultSum = yearMonthCardStatisticService | |
121 | - .queryYearMonthCardStatisticSum(request); | |
122 | - | |
123 | - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
124 | - SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); | |
125 | - String[] title = new String[] {"交易时间", "停车场", "类型", "车牌号", "支付方式", "支付金额", "有效期", "状态"}; | |
126 | - String sheetName = "年卡月卡统计"; | |
127 | - String fileName = "年卡月卡统计" + format2.format(new Date()); | |
128 | - | |
129 | - String[] billTitle = new String[9]; | |
130 | - billTitle = new String[2]; | |
131 | - //if (!org.springframework.util.CollectionUtils.isEmpty(bizResultSum.getData())) { | |
132 | - // List<YearMonthCardStatisticSumDTO> dtoList = bizResultSum.getData(); | |
133 | - // String amountsum = ""; | |
134 | - // String sum = ""; | |
135 | - // for (YearMonthCardStatisticSumDTO dto : dtoList) { | |
136 | - // amountsum = dto.getAmountSum() == null ? " " : dto.getAmountSum() + "," + amountsum; | |
137 | - // sum = dto.getOrderSum() + "," + sum; | |
138 | - // } | |
139 | - // String ordertype = ""; | |
140 | - // if (null != orderType) { | |
141 | - // if (2 == orderType) { | |
142 | - // ordertype = "年卡"; | |
143 | - // } else if (3 == orderType) { | |
144 | - // ordertype = "月卡"; | |
145 | - // } | |
146 | - // } | |
147 | - // String datastate = ""; | |
148 | - // if (null != dataState) { | |
149 | - // if (1 == dataState) { | |
150 | - // datastate = "有效"; | |
151 | - // } else if (0 == dataState) { | |
152 | - // datastate = "无效"; | |
153 | - // } | |
154 | - // } | |
155 | - // | |
156 | - billTitle[0] = "年卡月卡统计"; | |
157 | - // billTitle[1] = "汇总"; | |
158 | - // billTitle[2] = "停车场: " + parkNames; | |
159 | - // billTitle[3] = "时间: " + endTime; | |
160 | - // billTitle[4] = "类型:" + (orderType != null ? ordertype : ""); | |
161 | - // billTitle[5] = "状态: " + (dataState != null ? datastate : ""); | |
162 | - // billTitle[6] = "支付方式: " + (payType != null ? payType : ""); | |
163 | - // billTitle[7] = "每个月的总笔数" + sum; | |
164 | - // billTitle[8] = "每个月的总金额数" + amountsum; | |
165 | - //} else { | |
166 | - // billTitle[0] = "年卡月卡统计"; | |
167 | - // billTitle[1] = "汇总"; | |
168 | - // billTitle[2] = "停车场: "; | |
169 | - // billTitle[3] = "时间: "; | |
170 | - // billTitle[4] = "类型:"; | |
171 | - // billTitle[5] = "状态: "; | |
172 | - // billTitle[6] = "支付方式: "; | |
173 | - // billTitle[7] = "每个月的总车数"; | |
174 | - // billTitle[8] = "每个月的总金额数"; | |
175 | - //} | |
176 | - | |
177 | - // 1.创建excel信息 | |
178 | - XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | |
179 | - // 2.设置excel表头和表体 | |
180 | - Layouter.buildReport(workSheet, title,0,0); | |
181 | - // 3.填充数据 | |
182 | - List<Object[]> contentList = new ArrayList<Object[]>(); | |
183 | - List<YearMonthCardStatisticDTO> list = new ArrayList<>(); | |
184 | - if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) { | |
185 | - list = bizResult.getData().getDataList(); | |
186 | - } | |
187 | - for (YearMonthCardStatisticDTO e : list) { | |
188 | - Object[] obj = new Object[title.length]; | |
189 | - int index = 0; | |
190 | - obj[index++] = e.getPayFinishTime() != null ? format.format(e.getPayFinishTime()) : ""; | |
191 | - obj[index++] = e.getParkName(); | |
192 | - String cardType=""; | |
193 | - if (null != e.getOrderType()) { | |
194 | - if (2 == e.getOrderType()) { | |
195 | - cardType = "年卡"; | |
196 | - }else{ | |
197 | - cardType = "月卡"; | |
198 | - } | |
199 | - } | |
200 | - obj[index++]=cardType; | |
201 | - obj[index++] = e.getCarNumber(); | |
202 | - if (e.getPayType() != null) { | |
203 | - switch (e.getPayType()) { | |
204 | - case 1: | |
205 | - obj[index++] = "支付宝"; | |
206 | - break; | |
207 | - case 2: | |
208 | - obj[index++] = "微信"; | |
209 | - break; | |
210 | - case 3: | |
211 | - obj[index++] = "银联"; | |
212 | - break; | |
213 | - case 4: | |
214 | - obj[index++] = "微信"; | |
215 | - break; | |
216 | - default: | |
217 | - obj[index++] = "现金"; | |
218 | - break; | |
219 | - } | |
220 | - } else { | |
221 | - obj[index++] = ""; | |
222 | - } | |
223 | - obj[index++] = e.getAmount() != null ? e.getAmount() : "0.00"; | |
224 | - obj[index++] = e.getEffDate() != null ? format.format(e.getEffDate()) | |
225 | - : "" + "-" + e.getExpDate() != null ? format.format(e.getExpDate()) : ""; | |
226 | - //有效、无效 | |
227 | - Date d = new Date(); | |
228 | - String state = ""; | |
229 | - if ((d.getTime() <= e.getExpDate().getTime()) && (d.getTime() >= e.getEffDate().getTime())) { | |
230 | - state = "有效"; | |
231 | - } else { | |
232 | - state = "无效"; | |
233 | - } | |
234 | - obj[index++] = state; | |
235 | - contentList.add(obj); | |
236 | - } | |
237 | - ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); | |
238 | - fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); | |
239 | - // 4.excel输出配置 | |
240 | - ExcelUtil.write(response, workSheet, fileName); | |
241 | - } | |
242 | - | |
243 | -} |
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/parklotmanage/ParkLotManageController.java deleted
1 | -package com.zteits.irain.portal.web.parkinglotcloudplatform.parklotmanage; | |
2 | - | |
3 | -import java.util.List; | |
4 | -import java.util.Map; | |
5 | - | |
6 | -import javax.servlet.http.HttpSession; | |
7 | - | |
8 | -import org.apache.commons.lang3.StringUtils; | |
9 | -import org.slf4j.Logger; | |
10 | -import org.slf4j.LoggerFactory; | |
11 | -import org.springframework.beans.factory.annotation.Autowired; | |
12 | -import org.springframework.web.bind.annotation.GetMapping; | |
13 | -import org.springframework.web.bind.annotation.RequestMapping; | |
14 | -import org.springframework.web.bind.annotation.RequestParam; | |
15 | -import org.springframework.web.bind.annotation.RestController; | |
16 | - | |
17 | -import com.alibaba.dubbo.common.utils.CollectionUtils; | |
18 | -import com.clouds.common.cache.park.ParkingLotCacheUtil; | |
19 | -import com.clouds.common.entity.UserInfo; | |
20 | -import com.clouds.common.utils.ResultUtils; | |
21 | -import com.clouds.common.web.SessionCommUtil; | |
22 | -import com.clouds.common.web.vo.BizResultVO; | |
23 | -import com.google.common.collect.Lists; | |
24 | -import com.google.common.collect.Maps; | |
25 | -import com.zteits.clouds.api.apibase.bean.BizResult; | |
26 | -import com.zteits.clouds.api.apibase.constants.ErrorType; | |
27 | -import com.zteits.clouds.api.apibase.exception.BizException; | |
28 | -import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; | |
29 | -import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; | |
30 | -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; | |
31 | -import com.zteits.clouds.api.service.park.ParkingLotQueryService; | |
32 | -import com.zteits.clouds.api.service.pay.TdCustCompanyService; | |
33 | - | |
34 | -import io.swagger.annotations.Api; | |
35 | -import io.swagger.annotations.ApiOperation; | |
36 | - | |
37 | -/** | |
38 | - * 停车场管理 | |
39 | - * | |
40 | - * Copyright: Copyright (c) 2017 zteits | |
41 | - * | |
42 | - * @ClassName: ParkingLotController.java | |
43 | - * @Description: | |
44 | - * @version: v1.0.0 | |
45 | - * @author: zhaowg | |
46 | - * @date: 2017年6月16日 下午5:27:21 | |
47 | - * Modification History: | |
48 | - * Date Author Version Description | |
49 | - *---------------------------------------------------------* | |
50 | - * 2017年6月16日 zhaowg v1.0.0 创建 | |
51 | - */ | |
52 | -@Api(value="停车场管理",description="停车场管理") | |
53 | -@RestController | |
54 | -@RequestMapping("parkLotManage") | |
55 | -public class ParkLotManageController{ | |
56 | - private Logger logger = LoggerFactory.getLogger(ParkLotManageController.class); | |
57 | - @Autowired | |
58 | - private HttpSession session; | |
59 | - @Autowired | |
60 | - private SessionCommUtil sessionCommUtil; | |
61 | - @Autowired | |
62 | - private TdCustCompanyService tdCustCompanyService; | |
63 | - @Autowired | |
64 | - private ParkingLotQueryService parkingLotQueryService; | |
65 | - /** | |
66 | - * 根据登录人权限获取停车场名称列表 | |
67 | - * @return | |
68 | - * 2017年6月16日 zhaowg | |
69 | - * @throws Exception | |
70 | - */ | |
71 | - @ApiOperation("根据登录人权限获取停车场名称列表") | |
72 | - @GetMapping("getParkLotNamesByUserId") | |
73 | - public BizResultVO<List<Map<String,String>>> GetParkLotNameListByUserId(@RequestParam String sysCode) throws Exception { | |
74 | - List<Map<String,String>> result = Lists.newArrayList(); | |
75 | - //拥有的停车场编号 | |
76 | - List<String> plNos = this.GetParkLotNosByCurrUser(sysCode); | |
77 | - //查询对应的停车场信息 | |
78 | - if(CollectionUtils.isEmpty(plNos)){ | |
79 | - return new BizResultVO<List<Map<String,String>>>().setData(result); | |
80 | - } | |
81 | - for (String plNo : plNos) { | |
82 | - Map<String,String> plNoMap = Maps.newHashMap(); | |
83 | - //先查询缓存 | |
84 | - ParkingLotDTO lotDTO = ParkingLotCacheUtil.getParkLotByPlNo(plNo); | |
85 | - if(lotDTO == null){ | |
86 | - //查询数据库 | |
87 | - QueryParkLotInfoByPkNoRequest request = new QueryParkLotInfoByPkNoRequest(); | |
88 | - request.setSysCode(sysCode); | |
89 | - request.setPklNo(plNo); | |
90 | - BizResult<ParkingLotDTO> bizResult2 = parkingLotQueryService.QueryParkingLotByPkNo(request); | |
91 | - lotDTO = ResultUtils.getBizResultData(bizResult2); | |
92 | - } | |
93 | - if(lotDTO == null || StringUtils.isBlank(lotDTO.getPlName()) || lotDTO.getPlName().equals("null")){ | |
94 | - continue; | |
95 | - } | |
96 | - plNoMap.put("code",plNo ); | |
97 | - plNoMap.put("name",lotDTO.getPlName()); | |
98 | - result.add(plNoMap); | |
99 | - } | |
100 | - | |
101 | - return new BizResultVO<List<Map<String,String>>>().setData(result); | |
102 | - } | |
103 | - | |
104 | - private List<String> GetParkLotNosByCurrUser(String sysCode) throws Exception { | |
105 | - logger.info("根据登录人权限获取停车场列表"); | |
106 | - List<String> plNos = Lists.newArrayList(); | |
107 | - //2.调用接口查询当前登录人管辖的停车场名称 | |
108 | - UserInfo userInfo = sessionCommUtil.getUserInfo(); | |
109 | - if(userInfo!=null){ | |
110 | - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest(); | |
111 | - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds()); | |
112 | - tdCompanyParkQueryRequest.setSysCode(sysCode); | |
113 | - tdCompanyParkQueryRequest.setSessionId(session.getId()); | |
114 | - BizResult<List<String>> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest ); | |
115 | - plNos = ResultUtils.getBizResultData(bizResult); | |
116 | - }else{ | |
117 | - throw new BizException(ErrorType.AUTH_TOKEN_NOT_EXISTS); | |
118 | - } | |
119 | - return plNos; | |
120 | - } | |
121 | -} |