Commit d2454e1c authored by hanfeng's avatar hanfeng

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

parent bd1d4e8f
......@@ -47,11 +47,9 @@ public class LicensePlateType implements Serializable {
private Date updateDate;
public LicensePlateType(String code, String type,Date createDate) {
public LicensePlateType(String code, String type) {
this.code=code;
this.type=type;
this.createDate=createDate;
}
......
......@@ -5,12 +5,14 @@ import com.xxfc.platform.universal.entity.LicensePlateType;
import com.xxfc.platform.universal.entity.SearchableCity;
import com.xxfc.platform.universal.mapper.LicensePlateTypeMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
@Service
public class LicensePlateTypeBiz extends BaseBiz<LicensePlateTypeMapper, LicensePlateType> {
@Transactional
public void insertLicensePlateType(ArrayList<LicensePlateType> licensePlateTypes) {
mapper.insertLicensePlateType(licensePlateTypes);
}
......
......@@ -49,7 +49,7 @@ public class TrafficViolationsController {
@GetMapping("/LicensePlateType")
public ObjectRestResponse getLicensePlateType() {
try {
return ObjectRestResponse.succ(JSONObject.parse(tvService.getLicensePlateType()));
return ObjectRestResponse.succ(tvService.getLicensePlateType());
} catch (Exception e) {
e.printStackTrace();
return ObjectRestResponse.createDefaultFail();
......
......@@ -7,12 +7,14 @@ import com.xxfc.platform.universal.biz.SearchableCityBiz;
import com.xxfc.platform.universal.entity.LicensePlateType;
import com.xxfc.platform.universal.utils.CertifHttpUtils;
import com.xxfc.platform.universal.vo.TrafficViolations;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;
import java.util.*;
......@@ -94,16 +96,11 @@ public class TrafficViolationsService {
}
/**
* 查询车牌类型
*
* @return
* 放入bean中
* @throws Exception
*
*/
public void getLicensePlateType() throws Exception {
public void saveLicensePlateType() throws Exception {
String result = searchaLicensePlateType();
if (StringUtils.isBlank(result)) {
throw new BaseException("错误! 查询不到车辆类型");
}
......@@ -115,7 +112,7 @@ public class TrafficViolationsService {
}
ArrayList<LicensePlateType> licensePlateTypes=new ArrayList<>();
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);
}
......@@ -165,4 +162,12 @@ public class TrafficViolationsService {
HttpEntity entity = httpResponse.getEntity();
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