Commit c8d5c77017ae284170a0a4470bbb7853f8fe4433
1 parent
79b3a7cd
纯电车日报表统计电量和百公里能耗。
Showing
4 changed files
with
320 additions
and
3 deletions
src/main/java/com/bsth/entity/oil/JdlReception.java
0 → 100644
| 1 | +package com.bsth.entity.oil; | |
| 2 | + | |
| 3 | +import java.util.Date; | |
| 4 | + | |
| 5 | +import javax.persistence.Entity; | |
| 6 | +import javax.persistence.GeneratedValue; | |
| 7 | +import javax.persistence.GenerationType; | |
| 8 | +import javax.persistence.Id; | |
| 9 | +import javax.persistence.Table; | |
| 10 | + | |
| 11 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 12 | + | |
| 13 | +/** | |
| 14 | +-------------------------------------------------------- | |
| 15 | + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', | |
| 16 | + `station_name` varchar(255) DEFAULT NULL COMMENT '站点名称', | |
| 17 | + `connector_id` varchar(255) DEFAULT NULL COMMENT '枪编号', | |
| 18 | + `order_no` varchar(255) DEFAULT NULL COMMENT '订单编号', | |
| 19 | + `start_time` varchar(255) DEFAULT NULL COMMENT '充电开始时间', | |
| 20 | + `end_time` varchar(255) DEFAULT NULL COMMENT '充电结束时间', | |
| 21 | + `start_soc` double(11,2) DEFAULT NULL COMMENT '开始 SOC(%)', | |
| 22 | + `end_soc` double(11,2) DEFAULT NULL COMMENT '结束 SOC(%)', | |
| 23 | + `stop_reason` varchar(255) DEFAULT NULL COMMENT '终止原因', | |
| 24 | + `charge_capacity` double(11,3) DEFAULT NULL COMMENT '充电量,单位:度', | |
| 25 | + `electric_charge` double(11,2) DEFAULT NULL COMMENT '电费,单位:元', | |
| 26 | + `service_charge` double(11,2) DEFAULT NULL COMMENT '服务费,单位:元', | |
| 27 | + `total_amount` double(11,2) DEFAULT NULL COMMENT '总费用,单位:元', | |
| 28 | + `vin_code` varchar(255) DEFAULT NULL COMMENT '卡号', | |
| 29 | + `card_no` varchar(255) DEFAULT NULL COMMENT 'VIN,车架号', | |
| 30 | + `car_code` varchar(255) DEFAULT NULL COMMENT '自编号', | |
| 31 | + `car_plate` varchar(255) DEFAULT NULL COMMENT '牌照号', | |
| 32 | + `date_str` varchar(255) DEFAULT NULL COMMENT '营运日期', | |
| 33 | + `origin` int(2) NOT NULL DEFAULT '0' COMMENT '数据源(0:接口获取;1:导入)', | |
| 34 | + `sum_time` bigint(11) DEFAULT NULL COMMENT '总计充电时间(分钟)', | |
| 35 | + `create_by` varchar(255) DEFAULT NULL COMMENT '创建人', | |
| 36 | + `create_date` datetime DEFAULT NULL COMMENT '创建时间', | |
| 37 | + `update_by` varchar(255) DEFAULT NULL COMMENT '修改人', | |
| 38 | + `update_date` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', | |
| 39 | +*/ | |
| 40 | +@Entity | |
| 41 | +@Table(name = "bsth_c_jdl_reception") | |
| 42 | +public class JdlReception { | |
| 43 | + @Id | |
| 44 | + @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| 45 | + private Long id; | |
| 46 | + private String stationName; | |
| 47 | + private String connectorId; | |
| 48 | + private String orderNo; | |
| 49 | + private String startTime; | |
| 50 | + private String endTime; | |
| 51 | + private Double startSoc; | |
| 52 | + private Double endSoc; | |
| 53 | + private String stopReason; | |
| 54 | + private Double chargeCapacity; | |
| 55 | + private Double electricCharge; | |
| 56 | + private Double serviceCharge; | |
| 57 | + private Double totalAmount; | |
| 58 | + private String vinCode; | |
| 59 | + private String cardNo; | |
| 60 | + private String carCode; | |
| 61 | + private String carPlate; | |
| 62 | + private String dateStr; | |
| 63 | + private Integer origin; | |
| 64 | + private Integer sumTime; | |
| 65 | + private String createBy; | |
| 66 | + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") | |
| 67 | + private Date createDate; | |
| 68 | + private String updateBy; | |
| 69 | + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") | |
| 70 | + private Date updateDate; | |
| 71 | + | |
| 72 | + | |
| 73 | + public Long getId() { | |
| 74 | + return id; | |
| 75 | + } | |
| 76 | + public void setId(Long id) { | |
| 77 | + this.id = id; | |
| 78 | + } | |
| 79 | + public String getStationName() { | |
| 80 | + return stationName; | |
| 81 | + } | |
| 82 | + public void setStationName(String stationName) { | |
| 83 | + this.stationName = stationName; | |
| 84 | + } | |
| 85 | + public String getConnectorId() { | |
| 86 | + return connectorId; | |
| 87 | + } | |
| 88 | + public void setConnectorId(String connectorId) { | |
| 89 | + this.connectorId = connectorId; | |
| 90 | + } | |
| 91 | + public String getOrderNo() { | |
| 92 | + return orderNo; | |
| 93 | + } | |
| 94 | + public void setOrderNo(String orderNo) { | |
| 95 | + this.orderNo = orderNo; | |
| 96 | + } | |
| 97 | + public String getStartTime() { | |
| 98 | + return startTime; | |
| 99 | + } | |
| 100 | + public void setStartTime(String startTime) { | |
| 101 | + this.startTime = startTime; | |
| 102 | + } | |
| 103 | + public String getEndTime() { | |
| 104 | + return endTime; | |
| 105 | + } | |
| 106 | + public void setEndTime(String endTime) { | |
| 107 | + this.endTime = endTime; | |
| 108 | + } | |
| 109 | + public Double getStartSoc() { | |
| 110 | + return startSoc; | |
| 111 | + } | |
| 112 | + public void setStartSoc(Double startSoc) { | |
| 113 | + this.startSoc = startSoc; | |
| 114 | + } | |
| 115 | + public Double getEndSoc() { | |
| 116 | + return endSoc; | |
| 117 | + } | |
| 118 | + public void setEndSoc(Double endSoc) { | |
| 119 | + this.endSoc = endSoc; | |
| 120 | + } | |
| 121 | + public String getStopReason() { | |
| 122 | + return stopReason; | |
| 123 | + } | |
| 124 | + public void setStopReason(String stopReason) { | |
| 125 | + this.stopReason = stopReason; | |
| 126 | + } | |
| 127 | + public Double getChargeCapacity() { | |
| 128 | + return chargeCapacity; | |
| 129 | + } | |
| 130 | + public void setChargeCapacity(Double chargeCapacity) { | |
| 131 | + this.chargeCapacity = chargeCapacity; | |
| 132 | + } | |
| 133 | + public Double getElectricCharge() { | |
| 134 | + return electricCharge; | |
| 135 | + } | |
| 136 | + public void setElectricCharge(Double electricCharge) { | |
| 137 | + this.electricCharge = electricCharge; | |
| 138 | + } | |
| 139 | + public Double getServiceCharge() { | |
| 140 | + return serviceCharge; | |
| 141 | + } | |
| 142 | + public void setServiceCharge(Double serviceCharge) { | |
| 143 | + this.serviceCharge = serviceCharge; | |
| 144 | + } | |
| 145 | + public Double getTotalAmount() { | |
| 146 | + return totalAmount; | |
| 147 | + } | |
| 148 | + public void setTotalAmount(Double totalAmount) { | |
| 149 | + this.totalAmount = totalAmount; | |
| 150 | + } | |
| 151 | + public String getVinCode() { | |
| 152 | + return vinCode; | |
| 153 | + } | |
| 154 | + public void setVinCode(String vinCode) { | |
| 155 | + this.vinCode = vinCode; | |
| 156 | + } | |
| 157 | + public String getCardNo() { | |
| 158 | + return cardNo; | |
| 159 | + } | |
| 160 | + public void setCardNo(String cardNo) { | |
| 161 | + this.cardNo = cardNo; | |
| 162 | + } | |
| 163 | + public String getCarCode() { | |
| 164 | + return carCode; | |
| 165 | + } | |
| 166 | + public void setCarCode(String carCode) { | |
| 167 | + this.carCode = carCode; | |
| 168 | + } | |
| 169 | + public String getCarPlate() { | |
| 170 | + return carPlate; | |
| 171 | + } | |
| 172 | + public void setCarPlate(String carPlate) { | |
| 173 | + this.carPlate = carPlate; | |
| 174 | + } | |
| 175 | + public String getDateStr() { | |
| 176 | + return dateStr; | |
| 177 | + } | |
| 178 | + public void setDateStr(String dateStr) { | |
| 179 | + this.dateStr = dateStr; | |
| 180 | + } | |
| 181 | + public Integer getOrigin() { | |
| 182 | + return origin; | |
| 183 | + } | |
| 184 | + public void setOrigin(Integer origin) { | |
| 185 | + this.origin = origin; | |
| 186 | + } | |
| 187 | + public Integer getSumTime() { | |
| 188 | + return sumTime; | |
| 189 | + } | |
| 190 | + public void setSumTime(Integer sumTime) { | |
| 191 | + this.sumTime = sumTime; | |
| 192 | + } | |
| 193 | + public String getCreateBy() { | |
| 194 | + return createBy; | |
| 195 | + } | |
| 196 | + public void setCreateBy(String createBy) { | |
| 197 | + this.createBy = createBy; | |
| 198 | + } | |
| 199 | + public Date getCreateDate() { | |
| 200 | + return createDate; | |
| 201 | + } | |
| 202 | + public void setCreateDate(Date createDate) { | |
| 203 | + this.createDate = createDate; | |
| 204 | + } | |
| 205 | + public String getUpdateBy() { | |
| 206 | + return updateBy; | |
| 207 | + } | |
| 208 | + public void setUpdateBy(String updateBy) { | |
| 209 | + this.updateBy = updateBy; | |
| 210 | + } | |
| 211 | + public Date getUpdateDate() { | |
| 212 | + return updateDate; | |
| 213 | + } | |
| 214 | + public void setUpdateDate(Date updateDate) { | |
| 215 | + this.updateDate = updateDate; | |
| 216 | + } | |
| 217 | + | |
| 218 | +} | |
| 0 | 219 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/repository/oil/JdlReceptionRepository.java
0 → 100644
| 1 | +package com.bsth.repository.oil; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +import org.springframework.data.jpa.repository.Query; | |
| 6 | +import org.springframework.data.repository.PagingAndSortingRepository; | |
| 7 | +import org.springframework.stereotype.Repository; | |
| 8 | + | |
| 9 | +import com.bsth.entity.oil.JdlReception; | |
| 10 | + | |
| 11 | +@Repository | |
| 12 | +public interface JdlReceptionRepository extends PagingAndSortingRepository<JdlReception, Integer>{ | |
| 13 | + | |
| 14 | + @Query(value="SELECT j FROM JdlReception j where j.dateStr = ?") | |
| 15 | + List<JdlReception> queryListByDateStr(String dateStr); | |
| 16 | + | |
| 17 | +} | |
| 0 | 18 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/service/impl/RefuelServiceImpl.java
| ... | ... | @@ -2,10 +2,13 @@ package com.bsth.service.impl; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.entity.Cars; |
| 4 | 4 | import com.bsth.entity.Refuel; |
| 5 | +import com.bsth.entity.oil.JdlReception; | |
| 5 | 6 | import com.bsth.entity.realcontrol.ChildTaskPlan; |
| 6 | 7 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 7 | 8 | import com.bsth.entity.sys.SysUser; |
| 8 | 9 | import com.bsth.repository.RefuelRepository; |
| 10 | +import com.bsth.repository.oil.JdlReceptionRepository; | |
| 11 | +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | |
| 9 | 12 | import com.bsth.security.util.SecurityUtils; |
| 10 | 13 | import com.bsth.service.RefuelService; |
| 11 | 14 | import com.bsth.service.report.CulateMileageService; |
| ... | ... | @@ -43,6 +46,12 @@ public class RefuelServiceImpl extends BaseServiceImpl<Refuel, Long> implements |
| 43 | 46 | |
| 44 | 47 | @Autowired |
| 45 | 48 | private RefuelRepository repository; |
| 49 | + | |
| 50 | + @Autowired | |
| 51 | + private JdlReceptionRepository jdlReceptionRepository; | |
| 52 | + | |
| 53 | + @Autowired | |
| 54 | + private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 46 | 55 | |
| 47 | 56 | @Autowired |
| 48 | 57 | private CulateMileageService culateMileageService; |
| ... | ... | @@ -903,12 +912,13 @@ public class RefuelServiceImpl extends BaseServiceImpl<Refuel, Long> implements |
| 903 | 912 | m.put("in", ""); |
| 904 | 913 | m.put("jdl", ""); |
| 905 | 914 | m.put("hdl", ""); |
| 915 | + m.put("bglnh", ""); | |
| 916 | + m.put("consume", ""); | |
| 906 | 917 | m.put("realMileage", realMileage); |
| 907 | 918 | m.put("ksMileage", ksMileage); |
| 908 | 919 | m.put("ssMileage", ssMileage); |
| 909 | 920 | m.put("ljgl", ljgl); |
| 910 | 921 | m.put("sjssgl", Arith.sub(ssMileage, ljgl)); // 实际损失公里(损失公里-加车公里,20250808青浦巴士工单) |
| 911 | - m.put("consume", ""); | |
| 912 | 922 | m.put("bc", bc); |
| 913 | 923 | m.put("yybc", Integer.valueOf(sjbc)+Integer.valueOf(ljbc)); |
| 914 | 924 | m.put("jhbc", jhbc); |
| ... | ... | @@ -928,12 +938,12 @@ public class RefuelServiceImpl extends BaseServiceImpl<Refuel, Long> implements |
| 928 | 938 | lastMap.put("in", ""); |
| 929 | 939 | lastMap.put("jdl", ""); |
| 930 | 940 | lastMap.put("hdl", ""); |
| 941 | + lastMap.put("consume", ""); | |
| 931 | 942 | lastMap.put("realMileage", realMileage_z); |
| 932 | 943 | lastMap.put("ksMileage", ksMileage_z); |
| 933 | 944 | lastMap.put("ssMileage", ssMileage_z); |
| 934 | 945 | lastMap.put("ljgl", ljgl_z); |
| 935 | 946 | lastMap.put("sjssgl", Arith.sub(ssMileage_z, ljgl_z)+""); // 实际损失公里(损失公里-加车公里,20250808青浦巴士工单) |
| 936 | - lastMap.put("consume", ""); | |
| 937 | 947 | lastMap.put("bc", bc_z); |
| 938 | 948 | lastMap.put("yybc", yybc_z); |
| 939 | 949 | lastMap.put("jhbc", jhbc_z); |
| ... | ... | @@ -941,6 +951,78 @@ public class RefuelServiceImpl extends BaseServiceImpl<Refuel, Long> implements |
| 941 | 951 | lastMap.put("cr", cr_z); |
| 942 | 952 | lastMap.put("remark", ""); |
| 943 | 953 | |
| 954 | +// Map<String, Double> mileageMap = new HashMap<String, Double>(); | |
| 955 | + Set<String> carSet = new HashSet<String>(); | |
| 956 | + for(Map<String, Object> m : resList){ // 合计还未添加进去前 | |
| 957 | + String carCode = m.get("car").toString(); | |
| 958 | + carSet.add(carCode); | |
| 959 | + } | |
| 960 | + | |
| 961 | + List<ScheduleRealInfo> scheduleDayList = scheduleRealInfoRepository.findByDate(date); | |
| 962 | + Map<String, List<ScheduleRealInfo>> scheduleDayMap = new HashMap<String, List<ScheduleRealInfo>>(); | |
| 963 | + for(ScheduleRealInfo s : scheduleDayList){ | |
| 964 | + String carCode = s.getClZbh(); | |
| 965 | + if(carSet.contains(carCode) && !scheduleDayMap.containsKey(carCode)){ | |
| 966 | + scheduleDayMap.put(carCode, new ArrayList<ScheduleRealInfo>()); | |
| 967 | + } | |
| 968 | + scheduleDayMap.get(carCode).add(s); | |
| 969 | + } | |
| 970 | + Map<String, Double> mileageMap = new HashMap<String, Double>(); | |
| 971 | + for(String carCode : scheduleDayMap.keySet()){ | |
| 972 | + List<ScheduleRealInfo> tempList = scheduleDayMap.get(carCode); | |
| 973 | + Double sjgl = culateMileageService.culateSjgl(tempList); | |
| 974 | + Double ksgl = culateMileageService.culateKsgl(tempList); | |
| 975 | + Double jccgl = culateMileageService.culateJccgl(tempList); | |
| 976 | + Double ljgl = culateMileageService.culateLjgl(tempList); | |
| 977 | + Double realMileage = Arith.add(Arith.add(sjgl, ksgl), Arith.add(jccgl, ljgl)); | |
| 978 | + mileageMap.put(carCode, realMileage); | |
| 979 | + } | |
| 980 | + | |
| 981 | + List<JdlReception> queryListByDateStr = jdlReceptionRepository.queryListByDateStr(date); | |
| 982 | + Map<String, Double> jdlMap = new HashMap<String, Double>(); | |
| 983 | + for(JdlReception j : queryListByDateStr){ | |
| 984 | + if(j.getCarCode() != null && j.getCarCode().trim().length() > 0 | |
| 985 | + && j.getChargeCapacity() != null){ | |
| 986 | + String carCode = j.getCarCode().trim(); | |
| 987 | + if(carSet.contains(carCode) && !jdlMap.containsKey(carCode)){ | |
| 988 | + jdlMap.put(carCode, 0d); | |
| 989 | + } | |
| 990 | + jdlMap.put(carCode, Arith.add(jdlMap.get(carCode), j.getChargeCapacity())); | |
| 991 | + } | |
| 992 | + } | |
| 993 | + | |
| 994 | + String nh_z = ""; | |
| 995 | + for(Map<String, Object> m : resList){ | |
| 996 | + if(m.containsKey("realMileage") && m.get("realMileage").toString().length() > 0){ | |
| 997 | + String realMileage = m.get("realMileage").toString(); | |
| 998 | + String carCode = m.get("car").toString(); | |
| 999 | + if(mileageMap.containsKey(carCode) && jdlMap.containsKey(carCode)){ | |
| 1000 | + Double mileageAll = mileageMap.get(carCode); | |
| 1001 | + Double jdlAll = jdlMap.get(carCode); | |
| 1002 | + if(Arith.compareTo(mileageAll, 0D) == 1){ | |
| 1003 | + double nh = Arith.mul(jdlAll, Arith.div(realMileage, mileageAll, 3)); | |
| 1004 | + nh = Arith.round(nh, 3); | |
| 1005 | + m.put("jdl", nh); | |
| 1006 | + m.put("hdl", nh); | |
| 1007 | + | |
| 1008 | + if(Arith.compareTo(realMileage, 0D) == 1){ | |
| 1009 | + double bglnh = Arith.mul(Arith.div(nh, realMileage, 5), 100); | |
| 1010 | + m.put("consume", bglnh); | |
| 1011 | + } | |
| 1012 | + | |
| 1013 | + nh_z = Arith.add(nh_z.length() == 0?0D:nh_z, nh) + ""; | |
| 1014 | + } | |
| 1015 | + } | |
| 1016 | + } | |
| 1017 | + } | |
| 1018 | + | |
| 1019 | + lastMap.put("jdl", nh_z); | |
| 1020 | + lastMap.put("hdl", nh_z); | |
| 1021 | + if(nh_z.length() > 0 && realMileage_z.length() > 0 && Arith.compareTo(realMileage_z, 0D) == 1){ | |
| 1022 | + double bglnh = Arith.mul(Arith.div(nh_z, realMileage_z, 5), 100); | |
| 1023 | + lastMap.put("consume", bglnh); | |
| 1024 | + } | |
| 1025 | + | |
| 944 | 1026 | resList.add(lastMap); |
| 945 | 1027 | |
| 946 | 1028 | return resList; | ... | ... |
src/main/resources/static/pages/forms/statement/refuelDc.html