Commit dbcc28c903d0a3116b9c729587369b3c01160a98
1 parent
d4231a2f
充电量接口接入到集调的表中
# Conflicts: # src/main/java/com/bsth/server_rs/electric/ElectricService.java
Showing
1 changed file
with
51 additions
and
1 deletions
src/main/java/com/bsth/server_rs/electric/ElectricService.java
| 1 | 1 | package com.bsth.server_rs.electric; |
| 2 | 2 | |
| 3 | +import com.alibaba.fastjson.JSONObject; | |
| 4 | +import com.bsth.entity.JdlReception; | |
| 5 | +import com.bsth.repository.JdlReceptionRepository; | |
| 3 | 6 | import com.bsth.server_ws.electric_oil.entity.Electric; |
| 4 | 7 | import org.slf4j.Logger; |
| 5 | 8 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -7,13 +10,19 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 7 | 10 | import org.springframework.jdbc.core.BeanPropertyRowMapper; |
| 8 | 11 | import org.springframework.jdbc.core.JdbcTemplate; |
| 9 | 12 | import org.springframework.stereotype.Component; |
| 13 | +import org.springframework.web.bind.annotation.RequestBody; | |
| 10 | 14 | |
| 11 | 15 | import javax.ws.rs.GET; |
| 16 | +import javax.ws.rs.POST; | |
| 12 | 17 | import javax.ws.rs.Path; |
| 13 | 18 | import javax.ws.rs.PathParam; |
| 14 | 19 | import javax.ws.rs.Produces; |
| 15 | 20 | import javax.ws.rs.core.MediaType; |
| 21 | + | |
| 22 | +import java.util.Date; | |
| 23 | +import java.util.HashMap; | |
| 16 | 24 | import java.util.List; |
| 25 | +import java.util.Map; | |
| 17 | 26 | |
| 18 | 27 | /** |
| 19 | 28 | * Created by panzhao on 2018/3/27. |
| ... | ... | @@ -27,6 +36,9 @@ public class ElectricService { |
| 27 | 36 | |
| 28 | 37 | @Autowired |
| 29 | 38 | JdbcTemplate jdbcTemplate; |
| 39 | + | |
| 40 | + @Autowired | |
| 41 | + JdlReceptionRepository jdlReceptionRepository; | |
| 30 | 42 | |
| 31 | 43 | @GET |
| 32 | 44 | @Path("/{company}/{rq}") |
| ... | ... | @@ -39,8 +51,46 @@ public class ElectricService { |
| 39 | 51 | list = jdbcTemplate.query("select fgsdm as fgs_bm,c.business_name as fgs_name,ssgsdm as gs_bm,b.business_name as gs_name,cdl as jdl,'' as jdz,'' as remarks,rq,createtime as create_date,nbbm,'' as jsy from (select fgsdm,ssgsdm,sum(cdl * 1000) / 1000 as cdl,rq,max(createtime) as createtime,nbbm from bsth_c_dlb where rq = '" + rq + "' GROUP BY fgsdm,ssgsdm,rq,nbbm) a left join bsth_c_business b on a.ssgsdm = b.business_code LEFT JOIN bsth_c_business c on concat(a.ssgsdm, '_', a.fgsdm) = concat(c.up_code, '_', c.business_code) where ssgsdm="+company |
| 40 | 52 | , BeanPropertyRowMapper.newInstance(Electric.class)); |
| 41 | 53 | }catch (Exception e){ |
| 42 | - logger.error("", e); | |
| 54 | + logger.error("ElectricService", e); | |
| 43 | 55 | } |
| 44 | 56 | return list; |
| 45 | 57 | } |
| 58 | + | |
| 59 | + @POST | |
| 60 | + @Path("/orderDataEnter") | |
| 61 | + public Map<String, Object> orderDataEnter(@RequestBody JSONObject body){ | |
| 62 | + Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 63 | + try { | |
| 64 | + JdlReception jdlReception = new JdlReception(); | |
| 65 | + jdlReception.setStationName(body.getString("StationName")); | |
| 66 | + jdlReception.setConnectorId(body.getString("ConnectorID")); | |
| 67 | + jdlReception.setOrderNo(body.getString("OrderNo")); | |
| 68 | + jdlReception.setStartTime(body.getString("StartTime")); | |
| 69 | + jdlReception.setEndTime(body.getString("EndTime")); | |
| 70 | + jdlReception.setStartSoc(body.getDouble("StartSoc")); | |
| 71 | + jdlReception.setEndSoc(body.getDouble("EndSoc")); | |
| 72 | + jdlReception.setStopReason(body.getString("StopReason")); | |
| 73 | + jdlReception.setChargeCapacity(body.getDouble("ChargeCapacity")); | |
| 74 | + jdlReception.setElectricCharge(body.getDouble("ElectricCharge")); | |
| 75 | + jdlReception.setServiceCharge(body.getDouble("ServiceCharge")); | |
| 76 | + jdlReception.setTotalAmount(body.getDouble("TotalAmount")); | |
| 77 | + jdlReception.setVinCode(body.getString("VinCode")); | |
| 78 | + jdlReception.setCardNo(body.getString("CardNo")); | |
| 79 | + jdlReception.setCarCode(body.getString("CarCode")); | |
| 80 | + jdlReception.setOrigin(0); | |
| 81 | + jdlReception.setCreateBy("接口接入"); | |
| 82 | + jdlReception.setCreateDate(new Date()); | |
| 83 | + jdlReceptionRepository.save(jdlReception); | |
| 84 | + | |
| 85 | + resMap.put("Status", 0); | |
| 86 | + resMap.put("msg", "成功"); | |
| 87 | + }catch (Exception e){ | |
| 88 | + logger.error("ElectricService.orderDataEnter", body); | |
| 89 | + logger.error("ElectricService.orderDataEnter", e); | |
| 90 | + resMap.put("Status", 1); | |
| 91 | + resMap.put("Msg", "内部错误"); | |
| 92 | + } | |
| 93 | + return resMap; | |
| 94 | + } | |
| 95 | + | |
| 46 | 96 | } | ... | ... |