兴安优化车辆包兼容
This commit is contained in:
@@ -15,11 +15,11 @@ spring:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
# namespace: xa
|
||||
namespace: xa
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
# namespace: xa
|
||||
namespace: xa
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
||||
@@ -15,11 +15,11 @@ spring:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
# namespace: xa
|
||||
namespace: xa
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
# namespace: xa
|
||||
namespace: xa
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
||||
@@ -13,24 +13,19 @@ import com.dcsoft.common.core.utils.file.FileUtils;
|
||||
import com.dcsoft.common.redis.service.RedisService;
|
||||
import com.dcsoft.file.service.IFaceService;
|
||||
import com.dcsoft.file.service.ISysFileService;
|
||||
import com.dcsoft.file.utils.FileUploadUtils;
|
||||
import com.dcsoft.file.utils.ImageToBase64Utils;
|
||||
import com.dcsoft.file.utils.MinioUtil;
|
||||
import com.dcsoft.file.utils.PictureUtils;
|
||||
import com.dcsoft.file.utils.*;
|
||||
import com.dcsoft.system.api.domain.SysFile;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.RemoveObjectArgs;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import net.coobird.thumbnailator.geometry.Positions;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
@@ -164,6 +159,27 @@ public class SysFileController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("uploadMinioCarBase64")
|
||||
public R<SysFile> uploadMinioCarBase64(@RequestBody JSONObject data) {
|
||||
try {
|
||||
String url = data.getString("url");
|
||||
if(StringUtils.isEmpty(url)){
|
||||
return R.fail("图片地址不能为空");
|
||||
}
|
||||
MultipartFile file = Base64ToMultipartFileUtil.convertToMultipartFile(url);
|
||||
|
||||
String fileNames = FileUploadUtils.uploadMinio(file, this.bucketName2, file.getName());
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setName(FileUtils.getName(fileNames));
|
||||
fileNames = fileNames.replace(miniourl, miniogwurl);
|
||||
sysFile.setUrl(fileNames);
|
||||
return R.ok(sysFile);
|
||||
} catch (Exception e) {
|
||||
log.error("上传文件失败", e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 文件上传请求
|
||||
@@ -293,29 +309,16 @@ public class SysFileController {
|
||||
@PostMapping("uploadMinio1")
|
||||
public R<SysFile> uploadMinio1(MultipartFile file, String fileName) {
|
||||
try {
|
||||
//判断压缩图片
|
||||
if ((1024 * 1024 * 0.1) <= file.getSize()) {
|
||||
// 小于 1M 的
|
||||
try {
|
||||
String fileNames1 = file.getOriginalFilename();
|
||||
File newFile = new File(fileNames1);
|
||||
if ((1024 * 1024 * 0.1) <= file.getSize() && file.getSize() <= (1024 * 1024)) {
|
||||
Thumbnails.of(file.getInputStream()).scale(1f).outputQuality(0.4f).toFile(newFile);
|
||||
}
|
||||
// 1 - 2M 的
|
||||
else if ((1024 * 1024) < file.getSize() && file.getSize() <= (1024 * 1024 * 2)) {
|
||||
Thumbnails.of(file.getInputStream()).scale(1f).outputQuality(0.2f).toFile(newFile);
|
||||
}
|
||||
// 2M 以上的
|
||||
else if ((1024 * 1024 * 2) < file.getSize()) {
|
||||
Thumbnails.of(file.getInputStream()).scale(1f).outputQuality(0.1f).toFile(newFile);
|
||||
}
|
||||
// 转为 MultipartFile
|
||||
file = PictureUtils.getMultipartFile(newFile);
|
||||
newFile.delete();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
// 裁剪图片为640*480
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
File newFile = new File(originalFilename);
|
||||
Thumbnails.of(file.getInputStream()).crop(Positions.CENTER).size(480, 640).toFile(newFile);
|
||||
|
||||
file = PictureUtils.getMultipartFile(newFile);
|
||||
newFile.delete();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
initFlowRules();
|
||||
//上传前进行人脸检测
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.dcsoft.file.utils;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Base64;
|
||||
|
||||
public class Base64MultipartFile implements MultipartFile {
|
||||
|
||||
private final byte[] fileContent;
|
||||
private final String fileName;
|
||||
private final String contentType;
|
||||
|
||||
public Base64MultipartFile(String base64Data, String fileName) {
|
||||
// 清理Base64数据
|
||||
String cleanedBase64 = base64Data.contains(",")
|
||||
? base64Data.substring(base64Data.indexOf(",") + 1)
|
||||
: base64Data;
|
||||
|
||||
this.fileContent = Base64.getDecoder().decode(cleanedBase64);
|
||||
this.fileName = fileName;
|
||||
this.contentType = extractContentType(base64Data);
|
||||
}
|
||||
|
||||
private String extractContentType(String base64Data) {
|
||||
if (base64Data.startsWith("data:image/jpeg")) {
|
||||
return "image/jpeg";
|
||||
} else if (base64Data.startsWith("data:image/png")) {
|
||||
return "image/png";
|
||||
} else if (base64Data.startsWith("data:image/gif")) {
|
||||
return "image/gif";
|
||||
}
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "file";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalFilename() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return fileContent == null || fileContent.length == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return fileContent.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
return fileContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(fileContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||
try (FileOutputStream fos = new FileOutputStream(dest)) {
|
||||
fos.write(fileContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.dcsoft.file.utils;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public class Base64ToMultipartFileUtil {
|
||||
|
||||
public static MultipartFile convertToMultipartFile(String base64Data, String fileName) {
|
||||
return new Base64MultipartFile(base64Data, fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动生成文件名
|
||||
*/
|
||||
public static MultipartFile convertToMultipartFile(String base64Data) {
|
||||
String fileName = generateFileName(base64Data);
|
||||
return convertToMultipartFile(base64Data, fileName);
|
||||
}
|
||||
|
||||
private static String generateFileName(String base64Data) {
|
||||
String extension = ".jpg";
|
||||
if (base64Data.startsWith("data:image/png")) {
|
||||
extension = ".png";
|
||||
} else if (base64Data.startsWith("data:image/gif")) {
|
||||
extension = ".gif";
|
||||
}
|
||||
return "image_" + System.currentTimeMillis() + extension;
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
group by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectJobLogAll" resultMap="SysJobLogResult">
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.dcsoft.system.vehicle.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.dcsoft.common.core.utils.StringUtils;
|
||||
import com.dcsoft.common.core.utils.poi.ExcelUtil;
|
||||
import com.dcsoft.common.core.web.controller.BaseController;
|
||||
import com.dcsoft.common.core.web.domain.AjaxResult;
|
||||
@@ -11,17 +12,20 @@ import com.dcsoft.common.log.enums.BusinessType;
|
||||
import com.dcsoft.common.security.annotation.RequiresPermissions;
|
||||
import com.dcsoft.common.security.utils.SecurityUtils;
|
||||
import com.dcsoft.system.vehicle.domain.CarInfo;
|
||||
import com.dcsoft.system.vehicle.domain.CarPark;
|
||||
import com.dcsoft.system.vehicle.domain.CarParkItem;
|
||||
import com.dcsoft.system.vehicle.domain.CarParkRecord;
|
||||
import com.dcsoft.system.vehicle.service.ICarInfoService;
|
||||
import com.dcsoft.system.vehicle.service.ICarParkItemService;
|
||||
import com.dcsoft.system.vehicle.service.ICarParkRecordService;
|
||||
import com.dcsoft.system.vehicle.service.ICarParkService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -44,6 +48,9 @@ public class CarInfoController extends BaseController
|
||||
@Autowired
|
||||
private ICarParkItemService carParkItemService;
|
||||
|
||||
@Autowired
|
||||
private ICarParkService carParkService;
|
||||
|
||||
/**
|
||||
* 查询车辆信息列表
|
||||
*/
|
||||
@@ -118,13 +125,18 @@ public class CarInfoController extends BaseController
|
||||
//保存车辆授权
|
||||
//根据车场查询车辆
|
||||
if (carInfo.getParkId() != null) {
|
||||
List<Long> list = new ArrayList<>();
|
||||
CarPark park = carParkService.selectCarParkById(carInfo.getParkId());
|
||||
list.add(carInfo.getParkId());
|
||||
list.add(park.getParentId());
|
||||
|
||||
CarParkItem carParkItem = new CarParkItem();
|
||||
carParkItem.setParkId(carInfo.getParkId());
|
||||
carParkItem.setParkIds(list);
|
||||
List<CarParkItem> itemList = carParkItemService.selectCarParkItemList(carParkItem);
|
||||
for (CarParkItem a : itemList) {
|
||||
CarParkRecord carParkRecord = new CarParkRecord();
|
||||
carParkRecord.setCustomerId(carInfo.getCustomerId());
|
||||
carParkRecord.setParkId(carInfo.getParkId());
|
||||
carParkRecord.setParkId(a.getParkId());
|
||||
carParkRecord.setEquipmentId(a.getEquipmentId());
|
||||
carParkRecordService.insertCarParkRecord(carParkRecord);
|
||||
}
|
||||
@@ -138,22 +150,30 @@ public class CarInfoController extends BaseController
|
||||
@RequiresPermissions("system:carInfo:edit")
|
||||
@Log(title = "车辆信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CarInfo carInfo)
|
||||
{
|
||||
if(!checkPlateNumberFormat(carInfo.getPlate())){
|
||||
public AjaxResult edit(@RequestBody CarInfo carInfo) {
|
||||
if (!StrUtil.equals("2", carInfo.getCarType()) && !checkPlateNumberFormat(carInfo.getPlate())) {
|
||||
return AjaxResult.error("车牌号不正确!");
|
||||
}
|
||||
if (StringUtils.equals("1", carInfo.getTimeSegEnable()) && StringUtils.isBlank(carInfo.getSegTime())) {
|
||||
return AjaxResult.error("已启用时间段,时间段不能为空!");
|
||||
}
|
||||
|
||||
//根据车场查询车辆
|
||||
if(carInfo.getParkId()!=null){
|
||||
if (carInfo.getParkId() != null) {
|
||||
//删除车辆授权
|
||||
carParkRecordService.deleteCarParkRecordByCustomerId(carInfo.getCustomerId());
|
||||
CarParkItem carParkItem=new CarParkItem();
|
||||
carParkItem.setParkId(carInfo.getParkId());
|
||||
List<CarParkItem> itemList=carParkItemService.selectCarParkItemList(carParkItem);
|
||||
for(CarParkItem a:itemList){
|
||||
CarParkRecord carParkRecord=new CarParkRecord();
|
||||
|
||||
List<Long> list = new ArrayList<>();
|
||||
CarPark park = carParkService.selectCarParkById(carInfo.getParkId());
|
||||
list.add(carInfo.getParkId());
|
||||
list.add(park.getParentId());
|
||||
CarParkItem carParkItem = new CarParkItem();
|
||||
carParkItem.setParkIds(list);
|
||||
List<CarParkItem> itemList = carParkItemService.selectCarParkItemList(carParkItem);
|
||||
for (CarParkItem a : itemList) {
|
||||
CarParkRecord carParkRecord = new CarParkRecord();
|
||||
carParkRecord.setCustomerId(carInfo.getCustomerId());
|
||||
carParkRecord.setParkId(carInfo.getParkId());
|
||||
carParkRecord.setParkId(a.getParkId());
|
||||
carParkRecord.setEquipmentId(a.getEquipmentId());
|
||||
carParkRecordService.insertCarParkRecord(carParkRecord);
|
||||
|
||||
@@ -213,7 +233,7 @@ public class CarInfoController extends BaseController
|
||||
}
|
||||
|
||||
public boolean checkPlateNumberFormat(String content) {
|
||||
String pattern = "([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼]{1}(([A-HJ-Z]{1}[A-HJ-NP-Z0-9]{5})|([A-HJ-Z]{1}(([DF]{1}[A-HJ-NP-Z0-9]{1}[0-9]{4})|([0-9]{5}[DF]{1})))|([A-HJ-Z]{1}[A-D0-9]{1}[0-9]{3}警)))|([0-9]{6}使)|((([沪粤川云桂鄂陕蒙藏黑辽渝]{1}A)|鲁B|闽D|蒙E|蒙H)[0-9]{4}领)|(WJ[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼·•]{1}[0-9]{4}[TDSHBXJ0-9]{1})|([VKHBSLJNGCE]{1}[A-DJ-PR-TVY]{1}[0-9]{5})";
|
||||
String pattern = "([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼]{1}(([A-HJ-Z]{1}[A-HJ-NP-Z0-9]{5})|([A-HJ-Z]{1}(([ADF]{1}[A-HJ-NP-Z0-9]{1}[0-9]{4})|([0-9]{5}[ADF]{1})))|([A-HJ-Z]{1}[A-D0-9]{1}[0-9]{3}警)))|([0-9]{6}使)|((([沪粤川云桂鄂陕蒙藏黑辽渝]{1}A)|鲁B|闽D|蒙E|蒙H)[0-9]{4}领)|(WJ[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼·•]{1}[0-9]{4}[TDSHBXJ0-9]{1})|([VKHBSLJNGCE]{1}[A-DJ-PR-TVY]{1}[0-9]{5})";
|
||||
return Pattern.matches(pattern, content);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,17 @@ public class CarParkController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询车场信息下拉数据
|
||||
*/
|
||||
@RequiresPermissions("system:carPark:list")
|
||||
@GetMapping("/getCarParkSelect/{id}")
|
||||
public AjaxResult getCarParkSelect(@PathVariable("id") Long id)
|
||||
{
|
||||
List<CarPark> list = carParkService.getCarParkSelect(id);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出车场信息列表
|
||||
*/
|
||||
|
||||
@@ -69,6 +69,7 @@ public class CarInfo extends BaseEntity
|
||||
private String sync;
|
||||
|
||||
private Long parkId;
|
||||
|
||||
@Excel(name = "所属员工",sort = 9)
|
||||
private String peopleName;
|
||||
|
||||
@@ -84,7 +85,7 @@ public class CarInfo extends BaseEntity
|
||||
private String remark;
|
||||
private String carType;
|
||||
|
||||
@Excel(name = "所属单位",sort = 8,readConverterExp = "1=锦盛化工,2=锦亿科技,3=锦泽化工,4=锋盛环保,5=锦鑫化工,6=锦鑫稀材,7=锦盛电厂,8=锦桂科技,9=晟锦科技,10=锦淳公司")
|
||||
@Excel(name = "所属单位", sort = 8, readConverterExp = "1=兴安化工,2=兴安镓业")
|
||||
private String unit;
|
||||
|
||||
public Long getParkId() {
|
||||
|
||||
@@ -31,6 +31,15 @@ public class CarPark extends BaseEntity
|
||||
|
||||
private String spaceName;
|
||||
|
||||
/** 上级车场(一并下发车场)*/
|
||||
private Long parentId;
|
||||
|
||||
/** 上级车场(一并下发车场)*/
|
||||
private String parentIdName;
|
||||
|
||||
/** 满车位自动锁杆:0:不锁,1:锁 */
|
||||
private Integer autoLock;
|
||||
|
||||
/** 车位总数 */
|
||||
@Excel(name = "车位总数")
|
||||
private Long carsNum;
|
||||
@@ -41,6 +50,30 @@ public class CarPark extends BaseEntity
|
||||
|
||||
private List<CarParkItem> itemList = new ArrayList<CarParkItem>();
|
||||
|
||||
public String getParentIdName() {
|
||||
return parentIdName;
|
||||
}
|
||||
|
||||
public void setParentIdName(String parentIdName) {
|
||||
this.parentIdName = parentIdName;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Integer getAutoLock() {
|
||||
return autoLock;
|
||||
}
|
||||
|
||||
public void setAutoLock(Integer autoLock) {
|
||||
this.autoLock = autoLock;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.dcsoft.common.core.web.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车场设备信息对象 car_park_item
|
||||
*
|
||||
@@ -26,12 +28,23 @@ public class CarParkItem extends BaseEntity
|
||||
@Excel(name = "车场id")
|
||||
private Long parkId;
|
||||
|
||||
/** 车场ids */
|
||||
private List<Long> parkIds;
|
||||
|
||||
/** 通道方向 */
|
||||
@Excel(name = "通道方向")
|
||||
private String way;
|
||||
|
||||
private String area;
|
||||
|
||||
public List<Long> getParkIds() {
|
||||
return parkIds;
|
||||
}
|
||||
|
||||
public void setParkIds(List<Long> parkIds) {
|
||||
this.parkIds = parkIds;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
|
||||
@@ -73,4 +73,8 @@ public interface CarParkMapper
|
||||
public int selectCarInfo(@Param("id") Long id,@Param("flag") String flag);
|
||||
|
||||
public CarPark selectCarParkByName(String name);
|
||||
|
||||
List<CarPark> selectByIds(@Param("list") List<Long> collect);
|
||||
|
||||
List<CarPark> getCarParkSelect(Long id);
|
||||
}
|
||||
|
||||
@@ -59,4 +59,6 @@ public interface ICarParkService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCarParkById(Long id);
|
||||
|
||||
List<CarPark> getCarParkSelect(Long id);
|
||||
}
|
||||
|
||||
@@ -223,110 +223,103 @@ public class CarInfoServiceImpl implements ICarInfoService
|
||||
/**
|
||||
* 导入用户数据
|
||||
*
|
||||
* @param userList 用户数据列表
|
||||
* @param userList 用户数据列表
|
||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||
* @param operName 操作用户
|
||||
* @param operName 操作用户
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String importData(List<CarInfo> userList, boolean isUpdateSupport, String operName)
|
||||
{
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0)
|
||||
{
|
||||
public String importData(List<CarInfo> userList, boolean isUpdateSupport, String operName) {
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0) {
|
||||
throw new ServiceException("导入用户数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
int i=0;
|
||||
for (CarInfo user : userList)
|
||||
{
|
||||
int i = 0;
|
||||
for (CarInfo user : userList) {
|
||||
i++;
|
||||
try
|
||||
{
|
||||
try {
|
||||
// 验证车牌是否合格
|
||||
if(!checkPlateNumberFormat(user.getPlate())){
|
||||
if (!checkPlateNumberFormat(user.getPlate())) {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>" + failureNum + "、车牌信息 " + user.getPlate() + "格式错误");
|
||||
}else{
|
||||
// 验证是否存在这个用户
|
||||
CarInfo u = carInfoMapper.selectCarInfoByCarNo(user.getPlate());
|
||||
SysPeople people=peopleMapper.selectSysPeopleByUserName(user.getPeopleName());
|
||||
if(people!=null){
|
||||
user.setPeopleId(people.getId());
|
||||
}
|
||||
CarPark carPark=carParkMapper.selectCarParkByName(user.getParkName());
|
||||
if(carPark!=null){
|
||||
user.setParkId(carPark.getId());
|
||||
}
|
||||
if (StringUtils.isNull(u))
|
||||
{
|
||||
user.setCarType("0");
|
||||
user.setCreateBy(operName);
|
||||
this.insertCarInfo(user);
|
||||
//保存车辆授权
|
||||
//根据车场查询车辆
|
||||
if(user.getParkId()!=null){
|
||||
CarParkItem carParkItem=new CarParkItem();
|
||||
carParkItem.setParkId(user.getParkId());
|
||||
List<CarParkItem> itemList=carParkItemMapper.selectCarParkItemList(carParkItem);
|
||||
for(CarParkItem a:itemList){
|
||||
CarParkRecord carParkRecord=new CarParkRecord();
|
||||
carParkRecord.setCustomerId(user.getCustomerId());
|
||||
carParkRecord.setParkId(user.getParkId());
|
||||
carParkRecord.setEquipmentId(a.getEquipmentId());
|
||||
carParkRecordMapper.insertCarParkRecord(carParkRecord);
|
||||
}
|
||||
} else {
|
||||
// 验证是否存在这个用户
|
||||
CarInfo u = carInfoMapper.selectCarInfoByCarNo(user.getPlate());
|
||||
SysPeople people = peopleMapper.selectSysPeopleByUserName(user.getPeopleName());
|
||||
if (people != null) {
|
||||
user.setPeopleId(people.getId());
|
||||
}
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、车牌信息 " + user.getPlate() + " 导入成功");
|
||||
}
|
||||
else if (isUpdateSupport)
|
||||
{
|
||||
user.setCarType("0");
|
||||
user.setCustomerId(u.getCustomerId());
|
||||
user.setUpdateBy(operName);
|
||||
this.updateCarInfo(user);
|
||||
//根据车场查询车辆
|
||||
if(user.getParkId()!=null){
|
||||
//删除车辆授权
|
||||
carParkRecordMapper.deleteCarParkRecordByCustomerId(user.getCustomerId());
|
||||
CarParkItem carParkItem=new CarParkItem();
|
||||
carParkItem.setParkId(user.getParkId());
|
||||
List<CarParkItem> itemList=carParkItemMapper.selectCarParkItemList(carParkItem);
|
||||
for(CarParkItem a:itemList){
|
||||
CarParkRecord carParkRecord=new CarParkRecord();
|
||||
carParkRecord.setCustomerId(user.getCustomerId());
|
||||
carParkRecord.setParkId(user.getParkId());
|
||||
carParkRecord.setEquipmentId(a.getEquipmentId());
|
||||
carParkRecordMapper.insertCarParkRecord(carParkRecord);
|
||||
}
|
||||
CarPark carPark = carParkMapper.selectCarParkByName(user.getParkName());
|
||||
if (carPark != null) {
|
||||
user.setParkId(carPark.getId());
|
||||
}
|
||||
if (StringUtils.isNull(u)) {
|
||||
user.setCarType("0");
|
||||
user.setCreateBy(operName);
|
||||
this.insertCarInfo(user);
|
||||
//保存车辆授权
|
||||
//根据车场查询车辆
|
||||
if (user.getParkId() != null) {
|
||||
List<Long> list = new ArrayList<>();
|
||||
list.add(user.getParkId());
|
||||
list.add(carPark.getParentId());
|
||||
CarParkItem carParkItem = new CarParkItem();
|
||||
carParkItem.setParkIds(list);
|
||||
List<CarParkItem> itemList = carParkItemMapper.selectCarParkItemList(carParkItem);
|
||||
for (CarParkItem a : itemList) {
|
||||
CarParkRecord carParkRecord = new CarParkRecord();
|
||||
carParkRecord.setCustomerId(user.getCustomerId());
|
||||
carParkRecord.setParkId(a.getParkId());
|
||||
carParkRecord.setEquipmentId(a.getEquipmentId());
|
||||
carParkRecordMapper.insertCarParkRecord(carParkRecord);
|
||||
}
|
||||
}
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、车牌信息 " + user.getPlate() + " 导入成功");
|
||||
} else if (isUpdateSupport) {
|
||||
user.setCarType("0");
|
||||
user.setCustomerId(u.getCustomerId());
|
||||
user.setUpdateBy(operName);
|
||||
this.updateCarInfo(user);
|
||||
//根据车场查询车辆
|
||||
if (user.getParkId() != null) {
|
||||
//删除车辆授权
|
||||
carParkRecordMapper.deleteCarParkRecordByCustomerId(user.getCustomerId());
|
||||
|
||||
List<Long> list = new ArrayList<>();
|
||||
list.add(user.getParkId());
|
||||
list.add(carPark.getParentId());
|
||||
CarParkItem carParkItem = new CarParkItem();
|
||||
carParkItem.setParkIds(list);
|
||||
List<CarParkItem> itemList = carParkItemMapper.selectCarParkItemList(carParkItem);
|
||||
for (CarParkItem a : itemList) {
|
||||
CarParkRecord carParkRecord = new CarParkRecord();
|
||||
carParkRecord.setCustomerId(user.getCustomerId());
|
||||
carParkRecord.setParkId(a.getParkId());
|
||||
carParkRecord.setEquipmentId(a.getEquipmentId());
|
||||
carParkRecordMapper.insertCarParkRecord(carParkRecord);
|
||||
}
|
||||
}
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、车牌信息 " + user.getPlate() + " 更新成功");
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>" + failureNum + "、车牌信息 " + user.getPlate() + " 已存在");
|
||||
}
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、车牌信息 " + user.getPlate() + " 更新成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>" + failureNum + "、车牌信息 " + user.getPlate() + " 已存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、车牌信息 " + user.getPlate() + " 导入失败:";
|
||||
failureMsg.append(msg + e.getMessage());
|
||||
}
|
||||
}
|
||||
if (failureNum > 0)
|
||||
{
|
||||
if (failureNum > 0) {
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new ServiceException(failureMsg.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||
}
|
||||
return successMsg.toString();
|
||||
@@ -337,8 +330,8 @@ public class CarInfoServiceImpl implements ICarInfoService
|
||||
return carInfoMapper.selectCarInfoByPlate(plate);
|
||||
}
|
||||
|
||||
public boolean checkPlateNumberFormat(String content) {
|
||||
String pattern = "([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼]{1}(([A-HJ-Z]{1}[A-HJ-NP-Z0-9]{5})|([A-HJ-Z]{1}(([DF]{1}[A-HJ-NP-Z0-9]{1}[0-9]{4})|([0-9]{5}[DF]{1})))|([A-HJ-Z]{1}[A-D0-9]{1}[0-9]{3}警)))|([0-9]{6}使)|((([沪粤川云桂鄂陕蒙藏黑辽渝]{1}A)|鲁B|闽D|蒙E|蒙H)[0-9]{4}领)|(WJ[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼·•]{1}[0-9]{4}[TDSHBXJ0-9]{1})|([VKHBSLJNGCE]{1}[A-DJ-PR-TVY]{1}[0-9]{5})";
|
||||
public static boolean checkPlateNumberFormat(String content) {
|
||||
String pattern = "([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼]{1}(([A-HJ-Z]{1}[A-HJ-NP-Z0-9]{5})|([A-HJ-Z]{1}(([ADF]{1}[A-HJ-NP-Z0-9]{1}[0-9]{4})|([0-9]{5}[ADF]{1})))|([A-HJ-Z]{1}[A-D0-9]{1}[0-9]{3}警)))|([0-9]{6}使)|((([沪粤川云桂鄂陕蒙藏黑辽渝]{1}A)|鲁B|闽D|蒙E|蒙H)[0-9]{4}领)|(WJ[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼·•]{1}[0-9]{4}[TDSHBXJ0-9]{1})|([VKHBSLJNGCE]{1}[A-DJ-PR-TVY]{1}[0-9]{5})";
|
||||
return Pattern.matches(pattern, content);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.dcsoft.system.vehicle.service.impl;
|
||||
|
||||
import com.dcsoft.common.core.utils.CollUtil;
|
||||
import com.dcsoft.common.core.utils.DateUtils;
|
||||
import com.dcsoft.system.vehicle.domain.CarPark;
|
||||
import com.dcsoft.system.vehicle.mapper.CarParkMapper;
|
||||
@@ -7,7 +8,9 @@ import com.dcsoft.system.vehicle.service.ICarParkService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 车场信息Service业务层处理
|
||||
@@ -40,9 +43,22 @@ public class CarParkServiceImpl implements ICarParkService
|
||||
* @return 车场信息
|
||||
*/
|
||||
@Override
|
||||
public List<CarPark> selectCarParkList(CarPark carPark)
|
||||
{
|
||||
return carParkMapper.selectCarParkList(carPark);
|
||||
public List<CarPark> selectCarParkList(CarPark carPark) {
|
||||
List<CarPark> carParks = carParkMapper.selectCarParkList(carPark);
|
||||
|
||||
List<Long> collect = carParks.stream().map(CarPark::getParentId).filter(parentId -> parentId != 0).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
List<CarPark> parkList = carParkMapper.selectByIds(collect);
|
||||
for (CarPark park : parkList) {
|
||||
for (CarPark carPark1 : carParks) {
|
||||
if (park.getId().equals(carPark1.getParentId())) {
|
||||
carPark1.setParentIdName(park.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return carParks;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,4 +110,9 @@ public class CarParkServiceImpl implements ICarParkService
|
||||
{
|
||||
return carParkMapper.deleteCarParkById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CarPark> getCarParkSelect(Long id) {
|
||||
return carParkMapper.getCarParkSelect(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="enable != null">enable = #{enable},</if>
|
||||
<if test="plate != null and plate != ''">plate = #{plate},</if>
|
||||
<if test="timeSegEnable != null and timeSegEnable != ''">time_seg_enable = #{timeSegEnable},</if>
|
||||
<if test="segTime != null">seg_time = #{segTime},</if>
|
||||
seg_time = #{segTime},
|
||||
<if test="needAlarm != null">need_alarm = #{needAlarm},</if>
|
||||
<if test="vehicleCode != null">vehicle_code = #{vehicleCode},</if>
|
||||
<if test="vehicleComment != null">vehicle_comment = #{vehicleComment},</if>
|
||||
|
||||
@@ -21,6 +21,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<where>
|
||||
<if test="equipmentId != null "> and equipment_id = #{equipmentId}</if>
|
||||
<if test="parkId != null "> and park_id = #{parkId}</if>
|
||||
<if test="parkIds != null and parkIds.size() > 0"> and park_id in
|
||||
<foreach item="id" collection="parkIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="way != null and way != ''"> and way = #{way}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@@ -16,11 +16,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="spaceName" column="space_name" />
|
||||
<result property="autoLock" column="auto_lock" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCarParkVo">
|
||||
select cp.id, cp.name, cp.space_id, cp.cars_num, cp.surplus_num, cp.remark, cp.create_by, cp.create_time,
|
||||
cp.update_by, cp.update_time,ss.name space_name
|
||||
cp.update_by, cp.update_time,ss.name space_name,cp.auto_lock,cp.parent_id
|
||||
from car_park cp
|
||||
left join sys_space ss on cp.space_id=ss.id
|
||||
|
||||
@@ -51,6 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="autoLock != null">auto_lock,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
@@ -63,6 +67,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="autoLock != null">#{autoLock},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -78,6 +84,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="autoLock != null">auto_lock = #{autoLock},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -122,4 +130,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where cp.name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultType="com.dcsoft.system.vehicle.domain.CarPark">
|
||||
select cp.id, cp.name, cp.space_id, cp.cars_num, cp.surplus_num, cp.remark,cp.auto_lock,cp.parent_id
|
||||
from car_park cp
|
||||
where cp.id in
|
||||
<foreach item="id" collection="list" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getCarParkSelect" resultType="com.dcsoft.system.vehicle.domain.CarPark">
|
||||
select cp.id, cp.name
|
||||
from car_park cp
|
||||
where cp.id != #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select cpg.id, cpg.park_id, cpg.area, cpg.license, cpg.join_time, cpg.sn,cp.name park_name,se.name equipment_name,HOUR(TIMEDIFF(NOW(),cpg.join_time)) AS time_long
|
||||
from car_pass_gather cpg
|
||||
left join car_park cp on cp.id=cpg.park_id
|
||||
left join sys_equipment se on se.sequence=cpg.sn
|
||||
left join sys_equipment se on se.sequence=cpg.sn and se.product_id = 4
|
||||
</sql>
|
||||
|
||||
<select id="selectCarPassGatherList" parameterType="CarPassGather" resultMap="CarPassGatherResult">
|
||||
|
||||
@@ -28,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select cpr.id, cpr.park_id, cpr.unique_no, cpr.direction, cpr.license, cpr.pass_time, cpr.trigger_type, cpr.color_type,
|
||||
cpr.car_color, cpr.url, cpr.data_type, cpr.sn,cpi.way,cp.name park_name,se.name equipment_name,ci.unit,cpr.type
|
||||
from car_pass_record cpr
|
||||
left join sys_equipment se on cpr.sn=se.sequence
|
||||
left join sys_equipment se on cpr.sn=se.sequence and se.product_id = 4
|
||||
left join car_park_item cpi on cpi.equipment_id=se.id
|
||||
left join car_park cp on cp.id=cpi.park_id
|
||||
left join car_info ci on cpr.license=ci.plate
|
||||
|
||||
Reference in New Issue
Block a user