Commit 9e01defd by 杨林龙

Merge remote-tracking branch 'origin/master'

2 parents 7e74bc2c d2c87991
......@@ -92,6 +92,11 @@
<artifactId>ne-shield-alarmcenter-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>ne-shield-publiccenter-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
......
......@@ -28,8 +28,11 @@ public enum ResultEnum {
IMPORT_FAIL_FILE(12120002, "导入文件与指定模板不匹配"),
IMPORT_FILE_TYPE_ERROR(12120003, "导入文件类型错误"),
IMPORT_FAIL_NOT_FOUND(12120004, "未找到失败的文件"),
UN_BIND_DEVICE(12120005, "请先解绑设备"),
EXIST_VEHICLE(12120005, "该车辆已存在:vin %s"),
UN_BIND_DEVICE(12120005, "请先解绑原设备,再重新绑定新设备"),
EXIST_VEHICLE(12120006, "该车辆已存在:vin %s"),
IMPORT_SIZE_TIP(12120007, "每次只能导入 %s 条。"),
IMPORT_EMPTY(12120008, "导入的数据为空。"),
PARSE_EXCEL_ERROR(12120002, "解析excel文件异常"),
/**
* 拆除报警
......
package cn.com.glsx.admin.common.exception;
import cn.com.glsx.admin.common.enums.ResultEnum;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.glsx.plat.core.web.R;
import com.glsx.plat.exception.ExceptionLevel;
......@@ -45,6 +47,15 @@ public class AdminExceptionHandler extends GlobalExceptionHandler {
return R.error(e.getMessage());
}
@ExceptionHandler(ExcelAnalysisException.class)
public R handleExcelAnalysisException(ExcelAnalysisException e) {
if (e.getCause() instanceof AdminException) {
AdminException exp = (AdminException) e.getCause();
return R.error(exp.getErrorCode(),exp.getMessage());
}
return R.error(ResultEnum.PARSE_EXCEL_ERROR.getMessage());
}
@ExceptionHandler(ExcelDataConvertException.class)
public R handleExcelDataConvertException(ExcelDataConvertException e) {
return R.error(e.getMessage());
......
......@@ -112,6 +112,7 @@ public class VehicleController {
TrialDriveVehicleImportListener listener = new TrialDriveVehicleImportListener(vehicleService, deviceService);
EasyExcel.read(file.getInputStream(), TrialDriveVehicleImport.class, listener)
.head(TrialDriveVehicleImport.class)
.ignoreEmptyRow(false)
.sheet().doRead();
BaseImportInfo importInfo = listener.getBaseImportInfo();
return R.ok().data(importInfo);
......
......@@ -19,6 +19,7 @@ import java.util.List;
@Mapper
public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
@DataPerm(showSql = true)
List<VehicleLinkSnsDTO> linkSnsSearch(VehicleSearch search);
/**
......
package cn.com.glsx.admin.modules.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.util.Date;
@Data
public class ElectricFenceDTO extends BaseAreaDto{
public class ElectricFenceDTO extends BaseAreaDto {
private Long fenceId;
private String shopName;
......@@ -18,4 +17,8 @@ public class ElectricFenceDTO extends BaseAreaDto{
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate;
private Integer approvalStatus;
private String approvalResult;
private String approvalRemark;
}
......@@ -42,4 +42,13 @@ public class ElectricFenceExport extends BaseAreaDto {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate;
@ExcelIgnore
private Integer approvalStatus;
@ExcelProperty(value = "审核结果", index = 9)
private String approvalResult;
@ExcelProperty(value = "审核备注", index = 10)
private String approvalRemark;
}
......@@ -95,15 +95,20 @@ public class TrialDriveVehicleImportListener extends AnalysisEventListener<Trial
list.add(vehicleImport);
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
if (list.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
list.clear();
throw new AdminException(ResultEnum.IMPORT_SIZE_TIP.getCode(),
String.format(ResultEnum.IMPORT_SIZE_TIP.getMessage(), BATCH_COUNT));
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
if (CollectionUtils.isEmpty(list)) {
log.info("导入的数据为空");
throw new AdminException(ResultEnum.IMPORT_EMPTY);
}
// 保存数据
saveData();
//保存失败的文件
if (CollectionUtils.isNotEmpty(failList)) {
......@@ -112,6 +117,7 @@ public class TrialDriveVehicleImportListener extends AnalysisEventListener<Trial
baseImportInfo.setFailNum(baseImportInfo.getFailNum() + failList.size());
}
log.info("所有数据解析存储完成!");
list.clear();
}
/**
......
package cn.com.glsx.admin.modules.model.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
@Data
......@@ -50,6 +52,10 @@ public class VehicleInfoBo {
private String vin;
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
private Date registrationDate;
/**
* 车辆上牌资料
*/
......
......@@ -77,6 +77,7 @@ public class ElectricFenceService {
organizaService.drawOrganization(list);
list.forEach(index -> {
index.setBizFenceType(BizFenceTypeEnum.getNameByCode(Integer.valueOf(index.getBizFenceType())));
index.setApprovalResult(ApprovalStatusEnum.getValueByCode(index.getApprovalStatus()));
});
return new PageInfo<>(list);
}
......@@ -86,6 +87,7 @@ public class ElectricFenceService {
organizaService.drawOrganization(list);
list.forEach(index -> {
index.setBizFenceType(BizFenceTypeEnum.getNameByCode(Integer.valueOf(index.getBizFenceType())));
index.setApprovalResult(ApprovalStatusEnum.getValueByCode(index.getApprovalStatus()));
});
return list;
}
......@@ -325,8 +327,11 @@ public class ElectricFenceService {
electricFenceSnsCopyMapper.logicDeleteByFenceId(fenceBO.getId());
ElectricFenceCopy electricFenceCopy = electricFenceCopyMapper.selectByFenceId(fenceBO.getId());
ElectricFenceCopy fenceCopy = new ElectricFenceCopy();
BeanUtils.copyProperties(fenceBO, fenceCopy);
fenceCopy.setId(null);
fenceCopy.setFenceId(localFence.getId());
if (fenceBO.getShapeType() != null) {
......@@ -353,7 +358,6 @@ public class ElectricFenceService {
// + " 操作人:" + ShieldContextHolder.getAccount() + "(" + ShieldContextHolder.getUserId() + ")"
// + "<br/>");
ElectricFenceCopy electricFenceCopy = electricFenceCopyMapper.selectByFenceId(fenceBO.getId());
if (electricFenceCopy == null) {
fenceCopy.setCreatedDate(new Date());
if (fenceBO.getShopId() != null) {
......@@ -361,6 +365,7 @@ public class ElectricFenceService {
}
int updateCnt = electricFenceCopyMapper.insertUseGeneratedKeys(fenceCopy);
} else {
fenceCopy.setId(electricFenceCopy.getId());
fenceCopy.setUpdatedDate(new Date());
if (fenceBO.getShopId() != null) {
fenceCopy.setCreatedBy(fenceBO.getShopId());
......@@ -416,11 +421,13 @@ public class ElectricFenceService {
if (ObjectUtil.isNull(fence)) {
fence = new ElectricFence();
BeanUtils.copyProperties(fenceCopy, fence);
fence.setId(null);
electricFenceMapper.insertUseGeneratedKeys(fence);
electricFenceCopyMapper.updateFenceIdById(fenceCopy.getId(), fence.getId());
} else {
BeanUtils.copyProperties(fenceCopy, fence);
fence.setId(fenceCopy.getFenceId());
electricFenceMapper.updateByPrimaryKey(fence);
}
......
......@@ -121,10 +121,13 @@ public class TrialDriveShopService {
// 校验数据
checkTrialDriveShop(shopBO, true);
TrialDriveShop trialDriveShop = trialDriveShopMapper.selectById(shopBO.getId());
//同步更新特约店围栏记录在围栏表
syncUpdateFence(shopBO);
TrialDriveShop shop = TrialDriveShopConverter.INSTANCE.bo2do(shopBO);
shop.setFenceId(trialDriveShop.getFenceId());
if (shopBO.getSpecialShopId() != null) {
shop.setCreatedBy(shopBO.getSpecialShopId());
} else {
......@@ -159,7 +162,7 @@ public class TrialDriveShopService {
}
}
public void syncUpdateFence(TrialDriveShopBO shopBO) throws Exception {
public ElectricFence syncUpdateFence(TrialDriveShopBO shopBO) throws Exception {
TrialDriveShop shop = trialDriveShopMapper.selectById(shopBO.getId());
ElectricFenceBO fenceBO = new ElectricFenceBO();
......@@ -183,7 +186,7 @@ public class TrialDriveShopService {
fenceBO.setSnList(shopBO.getSnList());
electricFenceService.updateFence(fenceBO);
return electricFenceService.updateFence(fenceBO);
}
public TrialDriveShopDetailsDTO getDetailsById(Long shopId) {
......
......@@ -51,6 +51,7 @@ public class VehicleDocService {
*/
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdateVehDoc(VehicleInfoBo vehicleInfoBo) {
// 1.更新车辆信息
TrialDriveVehicleEditBo trialDriveVehicleEditBo = new TrialDriveVehicleEditBo();
BeanUtils.copyProperties(vehicleInfoBo, trialDriveVehicleEditBo);
......
......@@ -8,7 +8,6 @@ import cn.com.glsx.admin.common.exception.AdminException;
import cn.com.glsx.admin.modules.entity.Device;
import cn.com.glsx.admin.modules.entity.Vehicle;
import cn.com.glsx.admin.modules.entity.VehicleDevice;
import cn.com.glsx.admin.modules.mapper.TrialDriveShopMapper;
import cn.com.glsx.admin.modules.mapper.VehicleMapper;
import cn.com.glsx.admin.modules.model.TrialDriveVehicleEditDTO;
import cn.com.glsx.admin.modules.model.TrialDriveVehiclePageDTO;
......@@ -19,6 +18,7 @@ import cn.com.glsx.admin.modules.model.param.*;
import cn.com.glsx.admin.modules.utils.DateUtil;
import cn.com.glsx.admin.modules.utils.FileIOUtil;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.publiccenter.api.feign.SysDictDataService;
import cn.com.glsx.usercenter.api.dto.request.FindUserRequest;
import cn.com.glsx.usercenter.api.dto.response.User;
import cn.com.glsx.usercenter.api.feign.UserService;
......@@ -62,6 +62,9 @@ public class VehicleService {
@Autowired
private OrganizaService organizaService;
@Autowired
private SysDictDataService dictDataService;
public PageInfo<TrialDriveVehiclePageDTO> searchTrialDrive(VehicleManageSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<TrialDriveVehiclePageDTO> listDriveVehicle = vehicleMapper.searchTrialDrive(search);
......@@ -177,7 +180,12 @@ public class VehicleService {
return;
} else if (StringUtils.isBlank(sn) && CollectionUtils.isNotEmpty(bindVehicleDevice)) {
throw new AdminException(ResultEnum.UN_BIND_DEVICE);
} else if (StringUtils.isNotBlank(sn) && CollectionUtils.isNotEmpty(bindVehicleDevice)) {
}
if (StringUtils.isNotBlank(sn) && !deviceService.checkSnExist(sn)) {
throw new AdminException(ResultEnum.DEVICE_NOT_EXIST.getCode(),
String.format(ResultEnum.DEVICE_NOT_EXIST.getMessage(), sn));
}
if (StringUtils.isNotBlank(sn) && CollectionUtils.isNotEmpty(bindVehicleDevice)) {
//绑定的设备和已存在的是否相同 全部不相同 提示先解绑 再重新绑定
boolean bindFlag = false;
for (VehicleDevice vehicleDevice : bindVehicleDevice) {
......
......@@ -85,10 +85,14 @@
ttds.shop_level shopLevel,
tef.created_date createdDate,
tef.created_by createdBy,
biz_fence_type as bizFenceType
tef.biz_fence_type as bizFenceType,
ta.status approvalStatus,
ta.remark approvalRemark
from t_electric_fence tef
left join t_user tu on tu.id = tef.created_by
left join t_trial_drive_shop ttds on ttds.fence_id = tef.id
left join t_electric_fence_copy tefc on tefc.fence_id = tef.id
left join t_approval ta on ta.biz_id = tefc.id and ta.biz_type = 1
where tef.del_flag = 0
and tef.biz_fence_type = 12
<if test="term != null and term !=''">
......@@ -111,10 +115,14 @@
ttds.shop_level shopLevel,
tef.created_date createdDate,
tef.created_by createdBy,
tef.biz_fence_type bizFenceType
tef.biz_fence_type bizFenceType,
ta.status approvalStatus,
ta.remark approvalRemark
from t_electric_fence tef
left join t_user tu on tu.id = tef.created_by
left join t_trial_drive_shop ttds on ttds.fence_id = tef.id
left join t_electric_fence_copy tefc on tefc.fence_id = tef.id
left join t_approval ta on ta.biz_id = tefc.id and ta.biz_type = 1
where tef.del_flag = 0
and tef.biz_fence_type = 12
<if test="term != null and term !=''">
......
......@@ -31,7 +31,6 @@
<include refid="Base_Column_List"/>
from t_electric_fence_sns_copy
where fence_id = #{fenceId}
and source = 1
and del_flag = 0
</select>
......
......@@ -30,7 +30,6 @@
<include refid="Base_Column_List"/>
from t_electric_fence_sns
where fence_id = #{fenceId}
and source = 1
and del_flag = 0
</select>
......
......@@ -12,8 +12,11 @@ import cn.com.glsx.auth.model.Department;
import cn.com.glsx.auth.model.Role;
import cn.com.glsx.auth.model.SyntheticUser;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.publiccenter.api.dto.response.SysDictDataResponse;
import cn.com.glsx.publiccenter.api.feign.SysDictDataService;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
......@@ -38,7 +41,8 @@ public class VehicleServiceTest {
@Autowired
private VehicleService vehicleService;
@Autowired
private SysDictDataService dictDataService;
@Before
public void runBeforeTestMethod() {
SyntheticUser user = new SyntheticUser();
......@@ -162,6 +166,16 @@ public class VehicleServiceTest {
System.out.println(JSONObject.toJSONString(seq));
}
@Test
public void getDictDataByIdTest() {
R<SysDictDataResponse> dictDataR = dictDataService.getDictDataById(90L);
SysDictDataResponse response = null;
if (dictDataR != null) {
response = dictDataR.getData(SysDictDataResponse.class);
}
System.out.println(JSONObject.toJSONString(response));
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!