server/system_service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
@@ -2,6 +2,7 @@ import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; import com.doumee.core.utils.Constants; import lombok.AllArgsConstructor; import lombok.Data; import org.apache.poi.ss.usermodel.*; @@ -359,7 +360,7 @@ /** * é ç½®åå æ ¼è¾¹æ¡ */ private void configCellBorder (CellStyle style) { private static void configCellBorder(CellStyle style) { style.setBorderTop(BorderStyle.THIN); style.setBorderRight(BorderStyle.THIN); style.setBorderBottom(BorderStyle.THIN); @@ -428,4 +429,71 @@ private Field field; } /** * 导åºå°æå®è¾åºæµ * @param os è¾åºæµ */ public static void exportList (List<List<String>> dataList ,String sheetName, OutputStream os) { SXSSFWorkbook sxssfWorkbook; try { sxssfWorkbook = new SXSSFWorkbook(); Sheet sheet = sxssfWorkbook.createSheet(sheetName); // å建å头 sheet.createFreezePane(0, 1); Row header = sheet.createRow(0); CellStyle hstyle = configHeaderCellStatic(sxssfWorkbook); for (int i = 0; i < dataList.size(); i++) { Cell cell = header.createCell(i); cell.setCellValue(dataList.get(i).get(Constants.ZERO)); // å宽设置 sheet.setColumnWidth(i, dataList.get(i).get(Constants.ZERO).length() * 2 * 256); // 设置å头åå æ ¼ cell.setCellStyle(hstyle); } //æ»è¡æ° Integer rowSize = dataList.get(Constants.ZERO).size(); //æ»åæ° Integer columnSize = dataList.size(); for (int i = 1; i < rowSize; i++) { Row row = sheet.createRow(i); for (int j = 0; j < columnSize; j++) { Cell cell = row.createCell(j); cell.setCellValue(dataList.get(j).get(i)); } } sxssfWorkbook.write(os); os.close(); } catch (Exception e) { throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { e.printStackTrace(); } } } } private static CellStyle configHeaderCellStatic (SXSSFWorkbook workbook) { CellStyle style = workbook.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); // è®¾ç½®èæ¯ style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); // åä½ Font font = workbook.createFont(); font.setFontHeightInPoints((short) 12); style.setFont(font); // è®¾ç½®è¾¹æ¡ configCellBorder(style); return style; } } server/system_service/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -3602,4 +3602,13 @@ gc.setTime(date); return gc.get(2) + 1; } public static int getNowDayNum(){ // è·åCalendarå®ä¾ Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.DAY_OF_MONTH); } } server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/InoutRecordCloudController.java
@@ -5,7 +5,10 @@ import com.doumee.core.annotation.excel.ExcelExporter; import com.doumee.core.annotation.pr.PreventRepeat; import com.doumee.core.utils.Constants; import com.doumee.dao.business.dto.InParkDataDTO; import com.doumee.dao.business.model.InoutRecord; import com.doumee.dao.business.vo.GeneralDataVO; import com.doumee.dao.business.vo.InParkUserDataVO; import com.doumee.service.business.InoutRecordService; import com.doumee.service.business.third.model.ApiResponse; import com.doumee.service.business.third.model.PageData; @@ -88,4 +91,40 @@ public ApiResponse findById(@PathVariable Integer id) { return ApiResponse.success(inoutRecordService.findById(id)); } @ApiOperation("åºç¡æ°æ®") @PostMapping("/getInParkUserData") // @CloudRequiredPermission("business:inoutrecord:query") public ApiResponse<InParkUserDataVO> getInParkUserData (@RequestBody InParkDataDTO inParkDataDTO) { return ApiResponse.success(inoutRecordService.getInParkUserData(inParkDataDTO)); } @ApiOperation("å æ¯æ°æ®") @PostMapping("/getRataList") // @CloudRequiredPermission("business:inoutrecord:query") public ApiResponse<List<GeneralDataVO>> getRataList (@RequestBody InParkDataDTO inParkDataDTO) { return ApiResponse.success(inoutRecordService.getRataList(inParkDataDTO)); } @ApiOperation("æ¥è¡¨æ°æ®") @PostMapping("/getReportList") // @CloudRequiredPermission("business:inoutrecord:query") public ApiResponse<List<List<String>>> getReportList (@RequestBody InParkDataDTO inParkDataDTO) { return ApiResponse.success(inoutRecordService.getReportList(inParkDataDTO)); } @ApiOperation("å ¥åæ°æ®åæ-导åºExcel") @PostMapping("/reportExportExcel") // @CloudRequiredPermission("business:inoutrecord:query") public void reportExportExcel (@RequestBody InParkDataDTO inParkDataDTO, HttpServletResponse response) { inoutRecordService.excel(inParkDataDTO,response); } } server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/PlatformCloudController.java
@@ -251,7 +251,6 @@ public ApiResponse restoreWork (@RequestBody JobOperateDTO jobOperateDTO, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { jobOperateDTO.setLoginUserInfo(getLoginUser(token)); PlatformJob platformJob = platformJobService.restoreWork(jobOperateDTO); platformJobService.cancelInPark(platformJob); return ApiResponse.success("æä½æå"); } server/visits/dmvisit_service/src/main/java/com/doumee/dao/admin/response/PCWorkPlatformDataVO.java
@@ -40,6 +40,9 @@ @ApiModelProperty(value = "å¨åé¿æç¸å ³æ¹äººæ°") private Long inParkLwUserNum; @ApiModelProperty(value = "å¨åè´§è¿è½¦è¾å¸æºäººæ°") private Long inParkDriverUserNum; @ApiModelProperty(value = "ç¸å ³æ¹å ¥å人次") private Integer lwUserInNum; server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/InoutRecordMapper.java
@@ -2,11 +2,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.doumee.dao.business.model.InoutRecord; import com.github.yulichang.base.MPJBaseMapper; /** * @author æ±è¹è¹ * @date 2025/04/28 16:19 */ public interface InoutRecordMapper extends BaseMapper<InoutRecord> { public interface InoutRecordMapper extends MPJBaseMapper<InoutRecord> { } server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/dto/InParkDataDTO.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,26 @@ package com.doumee.dao.business.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * Created by IntelliJ IDEA. * * @Author : Rk * @create 2024/5/20 14:54 */ @Data public class InParkDataDTO { @ApiModelProperty(value = "æ¥è¯¢ç±»åï¼0è½¦è¾ 1人å") private Integer type; @ApiModelProperty(value = "人车类åï¼0=人次/车次;1=人å/车è¾") private Integer isGroupBy; @ApiModelProperty(value = "æ¥è¯¢æ¥æ å¹´ä»½å ¥ yyyy æä»½å ¥ yyyy-MM") private String dateStr; } server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/vo/GeneralDataVO.java
@@ -12,9 +12,15 @@ @Data public class GeneralDataVO{ @ApiModelProperty(value = "ä¸å¡ä¸»é®",hidden = true) private Integer id; @ApiModelProperty(value = "åç§°") private String name; @ApiModelProperty(value = "åç±»") private String categoryName; @ApiModelProperty(value = "æ°é") private Integer total ; server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/vo/HiddenDangerCompanyVO.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,22 @@ package com.doumee.dao.business.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data public class HiddenDangerCompanyVO { @ApiModelProperty(value = "ä¸å¡ä¸»é®",hidden = true) private Integer id; @ApiModelProperty(value = "åç±»") private String categoryName; public HiddenDangerCompanyVO(String categoryName, int id) { this.categoryName = categoryName; this.id = id; } } server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/vo/InParkUserDataVO.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,35 @@ package com.doumee.dao.business.vo; import java.util.List; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class InParkUserDataVO { @ApiModelProperty(value = "仿¥æ»æ°") private Integer todayTotal; @ApiModelProperty(value = "æ¨æ¥æ»æ°") private Integer yesterdayTotal; @ApiModelProperty(value = "æ¬å¨æ»æ°") private Integer weekTotal; @ApiModelProperty(value = "æ¬ææ»æ°") private Integer monthTotal; @ApiModelProperty(value = "æ¬å¹´æ»æ°") private Integer yearTotal; @ApiModelProperty(value = "åç±»å æ¯ - æå½¢å¾") List<GeneralDataVO> rataList; @ApiModelProperty(value = "æ¬å¹´ç´¯è®¡ç»è®¡") List<GeneralDataVO> cumulativeDataList; @ApiModelProperty(value = "å¹´åº¦å ¥åç»è®¡æåº") List<GeneralDataVO> yearSortList; } server/visits/dmvisit_service/src/main/java/com/doumee/service/business/InoutRecordService.java
@@ -1,9 +1,13 @@ package com.doumee.service.business; import com.doumee.dao.business.dto.InParkDataDTO; import com.doumee.dao.business.model.InoutRecord; import com.doumee.dao.business.vo.GeneralDataVO; import com.doumee.dao.business.vo.InParkUserDataVO; import com.doumee.service.business.third.model.PageData; import com.doumee.service.business.third.model.PageWrap; import javax.servlet.http.HttpServletResponse; import java.util.List; /** @@ -95,4 +99,12 @@ * @return long */ long count(InoutRecord inoutRecord); InParkUserDataVO getInParkUserData(InParkDataDTO inParkDataDTO); List<GeneralDataVO> getRataList(InParkDataDTO inParkDataDTO); List<List<String>> getReportList(InParkDataDTO inParkDataDTO); void excel(InParkDataDTO inParkDataDTO, HttpServletResponse response); } server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CarsServiceImpl.java
@@ -355,11 +355,26 @@ @Override public List<Cars> findList(Cars cars) { if(Objects.nonNull(cars) && Constants.equalsInteger(Constants.ZERO,cars.getType())){ return this.getGwCar(); } QueryWrapper<Cars> wrapper = new QueryWrapper<>(cars); wrapper.lambda().eq(Cars::getIsdeleted,Constants.ZERO); return carsMapper.selectList(wrapper); } public List<Cars> getGwCar(){ List<Cars> list = carsMapper.selectJoinList(Cars.class, new MPJLambdaWrapper<Cars>().selectAll(Cars.class) .leftJoin(Category.class,Category::getId,Cars::getCateId) .eq(Category::getBizType,Constants.FOUR) .eq(Cars::getIsdeleted,Constants.ZERO) ); return list; } @Override public PageData<Cars> findPage(PageWrap<Cars> pageWrap) { IPage<Cars> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/HiddenDangerServiceImpl.java
@@ -10,6 +10,7 @@ import com.doumee.core.exception.BusinessException; import com.doumee.dao.business.dao.*; import com.doumee.dao.business.vo.GeneralDataVO; import com.doumee.dao.business.vo.HiddenDangerCompanyVO; import com.doumee.dao.business.vo.HiddenDangerDataVO; import com.doumee.service.business.third.model.LoginUserInfo; import com.doumee.service.business.third.model.PageData; @@ -793,33 +794,30 @@ @Override public HiddenDangerDataVO hiddenDangerData(HiddenDanger hiddenDanger){ HiddenDangerDataVO hiddenDangerDataVO = new HiddenDangerDataVO(); List<HiddenDanger> hiddenDangerYearList = hiddenDangerMapper.selectJoinList(HiddenDanger.class, List<HiddenDanger> hiddenDangerAllList = hiddenDangerMapper.selectJoinList(HiddenDanger.class, new MPJLambdaWrapper<HiddenDanger>() .selectAll(HiddenDanger.class) .selectAs(HiddenDangerParam::getCompanyId, HiddenDanger::getAreaCompanyId) .leftJoin(HiddenDangerParam.class,HiddenDangerParam::getId,HiddenDanger::getAreaId) //鿣åºå .eq(HiddenDanger::getIsdeleted,Constants.ZERO) .eq(Objects.nonNull(hiddenDanger.getStatus()),HiddenDanger::getStatus,hiddenDanger.getStatus()) .apply(" ( DATE_FORMAT(CREATE_DATE, '%Y') = DATE_FORMAT(now(), '%Y') ) ") .apply(" ( DATE_FORMAT(t.CREATE_DATE, '%Y') = DATE_FORMAT(now(), '%Y') ) ") .ge(Objects.nonNull(hiddenDanger.getQueryStartTime()), HiddenDanger::getCreateDate,hiddenDanger.getQueryStartTime()) .le(Objects.nonNull(hiddenDanger.getQueryEndTime()),HiddenDanger::getCreateDate,hiddenDanger.getQueryEndTime()) ); List<GeneralDataVO> yearDataList = new ArrayList<>(); if(CollectionUtils.isEmpty(hiddenDangerYearList)){ if(CollectionUtils.isEmpty(hiddenDangerAllList)){ return hiddenDangerDataVO; } for (int i = 1; i <=12 ; i++) { GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(Integer.toString(i)); generalDataVO.setTotal(hiddenDangerYearList.stream().filter(j->Constants.equalsInteger(Integer.valueOf(generalDataVO.getName()),Integer.valueOf(DateUtil.formatDate(j.getCreateDate(),"MM")))).collect(Collectors.toList()).size()); generalDataVO.setTotal(hiddenDangerAllList.stream().filter(j->Constants.equalsInteger(Integer.valueOf(generalDataVO.getName()),Integer.valueOf(DateUtil.formatDate(j.getCreateDate(),"MM")))).collect(Collectors.toList()).size()); generalDataVO.setName(generalDataVO.getName()+"æ"); yearDataList.add(generalDataVO); } hiddenDangerDataVO.setYearList(yearDataList); List<HiddenDanger> hiddenDangerAllList = hiddenDangerYearList.stream().filter(i->DateUtil.formatDate(i.getCreateDate(),"yyyy-MM-dd").equals(DateUtil.formatDate(new Date(),"yyyy-MM-dd"))).collect(Collectors.toList()); if(CollectionUtils.isEmpty(hiddenDangerAllList)){ return hiddenDangerDataVO; } hiddenDangerDataVO.setTotal(hiddenDangerAllList.size()); @@ -859,22 +857,26 @@ } //å ¨é¨éæ£åºåé¨é¨æ°æ® List<Integer> companyIdList = hiddenDangerAllList.stream().map(i->i.getAreaCompanyId()).collect(Collectors.toList()); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(companyIdList)){ List<HiddenDangerCompanyVO> hiddenDangerCompanyVOList = hiddenDangerAllList.stream().map(i->new HiddenDangerCompanyVO(i.getAreaName(),i.getAreaCompanyId())).collect(Collectors.toList()); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(hiddenDangerCompanyVOList)){ List<GeneralDataVO> companyGeneralDataList = new ArrayList<>(); Set<Integer> companyIdSetList = new HashSet<>(companyIdList); Set<HiddenDangerCompanyVO> companyIdSetList = new HashSet<>(hiddenDangerCompanyVOList); List<Company> companyList = companyMapper.selectList(new QueryWrapper<Company>() .lambda().eq(Company::getIsdeleted,Constants.ZERO)); for (Integer companyId:companyIdSetList) { if(Objects.isNull(companyId)){ for (HiddenDangerCompanyVO hiddenDangerCompanyVO:companyIdSetList) { if(Objects.isNull(hiddenDangerCompanyVO) || Objects.isNull(hiddenDangerCompanyVO.getId()) || StringUtils.isBlank(hiddenDangerCompanyVO.getCategoryName())){ continue; } Optional<Company> optionalCompany = companyList.stream().filter(i->Constants.equalsInteger(i.getId(),companyId)).findAny(); Optional<Company> optionalCompany = companyList.stream().filter(i->Constants.equalsInteger(i.getId(),hiddenDangerCompanyVO.getId())).findAny(); if(optionalCompany.isPresent()){ GeneralDataVO generalDataVO = new GeneralDataVO(); Company company = optionalCompany.get(); Integer total = hiddenDangerAllList.stream().filter(i->Constants.equalsInteger(i.getAreaCompanyId(),company.getId())).collect(Collectors.toList()).size(); generalDataVO.setName(company.getName()); generalDataVO.setTotal(total); generalDataVO.setCategoryName(hiddenDangerCompanyVO.getCategoryName()); companyGeneralDataList.add(generalDataVO); } } server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/InoutRecordServiceImpl.java
@@ -1,8 +1,18 @@ package com.doumee.service.business.impl; import com.doumee.core.annotation.excel.ExcelExporter; import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; import com.doumee.core.utils.Constants; import com.doumee.core.utils.DateUtil; import com.doumee.core.utils.Utils; import com.doumee.dao.business.CategoryMapper; import com.doumee.dao.business.InoutRecordMapper; import com.doumee.dao.business.dto.InParkDataDTO; import com.doumee.dao.business.model.Category; import com.doumee.dao.business.model.InoutRecord; import com.doumee.dao.business.vo.GeneralDataVO; import com.doumee.dao.business.vo.InParkUserDataVO; import com.doumee.service.business.InoutRecordService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; @@ -10,11 +20,26 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.doumee.service.business.third.model.PageData; import com.doumee.service.business.third.model.PageWrap; import com.github.yulichang.wrapper.MPJLambdaWrapper; import io.swagger.annotations.ApiModelProperty; import io.swagger.models.auth.In; import org.apache.commons.lang.StringUtils; import org.checkerframework.checker.units.qual.C; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.List; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.charset.Charset; import java.text.DecimalFormat; import java.time.*; import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.stream.Collectors; /** * åºå ¥åºäººæ¬¡è½¦æ¬¡æ¯æ¥ç»è®¡è¡¨Serviceå®ç° @@ -26,6 +51,9 @@ @Autowired private InoutRecordMapper inoutRecordMapper; @Autowired private CategoryMapper categoryMapper; @Override public Integer create(InoutRecord inoutRecord) { @@ -172,4 +200,353 @@ QueryWrapper<InoutRecord> wrapper = new QueryWrapper<>(inoutRecord); return inoutRecordMapper.selectCount(wrapper); } //人ååç±» åç¬å¤çäººåæ°æ® 0å³å¡è®¿å®¢ 1æ®é访客 2å é¨åå·¥ 3车è¾ä¿¡æ¯ 4ç¸å ³æ¹äººå 5è´§è¿å¸æº private static String[] userTypeList = new String[]{"","æ®é访客","å é¨äººå","","ç¸å ³æ¹äººå","è´§è¿å¸æº"}; /** * æ¥è¯¢åºç¡æ°æ® * @return */ @Override public InParkUserDataVO getInParkUserData(InParkDataDTO inParkDataDTO){ if(Objects.isNull(inParkDataDTO) || Objects.isNull(inParkDataDTO.getType()) || Objects.isNull(inParkDataDTO.getIsGroupBy()) || (Objects.nonNull(inParkDataDTO.getType())&& !(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE) )) || (Objects.nonNull(inParkDataDTO.getIsGroupBy())&& !(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE) )) ){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } //æ¥è¯¢æ¬å¨çå¼å§æ¥æåç»ææ¥æ Long weekStart = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli(); InParkUserDataVO inParkUserDataVO = new InParkUserDataVO(); List<InoutRecord> yearList = inoutRecordMapper.selectJoinList(InoutRecord.class,new MPJLambdaWrapper<InoutRecord>() .selectAll(InoutRecord.class) .eq(InoutRecord::getIsdeleted,Constants.ZERO) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO),InoutRecord::getCarCode) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE),InoutRecord::getMemberPhone) .apply(" ( DATE_FORMAT(CREATE_DATE, '%Y') = DATE_FORMAT(now(), '%Y') ) ") ); List<InoutRecord> monthList = yearList.stream().filter(i->DateUtil.formatDate(i.getCreateDate(),"yyyy-MM").equals(DateUtil.formatDate(new Date(),"yyyy-MM"))).collect(Collectors.toList()); List<InoutRecord> weekList = yearList.stream().filter(i->i.getCreateDate().getTime()>=weekStart).collect(Collectors.toList()); List<InoutRecord> todayList = weekList.stream().filter(i-> DateUtil.formatDate(i.getCreateDate(),"yyyy-MM-dd").equals(DateUtil.formatDate(new Date(),"yyyy-MM-dd"))).collect(Collectors.toList()); List<InoutRecord> yesterdayList = yearList.stream().filter(i-> DateUtil.formatDate(i.getCreateDate(),"yyyy-MM-dd").equals(DateUtil.getBeforDay(new Date(),1))).collect(Collectors.toList()); if(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ZERO)){ inParkUserDataVO.setYearTotal(yearList.size()); inParkUserDataVO.setMonthTotal(monthList.size()); inParkUserDataVO.setTodayTotal(todayList.size()); inParkUserDataVO.setWeekTotal(weekList.size()); inParkUserDataVO.setYesterdayTotal(yesterdayList.size()); }else{ yearList = this.getListByType(yearList,inParkDataDTO.getType()); monthList = this.getListByType(monthList,inParkDataDTO.getType()); weekList = this.getListByType(weekList,inParkDataDTO.getType()); todayList = this.getListByType(todayList,inParkDataDTO.getType()); yesterdayList = this.getListByType(yesterdayList,inParkDataDTO.getType()); inParkUserDataVO.setYearTotal(yearList.size()); inParkUserDataVO.setMonthTotal(monthList.size()); inParkUserDataVO.setTodayTotal(todayList.size()); inParkUserDataVO.setWeekTotal(weekList.size()); inParkUserDataVO.setYesterdayTotal(yesterdayList.size()); } //å¤ç年度æçº¿å¾æ°æ® List<GeneralDataVO> cumulativeDataList = new ArrayList<>(); for (int i = 1; i <=12 ; i++) { GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(Integer.toString(i)); generalDataVO.setTotal(yearList.stream().filter(j->Constants.equalsInteger(Integer.valueOf(generalDataVO.getName()),Integer.valueOf(DateUtil.formatDate(j.getCreateDate(),"MM")))).collect(Collectors.toList()).size()); generalDataVO.setName(generalDataVO.getName()+"æ"); cumulativeDataList.add(generalDataVO); } inParkUserDataVO.setCumulativeDataList(cumulativeDataList); //å¤çåç±»æ°æ® List<GeneralDataVO> yearSortList = new ArrayList<>(); if(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE)){ for (int i = 0; i < userTypeList.length; i++) { if(StringUtils.isBlank(userTypeList[i])){ continue; } GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(userTypeList[i]); int index = i; generalDataVO.setTotal(yearList.stream().filter(j->Constants.equalsInteger(j.getType(), index)).collect(Collectors.toList()).size()); yearSortList.add(generalDataVO); } }else{ List<String> categoryNameList = yearList.stream().filter(i-> StringUtils.isNotBlank(i.getCategoryName())).map(i->i.getCategoryName()).collect(Collectors.toList()); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(categoryNameList)){ Set<String> setList = new HashSet<>(categoryNameList); for (String categoryName:setList) { GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(categoryName); generalDataVO.setTotal(yearList.stream().filter(j->StringUtils.isNotBlank(j.getCategoryName())&&j.getCategoryName().equals(categoryName)).collect(Collectors.toList()).size()); yearSortList.add(generalDataVO); } } } if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(yearSortList)){ Collections.sort(yearSortList, new Comparator<GeneralDataVO>() { @Override public int compare(GeneralDataVO o1, GeneralDataVO o2) { // è¿åå¼ä¸ºintç±»åï¼å¤§äº0表示æ£åºï¼å°äº0表示éåº return o2.getTotal() - o1.getTotal(); } }); inParkUserDataVO.setYearSortList(yearSortList); } return inParkUserDataVO; } /** * æ¥è¯¢å æ¯æ°æ® * @return */ @Override public List<GeneralDataVO> getRataList(InParkDataDTO inParkDataDTO){ if(Objects.isNull(inParkDataDTO) || Objects.isNull(inParkDataDTO.getType()) || Objects.isNull(inParkDataDTO.getIsGroupBy()) || StringUtils.isBlank(inParkDataDTO.getDateStr()) || (Objects.nonNull(inParkDataDTO.getType())&& !(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE) )) || (Objects.nonNull(inParkDataDTO.getIsGroupBy())&& !(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE) )) || !( Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4) || Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7) ) ){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } List<GeneralDataVO> rataList = new ArrayList<>(); List<InoutRecord> yearList = inoutRecordMapper.selectJoinList(InoutRecord.class,new MPJLambdaWrapper<InoutRecord>() .selectAll(InoutRecord.class) .eq(InoutRecord::getIsdeleted,Constants.ZERO) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO),InoutRecord::getCarCode) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE),InoutRecord::getMemberPhone) .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)," ( DATE_FORMAT(CREATE_DATE, '%Y') = '"+inParkDataDTO.getDateStr()+"' ) ") .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)," ( DATE_FORMAT(CREATE_DATE, '%Y-%m') = '"+inParkDataDTO.getDateStr()+"' ) ") ); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(yearList)){ return rataList; } if(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE)){ yearList = this.getListByType(yearList,inParkDataDTO.getType()); } if(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE)){ for (int i = 0; i < userTypeList.length; i++) { if(StringUtils.isBlank(userTypeList[i])){ continue; } GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(userTypeList[i]); int index = i; generalDataVO.setTotal(yearList.stream().filter(j->Constants.equalsInteger(j.getType(), index)).collect(Collectors.toList()).size()); generalDataVO.setRata(new BigDecimal(generalDataVO.getTotal().toString()).divide(new BigDecimal(yearList.size()+""),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))); rataList.add(generalDataVO); } }else{ List<String> categoryNameList = yearList.stream().filter(i-> StringUtils.isNotBlank(i.getCategoryParentName())).map(i->i.getCategoryParentName()).collect(Collectors.toList()); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(categoryNameList)){ Set<String> setList = new HashSet<>(categoryNameList); for (String categoryName:setList) { GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(categoryName); generalDataVO.setTotal(yearList.stream().filter(j->StringUtils.isNotBlank(j.getCategoryParentName())&&j.getCategoryName().equals(categoryName)).collect(Collectors.toList()).size()); generalDataVO.setRata(new BigDecimal(generalDataVO.getTotal().toString()).divide(new BigDecimal(yearList.size()+""),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))); rataList.add(generalDataVO); } } } return rataList; } @Override public List<List<String>> getReportList(InParkDataDTO inParkDataDTO){ if(Objects.isNull(inParkDataDTO) || Objects.isNull(inParkDataDTO.getType()) || Objects.isNull(inParkDataDTO.getIsGroupBy()) || StringUtils.isBlank(inParkDataDTO.getDateStr()) || (Objects.nonNull(inParkDataDTO.getType())&& !(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE) )) || (Objects.nonNull(inParkDataDTO.getIsGroupBy())&& !(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE) )) || !( Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4) || Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7) ) ){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } List<InoutRecord> allList = inoutRecordMapper.selectJoinList(InoutRecord.class,new MPJLambdaWrapper<InoutRecord>() .selectAll(InoutRecord.class) .eq(InoutRecord::getIsdeleted,Constants.ZERO) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO),InoutRecord::getCarCode) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE),InoutRecord::getMemberPhone) .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)," ( DATE_FORMAT(CREATE_DATE, '%Y') = '"+inParkDataDTO.getDateStr()+"' ) ") .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)," ( DATE_FORMAT(CREATE_DATE, '%Y-%m') = '"+inParkDataDTO.getDateStr()+"' ) ") ); List<List<String>> resultList = new ArrayList<>(); if(CollectionUtils.isEmpty(allList)){ return resultList; } if(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE)){ allList = this.getListByType(allList,inParkDataDTO.getType()); } List<String> dateList = new ArrayList<>(); //年份 if(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)){ Integer maxMonth = 12; if(Constants.equalsInteger(DateUtil.getNowYearNum(),Integer.valueOf(inParkDataDTO.getDateStr()))){ maxMonth = DateUtil.getNowMonthNum(); } for (int i = 1; i <= maxMonth; i++) { dateList.add(DateUtil.getNowYearNum()+"-"+ StringUtils.leftPad(i+"",2,"0")); } }else { //æ¥æ Integer year = Integer.valueOf(inParkDataDTO.getDateStr().substring(0,4)); Integer month = Integer.valueOf(inParkDataDTO.getDateStr().substring(5,6)); Integer today = DateUtil.getNowDayNum(); YearMonth yearMonth = YearMonth.of(year, month); // è·å该æçæåä¸å¤© LocalDate lastDayDate = yearMonth.atEndOfMonth(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); Integer lastDay = Integer.valueOf(lastDayDate.format(formatter)); if(Constants.equalsInteger(year,DateUtil.getNowYearNum()) && Constants.equalsInteger(month,DateUtil.getNowMonthNum())){ if(today < lastDay){ lastDay = today; } } for (int i = 1; i <= lastDay; i++) { dateList.add(year + "-" + StringUtils.leftPad(month.toString(),2,"0") + "-" + StringUtils.leftPad(lastDay.toString(),2,"0")); } } return this.dealResultData(allList,dateList,inParkDataDTO.getType(),inParkDataDTO.getDateStr()); } public List<List<String>> dealResultData(List<InoutRecord> allList,List<String> dataList ,Integer type,String dateStr){ List<List<String>> resultList = new ArrayList<>(); List<String> totalString = new ArrayList<>(); totalString.add("æ¥æ"); if(Constants.equalsInteger(type,Constants.ZERO)){ List<String> categoryNameList = allList.stream().filter(j-> StringUtils.isNotBlank(j.getCategoryName())).map(j->j.getCategoryName()).collect(Collectors.toList()); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(categoryNameList)){ return resultList; } Set<String> setList = new HashSet<>(categoryNameList); for (String categoryName:setList) { totalString.add(categoryName); } totalString.add("å计"); resultList.add(totalString); Integer total = 0; for (String str:dataList) { for (String categoryName:setList) { List<String> dataChildList = new ArrayList<>(); dataChildList.add(str); if(Constants.equalsInteger(dateStr.length(),4)){ Integer childNum = allList.stream().filter(i->categoryName.equals(i.getCategoryName()) && DateUtil.formatDate(i.getCreateDate(),"yyyy-MM").equals(str)).collect(Collectors.toList()).size(); dataChildList.add( Integer.toString(childNum) ); total = total + childNum; }else if(Constants.equalsInteger(dateStr.length(),7)){ Integer childNum = allList.stream().filter(i->categoryName.equals(i.getCategoryName()) &&DateUtil.formatDate(i.getCreateDate(),"yyyy-MM-dd").equals(str)).collect(Collectors.toList()).size(); dataChildList.add( Integer.toString(childNum) ); total = total + childNum; } dataChildList.add(Integer.toString(total)); resultList.add(dataChildList); } } }else{ for (int j = 0; j < userTypeList.length; j++) { if(StringUtils.isBlank(userTypeList[j])){ continue; } totalString.add(userTypeList[j]); totalString.add("å计"); resultList.add(totalString); } Integer total = 0; for (String str:dataList) { for (String typeName:userTypeList) { List<String> dataChildList = new ArrayList<>(); dataChildList.add(str); if(Constants.equalsInteger(dateStr.length(),4)){ Integer childNum = allList.stream().filter(i->typeName.equals(i.getCategoryName()) && DateUtil.formatDate(i.getCreateDate(),"yyyy-MM").equals(str)).collect(Collectors.toList()).size(); dataChildList.add( Integer.toString(childNum) ); total = total + childNum; }else if(Constants.equalsInteger(dateStr.length(),7)){ Integer childNum = allList.stream().filter(i->typeName.equals(i.getCategoryName()) &&DateUtil.formatDate(i.getCreateDate(),"yyyy-MM-dd").equals(str)).collect(Collectors.toList()).size(); dataChildList.add( Integer.toString(childNum) ); total = total + childNum; } dataChildList.add(Integer.toString(total)); resultList.add(dataChildList); } } } return resultList; } public List<InoutRecord> getListByType(List<InoutRecord> list,Integer type){ return Constants.equalsInteger(type,Constants.ONE)?this.getDataByMemberPhoneSize(list):this.getDataByCarCodeSize(list); } public List<InoutRecord> getDataByMemberPhoneSize(List<InoutRecord> list){ Map<String, InoutRecord> uniqueByMemberPhone = list.stream() .collect(Collectors.toMap( InoutRecord::getMemberPhone, person -> person, (existing, replacement) -> existing )); List<InoutRecord> uniqueList = new ArrayList<>(uniqueByMemberPhone.values()); return uniqueList; } public List<InoutRecord> getDataByCarCodeSize(List<InoutRecord> list){ Map<String, InoutRecord> uniqueByCarCode = list.stream() .collect(Collectors.toMap( InoutRecord::getCarCode, person -> person, (existing, replacement) -> existing )); List<InoutRecord> uniqueList = new ArrayList<>(uniqueByCarCode.values()); return uniqueList; } @Override public void excel(InParkDataDTO inParkDataDTO, HttpServletResponse response){ List<List<String>> data = this.getReportList(inParkDataDTO); try { String fileName = Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO)?"å ¥å车è¾ç»è®¡è¡¨_":"å ¥å人åç»è®¡è¡¨_"+System.currentTimeMillis(); String encodeFileName = URLEncoder.encode(fileName, Charset.forName("UTF-8").toString()) + ".xlsx"; response.setHeader("Content-Disposition","attachment;filename=" + encodeFileName); response.setContentType("application/octet-stream"); response.setHeader("eva-opera-type", "download"); response.setHeader("eva-download-filename", encodeFileName); ExcelExporter.exportList(data, fileName, response.getOutputStream()); } catch (IOException e) { throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e); } } } server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java
@@ -2472,5 +2472,37 @@ } @Override @Transactional(rollbackFor = {Exception.class,BusinessException.class}) public PlatformJob restoreWork(JobOperateDTO jobOperateDTO){ if(Objects.isNull(jobOperateDTO) || Objects.isNull(jobOperateDTO.getJobId())){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } PlatformJob platformJob = platformJobMapper.selectById(jobOperateDTO.getJobId()); if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ throw new BusinessException(ResponseStatus.DATA_EMPTY); } if(!Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.EXCEPTION.getKey())){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对ä¸èµ·,ä¸å¡ç¶æå·²æµè½¬ï¼"); } Platform platform = platformJoinMapper.selectById(platformJob.getPlatformId()); if(Objects.isNull(platform)){ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"æªæ¥è¯¢å°æå°ä¿¡æ¯"); } PlatformJob oldPlatformJob = new PlatformJob(); BeanUtils.copyProperties(platformJob,oldPlatformJob); if(Objects.isNull(platformJob.getStartDate())){ platformJob.setStartDate(new Date()); } platformJob.setStatus(Constants.PlatformJobStatus.WORKING.getKey()); platformJob.setEditDate(new Date()); platformJobMapper.updateById(platformJob); //å卿使¥å¿ savePlatformLog(Constants.PlatformJobLogType.WORKING.getKey(),oldPlatformJob,platformJob, Constants.PlatformJobLogType.WORKING.getInfo().replace("{data}",platform.getName())); return platformJob; } } server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java
@@ -128,6 +128,8 @@ @Autowired private InoutDayCountMapper inoutDayCountMapper; @Autowired private InoutRecordMapper inoutRecordMapper; @Autowired private CarEventMapper carEventMapper; @Autowired @@ -1809,10 +1811,14 @@ .apply(" DATE(TIME_INFO) = CURDATE() ") .last(" limit 1 ") ); //仿¥å¨åäººæ° pcWorkPlatformDataVO.setTodayInParkUserNum( retentionList.stream().filter(i->!Constants.equalsInteger(i.getType(),Constants.THREE)).count() inoutRecordMapper.selectCount(new QueryWrapper<InoutRecord>().lambda() .isNotNull(InoutRecord::getMemberPhone) .isNull(InoutRecord::getCarCode) .apply( " DATE(TIME_INFO) = CURDATE() " )) //retentionList.stream().filter(i->!Constants.equalsInteger(i.getType(),Constants.THREE)).count() ); pcWorkPlatformDataVO.setTodayInUserNum(Constants.ZERO); @@ -1820,8 +1826,13 @@ //å¨åé¿æç¸å ³æ¹äººæ° pcWorkPlatformDataVO.setInParkLwUserNum( retentionList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.TWO) && Constants.equalsInteger(i.getCompanyType(),Constants.ZERO)).count() inoutRecordMapper.selectCount(new QueryWrapper<InoutRecord>().lambda() .eq(InoutRecord::getMemberType,Constants.TWO) .isNotNull(InoutRecord::getMemberPhone) .isNull(InoutRecord::getCarCode) .apply( " DATE(TIME_INFO) = CURDATE() " )) // retentionList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.TWO) // && Constants.equalsInteger(i.getCompanyType(),Constants.ZERO)).count() ); pcWorkPlatformDataVO.setLwUserInNum(Constants.ZERO); pcWorkPlatformDataVO.setLwUserOutNum(Constants.ZERO); @@ -1829,14 +1840,30 @@ //å¨å访客æ°é pcWorkPlatformDataVO.setInParkVisitUserNum( retentionList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ONE)&&Objects.isNull(i.getCompanyType())).count() inoutRecordMapper.selectCount(new QueryWrapper<InoutRecord>().lambda() .eq(InoutRecord::getMemberType,Constants.ZERO) .isNotNull(InoutRecord::getMemberPhone) .isNull(InoutRecord::getCarCode) .apply( " DATE(TIME_INFO) = CURDATE() " )) //retentionList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ONE)&&Objects.isNull(i.getCompanyType())).count() ); pcWorkPlatformDataVO.setVisitUserNum(Constants.ZERO); pcWorkPlatformDataVO.setSignLevelNum(Constants.ZERO); //å¨åè´§è¿è½¦è¾å¸æº pcWorkPlatformDataVO.setInParkDriverUserNum(inoutRecordMapper.selectCount(new QueryWrapper<InoutRecord>().lambda() .eq(InoutRecord::getMemberType,Constants.THREE) .isNotNull(InoutRecord::getMemberPhone) .isNull(InoutRecord::getCarCode) .apply( " DATE(TIME_INFO) = CURDATE() " ))); //å¨åè½¦è¾ pcWorkPlatformDataVO.setTodayInParkCarNum( retentionList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.THREE)).count() inoutRecordMapper.selectCount(new QueryWrapper<InoutRecord>().lambda() .isNotNull(InoutRecord::getCarCode) .isNull(InoutRecord::getMemberPhone) .apply( " DATE(TIME_INFO) = CURDATE() " )) //retentionList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.THREE)).count() ); pcWorkPlatformDataVO.setTodayInCarNum(Constants.ZERO); pcWorkPlatformDataVO.setTodayOutCarNum(Constants.ZERO);