You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
449 lines
17 KiB
449 lines
17 KiB
package com.bweb.controller.Etc;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.hai.common.exception.ErrorCode;
|
|
import com.hai.common.exception.ErrorHelp;
|
|
import com.hai.common.exception.SysCode;
|
|
import com.hai.common.security.SessionObject;
|
|
import com.hai.common.security.UserCenter;
|
|
import com.hai.common.utils.DateUtil;
|
|
import com.hai.common.utils.ResponseMsgUtil;
|
|
import com.hai.config.EtcService;
|
|
import com.hai.entity.*;
|
|
import com.hai.enum_type.CarTypeEnum;
|
|
import com.hai.etc.EtcCarMsgService;
|
|
import com.hai.etc.EtcCustMsgService;
|
|
import com.hai.model.ResponseData;
|
|
import com.hai.model.UserInfoModel;
|
|
import com.hai.service.CommonService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.util.*;
|
|
|
|
@RestController
|
|
@RequestMapping(value="/etcCustomer")
|
|
@Api(value="etc客户信息")
|
|
public class EtcCustomerController {
|
|
|
|
Logger log = LoggerFactory.getLogger(EtcCustomerController.class);
|
|
|
|
@Resource
|
|
private UserCenter userCenter;
|
|
|
|
@Resource
|
|
private EtcCustMsgService etcCustMsgService;
|
|
|
|
@Resource
|
|
private EtcCarMsgService etcCarMsgService;
|
|
|
|
@Resource
|
|
private CommonService commonService;
|
|
|
|
@RequestMapping(value = "/getEtcCustList", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "查询用户列表")
|
|
public ResponseData getEtcCustList(
|
|
@RequestParam(value = "custName", required = false) String custName,
|
|
@RequestParam(value = "phone", required = false) String phone, HttpServletRequest request
|
|
) {
|
|
try {
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request);
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
map.put("userId", userInfoModel.getSecUser().getId());
|
|
map.put("custName", custName);
|
|
map.put("phone", phone);
|
|
|
|
return ResponseMsgUtil.success(etcCustMsgService.getEtcCustList(map));
|
|
|
|
} catch (Exception e) {
|
|
log.error("BsMsgController --> getMsgByList() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "insertCustomer" , method = RequestMethod.POST)
|
|
@ResponseBody
|
|
@ApiOperation(value = "新增客户基本信息")
|
|
public ResponseData insertCustomer(@RequestBody EtcCustMsg etcCustMsg , HttpServletRequest request) {
|
|
try {
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request);
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
|
|
|
|
if (etcCustMsg == null
|
|
|| etcCustMsg.getPhone() == null
|
|
) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
|
|
}
|
|
|
|
etcCustMsg.setUserId(userInfoModel.getSecUser().getId());
|
|
etcCustMsg.setUserName(userInfoModel.getSecUser().getUserName());
|
|
etcCustMsg.setCreateTime(new Date());
|
|
etcCustMsg.setUpdateTime(new Date());
|
|
etcCustMsg.setStatus(0);
|
|
|
|
Map<String, Object> mapUser = new HashMap<>();
|
|
|
|
mapUser.put("phone" , etcCustMsg.getPhone());
|
|
|
|
EtcCustMsg custMsg = etcCustMsgService.findEtcCustByMap(mapUser);
|
|
|
|
if (custMsg != null) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前用户已存在,请勿重复提交!");
|
|
}
|
|
|
|
etcCustMsgService.insertEtcCust(etcCustMsg);
|
|
return ResponseMsgUtil.success(etcCustMsg.getId());
|
|
|
|
} catch (Exception e) {
|
|
log.error("BsMsgController --> insertMsg() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/findByCustomer", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "根据id查询详情")
|
|
public ResponseData findByCustomer(@RequestParam(value = "id", required = true) Long id) {
|
|
try {
|
|
return ResponseMsgUtil.success(etcCustMsgService.findEtcCustById(id));
|
|
} catch (Exception e) {
|
|
log.error("HighUserController --> findByUserId() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "editCustomer" , method = RequestMethod.POST)
|
|
@ResponseBody
|
|
@ApiOperation(value = "编辑客户基本信息")
|
|
public ResponseData editCustomer(@RequestBody EtcCustMsg etcCustMsg , HttpServletRequest request) {
|
|
try {
|
|
|
|
if (etcCustMsg == null
|
|
|| etcCustMsg.getId() == null
|
|
|| etcCustMsg.getBankPhone() == null
|
|
|| etcCustMsg.getAccountNo() == null
|
|
|| etcCustMsg.getAddress() == null
|
|
|| etcCustMsg.getCustAgentIdBront() == null
|
|
|| etcCustMsg.getCustAgentIdFront() == null
|
|
|| etcCustMsg.getBankCard() == null
|
|
|| etcCustMsg.getBankName() == null
|
|
|| etcCustMsg.getCustIdNo() == null
|
|
|| etcCustMsg.getCustName() == null
|
|
) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
|
|
}
|
|
|
|
Map<String, Object> mapUser = new HashMap<>();
|
|
|
|
mapUser.put("custIdNo" , etcCustMsg.getCustIdNo());
|
|
|
|
EtcCustMsg custMsgNo = etcCustMsgService.findEtcCustByMap(mapUser);
|
|
|
|
if (custMsgNo != null) {
|
|
if (!Objects.equals(custMsgNo.getId(), etcCustMsg.getId()) && Objects.equals(etcCustMsg.getCustIdNo(), custMsgNo.getCustIdNo())) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "身份证号已经存在!");
|
|
}
|
|
}
|
|
|
|
EtcCustMsg custMsg = etcCustMsgService.findEtcCustById(etcCustMsg.getId());
|
|
|
|
etcCustMsg.setUserId(custMsg.getUserId());
|
|
etcCustMsg.setUserName(custMsg.getUserName());
|
|
etcCustMsg.setPhone(custMsg.getPhone());
|
|
etcCustMsg.setCustId(custMsg.getCustId());
|
|
etcCustMsg.setUpdateTime(new Date());
|
|
etcCustMsg.setCreateTime(custMsg.getCreateTime());
|
|
|
|
etcCustMsgService.updateEtcCust(etcCustMsg);
|
|
return ResponseMsgUtil.success("成功");
|
|
|
|
} catch (Exception e) {
|
|
log.error("BsMsgController --> insertMsg() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "editCarMsg" , method = RequestMethod.POST)
|
|
@ResponseBody
|
|
@ApiOperation(value = "编辑车辆信息")
|
|
public ResponseData editCarMsg(@RequestBody EtcCarMsg etcCarMsg , HttpServletRequest request) {
|
|
try {
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request);
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
|
|
|
|
if (etcCarMsg == null
|
|
|| etcCarMsg.getCustId() == null
|
|
|| etcCarMsg.getProductId() == null
|
|
|| etcCarMsg.getCardVarietyId() == null
|
|
|| etcCarMsg.getVehPlateNo() == null
|
|
|| etcCarMsg.getVehPlateColor() == null
|
|
|| etcCarMsg.getVehType() == null
|
|
|| etcCarMsg.getAxlesNum() == null
|
|
|| etcCarMsg.getWheelsNum() == null
|
|
|| etcCarMsg.getDrivlicMainFro() == null
|
|
|| etcCarMsg.getDrivlicSubFro() == null
|
|
|| etcCarMsg.getHeadStockPhoto() == null
|
|
) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
|
|
}
|
|
|
|
if (etcCarMsg.getId() != null) {
|
|
EtcCarMsg carMsg = etcCarMsgService.findEtcCarById(etcCarMsg.getId());
|
|
etcCarMsg.setCreateTime(carMsg.getCreateTime());
|
|
etcCarMsg.setVehId(carMsg.getVehId());
|
|
} else {
|
|
etcCarMsg.setCreateTime(new Date());
|
|
}
|
|
|
|
Map<String , Object> map = new HashMap<>();
|
|
|
|
map.put("vehPlateNo" , etcCarMsg.getVehPlateNo());
|
|
map.put("vehPlateColor" , etcCarMsg.getVehPlateColor());
|
|
|
|
EtcCarMsg carMsg = etcCarMsgService.findEtcCarByMap(map);
|
|
|
|
if (carMsg != null) {
|
|
etcCarMsg.setId(carMsg.getId());
|
|
}
|
|
|
|
|
|
// 查询车辆类型
|
|
SecDictionary carType = commonService.mappingSysCode("CAR_TYPE", etcCarMsg.getVehType());
|
|
|
|
etcCarMsg.setUserId(userInfoModel.getSecUser().getId());
|
|
etcCarMsg.setVehTypeName(carType.getCodeName());
|
|
etcCarMsg.setUserName(userInfoModel.getSecUser().getUserName());
|
|
|
|
etcCarMsg.setUpdateTime(new Date());
|
|
etcCarMsg.setVehStatus(11);
|
|
|
|
etcCarMsgService.insertEtcCar(etcCarMsg);
|
|
return ResponseMsgUtil.success(etcCarMsg.getExt1());
|
|
|
|
} catch (Exception e) {
|
|
log.error("BsMsgController --> insertMsg() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/getEtcCarMsgList", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "查询车辆列表")
|
|
public ResponseData getEtcCarMsgList(
|
|
@RequestParam(value = "vehPlateNo", required = false) String vehPlateNo, HttpServletRequest request
|
|
) {
|
|
try {
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request);
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
map.put("userId", userInfoModel.getSecUser().getId());
|
|
map.put("vehPlateNo", vehPlateNo);
|
|
|
|
List<EtcCarMsg> list = etcCarMsgService.getEtcCarList(map);
|
|
|
|
for (EtcCarMsg etcCarMsg :list) {
|
|
JSONObject car = EtcService.getVehStatus(etcCarMsg);
|
|
if (car.getString("errCode").equals("0")) {
|
|
|
|
if (car.getJSONObject("result").getInteger("vehStatus") == 11) {
|
|
etcCarMsg.setVehStatus(13);
|
|
} else {
|
|
etcCarMsg.setVehStatus(car.getJSONObject("result").getInteger("vehStatus"));
|
|
}
|
|
etcCarMsg.setPayStatus(car.getJSONObject("result").getInteger("payStatus"));
|
|
etcCarMsg.setSignStatus(car.getJSONObject("result").getInteger("signStatus"));
|
|
etcCarMsg.setExt2(car.getJSONObject("result").getString("docException"));
|
|
}
|
|
}
|
|
|
|
return ResponseMsgUtil.success(etcCarMsgService.getEtcCarList(map));
|
|
|
|
} catch (Exception e) {
|
|
log.error("BsMsgController --> getMsgByList() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/sendRealNameCode", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "请求实名认证")
|
|
public ResponseData sendRealNameCode(@RequestParam(value = "id", required = true) Long id) {
|
|
try {
|
|
|
|
EtcCustMsg etcCustMsg = etcCustMsgService.findEtcCustById(id);
|
|
|
|
if (etcCustMsg == null || etcCustMsg.getCustId() == null) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "状态错误!");
|
|
}
|
|
|
|
JSONObject object = EtcService.sendRealNameCode(etcCustMsg.getCustId());
|
|
|
|
if (object.getString("errCode").equals("0")) {
|
|
return ResponseMsgUtil.success("请求成功!");
|
|
}
|
|
|
|
return ResponseMsgUtil.success(object.getString("errMsg"));
|
|
|
|
} catch (Exception e) {
|
|
log.error("HighUserController --> findByUserId() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/checkRealNameCode", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "验证实名认证编码")
|
|
public ResponseData checkRealNameCode(@RequestParam(value = "id", required = true) Long id ,
|
|
@RequestParam(value = "verifyCode", required = true) String verifyCode ) {
|
|
try {
|
|
|
|
EtcCustMsg etcCustMsg = etcCustMsgService.findEtcCustById(id);
|
|
|
|
if (etcCustMsg == null || etcCustMsg.getCustId() == null) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "状态错误!");
|
|
}
|
|
|
|
JSONObject object = EtcService.checkRealNameCode(etcCustMsg.getCustId() , verifyCode);
|
|
|
|
if (object.getString("errCode").equals("0")) {
|
|
etcCustMsg.setStatus(2);
|
|
etcCustMsg.setUpdateTime(new Date());
|
|
etcCustMsgService.updateEtcCust(etcCustMsg);
|
|
return ResponseMsgUtil.success("请求成功!");
|
|
}
|
|
|
|
return ResponseMsgUtil.success(object.getString("errMsg"));
|
|
|
|
} catch (Exception e) {
|
|
log.error("HighUserController --> findByUserId() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/findByCarMsg", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "根据id查询详情")
|
|
public ResponseData findByCarMsg(@RequestParam(value = "id", required = true) Long id) {
|
|
try {
|
|
|
|
return ResponseMsgUtil.success(etcCarMsgService.findEtcCarById(id));
|
|
|
|
} catch (Exception e) {
|
|
log.error("HighUserController --> findByUserId() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/getVehStatus", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "根据id查询详情")
|
|
public ResponseData getVehStatus(@RequestParam(value = "id", required = true) Long id) {
|
|
try {
|
|
|
|
EtcCarMsg carMsg = etcCarMsgService.findEtcCarById(id);
|
|
|
|
return ResponseMsgUtil.success(EtcService.getVehStatus(carMsg));
|
|
|
|
} catch (Exception e) {
|
|
log.error("HighUserController --> findByUserId() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/getVehStatusByList", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "getVehStatusByList")
|
|
public ResponseData getVehStatusByList() {
|
|
try {
|
|
|
|
Map<String , Object> map = new HashMap<>();
|
|
map.put("status" , "11,12,13,15");
|
|
|
|
|
|
List<EtcCarMsg> list = etcCarMsgService.getEtcCarList(map);
|
|
|
|
List<JSONObject> data = new ArrayList<>();
|
|
|
|
for (EtcCarMsg carMsg : list) {
|
|
JSONObject object = EtcService.getVehStatus(carMsg);
|
|
|
|
if (Objects.equals(object.getString("errCode"), "0") && object.getJSONObject("result") != null) {
|
|
carMsg.setVehStatus(object.getJSONObject("result").getInteger("vehStatus"));
|
|
carMsg.setUpdateTime(object.getJSONObject("result").getDate("activeTime"));
|
|
}
|
|
etcCarMsgService.updateEtcCar(carMsg);
|
|
object.put("carMsg" , carMsg);
|
|
data.add(object);
|
|
}
|
|
|
|
return ResponseMsgUtil.success(data);
|
|
|
|
} catch (Exception e) {
|
|
log.error("HighUserController --> findByUserId() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/queryActivateVehicleInfoPage", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "queryActivateVehicleInfoPage")
|
|
public ResponseData queryActivateVehicleInfoPage() {
|
|
try {
|
|
|
|
|
|
|
|
JSONObject object = EtcService.queryActivateVehicleInfoPage(DateUtil.format(DateUtil.reduceDate(new Date() , 2) , "yyyy-MM-dd HH:mm:ss") , DateUtil.format(new Date() , "yyyy-MM-dd HH:mm:ss") );
|
|
|
|
if (Objects.equals(object.getString("errCode"), "0") && object.getJSONObject("result").getJSONArray("records") != null) {
|
|
JSONArray jsonArray = object.getJSONObject("result").getJSONArray("records");
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
Map<String , Object> map = new HashMap<>();
|
|
map.put("vehPlateNo" , jsonArray.getJSONObject(i).getString("vehPlateNo"));
|
|
map.put("vehPlateColor" , CarTypeEnum.getNameByName(jsonArray.getJSONObject(i).getString("vehPlateColor")));
|
|
|
|
EtcCarMsg carMsg = etcCarMsgService.findEtcCarByMap(map);
|
|
carMsg.setCardNo(jsonArray.getJSONObject(i).getString("cardNo"));
|
|
carMsg.setObuNo(jsonArray.getJSONObject(i).getString("obuNo"));
|
|
|
|
etcCarMsgService.updateEtcCar(carMsg);
|
|
|
|
}
|
|
}
|
|
|
|
return ResponseMsgUtil.success(object);
|
|
|
|
} catch (Exception e) {
|
|
log.error("HighUserController --> findByUserId() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|