| | |
| | | package com.aps.job.controller; |
| | | |
| | | import java.util.List; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.quartz.SchedulerException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.aps.common.core.constant.Constants; |
| | | import com.aps.common.core.constant.SecurityConstants; |
| | | import com.aps.common.core.exception.job.TaskException; |
| | | import com.aps.common.core.utils.StringUtils; |
| | | import com.aps.common.core.utils.poi.ExcelUtil; |
| | | import com.aps.common.core.utils.uuid.Sequence; |
| | | import com.aps.common.core.web.controller.BaseController; |
| | | import com.aps.common.core.web.domain.AjaxResult; |
| | | import com.aps.common.core.web.page.TableDataInfo; |
| | | import com.aps.common.log.annotation.Log; |
| | | import com.aps.common.log.enums.BusinessType; |
| | | import com.aps.common.security.annotation.RequiresPermissions; |
| | | import com.aps.common.security.utils.SecurityUtils; |
| | | import com.aps.job.domain.SysJob; |
| | | import com.aps.job.service.ISysJobService; |
| | | import com.aps.job.service.*; |
| | | import com.aps.job.util.CronUtils; |
| | | import com.aps.job.util.ScheduleUtils; |
| | | import com.aps.system.api.RemoteCoreService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.quartz.SchedulerException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.ZoneOffset; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 调度任务信息操作处理 |
| | |
| | | { |
| | | @Autowired |
| | | private ISysJobService jobService; |
| | | |
| | | @Autowired |
| | | private IApsWorkOrderProcessService apsWorkOrderProcessService; |
| | | |
| | | @Autowired |
| | | private IApsWorkOrderJobService apsWorkOrderJobService; |
| | | |
| | | @Autowired |
| | | private IApsBomHeaderJobService apsBomHeaderJobService; |
| | | |
| | | @Autowired |
| | | private Sequence sequence; |
| | | |
| | | @Autowired |
| | | private IApsMaterialStorageManagementJobService apsMaterialStorageManagementJobService; |
| | | |
| | | @Autowired |
| | | private IApsStandardProcessRouteHeaderJobService apsStandardProcessRouteHeaderJobService; |
| | | |
| | | @Autowired |
| | | private RemoteCoreService remoteCoreService; |
| | | |
| | | @Autowired |
| | | public RedisTemplate redisTemplate; |
| | | |
| | | @Autowired |
| | | private IApsMaterialManagementJobService apsMaterialManagementJobService; |
| | | |
| | | /** |
| | | * 查询定时任务列表 |
| | |
| | | jobService.deleteJobByIds(jobIds); |
| | | return success(); |
| | | } |
| | | |
| | | @PostMapping("/refreshBomData") |
| | | public AjaxResult refreshBomData() throws SchedulerException, TaskException |
| | | { |
| | | try { |
| | | boolean res = apsBomHeaderJobService.syncBomDataJob(1, 1000, "", ""); |
| | | if(res){ |
| | | return success(); |
| | | }else { |
| | | return error(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return error(); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/refreshProcessRouteData") |
| | | public AjaxResult refreshProcessRouteData() throws SchedulerException, TaskException |
| | | { |
| | | try { |
| | | boolean res = apsStandardProcessRouteHeaderJobService.syncProcessRouteDataJob(1, 1000, "", ""); |
| | | if(res){ |
| | | return success(); |
| | | }else { |
| | | return error(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return error(); |
| | | } |
| | | } |
| | | |
| | | @PutMapping("/test") |
| | | public void test(@RequestBody SysJob job) throws Exception |
| | | { |
| | | System.out.println("start"); |
| | | //同步工单数据 |
| | | // boolean continueFlag = true; |
| | | // Integer currentPage = 1; |
| | | // ApsWorkOrderJobParam param=new ApsWorkOrderJobParam(); |
| | | // param.setPageIndex(currentPage); |
| | | // param.setDocState(Arrays.asList(0,1,2,4)); |
| | | // param.setPageSize(500); |
| | | // while (continueFlag){ |
| | | // param.setPageIndex(currentPage); |
| | | // continueFlag= apsWorkOrderJobService.batchSaveByPager(param); |
| | | // currentPage++; |
| | | // } |
| | | //同步物料数据 |
| | | // apsMaterialManagementJobService.syncApsMaterialData(1, 1000, "", ""); |
| | | //同步工艺路线数据 |
| | | // apsStandardProcessRouteHeaderJobService.syncProcessRouteData(1, 1000, "", ""); |
| | | //获取Redis缓存中的BOM数据 |
| | | // JSONArray jsonArray = (JSONArray)redisTemplate.opsForValue().get("BOM:BOM_FORTUNA_A6501-001080"); |
| | | //将BOM数据存进Redis中 |
| | | // remoteCoreService.setBomDataToRedis(SecurityConstants.INNER); |
| | | //同步物料库存数据 |
| | | apsMaterialStorageManagementJobService.syncApsMaterialStorageData(1, 1000, "", ""); |
| | | //同步BOM数据 |
| | | // apsBomHeaderJobService.syncBomData(1, 1000, "", ""); |
| | | |
| | | // System.out.println(sequence.nextId()); |
| | | // List<String> docNos = new ArrayList<>(); |
| | | // docNos.add("MO-240328010093"); |
| | | // apsWorkOrderProcessService.getWorkOrderProcessFromU9(docNos); |
| | | // apsWorkOrderProcessService.syncWorkOrderProcessData("", 100); |
| | | // apsWorkOrderJobService.syncPartOrderData(); |
| | | // apsWorkOrderJobService.syncPlateOrderData(); |
| | | // apsWorkOrderJobService.syncGasPipingData(); |
| | | // apsWorkOrderProcessService.syncProcessRouteData(); |
| | | System.out.println("end"); |
| | | //生成数据字典 |
| | | // HikariConfig hikariConfig = new HikariConfig(); |
| | | // hikariConfig.setDriverClassName("org.postgresql.Driver"); |
| | | // hikariConfig.setJdbcUrl("jdbc:postgresql://192.168.50.160:5432/postgres?stringtype=unspecified"); |
| | | // hikariConfig.setUsername("postgres"); |
| | | // hikariConfig.setPassword("pwd@aps"); |
| | | // //设置可以获取tables remarks信息 |
| | | // hikariConfig.addDataSourceProperty("useInformationSchema", "true"); |
| | | // hikariConfig.setMinimumIdle(2); |
| | | // hikariConfig.setMaximumPoolSize(5); |
| | | // DataSource dataSource = new HikariDataSource(hikariConfig); |
| | | // //生成配置 |
| | | // EngineConfig engineConfig = EngineConfig.builder() |
| | | // //生成文件路径 |
| | | // .fileOutputDir("D:\\projects\\aps\\文档") |
| | | // //打开目录 |
| | | // .openOutputDir(true) |
| | | // //文件类型 |
| | | // .fileType(EngineFileType.WORD) |
| | | // //生成模板实现 |
| | | // .produceType(EngineTemplateType.freemarker) |
| | | // //自定义文件名称 |
| | | // .fileName("自定义文件名称").build(); |
| | | // |
| | | // //忽略表 |
| | | // ArrayList<String> ignoreTableName = new ArrayList<>(); |
| | | // ignoreTableName.add("test_user"); |
| | | // ignoreTableName.add("test_group"); |
| | | // //忽略表前缀 |
| | | // ArrayList<String> ignorePrefix = new ArrayList<>(); |
| | | // ignorePrefix.add("test_"); |
| | | // //忽略表后缀 |
| | | // ArrayList<String> ignoreSuffix = new ArrayList<>(); |
| | | // ignoreSuffix.add("_test"); |
| | | // ProcessConfig processConfig = ProcessConfig.builder() |
| | | // //指定生成逻辑、当存在指定表、指定表前缀、指定表后缀时,将生成指定表,其余表不生成、并跳过忽略表配置 |
| | | // //根据名称指定表生成 |
| | | // .designatedTableName(new ArrayList<>()) |
| | | // //根据表前缀生成 |
| | | // .designatedTablePrefix(new ArrayList<>()) |
| | | // //根据表后缀生成 |
| | | // .designatedTableSuffix(new ArrayList<>()) |
| | | // //忽略表名 |
| | | // .ignoreTableName(ignoreTableName) |
| | | // //忽略表前缀 |
| | | // .ignoreTablePrefix(ignorePrefix) |
| | | // //忽略表后缀 |
| | | // .ignoreTableSuffix(ignoreSuffix).build(); |
| | | // //配置 |
| | | // Configuration config = Configuration.builder() |
| | | // //版本 |
| | | // .version("1.0.0") |
| | | // //描述 |
| | | // .description("数据库设计文档生成") |
| | | // //数据源 |
| | | // .dataSource(dataSource) |
| | | // //生成配置 |
| | | // .engineConfig(engineConfig) |
| | | // //生成配置 |
| | | // .produceConfig(processConfig) |
| | | // .build(); |
| | | // //执行生成 |
| | | // new DocumentationExecute(config).execute(); |
| | | // System.out.println("end"); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | BigDecimal a = new BigDecimal("0.1234"); |
| | | Double b = a.doubleValue()*60*60*1000; |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | //将now换成成毫秒 然后加上a 然后转换成LocalDateTime |
| | | //a转换成毫秒 |
| | | System.out.println(now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | System.out.println(b/1000/60); |
| | | Long milliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli(); |
| | | milliSecond += b.longValue(); |
| | | System.out.println(LocalDateTime.ofInstant(Instant.ofEpochMilli(milliSecond), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | System.out.println(new BigDecimal(585).divide(BigDecimal.valueOf(1232), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100))); |
| | | new BigDecimal(585).divide(BigDecimal.valueOf(1232), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); |
| | | } |
| | | } |