更新费率表写入创建人和更新人字段

This commit is contained in:
panshuling321 2022-02-21 13:34:26 +08:00
parent 715c4a777c
commit 00467991d5
3 changed files with 43 additions and 30 deletions

View File

@ -178,9 +178,8 @@ public class XhpcChargingStationController extends BaseController {
*/ */
@Log(title = "添加场站", businessType = BusinessType.INSERT) @Log(title = "添加场站", businessType = BusinessType.INSERT)
@PostMapping(value = "/addXhpcChargingStation") @PostMapping(value = "/addXhpcChargingStation")
public AjaxResult addXhpcChargingStation(@RequestBody XhpcChargingStationDto xhpcChargingStationDto) { public AjaxResult addXhpcChargingStation(HttpServletRequest request, @RequestBody XhpcChargingStationDto xhpcChargingStationDto) {
return xhpcChargingStationService.addXhpcChargingStation(request, xhpcChargingStationDto);
return xhpcChargingStationService.addXhpcChargingStation(xhpcChargingStationDto);
} }
/** /**
@ -215,9 +214,9 @@ public class XhpcChargingStationController extends BaseController {
*/ */
@Log(title = "编辑电站(编辑费率)", businessType = BusinessType.UPDATE) @Log(title = "编辑电站(编辑费率)", businessType = BusinessType.UPDATE)
@PostMapping(value = "/updateXhpcRateTime") @PostMapping(value = "/updateXhpcRateTime")
public AjaxResult updateXhpcRateTime(@RequestBody XhpcChargingStationDto xhpcChargingStationDto) { public AjaxResult updateXhpcRateTime(HttpServletRequest request, @RequestBody XhpcChargingStationDto xhpcChargingStationDto) {
return xhpcChargingStationService.updateXhpcRateTime(xhpcChargingStationDto); return xhpcChargingStationService.updateXhpcRateTime(request, xhpcChargingStationDto);
} }
} }

View File

@ -121,7 +121,7 @@ public interface IXhpcChargingStationService {
* @param xhpcChargingStationDto * @param xhpcChargingStationDto
* @return * @return
*/ */
AjaxResult addXhpcChargingStation(XhpcChargingStationDto xhpcChargingStationDto); AjaxResult addXhpcChargingStation(HttpServletRequest request, XhpcChargingStationDto xhpcChargingStationDto);
/** /**
@ -185,7 +185,7 @@ public interface IXhpcChargingStationService {
* @param * @param
* @return * @return
*/ */
AjaxResult updateXhpcRateTime(XhpcChargingStationDto xhpcChargingStationDto); AjaxResult updateXhpcRateTime(HttpServletRequest request, XhpcChargingStationDto xhpcChargingStationDto);
/** /**
* 上传桩编号和删除编号 * 上传桩编号和删除编号

View File

@ -314,7 +314,9 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
@Override @Override
@Transactional @Transactional
public AjaxResult addXhpcChargingStation(XhpcChargingStationDto xhpcChargingStationDto) { public AjaxResult addXhpcChargingStation(HttpServletRequest request, XhpcChargingStationDto xhpcChargingStationDto) {
LoginUser loginUser = logUserUtils.getLogUser(request);
String userName = loginUser.getUsername();
if (xhpcChargingStationDto.getName() == null || "".equals(xhpcChargingStationDto.getName())) { if (xhpcChargingStationDto.getName() == null || "".equals(xhpcChargingStationDto.getName())) {
return AjaxResult.error(1001, "电站名称不能为空"); return AjaxResult.error(1001, "电站名称不能为空");
@ -424,6 +426,8 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
//添加费率计费模型 //添加费率计费模型
XhpcRateModel xhpcRateModel = new XhpcRateModel(); XhpcRateModel xhpcRateModel = new XhpcRateModel();
BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel); BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel);
xhpcRateModel.setCreateBy(userName);
xhpcRateModel.setUpdateBy(userName);
int i = xhpcChargingStationMapper.insertXhpcRateModel(xhpcRateModel); int i = xhpcChargingStationMapper.insertXhpcRateModel(xhpcRateModel);
if (i == 0) { if (i == 0) {
return AjaxResult.error("1005", "费率计费模型添加失败"); return AjaxResult.error("1005", "费率计费模型添加失败");
@ -464,6 +468,8 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
xhpcRate.setServiceFee(xhpcRateDto.getServiceFee()); xhpcRate.setServiceFee(xhpcRateDto.getServiceFee());
xhpcRate.setRateModelId(rateModelId); xhpcRate.setRateModelId(rateModelId);
xhpcRate.setRateValue(xhpcRateDto.getId()); xhpcRate.setRateValue(xhpcRateDto.getId());
xhpcRate.setCreateBy(userName);
xhpcRate.setUpdateBy(userName);
xhpcChargingStationMapper.insertXhpcRate(xhpcRate); xhpcChargingStationMapper.insertXhpcRate(xhpcRate);
map.put(xhpcRateDto.getId(), xhpcRate.getRateId()); map.put(xhpcRateDto.getId(), xhpcRate.getRateId());
}else{ }else{
@ -517,15 +523,15 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue); sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName);
} }
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
if(!endTime.equals("24:00:00")) { if(!endTime.equals("24:00:00")) {
if(rateValue ==null || "".equals(rateValue)){ if(rateValue ==null || "".equals(rateValue)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName);
} }
}else{ }else{
if(k == 0){ if(k == 0){
@ -534,9 +540,9 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue); sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName);
} }
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
}else if(k < list.size()-1){ }else if(k < list.size()-1){
String endTimeK = list.get(k - 1).getEndTime(); String endTimeK = list.get(k - 1).getEndTime();
if (!endTimeK.equals(startTime)) { if (!endTimeK.equals(startTime)) {
@ -544,10 +550,10 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName);
} }
//并把本条数据也添加上 //并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
}else{ }else{
String endTimeK = list.get(k - 1).getEndTime(); String endTimeK = list.get(k - 1).getEndTime();
if (!endTimeK.equals(startTime)) { if (!endTimeK.equals(startTime)) {
@ -556,17 +562,17 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
//添加一条默认费率时段 //添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName);
} }
//并把本条数据也添加上 //并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
if (!endTime.equals("24:00:00")) { if (!endTime.equals("24:00:00")) {
if(rateValue ==null || "".equals(rateValue)){ if(rateValue ==null || "".equals(rateValue)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
//添加一条默认费率时段 //添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName);
} }
} }
} }
@ -699,7 +705,7 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
return map; return map;
} }
private int addXhpcRateTime(Long chargingStationId, Long rateModelId, Long defaultPeriodId, String startTime, String endTime, int sort, int type, String rateValue) { private int addXhpcRateTime(Long chargingStationId, Long rateModelId, Long defaultPeriodId, String startTime, String endTime, int sort, int type, String rateValue, String userName) {
XhpcRateTime xhpcRateTime = new XhpcRateTime(); XhpcRateTime xhpcRateTime = new XhpcRateTime();
xhpcRateTime.setChargingStationId(chargingStationId); xhpcRateTime.setChargingStationId(chargingStationId);
@ -713,6 +719,8 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
xhpcRateTime.setType(type); xhpcRateTime.setType(type);
xhpcRateTime.setRateValue(rateValue); xhpcRateTime.setRateValue(rateValue);
xhpcRateTime.setCreateTime(Calendar.getInstance().getTime()); xhpcRateTime.setCreateTime(Calendar.getInstance().getTime());
xhpcRateTime.setCreateBy(userName);
xhpcRateTime.setUpdateBy(userName);
xhpcChargingStationMapper.insertXhpcRateTime(xhpcRateTime); xhpcChargingStationMapper.insertXhpcRateTime(xhpcRateTime);
return sort++; return sort++;
} }
@ -875,7 +883,10 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
@Override @Override
@Transactional @Transactional
public AjaxResult updateXhpcRateTime(XhpcChargingStationDto xhpcChargingStationDto) { public AjaxResult updateXhpcRateTime(HttpServletRequest request, XhpcChargingStationDto xhpcChargingStationDto) {
LoginUser loginUser = logUserUtils.getLogUser(request);
String userName = loginUser.getUsername();
//电站id不能为空 //电站id不能为空
if (xhpcChargingStationDto.getChargingStationId() == null) { if (xhpcChargingStationDto.getChargingStationId() == null) {
return AjaxResult.error("1001", "电站id为空"); return AjaxResult.error("1001", "电站id为空");
@ -932,6 +943,7 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel); BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel);
xhpcRateModel.setRemark("修改"); xhpcRateModel.setRemark("修改");
xhpcRateModel.setCreateTime(new Date()); xhpcRateModel.setCreateTime(new Date());
xhpcRateModel.setCreateBy(userName);
int i = xhpcChargingStationMapper.insertXhpcRateModel(xhpcRateModel); int i = xhpcChargingStationMapper.insertXhpcRateModel(xhpcRateModel);
if (i == 0) { if (i == 0) {
return AjaxResult.error("1005", "费率计费模型添加失败"); return AjaxResult.error("1005", "费率计费模型添加失败");
@ -962,6 +974,8 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
xhpcRate.setServiceFee(xhpcRateDto.getServiceFee()); xhpcRate.setServiceFee(xhpcRateDto.getServiceFee());
xhpcRate.setRateModelId(rateModelId); xhpcRate.setRateModelId(rateModelId);
xhpcRate.setRateValue(xhpcRateDto.getId()); xhpcRate.setRateValue(xhpcRateDto.getId());
xhpcRate.setUpdateBy(userName);
xhpcRate.setCreateBy(userName);
xhpcChargingStationMapper.insertXhpcRate(xhpcRate); xhpcChargingStationMapper.insertXhpcRate(xhpcRate);
map.put(xhpcRateDto.getId(), xhpcRate.getRateId()); map.put(xhpcRateDto.getId(), xhpcRate.getRateId());
}else{ }else{
@ -1015,15 +1029,15 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue); sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName);
} }
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
if(!endTime.equals("24:00:00")) { if(!endTime.equals("24:00:00")) {
if(rateValue ==null || "".equals(rateValue)){ if(rateValue ==null || "".equals(rateValue)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName);
} }
}else{ }else{
if(k == 0){ if(k == 0){
@ -1032,9 +1046,9 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue); sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName);
} }
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
}else if(k < list.size()-1){ }else if(k < list.size()-1){
String endTimeK = list.get(k - 1).getEndTime(); String endTimeK = list.get(k - 1).getEndTime();
if (!endTimeK.equals(startTime)) { if (!endTimeK.equals(startTime)) {
@ -1042,10 +1056,10 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName);
} }
//并把本条数据也添加上 //并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
}else{ }else{
String endTimeK = list.get(k - 1).getEndTime(); String endTimeK = list.get(k - 1).getEndTime();
if (!endTimeK.equals(startTime)) { if (!endTimeK.equals(startTime)) {
@ -1054,17 +1068,17 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
//添加一条默认费率时段 //添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName);
} }
//并把本条数据也添加上 //并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
if (!endTime.equals("24:00:00")) { if (!endTime.equals("24:00:00")) {
if(rateValue ==null || "".equals(rateValue)){ if(rateValue ==null || "".equals(rateValue)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率"); return AjaxResult.error("请填写默认时间段费率");
} }
//添加一条默认费率时段 //添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue); sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName);
} }
} }
} }