兴安优化提交

This commit is contained in:
zc
2025-07-24 11:03:31 +08:00
parent 83c996a34b
commit 2625943fee
6 changed files with 36 additions and 44 deletions

View File

@@ -1,5 +1,6 @@
package com.dcsoft.system.vehicle.controller; package com.dcsoft.system.vehicle.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.dcsoft.common.core.utils.poi.ExcelUtil; import com.dcsoft.common.core.utils.poi.ExcelUtil;
import com.dcsoft.common.core.web.controller.BaseController; import com.dcsoft.common.core.web.controller.BaseController;
@@ -104,11 +105,15 @@ public class CarInfoController extends BaseController
@RequiresPermissions("system:carInfo:add") @RequiresPermissions("system:carInfo:add")
@Log(title = "车辆信息", businessType = BusinessType.INSERT) @Log(title = "车辆信息", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody CarInfo carInfo) public AjaxResult add(@RequestBody CarInfo carInfo) {
{
if (!StrUtil.equals("2", carInfo.getCarType()) && !checkPlateNumberFormat(carInfo.getPlate())) { if (!StrUtil.equals("2", carInfo.getCarType()) && !checkPlateNumberFormat(carInfo.getPlate())) {
return AjaxResult.error("车牌号不正确!"); return AjaxResult.error("车牌号不正确!");
} }
CarInfo car = carInfoService.selectCarInfoByPlate(carInfo.getPlate());
if (ObjectUtil.isNotEmpty(car)) {
return AjaxResult.error("车牌号已存在,不可重复添加!");
}
int i = carInfoService.insertCarInfo(carInfo); int i = carInfoService.insertCarInfo(carInfo);
//保存车辆授权 //保存车辆授权
//根据车场查询车辆 //根据车场查询车辆

View File

@@ -61,4 +61,6 @@ public interface CarInfoMapper
public int deleteCarInfoByCustomerIds(Long[] customerIds); public int deleteCarInfoByCustomerIds(Long[] customerIds);
public CarInfo selectCarInfoByCarNo(String plate); public CarInfo selectCarInfoByCarNo(String plate);
CarInfo selectCarInfoByPlate(String plate);
} }

View File

@@ -74,4 +74,6 @@ public interface ICarInfoService
public int selectCarInfo(Long id,String flag); public int selectCarInfo(Long id,String flag);
String importData(List<CarInfo> userList, boolean updateSupport, String operName); String importData(List<CarInfo> userList, boolean updateSupport, String operName);
CarInfo selectCarInfoByPlate(String plate);
} }

View File

@@ -332,6 +332,11 @@ public class CarInfoServiceImpl implements ICarInfoService
return successMsg.toString(); return successMsg.toString();
} }
@Override
public CarInfo selectCarInfoByPlate(String plate) {
return carInfoMapper.selectCarInfoByPlate(plate);
}
public boolean checkPlateNumberFormat(String content) { 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}(([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})";
return Pattern.matches(pattern, content); return Pattern.matches(pattern, content);

View File

@@ -107,7 +107,7 @@ public class VisCarryStuffController extends BaseController {
@Value("${app.deptId:228}") @Value("${app.deptId:228}")
private String appDeptId; private String appDeptId;
@Value("${app.watermarkUrl:http://81.68.71.142:9000/others/gz/111.png}") @Value("${app.watermarkUrl:http://81.68.71.142:9000/others/gz/gz.png}")
private String watermarkUrl; private String watermarkUrl;
@Autowired @Autowired
@@ -565,6 +565,10 @@ public class VisCarryStuffController extends BaseController {
}); });
} }
//查询申请二维码
CheckCodeVo checkCodeVo = visCarryStuffService.selectStuffCheckCode(id);
String code = checkCodeVo.getCode();
// 创建PDF文档 // 创建PDF文档
Document document = new Document(new RectangleReadOnly(842F, 595F)); Document document = new Document(new RectangleReadOnly(842F, 595F));
document.setMargins(60, 60, 72, 72); document.setMargins(60, 60, 72, 72);
@@ -572,13 +576,9 @@ public class VisCarryStuffController extends BaseController {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document, baos); PdfWriter writer = PdfWriter.getInstance(document, baos);
// 添加水印事件处理器(只有保安部门才可添加水印) // 添加水印事件处理器
LoginUser user = SecurityUtils.getLoginUser();
SysUser sysUser = sysUserService.selectUserById(user.getUserid());
if (ObjectUtil.isNotNull(sysUser) && StringUtils.equals(appDeptId, String.valueOf(sysUser.getDeptId()))) {
PdfWatermark pdfWatermark = new PdfWatermark(watermarkUrl); PdfWatermark pdfWatermark = new PdfWatermark(watermarkUrl);
writer.setPageEvent(pdfWatermark); writer.setPageEvent(pdfWatermark);
}
document.open(); document.open();
@@ -700,34 +700,6 @@ public class VisCarryStuffController extends BaseController {
return cell; return cell;
} }
// 水印处理类
/*private static class PdfWatermark extends PdfPageEventHelper {
@Override
public void onEndPage(PdfWriter writer, Document document) {
try {
// 加载公章图片
Image seal = Image.getInstance("http://81.68.71.142:9000/others/gz/111.png");
// 设置水印位置(右下角)
float x = document.right() - seal.getScaledWidth() - 50;
float y = document.bottom() + 50;
// 设置透明度
PdfContentByte canvas = writer.getDirectContentUnder();
seal.setAbsolutePosition(x, y);
seal.scaleAbsolute(100, 100); // 调整大小
canvas.saveState();
PdfGState gs = new PdfGState();
gs.setFillOpacity(0.5f); // 设置透明度
canvas.setGState(gs);
canvas.addImage(seal);
canvas.restoreState();
} catch (Exception e) {
log.error("添加水印异常:", e);
}
}
}*/
} }

View File

@@ -162,5 +162,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where ci.plate = #{plate} and ci.del_flag=0 where ci.plate = #{plate} and ci.del_flag=0
limit 1 limit 1
</select> </select>
<select id="selectCarInfoByPlate" resultMap="CarInfoResult">
select
*
from car_info
where plate = #{plate}
</select>
</mapper> </mapper>