1.倒短磅新增皮重过期提醒。

This commit is contained in:
xiaosuonian 2025-07-14 16:32:00 +08:00
parent 72671b142e
commit 1e1da7086f
7 changed files with 102 additions and 3 deletions

View File

@ -128,4 +128,13 @@ public class EmpwgtdataController extends BaseController
return success(empwgtdataService.getCarnoEmpwgtData(carno));
}
@PreAuthorize("@ss.hasPermi('measurement/basedata:empwgtdata:query')")
@GetMapping(value = "/getCarnoEmpwgtDataStatus/{carno}")
public AjaxResult getCarnoEmpwgtDataStatus(@PathVariable("carno") String carno)
{
return success(empwgtdataService.getCarnoEmpwgtDataStatus(carno));
}
}

View File

@ -71,4 +71,11 @@ public interface IEmpwgtdataService extends IService<Empwgtdata>
public Empwgtdata selectEnableEmpwgtdata(Empwgtdata empwgtdata);
public Empwgtdata getCarnoEmpwgtData(String carno);
/**
* 根据车牌号获取当前皮重数据状态
* @param carno
* @return
*/
public String getCarnoEmpwgtDataStatus(String carno);
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.basedata.service.impl;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.List;
@ -10,6 +11,7 @@ import com.ruoyi.basedata.domain.Pounddata;
import com.ruoyi.basedata.service.IPounddataService;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.util.AllNumberUtil;
import com.ruoyi.util.Util;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@ -183,5 +185,51 @@ public class EmpwgtdataServiceImpl extends ServiceImpl<EmpwgtdataMapper, Empwgtd
return empwgtdata;
}
public String getCarnoEmpwgtDataStatus(String carno) {
// 获取皮重有效时间配置默认24小时
int effectiveHours = getConfigAsInt("HistoryPoundWeightEffectiveTime");
// 获取皮重过期提醒时间配置默认4小时
int reminderHours = getConfigAsInt("WeightExTime");
// 构建查询条件
Empwgtdata queryEmp = new Empwgtdata();
queryEmp.setCarno(carno);
// 获取有效时间点当前时间减去有效期
LocalDateTime effectiveTimePoint = LocalDateTime.now().minusHours(effectiveHours);
queryEmp.setWeighdt(Util.toDate(effectiveTimePoint));
// 查询有效皮重数据
Empwgtdata empwgtdata = selectEnableEmpwgtdata(queryEmp);
if (empwgtdata == null) {
return String.format("当前车辆: %s 没有可用的皮重数据!请先称皮重", carno);
}
// 检查皮重状态
LocalDateTime weighTime = Util.toLocalDateTime(empwgtdata.getWeighdt());
LocalDateTime expiryTime = weighTime.plusHours(effectiveHours);
LocalDateTime now = LocalDateTime.now();
// 计算剩余小时数正数表示未过期负数表示已过期
long hoursRemaining = ChronoUnit.HOURS.between(now, expiryTime);
if (hoursRemaining <= 0) {
return String.format("当前车辆: %s 的皮重数据已过期,请重新称重", carno);
} else if (hoursRemaining <= reminderHours) {
return String.format("当前车辆: %s 的皮重数据将在 %d 小时后过期,请及时更新!", carno, hoursRemaining);
}
return ""; // 皮重状态正常返回空字符串
}
// 辅助方法从配置服务获取整数值带默认值和异常处理
private int getConfigAsInt(String configKey) {
try {
String value = configService.selectConfigByKey(configKey);
return Integer.parseInt(value);
} catch (Exception e) {
throw new RuntimeException("获取配置项 " + configKey + " 出现异常,请检查!");
}
}
}

View File

@ -10,6 +10,9 @@ import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
@Component
@ -75,4 +78,14 @@ public class Util {
}
return false;
}
// 辅助方法LocalDateTime转Date
public static Date toDate(LocalDateTime localDateTime) {
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
// 辅助方法Date转LocalDateTime
public static LocalDateTime toLocalDateTime(Date date) {
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}
}

View File

@ -58,3 +58,11 @@ export function getCarnoEmpwgtData(carno) {
method: 'get'
})
}
// 查询历史皮重重量数据状态。
export function getCarnoEmpwgtDataStatus(carno) {
return request({
url: '/measurement/basedata/empwgtdata/getCarnoEmpwgtDataStatus/' + carno,
method: 'get'
})
}

View File

@ -710,7 +710,7 @@ import SearchSelect from "@/components/SearchSelect/index.vue";
//
import { listTruepound, getTruepound, delTruepound, addTruepound, updateTruepound } from "@/api/measurement/basedata/truepound"
import {mulToString} from "@/api/tool/util";
import {addEmpwgtdata, getCarnoEmpwgtData, listEmpwgtdata} from "@/api/measurement/basedata/empwgtdata";
import {addEmpwgtdata, getCarnoEmpwgtData, listEmpwgtdata,getCarnoEmpwgtDataStatus} from "@/api/measurement/basedata/empwgtdata";
//
import { listPoundmst,getNumber, getPoundmst, delPoundmst, addPoundmst, updatePoundmst } from "@/api/measurement/bill/poundmst"
//
@ -1025,7 +1025,7 @@ watch: {
//
handleSearchHistoryPound() {
this.historyPoundLoading = true
var thisqueryParams = {
const thisqueryParams = {
carno:"",
isinuse:"Y"
};
@ -1036,7 +1036,19 @@ watch: {
this.queryPageParams.historyPound.total = response.total;
this.historyPoundList = response.rows;
this.historyPoundLoading = false;
})
});
//
getCarnoEmpwgtDataStatus(this.queryParams.carno).then(response => {
const msg = response.msg;
if ("" !== msg){
//
this.$confirm(msg, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
}
});
},
//,1
handleSearchMstBillFirst(){

View File

@ -748,6 +748,8 @@ export default {
},
//
handleSearchMstBill(){
//
if (!this.checkPoundSelected())return;
this.mstBillLoading = true
this.queryPageParams.mstBill.poundid = this.truepoundData.buspoundid;
listPoundmst(this.queryPageParams.mstBill).then(response => {