package com.bofeng.service; import com.bofeng.JwtHelper; import com.bofeng.dao.MsSuspectedMapper; import com.bofeng.dao.OutScanEstateMapper; import com.bofeng.dao.RbMapper; import com.bofeng.dao.SweepCodeMapper; import com.bofeng.entity.*; import com.yvan.PageDb; import com.yvan.platform.StringUtils; import org.apache.shiro.util.CollectionUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; @Service @Transactional(readOnly = true) public class SweepCodeService { @Autowired private SweepCodeMapper sweepCodeMapper; @Autowired private OutScanEstateMapper outScanEstateMapper; @Autowired private RbMapper rbMapper; @Autowired private MsSuspectedMapper msSuspectedMapper; @Autowired private MsReportService msReportService; @Autowired private ScanService scanService; public List selectCode(PageDb pageDb, Map queryParam) { List sysUptownHouses = sweepCodeMapper.selectCode(pageDb,queryParam); return sysUptownHouses; } // public List selectLingyunUser(PageDb pageDb, Map queryParam) { // Long userId = JwtHelper.getUserId(); // if (userId > 7000 && userId < 8000) { // queryParam.put("unitId", userId); // } // queryParam.put("uptownId", 1238790987234L); // List sysUptownHouses = sweepCodeMapper.selectLingyunUser(pageDb,queryParam); // return sysUptownHouses; // } public List selectLingyunUser(PageDb pageDb, Map queryParam, Long uptownId) throws ParseException { Long userId = JwtHelper.getUserId(); if (userId > 7000 && userId < 8000) { queryParam.put("unitId", userId); } queryParam.put("uptownId", uptownId); queryParam.put("orderStr", " suu.unit_id asc,suho.linkman "); List sysUptownHouses = rbMapper.exSelectLingyunUserPage(pageDb,queryParam); if (sysUptownHouses != null && sysUptownHouses.size() > 0) { String tripDet; for (ExcelRiBaoLYBM4 excelRiBaoLYBM4 : sysUptownHouses) { if (excelRiBaoLYBM4.getIsContact() == 0) { excelRiBaoLYBM4.setIsContactDesc("否"); } else if (excelRiBaoLYBM4.getIsContact() == 1) { excelRiBaoLYBM4.setIsContactDesc("是"); } if (excelRiBaoLYBM4.getIsSuspected() == 0) { excelRiBaoLYBM4.setIsSuspectedDesc("否"); } else if (excelRiBaoLYBM4.getIsSuspected() == 1) { excelRiBaoLYBM4.setIsSuspectedDesc("是"); } tripDet = ""; //出行详细 List listDet = msSuspectedMapper.selectTripSuspected(excelRiBaoLYBM4.getTripId()); if (listDet != null && listDet.size() > 0) { for (MsTripDet msTripDet : listDet) { tripDet += "出发地:" + msReportService.getLocalOther(msTripDet.getStartLocal(), msTripDet.getStartLocalOther()) + ","; tripDet += "目的地:" + msReportService.getLocalOther(msTripDet.getEndLocal(), msTripDet.getEndLocalOther()) + ","; tripDet += "出行方式:" + msReportService.getTripType(msTripDet.getTripType()) + ","; tripDet += "车次/航班/车牌:" + msTripDet.getTripTypeDesp() + ","; } excelRiBaoLYBM4.setTripDetDesc(tripDet.substring(0, tripDet.length() - 1)); } // 复工 excelRiBaoLYBM4.setReturnWork(scanService.returnWorkLYlist(excelRiBaoLYBM4.getUserId(), excelRiBaoLYBM4.getLinkman(), excelRiBaoLYBM4.getPhone())); } } return sysUptownHouses; } public List selectLingyunUserNotOnJob(PageDb pageDb, Map queryParam,Long notOnJob) throws ParseException { Long userId = JwtHelper.getUserId(); if (userId > 7000 && userId < 8000) { queryParam.put("unitId", userId); } queryParam.put("notOnJob", notOnJob); queryParam.put("orderStr", " op.create_at desc "); List sysUptownHouses = rbMapper.exSelectLingyunUserPage(pageDb,queryParam); if (sysUptownHouses != null && sysUptownHouses.size() > 0) { String tripDet; for (ExcelRiBaoLYBM4 excelRiBaoLYBM4 : sysUptownHouses) { if (excelRiBaoLYBM4.getIsContact() == 0) { excelRiBaoLYBM4.setIsContactDesc("否"); } else if (excelRiBaoLYBM4.getIsContact() == 1) { excelRiBaoLYBM4.setIsContactDesc("是"); } if (excelRiBaoLYBM4.getIsSuspected() == 0) { excelRiBaoLYBM4.setIsSuspectedDesc("否"); } else if (excelRiBaoLYBM4.getIsSuspected() == 1) { excelRiBaoLYBM4.setIsSuspectedDesc("是"); } tripDet = ""; //出行详细 List listDet = msSuspectedMapper.selectTripSuspected(excelRiBaoLYBM4.getTripId()); if (listDet != null && listDet.size() > 0) { for (MsTripDet msTripDet : listDet) { tripDet += "出发地:" + msReportService.getLocalOther(msTripDet.getStartLocal(), msTripDet.getStartLocalOther()) + ","; tripDet += "目的地:" + msReportService.getLocalOther(msTripDet.getEndLocal(), msTripDet.getEndLocalOther()) + ","; tripDet += "出行方式:" + msReportService.getTripType(msTripDet.getTripType()) + ","; tripDet += "车次/航班/车牌:" + msTripDet.getTripTypeDesp() + ","; } excelRiBaoLYBM4.setTripDetDesc(tripDet.substring(0, tripDet.length() - 1)); } // 复工 excelRiBaoLYBM4.setReturnWork(scanService.returnWorkLYlist(excelRiBaoLYBM4.getUserId(), excelRiBaoLYBM4.getLinkman(), excelRiBaoLYBM4.getPhone())); } } return sysUptownHouses; } public List HCUser(PageDb pageDb, Map queryParam) { queryParam.put("uptownId", 100000002L); List sysUptownHouses = rbMapper.exSelectLingyunUserPage(pageDb,queryParam); if (sysUptownHouses != null && sysUptownHouses.size() > 0) { String tripDet; for (ExcelRiBaoLYBM4 excelRiBaoLYBM4 : sysUptownHouses) { if (excelRiBaoLYBM4.getIsContact() == 0) { excelRiBaoLYBM4.setIsContactDesc("否"); } else if (excelRiBaoLYBM4.getIsContact() == 1) { excelRiBaoLYBM4.setIsContactDesc("是"); } if (excelRiBaoLYBM4.getIsSuspected() == 0) { excelRiBaoLYBM4.setIsSuspectedDesc("否"); } else if (excelRiBaoLYBM4.getIsSuspected() == 1) { excelRiBaoLYBM4.setIsSuspectedDesc("是"); } tripDet = ""; //出行详细 List listDet = msSuspectedMapper.selectTripSuspected(excelRiBaoLYBM4.getTripId()); if (listDet != null && listDet.size() > 0) { for (MsTripDet msTripDet : listDet) { tripDet += "出发地:" + msReportService.getLocalOther(msTripDet.getStartLocal(), msTripDet.getStartLocalOther()) + ","; tripDet += "目的地:" + msReportService.getLocalOther(msTripDet.getEndLocal(), msTripDet.getEndLocalOther()) + ","; tripDet += "出行方式:" + msReportService.getTripType(msTripDet.getTripType()) + ","; tripDet += "车次/航班/车牌:" + msTripDet.getTripTypeDesp() + ","; } excelRiBaoLYBM4.setTripDetDesc(tripDet.substring(0, tripDet.length() - 1)); } } } return sysUptownHouses; } public List selectLingyunUserHistory(PageDb pageDb, Long userId) { List sysUptownHouses = rbMapper.exSelectLingyunUserHistory(pageDb,userId); if (sysUptownHouses != null && sysUptownHouses.size() > 0) { String tripDet; for (ExcelRiBaoLYBM4 excelRiBaoLYBM4 : sysUptownHouses) { if (excelRiBaoLYBM4.getIsContact() == 0) { excelRiBaoLYBM4.setIsContactDesc("否"); } else if (excelRiBaoLYBM4.getIsContact() == 1) { excelRiBaoLYBM4.setIsContactDesc("是"); } if (excelRiBaoLYBM4.getIsSuspected() == 0) { excelRiBaoLYBM4.setIsSuspectedDesc("否"); } else if (excelRiBaoLYBM4.getIsSuspected() == 1) { excelRiBaoLYBM4.setIsSuspectedDesc("是"); } tripDet = ""; //出行详细 List listDet = msSuspectedMapper.selectTripSuspected(excelRiBaoLYBM4.getTripId()); if (listDet != null && listDet.size() > 0) { for (MsTripDet msTripDet : listDet) { tripDet += "出发地:" + msReportService.getLocalOther(msTripDet.getStartLocal(), msTripDet.getStartLocalOther()) + ","; tripDet += "目的地:" + msReportService.getLocalOther(msTripDet.getEndLocal(), msTripDet.getEndLocalOther()) + ","; tripDet += "出行方式:" + msReportService.getTripType(msTripDet.getTripType()) + ","; tripDet += "车次/航班/车牌:" + msTripDet.getTripTypeDesp() + ","; } excelRiBaoLYBM4.setTripDetDesc(tripDet.substring(0, tripDet.length() - 1)); } } } return sysUptownHouses; } public List exSelectLingyunUser(Map queryParam, Long uptownId) throws ParseException { queryParam.put("uptownId", uptownId); List sysUptownHouses = rbMapper.exSelectLingyunUser(queryParam); if (sysUptownHouses != null && sysUptownHouses.size() > 0) { String tripDet; for (ExcelRiBaoLYBM4 excelRiBaoLYBM4 : sysUptownHouses) { if (excelRiBaoLYBM4.getIsContact() == 0) { excelRiBaoLYBM4.setIsContactDesc("否"); } else if (excelRiBaoLYBM4.getIsContact() == 1) { excelRiBaoLYBM4.setIsContactDesc("是"); } if (excelRiBaoLYBM4.getIsSuspected() == 0) { excelRiBaoLYBM4.setIsSuspectedDesc("否"); } else if (excelRiBaoLYBM4.getIsSuspected() == 1) { excelRiBaoLYBM4.setIsSuspectedDesc("是"); } if (excelRiBaoLYBM4.getReportStatus() == 0) { excelRiBaoLYBM4.setReportStatusDesc("未上报"); } else if (excelRiBaoLYBM4.getMsStatus() == 1) { excelRiBaoLYBM4.setReportStatusDesc("正常"); } else { excelRiBaoLYBM4.setReportStatusDesc("异常"); } if(StringUtils.isNullOrEmpty(excelRiBaoLYBM4.getOldOpenId())){ excelRiBaoLYBM4.setIsBand("否"); }else{ excelRiBaoLYBM4.setIsBand("是"); } tripDet = ""; //出行详细 List listDet = msSuspectedMapper.selectTripSuspected(excelRiBaoLYBM4.getTripId()); if (listDet != null && listDet.size() > 0) { for (MsTripDet msTripDet : listDet) { tripDet += "出发地:" + msReportService.getLocalOther(msTripDet.getStartLocal(), msTripDet.getStartLocalOther()) + ","; tripDet += "目的地:" + msReportService.getLocalOther(msTripDet.getEndLocal(), msTripDet.getEndLocalOther()) + ","; tripDet += "出行方式:" + msReportService.getTripType(msTripDet.getTripType()) + ","; tripDet += "车次/航班/车牌:" + msTripDet.getTripTypeDesp() + ","; } excelRiBaoLYBM4.setTripDetDesc(tripDet.substring(0, tripDet.length() - 1)); }// 复工 excelRiBaoLYBM4.setReturnWork(scanService.returnWorkLYlist(excelRiBaoLYBM4.getUserId(), excelRiBaoLYBM4.getLinkman(), excelRiBaoLYBM4.getPhone())); if (excelRiBaoLYBM4.getReturnWork() == 1) { excelRiBaoLYBM4.setReturnWorkMsg("允许复工"); } else { excelRiBaoLYBM4.setReturnWorkMsg("禁止复工"); } } } return sysUptownHouses; } public List exSelectHCUser(Map queryParam) { queryParam.put("uptownId", 100000002L); List sysUptownHouses = rbMapper.exSelectHCUser(queryParam); if (sysUptownHouses != null && sysUptownHouses.size() > 0) { String tripDet; for (ExcelRiBaoHCBM4 excelRiBaoLYBM4 : sysUptownHouses) { if (excelRiBaoLYBM4.getIsContact() == 0) { excelRiBaoLYBM4.setIsContactDesc("否"); } else if (excelRiBaoLYBM4.getIsContact() == 1) { excelRiBaoLYBM4.setIsContactDesc("是"); } if (excelRiBaoLYBM4.getIsSuspected() == 0) { excelRiBaoLYBM4.setIsSuspectedDesc("否"); } else if (excelRiBaoLYBM4.getIsSuspected() == 1) { excelRiBaoLYBM4.setIsSuspectedDesc("是"); } tripDet = ""; //出行详细 List listDet = msSuspectedMapper.selectTripSuspected(excelRiBaoLYBM4.getTripId()); if (listDet != null && listDet.size() > 0) { for (MsTripDet msTripDet : listDet) { tripDet += "出发地:" + msReportService.getLocalOther(msTripDet.getStartLocal(), msTripDet.getStartLocalOther()) + ","; tripDet += "目的地:" + msReportService.getLocalOther(msTripDet.getEndLocal(), msTripDet.getEndLocalOther()) + ","; tripDet += "出行方式:" + msReportService.getTripType(msTripDet.getTripType()) + ","; tripDet += "车次/航班/车牌:" + msTripDet.getTripTypeDesp() + ","; } excelRiBaoLYBM4.setTripDetDesc(tripDet.substring(0, tripDet.length() - 1)); } } } return sysUptownHouses; } public List export(Map queryParam) { List sysUptownHouses = sweepCodeMapper.export(queryParam); if(sysUptownHouses.size() != 0){ for (int i = 0; i < sysUptownHouses.size(); i++) { if(sysUptownHouses.get(i).getInType() == 1 ){ sysUptownHouses.get(i).setInTypeStr("进入"); }else if(sysUptownHouses.get(i).getInType() == 2 ){ sysUptownHouses.get(i).setInTypeStr("外出"); } if(sysUptownHouses.get(i).getGoStatus() == 1 ){ sysUptownHouses.get(i).setGoStatusStr("允许"); }else if(sysUptownHouses.get(i).getGoStatus() == -1 ){ sysUptownHouses.get(i).setGoStatusStr("禁止"); } } } return sysUptownHouses; } public List selectCodeLY(PageDb pageDb, Map queryParam) { List sysUptownHouses = sweepCodeMapper.selectCodeLY(pageDb,queryParam); return sysUptownHouses; } public List exportLY(Map queryParam) { List sysUptownHouses = sweepCodeMapper.exportLY(queryParam); if(sysUptownHouses.size() != 0){ for (int i = 0; i < sysUptownHouses.size(); i++) { if(sysUptownHouses.get(i).getInType() == 1 ){ sysUptownHouses.get(i).setInTypeStr("进入"); }else if(sysUptownHouses.get(i).getInType() == 2 ){ sysUptownHouses.get(i).setInTypeStr("外出"); } if(sysUptownHouses.get(i).getGoStatus() == 1 ){ sysUptownHouses.get(i).setGoStatusStr("允许"); }else if(sysUptownHouses.get(i).getGoStatus() == -1 ){ sysUptownHouses.get(i).setGoStatusStr("禁止"); } } } return sysUptownHouses; } public List selectCodeHC(PageDb pageDb, Map queryParam) { List sysUptownHouses = sweepCodeMapper.selectCodeHC(pageDb,queryParam); return sysUptownHouses; } public List exportHC(Map queryParam) { List sysUptownHouses = sweepCodeMapper.exportHC(queryParam); if(sysUptownHouses.size() != 0){ for (int i = 0; i < sysUptownHouses.size(); i++) { if(sysUptownHouses.get(i).getInType() == 1 ){ sysUptownHouses.get(i).setInTypeStr("进入"); }else if(sysUptownHouses.get(i).getInType() == 2 ){ sysUptownHouses.get(i).setInTypeStr("外出"); } if(sysUptownHouses.get(i).getGoStatus() == 1 ){ sysUptownHouses.get(i).setGoStatusStr("允许"); }else if(sysUptownHouses.get(i).getGoStatus() == -1 ){ sysUptownHouses.get(i).setGoStatusStr("禁止"); } } } return sysUptownHouses; } public List selectClockLY(PageDb pageDb, Map queryParam) { queryParam.put("uptownId", 1238790987234L); Long userId = JwtHelper.getUserId(); if (userId > 7000 && userId < 8000) { queryParam.put("unitId", userId); } List list = sweepCodeMapper.selectClockLY(pageDb,queryParam); return list; } public List exSelectClockLY(Map queryParam) { queryParam.put("uptownId", 1238790987234L); List list = sweepCodeMapper.exSelectClockLY(queryParam); return list; } public List exClockCount(Map queryParam) { return sweepCodeMapper.exClockCount(queryParam); } public List selectXunJian(PageDb pageDb, Map queryParam) { List outScanEstates = outScanEstateMapper.selectXunJian(pageDb,queryParam); return outScanEstates; } public List exportXunJian(Map queryParam) { List outScanEstates = outScanEstateMapper.exportXunJian(queryParam); if(outScanEstates.size() != 0){ for (int i = 0; i < outScanEstates.size(); i++) { if(outScanEstates.get(i).getGoStatus() == 1 ){ outScanEstates.get(i).setGoStatusStr("允许"); }else if(outScanEstates.get(i).getGoStatus() == -1 ){ outScanEstates.get(i).setGoStatusStr("禁止"); } } } return outScanEstates; } /** * 复制list实体 list -> another list * @param target 目标list实体 * @param soucreList 源list实体 * @param * @param * @return */ public List listCopyToAotherList(Class target, List soucreList) { if (!CollectionUtils.isEmpty(soucreList)) { List targetList = new ArrayList<>(); for (T t : soucreList) { try { F f = target.newInstance(); BeanUtils.copyProperties(t, f); targetList.add(f); } catch (Exception e) { // } } return targetList; } else { return null; } } }