添加了汽车入库时,接入finance,自动计时计算费用

master
Miku 2 years ago
parent 18f05d2998
commit bb2ee3b067

@ -92,11 +92,11 @@ public class CarManage extends PageBean implements Serializable {
@Column(name = "type", length = 4)
private Short type;
/**
* 0 1
*/
@Column(name = "status", length = 4)
private Short status;
/**
* 0 1
*/
@Column(name = "status", length = 4)
private Short status;
/**
*
@ -111,19 +111,19 @@ public class CarManage extends PageBean implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Timestamp validityTime;
/**
*
*/
@Column(name = "gmt_create")
/**
*
*/
@Column(name = "gmt_create")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") // 该属性在序列化为JSON时按指定格式进行格式化
private Timestamp gmtCreate;
private Timestamp gmtCreate;
/**
*
*/
@Column(name = "gmt_modified")
/**
*
*/
@Column(name = "gmt_modified")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Timestamp gmtModified;
private Timestamp gmtModified;
/**
* id

@ -3,6 +3,7 @@ package com.smart.module.car.service;
import com.smart.common.model.Result;
import com.smart.common.util.ExcelExport;
import com.smart.module.car.entity.CarManage;
import com.smart.module.finance.entity.Order;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import java.io.IOException;
@ -34,6 +35,13 @@ public interface CarManageService {
*/
CarManage getByPlateNumber(String plateNumber, Long parkManageId);
/**
*
* @param entity
* @return
*/
Result renew(Order entity);
/**
* Excel
* @param orgId ID

@ -1,6 +1,7 @@
package com.smart.module.car.service;
import com.smart.common.model.Result;
import com.smart.module.car.entity.CarManage;
import com.smart.module.car.entity.CarParkingRecord;
/**

@ -11,6 +11,8 @@ import com.smart.common.util.ShiroUtils;
import com.smart.module.car.entity.CarManage;
import com.smart.module.car.repository.CarManageRepository;
import com.smart.module.car.service.CarManageService;
import com.smart.module.finance.entity.Order;
import com.smart.module.finance.service.OrderService;
import com.smart.module.sys.entity.SysUser;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@ -38,6 +40,8 @@ public class CarManageServiceImpl implements CarManageService {
@Autowired
private CarManageRepository carManageRepository; // 汽车管理的数据访问层接口
@Autowired
private OrderService orderService; // 订单管理的业务逻辑层接口
// 保存汽车管理信息并刷新到数据库
@Override
@ -80,7 +84,21 @@ public class CarManageServiceImpl implements CarManageService {
return carManage;
}
// 续租
@Override
@Transactional(rollbackFor=Exception.class)
public Result renew(Order entity) {
SysUser user = ShiroUtils.getUserEntity();
entity.setOrgId(user.getOrgId());
entity.setUserCreate(user.getUserId());
entity.setBody("车位续租");
entity.setStatus(SystemConstant.PAY_STATUS_YES);
orderService.save(entity); // 保存订单信息
Timestamp validityTime = entity.getValidityTime();
String nativeSql = "UPDATE app_car_manage SET validity_time=? WHERE id=?";
dynamicQuery.nativeExecuteUpdate(nativeSql,validityTime,entity.getCarId()); // 执行原生更新语句,更新有效期时间
return Result.ok();
}
// 导出数据至 Excel
@Override

@ -9,6 +9,8 @@ import com.smart.common.util.ShiroUtils;
import com.smart.module.car.entity.CarParkingRecord;
import com.smart.module.car.repository.CarParkingRecordRepository;
import com.smart.module.car.service.CarParkingRecordService;
import com.smart.module.finance.entity.Order;
import com.smart.module.finance.service.OrderService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
@ -28,12 +30,29 @@ public class CarParkingRecordServiceImpl implements CarParkingRecordService {
private DynamicQuery dynamicQuery;
@Autowired
private CarParkingRecordRepository carParkingRecordRepository;
@Autowired
private OrderService orderService;
@Override
@Transactional(rollbackFor=Exception.class)
public Result save(CarParkingRecord entity) {
if(entity.getId()!=null){
/**
*
*/
if(entity.getType().shortValue() != SystemConstant.CAR_TYPE_TEMP){
Order order = new Order();
order.setOrgId(entity.getOrgId());
order.setParkManageId(entity.getParkManageId());
order.setUserCreate(-1L);
order.setBody("临时车辆");
order.setStatus(SystemConstant.PAY_STATUS_NO);
order.setGmtCreate(DateUtils.getTimestamp());
order.setPlateNumber(entity.getPlateNumber());
order.setTotalFee(entity.getCost());
orderService.save(order);
}
}
carParkingRecordRepository.saveAndFlush(entity);
return Result.ok("保存成功");
}

@ -1,23 +1,23 @@
package com.smart.module.car.service.impl;
import com.smart.common.constant.SystemConstant;
import com.smart.common.dynamicquery.DynamicQuery;
import com.smart.common.model.PageBean;
import com.smart.common.model.Result;
import com.smart.common.util.DateUtils;
import com.smart.common.util.ShiroUtils;
import com.smart.module.car.entity.CarParkManage;
import com.smart.module.car.repository.ParkManageRepository;
import com.smart.module.car.service.ParkManageService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.smart.common.constant.SystemConstant; // 导入系统常量
import com.smart.common.dynamicquery.DynamicQuery; // 导入动态查询工具类
import com.smart.common.model.PageBean; // 导入分页实体类
import com.smart.common.model.Result; // 导入结果实体类
import com.smart.common.util.DateUtils; // 导入日期工具类
import com.smart.common.util.ShiroUtils; // 导入权限工具类
import com.smart.module.car.entity.CarParkManage; // 导入停车场实体类
import com.smart.module.car.repository.ParkManageRepository; // 导入停车场仓库类
import com.smart.module.car.service.ParkManageService; // 导入停车场服务接口
import org.apache.commons.lang3.StringUtils; // 导入字符串工具类
import org.springframework.beans.factory.annotation.Autowired; // 导入自动装配注解
import org.springframework.data.domain.PageRequest; // 导入分页请求类
import org.springframework.data.domain.Pageable; // 导入分页对象接口
import org.springframework.stereotype.Service; // 导入服务注解
import org.springframework.transaction.annotation.Transactional; // 导入事务注解
import java.util.List;
import java.util.Map;
import java.util.List; // 导入列表类
import java.util.Map; // 导入映射类
@Service // 服务注解,表示该类为一个服务类
public class ParkManageServiceImpl implements ParkManageService {

@ -5,6 +5,7 @@ import com.smart.common.util.ExcelExport;
import com.smart.module.car.entity.CarManage;
import com.smart.module.car.repository.CarManageRepository;
import com.smart.module.car.service.CarManageService;
import com.smart.module.finance.entity.Order;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
@ -69,6 +70,15 @@ public class CarManageController {
return Result.ok();
}
/**
*
*/
@PostMapping("renew")
@RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR)
public Result renew(@RequestBody Order entity){
return carManageService.renew(entity);
}
/**
* Excel

@ -15,17 +15,18 @@ import com.smart.module.car.repository.ParkManageRepository;
import com.smart.module.car.service.CarManageService;
import com.smart.module.car.service.CarParkingRecordService;
import com.smart.module.car.util.BaiDuUtils;
//import net.sourceforge.tess4j.ITesseract;
//import net.sourceforge.tess4j.Tesseract;
import com.smart.module.car.util.CostUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
//import net.sourceforge.tess4j.ITesseract;
//import net.sourceforge.tess4j.Tesseract;
//import net.sourceforge.tess4j.TesseractException;
import java.io.File;
//import java.io.IOException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@ -131,6 +132,7 @@ public class DistinguishController {
*
*/
if(record!=null){
record.setCost(CostUtils.calculate(record,carParkManage));
record.setGmtOut(DateUtils.getTimestamp());
map.put("msg","出厂成功");
}else{

@ -5,6 +5,7 @@ import com.smart.common.util.OrderUtils;
import com.smart.module.car.entity.CarParkManage;
import com.smart.module.car.repository.ParkManageRepository;
import com.smart.module.car.service.ParkManageService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
@ -32,7 +33,6 @@ public class ParkManageController {
// 注入停车场管理仓库,用于查询停车场信息
/**
*
*/

Loading…
Cancel
Save