bug修改

highway
zhaoxiaolin 1 year ago
parent 39b392d037
commit 42b9c09918

@ -35,4 +35,10 @@ public interface RemoteMesService {
@PostMapping("/prepare/reportWorkTask")
public R reportWorkTask();
@PostMapping("/wcsInterface/dataClearTask")
public R dataClearTask();
@PostMapping("/wcsInterface/dataBKTask")
public R dataBKTask();
}

@ -45,6 +45,16 @@ public class RemoteMesFallbackFactory implements FallbackFactory<RemoteMesServic
public R reportWorkTask() {
return R.fail("报工失败:" + throwable.getMessage());
}
@Override
public R dataClearTask() {
return R.fail("数据库清理失败:" + throwable.getMessage());
}
@Override
public R dataBKTask() {
return R.fail("数据库备份失败:" + throwable.getMessage());
}
};
}
}

@ -11,6 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.op.common.core.utils.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
*
*
@ -103,4 +106,15 @@ public class RyTask {
logger.info("++物料接口+开始++sapBomTask+++++");
remoteSapService.sapBomSync();
}
/**每天执行100一次**/
public void dataClearTask(){
logger.info("++数据库清理3天内的数据+开始++dataClearTask+++++");
remoteMesService.dataClearTask();
}
/**每月1日执行110一次**/
public void dataBKTask(){
logger.info("++数据库备份的数据+开始++dataClearTask+++++");
remoteMesService.dataBKTask();
}
}

@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
@ -29,7 +30,7 @@ import java.util.List;
public class WCSInterfaceController extends BaseController {
@Autowired
private IWCSInterfaceService WCInterfaceService;
private IWCSInterfaceService wCInterfaceService;
/**
*
@ -46,7 +47,7 @@ public class WCSInterfaceController extends BaseController {
wcsdto.setMessage("factory is not null");
return wcsdto;
}
return WCInterfaceService.requestDestinationStations(wcsdto);
return wCInterfaceService.requestDestinationStations(wcsdto);
}
// "下一工序机台集合获取(手持)"
@PostMapping("/pdaRequestDestinationStations")
@ -54,7 +55,7 @@ public class WCSInterfaceController extends BaseController {
if(StringUtils.isBlank(wcsdto.getFactory())){
return error("factory is not null");
}
return success(WCInterfaceService.requestDestinationStations(wcsdto));
return success(wCInterfaceService.requestDestinationStations(wcsdto));
}
// "获取料罐用量(废弃,留着以后给别的功能用)"
@ -66,7 +67,7 @@ public class WCSInterfaceController extends BaseController {
if(StringUtils.isBlank(lgdtos.get(0).getFactoryCode())){
return error("工厂信息为空");
}
return success(WCInterfaceService.saveLGusedLog(lgdtos));
return success(wCInterfaceService.saveLGusedLog(lgdtos));
}
/**
@ -74,14 +75,14 @@ public class WCSInterfaceController extends BaseController {
*/
@PostMapping("/getBoardFactory")
public AjaxResult getBoardFactory(@RequestBody BoardDTO boardDTO) {
return success(WCInterfaceService.getBoardFactory(boardDTO));
return success(wCInterfaceService.getBoardFactory(boardDTO));
}
@PostMapping("/getBoardShifts")
public AjaxResult getProShifts(@RequestBody BoardDTO boardDTO) {
if(StringUtils.isBlank(boardDTO.getFactory())){
return error("[factory] is not null");
}
return success(WCInterfaceService.getProShifts(boardDTO));
return success(wCInterfaceService.getProShifts(boardDTO));
}
@PostMapping("/getMesBoardEquProductionToday")
public AjaxResult getMesBoardEquProductionToday(@RequestBody BoardDTO boardDTO) {
@ -99,7 +100,18 @@ public class WCSInterfaceController extends BaseController {
if(StringUtils.isEmpty(boardDTO.getEquTypeCode())){//设备类型
return error("[equTypeCode] is not null");
}
return success(WCInterfaceService.getMesBoardEquProductionToday(boardDTO));
return success(wCInterfaceService.getMesBoardEquProductionToday(boardDTO));
}
/************************************************************/
/****************************数据库清理************************/
/************************************************************/
//定时清理表
@PostMapping("/dataClearTask")
public AjaxResult dataClearTask() {
List<String> tables = new ArrayList<>();
tables.add("mes_plc_log");
tables.add("mes_interface_log");
return success(wCInterfaceService.dataClearTask(tables));
}
public static void main(String args[]){

@ -38,4 +38,6 @@ public interface MesMapper {
List<BoardDTO> getTotalNumL(BoardDTO boardDTO);
List<BoardDTO> getEveryNumL(BoardDTO boardDTO);
void deleteDateByTableName(@Param("table")String table,@Param("ymdhms")String ymdhms);
}

@ -1,5 +1,6 @@
package com.op.mes.service;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult;
import com.op.mes.domain.MesShift;
import com.op.mes.domain.dto.BaseEquipmentDto;
@ -28,4 +29,6 @@ public interface IWCSInterfaceService {
String saveLGusedLog(List<LGInfoDto> lgdtos);
List<MesShift> getProShifts(BoardDTO boardDTO);
R dataClearTask(List<String> tables);
}

@ -2,6 +2,7 @@ package com.op.mes.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.core.utils.uuid.IdUtils;
@ -11,16 +12,27 @@ import com.op.mes.mapper.MesMapper;
import com.op.mes.mapper.MesReportWorkMapper;
import com.op.mes.mapper.ProRfidProcessDetailMapper;
import com.op.mes.service.IWCSInterfaceService;
import com.op.system.api.RemoteUserService;
import com.op.system.api.domain.SysDept;
import com.op.system.api.domain.SysUser;
import com.op.system.api.domain.dto.BoardDTO;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.dto.WCSDataDTO;
import com.op.system.api.domain.mes.ProRfidProcessDetail;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -31,7 +43,7 @@ import java.util.stream.Collectors;
*/
@Service
public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private MesMapper mesMapper;
@Autowired
@ -39,6 +51,9 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
@Autowired
private MesReportWorkMapper mesReportWorkMapper;
@Autowired
private RemoteUserService remoteUserService;
/**
* JSON
* {
@ -176,6 +191,45 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
}
@Override
public R dataClearTask(List<String> tables) {
// 加载sf-cloud库的sys_datasource
SysUser sysUser = new SysUser();
sysUser.setUserId(1L);
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
List<Map<String, String>> dateSources = dateSources0.getData();
ExecutorService executorService = new ThreadPoolExecutor(
dateSources.size(),
dateSources.size(),
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
try {
dateSources.forEach(dateSource -> {
logger.info("++++++++++++" + dateSource.get("poolName") + "++++开始++++++++++");
Runnable run = () -> dateDeleteFunc(dateSource.get("poolName"),tables);
executorService.execute(run);
});
} catch (Exception e) {
logger.error("service == deviceOfflineTimingTask == exception", e);
return R.fail("service == deviceOfflineTimingTask == exception");
} finally {
executorService.shutdown();
}
return R.ok(true);
}
public void dateDeleteFunc(String poolName,List<String> tables){
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
DateTimeFormatter ymdhms = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate today = LocalDate.now();
System.out.println("今天的日期为:"+today);
LocalDate nextWeek = today.plus(-3, ChronoUnit.DAYS);
String ymdhms7 = nextWeek.format(ymdhms)+" 00:00:00";
for(String table:tables){
mesMapper.deleteDateByTableName(table,ymdhms7);
}
}
@Override
public String saveLGusedLog(List<LGInfoDto> lgdtos) {
DynamicDataSourceContextHolder.push("ds_"+lgdtos.get(0).getFactoryCode());// 这是数据源的key
@ -191,6 +245,11 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
}
public static void main(String args[]){
System.out.println(DateUtils.getDate());
DateTimeFormatter ymdhms = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate today = LocalDate.now();
System.out.println("今天的日期为:"+today);
LocalDate nextWeek = today.plus(-3, ChronoUnit.DAYS);
String ymdhms7 = nextWeek.format(ymdhms);
System.out.println("7天之前的日期为:"+ymdhms7);
}
}

@ -55,6 +55,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
</foreach>
</insert>
<delete id="deleteDateByTableName">
delete from ${table} where #{ymdhms} > CONVERT(varchar(30),create_time, 120)
</delete>
<select id="getWetPlanDetail" resultType="com.op.system.api.domain.dto.WCSDataItemsDTO">
select

@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectBaseApkFileVo"/>
where id = #{id}
</select>
<select id="getLastApkVersion" resultType="com.op.system.domain.BaseApkFile">
<select id="getLastApkVersion" resultMap="BaseApkFileResult">
select top 1 id, file_name, file_address, version, attr1, attr2, attr3, attr4,
create_by, create_time, update_by, update_time, remark
from base_apk_file

@ -159,7 +159,8 @@ public class ProProcessServiceImpl implements IProProcessService {
}
proProcess.setUpdateTime(DateUtils.getNowDate());
return proProcessMapper.updateProProcess(proProcess);
int n = proProcessMapper.updateProProcess(proProcess);
return n;
}
/**

Loading…
Cancel
Save