Commit 0e620522156a1dcc23ad230017e5a546b5a1090e

Authored by 潘钊
1 parent c519a399

update...

src/main/java/com/bsth/CXFConfig.java
... ... @@ -41,9 +41,16 @@ public class CXFConfig {
41 41 return new SpringBus();
42 42 }
43 43  
  44 + @Autowired
  45 + CompanyServiceSoap companyServiceSoap;
  46 + @Autowired
  47 + LD_ServiceSoap ld_serviceSoap;
  48 + @Autowired
  49 + AttendanceServiceSoap attendanceServiceSoap;
  50 +
44 51 @Bean
45 52 public Endpoint companyEndpoint() {
46   - EndpointImpl endpoint = new EndpointImpl(springBus(), new CompanyServiceSoap());
  53 + EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
47 54 endpoint.publish("/CompanyService");
48 55 //endpoint.getInInterceptors().add(new AuthInterceptor());
49 56 return endpoint;
... ... @@ -51,7 +58,7 @@ public class CXFConfig {
51 58  
52 59 @Bean
53 60 public Endpoint ldServiceEndpoint() {
54   - EndpointImpl endpoint = new EndpointImpl(springBus(), new LD_ServiceSoap());
  61 + EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
55 62 endpoint.publish("/LD_Service");
56 63 //endpoint.getInInterceptors().add(new AuthInterceptor());
57 64 return endpoint;
... ... @@ -59,21 +66,12 @@ public class CXFConfig {
59 66  
60 67 @Bean
61 68 public Endpoint attendanceServiceEndpoint() {
62   - EndpointImpl endpoint = new EndpointImpl(springBus(), new AttendanceServiceSoap());
  69 + EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
63 70 endpoint.publish("/attendanceService");
64 71 //endpoint.getInInterceptors().add(new AuthInterceptor());
65 72 return endpoint;
66 73 }
67 74  
68   -
69   -/* @Bean
70   - public Endpoint LineServiceEndpoint(){
71   - EndpointImpl endpoint = new EndpointImpl(springBus(), lineService());
72   - endpoint.publish("/data_line");
73   - //endpoint.getInInterceptors().add(new AuthInterceptor());
74   - return endpoint;
75   - }*/
76   -
77 75 @Autowired
78 76 ScheduleRealService scheduleRealService;
79 77 @Autowired
... ...
src/main/java/com/bsth/common/BusinessCodeData.java 0 → 100644
  1 +package com.bsth.common;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import org.springframework.stereotype.Component;
  5 +
  6 +import java.util.HashMap;
  7 +import java.util.Map;
  8 +import java.util.Set;
  9 +
  10 +/**
  11 + * 公司编码数据
  12 + * Created by panzhao on 2017/10/10.
  13 + */
  14 +@Component
  15 +public class BusinessCodeData {
  16 +
  17 + private static String str = "{\"22\": {\"name\": \"金高公司\",\"fgs\": {\"1\": \"四分公司\",\"2\": \"二分公司\",\"3\": \"三分公司\",\"5\": \"一分公司\"}},\"26\": {\"name\": \"南汇公司\",\"fgs\": {\"1\": \"南汇一分\",\"2\": \"南汇二分\",\"3\": \"南汇三分\",\"4\": \"南汇维修公司\",\"5\": \"南汇公司\"}},\"55\": {\"name\": \"上南公司\",\"fgs\": {\"1\": \"上南二分公司\",\"2\": \"上南三分公司\",\"3\": \"上南六分公司\",\"4\": \"上南一分公司\"}},\"05\": {\"name\": \"杨高公司\",\"fgs\": {\"1\": \"川沙分公司\",\"2\": \"金桥分公司\",\"3\": \"芦潮港分公司\",\"5\": \"杨高分公司\",\"6\": \"周浦分公司\"}},\"24\":{\"name\": \"嘉定公交\",\"fgs\": {\"1\": \"一车队\",\"2\": \"二车队\",\"3\": \"三车队\"}},\"77\": {\"name\": \"闵行公司\",\"fgs\": {\"78\": \"闵行公司\"}},\"99\": {\"name\": \"青浦公交\",\"fgs\": {\"100\": \"青浦公交\"}}}";
  18 + static JSONObject data;
  19 +
  20 + /**
  21 + * 编码和名称对照表
  22 + */
  23 + public static Map<String, String> code2Name;
  24 +
  25 + static{
  26 + data = JSONObject.parseObject(str);
  27 + code2Name = new HashMap<>();
  28 +
  29 + Set<String> ks = data.keySet(), fgsKs;
  30 + JSONObject subObj, fgsObj;
  31 + for(String k : ks){
  32 + subObj = JSONObject.parseObject(data.getString(k));
  33 + code2Name.put(k, subObj.getString("name"));
  34 +
  35 + //fgs
  36 + fgsObj = JSONObject.parseObject(subObj.getString("fgs"));
  37 + fgsKs = fgsObj.keySet();
  38 + for(String k2 : fgsKs){
  39 + code2Name.put(k + "_" + k2, fgsObj.getString(k2));
  40 + }
  41 + }
  42 + }
  43 +}
... ...
src/main/java/com/bsth/server_ws/electric_oil/OilService.java 0 → 100644
  1 +package com.bsth.server_ws.electric_oil;
  2 +
  3 +import com.bsth.server_ws.electric_oil.entity.ClsCDL;
  4 +
  5 +import javax.jws.WebService;
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * Created by panzhao on 2017/10/10.
  10 + */
  11 +@WebService(
  12 + name = "OilServiceSoap",
  13 + targetNamespace = "http://control.bsth.com/")
  14 +public interface OilService {
  15 +
  16 + /**
  17 + *
  18 + * @param fCheckBM 接口验证码为:BSTH@BSTH#BSTH 延续老接口密码
  19 + * @param fStationID 停车场ID
  20 + * @param fKWHInfoArr 冲电量信息
  21 + * @return
  22 + */
  23 + String upLoadKWHInfo(String fCheckBM, String fStationID, List<ClsCDL> fKWHInfoArr);
  24 +}
... ...
src/main/java/com/bsth/server_ws/electric_oil/OilServiceSoap.java 0 → 100644
  1 +package com.bsth.server_ws.electric_oil;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.bsth.server_ws.electric_oil.db.ElectricMultSaveUtil;
  5 +import com.bsth.server_ws.electric_oil.entity.ClsCDL;
  6 +import com.bsth.server_ws.electric_oil.entity.Electric;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import javax.jws.WebService;
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * Created by panzhao on 2017/10/10.
  17 + */
  18 +@Component
  19 +@WebService(
  20 + name = "OilServiceSoap",
  21 + portName = "OilServiceSoap",
  22 + serviceName = "OilService",
  23 + targetNamespace = "http://control.bsth.com/",
  24 + endpointInterface = "com.bsth.server_ws.electric_oil.OilService")
  25 +public class OilServiceSoap implements OilService {
  26 +
  27 + Logger logger = LoggerFactory.getLogger(this.getClass());
  28 +
  29 + @Autowired
  30 + ElectricMultSaveUtil electricMultSaveUtil;
  31 +
  32 + @Override
  33 + public String upLoadKWHInfo(String fCheckBM, String fStationID, List<ClsCDL> fKWHInfoArr) {
  34 + try{
  35 + logger.info("上传电量数据, id: " + fStationID + " data [" + JSON.toJSONString(fKWHInfoArr) + "]");
  36 + }catch (Exception e){
  37 + logger.error("", e);
  38 + }
  39 + //入库
  40 + try {
  41 + List<Electric> list = Electric.getMultInstance(fKWHInfoArr, fStationID);
  42 + electricMultSaveUtil.multSave(list);
  43 + }catch (Exception e){
  44 + logger.error("", e);
  45 + return "上传失败,server 端出现异常!";
  46 + }
  47 + return null;
  48 + }
  49 +}
... ...
src/main/java/com/bsth/server_ws/electric_oil/db/ElectricMultSaveUtil.java 0 → 100644
  1 +package com.bsth.server_ws.electric_oil.db;
  2 +
  3 +import com.bsth.server_ws.electric_oil.entity.Electric;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  8 +import org.springframework.jdbc.core.JdbcTemplate;
  9 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
  10 +import org.springframework.stereotype.Component;
  11 +import org.springframework.transaction.TransactionDefinition;
  12 +import org.springframework.transaction.TransactionStatus;
  13 +import org.springframework.transaction.support.DefaultTransactionDefinition;
  14 +
  15 +import java.sql.PreparedStatement;
  16 +import java.sql.SQLException;
  17 +import java.util.List;
  18 +
  19 +/**
  20 + * 电量信息批量入库
  21 + * Created by panzhao on 2017/10/10.
  22 + */
  23 +@Component
  24 +public class ElectricMultSaveUtil {
  25 +
  26 + @Autowired
  27 + JdbcTemplate jdbcTemplate;
  28 +
  29 + Logger logger = LoggerFactory.getLogger(this.getClass());
  30 +
  31 + public void multSave(final List<Electric> list) {
  32 + //编程式事务
  33 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  34 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  35 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  36 + TransactionStatus status = tran.getTransaction(def);
  37 +
  38 + try {
  39 + jdbcTemplate.batchUpdate("insert into bsth_c_jdl(fgs_bm, fgs_name, gs_bm, gs_name, jdl, jdz, remarks, rq, creater_date, nbbm) VALUES(?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() {
  40 + @Override
  41 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  42 + Electric e = list.get(i);
  43 + ps.setString(1, e.getFgsBm());
  44 + ps.setString(2, e.getFgsName());
  45 + ps.setString(3, e.getGsBm());
  46 + ps.setString(4, e.getGsName());
  47 + ps.setDouble(5, e.getJdl());
  48 + ps.setString(6, e.getJdz());
  49 + ps.setString(7, e.getRemarks());
  50 + ps.setDate(8, new java.sql.Date(e.getRq().getTime()));
  51 + ps.setDate(9, new java.sql.Date(e.getCreateDate().getTime()));
  52 + ps.setString(10, e.getNbbm());
  53 + }
  54 +
  55 + @Override
  56 + public int getBatchSize() {
  57 + return list.size();
  58 + }
  59 + });
  60 +
  61 + tran.commit(status);
  62 + } catch (Exception e) {
  63 + logger.error("", e);
  64 + tran.rollback(status);
  65 + }
  66 + }
  67 +}
... ...
src/main/java/com/bsth/server_ws/electric_oil/entity/ClsCDL.java 0 → 100644
  1 +package com.bsth.server_ws.electric_oil.entity;
  2 +
  3 +/**
  4 + *
  5 + * Created by panzhao on 2017/10/10.
  6 + */
  7 +public class ClsCDL {
  8 +
  9 + /**
  10 + * 营运日期
  11 + * YYYY-MM-DD
  12 + */
  13 + private String yyrq;
  14 +
  15 + /**
  16 + * 记录生成日期
  17 + * YYYY-MM-DD HH24:MI:SS
  18 + */
  19 + private String createRq;
  20 +
  21 + /**
  22 + * 车辆自编号
  23 + */
  24 + private String nbbm;
  25 +
  26 + /**
  27 + * 驾驶员工号
  28 + */
  29 + private String jsyGh;
  30 +
  31 + /**
  32 + * 充电量
  33 + */
  34 + private String cdl;
  35 +
  36 + public String getYyrq() {
  37 + return yyrq;
  38 + }
  39 +
  40 + public void setYyrq(String yyrq) {
  41 + this.yyrq = yyrq;
  42 + }
  43 +
  44 + public String getCreateRq() {
  45 + return createRq;
  46 + }
  47 +
  48 + public void setCreateRq(String createRq) {
  49 + this.createRq = createRq;
  50 + }
  51 +
  52 + public String getNbbm() {
  53 + return nbbm;
  54 + }
  55 +
  56 + public void setNbbm(String nbbm) {
  57 + this.nbbm = nbbm;
  58 + }
  59 +
  60 + public String getJsyGh() {
  61 + return jsyGh;
  62 + }
  63 +
  64 + public void setJsyGh(String jsyGh) {
  65 + this.jsyGh = jsyGh;
  66 + }
  67 +
  68 + public String getCdl() {
  69 + return cdl;
  70 + }
  71 +
  72 + public void setCdl(String cdl) {
  73 + this.cdl = cdl;
  74 + }
  75 +}
... ...
src/main/java/com/bsth/server_ws/electric_oil/entity/Electric.java 0 → 100644
  1 +package com.bsth.server_ws.electric_oil.entity;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.bsth.common.BusinessCodeData;
  5 +import com.bsth.server_rs.base_info.car.Car;
  6 +import com.bsth.server_rs.base_info.car.buffer.CarBufferData;
  7 +import org.joda.time.format.DateTimeFormat;
  8 +import org.joda.time.format.DateTimeFormatter;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +
  12 +import java.util.ArrayList;
  13 +import java.util.Date;
  14 +import java.util.List;
  15 +
  16 +/**
  17 + * 调度系统加电量表
  18 + * bsth_c_jdl
  19 + * Created by panzhao on 2017/10/10.
  20 + */
  21 +public class Electric {
  22 +
  23 + private Electric(){}
  24 +
  25 + static DateTimeFormatter fmtyyyyMMddHHmmss = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
  26 + static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  27 +
  28 + static Logger logger = LoggerFactory.getLogger(Electric.class);
  29 +
  30 + public static List<Electric> getMultInstance(List<ClsCDL> list, String stationId){
  31 + List<Electric> rs = new ArrayList<>();
  32 +
  33 + Electric e;
  34 + for(ClsCDL c : list){
  35 + e = getInstance(c);
  36 + if(null != e){
  37 + e.setJdz(stationId);
  38 + rs.add(e);
  39 + }
  40 + }
  41 + return rs;
  42 + }
  43 +
  44 + private static Electric getInstance(ClsCDL clsCDL){
  45 + String nbbm = clsCDL.getNbbm();
  46 + if(null == nbbm)
  47 + return null;
  48 +
  49 + try{
  50 + Car car = CarBufferData.findOne(clsCDL.getNbbm());
  51 +
  52 + Electric e = new Electric();
  53 + e.setGsBm(car.getCompanyCode());
  54 + e.setGsName(BusinessCodeData.code2Name.get(e.getGsBm()));
  55 + e.setFgsBm(car.getBrancheCompanyCode());
  56 + e.setFgsName(BusinessCodeData.code2Name.get(e.getFgsBm()));
  57 + e.setRq(fmtyyyyMMdd.parseDateTime(clsCDL.getYyrq()).toDate());
  58 + e.setCreateDate(fmtyyyyMMddHHmmss.parseDateTime(clsCDL.getCreateRq()).toDate());
  59 + e.setNbbm(nbbm);
  60 + e.setJdl(Double.parseDouble(clsCDL.getCdl()));
  61 + }catch (Exception e){
  62 + logger.error("异常数据;" + JSON.toJSONString(clsCDL));
  63 + }
  64 + return null;
  65 + }
  66 +
  67 + /**
  68 + * 公司编码
  69 + */
  70 + private String gsBm;
  71 +
  72 + /**
  73 + * 公司名称
  74 + */
  75 + private String gsName;
  76 +
  77 + /**
  78 + * 分公司编码
  79 + */
  80 + private String fgsBm;
  81 +
  82 + /**
  83 + * 分公司名称
  84 + */
  85 + private String fgsName;
  86 +
  87 + /**
  88 + * 车辆内部编码
  89 + */
  90 + private String nbbm;
  91 +
  92 + /**
  93 + * 加电站
  94 + */
  95 + private String jdz;
  96 +
  97 + /**
  98 + * 加电量
  99 + */
  100 + private Double jdl;
  101 +
  102 + /**
  103 + * 时间
  104 + */
  105 + private Date rq;
  106 +
  107 + /**
  108 + * 入库时间
  109 + */
  110 + private Date createDate;
  111 +
  112 + private String remarks = "接入数据";
  113 +
  114 + public String getGsBm() {
  115 + return gsBm;
  116 + }
  117 +
  118 + public void setGsBm(String gsBm) {
  119 + this.gsBm = gsBm;
  120 + }
  121 +
  122 + public String getGsName() {
  123 + return gsName;
  124 + }
  125 +
  126 + public void setGsName(String gsName) {
  127 + this.gsName = gsName;
  128 + }
  129 +
  130 + public String getFgsBm() {
  131 + return fgsBm;
  132 + }
  133 +
  134 + public void setFgsBm(String fgsBm) {
  135 + this.fgsBm = fgsBm;
  136 + }
  137 +
  138 + public String getFgsName() {
  139 + return fgsName;
  140 + }
  141 +
  142 + public void setFgsName(String fgsName) {
  143 + this.fgsName = fgsName;
  144 + }
  145 +
  146 + public String getNbbm() {
  147 + return nbbm;
  148 + }
  149 +
  150 + public void setNbbm(String nbbm) {
  151 + this.nbbm = nbbm;
  152 + }
  153 +
  154 + public String getJdz() {
  155 + return jdz;
  156 + }
  157 +
  158 + public void setJdz(String jdz) {
  159 + this.jdz = jdz;
  160 + }
  161 +
  162 + public Date getRq() {
  163 + return rq;
  164 + }
  165 +
  166 + public void setRq(Date rq) {
  167 + this.rq = rq;
  168 + }
  169 +
  170 + public Date getCreateDate() {
  171 + return createDate;
  172 + }
  173 +
  174 + public void setCreateDate(Date createDate) {
  175 + this.createDate = createDate;
  176 + }
  177 +
  178 + public String getRemarks() {
  179 + return remarks;
  180 + }
  181 +
  182 + public void setRemarks(String remarks) {
  183 + this.remarks = remarks;
  184 + }
  185 +
  186 + public Double getJdl() {
  187 + return jdl;
  188 + }
  189 +
  190 + public void setJdl(Double jdl) {
  191 + this.jdl = jdl;
  192 + }
  193 +}
... ...
src/main/java/com/bsth/server_ws/park_station/CompanyServiceSoap.java
... ... @@ -8,6 +8,7 @@ import com.bsth.server_ws.util.ControlHttpUtils;
8 8 import com.bsth.server_ws.util.WSDataConver;
9 9 import org.slf4j.Logger;
10 10 import org.slf4j.LoggerFactory;
  11 +import org.springframework.stereotype.Component;
11 12  
12 13 import javax.jws.WebMethod;
13 14 import javax.jws.WebService;
... ... @@ -19,7 +20,7 @@ import java.util.List;
19 20 * BS调度系统webservice接口实现,完美兼容老系统接口格式
20 21 * Created by panzhao on 2017/3/10.
21 22 */
22   -
  23 +@Component
23 24 @WebService(
24 25 name = "CompanyServiceSoap",
25 26 portName = "CompanyServiceSoap",
... ...
src/main/resources/application.properties
... ... @@ -14,5 +14,5 @@ multipart.maxRequestSize = -1
14 14 server.compression.enabled=true
15 15 server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript
16 16  
17   -#redis »º´æ¶àÉÙÌìµÄÊý¾Ý
  17 +#redis
18 18 cache.days=32
... ...