优化每月5日凌晨三点执行一次,首次可使用接口调用入库最小费额http://ip:port/MinFeeInsertDb/sys/insertMinFee

main
gaoshuguang 2 years ago
parent 0df5ed1766
commit 4a93bb68ef

@ -4,7 +4,7 @@
<inspection_tool class="AlibabaVarargsParameter" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="63" name="Java" />
<language minSize="76" name="Java" />
</Languages>
</inspection_tool>
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">

@ -40,14 +40,14 @@ public class TimeTaskInfo {
String uuid = UuidUtil.getUuid();
//获取最小费额文件的位置
String UserType = PropertiesUtil.getValue("UserType");
if (Constant.STR_TWO.equals(UserType)) {
log.info("[uuid:{}]分中心定时执行最小费额文件入库处理,当前时间={}", uuid, LocalDateTime.now());
if (Constant.STR_TWO.equals(UserType)||Constant.STR_FOUR.equals(UserType)) {
log.info("[uuid:{}]总中心或分中心定时执行最小费额文件入库处理,当前时间={}", uuid, LocalDateTime.now());
long start = System.currentTimeMillis();
minFeeInsertService.fileInsertDatabase(uuid);
long end = System.currentTimeMillis();
log.info("[uuid:{}]分中心定时执行最小费额文件入库处理执行完成,耗时:{}毫秒", uuid, end - start);
log.info("[uuid:{}]总中心或分中心定时执行最小费额文件入库处理执行完成,耗时:{}毫秒", uuid, end - start);
} else {
log.info("[uuid:{}]当前服务不是分中心服务,不执行最小费额文件入库处理", uuid);
log.info("[uuid:{}]当前服务不是总中心或分中心服务,不执行最小费额文件入库处理", uuid);
}
}

@ -0,0 +1,45 @@
package com.nm.gsgl.controller;
import com.nm.gsgl.common.Constant;
import com.nm.gsgl.common.utils.PropertiesUtil;
import com.nm.gsgl.common.utils.UuidUtil;
import com.nm.gsgl.entity.Res;
import com.nm.gsgl.service.MinFeeInsertService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Map;
/**
* @author: shuguang
* @date: 20240407 10:19
* @description:
*/
@RestController
@Slf4j
public class ManualController {
@Resource
private MinFeeInsertService minFeeInsertService;
@GetMapping("/sys/insertMinFee")
public Res queryImageInfo() {
String uuid = UuidUtil.getUuid();
//获取最小费额文件的位置
String UserType = PropertiesUtil.getValue("UserType");
if (Constant.STR_TWO.equals(UserType)||Constant.STR_FOUR.equals(UserType)) {
log.info("[uuid:{}]总中心或分中心手动执行最小费额文件入库处理,当前时间={}", uuid, LocalDateTime.now());
long start = System.currentTimeMillis();
minFeeInsertService.fileInsertDatabase(uuid);
long end = System.currentTimeMillis();
log.info("[uuid:{}]总中心或分中心手动执行最小费额文件入库处理执行完成,耗时:{}毫秒", uuid, end - start);
} else {
log.info("[uuid:{}]当前服务不是总中心或分中心服务,不执行最小费额文件入库处理", uuid);
}
return Res.success();
}
}

@ -3,6 +3,7 @@ package com.nm.gsgl.entity.minfee;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.apache.ibatis.type.JdbcType;
import java.util.Date;
@ -14,7 +15,7 @@ import java.util.Date;
@TableName("ALLROADFEE_TABLE")
@Data
public class AllRoadFee {
@TableField("BEGDATE")
@TableField(value = "BEGDATE",jdbcType = JdbcType.DATE,update = "to_date(#{BEGDATE},'yyyy-mm-dd hh24:mi:ss')")
private Date begdate;
@TableField("VERSION")
private String version;

@ -59,6 +59,7 @@ public class MinFeeInsertServiceImpl implements MinFeeInsertService {
try {
//获取最小费额文件的位置
String DownloadPath = PropertiesUtil.getValue("DownloadPath") + File.separator + "DownloadFilePath";
log.info("[uuid:{}]-获取最小费额文件的位置{}", uuid,DownloadPath);
//获取解压缩文件目录
String ExtractDirPath = PropertiesUtil.getValue("ExtractDirPath");
FileUtil.fileCreat(ExtractDirPath);
@ -117,46 +118,54 @@ public class MinFeeInsertServiceImpl implements MinFeeInsertService {
QueryWrapper<NameTable> nameTableQueryWrapper = new QueryWrapper<>();
nameTableQueryWrapper.eq("STANO", Integer.parseInt(stano));
NameTable nameTable = nameTableMapper.selectOne(nameTableQueryWrapper);
String exId = nameTable.getGbstationid();
List<AllRoadFee> allRoadFees = DatabaseUtil.selectAllRoadMinFee(Constant.SQLITE_DRIVER_NAME, url, Constant.SELECT_ALL_ROAD_MIN_FEE_TABLE);
log.info("[uuid:{}]查询{}文件ALLROADMINFEE_TABLE表中数据条数为:{}", uuid, fileName, allRoadFees.size());
if (!allRoadFees.isEmpty()) {
//先删除原来的数据
QueryWrapper<AllRoadFee> deltWrapper = new QueryWrapper<>();
deltWrapper.eq("EXID", exId);
int delete = allRoadFeeMapper.delete(deltWrapper);
log.info("[uuid:{}]删除数据库ALLROADFEE_TABLE表中EXID={}数据条数为:{}", uuid, exId, delete);
log.info("[uuid:{}]开始将读取的SQB文件:{},插入数据库ALLROADFEE_TABLE表", uuid, fileName);
List<AllRoadFee> allRoadFeeList = new ArrayList<>();
for (AllRoadFee allRoadFee : allRoadFees) {
//调用insertBatchSomeColumn方法
allRoadFeeList.add(allRoadFee);
//控制每次提交数量
if (allRoadFeeList.size() == 200) {
allRoadFeeMapper.insertBatchSomeColumn(allRoadFeeList);
//将入库的list清空重新新增
allRoadFeeList.clear();
if(nameTable != null){
String exId = nameTable.getGbstationid();
List<AllRoadFee> allRoadFees = DatabaseUtil.selectAllRoadMinFee(Constant.SQLITE_DRIVER_NAME, url, Constant.SELECT_ALL_ROAD_MIN_FEE_TABLE);
log.info("[uuid:{}]查询{}文件ALLROADMINFEE_TABLE表中数据条数为:{}", uuid, fileName, allRoadFees.size());
if (!allRoadFees.isEmpty()) {
//先删除原来的数据
QueryWrapper<AllRoadFee> deltWrapper = new QueryWrapper<>();
deltWrapper.eq("EXID", exId);
int delete = allRoadFeeMapper.delete(deltWrapper);
log.info("[uuid:{}]删除数据库ALLROADFEE_TABLE表中EXID={}数据条数为:{}", uuid, exId, delete);
log.info("[uuid:{}]开始将读取的SQB文件:{},插入数据库ALLROADFEE_TABLE表", uuid, fileName);
//List<AllRoadFee> allRoadFeeList = new ArrayList<>();
for (AllRoadFee allRoadFee : allRoadFees) {
////调用insertBatchSomeColumn方法
//allRoadFeeList.add(allRoadFee);
////控制每次提交数量
//if (allRoadFeeList.size() == 200) {
// allRoadFeeMapper.insertBatchSomeColumn(allRoadFeeList);
// //将入库的list清空重新新增
// allRoadFeeList.clear();
//}
allRoadFeeMapper.insert(allRoadFee);
}
//将list中size不够200的数据在此处新增
//allRoadFeeMapper.insertBatchSomeColumn(allRoadFeeList);
log.info("[uuid:{}]插入数据库ALLROADFEE_TABLE表中数据条数为:{}", uuid, allRoadFees.size());
//删除文件
FileUtil.fileDelete(sqbFilePathAll);
log.info("[uuid:{}]删除已入库的文件:{}", uuid, sqbFilePathAll);
}
//将list中size不够200的数据在此处新增
allRoadFeeMapper.insertBatchSomeColumn(allRoadFeeList);
log.info("[uuid:{}]插入数据库ALLROADFEE_TABLE表中数据条数为:{}", uuid, allRoadFees.size());
//删除文件
FileUtil.fileDelete(sqbFilePathAll);
log.info("[uuid:{}]删除已入库的文件:{}", uuid, sqbFilePathAll);
}
//插入已处理完成的表中
MinFeeRecord record = new MinFeeRecord();
record.setStano(stano);
record.setFilename(fileName);
record.setRecorddate(new Date());
UpdateWrapper<MinFeeRecord> recordUpdateWrapper = new UpdateWrapper<>();
recordUpdateWrapper.eq("stano", stano);
if (minFeeRecordMapper.exists(recordUpdateWrapper)) {
minFeeRecordMapper.update(record, recordUpdateWrapper);
} else {
minFeeRecordMapper.insert(record);
//插入已处理完成的表中
MinFeeRecord record = new MinFeeRecord();
record.setStano(stano);
record.setFilename(fileName);
record.setRecorddate(new Date());
UpdateWrapper<MinFeeRecord> recordUpdateWrapper = new UpdateWrapper<>();
recordUpdateWrapper.eq("stano", stano);
if (minFeeRecordMapper.exists(recordUpdateWrapper)) {
minFeeRecordMapper.update(record, recordUpdateWrapper);
} else {
minFeeRecordMapper.insert(record);
}
}else {
log.info("[uuid:{}]查询NAME_TABLE表中STANO={}数据条数为空,暂不入库", uuid, Integer.parseInt(stano));
}
}
}
}

@ -1,5 +1,7 @@
#每天凌晨三点执行一次
time.corn1 = 0 0 3 * * ?
#time.corn1 = 0 0 3 * * ?
#每月5日凌晨三点执行一次
time.corn1 = 0 0 3 5 * ?
#每1小时执行一次
#time.corn1 = 0 0 0/1 * * ?
#每10分钟执行一次

@ -1,4 +0,0 @@
序号 日期 版本号 说明
1 2023年12月20日 1.0.0 初始版本号

@ -0,0 +1,5 @@
序号 日期 版本号 说明
1 2023年12月20日 1.0.0 初始版本号
1 2024年04月05日 1.0.1 优化每月5日凌晨三点执行一次首次可使用接口调用入库最小费额http://ip:port/MinFeeInsertDb/sys/insertMinFee
Loading…
Cancel
Save