Commit d2454e1c authored by hanfeng's avatar hanfeng

修改违章,把查询到的车型代码和类型保存到数据库2

parent bd1d4e8f
...@@ -47,11 +47,9 @@ public class LicensePlateType implements Serializable { ...@@ -47,11 +47,9 @@ public class LicensePlateType implements Serializable {
private Date updateDate; private Date updateDate;
public LicensePlateType(String code, String type,Date createDate) { public LicensePlateType(String code, String type) {
this.code=code; this.code=code;
this.type=type; this.type=type;
this.createDate=createDate;
} }
......
...@@ -5,12 +5,14 @@ import com.xxfc.platform.universal.entity.LicensePlateType; ...@@ -5,12 +5,14 @@ import com.xxfc.platform.universal.entity.LicensePlateType;
import com.xxfc.platform.universal.entity.SearchableCity; import com.xxfc.platform.universal.entity.SearchableCity;
import com.xxfc.platform.universal.mapper.LicensePlateTypeMapper; import com.xxfc.platform.universal.mapper.LicensePlateTypeMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
@Service @Service
public class LicensePlateTypeBiz extends BaseBiz<LicensePlateTypeMapper, LicensePlateType> { public class LicensePlateTypeBiz extends BaseBiz<LicensePlateTypeMapper, LicensePlateType> {
@Transactional
public void insertLicensePlateType(ArrayList<LicensePlateType> licensePlateTypes) { public void insertLicensePlateType(ArrayList<LicensePlateType> licensePlateTypes) {
mapper.insertLicensePlateType(licensePlateTypes); mapper.insertLicensePlateType(licensePlateTypes);
} }
......
...@@ -49,7 +49,7 @@ public class TrafficViolationsController { ...@@ -49,7 +49,7 @@ public class TrafficViolationsController {
@GetMapping("/LicensePlateType") @GetMapping("/LicensePlateType")
public ObjectRestResponse getLicensePlateType() { public ObjectRestResponse getLicensePlateType() {
try { try {
return ObjectRestResponse.succ(JSONObject.parse(tvService.getLicensePlateType())); return ObjectRestResponse.succ(tvService.getLicensePlateType());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
......
...@@ -7,12 +7,14 @@ import com.xxfc.platform.universal.biz.SearchableCityBiz; ...@@ -7,12 +7,14 @@ import com.xxfc.platform.universal.biz.SearchableCityBiz;
import com.xxfc.platform.universal.entity.LicensePlateType; import com.xxfc.platform.universal.entity.LicensePlateType;
import com.xxfc.platform.universal.utils.CertifHttpUtils; import com.xxfc.platform.universal.utils.CertifHttpUtils;
import com.xxfc.platform.universal.vo.TrafficViolations; import com.xxfc.platform.universal.vo.TrafficViolations;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
...@@ -94,16 +96,11 @@ public class TrafficViolationsService { ...@@ -94,16 +96,11 @@ public class TrafficViolationsService {
} }
/** /**
* 查询车牌类型 * 放入bean中
*
* @return
* @throws Exception * @throws Exception
*
*/ */
public void saveLicensePlateType() throws Exception {
public void getLicensePlateType() throws Exception {
String result = searchaLicensePlateType(); String result = searchaLicensePlateType();
if (StringUtils.isBlank(result)) { if (StringUtils.isBlank(result)) {
throw new BaseException("错误! 查询不到车辆类型"); throw new BaseException("错误! 查询不到车辆类型");
} }
...@@ -115,7 +112,7 @@ public class TrafficViolationsService { ...@@ -115,7 +112,7 @@ public class TrafficViolationsService {
} }
ArrayList<LicensePlateType> licensePlateTypes=new ArrayList<>(); ArrayList<LicensePlateType> licensePlateTypes=new ArrayList<>();
for (Map.Entry<String, String> licensePlateTypeEntry : licensePlateTypeMap.entrySet()) { for (Map.Entry<String, String> licensePlateTypeEntry : licensePlateTypeMap.entrySet()) {
licensePlateTypes.add(new LicensePlateType(licensePlateTypeEntry.getKey(),licensePlateTypeEntry.getValue(),new Date())); licensePlateTypes.add(new LicensePlateType(licensePlateTypeEntry.getKey(),licensePlateTypeEntry.getValue()));
} }
licensePlateTypeBiz.insertLicensePlateType(licensePlateTypes); licensePlateTypeBiz.insertLicensePlateType(licensePlateTypes);
} }
...@@ -165,4 +162,12 @@ public class TrafficViolationsService { ...@@ -165,4 +162,12 @@ public class TrafficViolationsService {
HttpEntity entity = httpResponse.getEntity(); HttpEntity entity = httpResponse.getEntity();
return unicodeToString(EntityUtils.toString(entity)); return unicodeToString(EntityUtils.toString(entity));
} }
public ArrayList<LicensePlateType> getLicensePlateType() {
List<LicensePlateType> licensePlateTypes = licensePlateTypeBiz.selectListAll();
if (CollectionUtils.isEmpty(licensePlateTypes)) {
}
return null;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment