diff --git a/box-bps/pom.xml b/box-bps/pom.xml new file mode 100644 index 000000000..5cc6d8bad --- /dev/null +++ b/box-bps/pom.xml @@ -0,0 +1,47 @@ + + + + ruoyi + com.ruoyi + 4.6.2 + + 4.0.0 + + box-bps + + + bps系统模块 + + + + + + + com.ruoyi + ruoyi-common + + + + org.json + json + 20160810 + + + + io.swagger + swagger-annotations + 1.5.21 + compile + + + + com.github.kuaidi100-api + sdk + 1.0.2 + + + + + \ No newline at end of file diff --git a/box-bps/src/main/java/com/ruoyi/bps/controller/ExpImportQueryController.java b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpImportQueryController.java new file mode 100644 index 000000000..07ad24b84 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpImportQueryController.java @@ -0,0 +1,186 @@ +package com.ruoyi.bps.controller; + +import com.ruoyi.bps.domain.ExpImportQuery; +import com.ruoyi.bps.domain.ExpressInfo; +import com.ruoyi.bps.mapper.ExpressInfoMapper; +import com.ruoyi.bps.service.IExpImportQueryService; +import com.ruoyi.bps.service.IExpressInfoService; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +/** + * Excel批量快递查询Controller + * + * @author Bo + * @date 2021-07-21 + */ +@Controller +@RequestMapping("/bps/expImportQuery") +public class ExpImportQueryController extends BaseController +{ + private String prefix = "bps/expImportQuery"; + + @Autowired + private IExpImportQueryService expImportQueryService; + + @Autowired + private IExpressInfoService expressInfoService; + + @Autowired + private ExpressInfoMapper expressInfoMapper; + + @RequiresPermissions("bps:expImportQuery:view") + @GetMapping() + public String expImportQuery() + { + return prefix + "/expImportQuery"; + } + + /** + * 查询Excel批量快递查询列表 + */ + @RequiresPermissions("bps:expImportQuery:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(ExpImportQuery expImportQuery) + { + startPage(); + List list = expImportQueryService.selectExpImportQueryList(expImportQuery); + return getDataTable(list); + } + + /** + * 导出Excel批量快递查询列表 + */ + @RequiresPermissions("bps:expImportQuery:export") + @Log(title = "Excel批量快递查询", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(ExpImportQuery expImportQuery) + { + List list = expImportQueryService.selectExpImportQueryList(expImportQuery); + ExcelUtil util = new ExcelUtil(ExpImportQuery.class); + return util.exportExcel(list, "Excel批量快递查询数据"); + } + + + /** + * 导出Excel批量快递查询列表 + */ + @RequiresPermissions("bps:expressInfo:export") + @Log(title = "详细快递信息导出", businessType = BusinessType.EXPORT) + @PostMapping("/exportDetail") + @ResponseBody + public AjaxResult exportDetail(ExpressInfo expressInfo) + { + List list = expressInfoService.selectLocalExpressInfoList(expressInfo); + ExcelUtil util = new ExcelUtil(ExpressInfo.class); + return util.exportExcel(list, "Excel批量快递查询数据"); + } + + /** + * 新增Excel批量快递查询 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存Excel批量快递查询 + */ + @RequiresPermissions("bps:expImportQuery:add") + @Log(title = "Excel批量快递查询", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(ExpImportQuery expImportQuery) + { + return toAjax(expImportQueryService.insertExpImportQuery(expImportQuery)); + } + + /** + * 修改Excel批量快递查询 + */ + @GetMapping("/edit/{sid}") + public String edit(@PathVariable("sid") Long sid, ModelMap mmap) + { + ExpImportQuery expImportQuery = expImportQueryService.selectExpImportQueryById(sid); + mmap.put("expImportQuery", expImportQuery); + return prefix + "/edit"; + } + + /** + * 修改保存Excel批量快递查询 + */ + @RequiresPermissions("bps:expImportQuery:edit") + @Log(title = "Excel批量快递查询", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(ExpImportQuery expImportQuery) + { + return toAjax(expImportQueryService.updateExpImportQuery(expImportQuery)); + } + + /** + * 删除Excel批量快递查询 + */ + @RequiresPermissions("bps:expImportQuery:remove") + @Log(title = "Excel批量快递查询", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(expImportQueryService.deleteExpImportQueryByIds(ids)); + } + + + /** + * 快递查询明细信息 + */ + @RequiresPermissions("bps:expImportQuery:detail") + @GetMapping("/detail/{sid}") + public String detail(@PathVariable("sid") Long sid, ModelMap mmap) + { + String queryId = expImportQueryService.selectExpImportQueryById(sid).getQueryId(); + ExpressInfo expressInfo= new ExpressInfo(); + expressInfo.setQueryId(queryId); + mmap.put("expressInfo",expressInfo); + return prefix + "/detail"; + } + + /** + * Excel导入查模板下载 + */ + @GetMapping ( "/importTemplate" ) + @ResponseBody + public AjaxResult importTemplate ( ) { + ExcelUtil util = new ExcelUtil<>(ExpressInfo.class); + return util.importTemplateExcel ( "快递查询导入模板" ); + } + + /** + * Excel导入查询 + */ + @PostMapping("/importData") + @Log(title = "Excel批量导入快递查询", businessType = BusinessType.IMPORT) + @ResponseBody + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception + { + ExcelUtil util= new ExcelUtil(ExpressInfo.class); + List expressInfoList=util.importExcel(file.getInputStream()); + return expImportQueryService.importData(expressInfoList); + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/controller/ExpSubsPushApiController.java b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpSubsPushApiController.java new file mode 100644 index 000000000..b33d9f2aa --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpSubsPushApiController.java @@ -0,0 +1,66 @@ +package com.ruoyi.bps.controller; + +import com.kuaidi100.sdk.response.SubscribeResp; +import com.ruoyi.bps.domain.ExpSubscribe; +import com.ruoyi.bps.service.IExpSubsPushApiService; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.enums.BusinessType; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 接受快递推送信息的API接口Controller + * + * @author box + * @date 2021-05-13 + */ +@Api(value = "快递信息订阅推送",tags = "快递订阅接口") +@RestController +/*@RequestMapping("/anon")*/ +public class ExpSubsPushApiController extends BaseController { + @Autowired + IExpSubsPushApiService expSubsPushApiService; + + //推送 + @CrossOrigin + @PostMapping("anon/subscribeCallBackUrl") + @ApiOperation("快递信息订阅推送接受") + public SubscribeResp SubscribeCallBackUrl(HttpServletRequest request) { + return expSubsPushApiService.ExpressSubscribeCallBackUrl(request); + } + + //订阅 + @CrossOrigin + @PostMapping("anon/subscribe") + public SubscribeResp Subscribe(ExpSubscribe expSubscribe){ + return expSubsPushApiService.ExpressSubscribe(expSubscribe); + } + + //接受topgp订阅, + @Log(title = "快递订阅", businessType = BusinessType.OTHER) + @CrossOrigin + @ApiOperation(value="topgp订阅快递",notes = "request body格式: {\"deliveryNo\":\"S301-2108020001\",\"expressNo\":\"300444235610\",\"company\":\"annengwuliu\",\"phone\":\"13800138000\"}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String", dataTypeClass = String.class), + @ApiImplicitParam(name = "requestJson", value = "请求json",required = true, paramType = "body", dataType = "String", dataTypeClass = String.class) + }) + + @PostMapping("api/express/topgpSubscribe") + public String topgpSubscribe(HttpServletRequest request, HttpServletResponse response) throws IOException { + return expSubsPushApiService.ExpressSubscribeWithTopgp(request); + } + + +} + diff --git a/box-bps/src/main/java/com/ruoyi/bps/controller/ExpSubsPushRespController.java b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpSubsPushRespController.java new file mode 100644 index 000000000..561d0a174 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpSubsPushRespController.java @@ -0,0 +1,135 @@ +package com.ruoyi.bps.controller; + +import com.ruoyi.bps.domain.ExpSubsPushResp; +import com.ruoyi.bps.service.IExpSubsPushRespService; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 快递订阅推送信息增删改查Controller + * + * @author box + * @date 2021-05-13 + */ +@Controller +@RequestMapping("/bps/expsubspushresp") +public class ExpSubsPushRespController extends BaseController +{ + private String prefix = "bps/expsubspushresp"; + + @Autowired + private IExpSubsPushRespService expSubsPushRespService; + + @RequiresPermissions("bps:expsubspushresp:view") + @GetMapping() + public String expsubspushresp() + { + return prefix + "/expsubspushresp"; + } + + /** + * 查询快递订阅推送信息列表 + */ + @RequiresPermissions("bps:expsubspushresp:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(ExpSubsPushResp expSubsPushResp) + { + startPage(); + List list = expSubsPushRespService.selectExpSubsPushRespList(expSubsPushResp); + return getDataTable(list); + } + + /** + * 导出快递订阅推送信息列表 + */ + @RequiresPermissions("bps:expsubspushresp:export") + @Log(title = "快递订阅推送信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(ExpSubsPushResp expSubsPushResp) + { + List list = expSubsPushRespService.selectExpSubsPushRespList(expSubsPushResp); + ExcelUtil util = new ExcelUtil(ExpSubsPushResp.class); + return util.exportExcel(list, "快递订阅推送信息数据"); + } + + /** + * 新增快递订阅推送信息 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存快递订阅推送信息 + */ + @RequiresPermissions("bps:expsubspushresp:add") + @Log(title = "快递订阅推送信息", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(ExpSubsPushResp expSubsPushResp) + { + return toAjax(expSubsPushRespService.insertExpSubsPushResp(expSubsPushResp)); + } + + /** + * 修改快递订阅推送信息 + */ + @GetMapping("/edit/{sid}") + public String edit(@PathVariable("sid") Long sid, ModelMap mmap) + { + ExpSubsPushResp expSubsPushResp = expSubsPushRespService.selectExpSubsPushRespById(sid); + mmap.put("expSubsPushResp", expSubsPushResp); + return prefix + "/edit"; + } + + /** + * 修改保存快递订阅推送信息 + */ + @RequiresPermissions("bps:expsubspushresp:edit") + @Log(title = "快递订阅推送信息", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(ExpSubsPushResp expSubsPushResp) + { + return toAjax(expSubsPushRespService.updateExpSubsPushResp(expSubsPushResp)); + } + + /** + * 删除快递订阅推送信息 + */ + @RequiresPermissions("bps:expsubspushresp:remove") + @Log(title = "快递订阅推送信息", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(expSubsPushRespService.deleteExpSubsPushRespByIds(ids)); + } + + /** + * 快递订阅推送详细信息 + */ + @RequiresPermissions("bps:expsubspushresp:detail") + @GetMapping("/detail/{sid}") + public String detail(@PathVariable("sid") Long sid, ModelMap mmap) + { + ExpSubsPushResp expSubsPushResp = expSubsPushRespService.selectExpSubsPushRespById(sid); + mmap.put("expSubsPushResp", expSubsPushResp); + return prefix + "/detail"; + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/controller/ExpSubscribeController.java b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpSubscribeController.java new file mode 100644 index 000000000..ee8753a04 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpSubscribeController.java @@ -0,0 +1,148 @@ +package com.ruoyi.bps.controller; + +import com.ruoyi.bps.domain.ExpSubscribe; +import com.ruoyi.bps.service.IExpSubsPushApiService; +import com.ruoyi.bps.service.IExpSubscribeService; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.kuaidi100.sdk.response.SubscribeResp; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * 快递订阅Controller + * + * @author box + * @date 2021-05-20 + */ +@Controller +@RequestMapping("/bps/subscribe") +public class ExpSubscribeController extends BaseController +{ + private String prefix = "bps/subscribe"; + + @Autowired + private IExpSubscribeService expSubscribeService; + + @Autowired + private IExpSubsPushApiService iExpSubsPushApiService; + + @RequiresPermissions("bps:subscribe:view") + @GetMapping() + public String subscribe() + { + return prefix + "/subscribe"; + } + + /** + * 订阅快递 + */ + @CrossOrigin + @RequestMapping("/subscribe") + @ResponseBody + public SubscribeResp ExpressSubscribe(@RequestBody ExpSubscribe expSubscribe) { + return iExpSubsPushApiService.ExpressSubscribe(expSubscribe); + } + + + /** + * 查询快递订阅列表 + */ + @RequiresPermissions("bps:subscribe:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(ExpSubscribe expSubscribe) + { + startPage(); + List list; + if(expSubscribe.getNumber().contains(",")){ + List number= Arrays.asList(expSubscribe.getNumber().split(",")); + list=expSubscribeService.selectExpSubsPushRespByNumber(number); + } + else { + list = expSubscribeService.selectExpSubscribeList(expSubscribe); + } + return getDataTable(list); + } + + /** + * 导出快递订阅列表 + */ + @RequiresPermissions("bps:subscribe:export") + @Log(title = "快递订阅", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(ExpSubscribe expSubscribe) + { + List list = expSubscribeService.selectExpSubscribeList(expSubscribe); + ExcelUtil util = new ExcelUtil(ExpSubscribe.class); + return util.exportExcel(list, "快递订阅数据"); + } + + /** + * 新增快递订阅 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存快递订阅 + */ + @RequiresPermissions("bps:subscribe:add") + @Log(title = "快递订阅", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(ExpSubscribe expSubscribe) + { + return toAjax(expSubscribeService.insertExpSubscribe(expSubscribe)); + } + + /** + * 修改快递订阅 + */ + @GetMapping("/edit/{sid}") + public String edit(@PathVariable("sid") Long sid, ModelMap mmap) + { + ExpSubscribe expSubscribe = expSubscribeService.selectExpSubscribeById(sid); + mmap.put("expSubscribe", expSubscribe); + return prefix + "/edit"; + } + + /** + * 修改保存快递订阅 + */ + @RequiresPermissions("bps:subscribe:edit") + @Log(title = "快递订阅", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(ExpSubscribe expSubscribe) + { + return toAjax(expSubscribeService.updateExpSubscribe(expSubscribe)); + } + + /** + * 删除快递订阅 + */ + @RequiresPermissions("bps:subscribe:remove") + @Log(title = "快递订阅", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(expSubscribeService.deleteExpSubscribeByIds(ids)); + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/controller/ExpressInfoController.java b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpressInfoController.java new file mode 100644 index 000000000..93f7e921f --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpressInfoController.java @@ -0,0 +1,174 @@ +package com.ruoyi.bps.controller; + +import com.ruoyi.bps.domain.ExpressInfo; +import com.ruoyi.bps.service.IExpressInfoService; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.controller.BaseController; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.ArrayList; +import java.util.List; + +/** + * 快递信息Controller + * + * @author box + * @date 2021-05-06 + */ +@Controller +@RequestMapping("/bps/expressInfo") +public class ExpressInfoController extends BaseController +{ + private String prefix = "bps/expressInfo"; + + @Autowired + private IExpressInfoService expressInfoService; + + @RequiresPermissions("bps:expressInfo:view") + @GetMapping() + public String expressInfo() + { + return prefix + "/expressInfo"; + } + + /** + * 查询快递信息列表 + */ + @RequiresPermissions("bps:expressInfo:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(ExpressInfo expressInfo) + { + startPage(); + List list = expressInfoService.selectExpressInfoList(expressInfo); + return getDataTable(list); + } + + /** + * 查询快递信息列表 + */ + @RequiresPermissions("bps:expressInfo:list") + @PostMapping("/localList") + @ResponseBody + public TableDataInfo localList(ExpressInfo expressInfo) + { + startPage(); + List list = expressInfoService.selectLocalExpressInfoList(expressInfo); + + return getDataTable(list); + } + + /** + * 导出快递信息列表 + */ + @RequiresPermissions("bps:expressInfo:export") + @Log(title = "快递信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(ExpressInfo expressInfo) + { + List list = expressInfoService.selectExpressInfoList(expressInfo); + ExcelUtil util = new ExcelUtil(ExpressInfo.class); + return util.exportExcel(list, "快递信息数据"); + } + + /** + * 新增快递信息 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存快递信息 + */ + @RequiresPermissions("bps:expressInfo:add") + @Log(title = "快递信息", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(ExpressInfo expressInfo) + { + return toAjax(expressInfoService.insertExpressInfo(expressInfo)); + } + + /** + * 修改快递信息 + */ + @GetMapping("/edit/{message}") + public String edit(@PathVariable("message") String message, ModelMap mmap) + { + ExpressInfo expressInfo = expressInfoService.selectExpressInfoById(message); + mmap.put("expressInfo", expressInfo); + return prefix + "/edit"; + } + + /** + * 修改保存快递信息 + */ + @RequiresPermissions("bps:expressInfo:edit") + @Log(title = "快递信息", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(ExpressInfo expressInfo) + { + return toAjax(expressInfoService.updateExpressInfo(expressInfo)); + } + + /** + * 删除快递信息 + */ + @RequiresPermissions("bps:expressInfo:remove") + @Log(title = "快递信息", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(expressInfoService.deleteExpressInfoByIds(ids)); + } + + + + @GetMapping ( "/importTemplate" ) + @ResponseBody + public AjaxResult importTemplate ( ) { + ExcelUtil < ExpressInfo > util = new ExcelUtil<>(ExpressInfo.class); + return util.importTemplateExcel ( "快递查询导入模板" ); + } + + @PostMapping("/importData") + @ResponseBody + public TableDataInfo importData(MultipartFile file, boolean updateSupport) throws Exception + { + /*ExcelUtil util = new ExcelUtil(SysUser.class); + List userList = util.importExcel(file.getInputStream()); + String operName = ShiroUtils.getSysUser().getLoginName(); + String message = userService.importUser(userList, updateSupport, operName); + return AjaxResult.success(message);*/ + + ExcelUtil util= new ExcelUtil(ExpressInfo.class); + List expressInfoList=util.importExcel(file.getInputStream()); + List list = new ArrayList<>(); + for( ExpressInfo expressInfo:expressInfoList) + { + list.add(expressInfo); + + } + + //String message = expressInfoList.importUser(userList, updateSupport, operName); + + return getDataTable(list); + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/controller/ExpressTestController.java b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpressTestController.java new file mode 100644 index 000000000..c248bc8e6 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpressTestController.java @@ -0,0 +1,50 @@ +package com.ruoyi.bps.controller; + + +//import com.ruoyi.bps.express.contant.CompanyConstant; +//import com.ruoyi.bps.express.request.QueryTrackParam; + +import com.ruoyi.bps.service.IExpressService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.page.TableDataInfo; +import com.kuaidi100.sdk.request.QueryTrackParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ExpressTestController extends BaseController { + @Autowired + private IExpressService expressService; + + @RequestMapping("/anon/bps/express/test/queryTrackMultiList") + public TableDataInfo QueryTrackMultiList(){ + //return expressService.QueryTrackExpressMultiList(expressService.GetTestQueryTrackParam()).toString(); + return getDataTable(expressService.QueryTrackExpressMultiList(expressService.GetTestQueryTrackParam())); + } + + @RequestMapping("/anon/bps/express/test/queryTrackMulti") + public String QueryTrackMulti(){ + return expressService.QueryTrackExpressMulti(expressService.GetTestQueryTrackParam()); + } + + @RequestMapping("/anon/bps/express/test/queryTrack") + public String QueryTrack(){ + QueryTrackParam queryTrackParam = new QueryTrackParam(); + queryTrackParam.setCom("annengwuliu"); + queryTrackParam.setNum("3004459671351"); + queryTrackParam.setPhone("17725390266"); + + return expressService.QueryTrackExpress(queryTrackParam); + + + } + @RequestMapping("/anon/bps/express/test/subscribe") + public String Subscribe(){ + return expressService.SubscribeExpress(); + } + + + + +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/controller/FrForCrTopgpController.java b/box-bps/src/main/java/com/ruoyi/bps/controller/FrForCrTopgpController.java new file mode 100644 index 000000000..ea61ca9ac --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/controller/FrForCrTopgpController.java @@ -0,0 +1,107 @@ +package com.ruoyi.bps.controller; + +import com.ruoyi.bps.service.TopgpDdlService; +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.common.utils.StringUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Api(tags = "TOPGP使用帆软报表接口") +@RestController +public class FrForCrTopgpController { + @Autowired + private TopgpDdlService topgpDdlService; + + //访问 ../anon/bps/frforcr/topprod时,使用topprod + @ApiOperation("TOPPROD正式区访问") + @ApiImplicitParam(name = "jsonString", value = "Json字符串", paramType = "body", dataType = "String", dataTypeClass = String.class) + @CrossOrigin + @Log(title = "CSFR412_CR报表_TOPPROD", businessType = BusinessType.DROP) + @PostMapping("/anon/bps/frforcr/topprod") + @DataSource(value = DataSourceType.TOPPRODDSREPORT) + public AjaxResult frforcrtopprod(@RequestBody Map map){ + return frforcrtoppgp(map); + } + + //访问../anon/bps/frforcr/topprod时,使用toptest实例 + @ApiOperation("TOPTEST正式区访问") + @ApiImplicitParam(name = "jsonString", value = "Json字符串", paramType = "body", dataType = "String", dataTypeClass = String.class) + @CrossOrigin + @Log(title = "CSFR412_CR报表_TOPTEST", businessType = BusinessType.DROP) + @PostMapping("/anon/bps/frforcr/toptest") + @DataSource(value = DataSourceType.TOPTESTDSREPORT) + public AjaxResult frforcrtoptest(@RequestBody Map map){ + return frforcrtoppgp(map); + } + + private AjaxResult frforcrtoppgp(Map map){ + /* 多此一举,在@RequestBody时取不到值是,已经会报500错误了,并不会执行到这一段。 + if(map.isEmpty()){ //如果传过来的值为空,返回未取到表名 + // System.out.println(LocalTime.now()+"未获取到表名!"); + return AjaxResult.error("未取到表名传参!"); + } + */ + StringBuilder droppedTable = new StringBuilder(); + StringBuilder errorDroppedTable = new StringBuilder(); + StringBuilder notExistsTable = new StringBuilder(); + + for (String tableName : getTableName(map)) { + if(topgpDdlService.isTableInDb("ds_report",tableName) <=0){ + //表名在数据库中不存在 + //System.out.println(LocalTime.now() + "【" + tableName + "】不存在!"); + notExistsTable.append(tableName+","); + continue; + } + + try { + topgpDdlService.dropTable("ds_report." + tableName); + //System.out.println(LocalTime.now() + "【" + tableName + "】已被删除!"); + droppedTable.append(tableName+","); + } catch (Exception e) { + //System.out.println(LocalTime.now() + "【" + tableName + "】删除异常!"); + errorDroppedTable.append(tableName+","); + } + } + + //删除异常写入日志 + if (StringUtils.isNotEmpty(errorDroppedTable)){ + return AjaxResult.error(errorDroppedTable+"删除异常!"); + } + //表不存在写入日志 + if(StringUtils.isNotEmpty(notExistsTable)){ + return AjaxResult.warn(notExistsTable+"表不存在!"); + } + //被删除的表写入日志 + if(StringUtils.isNotEmpty(droppedTable)){ + return AjaxResult.success(droppedTable + "删除成功!"); + } + //以上三种情况都不存在,说明发生了不明异常,写入日志 + return AjaxResult.warn("发生不明异常!"); + } + + //防止意手抖把SID也当成表传过来 + //排除sid的key值 + private List getTableName(Map map){ + List list=new ArrayList(); + for(String key:map.keySet()){ + if(key !="sid") + { + list.add(map.get(key).toString()); + } + } + return list; + } +} + + diff --git a/box-bps/src/main/java/com/ruoyi/bps/controller/QueryExpressController.java b/box-bps/src/main/java/com/ruoyi/bps/controller/QueryExpressController.java new file mode 100644 index 000000000..faa2d2510 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/controller/QueryExpressController.java @@ -0,0 +1,103 @@ +package com.ruoyi.bps.controller; + + +//import com.ruoyi.bps.express.contant.CompanyConstant; +//import com.ruoyi.bps.express.request.QueryTrackParam; +//import com.ruoyi.bps.express.response.QueryTrackResp; + +import com.ruoyi.bps.service.IExpressService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.page.TableDataInfo; +import com.google.gson.Gson; +import com.kuaidi100.sdk.request.QueryTrackParam; +import com.kuaidi100.sdk.response.QueryTrackResp; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.HashMap; +import java.util.Map; + +@Controller +public class QueryExpressController extends BaseController { + @Autowired + private IExpressService expressService; + @RequiresPermissions("bps:express:view") + @RequestMapping("/bps/express/queryExpress") + public String queryExpress() + { + //return "express/queryExpress"; + //说明:此处不能用绝对路径,否则,当application.yml中,设定context-path: /it_war后,打Jar包时,会找不到thymeleaf对应的文件。 + return "express/queryExpress"; + } + + @CrossOrigin + @RequestMapping("/bps/express/queryExpress/list") + @ResponseBody + public Map queryExpressList(@RequestBody QueryTrackParam queryTrackParam){ + Map result = null; + if (queryTrackParam != null) { + System.out.println("运单号码:" + queryTrackParam.getNum()); + System.out.println("快递公司:" + queryTrackParam.getCom()); + System.out.println("电话:" + queryTrackParam.getPhone()); + result = new HashMap<>(); + result.put("code", "1"); + result.put("msg", "ok"); + result.put("info",expressService.QueryTrackExpress(queryTrackParam)); + } + return result; + } + + @CrossOrigin + @RequestMapping("/bps/express/queryExpress/list1") + @ResponseBody + public Map queryExpressList1(@RequestBody QueryTrackParam queryTrackParam){ + Map result = null; + if (queryTrackParam != null) { + System.out.println("运单号码:" + queryTrackParam.getNum()); + System.out.println("快递公司:" + queryTrackParam.getCom()); + System.out.println("电话:" + queryTrackParam.getPhone()); + String info=expressService.QueryTrackExpress(queryTrackParam); + QueryTrackResp queryTrackResp = new Gson().fromJson(info,QueryTrackResp.class); + result = new HashMap<>(); + result.put("code", "1"); + result.put("msg", "ok"); + result.put("nu",queryTrackResp.getNu()); + result.put("com",queryTrackResp.getCom()); + result.put("state",queryTrackResp.getState()); + result.put("info",queryTrackResp.getData()); + } + return result; + } + + @RequestMapping("/anon/bps/express/queryTrackMultiList") + public TableDataInfo QueryTrackMultiList(@RequestBody QueryTrackParam queryTrackParam){ + + return getDataTable(expressService.QueryTrackExpressMultiList(expressService.GetTestQueryTrackParam())); + } + + @RequestMapping("/anon/bps/express/queryTrackMulti") + public String QueryTrackMulti(){ + return expressService.QueryTrackExpressMulti(expressService.GetTestQueryTrackParam()); + } + + @RequestMapping("/anon/bps/express/queryTrack") + public String QueryTrack(){ + QueryTrackParam queryTrackParam = new QueryTrackParam(); + queryTrackParam.setCom("annengwuliu"); + queryTrackParam.setNum("3004459671351"); + queryTrackParam.setPhone("17725390266"); + + return expressService.QueryTrackExpress(queryTrackParam); + + + } + @RequestMapping("/anon/bps/express/subscribe") + public String Subscribe(){ + return expressService.SubscribeExpress(); + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/domain/ExpImportQuery.java b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpImportQuery.java new file mode 100644 index 000000000..b18dde143 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpImportQuery.java @@ -0,0 +1,143 @@ +package com.ruoyi.bps.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * Excel批量快递查询对象 exp_import_query + * + * @author Bo + * @date 2021-07-21 + */ +public class ExpImportQuery extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** sid */ + private Long sid; + + /** 查询ID */ + @Excel(name = "查询ID") + private String queryId; + + /** 查询时间 */ + @Excel(name = "查询时间") + private String queryTime; + + /** 用户ID */ + @Excel(name = "用户ID") + private String queryLoginName; + + /** 用户名 */ + @Excel(name = "用户名") + private String queryUserName; + + /** 查询IP */ + @Excel(name = "查询IP") + private String queryIp; + + /** 完成时间 */ + @Excel(name = "完成时间") + private String finishTime; + + /** 完成状态 */ + @Excel(name = "完成状态") + private String status; + + /** 运单总量 */ + @Excel(name = "运单总量") + private String queryQty; + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public Long getSid() { + return sid; + } + + public void setSid(Long sid) { + this.sid = sid; + } + + public String getQueryId() { + return queryId; + } + + public void setQueryId(String queryId) { + this.queryId = queryId; + } + + public String getQueryTime() { + return queryTime; + } + + public void setQueryTime(String queryTime) { + this.queryTime = queryTime; + } + + public String getQueryLoginName() { + return queryLoginName; + } + + public void setQueryLoginName(String queryLoginName) { + this.queryLoginName = queryLoginName; + } + + public String getQueryUserName() { + return queryUserName; + } + + public void setQueryUserName(String queryUserName) { + this.queryUserName = queryUserName; + } + + public String getQueryIp() { + return queryIp; + } + + public void setQueryIp(String queryIp) { + this.queryIp = queryIp; + } + + public String getFinishTime() { + return finishTime; + } + + public void setFinishTime(String finishTime) { + this.finishTime = finishTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getQueryQty() { + return queryQty; + } + + public void setQueryQty(String queryQty) { + this.queryQty = queryQty; + } + + @Override + public String toString() { + return "ExpImportQuery{" + + "sid=" + sid + + ", queryId='" + queryId + '\'' + + ", queryTime='" + queryTime + '\'' + + ", queryLoginName='" + queryLoginName + '\'' + + ", queryUserName='" + queryUserName + '\'' + + ", queryIp='" + queryIp + '\'' + + ", finishTime='" + finishTime + '\'' + + ", status='" + status + '\'' + + ", queryQty='" + queryQty + '\'' + + '}'; + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/domain/ExpSubsPushResp.java b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpSubsPushResp.java new file mode 100644 index 000000000..c462fd961 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpSubsPushResp.java @@ -0,0 +1,334 @@ +package com.ruoyi.bps.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 快递订阅推送信息对象 exp_subs_push_resp + * + * @author box + * @date 2021-05-13 + */ +public class ExpSubsPushResp extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** SID */ + private Long sid; + + /** 监控状态 */ + @Excel(name = "监控状态") + private String status; + + /** 状态 */ + @Excel(name = "状态") + private String billStatus; + + /** 监控状态消息 */ + @Excel(name = "监控状态消息") + private String message; + + /** 快递公司编码是否出错 */ + @Excel(name = "快递公司编码是否出错") + private String autoCheck; + + /** 原始快递公司编码 */ + @Excel(name = "原始快递公司编码") + private String comOld; + + /** 修正快递公司编码 */ + @Excel(name = "修正快递公司编码") + private String comNew; + + /** 当前快递消息 */ + @Excel(name = "当前快递消息") + private String lastResultMessage; + + /** 当前快递单状态 */ + @Excel(name = "当前快递单状态") + private String lastResultState; + + /** 通讯状态 */ + @Excel(name = "通讯状态") + private String lastResulStatus; + + /** 快递单明细状态 */ + @Excel(name = "快递单明细状态") + private String lastResultCondition; + + /** 是否签收 */ + @Excel(name = "是否签收") + private String lastResultIsCheck; + + /** 快递公司编码 */ + @Excel(name = "快递公司编码") + private String lastResultCom; + + /** 快递单号 */ + @Excel(name = "快递单号") + private String lastResultNu; + + /** 快递流转信息 */ + @Excel(name = "快递流转信息") + private String lastResultData; + + /** 目的国快递消息 */ + @Excel(name = "目的国快递消息") + private String destResultMessage; + + /** 目的国快递单状态 */ + @Excel(name = "目的国快递单状态") + private String destResultState; + + /** 目的国通讯状态 */ + @Excel(name = "目的国通讯状态") + private String destResultStatus; + + /** 目的国快递单明细状态 */ + @Excel(name = "目的国快递单明细状态") + private String destResultCondition; + + /** 目的国是否签收 */ + @Excel(name = "目的国是否签收") + private String destResultIsCheck; + + /** 目的国快递公司编码 */ + @Excel(name = "目的国快递公司编码") + private String destResultCom; + + /** 目的国快递单号 */ + @Excel(name = "目的国快递单号") + private String destResultNu; + + /** 目的国快递流转信息 */ + @Excel(name = "目的国快递流转信息") + private String destResultData; + + /** 最后更新时间 */ + @Excel(name = "最后更新时间") + private String lastResponseTime; + + public Long getSid() { + return sid; + } + + public void setSid(Long sid) { + this.sid = sid; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getBillStatus() { + return billStatus; + } + + public void setBillStatus(String billStatus) { + this.billStatus = billStatus; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getAutoCheck() { + return autoCheck; + } + + public void setAutoCheck(String autoCheck) { + this.autoCheck = autoCheck; + } + + public String getComOld() { + return comOld; + } + + public void setComOld(String comOld) { + this.comOld = comOld; + } + + public String getComNew() { + return comNew; + } + + public void setComNew(String comNew) { + this.comNew = comNew; + } + + public String getLastResultMessage() { + return lastResultMessage; + } + + public void setLastResultMessage(String lastResultMessage) { + this.lastResultMessage = lastResultMessage; + } + + public String getLastResultState() { + return lastResultState; + } + + public void setLastResultState(String lastResultState) { + this.lastResultState = lastResultState; + } + + public String getLastResulStatus() { + return lastResulStatus; + } + + public void setLastResulStatus(String lastResulStatus) { + this.lastResulStatus = lastResulStatus; + } + + public String getLastResultCondition() { + return lastResultCondition; + } + + public void setLastResultCondition(String lastResultCondition) { + this.lastResultCondition = lastResultCondition; + } + + public String getLastResultIsCheck() { + return lastResultIsCheck; + } + + public void setLastResultIsCheck(String lastResultIsCheck) { + this.lastResultIsCheck = lastResultIsCheck; + } + + public String getLastResultCom() { + return lastResultCom; + } + + public void setLastResultCom(String lastResultCom) { + this.lastResultCom = lastResultCom; + } + + public String getLastResultNu() { + return lastResultNu; + } + + public void setLastResultNu(String lastResultNu) { + this.lastResultNu = lastResultNu; + } + + public String getLastResultData() { + return lastResultData; + } + + public void setLastResultData(String lastResultData) { + this.lastResultData = lastResultData; + } + + public String getDestResultMessage() { + return destResultMessage; + } + + public void setDestResultMessage(String destResultMessage) { + this.destResultMessage = destResultMessage; + } + + public String getDestResultState() { + return destResultState; + } + + public void setDestResultState(String destResultState) { + this.destResultState = destResultState; + } + + public String getDestResultStatus() { + return destResultStatus; + } + + public void setDestResultStatus(String destResultStatus) { + this.destResultStatus = destResultStatus; + } + + public String getDestResultCondition() { + return destResultCondition; + } + + public void setDestResultCondition(String destResultCondition) { + this.destResultCondition = destResultCondition; + } + + public String getDestResultIsCheck() { + return destResultIsCheck; + } + + public void setDestResultIsCheck(String destResultIsCheck) { + this.destResultIsCheck = destResultIsCheck; + } + + public String getDestResultCom() { + return destResultCom; + } + + public void setDestResultCom(String destResultCom) { + this.destResultCom = destResultCom; + } + + public String getDestResultNu() { + return destResultNu; + } + + public void setDestResultNu(String destResultNu) { + this.destResultNu = destResultNu; + } + + public String getDestResultData() { + return destResultData; + } + + public void setDestResultData(String destResultData) { + this.destResultData = destResultData; + } + + public String getLastResponseTime() { + return lastResponseTime; + } + + public void setLastResponseTime(String lastResponseTime) { + this.lastResponseTime = lastResponseTime; + } + + @Override + public String toString() { + return "ExpSubsPushResp{" + + "sid=" + sid + + ", status='" + status + '\'' + + ", billStatus='" + billStatus + '\'' + + ", message='" + message + '\'' + + ", autoCheck='" + autoCheck + '\'' + + ", comOld='" + comOld + '\'' + + ", comNew='" + comNew + '\'' + + ", lastResultMessage='" + lastResultMessage + '\'' + + ", lastResultState='" + lastResultState + '\'' + + ", lastResulStatus='" + lastResulStatus + '\'' + + ", lastResultCondition='" + lastResultCondition + '\'' + + ", lastResultIsCheck='" + lastResultIsCheck + '\'' + + ", lastResultCom='" + lastResultCom + '\'' + + ", lastResultNu='" + lastResultNu + '\'' + + ", lastResultData='" + lastResultData + '\'' + + ", destResultMessage='" + destResultMessage + '\'' + + ", destResultState='" + destResultState + '\'' + + ", destResultStatus='" + destResultStatus + '\'' + + ", destResultCondition='" + destResultCondition + '\'' + + ", destResultIsCheck='" + destResultIsCheck + '\'' + + ", destResultCom='" + destResultCom + '\'' + + ", destResultNu='" + destResultNu + '\'' + + ", destResultData='" + destResultData + '\'' + + ", lastResponseTime='" + lastResponseTime + '\'' + + '}'; + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/domain/ExpSubscribe.java b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpSubscribe.java new file mode 100644 index 000000000..2ef48209f --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpSubscribe.java @@ -0,0 +1,149 @@ +package com.ruoyi.bps.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 快递订阅对象 exp_subscribe + * + * @author box + * @date 2021-05-20 + */ +public class ExpSubscribe extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** SID */ + private Long sid; + + /** 快递公司编码 */ + @Excel(name = "快递公司编码") + private String company; + + /** 快递单号 */ + @Excel(name = "快递单号") + private String number; + + /** 收/寄件人电话 */ + @Excel(name = "收/寄件人电话") + private String phone; + + /** 盐 */ + @Excel(name = "盐") + private String salt; + + /** 订阅时间 */ + @Excel(name = "订阅时间") + private String subscribeTime; + + /** 订阅结果 */ + @Excel(name = "订阅结果") + private String result; + + /** 返回码 */ + @Excel(name = "返回码") + private String returnCode; + + /** 返回消息 */ + @Excel(name = "返回消息") + private String message; + + public void setSid(Long sid) + { + this.sid = sid; + } + + public Long getSid() + { + return sid; + } + public void setCompany(String company) + { + this.company = company; + } + + public String getCompany() + { + return company; + } + public void setNumber(String number) + { + this.number = number; + } + + public String getNumber() + { + return number; + } + public void setPhone(String phone) + { + this.phone = phone; + } + + public String getPhone() + { + return phone; + } + public void setSalt(String salt) + { + this.salt = salt; + } + + public String getSalt() + { + return salt; + } + public void setSubscribeTime(String subscribeTime) + { + this.subscribeTime = subscribeTime; + } + + public String getSubscribeTime() + { + return subscribeTime; + } + public void setResult(String result) + { + this.result = result; + } + + public String getResult() + { + return result; + } + public void setReturnCode(String returnCode) + { + this.returnCode = returnCode; + } + + public String getReturnCode() + { + return returnCode; + } + public void setMessage(String message) + { + this.message = message; + } + + public String getMessage() + { + return message; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("sid", getSid()) + .append("company", getCompany()) + .append("number", getNumber()) + .append("phone", getPhone()) + .append("salt", getSalt()) + .append("subscribeTime", getSubscribeTime()) + .append("result", getResult()) + .append("returnCode", getReturnCode()) + .append("message", getMessage()) + .toString(); + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java new file mode 100644 index 000000000..fdd8384e4 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java @@ -0,0 +1,298 @@ +package com.ruoyi.bps.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 快递信息对象 expressInfo + * + * @author box + * @date 2021-05-06 + */ +public class ExpressInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 消息 */ + private String sid; + + /** 消息 */ + @Excel(name = "消息",type= Excel.Type.EXPORT) + private String message; + + + /** 出货单号 */ + @Excel(name = "出货单号") + private String deliveryNum; + + /** 快递单号 */ + @Excel(name = "快递单号") + private String nu; + + /** 签收状态 */ + @Excel(name = "签收状态",type= Excel.Type.EXPORT,readConverterExp = "0=未签收,1=已签收") + private String ischeck; + + /** 快递公司 */ + @Excel(name = "快递公司",type= Excel.Type.EXPORT,dictType = "express_company") + private String com; + + /** 通信状态 */ + //@Excel(name = "通信状态",type= Excel.Type.EXPORT) + private String status; + + /** 运单详情 */ + @Excel(name = "运单详情",type= Excel.Type.EXPORT) + private String data; + + /** 当前状态 */ + @Excel(name = "当前状态",type= Excel.Type.EXPORT,dictType = "express_stats") + private String state; + + /** 状态标志 */ + //@Excel(name = "状态标志",type= Excel.Type.EXPORT) + private String condition; + + /** 路由信息 */ + //@Excel(name = "路由信息",type= Excel.Type.EXPORT) + private String routeInfo; + + /** 返回码 */ + //@Excel(name = "返回码",type= Excel.Type.EXPORT) + private String returnCode; + + /** 返回结果 */ + //@Excel(name = "返回结果",type= Excel.Type.EXPORT) + private String result; + + /** 电话号码 */ + //@Excel(name = "电话号码",type= Excel.Type.EXPORT) + private String phone; + + /** 揽收时间*/ + @Excel(name = "揽收时间",type= Excel.Type.EXPORT) + private String collectTime; + + /** 签收时间*/ + @Excel(name = "签收时间",type= Excel.Type.EXPORT) + private String singedTime; + + /** 最后更新时间*/ + @Excel(name = "最后更新时间",type= Excel.Type.EXPORT) + private String lastUpdateTime; + + /** 查询时间*/ + @Excel(name = "查询时间",type= Excel.Type.EXPORT) + private String queryTime; + + /** 查询人*/ + @Excel(name = "查询人",type= Excel.Type.EXPORT) + private String queryUserName; + + /** 查询ID*/ + private String queryId; + + /** 查询类型*/ + private String queryType; + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getDeliveryNum() { + return deliveryNum; + } + + public void setDeliveryNum(String deliveryNum) { + this.deliveryNum = deliveryNum; + } + + public String getNu() { + return nu; + } + + public void setNu(String nu) { + this.nu = nu; + } + + public String getIscheck() { + return ischeck; + } + + public void setIscheck(String ischeck) { + this.ischeck = ischeck; + } + + public String getCom() { + return com; + } + + public void setCom(String com) { + this.com = com; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCondition() { + return condition; + } + + public void setCondition(String condition) { + this.condition = condition; + } + + public String getRouteInfo() { + return routeInfo; + } + + public void setRouteInfo(String routeInfo) { + this.routeInfo = routeInfo; + } + + public String getReturnCode() { + return returnCode; + } + + public void setReturnCode(String returnCode) { + this.returnCode = returnCode; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getCollectTime() { + return collectTime; + } + + public void setCollectTime(String collectTime) { + this.collectTime = collectTime; + } + + public String getSingedTime() { + return singedTime; + } + + public void setSingedTime(String singedTime) { + this.singedTime = singedTime; + } + + public String getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(String lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getQueryTime() { + return queryTime; + } + + public void setQueryTime(String queryTime) { + this.queryTime = queryTime; + } + + public String getQueryUserName() { + return queryUserName; + } + + public void setQueryUserName(String queryUserName) { + this.queryUserName = queryUserName; + } + + public String getQueryId() { + return queryId; + } + + public void setQueryId(String queryId) { + this.queryId = queryId; + } + + public String getQueryType() { + return queryType; + } + + public void setQueryType(String queryType) { + this.queryType = queryType; + } + + @Override + public String toString() { + return "ExpressInfo{" + + "sid='" + sid + '\'' + + ", message='" + message + '\'' + + ", deliveryNum='" + deliveryNum + '\'' + + ", nu='" + nu + '\'' + + ", ischeck='" + ischeck + '\'' + + ", com='" + com + '\'' + + ", status='" + status + '\'' + + ", data='" + data + '\'' + + ", state='" + state + '\'' + + ", condition='" + condition + '\'' + + ", routeInfo='" + routeInfo + '\'' + + ", returnCode='" + returnCode + '\'' + + ", result='" + result + '\'' + + ", phone='" + phone + '\'' + + ", collectTime='" + collectTime + '\'' + + ", singedTime='" + singedTime + '\'' + + ", lastUpdateTime='" + lastUpdateTime + '\'' + + ", queryTime='" + queryTime + '\'' + + ", queryUserName='" + queryUserName + '\'' + + ", queryId='" + queryId + '\'' + + ", queryType='" + queryType + '\'' + + '}'; + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpImportQueryMapper.java b/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpImportQueryMapper.java new file mode 100644 index 000000000..a5f968462 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpImportQueryMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.bps.mapper; + +import java.util.List; +import com.ruoyi.bps.domain.ExpImportQuery; + +/** + * Excel批量快递查询Mapper接口 + * + * @author Bo + * @date 2021-07-21 + */ +public interface ExpImportQueryMapper +{ + /** + * 查询Excel批量快递查询 + * + * @param sid Excel批量快递查询ID + * @return Excel批量快递查询 + */ + public ExpImportQuery selectExpImportQueryById(Long sid); + + /** + * 查询Excel批量快递查询列表 + * + * @param expImportQuery Excel批量快递查询 + * @return Excel批量快递查询集合 + */ + public List selectExpImportQueryList(ExpImportQuery expImportQuery); + + /** + * 新增Excel批量快递查询 + * + * @param expImportQuery Excel批量快递查询 + * @return 结果 + */ + public int insertExpImportQuery(ExpImportQuery expImportQuery); + + /** + * 修改Excel批量快递查询 + * + * @param expImportQuery Excel批量快递查询 + * @return 结果 + */ + public int updateExpImportQuery(ExpImportQuery expImportQuery); + + /** + * 删除Excel批量快递查询 + * + * @param sid Excel批量快递查询ID + * @return 结果 + */ + public int deleteExpImportQueryById(Long sid); + + /** + * 批量删除Excel批量快递查询 + * + * @param sids 需要删除的数据ID + * @return 结果 + */ + public int deleteExpImportQueryByIds(String[] sids); +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpSubsPushRespMapper.java b/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpSubsPushRespMapper.java new file mode 100644 index 000000000..f1a0bac8b --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpSubsPushRespMapper.java @@ -0,0 +1,64 @@ +package com.ruoyi.bps.mapper; + +import com.ruoyi.bps.domain.ExpSubsPushResp; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +/** + * 快递订阅推送信息Mapper接口 + * + * @author box + * @date 2021-05-13 + */ +public interface ExpSubsPushRespMapper +{ + /** + * 查询快递订阅推送信息 + * + * @param sid 快递订阅推送信息ID + * @return 快递订阅推送信息 + */ + public ExpSubsPushResp selectExpSubsPushRespById(Long sid); + + /** + * 查询快递订阅推送信息列表 + * + * @param expSubsPushResp 快递订阅推送信息 + * @return 快递订阅推送信息集合 + */ + public List selectExpSubsPushRespList(ExpSubsPushResp expSubsPushResp); + + /** + * 新增快递订阅推送信息 + * + * @param expSubsPushResp 快递订阅推送信息 + * @return 结果 + */ + public int insertExpSubsPushResp(ExpSubsPushResp expSubsPushResp); + + /** + * 修改快递订阅推送信息 + * + * @param expSubsPushResp 快递订阅推送信息 + * @return 结果 + */ + public int updateExpSubsPushResp(ExpSubsPushResp expSubsPushResp); + + /** + * 删除快递订阅推送信息 + * + * @param sid 快递订阅推送信息ID + * @return 结果 + */ + public int deleteExpSubsPushRespById(Long sid); + + /** + * 批量删除快递订阅推送信息 + * + * @param sids 需要删除的数据ID + * @return 结果 + */ + public int deleteExpSubsPushRespByIds(String[] sids); +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpSubscribeMapper.java b/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpSubscribeMapper.java new file mode 100644 index 000000000..e13b0bbb0 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpSubscribeMapper.java @@ -0,0 +1,73 @@ +package com.ruoyi.bps.mapper; + +import com.ruoyi.bps.domain.ExpSubsPushResp; +import com.ruoyi.bps.domain.ExpSubscribe; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +/** + * 快递订阅Mapper接口 + * + * @author box + * @date 2021-05-20 + */ +public interface ExpSubscribeMapper +{ + /** + * 查询快递订阅 + * + * @param sid 快递订阅ID + * @return 快递订阅 + */ + public ExpSubscribe selectExpSubscribeById(Long sid); + + /** + * 查询快递订阅列表 + * + * @param expSubscribe 快递订阅 + * @return 快递订阅集合 + */ + public List selectExpSubscribeList(ExpSubscribe expSubscribe); + + /** + * 新增快递订阅 + * + * @param expSubscribe 快递订阅 + * @return 结果 + */ + public int insertExpSubscribe(ExpSubscribe expSubscribe); + + /** + * 修改快递订阅 + * + * @param expSubscribe 快递订阅 + * @return 结果 + */ + public int updateExpSubscribe(ExpSubscribe expSubscribe); + + /** + * 删除快递订阅 + * + * @param sid 快递订阅ID + * @return 结果 + */ + public int deleteExpSubscribeById(Long sid); + + /** + * 批量删除快递订阅 + * + * @param sids 需要删除的数据ID + * @return 结果 + */ + public int deleteExpSubscribeByIds(String[] sids); + + /** + * 根据快递单号查询快递订阅推送信息 + * + * @param number 快递单号List + * @return 快递订阅推送信息 + */ + public List selectExpSubscribeByNumber(List number); +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpressInfoMapper.java b/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpressInfoMapper.java new file mode 100644 index 000000000..0d8fcd6a5 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/mapper/ExpressInfoMapper.java @@ -0,0 +1,82 @@ +package com.ruoyi.bps.mapper; + +import com.ruoyi.bps.domain.ExpressInfo; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +/** + * 快递信息Mapper接口 + * + * @author box + * @date 2021-05-06 + */ +public interface ExpressInfoMapper +{ + /** + * 查询快递信息 + * + * @param message 快递信息ID + * @return 快递信息 + */ + public ExpressInfo selectExpressInfoById(String message); + + /** + * 查询快递信息列表 + * + * @param expressInfo 快递信息 + * @return 快递信息集合 + */ + public List selectExpressInfoList(ExpressInfo expressInfo); + + /** + * 新增快递信息 + * + * @param expressInfo 快递信息 + * @return 结果 + */ + public int insertExpressInfo(ExpressInfo expressInfo); + + /** + * 修改快递信息 + * + * @param expressInfo 快递信息 + * @return 结果 + */ + public int updateExpressInfo(ExpressInfo expressInfo); + + /** + * 删除快递信息 + * + * @param message 快递信息ID + * @return 结果 + */ + public int deleteExpressInfoById(String message); + + /** + * 批量删除快递信息 + * + * @param messages 需要删除的数据ID + * @return 结果 + */ + public int deleteExpressInfoByIds(String[] messages); + + /** + * 批量新增快递信息 + * + * @param expressInfoList 角色菜单列表 + * @return 结果 + */ + public int batchInsertExpressInfo(List expressInfoList); + + + /** + * 删除快递信息 + * + * @param queryId 快递信息queryId + * @return 结果 + */ + public int deleteExpressInfoByQueryId(String queryId); + +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/mapper/TopgpDdlMapper.java b/box-bps/src/main/java/com/ruoyi/bps/mapper/TopgpDdlMapper.java new file mode 100644 index 000000000..ad06f7d89 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/mapper/TopgpDdlMapper.java @@ -0,0 +1,32 @@ +package com.ruoyi.bps.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Component; + +@Mapper +@Component("TopgpDdlMapper") +public interface TopgpDdlMapper { + // alter table + int alterTableName(@Param("originalTableName") String originalTableName, + @Param("newTableName") String newTableName); + + //truncate table + int truncateTable(@Param("tableName") String tableName); + + //drop table + int dropTable(@Param("tableName") String tableName); + + //copy table + void copyTable(@Param("newTableName") String newTableName, + @Param("originalTableName") String originalTableName); + + //获取表记录数 + int getRecordCount(@Param("tableName") String tableName); + + + + //查询数据库中表是否存在 + int isTableInDb(@Param("dataBaseName") String dataBaseName, + @Param("tableName") String tableName); +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/IExpImportQueryService.java b/box-bps/src/main/java/com/ruoyi/bps/service/IExpImportQueryService.java new file mode 100644 index 000000000..0a08b6692 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/IExpImportQueryService.java @@ -0,0 +1,72 @@ +package com.ruoyi.bps.service; + +import java.util.List; +import com.ruoyi.bps.domain.ExpImportQuery; +import com.ruoyi.bps.domain.ExpressInfo; +import com.ruoyi.common.core.domain.AjaxResult; + +/** + * Excel批量快递查询Service接口 + * + * @author Bo + * @date 2021-07-21 + */ +public interface IExpImportQueryService +{ + /** + * 查询Excel批量快递查询 + * + * @param sid Excel批量快递查询ID + * @return Excel批量快递查询 + */ + public ExpImportQuery selectExpImportQueryById(Long sid); + + /** + * 查询Excel批量快递查询列表 + * + * @param expImportQuery Excel批量快递查询 + * @return Excel批量快递查询集合 + */ + public List selectExpImportQueryList(ExpImportQuery expImportQuery); + + /** + * 新增Excel批量快递查询 + * + * @param expImportQuery Excel批量快递查询 + * @return 结果 + */ + public int insertExpImportQuery(ExpImportQuery expImportQuery); + + /** + * 修改Excel批量快递查询 + * + * @param expImportQuery Excel批量快递查询 + * @return 结果 + */ + public int updateExpImportQuery(ExpImportQuery expImportQuery); + + /** + * 批量删除Excel批量快递查询 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteExpImportQueryByIds(String ids); + + /** + * 删除Excel批量快递查询信息 + * + * @param sid Excel批量快递查询ID + * @return 结果 + */ + public int deleteExpImportQueryById(Long sid); + + /** + * 删除Excel批量快递查询信息 + * + * @param expressInfoList Excel导入的快递列表 + * @return 结果 + */ + public AjaxResult importData(List expressInfoList) throws Exception; + +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/IExpSubsPushApiService.java b/box-bps/src/main/java/com/ruoyi/bps/service/IExpSubsPushApiService.java new file mode 100644 index 000000000..f47f834de --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/IExpSubsPushApiService.java @@ -0,0 +1,36 @@ +package com.ruoyi.bps.service; + +import com.ruoyi.bps.domain.ExpSubscribe; +import com.kuaidi100.sdk.response.SubscribeResp; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +public interface IExpSubsPushApiService { + + /** + * 向快递100推送订阅请求 + * @param expSubscribe + * @return + */ + public SubscribeResp ExpressSubscribe(ExpSubscribe expSubscribe); + + /** + * 快递100订阅推送处理 + * + * 回调接口支持自定义参数,比如订阅时回调地址填写的是 http://www.xxx.com?orderId=1233333 + * 可以通过下面这种方式获取到orderId: String orderId = request.getParameter("orderId"); + * + * 返回值必须是下面这样的格式,否则快递100将认为该推送失败,快递100将会重试3次该推送,时间间隔35分钟; + * 成功结果返回例子: {"result":true,"returnCode":"200","message":"提交成功"} + * + */ + public SubscribeResp ExpressSubscribeCallBackUrl(HttpServletRequest request); + + /** + * 获取Topgp推送的快递信息,向快递100推送订阅请求 + * @param request + * @return + */ + public String ExpressSubscribeWithTopgp(HttpServletRequest request) throws IOException; +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/IExpSubsPushRespService.java b/box-bps/src/main/java/com/ruoyi/bps/service/IExpSubsPushRespService.java new file mode 100644 index 000000000..61a6f4aba --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/IExpSubsPushRespService.java @@ -0,0 +1,63 @@ +package com.ruoyi.bps.service; + +import com.ruoyi.bps.domain.ExpSubsPushResp; + +import java.util.List; + +/** + * 快递订阅推送信息Service接口 + * + * @author box + * @date 2021-05-13 + */ +public interface IExpSubsPushRespService +{ + /** + * 查询快递订阅推送信息 + * + * @param sid 快递订阅推送信息ID + * @return 快递订阅推送信息 + */ + public ExpSubsPushResp selectExpSubsPushRespById(Long sid); + + /** + * 查询快递订阅推送信息列表 + * + * @param expSubsPushResp 快递订阅推送信息 + * @return 快递订阅推送信息集合 + */ + public List selectExpSubsPushRespList(ExpSubsPushResp expSubsPushResp); + + /** + * 新增快递订阅推送信息 + * + * @param expSubsPushResp 快递订阅推送信息 + * @return 结果 + */ + public int insertExpSubsPushResp(ExpSubsPushResp expSubsPushResp); + + /** + * 修改快递订阅推送信息 + * + * @param expSubsPushResp 快递订阅推送信息 + * @return 结果 + */ + public int updateExpSubsPushResp(ExpSubsPushResp expSubsPushResp); + + /** + * 批量删除快递订阅推送信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteExpSubsPushRespByIds(String ids); + + /** + * 删除快递订阅推送信息信息 + * + * @param sid 快递订阅推送信息ID + * @return 结果 + */ + public int deleteExpSubsPushRespById(Long sid); + +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/IExpSubscribeService.java b/box-bps/src/main/java/com/ruoyi/bps/service/IExpSubscribeService.java new file mode 100644 index 000000000..58d46a868 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/IExpSubscribeService.java @@ -0,0 +1,71 @@ +package com.ruoyi.bps.service; + +import com.ruoyi.bps.domain.ExpSubsPushResp; +import com.ruoyi.bps.domain.ExpSubscribe; + +import java.util.List; + +/** + * 快递订阅Service接口 + * + * @author box + * @date 2021-05-20 + */ +public interface IExpSubscribeService +{ + /** + * 查询快递订阅 + * + * @param sid 快递订阅ID + * @return 快递订阅 + */ + public ExpSubscribe selectExpSubscribeById(Long sid); + + /** + * 查询快递订阅列表 + * + * @param expSubscribe 快递订阅 + * @return 快递订阅集合 + */ + public List selectExpSubscribeList(ExpSubscribe expSubscribe); + + /** + * 新增快递订阅 + * + * @param expSubscribe 快递订阅 + * @return 结果 + */ + public int insertExpSubscribe(ExpSubscribe expSubscribe); + + /** + * 修改快递订阅 + * + * @param expSubscribe 快递订阅 + * @return 结果 + */ + public int updateExpSubscribe(ExpSubscribe expSubscribe); + + /** + * 批量删除快递订阅 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteExpSubscribeByIds(String ids); + + /** + * 删除快递订阅信息 + * + * @param sid 快递订阅ID + * @return 结果 + */ + public int deleteExpSubscribeById(Long sid); + + /** + * 根据快递单号查询快递订阅推送信息 + * + * @param number 快递单号List + * @return 快递订阅推送信息 + */ + public List selectExpSubsPushRespByNumber(List number); +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/IExpressInfoService.java b/box-bps/src/main/java/com/ruoyi/bps/service/IExpressInfoService.java new file mode 100644 index 000000000..48c284c68 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/IExpressInfoService.java @@ -0,0 +1,78 @@ +package com.ruoyi.bps.service; + +import com.ruoyi.bps.domain.ExpressInfo; + +import java.util.List; + +/** + * 快递信息Service接口 + * + * @author box + * @date 2021-05-06 + */ +public interface IExpressInfoService +{ + /** + * 查询快递信息 + * + * @param message 快递信息ID + * @return 快递信息 + */ + public ExpressInfo selectExpressInfoById(String message); + + /** + * 查询本地快递信息列表 + * + * @param expressInfo 快递信息 + * @return 快递信息集合 + */ + public List selectLocalExpressInfoList(ExpressInfo expressInfo); + + /** + * 查询本地快递信息列表 + * + * @param expressInfo 快递信息 + * @return 快递信息集合 + */ + public List selectExpressInfoList(ExpressInfo expressInfo); + + /** + * 新增快递信息 + * + * @param expressInfo 快递信息 + * @return 结果 + */ + public int insertExpressInfo(ExpressInfo expressInfo); + + /** + * 修改快递信息 + * + * @param expressInfo 快递信息 + * @return 结果 + */ + public int updateExpressInfo(ExpressInfo expressInfo); + + /** + * 批量删除快递信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteExpressInfoByIds(String ids); + + /** + * 删除快递信息信息 + * + * @param message 快递信息ID + * @return 结果 + */ + public int deleteExpressInfoById(String message); + + /** + * 查询快递信息 + * + * @param expressInfo 快递信息 + * @return 快递信息 + */ + public ExpressInfo SelectExpressInfo(ExpressInfo expressInfo); +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/IExpressService.java b/box-bps/src/main/java/com/ruoyi/bps/service/IExpressService.java new file mode 100644 index 000000000..b3adfa8da --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/IExpressService.java @@ -0,0 +1,33 @@ +package com.ruoyi.bps.service; + +//import com.ruoyi.bps.express.request.QueryTrackParam; +//import com.ruoyi.bps.express.response.QueryTrackResp; + +import com.kuaidi100.sdk.request.QueryTrackParam; +import com.kuaidi100.sdk.response.QueryTrackResp; + +import java.util.List; + +public interface IExpressService { + + public List QueryTrackExpressMultiList(List list); + /** + * 查询多条物流轨迹 + */ + public String QueryTrackExpressMulti(List list); + + /** + * 查询物流轨迹 + */ + public String QueryTrackExpress(QueryTrackParam qt); + + /** + * 订阅 + */ + public String SubscribeExpress(); + + /** + * 测试快递单号合集 + */ + public List GetTestQueryTrackParam(); +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/TopgpDdlService.java b/box-bps/src/main/java/com/ruoyi/bps/service/TopgpDdlService.java new file mode 100644 index 000000000..e2d2b4e6a --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/TopgpDdlService.java @@ -0,0 +1,22 @@ +package com.ruoyi.bps.service; + +public interface TopgpDdlService { + //修改表名 + int alterTableName(String originalTableName, String newTableName); + + // truncate指定数据库表的数据 + int truncateTable(String tableName); + + //drop 指定定数据库表 + int dropTable(String tableName); + + + //根据传入的表明,创建新的表并且将原表的数据插入到新的Occur表中 + void copyTable(String newTableName,String originalTableName); + + //统计某张表中的总数据条数 + int getRecordCount(String tableName); + + //从指定数据库中,查询是否存在某张表 + int isTableInDb(String dataBaseName, String tableName); +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpImportQueryServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpImportQueryServiceImpl.java new file mode 100644 index 000000000..813c66b4c --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpImportQueryServiceImpl.java @@ -0,0 +1,174 @@ +package com.ruoyi.bps.service.impl; + +import com.ruoyi.bps.domain.ExpImportQuery; +import com.ruoyi.bps.domain.ExpressInfo; +import com.ruoyi.bps.mapper.ExpImportQueryMapper; +import com.ruoyi.bps.mapper.ExpressInfoMapper; +import com.ruoyi.bps.service.IExpImportQueryService; +import com.ruoyi.bps.service.IExpressInfoService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Excel批量快递查询Service业务层处理 + * + * @author Bo + * @date 2021-07-21 + */ +@Service +public class ExpImportQueryServiceImpl implements IExpImportQueryService +{ + @Autowired + private ExpImportQueryMapper expImportQueryMapper; + + @Autowired + private IExpressInfoService expressInfoService; + + @Autowired + private ExpressInfoMapper expressInfoMapper; + + /** + * 查询Excel批量快递查询 + * + * @param sid Excel批量快递查询ID + * @return Excel批量快递查询 + */ + @Override + public ExpImportQuery selectExpImportQueryById(Long sid) + { + return expImportQueryMapper.selectExpImportQueryById(sid); + } + + /** + * 查询Excel批量快递查询列表 + * + * @param expImportQuery Excel批量快递查询 + * @return Excel批量快递查询 + */ + @Override + public List selectExpImportQueryList(ExpImportQuery expImportQuery) + { + return expImportQueryMapper.selectExpImportQueryList(expImportQuery); + } + + /** + * 新增Excel批量快递查询 + * + * @param expImportQuery Excel批量快递查询 + * @return 结果 + */ + @Override + public int insertExpImportQuery(ExpImportQuery expImportQuery) + { + return expImportQueryMapper.insertExpImportQuery(expImportQuery); + } + + /** + * 修改Excel批量快递查询 + * + * @param expImportQuery Excel批量快递查询 + * @return 结果 + */ + @Override + public int updateExpImportQuery(ExpImportQuery expImportQuery) + { + return expImportQueryMapper.updateExpImportQuery(expImportQuery); + } + + /** + * 删除Excel批量快递查询对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + @Transactional + public int deleteExpImportQueryByIds(String ids) + { + for(String str:Arrays.asList(ids.split(","))) + { + expressInfoMapper.deleteExpressInfoByQueryId(str); + } + int message= expImportQueryMapper.deleteExpImportQueryByIds(Convert.toStrArray(ids)); + return message; + } + + /** + * 删除Excel批量快递查询信息 + * + * @param sid Excel批量快递查询ID + * @return 结果 + */ + @Override + public int deleteExpImportQueryById(Long sid) + { + return expImportQueryMapper.deleteExpImportQueryById(sid); + } + + + /** + * Excel批量快递查询信息 + * + * @param expressInfoList Excel导入的快递列表 + * @return 结果 + */ + @Override + @Transactional + public AjaxResult importData(List expressInfoList) throws Exception { + String queryTime= DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss"); + String queryId= LocalDateTime.now().toString(); + ExpImportQuery expImportQuery=new ExpImportQuery(); + List expressInfoListForInsert=new ArrayList<>(); + /* try{*/ + //将查询到的快递结果放到expressInfoListForInsert,并插入到数据库表expressInfo + for( ExpressInfo expressInfo:expressInfoList){ + ExpressInfo ei= expressInfoService.SelectExpressInfo(expressInfo); + ei.setQueryId(queryId); + ei.setQueryUserName(ShiroUtils.getSysUser().getUserName()); + ei.setQueryType("excel"); + ei.setQueryTime(queryTime); + //expressInfoService.insertExpressInfo(ei); + expressInfoListForInsert.add(ei); + /* for(int i=1;i<1001;i++){ //测试批量插入效率用时打开Mark,产生5万条数据。 + expressInfoListForInsert.add(ei); + }*/ + } + int size= expressInfoListForInsert.size(); + List expressInfos= new ArrayList<>(); + for(int i=1;i<=size;i++){ + expressInfos.add(expressInfoListForInsert.get(i-1)); + if( (i%400==0 ) ||i== size) { + expressInfoMapper.batchInsertExpressInfo(expressInfos); + expressInfos.clear(); + } + } + //将本次excel导入查询记录到数据表exp_import_query + expImportQuery.setQueryTime(queryTime); + expImportQuery.setQueryLoginName(ShiroUtils.getLoginName()); + expImportQuery.setQueryUserName(ShiroUtils.getSysUser().getUserName()); + expImportQuery.setFinishTime(DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss")); + expImportQuery.setQueryIp(ShiroUtils.getIp()); + expImportQuery.setStatus("success"); + expImportQuery.setQueryQty(String.valueOf(expressInfoList.size())); + expImportQuery.setQueryId(queryId); + int message=expImportQueryMapper.insertExpImportQuery(expImportQuery); + return AjaxResult.success(message); + + + /*}catch (Exception e){ + expImportQuery.setStatus("fail"); + return AjaxResult.error(e.getMessage()); + }*/ + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubsPushApiServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubsPushApiServiceImpl.java new file mode 100644 index 000000000..96c5e6fa9 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubsPushApiServiceImpl.java @@ -0,0 +1,312 @@ +package com.ruoyi.bps.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; +import com.kuaidi100.sdk.api.Subscribe; +import com.kuaidi100.sdk.contant.ApiInfoConstant; +import com.kuaidi100.sdk.core.IBaseClient; +import com.kuaidi100.sdk.pojo.HttpResult; +import com.kuaidi100.sdk.request.SubscribeParam; +import com.kuaidi100.sdk.request.SubscribeParameters; +import com.kuaidi100.sdk.request.SubscribeReq; +import com.kuaidi100.sdk.response.SubscribePushData; +import com.kuaidi100.sdk.response.SubscribePushParamResp; +import com.kuaidi100.sdk.response.SubscribePushResult; +import com.kuaidi100.sdk.response.SubscribeResp; +import com.kuaidi100.sdk.utils.PropertiesReader; +import com.kuaidi100.sdk.utils.SignUtils; +import com.ruoyi.bps.domain.ExpSubsPushResp; +import com.ruoyi.bps.domain.ExpSubscribe; +import com.ruoyi.bps.service.IExpSubsPushApiService; +import com.ruoyi.bps.service.IExpSubsPushRespService; +import com.ruoyi.bps.service.IExpSubscribeService; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService { + String key = PropertiesReader.get("key"); + String customer = PropertiesReader.get("customer"); + String secret = PropertiesReader.get("secret"); + String siid = PropertiesReader.get("siid"); + String userid = PropertiesReader.get("userid"); + String tid = PropertiesReader.get("tid"); + String secret_key = PropertiesReader.get("secret_key"); + String secret_secret = PropertiesReader.get("secret_secret"); + + @Autowired + private IExpSubsPushRespService expSubsPushRespService; + + @Autowired + IExpSubscribeService expSubscribeService; + + /** + * 订阅快递 + * @throws Exception + */ + @Override + public SubscribeResp ExpressSubscribe(ExpSubscribe expSubscribe) { + String subscribeFrom= expSubscribe.getSalt().equals("topgp")?"topgp":"bpsemi"; + + SubscribeParameters subscribeParameters = new SubscribeParameters(); + SubscribeResp subscribeResp = new SubscribeResp(); + subscribeParameters.setCallbackurl("http://report.bpsemi.cn:8081/it_war/anon/subscribeCallBackUrl"); + subscribeParameters.setPhone(expSubscribe.getPhone()); + subscribeParameters.setSalt("bpsemi"); + SubscribeParam subscribeParam = new SubscribeParam(); + subscribeParam.setParameters(subscribeParameters); + subscribeParam.setCompany(expSubscribe.getCompany()); + subscribeParam.setNumber(expSubscribe.getNumber()); + subscribeParam.setKey(key); + + SubscribeReq subscribeReq = new SubscribeReq(); + subscribeReq.setSchema(ApiInfoConstant.SUBSCRIBE_SCHEMA); + subscribeReq.setParam(new Gson().toJson(subscribeParam)); + + IBaseClient subscribe = new Subscribe(); + try{ + HttpResult httpResult= subscribe.execute(subscribeReq); + //System.out.println(httpResult); + subscribeResp= new Gson().fromJson(httpResult.getBody(),SubscribeResp.class); + }catch (Exception e) + { + return subscribeResp; + } + //如果快递公司或快递单号为空,则直接返回订阅结果 + if(StringUtils.isEmpty(expSubscribe.getCompany()) || StringUtils.isEmpty(expSubscribe.getNumber())) + { + return subscribeResp; + } + + //订阅记录写入数据库 + ExpSubscribe newExpSubscribe = new ExpSubscribe(); + newExpSubscribe.setCompany(expSubscribe.getCompany()); + newExpSubscribe.setNumber(expSubscribe.getNumber()); + newExpSubscribe.setPhone(expSubscribe.getPhone()); + newExpSubscribe.setSalt(subscribeFrom); //偷懒,把请求来源记录到salt栏位,不再增加exp_subscribe字段了。。以后找时间改吧 + newExpSubscribe.setSubscribeTime(DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss")); + newExpSubscribe.setResult((subscribeResp.isResult())?"true":"false"); + newExpSubscribe.setReturnCode(subscribeResp.getReturnCode()); + newExpSubscribe.setMessage(subscribeResp.getMessage()); + + /*ExpSubscribe queryExpSubscribe = new ExpSubscribe(); + queryExpSubscribe.setCompany(expSubscribe.getCompany()); + queryExpSubscribe.setNumber(expSubscribe.getNumber()); + queryExpSubscribe.setResult(expSubscribe.getResult()); + queryExpSubscribe.setReturnCode(expSubscribe.getReturnCode()); + List list=expSubscribeService.selectExpSubscribeList(queryExpSubscribe); + if(list.size()>0){ + //如果数据库中存在快递单号+快递公司编码+结果+返回码相同,则更新记录 + for(ExpSubscribe es:list){ + queryExpSubscribe= newExpSubscribe; + queryExpSubscribe.setSid(es.getSid()); + expSubscribeService.updateExpSubscribe(queryExpSubscribe); + } + }else { + //如果数据库中没有快递单号+快递公司编码,则更插入新记录 + expSubscribeService.insertExpSubscribe(newExpSubscribe); + }*/ + //20210802 无论系统里有没有记录,都会记录本次推送。 + expSubscribeService.insertExpSubscribe(newExpSubscribe); + + //返回订阅结果 + return subscribeResp; + } + + /** + * 获取从快递100订阅的快递推送信息,并返回响应结果 + * + * @param request 快递100推送的订阅信息 + * @return 结果 + */ + @Override + public SubscribeResp ExpressSubscribeCallBackUrl(HttpServletRequest request) { + //如果推送信息中没有包含 + if(StringUtils.isEmpty(request.getParameter("param")) + || StringUtils.isEmpty(request.getParameter("sign"))) { + SubscribeResp subscribeResp= new SubscribeResp(); + subscribeResp.setResult(Boolean.FALSE); + subscribeResp.setReturnCode("701"); + subscribeResp.setMessage("推送的信息不合法!"); + return subscribeResp; + } + + String param= request.getParameter("param"); + String sign = request.getParameter("sign"); + //log.debug("快递100订阅推送回调结果|{}|{}",param,sign); + //订阅时传的salt + String salt = "bpsemi"; + String ourSign = SignUtils.sign(param + salt); + SubscribeResp subscribeResp = new SubscribeResp(); + subscribeResp.setResult(Boolean.TRUE); + subscribeResp.setReturnCode("200"); + //加密如果不等,则不属于快递100推送,忽略掉当前请求 + if (!ourSign.equals(sign)){ + subscribeResp.setMessage("接受成功!但加密验证不通过!【sign】"+sign+"【ourSign】"+ourSign); + return subscribeResp; + } + //加密相等,继续处理业务逻辑 + subscribeResp.setMessage("接受成功!加密验证通过!【sign】"+sign+"【ourSign】"+ourSign); + + SubscribePushParamResp subscribePushParamResp = new Gson().fromJson(param, SubscribePushParamResp.class); + SubscribePushResult subscribePushResult = subscribePushParamResp.getLastResult(); + //快递单号 + String nu = subscribePushResult.getNu(); + //监控状态 (polling:监控中,shutdown:结束,abort:中止,updateall:重新推送。其中当快递单为已签收时status=shutdown) + String status= subscribePushParamResp.getStatus(); + if(status.equals("abort")){ + //todo + //当message为“3天查询无记录”或“60天无变化时”status= abort ,对于status=abort的状态的处理逻辑 + //将Abort信息存档。然后预警 + + } + //快递单当前状态 (0在途,1揽收,2疑难,3签收,4退签,5派件,6退回,7转单,10待清关,11清关中,12已清关,13清关异常,14收件人拒签) + String state = subscribePushResult.getState(); + //if(state.equals("3")){ + //处理签收逻辑 + //将快递流转状态存入数据库 + ExpSubsPushResp expSubsPushResp=new ExpSubsPushResp(); + expSubsPushResp.setLastResultNu(subscribePushResult.getNu()); + expSubsPushResp.setLastResultCom(subscribePushResult.getCom()); + List list=expSubsPushRespService.selectExpSubsPushRespList(expSubsPushResp); + if(list.size()>0){ + //如果数据库中存在快递单号+快递公司编码,则更新记录 + ExpSubsPushResp newExpSubsPushResp= ToExpSubsPushResp(subscribePushParamResp); + for(ExpSubsPushResp expr:list){ + newExpSubsPushResp.setSid(expr.getSid()); + expSubsPushRespService.updateExpSubsPushResp(newExpSubsPushResp); + newExpSubsPushResp.setSid(null); + } + }else { + //如果数据库中没有快递单号+快递公司编码,则更插入新记录 + expSubsPushRespService.insertExpSubsPushResp(ToExpSubsPushResp(subscribePushParamResp)); + } + // } + + return subscribeResp; + } + + /** + * 将快递100推送的信息转换为ExpSubsPushResp + * @param subscribePushParamResp + * @return ExpSubsPushResp + */ + private ExpSubsPushResp ToExpSubsPushResp(SubscribePushParamResp subscribePushParamResp){ + ExpSubsPushResp expSubsPushResp=new ExpSubsPushResp(); + + SubscribePushResult subscribePushLastResult = subscribePushParamResp.getLastResult(); + SubscribePushResult subscribePushDestResult = subscribePushParamResp.getDestResult(); + + expSubsPushResp.setStatus(subscribePushParamResp.getStatus()); + expSubsPushResp.setBillStatus(subscribePushParamResp.getBillstatus()); + expSubsPushResp.setMessage(subscribePushParamResp.getMessage()); + expSubsPushResp.setAutoCheck(subscribePushParamResp.getAutoCheck()); + expSubsPushResp.setComOld(subscribePushParamResp.getComOld()); + expSubsPushResp.setComNew(subscribePushParamResp.getComNew()); + + expSubsPushResp.setLastResultMessage(subscribePushLastResult.getMessage()); + expSubsPushResp.setLastResultState(subscribePushLastResult.getState()); + expSubsPushResp.setLastResulStatus(subscribePushLastResult.getStatus()); + expSubsPushResp.setLastResultCondition(subscribePushLastResult.getCondition()); + expSubsPushResp.setLastResultIsCheck(subscribePushLastResult.getIscheck()); + expSubsPushResp.setLastResultCom(subscribePushLastResult.getCom()); + expSubsPushResp.setLastResultNu(subscribePushLastResult.getNu()); + expSubsPushResp.setLastResultData(SubscribePushDataToString(subscribePushLastResult.getData())); + + if(subscribePushDestResult != null) { + //只有邮政国外的快递推送才会有DestResult信息 + expSubsPushResp.setDestResultMessage(subscribePushDestResult.getMessage()); + expSubsPushResp.setDestResultState(subscribePushDestResult.getState()); + expSubsPushResp.setDestResultStatus(subscribePushDestResult.getStatus()); + expSubsPushResp.setDestResultCondition(subscribePushDestResult.getCondition()); + expSubsPushResp.setDestResultIsCheck(subscribePushDestResult.getIscheck()); + expSubsPushResp.setDestResultCom(subscribePushDestResult.getCom()); + expSubsPushResp.setDestResultNu(subscribePushDestResult.getNu()); + expSubsPushResp.setDestResultData(SubscribePushDataToString(subscribePushDestResult.getData())); + } + expSubsPushResp.setLastResponseTime(DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss")); + + return expSubsPushResp; + } + + /** + * + * @param list 将List转化为字符串 + * @return + */ + private String SubscribePushDataToString(List list){ + String str=""; + for(SubscribePushData subscribePushData:list){ + str+="【"+subscribePushData.getTime()+"】 "; + if(StringUtils.isNotEmpty(subscribePushData.getAreaName())) + { + str+=subscribePushData.getAreaName()+"/"; //某些快递没有AreaName信息 + } + str+=subscribePushData.getContext(); + if(list.size()-1>list.indexOf(subscribePushData)){ + str+="\r\n"; + } + } + //System.out.println(str); + return str; + } + + + /** + * 获取Topgp推送的快递信息,向快递100推送订阅请求 + * + * @param request + * @return + */ + @Override + public String ExpressSubscribeWithTopgp(HttpServletRequest request) throws IOException { + //获取httpServletRequest传过来的Json字符串,并进行解析 + JSONObject contentJson= JSONObject.parseObject(ServletUtils.getRequestContent(request)); + String deliveryNo= contentJson.getString("deliveryNo"); + String expressNo = contentJson.getString("expressNo"); + String company = contentJson.getString("company"); + String phone = contentJson.getString("phone"); + //如果出货单号或者快递单号为空,则返回错误信息,并写入Logo + if(StringUtils.isEmpty(deliveryNo) || StringUtils.isEmpty(expressNo)){ + Map map=new HashMap<>(); + map.put("result",false); + map.put("returnCode",700); + map.put("message","快递单号或出货单号为空!"); + map.put("deliveryNo",deliveryNo); + map.put("expressNo",expressNo); + //写入Logo + //todo + + //返回错误信息 + return JSONObject.toJSONString(map); + + } + //向快递100推送订阅请求 + ExpSubscribe expSubscribe=new ExpSubscribe(); + expSubscribe.setNumber(expressNo); + expSubscribe.setCompany(company); + expSubscribe.setPhone(phone); + expSubscribe.setSalt("topgp"); //偷懒,把请求来源记录到salt栏位,不再增加exp_subscribe字段了。。以后找时间改吧 + SubscribeResp subscribeResp= ExpressSubscribe(expSubscribe); + + Object object = JSONObject.toJSON(subscribeResp); + Map map=JSONObject.parseObject(object.toString(), Map.class); + map.put("deliveryNo",deliveryNo); + map.put("expressNo",expressNo); + return JSONObject.toJSONString(map); + } + + + + + +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubsPushRespServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubsPushRespServiceImpl.java new file mode 100644 index 000000000..777b2568d --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubsPushRespServiceImpl.java @@ -0,0 +1,95 @@ +package com.ruoyi.bps.service.impl; + +import com.ruoyi.bps.domain.ExpSubsPushResp; +import com.ruoyi.bps.mapper.ExpSubsPushRespMapper; +import com.ruoyi.bps.service.IExpSubsPushRespService; +import com.ruoyi.common.core.text.Convert; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 快递订阅推送信息Service业务层处理 + * + * @author box + * @date 2021-05-13 + */ +@Service +public class ExpSubsPushRespServiceImpl implements IExpSubsPushRespService +{ + @Autowired + private ExpSubsPushRespMapper expSubsPushRespMapper; + + /** + * 查询快递订阅推送信息 + * + * @param sid 快递订阅推送信息ID + * @return 快递订阅推送信息 + */ + @Override + public ExpSubsPushResp selectExpSubsPushRespById(Long sid) + { + return expSubsPushRespMapper.selectExpSubsPushRespById(sid); + } + + /** + * 查询快递订阅推送信息列表 + * + * @param expSubsPushResp 快递订阅推送信息 + * @return 快递订阅推送信息 + */ + @Override + public List selectExpSubsPushRespList(ExpSubsPushResp expSubsPushResp) + { + return expSubsPushRespMapper.selectExpSubsPushRespList(expSubsPushResp); + } + + /** + * 新增快递订阅推送信息 + * + * @param expSubsPushResp 快递订阅推送信息 + * @return 结果 + */ + @Override + public int insertExpSubsPushResp(ExpSubsPushResp expSubsPushResp) + { + return expSubsPushRespMapper.insertExpSubsPushResp(expSubsPushResp); + } + + /** + * 修改快递订阅推送信息 + * + * @param expSubsPushResp 快递订阅推送信息 + * @return 结果 + */ + @Override + public int updateExpSubsPushResp(ExpSubsPushResp expSubsPushResp) + { + return expSubsPushRespMapper.updateExpSubsPushResp(expSubsPushResp); + } + + /** + * 删除快递订阅推送信息对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteExpSubsPushRespByIds(String ids) + { + return expSubsPushRespMapper.deleteExpSubsPushRespByIds(Convert.toStrArray(ids)); + } + + /** + * 删除快递订阅推送信息信息 + * + * @param sid 快递订阅推送信息ID + * @return 结果 + */ + @Override + public int deleteExpSubsPushRespById(Long sid) + { + return expSubsPushRespMapper.deleteExpSubsPushRespById(sid); + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubscribeServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubscribeServiceImpl.java new file mode 100644 index 000000000..259ac3aa2 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubscribeServiceImpl.java @@ -0,0 +1,108 @@ +package com.ruoyi.bps.service.impl; + +import com.ruoyi.bps.domain.ExpSubsPushResp; +import com.ruoyi.bps.domain.ExpSubscribe; +import com.ruoyi.bps.mapper.ExpSubscribeMapper; +import com.ruoyi.bps.service.IExpSubscribeService; +import com.ruoyi.common.core.text.Convert; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 快递订阅Service业务层处理 + * + * @author box + * @date 2021-05-20 + */ +@Service +public class ExpSubscribeServiceImpl implements IExpSubscribeService +{ + @Autowired + private ExpSubscribeMapper expSubscribeMapper; + + /** + * 查询快递订阅 + * + * @param sid 快递订阅ID + * @return 快递订阅 + */ + @Override + public ExpSubscribe selectExpSubscribeById(Long sid) + { + return expSubscribeMapper.selectExpSubscribeById(sid); + } + + /** + * 查询快递订阅列表 + * + * @param expSubscribe 快递订阅 + * @return 快递订阅 + */ + @Override + public List selectExpSubscribeList(ExpSubscribe expSubscribe) + { + return expSubscribeMapper.selectExpSubscribeList(expSubscribe); + } + + /** + * 新增快递订阅 + * + * @param expSubscribe 快递订阅 + * @return 结果 + */ + @Override + public int insertExpSubscribe(ExpSubscribe expSubscribe) + { + return expSubscribeMapper.insertExpSubscribe(expSubscribe); + } + + /** + * 修改快递订阅 + * + * @param expSubscribe 快递订阅 + * @return 结果 + */ + @Override + public int updateExpSubscribe(ExpSubscribe expSubscribe) + { + return expSubscribeMapper.updateExpSubscribe(expSubscribe); + } + + /** + * 删除快递订阅对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteExpSubscribeByIds(String ids) + { + return expSubscribeMapper.deleteExpSubscribeByIds(Convert.toStrArray(ids)); + } + + /** + * 删除快递订阅信息 + * + * @param sid 快递订阅ID + * @return 结果 + */ + @Override + public int deleteExpSubscribeById(Long sid) + { + return expSubscribeMapper.deleteExpSubscribeById(sid); + } + + + /** + * 根据快递单号查询快递订阅推送信息 + * + * @param number 快递单号List + * @return 快递订阅推送信息 + */ + @Override + public List selectExpSubsPushRespByNumber(List number){ + return expSubscribeMapper.selectExpSubscribeByNumber(number); + } +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java new file mode 100644 index 000000000..6e1f80630 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java @@ -0,0 +1,300 @@ +package com.ruoyi.bps.service.impl; + +import com.ruoyi.bps.domain.ExpressInfo; +import com.ruoyi.bps.mapper.ExpressInfoMapper; +import com.ruoyi.bps.service.IExpressInfoService; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.common.utils.StringUtils; +import com.google.gson.Gson; +import com.kuaidi100.sdk.api.AutoNum; +import com.kuaidi100.sdk.api.QueryTrack; +import com.kuaidi100.sdk.core.IBaseClient; +import com.kuaidi100.sdk.pojo.HttpResult; +import com.kuaidi100.sdk.request.AutoNumReq; +import com.kuaidi100.sdk.request.QueryTrackParam; +import com.kuaidi100.sdk.request.QueryTrackReq; +import com.kuaidi100.sdk.response.AutoNumResp; +import com.kuaidi100.sdk.response.QueryTrackData; +import com.kuaidi100.sdk.response.QueryTrackResp; +import com.kuaidi100.sdk.utils.PropertiesReader; +import com.kuaidi100.sdk.utils.SignUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * 快递信息Service业务层处理 + * + * @author box + * @date 2021-05-06 + */ +@Service +public class ExpressInfoServiceImpl implements IExpressInfoService +{ + /* + String key = "Jydbrxsm2311"; + String customer = "2DD48B3469B82F2B7700569093AB792B"; + String secret = "8781ed9b35a7438499eb02fee915915a"; + String userid = "2a62da2192c24d17a943ff78ee64f8c6"; + + */ + + String key = PropertiesReader.get("key"); + String customer = PropertiesReader.get("customer"); + String secret = PropertiesReader.get("secret"); + String siid = PropertiesReader.get("siid"); + String userid = PropertiesReader.get("userid"); + String tid = PropertiesReader.get("tid"); + String secret_key = PropertiesReader.get("secret_key"); + String secret_secret = PropertiesReader.get("secret_secret"); + + + + String msg=""; + + @Autowired + private ExpressInfoMapper expressInfoMapper; + + /** + * 查询快递信息 + * + * @param message 快递信息ID + * @return 快递信息 + */ + @Override + public ExpressInfo selectExpressInfoById(String message) + { + return expressInfoMapper.selectExpressInfoById(message); + } + + /** + * 查询本地快递信息列表 + * + * @param expressInfo 快递信息 + * @return 快递信息集合 + */ + @Override + public List selectLocalExpressInfoList(ExpressInfo expressInfo) { + return expressInfoMapper.selectExpressInfoList(expressInfo); + } + + /** + * 查询快递信息列表 + * + * @param expressInfo 快递信息 + * @return 快递信息列表 + */ + @Override + public List selectExpressInfoList(ExpressInfo expressInfo) + { + List expressInfoList=new ArrayList<>(); + //如果没有输入订单号,则返回空信息 + String nuStr=expressInfo.getNu(); + if(StringUtils.isEmpty(nuStr)){ + expressInfo.setData("请输入订单号进行查询!"); + expressInfoList.add(expressInfo); + return expressInfoList; + } + //如果是顺丰,则必须要输入电话号码 + if( StringUtils.isEmpty(expressInfo.getPhone()) + && (expressInfo.getCom().equals("nsf") || expressInfo.getCom().contains("shunfeng"))){ + expressInfo.setData("查询顺丰快递信息,必须要提供收/寄人电话号码"); + expressInfoList.add(expressInfo); + return expressInfoList; + } + + List stringList= Arrays.asList(nuStr.split(",")); + ExpressInfo newExpressInfo= expressInfo; + for(String str:stringList){ + newExpressInfo.setNu(str); + expressInfoList.add(SelectExpressInfo(newExpressInfo)); + } + return expressInfoList; + //return expressInfoMapper.selectExpressInfoList(expressInfo); + } + + @Override + public ExpressInfo SelectExpressInfo(ExpressInfo expressInfo){ + String nu=expressInfo.getNu(); //快递单号 + String com=expressInfo.getCom(); //快递公司 + String phone=expressInfo.getPhone(); //收、寄件人电话号码 + String deliveryNum= expressInfo.getDeliveryNum(); + ExpressInfo callbackExpressInfo=new ExpressInfo(); + + callbackExpressInfo.setNu(nu); + callbackExpressInfo.setPhone(phone); + callbackExpressInfo.setDeliveryNum(deliveryNum); + //如果没有输入快递公司编号,则查询快递公司编号 + if(StringUtils.isEmpty(com)){ + if(AutoGetExpressCom(nu)==null){ + callbackExpressInfo.setData("根据快递单号查询不到快递公司,请确认快递单号是否正确!"); + return callbackExpressInfo; + } + com=AutoGetExpressCom(nu).getComCode(); + } + callbackExpressInfo.setCom(com); + + //return callbackExpressInfo; + return QueryExpressInfo(callbackExpressInfo); + } + + private ExpressInfo QueryExpressInfo(ExpressInfo expressInfo){ + //从expressInfo中获取快递单号、物流信息、电话,生成快递请求参数 + QueryTrackParam queryTrackParam= new QueryTrackParam(); + queryTrackParam.setNum(expressInfo.getNu()); + queryTrackParam.setCom(expressInfo.getCom()); + queryTrackParam.setPhone(expressInfo.getPhone()); + + //获取快递信息 + String param = new Gson().toJson(queryTrackParam); + QueryTrackReq queryTrackReq=new QueryTrackReq(); + queryTrackReq.setParam(param); + queryTrackReq.setCustomer(customer); + queryTrackReq.setSign(SignUtils.querySign(param ,key,customer)); + HttpResult httpResult =new HttpResult(); + IBaseClient baseClient = new QueryTrack(); + try { + httpResult = baseClient.execute(queryTrackReq); + msg=httpResult.getBody(); + } + catch (Exception e) { + msg=e.toString(); + } + + //将快递信息转化为QueryTrackResp对象 + QueryTrackResp queryTrackResp = new Gson().fromJson(msg,QueryTrackResp.class); + + //如果没有查到物流信息,则返回错误信息 + if(StringUtils.isEmpty(queryTrackResp.getStatus()) || !queryTrackResp.getStatus().equals("200")){ + expressInfo.setData(queryTrackResp.getMessage()); + return expressInfo; + } + + //获取签收时间 + String signedTime=null; + if(queryTrackResp.getState().equals("3")) { + signedTime=queryTrackResp.getData().get(0).getFtime(); + } + + //获取最后更新时间 + String lastUpdateTime=queryTrackResp.getData().get(0).getFtime(); + + //获取揽收时间 + String collectTime= queryTrackResp.getData().get(queryTrackResp.getData().size()-1).getTime(); + + //获取查询时间 + String queryTime= StringUtils.isNotEmpty(expressInfo.getQueryTime())?expressInfo.getQueryTime():DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss"); + + //获取查询人(登录用户) + String queryUserName= ShiroUtils.getLoginName(); + + //将快递信息中的Context转化为字符 + String dataStr=""; + for(QueryTrackData queryTrackData :queryTrackResp.getData()){ + dataStr+="【"+queryTrackData.getTime()+"】 "; + dataStr+=queryTrackData.getContext(); + if(queryTrackResp.getData().size()-1>queryTrackResp.getData().indexOf(queryTrackData)){ + dataStr+="\r\n"; + } + } + String a= queryTrackResp.getCondition(); + ExpressInfo callbackExpressInfo=new ExpressInfo(); + callbackExpressInfo.setMessage(queryTrackResp.getMessage()); + callbackExpressInfo.setNu(queryTrackResp.getNu()); + callbackExpressInfo.setIscheck(queryTrackResp.getIscheck()); + callbackExpressInfo.setCom(queryTrackResp.getCom()); + callbackExpressInfo.setStatus(queryTrackResp.getStatus()); + callbackExpressInfo.setData(dataStr); + callbackExpressInfo.setState(queryTrackResp.getState()); + callbackExpressInfo.setCondition(queryTrackResp.getCondition()); + callbackExpressInfo.setRouteInfo(""); //出发位置,当前位置,到达位置,暂无信息 + callbackExpressInfo.setReturnCode(queryTrackResp.getReturnCode()); + callbackExpressInfo.setResult(queryTrackResp.isResult()?"Y":"N"); + callbackExpressInfo.setPhone(expressInfo.getPhone()); + callbackExpressInfo.setSingedTime(signedTime); + callbackExpressInfo.setCollectTime(collectTime); + callbackExpressInfo.setLastUpdateTime(lastUpdateTime); + callbackExpressInfo.setQueryTime(queryTime); + callbackExpressInfo.setQueryUserName(queryUserName); + callbackExpressInfo.setDeliveryNum(expressInfo.getDeliveryNum()); + + return callbackExpressInfo; + } + + /** + * 根据快递单号,查询快递公司编码 + * @param num 快递单号 + * @return 快递公司编码 + */ + + private AutoNumResp AutoGetExpressCom(String num){ + AutoNumReq autoNumReq = new AutoNumReq(); + autoNumReq.setKey(key); + autoNumReq.setNum(num); + + IBaseClient baseClient = new AutoNum(); + AutoNumResp autoNumResp=new AutoNumResp(); + try { + String str= baseClient.execute(autoNumReq).getBody().replace("[","").replace("]",""); + autoNumResp = new Gson().fromJson(str,AutoNumResp.class); + + } catch (Exception e) { + e.printStackTrace(); + } + return autoNumResp; + } + + /** + * 新增快递信息 + * + * @param expressInfo 快递信息 + * @return 结果 + */ + @Override + public int insertExpressInfo(ExpressInfo expressInfo) + { + return expressInfoMapper.insertExpressInfo(expressInfo); + } + + /** + * 修改快递信息 + * + * @param expressInfo 快递信息 + * @return 结果 + */ + @Override + public int updateExpressInfo(ExpressInfo expressInfo) + { + return expressInfoMapper.updateExpressInfo(expressInfo); + } + + /** + * 删除快递信息对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteExpressInfoByIds(String ids) + { + return expressInfoMapper.deleteExpressInfoByIds(Convert.toStrArray(ids)); + } + + /** + * 删除快递信息信息 + * + * @param message 快递信息ID + * @return 结果 + */ + @Override + public int deleteExpressInfoById(String message) + { + return expressInfoMapper.deleteExpressInfoById(message); + } + +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressServiceImpl.java new file mode 100644 index 000000000..7be4e0eb5 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressServiceImpl.java @@ -0,0 +1,188 @@ +package com.ruoyi.bps.service.impl; + + +import com.google.gson.Gson; +import com.kuaidi100.sdk.api.QueryTrack; +import com.kuaidi100.sdk.api.Subscribe; +import com.kuaidi100.sdk.contant.ApiInfoConstant; +import com.kuaidi100.sdk.core.IBaseClient; +import com.kuaidi100.sdk.pojo.HttpResult; +import com.kuaidi100.sdk.request.*; +import com.kuaidi100.sdk.response.QueryTrackResp; +import com.kuaidi100.sdk.utils.PropertiesReader; +import com.kuaidi100.sdk.utils.SignUtils; +import com.ruoyi.bps.service.IExpressService; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class ExpressServiceImpl implements IExpressService { + /* + String key = "Jydbrxsm2311"; + String customer = "2DD48B3469B82F2B7700569093AB792B"; + String secret = "8781ed9b35a7438499eb02fee915915a"; + String userid = "2a62da2192c24d17a943ff78ee64f8c6"; + */ + String key = PropertiesReader.get("key"); + String customer = PropertiesReader.get("customer"); + String secret = PropertiesReader.get("secret"); + String siid = PropertiesReader.get("siid"); + String userid = PropertiesReader.get("userid"); + String tid = PropertiesReader.get("tid"); + String secret_key = PropertiesReader.get("secret_key"); + String secret_secret = PropertiesReader.get("secret_secret"); + String msg=""; + @Autowired + IExpressService expressService; + + @Override + public List QueryTrackExpressMultiList(List list) { + List qtList=new ArrayList<>(); + + for(QueryTrackParam queryTrackParam:list) + { + QueryTrackResp queryTrackResp = new Gson().fromJson(expressService.QueryTrackExpress(queryTrackParam),QueryTrackResp.class); + qtList.add(queryTrackResp); + } + return qtList; + } + + /** + *查询多个物流轨迹 + */ + @Override + public String QueryTrackExpressMulti(List list) { + String str=""; + for(QueryTrackParam qt:list){ + str += QueryTrackExpress(qt); + } + return str; + } + + /** + * 查询单个物流轨迹 + */ + @Override + public String QueryTrackExpress(QueryTrackParam queryTrackParam) { + String str=""; + QueryTrackReq queryTrackReq = new QueryTrackReq(); + String param = new Gson().toJson(queryTrackParam); + + queryTrackReq.setParam(param); + queryTrackReq.setCustomer(customer); + queryTrackReq.setSign(SignUtils.querySign(param ,key,customer)); + HttpResult httpResult=new HttpResult(); + IBaseClient baseClient = new QueryTrack(); + try { + httpResult = baseClient.execute(queryTrackReq); + msg=httpResult.getBody(); + } + catch (Exception e) { + msg=e.toString(); + } + + JSONObject jsonObject = new JSONObject(msg); + if (jsonObject.has("returnCode")){ + QueryTrackResp queryTrackResp= new Gson().fromJson(msg,QueryTrackResp.class); + queryTrackResp.setStatus(queryTrackResp.getReturnCode()); + queryTrackResp.setNu(queryTrackParam.getNum()); + msg= new Gson().toJson(queryTrackResp); + } + /* else { + QueryTrackResp queryTrackResp=new Gson().fromJson(msg,QueryTrackResp.class); + for(int i=0;i GetTestQueryTrackParam() { + QueryTrackParam queryTrackParam = new QueryTrackParam(); + List list=new ArrayList(); + queryTrackParam.setCom("annengwuliu"); + queryTrackParam.setNum("300445967949"); + queryTrackParam.setPhone("17725390266"); + list.add(queryTrackParam); + + QueryTrackParam queryTrackParam1 = new QueryTrackParam(); + queryTrackParam1.setCom("annengwuliu"); + queryTrackParam1.setNum("300445967135"); + queryTrackParam1.setPhone("17725390266"); + list.add(queryTrackParam1); + + + QueryTrackParam queryTrackParam2 = new QueryTrackParam(); + queryTrackParam2.setCom("annengwuliu"); + queryTrackParam2.setNum("3004459670971"); + queryTrackParam2.setPhone("17725390266"); + list.add(queryTrackParam2); +/* + QueryTrackParam queryTrackParam3 = new QueryTrackParam(); + queryTrackParam3.setCom(CompanyConstant.AN); + queryTrackParam3.setNum("300445967045"); + queryTrackParam3.setPhone("17725390266"); + list.add(queryTrackParam3); + + QueryTrackParam queryTrackParam4 = new QueryTrackParam(); + queryTrackParam4.setCom(CompanyConstant.AN); + queryTrackParam4.setNum("300443569920"); + queryTrackParam4.setPhone("17725390266"); + list.add(queryTrackParam4); + + QueryTrackParam queryTrackParam5 = new QueryTrackParam(); + queryTrackParam5.setCom(CompanyConstant.AN); + queryTrackParam5.setNum("300443569878"); + queryTrackParam5.setPhone("17725390266"); + list.add(queryTrackParam5); + + QueryTrackParam queryTrackParam6 = new QueryTrackParam(); + queryTrackParam6.setCom(CompanyConstant.AN); + queryTrackParam6.setNum("300443569880"); + queryTrackParam6.setPhone("17725390266"); + list.add(queryTrackParam6); + */ + return list; + } + + +} diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/TopgpDdlServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/TopgpDdlServiceImpl.java new file mode 100644 index 000000000..932526508 --- /dev/null +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/TopgpDdlServiceImpl.java @@ -0,0 +1,46 @@ +package com.ruoyi.bps.service.impl; + +import com.ruoyi.bps.mapper.TopgpDdlMapper; +import com.ruoyi.bps.service.TopgpDdlService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +//@DataSource(value = DataSourceType.SLAVE) +//@DataSource(value = DataSourceType.TOPTESTDSREPORT) +public class TopgpDdlServiceImpl implements TopgpDdlService { + @Autowired + private TopgpDdlMapper topgpDdlMapper; + + //修改表名 + public int alterTableName(String originalTableName, String newTableName) + { + return topgpDdlMapper.alterTableName(originalTableName,newTableName); + } + + // truncate指定数据库表的数据 + public int truncateTable(String tableName){ + return topgpDdlMapper.truncateTable(tableName); + } + + //drop 指定定数据库表 + public int dropTable(String tableName){ + return topgpDdlMapper.dropTable(tableName); + } + + + //根据传入的表明,创建新的表并且将原表的数据插入到新的Occur表中 + public void copyTable(String newTableName,String originalTableName){ + return ; + } + + //统计某张表中的总数据条数 + public int getRecordCount(String tableName){ + return topgpDdlMapper.getRecordCount(tableName); + } + + //从指定数据库中,查询是否存在某张表 + public int isTableInDb(String dataBaseName, String tableName){ + return topgpDdlMapper.isTableInDb(dataBaseName,tableName); + } +} diff --git a/box-bps/src/main/resources/account.properties b/box-bps/src/main/resources/account.properties new file mode 100644 index 000000000..c7f7dc6a0 --- /dev/null +++ b/box-bps/src/main/resources/account.properties @@ -0,0 +1,25 @@ +#快递100的基础账号信息,可以在这里获取 +# https://poll.kuaidi100.com/manager/page/myinfo/enterprise +key = Jydbrxsm2311 +customer = 2DD48B3469B82F2B7700569093AB792B +secret = 8781ed9b35a7438499eb02fee915915a +userid = 2a62da2192c24d17a943ff78ee64f8c6 + +#电子面单快递公司账号信息(非必填) +partnerId = +partnerKey = +net = +siid = + +#短信模板id(非必填) +tid = + +#云平台相关(非必填) +#登录云平台 https://cloud.kuaidi100.com/buyer/user/info +secret_key = +secret_secret = + +#是否记录快递100接口返回结果,建议记录日志或者入库,方便后期有问题双方排查(true:启用 false: 关闭 ) +log.return.record = true +#日志记录位置,建议根据自身情况配置 +logPath = logs \ No newline at end of file diff --git a/box-bps/src/main/resources/mapper/bps/ExpImportQueryMapper.xml b/box-bps/src/main/resources/mapper/bps/ExpImportQueryMapper.xml new file mode 100644 index 000000000..1a405a2c7 --- /dev/null +++ b/box-bps/src/main/resources/mapper/bps/ExpImportQueryMapper.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + select sid, queryId, queryTime, queryLoginName, queryUserName, queryIp, finishTime, status, queryQty from exp_import_query + + + + + + + + insert into exp_import_query + + queryTime, + queryId, + queryLoginName, + queryUserName, + queryIp, + finishTime, + status, + queryQty, + + + #{queryTime}, + #{queryId}, + #{queryLoginName}, + #{queryUserName}, + #{queryIp}, + #{finishTime}, + #{status}, + #{queryQty}, + + + + + update exp_import_query + + queryTime = #{queryTime}, + queryId = #{queryId}, + queryLoginName = #{queryLoginName}, + queryUserName = #{queryUserName}, + queryIp = #{queryIp}, + finishTime = #{finishTime}, + status = #{status}, + queryQty = #{queryQty}, + + where sid = #{sid} + + + + delete from exp_import_query where sid = #{sid} + + + + delete from exp_import_query where sid in + + #{sid} + + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/mapper/bps/ExpSubsPushRespMapper.xml b/box-bps/src/main/resources/mapper/bps/ExpSubsPushRespMapper.xml new file mode 100644 index 000000000..3c8b7e752 --- /dev/null +++ b/box-bps/src/main/resources/mapper/bps/ExpSubsPushRespMapper.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select sid, status, billStatus, message, autoCheck, comOld, comNew, lastResultMessage, lastResultState, lastResulStatus, lastResultCondition, lastResultIsCheck, lastResultCom, lastResultNu, lastResultData, destResultMessage, destResultState, destResultStatus, destResultCondition, destResultIsCheck, destResultCom, destResultNu, destResultData, lastResponseTime from exp_subs_push_resp + + + + + + + + insert into exp_subs_push_resp + + status, + billStatus, + message, + autoCheck, + comOld, + comNew, + lastResultMessage, + lastResultState, + lastResulStatus, + lastResultCondition, + lastResultIsCheck, + lastResultCom, + lastResultNu, + lastResultData, + destResultMessage, + destResultState, + destResultStatus, + destResultCondition, + destResultIsCheck, + destResultCom, + destResultNu, + destResultData, + lastResponseTime, + + + #{status}, + #{billStatus}, + #{message}, + #{autoCheck}, + #{comOld}, + #{comNew}, + #{lastResultMessage}, + #{lastResultState}, + #{lastResulStatus}, + #{lastResultCondition}, + #{lastResultIsCheck}, + #{lastResultCom}, + #{lastResultNu}, + #{lastResultData}, + #{destResultMessage}, + #{destResultState}, + #{destResultStatus}, + #{destResultCondition}, + #{destResultIsCheck}, + #{destResultCom}, + #{destResultNu}, + #{destResultData}, + #{lastResponseTime}, + + + + + update exp_subs_push_resp + + status = #{status}, + billStatus = #{billStatus}, + message = #{message}, + autoCheck = #{autoCheck}, + comOld = #{comOld}, + comNew = #{comNew}, + lastResultMessage = #{lastResultMessage}, + lastResultState = #{lastResultState}, + lastResulStatus = #{lastResulStatus}, + lastResultCondition = #{lastResultCondition}, + lastResultIsCheck = #{lastResultIsCheck}, + lastResultCom = #{lastResultCom}, + lastResultNu = #{lastResultNu}, + lastResultData = #{lastResultData}, + destResultMessage = #{destResultMessage}, + destResultState = #{destResultState}, + destResultStatus = #{destResultStatus}, + destResultCondition = #{destResultCondition}, + destResultIsCheck = #{destResultIsCheck}, + destResultCom = #{destResultCom}, + destResultNu = #{destResultNu}, + destResultData = #{destResultData}, + lastResponseTime = #{lastResponseTime}, + + where sid = #{sid} + + + + delete from exp_subs_push_resp where sid = #{sid} + + + + delete from exp_subs_push_resp where sid in + + #{sid} + + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/mapper/bps/ExpSubscribeMapper.xml b/box-bps/src/main/resources/mapper/bps/ExpSubscribeMapper.xml new file mode 100644 index 000000000..a80cb1ff5 --- /dev/null +++ b/box-bps/src/main/resources/mapper/bps/ExpSubscribeMapper.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + select sid, company, number, phone, salt, subscribeTime, result, returnCode, message from exp_subscribe + + + + + + + + insert into exp_subscribe + + company, + number, + phone, + salt, + subscribeTime, + result, + returnCode, + message, + + + #{company}, + #{number}, + #{phone}, + #{salt}, + #{subscribeTime}, + #{result}, + #{returnCode}, + #{message}, + + + + + update exp_subscribe + + company = #{company}, + number = #{number}, + phone = #{phone}, + salt = #{salt}, + subscribeTime = #{subscribeTime}, + result = #{result}, + returnCode = #{returnCode}, + message = #{message}, + + where sid = #{sid} + + + + delete from exp_subscribe where sid = #{sid} + + + + delete from exp_subscribe where sid in + + #{sid} + + + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/mapper/bps/ExpressInfoMapper.xml b/box-bps/src/main/resources/mapper/bps/ExpressInfoMapper.xml new file mode 100644 index 000000000..5d9416346 --- /dev/null +++ b/box-bps/src/main/resources/mapper/bps/ExpressInfoMapper.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select sid, message, nu, deliveryNum, ischeck, com, status, `data`, `state`, `condition`, routeInfo, returnCode, `result`, phone, + collectTime, singedTime, lastUpdateTime, queryTime, queryUserName, queryId, queryType + from expressInfo + + + + + + + + insert into expressInfo + + message, + nu, + ischeck, + com, + status, + `data`, + `state`, + `condition`, + routeInfo, + returnCode, + `result`, + phone, + collectTime, + singedTime, + lastUpdateTime, + queryTime, + queryUserName, + queryId, + queryType, + deliveryNum, + + + #{message}, + #{nu}, + #{ischeck}, + #{com}, + #{status}, + #{data}, + #{state}, + #{condition}, + #{routeInfo}, + #{returnCode}, + #{result}, + #{phone}, + #{collectTime}, + #{singedTime}, + #{lastUpdateTime}, + #{queryTime}, + #{queryUserName}, + #{queryId}, + #{queryType}, + #{deliveryNum}, + + + + + update expressInfo + + nu = #{nu}, + ischeck = #{ischeck}, + com = #{com}, + status = #{status}, + `data` = #{data}, + `state` = #{state}, + `condition` = #{condition}, + routeInfo = #{routeInfo}, + returnCode = #{returnCode}, + `result` = #{result}, + phone = #{phone}, + collectTime = #{collectTime}, + singedTime = #{singedTime}, + lastUpdateTime = #{lastUpdateTime}, + queryTime = #{queryTime}, + queryUserName = #{queryUserName}, + queryId = #{queryId}, + queryType = #{queryType}, + deliveryNum = #{deliveryNum}, + + where message = #{message} + + + + delete from expressInfo where sid = #{sid} + + + + delete from expressInfo where sid in + + #{sid} + + + + + insert into expressInfo(message, nu, deliveryNum, ischeck, com, status, `data`, `state`, `condition`, routeInfo, returnCode, `result`, phone, + collectTime, singedTime, lastUpdateTime, queryTime, queryUserName, queryId, queryType) values + + ( #{expressInfo.message}, #{expressInfo.nu}, #{expressInfo.deliveryNum}, #{expressInfo.ischeck}, #{expressInfo.com}, #{expressInfo.status}, + #{expressInfo.data}, #{expressInfo.state}, #{expressInfo.condition}, #{expressInfo.routeInfo}, #{expressInfo.returnCode}, + #{expressInfo.result}, #{expressInfo.phone}, #{expressInfo.collectTime}, #{expressInfo.singedTime}, #{expressInfo.lastUpdateTime}, + #{expressInfo.queryTime}, #{expressInfo.queryUserName}, #{expressInfo.queryId}, #{expressInfo.queryType} + ) + + + + + delete from expressInfo where queryId in (select queryId from exp_import_query where sid= #{sid}) + + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/mapper/bps/TopgpDdlMapper.xml b/box-bps/src/main/resources/mapper/bps/TopgpDdlMapper.xml new file mode 100644 index 000000000..553117013 --- /dev/null +++ b/box-bps/src/main/resources/mapper/bps/TopgpDdlMapper.xml @@ -0,0 +1,29 @@ + + + + + + alter table ${originalTableName} rename ${newTableName} + + + + truncate table ${tableName} + + + + drop table ${tableName} + + + + create table ${newTableName} as select * from ${originalTableName} + + + + + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expImportQuery/add.html b/box-bps/src/main/resources/templates/bps/expImportQuery/add.html new file mode 100644 index 000000000..0f1e8b2be --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expImportQuery/add.html @@ -0,0 +1,75 @@ + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expImportQuery/detail.html b/box-bps/src/main/resources/templates/bps/expImportQuery/detail.html new file mode 100644 index 000000000..b88440c8d --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expImportQuery/detail.html @@ -0,0 +1,139 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
+
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expImportQuery/edit.html b/box-bps/src/main/resources/templates/bps/expImportQuery/edit.html new file mode 100644 index 000000000..47f9f625b --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expImportQuery/edit.html @@ -0,0 +1,70 @@ + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expImportQuery/expImportQuery.html b/box-bps/src/main/resources/templates/bps/expImportQuery/expImportQuery.html new file mode 100644 index 000000000..0bfb6fd02 --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expImportQuery/expImportQuery.html @@ -0,0 +1,161 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + +
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expressInfo/add.html b/box-bps/src/main/resources/templates/bps/expressInfo/add.html new file mode 100644 index 000000000..7a2c96f55 --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expressInfo/add.html @@ -0,0 +1,97 @@ + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expressInfo/edit.html b/box-bps/src/main/resources/templates/bps/expressInfo/edit.html new file mode 100644 index 000000000..909109769 --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expressInfo/edit.html @@ -0,0 +1,98 @@ + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expressInfo/expressInfo.html b/box-bps/src/main/resources/templates/bps/expressInfo/expressInfo.html new file mode 100644 index 000000000..58f71f9ec --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expressInfo/expressInfo.html @@ -0,0 +1,209 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + 实时查询 +  重置 +
  • +
+
+
+
+ +
+ + +
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expsubspushresp/add.html b/box-bps/src/main/resources/templates/bps/expsubspushresp/add.html new file mode 100644 index 000000000..111562c1d --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expsubspushresp/add.html @@ -0,0 +1,169 @@ + + + + + + +
+
+
+ +
+
+ + +
+ 代码生成请选择字典属性 +
+
+
+ +
+
+ + +
+ 代码生成请选择字典属性 +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+ 代码生成请选择字典属性 +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expsubspushresp/detail.html b/box-bps/src/main/resources/templates/bps/expsubspushresp/detail.html new file mode 100644 index 000000000..b8bf28f5a --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expsubspushresp/detail.html @@ -0,0 +1,229 @@ + + + + + + +
+
+ +
+ + +
+ +
+
+ + +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expsubspushresp/edit.html b/box-bps/src/main/resources/templates/bps/expsubspushresp/edit.html new file mode 100644 index 000000000..b4a69065b --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expsubspushresp/edit.html @@ -0,0 +1,170 @@ + + + + + + +
+
+ +
+ +
+
+ + +
+ 代码生成请选择字典属性 +
+
+
+ +
+
+ + +
+ 代码生成请选择字典属性 +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+ 代码生成请选择字典属性 +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html b/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html new file mode 100644 index 000000000..0b8c2dc29 --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html @@ -0,0 +1,230 @@ + + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + +
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/subscribe/add.html b/box-bps/src/main/resources/templates/bps/subscribe/add.html new file mode 100644 index 000000000..bf4238ba8 --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/subscribe/add.html @@ -0,0 +1,101 @@ + + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/subscribe/edit.html b/box-bps/src/main/resources/templates/bps/subscribe/edit.html new file mode 100644 index 000000000..035677c9d --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/subscribe/edit.html @@ -0,0 +1,76 @@ + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html b/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html new file mode 100644 index 000000000..6c20e4111 --- /dev/null +++ b/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html @@ -0,0 +1,191 @@ + + + + + + + +
+
+
+
+
+
+
    +
  • + 快递公司: + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • + +
  • +  搜索 +  重置 +
  • + +
+
+
+
+ + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/express/queryExpress.html b/box-bps/src/main/resources/templates/express/queryExpress.html new file mode 100644 index 000000000..2b6bb25ca --- /dev/null +++ b/box-bps/src/main/resources/templates/express/queryExpress.html @@ -0,0 +1,98 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + +
+
+
+
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/box-test/pom.xml b/box-test/pom.xml new file mode 100644 index 000000000..09ee67155 --- /dev/null +++ b/box-test/pom.xml @@ -0,0 +1,49 @@ + + + + ruoyi + com.ruoyi + 4.6.2 + + 4.0.0 + + box-test + + + test系统模块 + + + + + + + com.ruoyi + ruoyi-common + + + + + org.apache.cxf + cxf-spring-boot-starter-jaxws + 3.2.6 + + + org.json + json + 20160810 + compile + + + com.google.code.gson + gson + + + com.ruoyi + ruoyi-system + + + + + \ No newline at end of file diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/ApiController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/ApiController.java new file mode 100644 index 000000000..e3a4c9f77 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/ApiController.java @@ -0,0 +1,61 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.common.core.domain.AjaxResult; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.shiro.authz.annotation.RequiresRoles; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * + * 测试权限登录访问请求 + * + * 登录访问(返回token) POST / http://localhost:80/jwt/login?username=ry&password=admin123 + * + * 测试任意权限(header携带token) GET / http://localhost:80/api/list + * + * 测试菜单权限(header携带token) GET / http://localhost:80/api/user/list + * + * 测试角色权限(header携带token) GET / http://localhost:80/api/role/list + * + */ + + + +@RestController +@RequestMapping("/api") +public class ApiController +{ + /** + * 无权限访问 + * + * @return + */ + @GetMapping("/list") + public AjaxResult list() + { + return AjaxResult.success("list success"); + } + + /** + * 菜单权限 system:user:list + */ + @GetMapping("/user/list") + @RequiresPermissions("system:user:list") + public AjaxResult userlist() + { + return AjaxResult.success("user list success"); + } + + /** + * 角色权限 admin + */ + @GetMapping("/role/list") + @RequiresRoles("admin") + public AjaxResult rolelist() + { + return AjaxResult.success("role list success"); + } +} \ No newline at end of file diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/BoxTestController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/BoxTestController.java new file mode 100644 index 000000000..f282d9344 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/BoxTestController.java @@ -0,0 +1,18 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.test.service.TestService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/test") +public class BoxTestController { + @Autowired + private TestService testService; + @RequestMapping("test") + public String test(){ + testService.test(); + return testService.test(); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/FrForCrController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/FrForCrController.java new file mode 100644 index 000000000..29915a5e8 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/FrForCrController.java @@ -0,0 +1,45 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.test.service.OracleDdlService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.time.LocalTime; +import java.util.Map; + +@RestController +public class FrForCrController { + @Autowired + private OracleDdlService oracleDdlService; + + @CrossOrigin + @RequestMapping("/test/frforcr") + public void frforcr(@RequestBody Map map){ + for(Object value:map.values()){ + String dbName="ds7"; + String tableName=value.toString(); + String tableNameWithDb=dbName+"."+tableName; + int isTableInDb=oracleDdlService.isTableInDb(dbName,tableName); + if(isTableInDb>0){ + try{ + oracleDdlService.dropTable(tableNameWithDb); + System.out.println(LocalTime.now()+"【"+tableNameWithDb+"】已被删除!"); + }catch (Exception e){ + System.out.println(LocalTime.now()+"【"+tableNameWithDb+"】删除异常!"); + } + } + else{ + System.out.println(LocalTime.now()+"【"+tableNameWithDb+"】不存在!"); + } + } + + } + + + +} + + diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/GetEcologyInfoTestController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/GetEcologyInfoTestController.java new file mode 100644 index 000000000..0d52737dc --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/GetEcologyInfoTestController.java @@ -0,0 +1,152 @@ +package com.ruoyi.test.conrtroller; + + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.system.service.ISysDeptService; +import com.ruoyi.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GetEcologyInfoTestController extends BaseController { + @Autowired + private ISysDeptService deptService; + @Autowired + private ISysUserService userService; + + @RequestMapping("/anon/getEcologyDept") + public AjaxResult getEcologyDept() throws Exception { + String url="http://192.168.2.85:90/api/hrm/resful/getHrmdepartmentWithPage"; + String params="{\"params\":{\"pagesize\":999999}}"; + //return sendPost(url,params); + return deptService.syncEcologyDept(url,params); + + + } + + @RequestMapping("/anon/getEcologyUser") + public AjaxResult getEcologyUser(){ + String url="http://192.168.2.85:90/api/hrm/resful/getHrmUserInfoWithPage"; + String params="{\"params\":{\"pagesize\":999999}}"; + return userService.syncEcologyUser(url,params); + } + + /* *//*public Map sendPostWithRest(String url,String params){ + RestTemplate restTemplate=new RestTemplate(); + ResponseEntity result=null; + int statusCode=0; + try{ + result=restTemplate.postForEntity(url,params,String.class); + statusCode=result.getStatusCode().value(); + }catch (RestClientException e){ + System.out.println("POST Request uri: "+url+", params:"+params+" error:"+e.getMessage()); + } + Map map=new HashMap<>(); + map.put("statusCode",String.valueOf(statusCode)); + if(statusCode== 200){ + map.put("result",result.getBody()); + } else{ + map.put("result",String.valueOf(statusCode)); + } + + return map; + }*//* + + public SysDept insertEcologyDept(EcologyDept ecologyDept){ + SysDept dept=new SysDept(); + dept.setDeptId(Long.parseLong(ecologyDept.getId())); + dept.setParentId(Long.parseLong(ecologyDept.getSupdepid()) == 0 ? 999999 : Long.parseLong(ecologyDept.getSupdepid())); + dept.setDeptName(ecologyDept.getDepartmentname()); + //dept.setAncestors(pAncestors); + dept.setOrderNum("0"); + dept.setStatus("0"); + dept.setCreateBy("Admin"); + deptMapper.insertDept(dept); + return dept; + } + + public void updateAncestors(List sysDeptList) + { + if(sysDeptList.isEmpty()) + { + return; + } + List list =new ArrayList<>(); + for(SysDept dept:sysDeptList){ + SysDept info = deptMapper.selectDeptById(dept.getParentId()); + if(StringUtils.isNotEmpty(info.getAncestors())) { + dept.setAncestors(info.getAncestors()+","+dept.getParentId()); + deptMapper.updateDept(dept); + }else{ + list.add(dept); + } + } + updateAncestors(list); + } + + + + public String deptSync(Map mapResult){ + //如果接口返回状态码不为200,则不做同步处理 + String statusCode=mapResult.get("statusCode"); + String result= mapResult.get("result"); + if(!statusCode.equals("200")) + { + return mapResult.get("result"); + } + //取Ecology返回信息中的部门信息 + Map map = (Map) JSON.parse(result); + Map o= (Map) map.get("data"); + JSONArray json = (JSONArray) o.get("dataList"); + List depts = JSONArray.parseArray(json.toJSONString(), EcologyDept.class); + + //清空部门表,并插入顶级部门 + SysDept sysDept=deptMapper.selectDeptById(Long.parseLong("999999")); + deptMapper.truncateDept(); + deptMapper.insertDept(sysDept); + List list=new ArrayList<>(); + //同步Ecology部门信息 + for(EcologyDept ecologyDept:depts){ + if(ecologyDept.getSubcompanyid1().equals("1")) { //只取分部ID为“1”的部门,排除代理商 + *//* String pAncestors=null; + if(ecologyDept.getSupdepid().equals("0")){ //如果Ecology部门为一级部门,则设定ancestors="0,999999" + pAncestors="0,999999"; + }*//* + SysDept dept= insertEcologyDept(ecologyDept); + list.add(dept); + } + } + //更新祖级信息 + updateAncestors(list); + + return result; + } + + *//* public String sendPost(String url,String params) throws Exception { + RestTemplate restTemplate=new RestTemplate(); + ResponseEntity result = null; + int statusCode = 0; + try { + result = restTemplate.postForEntity(url, params, String.class); + statusCode = result.getStatusCode().value(); + } catch (RestClientException e) { + //logger.error("POST Request uri: {}, params: {}, error: {}", url, params, e.getMessage()); + } + if (statusCode == 200) { + + return result.getBody(); + } + if (statusCode >= 300 || statusCode < 200) { + throw new Exception("Response code is " + statusCode); + } + //return ResponseCreator.writeJsonErr(result.getStatusCode().toString()); + + return result.getStatusCode().toString(); + } +*//* + +*/ + +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/GetJsonReqController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/GetJsonReqController.java new file mode 100644 index 000000000..e5ad72c9e --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/GetJsonReqController.java @@ -0,0 +1,67 @@ +package com.ruoyi.test.conrtroller; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.test.domain.Beauty; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.Map; + +@RestController +@RequestMapping("/test") +public class GetJsonReqController { + + @CrossOrigin + @RequestMapping(value = "simple") + // json的结构和内部字段名称可以与POJO/DTO/javabean完全对应 + public Map getJsonBean(@RequestBody Beauty beauty) { + Map result = null; + + if (beauty != null) { + System.out.println("姓名:" + beauty.getName()); + System.out.println("年龄:" + beauty.getAge()); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + System.out.println("出生日期:" + sdf.format(beauty.getDate())); + + System.out.println("年收入:" + beauty.getSalary()); + result = new HashMap<>(); + result.put("code", "1"); + result.put("msg", "ok"); + } + + return result; + } + + @CrossOrigin + @RequestMapping(value = "complex") + //json的结构较为复杂,不直接与POJO/DTO/javabean对应。 + public Map getJsonComplex(@RequestBody JSONObject param) { + Map result = null; + + if (param != null) { + JSONObject master = param.getJSONObject("master"); + Beauty beauty = (Beauty) JSONObject.toJavaObject(master, Beauty.class); + System.out.println(beauty); + + JSONArray mm = param.getJSONArray("MM"); + for (int i = 0; i < mm.size(); i++) { + // 这里不能使用get(i),因为get(i)只会得到键值对。 + JSONObject json = mm.getJSONObject(i); + Beauty bt = (Beauty) JSONObject.toJavaObject(json, Beauty.class); + System.out.println(bt); + } + + result = new HashMap<>(); + result.put("code", "1"); + result.put("msg", "ok"); + } + + return result; + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/OracleDdlController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/OracleDdlController.java new file mode 100644 index 000000000..5f0b67f56 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/OracleDdlController.java @@ -0,0 +1,55 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.test.service.OracleDdlService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/test") +@DataSource(value = DataSourceType.SLAVE) +public class OracleDdlController { + @Autowired + private OracleDdlService oracleDdlService; + + //查询表录数 + @RequestMapping("getRecordCount") + + public String getRecordCount() { + String tableName = "tc_user"; + int result = oracleDdlService.getRecordCount(tableName); + return result + ""; + } + + //检查表是否存在 + @RequestMapping("isTableInDb") + public String isTableInDb() { + String dbName = "ds7"; + String tableName = "tc_user"; + return (oracleDdlService.isTableInDb(dbName, tableName)>0?"实例ds7中存在表tc_user":"实例ds7中不存在表tc_user"); + } + + //复制表 + @RequestMapping("copyTable") + public String copyTable() { + String originalTalble = "tc_user"; + String newTable = "new_tc_user"; + + if (oracleDdlService.isTableInDb("ds7", originalTalble) > 0) { + try { + oracleDdlService.copyTable(newTable, originalTalble); + return "复制" + originalTalble + "成功!新表名:" + newTable; + } catch (Exception e) { + System.out.println(e); + return "复制" + originalTalble + "失败!"; + } + } else { + return "表"+originalTalble+"不存在"; + + } + + } + +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/SendJsonController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/SendJsonController.java new file mode 100644 index 000000000..689d2ce84 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/SendJsonController.java @@ -0,0 +1,15 @@ +package com.ruoyi.test.conrtroller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + + +@Controller +public class SendJsonController { + @RequestMapping("/test/sendjson") + public String ajaxSend(){ + return ("test/sendJson"); + + } + +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/SoapTestController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/SoapTestController.java new file mode 100644 index 000000000..9f5872a3e --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/SoapTestController.java @@ -0,0 +1,171 @@ +package com.ruoyi.test.conrtroller; + +import org.apache.cxf.endpoint.Client; +import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; +import org.json.XML; +import org.springframework.web.bind.annotation.*; +import org.w3c.dom.Document; + +import javax.xml.namespace.QName; +import javax.xml.soap.MessageFactory; +import javax.xml.soap.SOAPBody; +import javax.xml.soap.SOAPBodyElement; +import javax.xml.soap.SOAPMessage; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.ws.BindingProvider; +import javax.xml.ws.Dispatch; +import javax.xml.ws.Service; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.soap.SOAPBinding; +import java.io.ByteArrayOutputStream; +import java.util.HashMap; +import java.util.Map; + + +@RestController +@RequestMapping("/anon/soap") +public class SoapTestController { + + + /** + * https://www.jianshu.com/p/cdbcdd724813 + * 方法一:用cxf框架 + * @param url + * @param method + * @param args + * @return + */ + @CrossOrigin + @RequestMapping("/hello") + @ResponseBody + public Map hello(String url, String method, String[] args) { + if (args.length < 1) { + args = new String[]{""}; + } + + // 创建动态客户端 + JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); + Client client = dcf.createClient(url); + // 需要密码的情况需要加上用户名和密码 + // client.getOutInterceptors().add(new ClientLoginInterceptor(USER_NAME,PASS_WORD)); + // 命名空间,方法名 + QName name = new QName("http://WebXml.com.cn/", method); + HashMap map = new HashMap<>(); + try { + // invoke("方法名",参数1,参数2,参数3....); + Object[] objects = client.invoke(name, args); + map.put("result", objects); + return map; + } catch (java.lang.Exception e) { + e.printStackTrace(); + map.put("result", "接口调用异常"); + return map; + } + } + + /** + * 方法二:自己用jax-ws的方式实现 + * @param url 请求地址 + * @param targetNamespace 名称空间 + * @param pName 端口名 + * @param method 方法名 + * @param argsName 参数名 + * @param args 参数 + * @return + * @throws Exception + */ + @RequestMapping("/getSoap") + @ResponseBody + public Map getSoap(String url, String targetNamespace, String pName, String method, String[] argsName, String[] args) throws Exception { + QName serviceName = new QName(targetNamespace, method); + + //WSDL中定义的端口的QName + QName portName = new QName(targetNamespace, pName); + + //创建动态Service实例 + Service service = Service.create(serviceName); + service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, url); + + //创建一个dispatch实例 + Dispatch dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE); + + // Use Dispatch as BindingProvider + BindingProvider bp = (BindingProvider) dispatch; + + // 配置RequestContext以发送SOAPAction HTTP标头 + Map rc = dispatch.getRequestContext(); + rc.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE); + rc.put(BindingProvider.SOAPACTION_URI_PROPERTY, targetNamespace + method); + + // 获取预配置的SAAJ MessageFactory + MessageFactory factory = ((SOAPBinding) bp.getBinding()).getMessageFactory(); + + // 创建SOAPMessage请求 + SOAPMessage request = null; + request = factory.createMessage(); + // 请求体 + SOAPBody body = request.getSOAPBody(); + + // Compose the soap:Body payload + QName payloadName = new QName(targetNamespace, method); + + SOAPBodyElement payload = body.addBodyElement(payloadName); + if (args.length > 0) { + for (int i = 0; i < argsName.length; i++) { + payload.addChildElement(argsName[i]).setValue(args[i]); + } + } +// payload.addChildElement("startCity").setValue("北京"); +// payload.addChildElement("lastCity").setValue("上海"); +// payload.addChildElement("theDate").setValue("2019-06-07"); +// payload.addChildElement("userID").setValue(""); + +// SOAPElement message = payload.addChildElement(INPUT_NMAE); +// message.addTextNode("88888"); + + SOAPMessage reply = null; + + try { + //调用端点操作并读取响应 + //request.writeTo(System.out); + reply = dispatch.invoke(request); + //reply.writeTo(System.out); + } catch (WebServiceException wse) { + wse.printStackTrace(); + } + + // 处理响应结果 + Document doc = reply.getSOAPPart().getEnvelope().getBody().extractContentAsDocument(); + HashMap map = new HashMap<>(); + map.put("result", XML.toJSONObject(format(doc)).toString()); + //System.out.println(XML.toJSONObject(format(doc)).toString()); + return map; + + } + + // Document对象转字符串 + public static String format(Document doc) throws Exception { + // XML转字符串 + String xmlStr = ""; + try { + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer t = tf.newTransformer(); + t.setOutputProperty("encoding", "UTF-8"); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + t.transform(new DOMSource(doc), new StreamResult(bos)); + xmlStr = bos.toString(); + } catch (TransformerConfigurationException e) { + e.printStackTrace(); + } catch (TransformerException e) { + e.printStackTrace(); + } + return xmlStr; + } + + +} \ No newline at end of file diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/SysCustomerController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/SysCustomerController.java new file mode 100644 index 000000000..9e4b8e568 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/SysCustomerController.java @@ -0,0 +1,123 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.test.domain.SysCustomer; +import com.ruoyi.test.service.ISysCustomerService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 客户Controller + * + * @author box + * @date 2021-02-13 + */ +@Controller +@RequestMapping("/test/customer") +public class SysCustomerController extends BaseController +{ + private String prefix = "test/customer"; + + @Autowired + private ISysCustomerService sysCustomerService; + + @RequiresPermissions("test:customer:view") + @GetMapping() + public String customer() + { + return prefix + "/customer"; + } + + /** + * 查询客户列表 + */ + @RequiresPermissions("test:customer:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysCustomer sysCustomer) + { + startPage(); + List list = sysCustomerService.selectSysCustomerList(sysCustomer); + return getDataTable(list); + } + + /** + * 导出客户列表 + */ + @RequiresPermissions("test:customer:export") + @Log(title = "客户", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysCustomer sysCustomer) + { + List list = sysCustomerService.selectSysCustomerList(sysCustomer); + ExcelUtil util = new ExcelUtil(SysCustomer.class); + return util.exportExcel(list, "customer"); + } + + /** + * 新增客户 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存客户 + */ + @RequiresPermissions("test:customer:add") + @Log(title = "客户", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(SysCustomer sysCustomer) + { + return toAjax(sysCustomerService.insertSysCustomer(sysCustomer)); + } + + /** + * 修改客户 + */ + @GetMapping("/edit/{customerId}") + public String edit(@PathVariable("customerId") Long customerId, ModelMap mmap) + { + SysCustomer sysCustomer = sysCustomerService.selectSysCustomerById(customerId); + mmap.put("sysCustomer", sysCustomer); + return prefix + "/edit"; + } + + /** + * 修改保存客户 + */ + @RequiresPermissions("test:customer:edit") + @Log(title = "客户", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(SysCustomer sysCustomer) + { + return toAjax(sysCustomerService.updateSysCustomer(sysCustomer)); + } + + /** + * 删除客户 + */ + @RequiresPermissions("test:customer:remove") + @Log(title = "客户", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(sysCustomerService.deleteSysCustomerByIds(ids)); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/SysFileInfoController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/SysFileInfoController.java new file mode 100644 index 000000000..e7a610ef5 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/SysFileInfoController.java @@ -0,0 +1,123 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.test.domain.SysFileInfo; +import com.ruoyi.test.service.ISysFileInfoService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 文件信息Controller + * + * @author box + * @date 2021-05-06 + */ +@Controller +@RequestMapping("/test/fileinfo") +public class SysFileInfoController extends BaseController +{ + private String prefix = "test/fileinfo"; + + @Autowired + private ISysFileInfoService sysFileInfoService; + + @RequiresPermissions("test:fileinfo:view") + @GetMapping() + public String fileinfo() + { + return prefix + "/fileinfo"; + } + + /** + * 查询文件信息列表 + */ + @RequiresPermissions("test:fileinfo:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysFileInfo sysFileInfo) + { + startPage(); + List list = sysFileInfoService.selectSysFileInfoList(sysFileInfo); + return getDataTable(list); + } + + /** + * 导出文件信息列表 + */ + @RequiresPermissions("test:fileinfo:export") + @Log(title = "文件信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysFileInfo sysFileInfo) + { + List list = sysFileInfoService.selectSysFileInfoList(sysFileInfo); + ExcelUtil util = new ExcelUtil(SysFileInfo.class); + return util.exportExcel(list, "文件信息数据"); + } + + /** + * 新增文件信息 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存文件信息 + */ + @RequiresPermissions("test:fileinfo:add") + @Log(title = "文件信息", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(SysFileInfo sysFileInfo) + { + return toAjax(sysFileInfoService.insertSysFileInfo(sysFileInfo)); + } + + /** + * 修改文件信息 + */ + @GetMapping("/edit/{fileId}") + public String edit(@PathVariable("fileId") Long fileId, ModelMap mmap) + { + SysFileInfo sysFileInfo = sysFileInfoService.selectSysFileInfoById(fileId); + mmap.put("sysFileInfo", sysFileInfo); + return prefix + "/edit"; + } + + /** + * 修改保存文件信息 + */ + @RequiresPermissions("test:fileinfo:edit") + @Log(title = "文件信息", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(SysFileInfo sysFileInfo) + { + return toAjax(sysFileInfoService.updateSysFileInfo(sysFileInfo)); + } + + /** + * 删除文件信息 + */ + @RequiresPermissions("test:fileinfo:remove") + @Log(title = "文件信息", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(sysFileInfoService.deleteSysFileInfoByIds(ids)); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/TcUserController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/TcUserController.java new file mode 100644 index 000000000..55953e6fc --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/TcUserController.java @@ -0,0 +1,64 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.test.domain.TcUser; +import com.ruoyi.test.service.TcUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/test") +public class TcUserController { + @Autowired + private TcUserService tcUserService; + + //查询所有 + // http://localhost/test/selectall + @RequestMapping("selectAll") + @ResponseBody + public String selectAll(){ + List users=tcUserService.selectAll(); + users.forEach(System.out::println); + return users.toString()+""; + } + + + //查询 by id + // http://localhost/test/selectById/1(此处1为要获取的id) + @RequestMapping(value = "selectById/{id}", method = RequestMethod.GET) + public String selectById(@PathVariable int id) { + return tcUserService.selectById(id).toString(); + } + + //插入新用户 + // http://localhost/test/insert?id=100&name=张三&password=20 + @RequestMapping(value = "/insert", method = RequestMethod.GET) + public TcUser insert(TcUser tcUser) { + return tcUserService.insert(tcUser); + } + + //通过用户id删除用户 + // http://localhost/test/deleteById?id=1(此处1为要删除的id) + @RequestMapping(value = "/deleteById", method = RequestMethod.GET) + public String delete(int id) { + int result = tcUserService.deleteById(id); + if (result >= 1) { + return "删除成功"; + } else { + return "删除失败"; + } + } + + //更新 by id + // http://localhost/test/updateById?id=2&name=波波&password=12 + @RequestMapping(value = "/updateById", method = RequestMethod.GET) + public String update(TcUser tcUser) { + int result = tcUserService.updateById(tcUser); + if (result >= 1) { + return "修改成功"; + } else { + return "修改失败"; + } + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/TestIndexController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/TestIndexController.java new file mode 100644 index 000000000..4900631cc --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/TestIndexController.java @@ -0,0 +1,16 @@ +package com.ruoyi.test.conrtroller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.time.LocalDateTime; + +@Controller +public class TestIndexController { + @RequestMapping("/test") + public String index(ModelMap modelMap){ + modelMap.put("date", LocalDateTime.now()); + return ("test/index"); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/TestVerifyController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/TestVerifyController.java new file mode 100644 index 000000000..f2d3c63f1 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/TestVerifyController.java @@ -0,0 +1,34 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.test.service.TestVerifyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class TestVerifyController { + @Autowired + private TestVerifyService testVerifyService; + + @RequestMapping("/test/testVerify") + public String testVerify(){ + return "/test/testVerify"; + } + + + + + /** + * 校验用户名 + */ + + @PostMapping("/test/testVerifyName") + @ResponseBody + public int testVerifyName(String name) + { + return testVerifyService.isNameUnique(name); + } + +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/WechatApiController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/WechatApiController.java new file mode 100644 index 000000000..ef71ebbee --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/WechatApiController.java @@ -0,0 +1,85 @@ +package com.ruoyi.test.conrtroller; + +import com.alibaba.fastjson.JSON; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.system.service.IWechatApiService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Controller +public class WechatApiController extends BaseController { + @Autowired + IWechatApiService wechatApiService; + + @RequestMapping("anon/getAccessToken") + @ResponseBody + public String getAccessToken() { + return wechatApiService.GetAccessToken(); + } + + @GetMapping("anon/userInfo") + @ResponseBody + public Object getJSON(HttpServletRequest request, HttpServletResponse response) throws IOException { + + BufferedReader streamReader = new BufferedReader( new InputStreamReader(request.getInputStream(), "UTF-8")); + StringBuilder responseStrBuilder = new StringBuilder(); + String inputStr; + while ((inputStr = streamReader.readLine()) != null) { + responseStrBuilder.append(inputStr); + } + //return JSON.parseObject(responseStrBuilder.toString(), Map.class); + return JSON.parse(responseStrBuilder.toString()); + + } + + + @GetMapping("anon/SendTextMessageToWechatUser") + @ResponseBody + public Map SendTextMessageToWechatUser() { + List userIdList = new ArrayList<>(); + userIdList.add("2342343243");//错误userId示例 + userIdList.add("erqrqwe");//错误userId示例 + userIdList.add(""); //空UserId示例 + userIdList.add("359"); + if(! String.valueOf(ShiroUtils.getUserId()).equals("359")){ + userIdList.add(String.valueOf(ShiroUtils.getUserId())); + } + Map resultMap = wechatApiService.SendTextMessageToWechatUser(userIdList,"哈哈哈!"); + return resultMap; + } + + @GetMapping("anon/SendTextCardMessageToWechatUser") + @ResponseBody + public Map SendTextCardMessageToWechatUser() { + List userIdList = new ArrayList<>(); + userIdList.add("23456667"); //错误userId示例 + userIdList.add("355354354"); //错误userId示例 + userIdList.add(""); //空UserId示例 + userIdList.add("359"); + //userIdList.add("454"); + //userIdList.add("408"); + if(!String.valueOf(ShiroUtils.getUserId()).equals("359")){ + userIdList.add(String.valueOf(ShiroUtils.getUserId())); + } + String title="号外:特大优惠!限时抢购"; + String description="今年仅此一次,苹果手机1000元起!欢迎前来购买!走过路过,不要错过!"; + String dtailUrl="https://item.jd.com/100008348530.html"; + + Map resultMap = wechatApiService.SendTextCardMessageToWechatUser(userIdList,title,description,dtailUrl); + return resultMap; + } + +} diff --git a/box-test/src/main/java/com/ruoyi/test/domain/Beauty.java b/box-test/src/main/java/com/ruoyi/test/domain/Beauty.java new file mode 100644 index 000000000..41c2ec760 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/domain/Beauty.java @@ -0,0 +1,55 @@ +package com.ruoyi.test.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +public class Beauty { + private String name; + private int age; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date date; + private double salary; + + public Beauty() { + + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } + + @Override + public String toString() { + return "Beauty [name=" + name + ", age=" + age + ", date=" + date + ", salary=" + salary + "]"; + } + +} diff --git a/box-test/src/main/java/com/ruoyi/test/domain/SysCustomer.java b/box-test/src/main/java/com/ruoyi/test/domain/SysCustomer.java new file mode 100644 index 000000000..0f34bbe05 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/domain/SysCustomer.java @@ -0,0 +1,113 @@ +package com.ruoyi.test.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; +import java.util.List; + +/** + * 客户对象 sys_customer + * + * @author box + * @date 2021-02-13 + */ +public class SysCustomer extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 客户id */ + private Long customerId; + + /** 客户姓名 */ + @Excel(name = "客户姓名") + private String customerName; + + /** 手机号码 */ + @Excel(name = "手机号码") + private String phonenumber; + + /** 客户性别 */ + @Excel(name = "客户性别") + private String sex; + + /** 客户生日 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "客户生日", width = 30, dateFormat = "yyyy-MM-dd") + private Date birthday; + + /** 商品信息 */ + private List sysGoodsList; + + public void setCustomerId(Long customerId) + { + this.customerId = customerId; + } + + public Long getCustomerId() + { + return customerId; + } + public void setCustomerName(String customerName) + { + this.customerName = customerName; + } + + public String getCustomerName() + { + return customerName; + } + public void setPhonenumber(String phonenumber) + { + this.phonenumber = phonenumber; + } + + public String getPhonenumber() + { + return phonenumber; + } + public void setSex(String sex) + { + this.sex = sex; + } + + public String getSex() + { + return sex; + } + public void setBirthday(Date birthday) + { + this.birthday = birthday; + } + + public Date getBirthday() + { + return birthday; + } + + public List getSysGoodsList() + { + return sysGoodsList; + } + + public void setSysGoodsList(List sysGoodsList) + { + this.sysGoodsList = sysGoodsList; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("customerId", getCustomerId()) + .append("customerName", getCustomerName()) + .append("phonenumber", getPhonenumber()) + .append("sex", getSex()) + .append("birthday", getBirthday()) + .append("remark", getRemark()) + .append("sysGoodsList", getSysGoodsList()) + .toString(); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/domain/SysFileInfo.java b/box-test/src/main/java/com/ruoyi/test/domain/SysFileInfo.java new file mode 100644 index 000000000..003c5f57a --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/domain/SysFileInfo.java @@ -0,0 +1,65 @@ +package com.ruoyi.test.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 文件信息对象 sys_file_info + * + * @author box + * @date 2021-05-06 + */ +public class SysFileInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 文件id */ + private Long fileId; + + /** 文件名称 */ + @Excel(name = "文件名称") + private String fileName; + + /** 文件路径 */ + @Excel(name = "文件路径") + private String filePath; + + public void setFileId(Long fileId) + { + this.fileId = fileId; + } + + public Long getFileId() + { + return fileId; + } + public void setFileName(String fileName) + { + this.fileName = fileName; + } + + public String getFileName() + { + return fileName; + } + public void setFilePath(String filePath) + { + this.filePath = filePath; + } + + public String getFilePath() + { + return filePath; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("fileId", getFileId()) + .append("fileName", getFileName()) + .append("filePath", getFilePath()) + .toString(); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/domain/SysGoods.java b/box-test/src/main/java/com/ruoyi/test/domain/SysGoods.java new file mode 100644 index 000000000..85740959a --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/domain/SysGoods.java @@ -0,0 +1,124 @@ +package com.ruoyi.test.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 商品对象 sys_goods + * + * @author box + * @date 2021-02-13 + */ +public class SysGoods extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 商品id */ + private Long goodsId; + + /** 客户id */ + @Excel(name = "客户id") + private Long customerId; + + /** 商品名称 */ + @Excel(name = "商品名称") + private String name; + + /** 商品重量 */ + @Excel(name = "商品重量") + private Integer weight; + + /** 商品价格 */ + @Excel(name = "商品价格") + private BigDecimal price; + + /** 商品时间 */ + @Excel(name = "商品时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date date; + + /** 商品种类 */ + @Excel(name = "商品种类") + private String type; + + public void setGoodsId(Long goodsId) + { + this.goodsId = goodsId; + } + + public Long getGoodsId() + { + return goodsId; + } + public void setCustomerId(Long customerId) + { + this.customerId = customerId; + } + + public Long getCustomerId() + { + return customerId; + } + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + public void setWeight(Integer weight) + { + this.weight = weight; + } + + public Integer getWeight() + { + return weight; + } + public void setPrice(BigDecimal price) + { + this.price = price; + } + + public BigDecimal getPrice() + { + return price; + } + public void setDate(Date date) + { + this.date = date; + } + + public Date getDate() + { + return date; + } + public void setType(String type) + { + this.type = type; + } + + public String getType() + { + return type; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("goodsId", getGoodsId()) + .append("customerId", getCustomerId()) + .append("name", getName()) + .append("weight", getWeight()) + .append("price", getPrice()) + .append("date", getDate()) + .append("type", getType()) + .toString(); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/domain/TcUser.java b/box-test/src/main/java/com/ruoyi/test/domain/TcUser.java new file mode 100644 index 000000000..da8a2d3cc --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/domain/TcUser.java @@ -0,0 +1,40 @@ +package com.ruoyi.test.domain; + +public class TcUser { + private int id; + private String name; + private String password; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public String toString() { + return "TcUser{" + + "id=" + id + + ", name='" + name + '\'' + + ", age='" + password + '\'' + + '}'; + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/mapper/OracleDdlMapper.java b/box-test/src/main/java/com/ruoyi/test/mapper/OracleDdlMapper.java new file mode 100644 index 000000000..e7c2f3a16 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/mapper/OracleDdlMapper.java @@ -0,0 +1,32 @@ +package com.ruoyi.test.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Component; + +@Mapper +@Component("OracleDdlMapper") +public interface OracleDdlMapper { + // alter table + int alterTableName(@Param("originalTableName") String originalTableName, + @Param("newTableName") String newTableName); + + //truncate table + int truncateTable(@Param("tableName") String tableName); + + //drop table + int dropTable(@Param("tableName") String tableName); + + //copy table + void copyTable(@Param("newTableName") String newTableName, + @Param("originalTableName") String originalTableName); + + //获取表记录数 + int getRecordCount(@Param("tableName") String tableName); + + + + //查询数据库中表是否存在 + int isTableInDb(@Param("dataBaseName") String dataBaseName, + @Param("tableName") String tableName); +} diff --git a/box-test/src/main/java/com/ruoyi/test/mapper/SysCustomerMapper.java b/box-test/src/main/java/com/ruoyi/test/mapper/SysCustomerMapper.java new file mode 100644 index 000000000..3ae177354 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/mapper/SysCustomerMapper.java @@ -0,0 +1,88 @@ +package com.ruoyi.test.mapper; + +import com.ruoyi.test.domain.SysCustomer; +import com.ruoyi.test.domain.SysGoods; + +import java.util.List; + +/** + * 客户Mapper接口 + * + * @author box + * @date 2021-02-13 + */ +public interface SysCustomerMapper +{ + /** + * 查询客户 + * + * @param customerId 客户ID + * @return 客户 + */ + public SysCustomer selectSysCustomerById(Long customerId); + + /** + * 查询客户列表 + * + * @param sysCustomer 客户 + * @return 客户集合 + */ + public List selectSysCustomerList(SysCustomer sysCustomer); + + /** + * 新增客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + public int insertSysCustomer(SysCustomer sysCustomer); + + /** + * 修改客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + public int updateSysCustomer(SysCustomer sysCustomer); + + /** + * 删除客户 + * + * @param customerId 客户ID + * @return 结果 + */ + public int deleteSysCustomerById(Long customerId); + + /** + * 批量删除客户 + * + * @param customerIds 需要删除的数据ID + * @return 结果 + */ + public int deleteSysCustomerByIds(String[] customerIds); + + /** + * 批量删除商品 + * + * @param customerIds 需要删除的数据ID + * @return 结果 + */ + public int deleteSysGoodsByCustomerIds(String[] customerIds); + + /** + * 批量新增商品 + * + * @param sysGoodsList 商品列表 + * @return 结果 + */ + public int batchSysGoods(List sysGoodsList); + + + /** + * 通过客户ID删除商品信息 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteSysGoodsByCustomerId(Long customerId); +} diff --git a/box-test/src/main/java/com/ruoyi/test/mapper/SysFileInfoMapper.java b/box-test/src/main/java/com/ruoyi/test/mapper/SysFileInfoMapper.java new file mode 100644 index 000000000..923f598cf --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/mapper/SysFileInfoMapper.java @@ -0,0 +1,62 @@ +package com.ruoyi.test.mapper; + +import com.ruoyi.test.domain.SysFileInfo; + +import java.util.List; + +/** + * 文件信息Mapper接口 + * + * @author box + * @date 2021-05-06 + */ +public interface SysFileInfoMapper +{ + /** + * 查询文件信息 + * + * @param fileId 文件信息ID + * @return 文件信息 + */ + public SysFileInfo selectSysFileInfoById(Long fileId); + + /** + * 查询文件信息列表 + * + * @param sysFileInfo 文件信息 + * @return 文件信息集合 + */ + public List selectSysFileInfoList(SysFileInfo sysFileInfo); + + /** + * 新增文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + public int insertSysFileInfo(SysFileInfo sysFileInfo); + + /** + * 修改文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + public int updateSysFileInfo(SysFileInfo sysFileInfo); + + /** + * 删除文件信息 + * + * @param fileId 文件信息ID + * @return 结果 + */ + public int deleteSysFileInfoById(Long fileId); + + /** + * 批量删除文件信息 + * + * @param fileIds 需要删除的数据ID + * @return 结果 + */ + public int deleteSysFileInfoByIds(String[] fileIds); +} diff --git a/box-test/src/main/java/com/ruoyi/test/mapper/TcUserMapper.java b/box-test/src/main/java/com/ruoyi/test/mapper/TcUserMapper.java new file mode 100644 index 000000000..39f541866 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/mapper/TcUserMapper.java @@ -0,0 +1,26 @@ +package com.ruoyi.test.mapper; + +import com.ruoyi.test.domain.TcUser; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Mapper +@Component("TCUserMapper") +public interface TcUserMapper { + //查询所有 + List selectAll(); + + //查询 by id + TcUser selectById(int id); + + //增加 + int insert(TcUser tcUser); + + //删除 by id + int deleteById(int id); + + //更新 by id + int updateById(TcUser tcUser); +} diff --git a/box-test/src/main/java/com/ruoyi/test/mapper/TestVerifyMapper.java b/box-test/src/main/java/com/ruoyi/test/mapper/TestVerifyMapper.java new file mode 100644 index 000000000..36327dd82 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/mapper/TestVerifyMapper.java @@ -0,0 +1,11 @@ +package com.ruoyi.test.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Component; + +@Mapper +@Component("TestVerifyMapper") +public interface TestVerifyMapper { + //检查姓名是否唯一 + int isNameUnique(String name); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/ISysCustomerService.java b/box-test/src/main/java/com/ruoyi/test/service/ISysCustomerService.java new file mode 100644 index 000000000..4a3aafa4d --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/ISysCustomerService.java @@ -0,0 +1,62 @@ +package com.ruoyi.test.service; + +import com.ruoyi.test.domain.SysCustomer; + +import java.util.List; + +/** + * 客户Service接口 + * + * @author box + * @date 2021-02-13 + */ +public interface ISysCustomerService +{ + /** + * 查询客户 + * + * @param customerId 客户ID + * @return 客户 + */ + public SysCustomer selectSysCustomerById(Long customerId); + + /** + * 查询客户列表 + * + * @param sysCustomer 客户 + * @return 客户集合 + */ + public List selectSysCustomerList(SysCustomer sysCustomer); + + /** + * 新增客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + public int insertSysCustomer(SysCustomer sysCustomer); + + /** + * 修改客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + public int updateSysCustomer(SysCustomer sysCustomer); + + /** + * 批量删除客户 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteSysCustomerByIds(String ids); + + /** + * 删除客户信息 + * + * @param customerId 客户ID + * @return 结果 + */ + public int deleteSysCustomerById(Long customerId); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/ISysFileInfoService.java b/box-test/src/main/java/com/ruoyi/test/service/ISysFileInfoService.java new file mode 100644 index 000000000..7df14d3ac --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/ISysFileInfoService.java @@ -0,0 +1,62 @@ +package com.ruoyi.test.service; + +import com.ruoyi.test.domain.SysFileInfo; + +import java.util.List; + +/** + * 文件信息Service接口 + * + * @author box + * @date 2021-05-06 + */ +public interface ISysFileInfoService +{ + /** + * 查询文件信息 + * + * @param fileId 文件信息ID + * @return 文件信息 + */ + public SysFileInfo selectSysFileInfoById(Long fileId); + + /** + * 查询文件信息列表 + * + * @param sysFileInfo 文件信息 + * @return 文件信息集合 + */ + public List selectSysFileInfoList(SysFileInfo sysFileInfo); + + /** + * 新增文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + public int insertSysFileInfo(SysFileInfo sysFileInfo); + + /** + * 修改文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + public int updateSysFileInfo(SysFileInfo sysFileInfo); + + /** + * 批量删除文件信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteSysFileInfoByIds(String ids); + + /** + * 删除文件信息信息 + * + * @param fileId 文件信息ID + * @return 结果 + */ + public int deleteSysFileInfoById(Long fileId); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/OracleDdlService.java b/box-test/src/main/java/com/ruoyi/test/service/OracleDdlService.java new file mode 100644 index 000000000..e6b5b6200 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/OracleDdlService.java @@ -0,0 +1,22 @@ +package com.ruoyi.test.service; + +public interface OracleDdlService { + //修改表名 + int alterTableName(String originalTableName, String newTableName); + + // truncate指定数据库表的数据 + int truncateTable(String tableName); + + //drop 指定定数据库表 + int dropTable(String tableName); + + + //根据传入的表明,创建新的表并且将原表的数据插入到新的Occur表中 + void copyTable(String newTableName,String originalTableName); + + //统计某张表中的总数据条数 + int getRecordCount(String tableName); + + //从指定数据库中,查询是否存在某张表 + int isTableInDb(String dataBaseName, String tableName); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/TcUserService.java b/box-test/src/main/java/com/ruoyi/test/service/TcUserService.java new file mode 100644 index 000000000..2f32e20cd --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/TcUserService.java @@ -0,0 +1,22 @@ +package com.ruoyi.test.service; + +import com.ruoyi.test.domain.TcUser; + +import java.util.List; + +public interface TcUserService { + //查询所有用户 + List selectAll(); + + //根据id查询用户信息 + TcUser selectById(int id); + + //新增用户 + TcUser insert (TcUser tcUser); + + // 根据id删除 + int deleteById (int id); + + //更新用户信息 + int updateById(TcUser tcUser); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/TestService.java b/box-test/src/main/java/com/ruoyi/test/service/TestService.java new file mode 100644 index 000000000..8b6b40b97 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/TestService.java @@ -0,0 +1,10 @@ +package com.ruoyi.test.service; + +import org.springframework.stereotype.Service; + +@Service +public class TestService { + public String test(){ + return "hello,box-test.test"; + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/TestVerifyService.java b/box-test/src/main/java/com/ruoyi/test/service/TestVerifyService.java new file mode 100644 index 000000000..6f6e9b0b4 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/TestVerifyService.java @@ -0,0 +1,9 @@ +package com.ruoyi.test.service; + +import org.springframework.stereotype.Service; + +@Service +public interface TestVerifyService { + //检查姓名是否唯一 + int isNameUnique(String name); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/impl/OracleDdlServiceImpl.java b/box-test/src/main/java/com/ruoyi/test/service/impl/OracleDdlServiceImpl.java new file mode 100644 index 000000000..1ebf0b930 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/impl/OracleDdlServiceImpl.java @@ -0,0 +1,45 @@ +package com.ruoyi.test.service.impl; + +import com.ruoyi.test.mapper.OracleDdlMapper; +import com.ruoyi.test.service.OracleDdlService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +//@DataSource(value = DataSourceType.SLAVE) +public class OracleDdlServiceImpl implements OracleDdlService { + @Autowired + private OracleDdlMapper oracleDdlMapper; + + //修改表名 + public int alterTableName(String originalTableName, String newTableName) + { + return oracleDdlMapper.alterTableName(originalTableName,newTableName); + } + + // truncate指定数据库表的数据 + public int truncateTable(String tableName){ + return oracleDdlMapper.truncateTable(tableName); + } + + //drop 指定定数据库表 + public int dropTable(String tableName){ + return oracleDdlMapper.dropTable(tableName); + } + + + //根据传入的表明,创建新的表并且将原表的数据插入到新的Occur表中 + public void copyTable(String newTableName,String originalTableName){ + return ; + } + + //统计某张表中的总数据条数 + public int getRecordCount(String tableName){ + return oracleDdlMapper.getRecordCount(tableName); + } + + //从指定数据库中,查询是否存在某张表 + public int isTableInDb(String dataBaseName, String tableName){ + return oracleDdlMapper.isTableInDb(dataBaseName,tableName); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/impl/SysCustomerServiceImpl.java b/box-test/src/main/java/com/ruoyi/test/service/impl/SysCustomerServiceImpl.java new file mode 100644 index 000000000..a7d13ef6b --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/impl/SysCustomerServiceImpl.java @@ -0,0 +1,132 @@ +package com.ruoyi.test.service.impl; + +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.test.domain.SysCustomer; +import com.ruoyi.test.domain.SysGoods; +import com.ruoyi.test.mapper.SysCustomerMapper; +import com.ruoyi.test.service.ISysCustomerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; + +/** + * 客户Service业务层处理 + * + * @author box + * @date 2021-02-13 + */ +@Service +public class SysCustomerServiceImpl implements ISysCustomerService +{ + @Autowired + private SysCustomerMapper sysCustomerMapper; + + /** + * 查询客户 + * + * @param customerId 客户ID + * @return 客户 + */ + @Override + public SysCustomer selectSysCustomerById(Long customerId) + { + return sysCustomerMapper.selectSysCustomerById(customerId); + } + + /** + * 查询客户列表 + * + * @param sysCustomer 客户 + * @return 客户 + */ + @Override + public List selectSysCustomerList(SysCustomer sysCustomer) + { + return sysCustomerMapper.selectSysCustomerList(sysCustomer); + } + + /** + * 新增客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + @Transactional + @Override + public int insertSysCustomer(SysCustomer sysCustomer) + { + int rows = sysCustomerMapper.insertSysCustomer(sysCustomer); + insertSysGoods(sysCustomer); + return rows; + } + + /** + * 修改客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + @Transactional + @Override + public int updateSysCustomer(SysCustomer sysCustomer) + { + sysCustomerMapper.deleteSysGoodsByCustomerId(sysCustomer.getCustomerId()); + insertSysGoods(sysCustomer); + return sysCustomerMapper.updateSysCustomer(sysCustomer); + } + + /** + * 删除客户对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Transactional + @Override + public int deleteSysCustomerByIds(String ids) + { + sysCustomerMapper.deleteSysGoodsByCustomerIds(Convert.toStrArray(ids)); + return sysCustomerMapper.deleteSysCustomerByIds(Convert.toStrArray(ids)); + } + + /** + * 删除客户信息 + * + * @param customerId 客户ID + * @return 结果 + */ + @Override + public int deleteSysCustomerById(Long customerId) + { + sysCustomerMapper.deleteSysGoodsByCustomerId(customerId); + return sysCustomerMapper.deleteSysCustomerById(customerId); + } + + /** + * 新增商品信息 + * + * @param sysCustomer 客户对象 + */ + public void insertSysGoods(SysCustomer sysCustomer) + { + List sysGoodsList = sysCustomer.getSysGoodsList(); + Long customerId = sysCustomer.getCustomerId(); + if (StringUtils.isNotNull(sysGoodsList)) + { + List list = new ArrayList(); + for (SysGoods sysGoods : sysGoodsList) + { + sysGoods.setCustomerId(customerId); + list.add(sysGoods); + } + if (list.size() > 0) + { + sysCustomerMapper.batchSysGoods(list); + } + } + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/impl/SysFileInfoServiceImpl.java b/box-test/src/main/java/com/ruoyi/test/service/impl/SysFileInfoServiceImpl.java new file mode 100644 index 000000000..a7407bbce --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/impl/SysFileInfoServiceImpl.java @@ -0,0 +1,95 @@ +package com.ruoyi.test.service.impl; + +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.test.domain.SysFileInfo; +import com.ruoyi.test.mapper.SysFileInfoMapper; +import com.ruoyi.test.service.ISysFileInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 文件信息Service业务层处理 + * + * @author box + * @date 2021-05-06 + */ +@Service +public class SysFileInfoServiceImpl implements ISysFileInfoService +{ + @Autowired + private SysFileInfoMapper sysFileInfoMapper; + + /** + * 查询文件信息 + * + * @param fileId 文件信息ID + * @return 文件信息 + */ + @Override + public SysFileInfo selectSysFileInfoById(Long fileId) + { + return sysFileInfoMapper.selectSysFileInfoById(fileId); + } + + /** + * 查询文件信息列表 + * + * @param sysFileInfo 文件信息 + * @return 文件信息 + */ + @Override + public List selectSysFileInfoList(SysFileInfo sysFileInfo) + { + return sysFileInfoMapper.selectSysFileInfoList(sysFileInfo); + } + + /** + * 新增文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + @Override + public int insertSysFileInfo(SysFileInfo sysFileInfo) + { + return sysFileInfoMapper.insertSysFileInfo(sysFileInfo); + } + + /** + * 修改文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + @Override + public int updateSysFileInfo(SysFileInfo sysFileInfo) + { + return sysFileInfoMapper.updateSysFileInfo(sysFileInfo); + } + + /** + * 删除文件信息对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteSysFileInfoByIds(String ids) + { + return sysFileInfoMapper.deleteSysFileInfoByIds(Convert.toStrArray(ids)); + } + + /** + * 删除文件信息信息 + * + * @param fileId 文件信息ID + * @return 结果 + */ + @Override + public int deleteSysFileInfoById(Long fileId) + { + return sysFileInfoMapper.deleteSysFileInfoById(fileId); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/impl/TcUserServiceImpl.java b/box-test/src/main/java/com/ruoyi/test/service/impl/TcUserServiceImpl.java new file mode 100644 index 000000000..ca691ce98 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/impl/TcUserServiceImpl.java @@ -0,0 +1,48 @@ +package com.ruoyi.test.service.impl; + +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.test.domain.TcUser; +import com.ruoyi.test.mapper.TcUserMapper; +import com.ruoyi.test.service.TcUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@DataSource(value = DataSourceType.SQLSVR) +public class TcUserServiceImpl implements TcUserService { + @Autowired + private TcUserMapper tcUserMapper; + + //查询所有用户 + @Override + public List selectAll() { + return tcUserMapper.selectAll(); + } + + //查询 by id + @Override + public TcUser selectById(int id) { + return tcUserMapper.selectById(id); + } + + //新增 + @Override + public TcUser insert(TcUser tcUser) { + int user=tcUserMapper.insert(tcUser); + return tcUser; + } + + //删除by id + @Override + public int deleteById(int id) { + return tcUserMapper.deleteById(id); + } + //更新 by id + @Override + public int updateById(TcUser tcUser) { + return tcUserMapper.updateById(tcUser); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/impl/TestVerifyServiceImpl.java b/box-test/src/main/java/com/ruoyi/test/service/impl/TestVerifyServiceImpl.java new file mode 100644 index 000000000..0293b1c6d --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/impl/TestVerifyServiceImpl.java @@ -0,0 +1,19 @@ +package com.ruoyi.test.service.impl; + +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.test.mapper.TestVerifyMapper; +import com.ruoyi.test.service.TestVerifyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +@DataSource(value = DataSourceType.SQLSVR) +public class TestVerifyServiceImpl implements TestVerifyService { + @Autowired + private TestVerifyMapper testVerifyMapper; + @Override + public int isNameUnique(String name) { + return testVerifyMapper.isNameUnique(name); + } +} diff --git a/box-test/src/main/resources/mapper/test/OracleDdlMapper.xml b/box-test/src/main/resources/mapper/test/OracleDdlMapper.xml new file mode 100644 index 000000000..08cb35d57 --- /dev/null +++ b/box-test/src/main/resources/mapper/test/OracleDdlMapper.xml @@ -0,0 +1,29 @@ + + + + + + alter table ${originalTableName} rename ${newTableName} + + + + truncate table ${tableName} + + + + drop table ${tableName} + + + + create table ${newTableName} as select * from ${originalTableName} + + + + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/mapper/test/SysCustomerMapper.xml b/box-test/src/main/resources/mapper/test/SysCustomerMapper.xml new file mode 100644 index 000000000..d4e97c0b1 --- /dev/null +++ b/box-test/src/main/resources/mapper/test/SysCustomerMapper.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select customer_id, customer_name, phonenumber, sex, birthday, remark from sys_customer + + + + + + + + insert into sys_customer + + customer_name, + phonenumber, + sex, + birthday, + remark, + + + #{customerName}, + #{phonenumber}, + #{sex}, + #{birthday}, + #{remark}, + + + + + update sys_customer + + customer_name = #{customerName}, + phonenumber = #{phonenumber}, + sex = #{sex}, + birthday = #{birthday}, + remark = #{remark}, + + where customer_id = #{customerId} + + + + delete from sys_customer where customer_id = #{customerId} + + + + delete from sys_customer where customer_id in + + #{customerId} + + + + + delete from sys_goods where customer_id in + + #{customerId} + + + + + delete from sys_goods where customer_id = #{customerId} + + + + insert into sys_goods( goods_id, customer_id, name, weight, price, date, type) values + + ( #{item.goodsId}, #{item.customerId}, #{item.name}, #{item.weight}, #{item.price}, #{item.date}, #{item.type}) + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/mapper/test/SysFileInfoMapper.xml b/box-test/src/main/resources/mapper/test/SysFileInfoMapper.xml new file mode 100644 index 000000000..1fa4beeac --- /dev/null +++ b/box-test/src/main/resources/mapper/test/SysFileInfoMapper.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + select file_id, file_name, file_path from sys_file_info + + + + + + + + insert into sys_file_info + + file_name, + file_path, + + + #{fileName}, + #{filePath}, + + + + + update sys_file_info + + file_name = #{fileName}, + file_path = #{filePath}, + + where file_id = #{fileId} + + + + delete from sys_file_info where file_id = #{fileId} + + + + delete from sys_file_info where file_id in + + #{fileId} + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/mapper/test/TcUserMapper.xml b/box-test/src/main/resources/mapper/test/TcUserMapper.xml new file mode 100644 index 000000000..ee5f415f7 --- /dev/null +++ b/box-test/src/main/resources/mapper/test/TcUserMapper.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + insert into tc_user + + + id, + + + name, + + + password, + + + + + #{id,jdbcType=INTEGER}, + + + #{name,jdbcType=VARCHAR}, + + + #{password,jdbcType=VARCHAR}, + + + + + + + delete from tc_user where id=#{id} + + + + + update tc_user + + + name = #{name,jdbcType=VARCHAR}, + + + password = #{password,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/mapper/test/TestVerifyMapper.xml b/box-test/src/main/resources/mapper/test/TestVerifyMapper.xml new file mode 100644 index 000000000..9995edb00 --- /dev/null +++ b/box-test/src/main/resources/mapper/test/TestVerifyMapper.xml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/customer/add.html b/box-test/src/main/resources/templates/test/customer/add.html new file mode 100644 index 000000000..c22d83716 --- /dev/null +++ b/box-test/src/main/resources/templates/test/customer/add.html @@ -0,0 +1,167 @@ + + + + + + + +
+
+

客户信息

+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 代码生成请选择字典属性 +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+

商品信息

+
+
+ + +
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/customer/customer.html b/box-test/src/main/resources/templates/test/customer/customer.html new file mode 100644 index 000000000..484e01d18 --- /dev/null +++ b/box-test/src/main/resources/templates/test/customer/customer.html @@ -0,0 +1,117 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/customer/edit.html b/box-test/src/main/resources/templates/test/customer/edit.html new file mode 100644 index 000000000..41c5e9093 --- /dev/null +++ b/box-test/src/main/resources/templates/test/customer/edit.html @@ -0,0 +1,186 @@ + + + + + + + + +
+
+

客户信息

+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 代码生成请选择字典属性 +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+

商品信息

+
+
+ + +
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/fileinfo/add.html b/box-test/src/main/resources/templates/test/fileinfo/add.html new file mode 100644 index 000000000..a3a91273a --- /dev/null +++ b/box-test/src/main/resources/templates/test/fileinfo/add.html @@ -0,0 +1,37 @@ + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/fileinfo/edit.html b/box-test/src/main/resources/templates/test/fileinfo/edit.html new file mode 100644 index 000000000..3d7f13c34 --- /dev/null +++ b/box-test/src/main/resources/templates/test/fileinfo/edit.html @@ -0,0 +1,38 @@ + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/fileinfo/fileinfo.html b/box-test/src/main/resources/templates/test/fileinfo/fileinfo.html new file mode 100644 index 000000000..a4b81a52c --- /dev/null +++ b/box-test/src/main/resources/templates/test/fileinfo/fileinfo.html @@ -0,0 +1,94 @@ + + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/index.html b/box-test/src/main/resources/templates/test/index.html new file mode 100644 index 000000000..8579cdc2d --- /dev/null +++ b/box-test/src/main/resources/templates/test/index.html @@ -0,0 +1,39 @@ + + + + + BPS后台管理系统-测试首页 + + +

BPS后台管理系统-测试首页



+ +一、集成企业微信测试 +
  • 推送文本消息到企业微信
  • +
  • 推送文本卡片消息到企业微信
  • +

    + +二、Mybaits配置DML测试-Oracle(第二数据源) +
  • 查询所有用户
  • +
  • 新增ID为1000的用户
  • +
  • 根据ID查询用户,查询id=1000的用户
  • +
  • 修改用户为1000的用户姓名为Xia
  • +
  • 删除ID为1000的用户
  • + +

    +三、Mybaits配置DDL测试-Oracle +
  • 查询表中的记录数
  • +
  • 查询tc_user是否存在
  • +

    +Ajax发送获取Json配置测试 +

    +四、输入后验证测试 + +

  • 验证数据表中是否有记录
  • +

    + + +三、当前系统时间 + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/sendJson.html b/box-test/src/main/resources/templates/test/sendJson.html new file mode 100644 index 000000000..9c01a77e4 --- /dev/null +++ b/box-test/src/main/resources/templates/test/sendJson.html @@ -0,0 +1,99 @@ + + + + + 发送json + + + + + + +
    +


    + +
    +
    + + + diff --git a/box-test/src/main/resources/templates/test/testVerify.html b/box-test/src/main/resources/templates/test/testVerify.html new file mode 100644 index 000000000..b58ae6111 --- /dev/null +++ b/box-test/src/main/resources/templates/test/testVerify.html @@ -0,0 +1,65 @@ + + + + + + +
    +
    +
    +
    用户名: + + +
    + +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/bps-kettle/pom.xml b/bps-kettle/pom.xml new file mode 100644 index 000000000..657b1ad91 --- /dev/null +++ b/bps-kettle/pom.xml @@ -0,0 +1,155 @@ + + + + ruoyi + com.ruoyi + 4.6.2 + + 4.0.0 + + bps-kettle + + 9.0.0.0-423 + 2.5.16 + 1.7.2 + 2.6.12 + + + + + + com.ruoyi + ruoyi-common + + + com.ruoyi + ruoyi-system + + + com.ruoyi + ruoyi-quartz + + + + + pentaho-kettle + kettle-core + ${kettle-version} + + + pentaho-kettle + kettle-engine + ${kettle-version} + + + org.apache.poi + poi + + + org.apache.poi + poi-ooxml + + + org.apache.poi + poi-ooxml-schemas + + + + + pentaho-kettle + kettle-dbdialog + ${kettle-version} + + + org.pentaho.di.plugins + kettle-sap-plugin-core + ${kettle-version} + + + pentaho-kettle + kettle-ui-swt + ${kettle-version} + + + + org.codehaus.janino + janino + ${janino-version} + + + org.eclipse.birt.runtime.3_7_1 + org.mozilla.javascript + ${javascript-version} + + + + net.sourceforge.jexcelapi + jxl + ${jxl-version} + + + + + mysql + mysql-connector-java + 8.0.11 + + + + mm.mysql + mm.mysql + 2.0.7 + + + + + com.microsoft.sqlserver + sqljdbc4 + 4.0 + + + + net.sourceforge.jtds + jtds + 1.2.4 + + + + + + + + pentaho + https://nexus.pentaho.org/content/groups/omni/ + + + + + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/cons/XJobStatus.java b/bps-kettle/src/main/java/com/ruoyi/kettle/cons/XJobStatus.java new file mode 100644 index 000000000..a95e5101d --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/cons/XJobStatus.java @@ -0,0 +1,43 @@ +package com.ruoyi.kettle.cons; + +public enum XJobStatus { + UNKNOWN("-1", "未知状态"), + PENDING("10", "等待中"), + RUNNING("20", "运行中"), + HALTING("21", "终止中"), + STOPPED("30", "已中断"), + FINISHED("40", "已完成"), + SUCCESS("88", "运行成功"), + FAILED("99", "异常停止"); + + private String status; + private String description; + + private XJobStatus(String status, String description) { + this.status = status; + this.description = description; + } + + public String value() { + return this.status; + } + + public String description() { + return this.description; + } + + public static XJobStatus forName(Integer value) { + XJobStatus[] statuses = values(); + XJobStatus[] var2 = statuses; + int var3 = statuses.length; + + for(int var4 = 0; var4 < var3; ++var4) { + XJobStatus status = var2[var4]; + if (status.value().equals(value)) { + return status; + } + } + + return UNKNOWN; + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/cons/XTransStatus.java b/bps-kettle/src/main/java/com/ruoyi/kettle/cons/XTransStatus.java new file mode 100644 index 000000000..7017e4fc5 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/cons/XTransStatus.java @@ -0,0 +1,46 @@ +package com.ruoyi.kettle.cons; + +public enum XTransStatus { + UNKNOWN("-1", "未知状态"), + WAITING("10", "等待中"), + INITIALIZING("20", "转换初始化"), + PREPARING("21", "转换准备执行"), + STOPPED("30", "已终止"), + FINISHED("40", "已结束"), + RUNNING("50", "转换运行中"), + PAUSED("60", "转换已被暂停"), + HALTING("70", "转换被挂起"), + SUCCESS("88", "转换运行成功"), + FAILED("99", "异常停止"); + + private String status; + private String description; + + private XTransStatus(String status, String description) { + this.status = status; + this.description = description; + } + + public String value() { + return this.status; + } + + public String description() { + return this.description; + } + + public static XTransStatus forName(Integer value) { + XTransStatus[] statuses = values(); + XTransStatus[] var2 = statuses; + int var3 = statuses.length; + + for(int var4 = 0; var4 < var3; ++var4) { + XTransStatus status = var2[var4]; + if (status.value().equals(value)) { + return status; + } + } + + return UNKNOWN; + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/controller/KettleJobController.java b/bps-kettle/src/main/java/com/ruoyi/kettle/controller/KettleJobController.java new file mode 100644 index 000000000..88507ee22 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/controller/KettleJobController.java @@ -0,0 +1,186 @@ +package com.ruoyi.kettle.controller; + +import java.util.List; +import java.util.stream.Collectors; + +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.kettle.domain.KettleTrans; +import com.ruoyi.quartz.service.ISysJobService; +import com.ruoyi.system.service.ISysRoleService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +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.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.kettle.domain.KettleJob; +import com.ruoyi.kettle.service.IKettleJobService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 作业调度Controller + * + * @author kone + * @date 2021-07-22 + */ +@Controller +@RequestMapping("/kettle/job") +public class KettleJobController extends BaseController +{ + private String prefix = "kettle/job"; + + @Autowired + private IKettleJobService kettleJobService; + @Autowired + private ISysRoleService roleService; + @Autowired + private ISysJobService jobService; + @RequiresPermissions("kettle:job:view") + @GetMapping() + public String job() + { + return prefix + "/job"; + } + + /** + * 查询作业调度列表 + */ + @RequiresPermissions("kettle:job:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(KettleJob kettleJob) + { + startPage(); + List list = kettleJobService.selectKettleJobList(kettleJob); + return getDataTable(list); + } + + /** + * 导出作业调度列表 + */ + @RequiresPermissions("kettle:job:export") + @Log(title = "作业调度", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(KettleJob kettleJob) + { + List list = kettleJobService.selectKettleJobList(kettleJob); + ExcelUtil util = new ExcelUtil(KettleJob.class); + return util.exportExcel(list, "作业调度数据"); + } + + /** + * 新增作业调度 + */ + @GetMapping("/add") + public String add(ModelMap mmap) + { + List roleKeys=roleService.selectRoleAll().stream().map(SysRole::getRoleKey).collect(Collectors.toList()); + mmap.put("allRoles",roleKeys); + return prefix + "/add"; + } + + /** + * 新增保存作业调度 + */ + @RequiresPermissions("kettle:job:add") + @Log(title = "作业调度", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(KettleJob kettleJob) + { + return kettleJobService.insertKettleJob(kettleJob); + } + + /** + * 修改作业调度 + */ + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") Long id, ModelMap mmap) + { + KettleJob kettleJob = kettleJobService.selectKettleJobById(id); + List roleKeys=roleService.selectRoleAll().stream().map(SysRole::getRoleKey).collect(Collectors.toList()); + String rks=""; + if(kettleJob!=null && kettleJob.getRoleKey()!=null){ + rks=kettleJob.getRoleKey(); + } + String[] rkArray=rks.split(","); + mmap.put("allRoles",roleKeys); + mmap.put("rkArray",rkArray); + mmap.put("kettleJob", kettleJob); + return prefix + "/edit"; + } + + /** + * 修改保存作业调度 + */ + @RequiresPermissions("kettle:job:edit") + @Log(title = "作业调度", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(KettleJob kettleJob) + { + return toAjax(kettleJobService.updateKettleJob(kettleJob)); + } + + /** + * 删除作业调度 + */ + @RequiresPermissions("kettle:job:remove") + @Log(title = "作业调度", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(kettleJobService.deleteKettleJobByIds(ids)); + } + + + @Log(title = "立即执行作业", businessType = BusinessType.UPDATE) + @RequiresPermissions("kettle:job:run") + @PostMapping("/run") + @ResponseBody + public AjaxResult run(KettleJob job) + { + AjaxResult result = kettleJobService.run(job); + return result; + } + @RequiresPermissions("kettle:job:log") + @GetMapping("/detail/{id}") + public String detail(@PathVariable("id") Long id, ModelMap mmap) + { + KettleJob kettleJob = kettleJobService.selectKettleJobById(id); + List jobLog= kettleJobService.queryJobLog(kettleJob); + mmap.put("kettleJob", kettleJob); + mmap.put("jobLog",jobLog); + return prefix + "/detail"; + } + /** + * 跳转到新增调度定时任务页面 + */ + @RequiresPermissions("kettle:job:setquartz") + @GetMapping("/jobQuartz/{id}") + public String jobQuartz(@PathVariable("id") Long id,ModelMap mmap) + { + KettleJob kettleJob = kettleJobService.selectKettleJobById(id); + //kettleTransServiceImpl.runTransQuartz('12','text') + String checkStr="kettleJobServiceImpl.runJobQuartz('"+kettleJob.getId()+"','"+kettleJob.getJobName()+"')"; + Long jobId = kettleJobService.checkQuartzExist(checkStr); + if(jobId != null){ + mmap.put("job", jobService.selectJobById(Long.valueOf(jobId))); + return "kettle/quartz/editquartz"; + }else{ + mmap.put("invokeTarget", checkStr); + //mmap.put("job", kettleJob); + return "kettle/quartz/addquartz"; + } + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/controller/KettleTransController.java b/bps-kettle/src/main/java/com/ruoyi/kettle/controller/KettleTransController.java new file mode 100644 index 000000000..dfe56dae6 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/controller/KettleTransController.java @@ -0,0 +1,196 @@ +package com.ruoyi.kettle.controller; + +import java.util.List; +import java.util.stream.Collectors; + +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.quartz.service.ISysJobService; +import com.ruoyi.system.service.ISysRoleService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +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.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.kettle.domain.KettleTrans; +import com.ruoyi.kettle.service.IKettleTransService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 转换Controller + * + * @author kone + * @date 2021-07-14 + */ +@Controller +@RequestMapping("/kettle/trans") +public class KettleTransController extends BaseController +{ + private String prefix = "kettle/trans"; + + @Autowired + private IKettleTransService kettleTransService; + @Autowired + private ISysRoleService roleService; + @Autowired + private ISysJobService jobService; + @RequiresPermissions("kettle:trans:view") + @GetMapping() + public String trans() + { + return prefix + "/trans"; + } + + /** + * 查询转换列表 + */ + @RequiresPermissions("kettle:trans:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(KettleTrans kettleTrans) + { + startPage(); + List list = kettleTransService.selectKettleTransList(kettleTrans); + return getDataTable(list); + } + + /** + * 导出转换列表 + */ + @RequiresPermissions("kettle:trans:export") + @Log(title = "转换", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(KettleTrans kettleTrans) + { + List list = kettleTransService.selectKettleTransList(kettleTrans); + ExcelUtil util = new ExcelUtil(KettleTrans.class); + return util.exportExcel(list, "转换数据"); + } + + /** + * 新增转换 + */ + @GetMapping("/add") + public String add(ModelMap mmap) + { + List roleKeys=roleService.selectRoleAll().stream().map(SysRole::getRoleKey).collect(Collectors.toList()); + mmap.put("allRoles",roleKeys); + return prefix + "/add"; + } + + /** + * 新增保存转换 + */ + @RequiresPermissions("kettle:trans:add") + @Log(title = "转换", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(KettleTrans kettleTrans) + { + return kettleTransService.insertKettleTrans(kettleTrans) ; + } + + /** + * 修改转换 + */ + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") Long id, ModelMap mmap) + { + KettleTrans kettleTrans = kettleTransService.selectKettleTransById(id); + List roleKeys=roleService.selectRoleAll().stream().map(SysRole::getRoleKey).collect(Collectors.toList()); + String rks=""; + if(kettleTrans!=null && kettleTrans.getRoleKey()!=null){ + rks=kettleTrans.getRoleKey(); + } + String[] rkArray=rks.split(","); + mmap.put("allRoles",roleKeys); + mmap.put("kettleTrans", kettleTrans); + mmap.put("rkArray",rkArray); + return prefix + "/edit"; + } + + /** + * 修改保存转换 + */ + @RequiresPermissions("kettle:trans:edit") + @Log(title = "转换", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(KettleTrans kettleTrans) + { + return toAjax(kettleTransService.updateKettleTrans(kettleTrans)); + } + + /** + * 删除转换 + */ + @RequiresPermissions("kettle:trans:remove") + @Log(title = "转换", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(kettleTransService.deleteKettleTransByIds(ids)); + } + + /** + * 转换执行得日志 + */ + @RequiresPermissions("kettle:trans:log") + @GetMapping("/detail/{id}") + public String detail(@PathVariable("id") Long id, ModelMap mmap) + { + KettleTrans kettleTrans = kettleTransService.selectKettleTransById(id); + List transLog= kettleTransService.queryTransLog(kettleTrans); + mmap.put("kettleTrans", kettleTrans); + mmap.put("transLog",transLog); + return prefix + "/detail"; + } + /** + * 转换立即执行一次 + */ + @Log(title = "立即执行转换", businessType = BusinessType.UPDATE) + @RequiresPermissions("kettle:trans:run") + @PostMapping("/run") + @ResponseBody + public AjaxResult run(KettleTrans trans) + { + AjaxResult result = kettleTransService.run(trans); + return result; + } + + + /** + * 跳转到新增调度定时任务页面 + */ + @RequiresPermissions("kettle:trans:setquartz") + @GetMapping("/transQuartz/{id}") + public String transQuartz(@PathVariable("id") Long id,ModelMap mmap) + { + KettleTrans trans = kettleTransService.selectKettleTransById(id); + //kettleTransServiceImpl.runTransQuartz('12','text') + String checkStr="kettleTransServiceImpl.runTransQuartz('"+trans.getId()+"','"+trans.getTransName()+"')"; + Long jobId = kettleTransService.checkQuartzExist(checkStr); + if(jobId != null){ + mmap.put("job", jobService.selectJobById(Long.valueOf(jobId))); + return "kettle/quartz/editquartz"; + }else{ + + mmap.put("invokeTarget", checkStr); + //mmap.put("trans", trans); + return "kettle/quartz/addquartz"; + } + } + + + +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/controller/XRepositoryController.java b/bps-kettle/src/main/java/com/ruoyi/kettle/controller/XRepositoryController.java new file mode 100644 index 000000000..cb8f61be1 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/controller/XRepositoryController.java @@ -0,0 +1,153 @@ +package com.ruoyi.kettle.controller; + +import java.util.List; + +import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.kettle.repo.RepoTree; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +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.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.kettle.domain.XRepository; +import com.ruoyi.kettle.service.IXRepositoryService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 资源库Controller + * + * @author kone + * @date 2021-07-12 + */ +@Controller +@RequestMapping("/kettle/repository") +public class XRepositoryController extends BaseController +{ + private String prefix = "kettle/repository"; + + @Autowired + private IXRepositoryService xRepositoryService; + + @RequiresPermissions("kettle:repository:view") + @GetMapping() + public String repository() + { + return prefix + "/repository"; + } + + /** + * 查询资源库列表 + */ + @RequiresPermissions("kettle:repository:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(XRepository xRepository) + { + startPage(); + List list = xRepositoryService.selectXRepositoryList(xRepository); + return getDataTable(list); + } + @GetMapping(value = { "/selectRepositoryTree", "/selectRepositoryTree/{type}" }) + public String selectRepositoryTree( @PathVariable(value = "type", required = false) String type, ModelMap mmap) + { + XRepository r=new XRepository(); + List repoTree = xRepositoryService.selectXRepositoryList(r); + //XRepository repository=xRepositoryService.selectXRepositoryById(2L); + //mmap.put("repository", repository); + mmap.put("repoTree", repoTree); + mmap.put("type", type); + return "kettle/common/repository_tree"; + } + @GetMapping("/repositoryRoot") + @ResponseBody + public List repositoryRoot() + { + List ztrees = xRepositoryService.selectRepoRoot(new XRepository()); + return ztrees; + } + @PostMapping("/qryRepoSubTree/{id}/{type}") + @ResponseBody + public List qryRepoSubTree(@PathVariable("id") Long id,@PathVariable("type") String type, ModelMap mmapy) { + List ztrees = xRepositoryService.selectRepoTree(id,type); + return ztrees; + } + /** + * 导出资源库列表 + */ + @RequiresPermissions("kettle:repository:export") + @Log(title = "资源库", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(XRepository xRepository) + { + List list = xRepositoryService.selectXRepositoryList(xRepository); + ExcelUtil util = new ExcelUtil(XRepository.class); + return util.exportExcel(list, "资源库数据"); + } + + /** + * 新增资源库 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存资源库 + */ + @RequiresPermissions("kettle:repository:add") + @Log(title = "资源库", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(XRepository xRepository) + { + return toAjax(xRepositoryService.insertXRepository(xRepository)); + } + + /** + * 修改资源库 + */ + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") Long id, ModelMap mmap) + { + XRepository xRepository = xRepositoryService.selectXRepositoryById(id); + mmap.put("xRepository", xRepository); + return prefix + "/edit"; + } + + /** + * 修改保存资源库 + */ + @RequiresPermissions("kettle:repository:edit") + @Log(title = "资源库", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(XRepository xRepository) + { + return toAjax(xRepositoryService.updateXRepository(xRepository)); + } + + /** + * 删除资源库 + */ + @RequiresPermissions("kettle:repository:remove") + @Log(title = "资源库", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(xRepositoryService.deleteXRepositoryByIds(ids)); + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/domain/KettleJob.java b/bps-kettle/src/main/java/com/ruoyi/kettle/domain/KettleJob.java new file mode 100644 index 000000000..3238c3238 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/domain/KettleJob.java @@ -0,0 +1,224 @@ +package com.ruoyi.kettle.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作业调度对象 kettle_job + * + * @author kone + * @date 2021-07-22 + */ +public class KettleJob extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** */ + private Long id; + + /** */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "", width = 30, dateFormat = "yyyy-MM-dd") + private Date createdTime; + + /** */ + @Excel(name = "") + private String createdBy; + + /** 作业名称 */ + @Excel(name = "作业名称") + private String jobName; + + /** 描述 */ + @Excel(name = "描述") + private String jobDescription; + + /** 作业类型(file,ftp,sf) */ + @Excel(name = "作业类型(file,ftp,sf)") + private String jobType; + + /** 路径 */ + @Excel(name = "路径") + private String jobPath; + + /** 资源库id */ + @Excel(name = "资源库id") + private Long jobRepositoryId; + + /** 日志级别 */ + @Excel(name = "日志级别") + private String jobLogLevel; + + /** 状态 */ + @Excel(name = "状态") + private String jobStatus; + + /** 是否删除 */ + @Excel(name = "是否删除") + private Integer isDel; + + /** 是否监控 */ + @Excel(name = "是否监控") + private Integer isMonitorEnabled; + + /** 可执行角色key,用+号拼接 */ + @Excel(name = "可执行角色key,用+号拼接") + private String roleKey; + + /** */ + @Excel(name = "") + private String tplKey; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setCreatedTime(Date createdTime) + { + this.createdTime = createdTime; + } + + public Date getCreatedTime() + { + return createdTime; + } + public void setCreatedBy(String createdBy) + { + this.createdBy = createdBy; + } + + public String getCreatedBy() + { + return createdBy; + } + public void setJobName(String jobName) + { + this.jobName = jobName; + } + + public String getJobName() + { + return jobName; + } + public void setJobDescription(String jobDescription) + { + this.jobDescription = jobDescription; + } + + public String getJobDescription() + { + return jobDescription; + } + public void setJobType(String jobType) + { + this.jobType = jobType; + } + + public String getJobType() + { + return jobType; + } + public void setJobPath(String jobPath) + { + this.jobPath = jobPath; + } + + public String getJobPath() + { + return jobPath; + } + public void setJobRepositoryId(Long jobRepositoryId) + { + this.jobRepositoryId = jobRepositoryId; + } + + public Long getJobRepositoryId() + { + return jobRepositoryId; + } + public void setJobLogLevel(String jobLogLevel) + { + this.jobLogLevel = jobLogLevel; + } + + public String getJobLogLevel() + { + return jobLogLevel; + } + public void setJobStatus(String jobStatus) + { + this.jobStatus = jobStatus; + } + + public String getJobStatus() + { + return jobStatus; + } + public void setIsDel(Integer isDel) + { + this.isDel = isDel; + } + + public Integer getIsDel() + { + return isDel; + } + public void setIsMonitorEnabled(Integer isMonitorEnabled) + { + this.isMonitorEnabled = isMonitorEnabled; + } + + public Integer getIsMonitorEnabled() + { + return isMonitorEnabled; + } + public void setRoleKey(String roleKey) + { + this.roleKey = roleKey; + } + + public String getRoleKey() + { + return roleKey; + } + public void setTplKey(String tplKey) + { + this.tplKey = tplKey; + } + + public String getTplKey() + { + return tplKey; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("createdTime", getCreatedTime()) + .append("updateTime", getUpdateTime()) + .append("createdBy", getCreatedBy()) + .append("updateBy", getUpdateBy()) + .append("jobName", getJobName()) + .append("jobDescription", getJobDescription()) + .append("jobType", getJobType()) + .append("jobPath", getJobPath()) + .append("jobRepositoryId", getJobRepositoryId()) + .append("jobLogLevel", getJobLogLevel()) + .append("jobStatus", getJobStatus()) + .append("isDel", getIsDel()) + .append("isMonitorEnabled", getIsMonitorEnabled()) + .append("roleKey", getRoleKey()) + .append("tplKey", getTplKey()) + .toString(); + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/domain/KettleTrans.java b/bps-kettle/src/main/java/com/ruoyi/kettle/domain/KettleTrans.java new file mode 100644 index 000000000..79d6248fe --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/domain/KettleTrans.java @@ -0,0 +1,220 @@ +package com.ruoyi.kettle.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 转换对象 kettle_trans + * + * @author kone + * @date 2021-07-14 + */ +public class KettleTrans extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** */ + private Long id; + + /** 转换名称 */ + @Excel(name = "转换名称") + private String transName; + + /** 转换描述 */ + @Excel(name = "转换描述") + private String transDescription; + + /** */ + private Date createdTime; + + /** */ + private String createdBy; + + /** 转换类型(file,ftp,sf) */ + private String transType; + + /** 路径 */ + @Excel(name = "路径") + private String transPath; + + /** 所属资源库id */ + @Excel(name = "所属资源库id") + private Long transRepositoryId; + + /** 日志级别 */ + @Excel(name = "日志级别") + private String transLogLevel; + + /** 状态 */ + @Excel(name = "状态") + private String transStatus; + + /** 是否删除 */ + @Excel(name = "是否删除") + private Integer isDel; + + /** 是否启用 */ + @Excel(name = "是否启用") + private Integer isMonitorEnabled; + + /** 保留备用 */ + private String tplKey; + + /** 可执行角色key,用+号拼接 */ + @Excel(name = "可执行角色key") + private String roleKey; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setTransName(String transName) + { + this.transName = transName; + } + + public String getTransName() + { + return transName; + } + public void setTransDescription(String transDescription) + { + this.transDescription = transDescription; + } + + public String getTransDescription() + { + return transDescription; + } + public void setCreatedTime(Date createdTime) + { + this.createdTime = createdTime; + } + + public Date getCreatedTime() + { + return createdTime; + } + public void setCreatedBy(String createdBy) + { + this.createdBy = createdBy; + } + + public String getCreatedBy() + { + return createdBy; + } + public void setTransType(String transType) + { + this.transType = transType; + } + + public String getTransType() + { + return transType; + } + public void setTransPath(String transPath) + { + this.transPath = transPath; + } + + public String getTransPath() + { + return transPath; + } + public void setTransRepositoryId(Long transRepositoryId) + { + this.transRepositoryId = transRepositoryId; + } + + public Long getTransRepositoryId() + { + return transRepositoryId; + } + public void setTransLogLevel(String transLogLevel) + { + this.transLogLevel = transLogLevel; + } + + public String getTransLogLevel() + { + return transLogLevel; + } + public void setTransStatus(String transStatus) + { + this.transStatus = transStatus; + } + + public String getTransStatus() + { + return transStatus; + } + public void setIsDel(Integer isDel) + { + this.isDel = isDel; + } + + public Integer getIsDel() + { + return isDel; + } + public void setIsMonitorEnabled(Integer isMonitorEnabled) + { + this.isMonitorEnabled = isMonitorEnabled; + } + + public Integer getIsMonitorEnabled() + { + return isMonitorEnabled; + } + public void setTplKey(String tplKey) + { + this.tplKey = tplKey; + } + + public String getTplKey() + { + return tplKey; + } + public void setRoleKey(String roleKey) + { + this.roleKey = roleKey; + } + + public String getRoleKey() + { + return roleKey; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("transName", getTransName()) + .append("transDescription", getTransDescription()) + .append("createdTime", getCreatedTime()) + .append("updateTime", getUpdateTime()) + .append("createdBy", getCreatedBy()) + .append("updateBy", getUpdateBy()) + .append("transType", getTransType()) + .append("transPath", getTransPath()) + .append("transRepositoryId", getTransRepositoryId()) + .append("transLogLevel", getTransLogLevel()) + .append("transStatus", getTransStatus()) + .append("isDel", getIsDel()) + .append("isMonitorEnabled", getIsMonitorEnabled()) + .append("tplKey", getTplKey()) + .append("roleKey", getRoleKey()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/domain/XRepository.java b/bps-kettle/src/main/java/com/ruoyi/kettle/domain/XRepository.java new file mode 100644 index 000000000..769576acf --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/domain/XRepository.java @@ -0,0 +1,256 @@ +package com.ruoyi.kettle.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 资源库对象 kettle_repository + * + * @author kone + * @date 2021-07-12 + */ +public class XRepository extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** */ + private Long id; + + /** */ + @Excel(name = "") + private String repoId; + + /** 资源库名称 */ + @Excel(name = "资源库名称") + private String repoName; + + /** 当资源库类型是db时候的用户名 */ + private String repoUsername; + + /** 当资源库类型是db时候的密码 */ + private String repoPassword; + + /** db类型 */ + private String repoType; + + /** 当资源库类型是db时候的连接类型 */ + private String dbAccess; + + /** 当资源库类型是db时候的ip */ + private String dbHost; + + /** 当资源库类型是db时候的端口 */ + private String dbPort; + + /** 当资源库类型是db时候的db库名 */ + private String dbName; + + /** 当资源库类型是db时候的db用户名 */ + private String dbUsername; + + /** 当资源库类型是db时候的db用户密码 */ + private String dbPassword; + + /** 软删除 */ + private int isDel; + + /** */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "", width = 30, dateFormat = "yyyy-MM-dd") + private Date createdTime; + + /** */ + @Excel(name = "") + private String createdBy; + + /** 资源库类型 */ + @Excel(name = "资源库类型") + private String type; + + /** 基础路径 */ + @Excel(name = "基础路径") + private String baseDir; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setRepoId(String repoId) + { + this.repoId = repoId; + } + + public String getRepoId() + { + return repoId; + } + public void setRepoName(String repoName) + { + this.repoName = repoName; + } + + public String getRepoName() + { + return repoName; + } + public void setRepoUsername(String repoUsername) + { + this.repoUsername = repoUsername; + } + + public String getRepoUsername() + { + return repoUsername; + } + public void setRepoPassword(String repoPassword) + { + this.repoPassword = repoPassword; + } + + public String getRepoPassword() + { + return repoPassword; + } + public void setRepoType(String repoType) + { + this.repoType = repoType; + } + + public String getRepoType() + { + return repoType; + } + public void setDbAccess(String dbAccess) + { + this.dbAccess = dbAccess; + } + + public String getDbAccess() + { + return dbAccess; + } + public void setDbHost(String dbHost) + { + this.dbHost = dbHost; + } + + public String getDbHost() + { + return dbHost; + } + public void setDbPort(String dbPort) + { + this.dbPort = dbPort; + } + + public String getDbPort() + { + return dbPort; + } + public void setDbName(String dbName) + { + this.dbName = dbName; + } + + public String getDbName() + { + return dbName; + } + public void setDbUsername(String dbUsername) + { + this.dbUsername = dbUsername; + } + + public String getDbUsername() + { + return dbUsername; + } + public void setDbPassword(String dbPassword) + { + this.dbPassword = dbPassword; + } + + public String getDbPassword() + { + return dbPassword; + } + public void setIsDel(int isDel) + { + this.isDel = isDel; + } + + public int getIsDel() + { + return isDel; + } + public void setCreatedTime(Date createdTime) + { + this.createdTime = createdTime; + } + + public Date getCreatedTime() + { + return createdTime; + } + public void setCreatedBy(String createdBy) + { + this.createdBy = createdBy; + } + + public String getCreatedBy() + { + return createdBy; + } + public void setType(String type) + { + this.type = type; + } + + public String getType() + { + return type; + } + public void setBaseDir(String baseDir) + { + this.baseDir = baseDir; + } + + public String getBaseDir() + { + return baseDir; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("repoId", getRepoId()) + .append("repoName", getRepoName()) + .append("repoUsername", getRepoUsername()) + .append("repoPassword", getRepoPassword()) + .append("repoType", getRepoType()) + .append("dbAccess", getDbAccess()) + .append("dbHost", getDbHost()) + .append("dbPort", getDbPort()) + .append("dbName", getDbName()) + .append("dbUsername", getDbUsername()) + .append("dbPassword", getDbPassword()) + .append("isDel", getIsDel()) + .append("createdTime", getCreatedTime()) + .append("updateTime", getUpdateTime()) + .append("createdBy", getCreatedBy()) + .append("updateBy", getUpdateBy()) + .append("type", getType()) + .append("baseDir", getBaseDir()) + .toString(); + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/mapper/KettleJobMapper.java b/bps-kettle/src/main/java/com/ruoyi/kettle/mapper/KettleJobMapper.java new file mode 100644 index 000000000..05d31bb1c --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/mapper/KettleJobMapper.java @@ -0,0 +1,69 @@ +package com.ruoyi.kettle.mapper; + +import java.util.List; +import com.ruoyi.kettle.domain.KettleJob; +import org.apache.ibatis.annotations.Param; + +/** + * 作业调度Mapper接口 + * + * @author kone + * @date 2021-07-22 + */ +public interface KettleJobMapper +{ + /** + * 查询作业调度 + * + * @param id 作业调度ID + * @return 作业调度 + */ + public KettleJob selectKettleJobById(Long id); + + /** + * 查询作业调度列表 + * + * @param kettleJob 作业调度 + * @param roleKeys + * @return 作业调度集合 + */ + public List selectKettleJobList(@Param("kettleJob") KettleJob kettleJob,@Param("roleKey") List roleKeys); + + /** + * 新增作业调度 + * + * @param kettleJob 作业调度 + * @return 结果 + */ + public int insertKettleJob(KettleJob kettleJob); + + /** + * 修改作业调度 + * + * @param kettleJob 作业调度 + * @return 结果 + */ + public int updateKettleJob(KettleJob kettleJob); + + /** + * 删除作业调度 + * + * @param id 作业调度ID + * @return 结果 + */ + public int deleteKettleJobById(Long id); + + /** + * 批量删除作业调度 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteKettleJobByIds(String[] ids); + + int selectJobByNameAndRepoId(@Param("jobName")String jobName, @Param("jobRepositoryId")Long jobRepositoryId); + + List queryJobLog(String jobName); + + Long checkQuartzExist(String checkStr); +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/mapper/KettleTransMapper.java b/bps-kettle/src/main/java/com/ruoyi/kettle/mapper/KettleTransMapper.java new file mode 100644 index 000000000..2152fe8f2 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/mapper/KettleTransMapper.java @@ -0,0 +1,69 @@ +package com.ruoyi.kettle.mapper; + +import java.util.List; +import com.ruoyi.kettle.domain.KettleTrans; +import org.apache.ibatis.annotations.Param; + +/** + * 转换Mapper接口 + * + * @author kone + * @date 2021-07-14 + */ +public interface KettleTransMapper +{ + /** + * 查询转换 + * + * @param id 转换ID + * @return 转换 + */ + public KettleTrans selectKettleTransById(Long id); + + /** + * 查询转换列表 + * + * @param kettleTrans 转换 + * @param roleKey + * @return 转换集合 + */ + public List selectKettleTransList(@Param("KettleTrans") KettleTrans kettleTrans,@Param("roleKey") List roleKey); + + /** + * 新增转换 + * + * @param kettleTrans 转换 + * @return 结果 + */ + public int insertKettleTrans(KettleTrans kettleTrans); + + /** + * 修改转换 + * + * @param kettleTrans 转换 + * @return 结果 + */ + public int updateKettleTrans(KettleTrans kettleTrans); + + /** + * 删除转换 + * + * @param id 转换ID + * @return 结果 + */ + public int deleteKettleTransById(Long id); + + /** + * 批量删除转换 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteKettleTransByIds(String[] ids); + + int selectKettleTransByTransName(String transName); + + List queryTransLog(String transName); + + Long checkQuartzExist(String checkStr); +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/mapper/XRepositoryMapper.java b/bps-kettle/src/main/java/com/ruoyi/kettle/mapper/XRepositoryMapper.java new file mode 100644 index 000000000..b3893f0f3 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/mapper/XRepositoryMapper.java @@ -0,0 +1,77 @@ +package com.ruoyi.kettle.mapper; + +import java.util.List; +import com.ruoyi.kettle.domain.XRepository; + +/** + * 资源库Mapper接口 + * + * @author kone + * @date 2021-07-12 + */ +public interface XRepositoryMapper +{ + /** + * 查询资源库 + * + * @param id 资源库ID + * @return 资源库 + */ + public XRepository selectXRepositoryById(Long id); + + /** + * 查询资源库列表 + * + * @param xRepository 资源库 + * @return 资源库集合 + */ + public List selectXRepositoryList(XRepository xRepository); + + /** + * 新增资源库 + * + * @param xRepository 资源库 + * @return 结果 + */ + public int insertXRepository(XRepository xRepository); + + /** + * 修改资源库 + * + * @param xRepository 资源库 + * @return 结果 + */ + public int updateXRepository(XRepository xRepository); + + /** + * 删除资源库 + * + * @param id 资源库ID + * @return 结果 + */ + public int deleteXRepositoryById(Long id); + + /** + * 批量删除资源库 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteXRepositoryByIds(String[] ids); + /** + * @Description:软删除 + * @Author: Kone.wang + * @Date: 14:07 + * @param id: + * @return: int + **/ + int updateIsDel(Long id); + /** + * @Description:批量软删除 + * @Author: Kone.wang + * @Date: 2021/7/19 14:07 + * @param ids: + * @return: int + **/ + public int updateIsDelBatch(String[] ids); +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/repo/RepoTree.java b/bps-kettle/src/main/java/com/ruoyi/kettle/repo/RepoTree.java new file mode 100644 index 000000000..1f2f5baa2 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/repo/RepoTree.java @@ -0,0 +1,96 @@ +package com.ruoyi.kettle.repo; + +public class RepoTree { + private static final long serialVersionUID = 1L; + + /** 节点ID */ + private String id; + + /** 节点父ID */ + private String pId; + + /** 节点名称 */ + private String name; + + /** 节点标题 */ + private String title; + + /** 是否勾选 */ + private boolean checked = false; + + /** 是否展开 */ + private boolean open = false; + + /** 是否能勾选 */ + private boolean nocheck = false; + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getpId() + { + return pId; + } + + public void setpId(String pId) + { + this.pId = pId; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public boolean isChecked() + { + return checked; + } + + public void setChecked(boolean checked) + { + this.checked = checked; + } + + public boolean isOpen() + { + return open; + } + + public void setOpen(boolean open) + { + this.open = open; + } + + public boolean isNocheck() + { + return nocheck; + } + + public void setNocheck(boolean nocheck) + { + this.nocheck = nocheck; + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/repo/RepositoryTree.java b/bps-kettle/src/main/java/com/ruoyi/kettle/repo/RepositoryTree.java new file mode 100644 index 000000000..cbb747bb2 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/repo/RepositoryTree.java @@ -0,0 +1,94 @@ +package com.ruoyi.kettle.repo; + +public class RepositoryTree { + private String id; + private String parent; + private String text; + private String icon; + private Object state; + private String type; + private boolean isLasted; + private String path; + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public String getPath() { + return this.path; + } + + public void setPath(String path) { + this.path = path; + } + + public boolean isLasted() { + return this.isLasted; + } + + public void setLasted(boolean isLasted) { + this.isLasted = isLasted; + } + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public String getParent() { + return this.parent; + } + + public void setParent(String parent) { + this.parent = parent; + } + + public String getText() { + return this.text; + } + + public void setText(String text) { + this.text = text; + } + + public String getIcon() { + return this.icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public Object getState() { + return this.state; + } + + public void setState(Object state) { + this.state = state; + } + + public RepositoryTree(String id, String parent, String text, String icon, Object state, String type, boolean isLasted, String path) { + this.id = id; + this.parent = parent; + this.text = text; + this.icon = icon; + this.state = state; + this.type = type; + this.isLasted = isLasted; + this.path = path; + } + + public RepositoryTree() { + } + + public String toString() { + return "RepositoryTree [id=" + this.id + ", parent=" + this.parent + ", text=" + this.text + ", icon=" + this.icon + ", state=" + this.state + ", type=" + this.type + ", isLasted=" + this.isLasted + ", path=" + this.path + "]"; + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/repo/XRepoManager.java b/bps-kettle/src/main/java/com/ruoyi/kettle/repo/XRepoManager.java new file mode 100644 index 000000000..ad01cc53b --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/repo/XRepoManager.java @@ -0,0 +1,266 @@ +package com.ruoyi.kettle.repo; + + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import org.pentaho.di.core.KettleEnvironment; +import org.pentaho.di.core.ProgressMonitorListener; +import org.pentaho.di.core.database.DatabaseMeta; +import org.pentaho.di.core.exception.KettleException; +import org.pentaho.di.repository.*; +import org.pentaho.di.repository.filerep.KettleFileRepository; +import org.pentaho.di.repository.filerep.KettleFileRepositoryMeta; +import org.pentaho.di.repository.kdr.KettleDatabaseRepository; +import org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.StringUtils; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +public class XRepoManager { + private static final Logger log = LoggerFactory.getLogger(XRepoManager.class); + public static Map repositoryCache = new HashMap(); + public static Map databaseMeta = new ConcurrentHashMap(); + + public XRepoManager() { + } + public static List getAllDirectoryTreeList(String repoId, Repository repository, String path, List allRepositoryTreeList,String type) throws KettleException { + List repositoryTreeList = getJobAndTrans(repoId, repository, path,type); + if (repositoryTreeList.size() != 0) { + Iterator var5 = repositoryTreeList.iterator(); + + while(var5.hasNext()) { + RepositoryTree repositoryTree = (RepositoryTree)var5.next(); + if (!repositoryTree.isLasted()) { + getAllDirectoryTreeList(repoId, repository, repositoryTree.getPath(), allRepositoryTreeList,type); + allRepositoryTreeList.add(repositoryTree); + } else { + allRepositoryTreeList.add(repositoryTree); + } + } + } + + return allRepositoryTreeList; + } + public static List getJobAndTrans(String repoId, Repository repository, String path,String type) throws KettleException { + RepositoryDirectoryInterface rDirectory = repository.loadRepositoryDirectoryTree().findDirectory(path); + List repositoryTreeList = getDirectory(repoId, repository, rDirectory); + List li = repository.getJobAndTransformationObjects(rDirectory.getObjectId(), false); + if (null != li) { + Iterator var6 = li.iterator(); + + while(var6.hasNext()) { + RepositoryElementMetaInterface repel = (RepositoryElementMetaInterface)var6.next(); + RepositoryTree repositoryTree; + StringBuilder stringBuilder; + if ("job".equals(repel.getObjectType().toString()) && type.equals("job")) { + repositoryTree = new RepositoryTree(); + stringBuilder = new StringBuilder(); + stringBuilder.append("job").append(rDirectory.getObjectId().toString()).append("@").append(repel.getObjectId().toString()); + repositoryTree.setId(stringBuilder.toString()); + repositoryTree.setParent(repoId + "@" + rDirectory.getObjectId().toString()); + repositoryTree.setText(repel.getName()); + if (repository instanceof KettleDatabaseRepository) { + repositoryTree.setType(repoId + "@db@" + "job"); + } else if (repository instanceof KettleFileRepository) { + repositoryTree.setType(repoId + "@file@" + "job"); + } + + repositoryTree.setLasted(true); + repositoryTree.setPath(repel.getRepositoryDirectory().getPath()); + repositoryTreeList.add(repositoryTree); + } else if ("transformation".equals(repel.getObjectType().toString())&& type.equals("trans")) { + repositoryTree = new RepositoryTree(); + stringBuilder = new StringBuilder(); + stringBuilder.append("transformation").append(rDirectory.getObjectId().toString()).append("@").append(repel.getObjectId().toString()); + repositoryTree.setId(stringBuilder.toString()); + repositoryTree.setParent(repoId + "@" + rDirectory.getObjectId().toString()); + repositoryTree.setText(repel.getName()); + if (repository instanceof KettleDatabaseRepository) { + repositoryTree.setType(repoId + "@db@" + "transformation"); + } else if (repository instanceof KettleFileRepository) { + repositoryTree.setType(repoId + "@file@" + "transformation"); + } + + repositoryTree.setLasted(true); + repositoryTree.setPath(repel.getRepositoryDirectory().getPath()); + repositoryTreeList.add(repositoryTree); + } + } + } + + return repositoryTreeList; + } + private static List getDirectory(String repoId, Repository repository, RepositoryDirectoryInterface rDirectory) throws KettleException { + List repositoryTreeList = new ArrayList(); + if (null != repository && null != rDirectory) { + RepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree().findDirectory(rDirectory.getObjectId()); + if (rDirectory.getNrSubdirectories() > 0) { + for(int i = 0; i < rDirectory.getNrSubdirectories(); ++i) { + RepositoryDirectory subTree = tree.getSubdirectory(i); + RepositoryTree repositoryTree = new RepositoryTree(); + repositoryTree.setId(repoId + "@" + subTree.getObjectId().toString()); + repositoryTree.setParent(repoId + "@" + rDirectory.getObjectId().toString()); + repositoryTree.setText(subTree.getName()); + repositoryTree.setPath(subTree.getPath()); + repositoryTree.setType("subTree"); + List RepositoryElementMetaInterfaceList = repository.getJobAndTransformationObjects(subTree.getObjectId(), false); + if (subTree.getNrSubdirectories() <= 0 && RepositoryElementMetaInterfaceList.size() <= 0) { + repositoryTree.setLasted(true); + } else { + repositoryTree.setLasted(false); + } + + repositoryTreeList.add(repositoryTree); + } + } + } + + return repositoryTreeList; + } + public static Repository createRep(BaseRepositoryMeta baseRepositoryMeta, String id) throws KettleException { + if (get(id) != null) { + return get(id); + } else { + Repository repo = null; + if (baseRepositoryMeta instanceof KettleDatabaseRepositoryMeta) { + repo = new KettleDatabaseRepository(); + ((Repository)repo).init((KettleDatabaseRepositoryMeta)baseRepositoryMeta); + } else { + repo = new KettleFileRepository(); + ((Repository)repo).init((KettleFileRepositoryMeta)baseRepositoryMeta); + } + + repositoryCache.put(id, repo); + log.info(((Repository)repo).getName() + "资源库初始化成功"); + return (Repository)repo; + } + } + + public static Repository createFileRep(String repoId, String repName, String description, String baseDirectory) throws KettleException { + if (!KettleEnvironment.isInitialized()) { + KettleEnvironment.init(); + } + + KettleFileRepositoryMeta fileRepMeta = new KettleFileRepositoryMeta(repoId, repName, description, baseDirectory); + return createRep(fileRepMeta, repoId); + } + private static Repository get(String repoId) { + return (Repository)repositoryCache.get(repoId); + } + /* public static String[] getDataBaseAccess() { + String[] dataBaseAccess = DatabaseMeta.dbAccessTypeCode; + return dataBaseAccess; + } + + public static DatabaseMeta createDatabaseMeta(String name, String type, String access, String host, String db, String port, String user, String pass, Map params, boolean replace, Repository repository) { + DatabaseMeta dm = null; + if (repository != null) { + try { + ObjectId dbId = repository.getDatabaseID(name); + if (dbId != null && !replace) { + dm = repository.loadDatabaseMeta(dbId, (String)null); + } else if (dbId != null && replace) { + repository.deleteDatabaseMeta(name); + } + } catch (KettleException var15) { + log.error("创建数据库元数据失败", var15); + } + } + + if (dm == null) { + dm = new DatabaseMeta(name, type, access, host, db, port, user, pass); + if (params != null) { + Iterator var13 = params.entrySet().iterator(); + + while(var13.hasNext()) { + Map.Entry ent = (Map.Entry)var13.next(); + dm.addExtraOption(type, (String)ent.getKey(), "" + ent.getValue()); + } + } + + dm.setForcingIdentifiersToLowerCase(true); + if (repository != null) { + try { + repository.save(dm, (String)null, (ProgressMonitorListener)null, true); + } catch (KettleException var14) { + log.error("保存数据库元数据失败", var14); + } + } + } + + if (!StringUtils.isEmpty(dm)) { + databaseMeta.put("databaseMeta", dm); + log.info("第一次连接,获取到资源库数据库信息,{}", JSON.toJSON(dm)); + } + + return dm; + } + + + + + + public static Repository createDBRepByJndi(String repoId, String name, String type, String db) throws KettleException { + return createBaseMetaRep(repoId, (String)null, (String)null, (JSONObject)null, name, type, DatabaseMeta.dbAccessTypeCode[4], (String)null, db, (String)null, (String)null, (String)null); + } + + public static Repository createDBRepByParams(String repoId, String repoName, JSONObject params, String databaseMetaName, String type, String access, String host, String db, String port, String user, String pass) throws KettleException { + return createBaseMetaRep(repoId, repoName, repoName, params, databaseMetaName, type, access, host, db, port, user, pass); + } + + public static Repository createDBRepByDesc(String repoId, String repoName, String description, String databaseMetaName, String type, String access, String host, String db, String port, String user, String pass) throws KettleException { + return createBaseMetaRep(repoId, repoName, description, (JSONObject)null, databaseMetaName, type, access, host, db, port, user, pass); + } + + public static Repository createBaseMetaRep(String repoId, String repoName, String description, JSONObject params, String databaseMetaName, String type, String access, String host, String db, String port, String user, String pass) throws KettleException { + DatabaseMeta dataMeta = createDatabaseMeta(databaseMetaName, type, access, host, db, port, user, pass, params, false, (Repository)null); + return createBaseRep(dataMeta, repoId, repoName, description); + } + + public static Repository createBaseRep(DatabaseMeta dataMeta, String repoId, String repoName, String description) throws KettleException { + KettleDatabaseRepositoryMeta kettleDatabaseMeta = new KettleDatabaseRepositoryMeta(repoId, repoName, description, dataMeta); + return createRep(kettleDatabaseMeta, repoId); + } + + public static KettleFileRepository createKFR(String id, String repName, String description, String baseDirectory) throws KettleException { + KettleFileRepositoryMeta kettleFileRepositoryMeta = (KettleFileRepositoryMeta)createFileRep(id, repName, repName + "文件资源库", baseDirectory); + KettleFileRepository kettleFileRepository = new KettleFileRepository(); + kettleFileRepository.init(kettleFileRepositoryMeta); + return kettleFileRepository; + } + + public static KettleDatabaseRepository createKDR(String name, String repoType, String dbAccess, String dbHost, String dbName, String dbPort, String dbUserName, String dbPass, String repoName, String repoId) throws KettleException { + createDatabaseMeta(name, repoType, dbAccess, dbHost, dbName, dbPort, dbUserName, dbPass, (Map)null, false, (Repository)null); + KettleDatabaseRepositoryMeta kettleDatabaseRepositoryMeta = (KettleDatabaseRepositoryMeta)createDBRepByDesc(repoId, repoName, repoName, name, repoType, dbAccess, dbHost, dbName, dbPort, dbUserName, dbPass); + KettleDatabaseRepository kettleDatabaseRepository = new KettleDatabaseRepository(); + kettleDatabaseRepository.init(kettleDatabaseRepositoryMeta); + return kettleDatabaseRepository; + } + + public static void disConnectionRepository(String id) { + if (repositoryCache.containsKey(id)) { + Repository repository = (Repository)repositoryCache.get(id); + repository.disconnect(); + repository.clearSharedObjectCache(); + repositoryCache.remove(id); + } + + } + + public static void destroyAll() { + repositoryCache.forEach((id, repository) -> { + repository.disconnect(); + repository.clearSharedObjectCache(); + }); + repositoryCache.clear(); + } + + + + + + */ +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/service/IKettleJobService.java b/bps-kettle/src/main/java/com/ruoyi/kettle/service/IKettleJobService.java new file mode 100644 index 000000000..a9a6b69a0 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/service/IKettleJobService.java @@ -0,0 +1,71 @@ +package com.ruoyi.kettle.service; + +import java.util.List; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.kettle.domain.KettleJob; + +/** + * 作业调度Service接口 + * + * @author kone + * @date 2021-07-22 + */ +public interface IKettleJobService +{ + /** + * 查询作业调度 + * + * @param id 作业调度ID + * @return 作业调度 + */ + public KettleJob selectKettleJobById(Long id); + + /** + * 查询作业调度列表 + * + * @param kettleJob 作业调度 + * @return 作业调度集合 + */ + public List selectKettleJobList(KettleJob kettleJob); + + /** + * 新增作业调度 + * + * @param kettleJob 作业调度 + * @return 结果 + */ + public AjaxResult insertKettleJob(KettleJob kettleJob); + + /** + * 修改作业调度 + * + * @param kettleJob 作业调度 + * @return 结果 + */ + public int updateKettleJob(KettleJob kettleJob); + + /** + * 批量删除作业调度 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteKettleJobByIds(String ids); + + /** + * 删除作业调度信息 + * + * @param id 作业调度ID + * @return 结果 + */ + public int deleteKettleJobById(Long id); + + AjaxResult run(KettleJob job); + + List queryJobLog(KettleJob kettleJob); + + Long checkQuartzExist(String checkStr); + + public AjaxResult runJobQuartz(String id, String jobName); +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/service/IKettleTransService.java b/bps-kettle/src/main/java/com/ruoyi/kettle/service/IKettleTransService.java new file mode 100644 index 000000000..37629babe --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/service/IKettleTransService.java @@ -0,0 +1,84 @@ +package com.ruoyi.kettle.service; + +import java.util.List; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.kettle.domain.KettleTrans; + +/** + * 转换Service接口 + * + * @author kone + * @date 2021-07-14 + */ +public interface IKettleTransService +{ + /** + * 查询转换 + * + * @param id 转换ID + * @return 转换 + */ + public KettleTrans selectKettleTransById(Long id); + + /** + * 查询转换列表 + * + * @param kettleTrans 转换 + * @return 转换集合 + */ + public List selectKettleTransList(KettleTrans kettleTrans); + + /** + * 新增转换 + * + * @param kettleTrans 转换 + * @return 结果 + */ + public AjaxResult insertKettleTrans(KettleTrans kettleTrans); + + /** + * 修改转换 + * + * @param kettleTrans 转换 + * @return 结果 + */ + public int updateKettleTrans(KettleTrans kettleTrans); + + /** + * 批量删除转换 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteKettleTransByIds(String ids); + + /** + * 删除转换信息 + * + * @param id 转换ID + * @return 结果 + */ + public int deleteKettleTransById(Long id); + /** + * @Description:立即执行一次转换 + * @Author: Kone.wang + * @Date: 2021/7/15 14:31 + * @param trans : + * @return: void + **/ + AjaxResult run(KettleTrans trans); + + List queryTransLog(KettleTrans trans) ; + /** + * @Description:设置定时执行转换 + * @Author: Kone.wang + * @Date: 2021/7/21 14:59 + * @param id: + * @param transName: + * @return: com.ruoyi.common.core.domain.AjaxResult + **/ + public AjaxResult runTransQuartz(String id,String transName); + + Long checkQuartzExist(String checkStr); +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/service/IXRepositoryService.java b/bps-kettle/src/main/java/com/ruoyi/kettle/service/IXRepositoryService.java new file mode 100644 index 000000000..eca79054a --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/service/IXRepositoryService.java @@ -0,0 +1,69 @@ +package com.ruoyi.kettle.service; + +import java.util.List; + +import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.kettle.domain.XRepository; +import com.ruoyi.kettle.repo.RepoTree; + +/** + * 资源库Service接口 + * + * @author kone + * @date 2021-07-12 + */ +public interface IXRepositoryService +{ + /** + * 查询资源库 + * + * @param id 资源库ID + * @return 资源库 + */ + public XRepository selectXRepositoryById(Long id); + + /** + * 查询资源库列表 + * + * @param xRepository 资源库 + * @return 资源库集合 + */ + public List selectXRepositoryList(XRepository xRepository); + + /** + * 新增资源库 + * + * @param xRepository 资源库 + * @return 结果 + */ + public int insertXRepository(XRepository xRepository); + + /** + * 修改资源库 + * + * @param xRepository 资源库 + * @return 结果 + */ + public int updateXRepository(XRepository xRepository); + + /** + * 批量删除资源库 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteXRepositoryByIds(String ids); + + /** + * 删除资源库信息 + * + * @param id 资源库ID + * @return 结果 + */ + public int deleteXRepositoryById(Long id); + + List selectRepoTree(Long id,String type); + + List selectRepoRoot(XRepository repository); +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/service/impl/KettleJobServiceImpl.java b/bps-kettle/src/main/java/com/ruoyi/kettle/service/impl/KettleJobServiceImpl.java new file mode 100644 index 000000000..2a1451d99 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/service/impl/KettleJobServiceImpl.java @@ -0,0 +1,176 @@ +package com.ruoyi.kettle.service.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.security.PermissionUtils; +import com.ruoyi.kettle.domain.KettleTrans; +import com.ruoyi.kettle.domain.XRepository; +import com.ruoyi.kettle.mapper.XRepositoryMapper; +import com.ruoyi.kettle.tools.KettleUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.kettle.mapper.KettleJobMapper; +import com.ruoyi.kettle.domain.KettleJob; +import com.ruoyi.kettle.service.IKettleJobService; +import com.ruoyi.common.core.text.Convert; + +/** + * 作业调度Service业务层处理 + * + * @author kone + * @date 2021-07-22 + */ +@Service("kettleJobServiceImpl") +public class KettleJobServiceImpl implements IKettleJobService +{ + @Autowired + private KettleJobMapper kettleJobMapper; + @Autowired + private XRepositoryMapper repositoryMapper; + + + @Autowired + private KettleUtil kettleUtil; + /** + * 查询作业调度 + * + * @param id 作业调度ID + * @return 作业调度 + */ + @Override + public KettleJob selectKettleJobById(Long id) + { + return kettleJobMapper.selectKettleJobById(id); + } + + /** + * 查询作业调度列表 + * + * @param kettleJob 作业调度 + * @return 作业调度 + */ + @Override + public List selectKettleJobList(KettleJob kettleJob) + { + Object o=PermissionUtils.getPrincipalProperty("roles"); + List roleList=new ArrayList<>(); + // roleList= (List) PermissionUtils.getPrincipalProperty("roles"); + if(o != null && o instanceof List){ + for(Object r:(List)o){ + roleList.add(SysRole.class.cast(r)); + } + } //当前用户的roleKey + List roleKeys=roleList.stream().map(SysRole::getRoleKey).collect(Collectors.toList()); + return kettleJobMapper.selectKettleJobList(kettleJob,roleKeys); + } + + /** + * 新增作业调度 + * + * @param kettleJob 作业调度 + * @return 结果 + */ + @Override + public AjaxResult insertKettleJob(KettleJob kettleJob) + { + String jobName=kettleJob.getJobName(); + if(kettleJobMapper.selectJobByNameAndRepoId(jobName,kettleJob.getJobRepositoryId())>0){ + return AjaxResult.error("已存在同名作业"); + } + String userName = (String) PermissionUtils.getPrincipalProperty("userName"); + if(kettleJob.getRoleKey()==null){ + kettleJob.setRoleKey("admin"); + }else{ + if(!kettleJob.getRoleKey().contains("admin")){ + kettleJob.setRoleKey(kettleJob.getRoleKey().concat(",admin")); + } + } + kettleJob.setCreatedBy(userName); + kettleJob.setUpdateBy(userName); + kettleJob.setJobType("File"); + return AjaxResult.success(kettleJobMapper.insertKettleJob(kettleJob)); + } + + /** + * 修改作业调度 + * + * @param kettleJob 作业调度 + * @return 结果 + */ + @Override + public int updateKettleJob(KettleJob kettleJob) + { + kettleJob.setUpdateTime(DateUtils.getNowDate()); + return kettleJobMapper.updateKettleJob(kettleJob); + } + + /** + * 删除作业调度对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteKettleJobByIds(String ids) + { + return kettleJobMapper.deleteKettleJobByIds(Convert.toStrArray(ids)); + } + + /** + * 删除作业调度信息 + * + * @param id 作业调度ID + * @return 结果 + */ + @Override + public int deleteKettleJobById(Long id) + { + return kettleJobMapper.deleteKettleJobById(id); + } + + @Override + public AjaxResult run(KettleJob job) { + Long id = job.getId(); + KettleJob kettleJob = kettleJobMapper.selectKettleJobById(id); + if(kettleJob ==null){ + return AjaxResult.error("作业不存在!"); + } + XRepository repository=repositoryMapper.selectXRepositoryById(kettleJob.getJobRepositoryId()); + if(repository==null){ + return AjaxResult.error("资源库不存在!"); + } + String path = kettleJob.getJobPath(); + try { + kettleUtil.KETTLE_LOG_LEVEL=kettleJob.getJobLogLevel(); + kettleUtil.KETTLE_REPO_ID=String.valueOf(kettleJob.getJobRepositoryId()); + kettleUtil.KETTLE_REPO_NAME=repository.getRepoName(); + kettleUtil.KETTLE_REPO_PATH=repository.getBaseDir(); + kettleUtil.callJob(path,kettleJob.getJobName(),null,null); + } catch (Exception e) { + e.printStackTrace(); + } + + + return AjaxResult.success("执行成功!"); } + + @Override + public List queryJobLog(KettleJob kettleJob) { + List logs=kettleJobMapper.queryJobLog(kettleJob.getJobName()); + return logs; + } + + @Override + public Long checkQuartzExist(String checkStr) { + return kettleJobMapper.checkQuartzExist(checkStr); + } + @Override + public AjaxResult runJobQuartz(String id, String jobName) { + KettleJob kettleJob = kettleJobMapper.selectKettleJobById(Long.valueOf(id)); + return run(kettleJob); + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/service/impl/KettleTransServiceImpl.java b/bps-kettle/src/main/java/com/ruoyi/kettle/service/impl/KettleTransServiceImpl.java new file mode 100644 index 000000000..499236de8 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/service/impl/KettleTransServiceImpl.java @@ -0,0 +1,217 @@ +package com.ruoyi.kettle.service.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.security.PermissionUtils; +import com.ruoyi.kettle.domain.XRepository; +import com.ruoyi.kettle.mapper.XRepositoryMapper; +import com.ruoyi.kettle.service.IKettleTransService; +import com.ruoyi.kettle.tools.KettleUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.kettle.mapper.KettleTransMapper; +import com.ruoyi.kettle.domain.KettleTrans; +import com.ruoyi.common.core.text.Convert; + +/** + * 转换Service业务层处理 + * + * @author kone + * @date 2021-07-14 + */ +@Service("kettleTransServiceImpl") +public class KettleTransServiceImpl implements IKettleTransService +{ + @Autowired + private KettleTransMapper kettleTransMapper; + @Autowired + private XRepositoryMapper repositoryMapper; + + @Autowired + private KettleUtil kettleUtil; + + /** + * 查询转换 + * + * @param id 转换ID + * @return 转换 + */ + @Override + public KettleTrans selectKettleTransById(Long id) + { + return kettleTransMapper.selectKettleTransById(id); + } + + /** + * 查询转换列表 + * + * @param kettleTrans 转换 + * @return 转换 + */ + @Override + public List selectKettleTransList(KettleTrans kettleTrans) + { + Object o=PermissionUtils.getPrincipalProperty("roles"); + List roleList=new ArrayList<>(); + // roleList= (List) PermissionUtils.getPrincipalProperty("roles"); + if(o != null && o instanceof List){ + for(Object r:(List)o){ + roleList.add(SysRole.class.cast(r)); + } + } + + //当前用户的roleKey + List roleKeys=roleList.stream().map(SysRole::getRoleKey).collect(Collectors.toList()); + + return kettleTransMapper.selectKettleTransList(kettleTrans,roleKeys); + } + + /** + * 新增转换 + * + * @param kettleTrans 转换 + * @return 结果 + */ + @Override + public AjaxResult insertKettleTrans(KettleTrans kettleTrans) + { + String transName=kettleTrans.getTransName(); + if(kettleTransMapper.selectKettleTransByTransName(transName)>0){ + return AjaxResult.error("已存在同名转换"); + } + String userName = (String) PermissionUtils.getPrincipalProperty("userName"); + if(kettleTrans.getRoleKey()==null){ + kettleTrans.setRoleKey("admin"); + }else{ + if(!kettleTrans.getRoleKey().contains("admin")){ + kettleTrans.setRoleKey(kettleTrans.getRoleKey().concat(",admin")); + } + } + kettleTrans.setCreatedBy(userName); + kettleTrans.setUpdateBy(userName); + kettleTrans.setTransType("File"); + return AjaxResult.success(kettleTransMapper.insertKettleTrans(kettleTrans)); + } + + /** + * 修改转换 + * + * @param kettleTrans 转换 + * @return 结果 + */ + @Override + public int updateKettleTrans(KettleTrans kettleTrans) + { + String userName = (String) PermissionUtils.getPrincipalProperty("userName"); + kettleTrans.setUpdateBy(userName); + kettleTrans.setUpdateTime(DateUtils.getNowDate()); + kettleTrans.setTransType("File"); + if(kettleTrans.getRoleKey()==null){ + kettleTrans.setRoleKey("admin"); + }else{ + if(!kettleTrans.getRoleKey().contains("admin")){ + kettleTrans.setRoleKey(kettleTrans.getRoleKey().concat(",admin")); + } + } return kettleTransMapper.updateKettleTrans(kettleTrans); + } + + /** + * 删除转换对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteKettleTransByIds(String ids) + { + return kettleTransMapper.deleteKettleTransByIds(Convert.toStrArray(ids)); + } + + /** + * 删除转换信息 + * + * @param id 转换ID + * @return 结果 + */ + @Override + public int deleteKettleTransById(Long id) + { + return kettleTransMapper.deleteKettleTransById(id); + } + + + /** + * @Description:立即执行一次转换 + * @Author: Kone.wang + * @Date: 2021/7/15 14:31 + * @param trans : + * @return: void + **/ + @Override + public AjaxResult run(KettleTrans trans) { + Long id = trans.getId(); + KettleTrans kettleTrans = kettleTransMapper.selectKettleTransById(id); + if(kettleTrans ==null){ + return AjaxResult.error("转换不存在!"); + } + XRepository repository=repositoryMapper.selectXRepositoryById(kettleTrans.getTransRepositoryId()); + if(repository==null){ + return AjaxResult.error("资源库不存在!"); + } + String path = kettleTrans.getTransPath(); + try { + kettleUtil.KETTLE_LOG_LEVEL=kettleTrans.getTransLogLevel(); + kettleUtil.KETTLE_REPO_ID=String.valueOf(kettleTrans.getTransRepositoryId()); + kettleUtil.KETTLE_REPO_NAME=repository.getRepoName(); + kettleUtil.KETTLE_REPO_PATH=repository.getBaseDir(); + kettleUtil.callTrans(path,kettleTrans.getTransName(),null,null); + } catch (Exception e) { + e.printStackTrace(); + } + + + return AjaxResult.success("执行成功!"); + } + /** + * @Description:查询抓换执行日志 + * @Author: Kone.wang + * @Date: 2021/7/28 16:24 + * @param kettleTrans: + * @return: java.util.List + **/ + @Override + public List queryTransLog(KettleTrans kettleTrans) { + List transLogs=kettleTransMapper.queryTransLog(kettleTrans.getTransName()); + return transLogs; + } + /** + * @Description:设置定时执行转换 + * @Author: Kone.wang + * @Date: 2021/7/21 14:59 + * @param id: + * @param transName: + * @return: com.ruoyi.common.core.domain.AjaxResult + **/ + @Override + public AjaxResult runTransQuartz(String id, String transName) { + KettleTrans kettleTrans = kettleTransMapper.selectKettleTransById(Long.valueOf(id)); + return run(kettleTrans); + } + /** + * @Description:检查该转换是否设置了定时任务 + * @Author: Kone.wang + * @Date: 2021/7/21 16:37 + * @param checkStr: + * @return: int + **/ + @Override + public Long checkQuartzExist(String checkStr) { + + return kettleTransMapper.checkQuartzExist(checkStr); + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/service/impl/XRepositoryServiceImpl.java b/bps-kettle/src/main/java/com/ruoyi/kettle/service/impl/XRepositoryServiceImpl.java new file mode 100644 index 000000000..d103612c3 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/service/impl/XRepositoryServiceImpl.java @@ -0,0 +1,249 @@ +package com.ruoyi.kettle.service.impl; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; + +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.security.PermissionUtils; +import com.ruoyi.kettle.repo.RepoTree; +import com.ruoyi.kettle.repo.RepositoryTree; +import com.ruoyi.kettle.repo.XRepoManager; +import com.ruoyi.kettle.tools.KettleUtil_2; +import org.pentaho.di.core.exception.KettleException; +import org.pentaho.di.repository.RepositoryDirectoryInterface; +import org.pentaho.di.repository.filerep.KettleFileRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.kettle.mapper.XRepositoryMapper; +import com.ruoyi.kettle.domain.XRepository; +import com.ruoyi.kettle.service.IXRepositoryService; +import com.ruoyi.common.core.text.Convert; +import org.springframework.util.CollectionUtils; + +/** + * 资源库Service业务层处理 + * + * @author kone + * @date 2021-07-12 + */ +@Service +public class XRepositoryServiceImpl implements IXRepositoryService +{ + @Autowired + private XRepositoryMapper xRepositoryMapper; + + /** + * 查询资源库 + * + * @param id 资源库ID + * @return 资源库 + */ + @Override + public XRepository selectXRepositoryById(Long id) + { + return xRepositoryMapper.selectXRepositoryById(id); + } + + /** + * 查询资源库列表 + * + * @param xRepository 资源库 + * @return 资源库 + */ + @Override + public List selectXRepositoryList(XRepository xRepository) + { + return xRepositoryMapper.selectXRepositoryList(xRepository); + } + + /** + * 新增资源库 + * + * @param xRepository 资源库 + * @return 结果 + */ + @Override + public int insertXRepository(XRepository xRepository) + { + String userName = (String) PermissionUtils.getPrincipalProperty("userName"); + xRepository.setCreatedBy(userName); + xRepository.setUpdateBy(userName); + xRepository.setType("File"); + return xRepositoryMapper.insertXRepository(xRepository); + } + + /** + * 修改资源库 + * + * @param xRepository 资源库 + * @return 结果 + */ + @Override + public int updateXRepository(XRepository xRepository) + { + String userName = (String) PermissionUtils.getPrincipalProperty("userName"); + xRepository.setUpdateTime(DateUtils.getNowDate()); + xRepository.setUpdateBy(userName); + + return xRepositoryMapper.updateXRepository(xRepository); + } + + /** + * 删除资源库对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteXRepositoryByIds(String ids) + { + return xRepositoryMapper.updateIsDelBatch(Convert.toStrArray(ids)); + // return xRepositoryMapper.deleteXRepositoryByIds(Convert.toStrArray(ids)); + } + + /** + * 删除资源库信息 + * + * @param id 资源库ID + * @return 结果 + */ + @Override + public int deleteXRepositoryById(Long id) + { + return xRepositoryMapper.updateIsDel(id); + //return xRepositoryMapper.deleteXRepositoryById(id); + } + + @Override + public List selectRepoRoot(XRepository repository) { + List repositoryList = xRepositoryMapper.selectXRepositoryList(repository); + List ztrees = initZtree2(repositoryList); + return ztrees; + } + + @Override + public List selectRepoTree(Long id,String type) { + XRepository xrs = xRepositoryMapper.selectXRepositoryById(id); + List repositoryTrees = getRepoTress(xrs,type); + List subTrees = new ArrayList<>(); + String pId=String.valueOf(xrs.getId()); +// try +// { + +// repositoryTrees.forEach(item -> { +// if (item.getParent().equals(pId)) { +// if (item.isLasted()) { +// if (!StringUtils.isEmpty(type)) { +// if (item.getType().indexOf(type) != -1) { +// subTrees.add(item); +// } +// } else { +// subTrees.add(item); +// } +// +// } else { +// subTrees.add(item); +// } +// }}); +// }catch (Exception e) +// { +// StringWriter sw = new StringWriter(); +// e.printStackTrace(new PrintWriter(sw)); +// //throw new UserDefinedException(BaseResultConstant.UNKNOW_EXCEPTION, sw.toString().substring(0, 800)); +// } + + List ztrees = initZtree(repositoryTrees,String.valueOf(id)); + return ztrees; + } + + + public List initZtree(List repositoryList ,String parentId) + { + + List ztrees = new ArrayList(); + for (RepositoryTree rt : repositoryList) { + if(rt.getId().equals(parentId) || rt.getText().equals("/")){ + continue; + } + RepoTree ztree = new RepoTree(); + ztree.setId(rt.getId()); + ztree.setpId(rt.getParent()); + ztree.setName(rt.getText()); + ztree.setTitle(rt.getPath()); + ztrees.add(ztree); + } + return ztrees; + } + public List initZtree2(List repositoryList ) + { + + List ztrees = new ArrayList(); + for (XRepository rt : repositoryList) + { + RepoTree ztree = new RepoTree(); + ztree.setId(String.valueOf(rt.getId())); + ztree.setpId(" "); + ztree.setName(rt.getRepoName()); + ztree.setTitle(rt.getBaseDir()); + ztrees.add(ztree); + } + return ztrees; + } + private List getRepoTress(XRepository xr,String jobortrans) { + List repositoryTrees = new ArrayList<>(); + List xRepositoryList =xRepositoryMapper.selectXRepositoryList(xr); + + if (!CollectionUtils.isEmpty(xRepositoryList)) { + xRepositoryList.forEach(item -> { + List tmpRepositoryList = new ArrayList<>(); + String type = item.getType(); + + if (type.equalsIgnoreCase("File")) { + // 文件库 + String baseDir = item.getBaseDir(); + + try { + KettleFileRepository repository = (KettleFileRepository) KettleUtil_2. + conFileRep(String.valueOf(item.getId()), item.getRepoName(), baseDir); + XRepoManager.getAllDirectoryTreeList(String.valueOf(item.getId()), repository, "/", tmpRepositoryList,jobortrans); + if (tmpRepositoryList.size() > 0) { + RepositoryDirectoryInterface rDirectory = repository.loadRepositoryDirectoryTree().findDirectory("/"); + RepositoryTree repositoryTree = new RepositoryTree(); + repositoryTree.setParent(String.valueOf(item.getId())); + repositoryTree.setId(item.getRepoId() + "@" + rDirectory.getObjectId().toString()); + //repositoryTree.setId(String.valueOf(item.getId())); + + repositoryTree.setText(rDirectory.getName().equals("\\/") ? "基础路径" : rDirectory.getName()); + repositoryTree.setLasted(false); + repositoryTree.setType("tree"); + repositoryTree.setPath("file"); + tmpRepositoryList.add(repositoryTree); + } + + } catch (KettleException e) { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + // throw new UserDefinedException(BaseResultConstant.UNKNOW_EXCEPTION, sw.toString().substring(0, 800)); + } + } + + +// RepositoryTree repositoryTree; +// repositoryTree = new RepositoryTree(); +// repositoryTree.setParent("99"); +// repositoryTree.setId(String.valueOf(item.getId())); +// repositoryTree.setText(item.getRepoName()); +// repositoryTree.setLasted(false); +// repositoryTree.setType(type); +// repositoryTree.setPath("repo"); +// tmpRepositoryList.add(repositoryTree); + repositoryTrees.addAll(tmpRepositoryList); + }); + } + + return repositoryTrees; + } + +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/tools/Constant.java b/bps-kettle/src/main/java/com/ruoyi/kettle/tools/Constant.java new file mode 100644 index 000000000..cad202178 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/tools/Constant.java @@ -0,0 +1,151 @@ +package com.ruoyi.kettle.tools; + + +import org.apache.commons.lang.StringUtils; +import org.pentaho.di.core.Const; +import org.pentaho.di.core.logging.LogLevel; + +import java.io.FileInputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +public class Constant extends Const { + public static final String VERSION = "7.1.0.0-12"; + public static final String DEFAULT_ENCODING = "UTF-8"; + public static final String DEFAULT_TIMEZONE = "GMT+8"; + public static final String UKETTLE = "resource/xtl.properties"; + public static final String VARIABLE_JOB_ID = "GLOBAL_JOB_ID"; + public static final String VARIABLE_TRANS_ID = "GLOBAL_TRANS_ID"; + public static final String VARIABLE_JOB_MONITOR_ID = "GLOBAL_JOB_MONITOR_ID"; + public static final String VARIABLE_TRANS_MONITOR_ID = "GLOBAL_TRANS_MONITOR_ID"; + public static final String DEFAULT_REPO_ID = "1326379690046259200"; + public static final String TYPE_JOB = "job"; + public static final String TYPE_TRANS = "transformation"; + public static final String JOB_FILE_TYPE = "file"; + public static final String JOB_REPO_TYPE = "db"; + public static final String TRANS_FILE_TYPE = "file"; + public static final String TRANS_REPO_TYPE = "db"; + public static final String TYPE_JOB_SUFFIX = ".kjb"; + public static final String TYPE_TRANS_SUFFIX = ".ktr"; + public static final String STARTS_WITH_USD = "$"; + public static final String STARTS_WITH_PARAM = "-param:"; + public static final String SPLIT_PARAM = "-param:"; + public static final String SPLIT_EQUAL = "="; + public static final String SPLIT_USD = "$"; + public static final String KETTLE_REPO = "repo"; + public static final String JOB_PREFIX = "JOB"; + public static final String JOB_GROUP_PREFIX = "JOB_GROUP"; + public static final String TRIGGER_PREFIX = "TRIGGER"; + public static final String TRIGGER_GROUP_PREFIX = "TRIGGER_GROUP"; + public static final String QUARTZ_SEPARATE = "@"; + public static final String RUNSTATUS_SEPARATE = "-"; + public static String KETTLE_HOME; + public static String KETTLE_PLUGIN; + public static String KETTLE_SCRIPT; + public static LogLevel KETTLE_LOGLEVEL; + public static Properties props; + + public Constant() { + } + + public static String get(String key) { + return props.getProperty(key); + } + + public static void set(Properties p) { + props = p; + } + + public static Properties readProperties() { + Properties p = new Properties(); + + try { + p.load(new FileInputStream(Constant.class.getResource("/").getPath().replace("%20", " ") + "resource/xtl.properties")); + } catch (Exception var2) { + var2.printStackTrace(); + } + + return p; + } + + public static LogLevel logger(int level) { + LogLevel logLevel = null; + if ("3".equals(level + "")) { + logLevel = LogLevel.BASIC; + } else if ("4".equals(level + "")) { + logLevel = LogLevel.DETAILED; + } else if ("1".equals(level + "")) { + logLevel = LogLevel.ERROR; + } else if ("5".equals(level + "")) { + logLevel = LogLevel.DEBUG; + } else if ("2".equals(level + "")) { + logLevel = LogLevel.MINIMAL; + } else if ("6".equals(level + "")) { + logLevel = LogLevel.ROWLEVEL; + } else if ("0".endsWith(level + "")) { + logLevel = LogLevel.NOTHING; + } else { + logLevel = KETTLE_LOGLEVEL; + } + + return logLevel; + } + + public static LogLevel logger(String code) { + LogLevel logLevel = null; + if ("Basic".equalsIgnoreCase(code)) { + logLevel = LogLevel.BASIC; + } else if ("Detail".equalsIgnoreCase(code)) { + logLevel = LogLevel.DETAILED; + } else if ("Error".equalsIgnoreCase(code)) { + logLevel = LogLevel.ERROR; + } else if ("Debug".equalsIgnoreCase(code)) { + logLevel = LogLevel.DEBUG; + } else if ("Minimal".equalsIgnoreCase(code)) { + logLevel = LogLevel.MINIMAL; + } else if ("Rowlevel".equalsIgnoreCase(code)) { + logLevel = LogLevel.ROWLEVEL; + } else if ("Nothing".equalsIgnoreCase(code)) { + logLevel = LogLevel.NOTHING; + } + + return logLevel; + } + + private static String uKettle() { + String classPath = Constant.class.getResource("/").getPath().replace("%20", " "); + String iQuartz = ""; + String index = "WEB-INF"; + if (classPath.indexOf("target") > 0) { + index = "target"; + } + + if ("\\".equals(FILE_SEPARATOR)) { + iQuartz = classPath.substring(1, classPath.indexOf(index)); + iQuartz = iQuartz.replace("/", "\\"); + } + + if ("/".equals(FILE_SEPARATOR)) { + iQuartz = classPath.substring(0, classPath.indexOf(index)); + iQuartz = iQuartz.replace("\\", "/"); + } + + return iQuartz; + } + + public static Map getQuartzBasic(String name, String path) { + Map quartzBasic = new HashMap(); + StringBuilder jobName = new StringBuilder(); + jobName.append("JOB").append("@").append(name).append("@").append(path); + StringBuilder jobGroupName = new StringBuilder(); + jobGroupName.append("JOB_GROUP").append("@").append("@").append(name).append("@").append(path); + String triggerName = StringUtils.replace(jobName.toString(), "JOB", "TRIGGER"); + String triggerGroupName = StringUtils.replace(jobGroupName.toString(), "JOB_GROUP", "TRIGGER_GROUP"); + quartzBasic.put("jobName", jobName.toString()); + quartzBasic.put("jobGroupName", jobGroupName.toString()); + quartzBasic.put("triggerName", triggerName); + quartzBasic.put("triggerGroupName", triggerGroupName); + return quartzBasic; + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/tools/DateHelper.java b/bps-kettle/src/main/java/com/ruoyi/kettle/tools/DateHelper.java new file mode 100644 index 000000000..9ee790282 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/tools/DateHelper.java @@ -0,0 +1,16 @@ +package com.ruoyi.kettle.tools; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class DateHelper { + public DateHelper() { + } + + public static String format(Date date) { + String strDate = ""; + SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.s"); + strDate = formatter.format(date); + return strDate; + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/tools/GenCodeUtil.java b/bps-kettle/src/main/java/com/ruoyi/kettle/tools/GenCodeUtil.java new file mode 100644 index 000000000..5fda8aab4 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/tools/GenCodeUtil.java @@ -0,0 +1,108 @@ +package com.ruoyi.kettle.tools; + + +import java.lang.management.ManagementFactory; +import java.net.InetAddress; +import java.net.NetworkInterface; + +public class GenCodeUtil { + private static final long TWEPOCH = 1288834974657L; + private static final long WORKER_ID_BITS = 5L; + private static final long DATACENTER_ID_BITS = 5L; + private static final long MAX_WORKER_ID = 31L; + private static final long MAX_DATACENTER_ID = 31L; + private static final long SEQUENCE_BITS = 12L; + private static final long WORKER_ID_SHIFT = 12L; + private static final long DATACENTER_ID_SHIFT = 17L; + private static final long TIMESTAMP_LEFT_SHIFT = 22L; + private static final long SEQUENCE_MASK = 4095L; + private static long lastTimestamp = -1L; + private static long sequence = 0L; + private static long workerId; + private static long datacenterId; + + public GenCodeUtil() { + datacenterId = getDatacenterId(31L); + workerId = getMaxWorkerId(datacenterId, 31L); + } + + public GenCodeUtil(long workerId, long datacenterId) { + if (workerId <= 31L && workerId >= 0L) { + if (datacenterId <= 31L && datacenterId >= 0L) { + GenCodeUtil.workerId = workerId; + GenCodeUtil.datacenterId = datacenterId; + } else { + throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", 31L)); + } + } else { + throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", 31L)); + } + } + + public static synchronized String nextId() { + long timestamp = timeGen(); + if (timestamp < lastTimestamp) { + throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); + } else { + if (lastTimestamp == timestamp) { + sequence = sequence + 1L & 4095L; + if (sequence == 0L) { + timestamp = tilNextMillis(lastTimestamp); + } + } else { + sequence = 0L; + } + + lastTimestamp = timestamp; + long nextId = timestamp - 1288834974657L << 22 | datacenterId << 17 | workerId << 12 | sequence; + return String.valueOf(nextId); + } + } + + private static long tilNextMillis(long lastTimestamp) { + long timestamp; + for(timestamp = timeGen(); timestamp <= lastTimestamp; timestamp = timeGen()) { + } + + return timestamp; + } + + private static long timeGen() { + return System.currentTimeMillis(); + } + + protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) { + StringBuffer mpid = new StringBuffer(); + mpid.append(datacenterId); + String name = ManagementFactory.getRuntimeMXBean().getName(); + if (!name.isEmpty()) { + mpid.append(name.split("@")[0]); + } + + return (long)(mpid.toString().hashCode() & '\uffff') % (maxWorkerId + 1L); + } + + protected static long getDatacenterId(long maxDatacenterId) { + long id = 0L; + + try { + InetAddress ip = InetAddress.getLocalHost(); + NetworkInterface network = NetworkInterface.getByInetAddress(ip); + if (network == null) { + id = 1L; + } else { + byte[] mac = network.getHardwareAddress(); + id = (255L & (long)mac[mac.length - 1] | 65280L & (long)mac[mac.length - 2] << 8) >> 6; + id %= maxDatacenterId + 1L; + } + } catch (Exception var7) { + System.out.println(" getDatacenterId: " + var7.getMessage()); + } + + return id; + } + + public static void main(String[] args) { + System.out.println(nextId()); + } +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/tools/KettleUtil.java b/bps-kettle/src/main/java/com/ruoyi/kettle/tools/KettleUtil.java new file mode 100644 index 000000000..c94960847 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/tools/KettleUtil.java @@ -0,0 +1,332 @@ +package com.ruoyi.kettle.tools; + +import com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder; +import org.pentaho.di.core.KettleEnvironment; +import org.pentaho.di.core.database.DatabaseMeta; +import org.pentaho.di.core.exception.KettleException; +import org.pentaho.di.core.logging.*; +import org.pentaho.di.core.util.EnvUtil; +import org.pentaho.di.core.variables.VariableSpace; +import org.pentaho.di.core.variables.Variables; +import org.pentaho.di.job.Job; +import org.pentaho.di.job.JobMeta; +import org.pentaho.di.repository.RepositoryDirectoryInterface; +import org.pentaho.di.repository.filerep.KettleFileRepository; +import org.pentaho.di.repository.filerep.KettleFileRepositoryMeta; +import org.pentaho.di.trans.Trans; +import org.pentaho.di.trans.TransMeta; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Component; + +import java.util.Iterator; +import java.util.Map; +@Component +public class KettleUtil { + public static final Logger log = LoggerFactory.getLogger(KettleUtil.class); + + + public String KETTLE_LOG_LEVEL = "basic"; + public String KETTLE_REPO_ID = "2"; + public String KETTLE_REPO_NAME = "koneTest"; + public String KETTLE_REPO_DESC = "DESC"; + public String KETTLE_REPO_PATH = "D:\\etl"; + + /** + * 执行文件资源库转换 + * @param transPath 转换路径(相对于资源库) + * @param transName 转换名称(不需要后缀) + * @param namedParams 命名参数 + * @param clParams 命令行参数 + */ + public void callTrans(String transPath, String transName, Map namedParams, String[] clParams) throws Exception { + KettleEnv.init(); + DatabaseMeta databaseMeta=new DatabaseMeta("kettle_trans_log", "mysql", "Native(JDBC)", + "xxx.xxx.x.xx","bps?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8", "3306", "root", "password"); + + String msg; + KettleFileRepository repo = this.fileRepositoryCon(); + TransMeta transMeta = this.loadTrans(repo, transPath, transName); + + transMeta.addDatabase(databaseMeta); + VariableSpace space=new Variables(); + TransLogTable jobLogTable= TransLogTable.getDefault(space,transMeta,null); + jobLogTable.setTableName("kettle_trans_log"); + jobLogTable.setConnectionName("kettle_trans_log"); + transMeta.setTransLogTable(jobLogTable); + //transMeta.getTransLogTable().setTableName(repInitialization.transLog); + //转换 + Trans trans = new Trans(transMeta); + //设置命名参数 + if(null != namedParams) { + //namedParams.forEach(trans::setParameterValue); + /*for (Map.Entry entry : namedParams.entrySet()) { + trans.setParameterValue(entry.getKey(), entry.getValue()); + }*/ + for(Iterator> it = namedParams.entrySet().iterator(); it.hasNext();){ + Map.Entry entry = it.next(); + trans.setParameterValue(entry.getKey(), entry.getValue()); + } + } + trans.setLogLevel(this.getLogerLevel(KETTLE_LOG_LEVEL)); + //执行 + trans.execute(clParams); + trans.waitUntilFinished(); + + KettleLogStore.discardLines(trans.getLogChannelId(),true); + + //记录日志 + String logChannelId = trans.getLogChannelId(); + LoggingBuffer appender = KettleLogStore.getAppender(); + String logText = appender.getBuffer(logChannelId, true).toString(); + log.info("[logTextlogText:"+logText+":logTextlogText]"); + //抛出异常 + if (trans.getErrors() > 0) { + msg = "There are errors during transformation exception!(转换过程中发生异常)"; + log.error(msg); + throw new Exception(msg); + } + } + + /** + * 执行文件资源库job + * @param jobName + * @throws Exception + */ + public boolean callJob(String jobPath, String jobName, Map variables, String[] clParams) throws Exception { + KettleEnv.init(); + String msg; + DatabaseMeta databaseMeta=new DatabaseMeta("kettle_job_log", "mysql", "Native(JDBC)", + "xxx.xxx.x.xx","bps?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8", "3306", "root", "password"); + KettleFileRepository repo = this.fileRepositoryCon(); + JobMeta jobMeta = this.loadJob(repo, jobPath, jobName); + jobMeta.addDatabase(databaseMeta); + VariableSpace space=new Variables(); + space.setVariable("test","fromDbName"); + JobLogTable jobLogTable= JobLogTable.getDefault(space,jobMeta); + jobLogTable.setTableName("kettle_job_log"); + jobLogTable.setConnectionName("kettle_job_log"); + jobMeta.setJobLogTable(jobLogTable); + + Job job = new Job(repo, jobMeta); + //向Job 脚本传递参数,脚本中获取参数值:${参数名} + if(null != variables) { + for(Iterator> it = variables.entrySet().iterator(); it.hasNext();){ + Map.Entry entry = it.next(); + job.setVariable(entry.getKey(), entry.getValue()); + } + } + //设置日志级别 + job.setLogLevel(this.getLogerLevel(KETTLE_LOG_LEVEL)); + job.setArguments(clParams); + job.start(); + job.waitUntilFinished(); + //记录日志 + String logChannelId = job.getLogChannelId(); + LoggingBuffer appender = KettleLogStore.getAppender(); + String logText = appender.getBuffer(logChannelId, true).toString(); + log.info(logText); + if (job.getErrors() > 0) { + msg = "There are errors during job exception!(执行job发生异常)"; + log.error(msg); + throw new Exception(msg); + } + return true; + } + + /** + * 加载转换 + * @param repo kettle文件资源库 + * @param transPath 相对路径 + * @param transName 转换名称 + */ + public TransMeta loadTrans(KettleFileRepository repo, String transPath, String transName) throws Exception{ + String msg; + RepositoryDirectoryInterface dir = repo.findDirectory(transPath);//根据指定的字符串路径找到目录 + if(null == dir){ + msg = "kettle资源库转换路径不存在【"+repo.getRepositoryMeta().getBaseDirectory()+transPath+"】!"; + throw new Exception(msg); + } + TransMeta transMeta = repo.loadTransformation(repo.getTransformationID(transName, dir), null); + if(null == transMeta){ + msg = "kettle资源库【"+dir.getPath()+"】不存在该转换【"+transName+"】!"; + throw new Exception(msg); + } + return transMeta; + } + + + + + + + + /** + * 加载job + * @param repo kettle文件资源库 + * @param jobPath 相对路径 + * @param jobName job名称 + */ + private JobMeta loadJob(KettleFileRepository repo, String jobPath, String jobName) throws Exception{ + String msg; + RepositoryDirectoryInterface dir = repo.findDirectory(jobPath);//根据指定的字符串路径找到目录 + if(null == dir){ + msg = "kettle资源库Job路径不存在【"+repo.getRepositoryMeta().getBaseDirectory()+jobPath+"】!"; + throw new Exception(msg); + } + JobMeta jobMeta = repo.loadJob(repo.getJobId(jobName, dir), null); + if(null == jobMeta){ + msg = "kettle资源库【"+dir.getPath()+"】不存在该转换【"+jobName+"】!"; + throw new Exception(msg); + } + return jobMeta; + } + + /** + * 调用trans文件 带参数的 + */ + public void callNativeTransWithParams(String[] params, String transName) throws Exception { + // 初始化 + KettleEnvironment.init(); + EnvUtil.environmentInit(); + TransMeta transMeta = new TransMeta(transName); + //转换 + Trans trans = new Trans(transMeta); + //执行 + trans.execute(params); + //等待结束 + trans.waitUntilFinished(); + //抛出异常 + if (trans.getErrors() > 0) { + throw new Exception("There are errors during transformation exception!(传输过程中发生异常)"); + } + } + + + + + + /** + * 调用job文件 + * @param jobName + * @throws Exception + */ + public void callNativeJob(String jobName) throws Exception { + // 初始化 + /*KettleEnvironment.init();*/ + + JobMeta jobMeta = new JobMeta(jobName, null); + Job job = new Job(null, jobMeta); + //向Job 脚本传递参数,脚本中获取参数值:${参数名} + //job.setVariable(paraname, paravalue); + //设置日志级别 + job.setLogLevel(this.getLogerLevel(KETTLE_LOG_LEVEL)); + job.start(); + job.waitUntilFinished(); + if (job.getErrors() > 0) { + throw new Exception("There are errors during job exception!(执行job发生异常)"); + } + } + + /** + * 取得kettle的日志级别 + */ + private LogLevel getLogerLevel(String level) { + LogLevel logLevel; + if ("basic".equals(level)) { + logLevel = LogLevel.BASIC; + } else if ("detail".equals(level)) { + logLevel = LogLevel.DETAILED; + } else if ("error".equals(level)) { + logLevel = LogLevel.ERROR; + } else if ("debug".equals(level)) { + logLevel = LogLevel.DEBUG; + } else if ("minimal".equals(level)) { + logLevel = LogLevel.MINIMAL; + } else if ("rowlevel".equals(level)) { + logLevel = LogLevel.ROWLEVEL; + } else if ("nothing".endsWith(level)){ + logLevel = LogLevel.NOTHING; + }else { + logLevel = null; + } + return logLevel; + } + + /** + * 配置kettle文件库资源库环境 + **/ + public KettleFileRepository fileRepositoryCon() throws KettleException { + String msg; + //初始化 + /*EnvUtil.environmentInit(); + KettleEnvironment.init();*/ + + //资源库元对象 + KettleFileRepositoryMeta fileRepositoryMeta = new KettleFileRepositoryMeta(this.KETTLE_REPO_ID, this.KETTLE_REPO_NAME, this.KETTLE_REPO_DESC, this.KETTLE_REPO_PATH); + // 文件形式的资源库 + KettleFileRepository repo = new KettleFileRepository(); + repo.init(fileRepositoryMeta); + //连接到资源库 + repo.connect("", "");//默认的连接资源库的用户名和密码 + + if (repo.isConnected()) { + msg = "kettle文件库资源库【" + KETTLE_REPO_PATH + "】连接成功"; + log.info(msg); + return repo; + } else { + msg = "kettle文件库资源库【" + KETTLE_REPO_PATH + "】连接失败"; + log.error(msg); + throw new KettleException(msg); + } + } + + // 调用Transformation示例 + public static void runTrans(String filename) { + try { + KettleEnvironment.init(); + TransMeta transMeta = new TransMeta(filename); + Trans trans = new Trans(transMeta); + trans.execute(null);// 执行转换 + trans.waitUntilFinished(); // 等待转换执行结束 + if (trans.getErrors() != 0) { + System.out.println("Error"); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /** + * Kettle环境初始化. + */ + public static class KettleEnv { + public static void init(){ + try { + KettleEnvironment.init(); + EnvUtil.environmentInit(); + log.info("Kettle环境初始化成功"); + }catch (Exception e){ + e.printStackTrace(); + log.error("Kettle环境初始化失败"); + } + + } + } + + /** + * 初始化环境 + */ + public class StartInit implements InitializingBean { + + @Override + public void afterPropertiesSet() throws Exception { + KettleEnv.init(); + + } + + } + + +} diff --git a/bps-kettle/src/main/java/com/ruoyi/kettle/tools/KettleUtil_2.java b/bps-kettle/src/main/java/com/ruoyi/kettle/tools/KettleUtil_2.java new file mode 100644 index 000000000..5b1132613 --- /dev/null +++ b/bps-kettle/src/main/java/com/ruoyi/kettle/tools/KettleUtil_2.java @@ -0,0 +1,736 @@ +package com.ruoyi.kettle.tools; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.kettle.cons.XJobStatus; +import com.ruoyi.kettle.cons.XTransStatus; +import com.ruoyi.kettle.repo.XRepoManager; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.vfs2.FileObject; +import org.pentaho.di.core.Const; +import org.pentaho.di.core.ProgressMonitorListener; +import org.pentaho.di.core.database.Database; +import org.pentaho.di.core.database.DatabaseMeta; +import org.pentaho.di.core.exception.KettleException; +import org.pentaho.di.core.exception.KettleSecurityException; +import org.pentaho.di.core.gui.Point; +import org.pentaho.di.core.gui.Rectangle; +import org.pentaho.di.core.gui.ScrollBarInterface; +import org.pentaho.di.core.gui.SwingGC; +import org.pentaho.di.core.parameters.NamedParams; +import org.pentaho.di.core.variables.VariableSpace; +import org.pentaho.di.core.vfs.KettleVFS; +import org.pentaho.di.job.Job; +import org.pentaho.di.job.JobHopMeta; +import org.pentaho.di.job.JobMeta; +import org.pentaho.di.job.JobPainter; +import org.pentaho.di.job.entries.job.JobEntryJob; +import org.pentaho.di.job.entries.special.JobEntrySpecial; +import org.pentaho.di.job.entries.trans.JobEntryTrans; +import org.pentaho.di.job.entry.JobEntryBase; +import org.pentaho.di.job.entry.JobEntryCopy; +import org.pentaho.di.job.entry.JobEntryInterface; +import org.pentaho.di.repository.*; +import org.pentaho.di.repository.filerep.KettleFileRepositoryMeta; +import org.pentaho.di.repository.kdr.KettleDatabaseRepository; +import org.pentaho.di.trans.Trans; +import org.pentaho.di.trans.TransHopMeta; +import org.pentaho.di.trans.TransMeta; +import org.pentaho.di.trans.TransPainter; +import org.pentaho.di.trans.step.StepInterface; +import org.pentaho.di.trans.step.StepMeta; +import org.pentaho.di.trans.step.StepMetaInterface; +import org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta; +import org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta; +import org.pentaho.metastore.api.IMetaStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.awt.image.BufferedImage; +import java.awt.image.ImageObserver; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class KettleUtil_2 { + private static final Logger log = LoggerFactory.getLogger(KettleUtil_2.class); + public static Map holder = new ConcurrentHashMap(); + + public static Map getHolder() { + return holder; + } + + public static void setHolder(Map holder) { + KettleUtil_2.holder = holder; + } + + public KettleUtil_2() { + } + public static Repository conFileRep(String repoId, String repoName, String baseDirectory) throws KettleException { + if (holder.containsKey(repoId)) { + return (Repository)holder.get(repoId); + } else { + XRepoManager.createFileRep(repoId, repoName, "文件资源库", baseDirectory); + Repository repository = connect(repoId); + if (null != repository) { + holder.put(repoId, repository); + return repository; + } else { + return null; + } + } + } + public static Repository connect(String repoId) throws KettleSecurityException, KettleException { + return connect(repoId, (String)null, (String)null); + } + + public static Repository connect(String repoId, String username, String password) throws KettleSecurityException, KettleException { + Repository repository = (Repository)XRepoManager.repositoryCache.get(repoId); + if (!repository.isConnected()) { + repository.connect(username, password); + log.info(repository.getName() + "资源库已连接!"); + } + + return repository; + } + /*public static Repository conByJndi(String repoId, String name, String db, String type, String kuser, String kpass) throws Exception { + testConnect(repoId); + if (holder.containsKey(repoId)) { + return (Repository)holder.get(repoId); + } else { + XRepoManager.createDBRepByJndi(repoId, name, type, db); + Repository repository = connect(repoId, kuser, kpass); + if (null != repository) { + holder.put(repoId, repository); + return repository; + } else { + return null; + } + } + } + + + + public static Repository conByNative(String repoId, String repoName, String name, String type, String host, String port, String db, String user, String pass, String kuser, String kpass) throws KettleException { + testConnect(repoId); + if (holder.containsKey(repoId)) { + return (Repository)holder.get(repoId); + } else { + XRepoManager.createDBRepByDesc(repoId, repoName, "资源库", name, type, "Native", host, db, port, user, pass); + Repository repository = connect(repoId, kuser, kpass); + if (null != repository) { + holder.put(repoId, repository); + return repository; + } else { + return null; + } + } + } + + public static DatabaseMeta createDatabaseMeta(String name, String type, String access, String host, String dbName, String port, String user, String pass, boolean replace, Repository repository) { + return XRepoManager.createDatabaseMeta(name, type, access, host, dbName, port, user, pass, (Map)null, replace, repository); + } + + public static DatabaseMeta createDatabaseMeta(String name, String type, String access, String host, String dbName, String port, String user, String pass, Map params, Repository repository) { + return XRepoManager.createDatabaseMeta(name, type, access, host, dbName, port, user, pass, params, false, repository); + } + + public static Repository conByParams(String repoId, String repoName, JSONObject params, String name, String type, String access, String host, String db, String port, String user, String pass, String kuser, String kpass) throws Exception { + testConnect(repoId); + if (holder.containsKey(repoId)) { + return (Repository)holder.get(repoId); + } else { + XRepoManager.createDBRepByParams(repoId, repoName, params, name, type, access, host, db, port, user, pass); + Repository repository = connect(repoId, kuser, kpass); + if (null != repository) { + holder.put(repoId, repository); + return repository; + } else { + return null; + } + } + } + + + + public static void setRepository(Repository repository) { + } + + public static void destroy(String id) { + XRepoManager.disConnectionRepository(id); + } + + public static void delJob(String repoId, long id_job) throws KettleException { + testConnect(repoId); + delJob(id_job, (Repository)holder.get(repoId)); + } + + private static String calcRelativeElementDirectory(RepositoryDirectoryInterface dir) { + return dir != null ? dir.getPath() : "/"; + } + + private static String calcDirectoryName(String repoId, RepositoryDirectoryInterface dir) { + testConnect(repoId); + StringBuilder directory = new StringBuilder(); + KettleFileRepositoryMeta repositoryMeta = (KettleFileRepositoryMeta)((Repository)holder.get(repoId)).getRepositoryMeta(); + String baseDir = repositoryMeta.getBaseDirectory(); + baseDir = Const.replace(baseDir, "\\", "/"); + directory.append(baseDir); + if (!baseDir.endsWith("/")) { + directory.append("/"); + } + + if (dir != null) { + String path = calcRelativeElementDirectory(dir); + if (path.startsWith("/")) { + directory.append(path.substring(1)); + } else { + directory.append(path); + } + + if (!path.endsWith("/")) { + directory.append("/"); + } + } + + return directory.toString(); + } + + public static void delFileJob(String repoId, String jobId) throws KettleException { + String path = jobId.substring(0, jobId.lastIndexOf("/")); + String jobName = jobId.substring(jobId.lastIndexOf("/") + 1); + RepositoryDirectoryInterface repositoryDirectoryInterface = ((Repository)holder.get(repoId)).findDirectory(path); + String filename = calcFilename(repoId, repositoryDirectoryInterface, jobName); + deleteFile(filename); + } + + private static String calcFilename(String repoId, RepositoryDirectoryInterface repositoryDirectoryInterface, String jobName) { + return calcDirectoryName(repoId, (RepositoryDirectoryInterface)null) + repositoryDirectoryInterface.getPath() + "/" + jobName; + } + + private static void deleteFile(String filename) throws KettleException { + try { + FileObject fileObject = KettleVFS.getFileObject(filename); + fileObject.delete(); + } catch (Exception var2) { + throw new KettleException("Unable to delete file with name [" + filename + "]", var2); + } + } + + public static void delJob(long id_job, Repository repository) throws KettleException { + repository.deleteJob(new LongObjectId(id_job)); + } + + public static void delTrans(String repoId, long id_job) throws KettleException { + testConnect(repoId); + delTrans(id_job, (Repository)holder.get(repoId)); + } + + public static void delTrans(long id_job, Repository repository) throws KettleException { + repository.deleteTransformation(new LongObjectId(id_job)); + } + + public static JobMeta loadJob(String repoId, long jobId) throws KettleException { + testConnect(repoId); + return ((Repository)holder.get(repoId)).loadJob(new LongObjectId(jobId), (String)null); + } + + public static JobMeta loadJob(String repoId, String jobId) throws KettleException { + testConnect(repoId); + return ((Repository)holder.get(repoId)).loadJob(new StringObjectId(jobId), (String)null); + } + + public static JobMeta loadJob(String repoId, String jobname, String directory) throws KettleException { + testConnect(repoId); + return loadJob(jobname, directory, (Repository)holder.get(repoId)); + } + + public static JobMeta loadJob(String jobname, String directory, Repository repository) throws KettleException { + RepositoryDirectoryInterface dir = repository.findDirectory(directory); + return repository.loadJob(jobname, dir, (ProgressMonitorListener)null, (String)null); + } + + public static JobMeta loadJob(String repoId, String jobname, long directory) throws KettleException { + testConnect(repoId); + return loadJob(jobname, directory, (Repository)holder.get(repoId)); + } + + public static JobMeta loadJob(String jobname, long directory, Repository repository) throws KettleException { + RepositoryDirectoryInterface dir = repository.findDirectory(new LongObjectId(directory)); + return repository.loadJob(jobname, dir, (ProgressMonitorListener)null, (String)null); + } + + public static TransMeta loadTrans(String repoId, long id) throws KettleException { + testConnect(repoId); + return ((Repository)holder.get(repoId)).loadTransformation(new LongObjectId(id), (String)null); + } + + public static TransMeta loadTrans(String repoId, String transname, String directory) throws KettleException { + testConnect(repoId); + return loadTrans(transname, directory, (Repository)holder.get(repoId)); + } + + public static TransMeta loadTrans(String transname, String directory, Repository repository) throws KettleException { + RepositoryDirectoryInterface dir = repository.findDirectory(directory); + return repository.loadTransformation(transname, dir, (ProgressMonitorListener)null, true, (String)null); + } + + public static TransMeta loadTrans(String repoId, JobMeta jobMeta, String teansName) throws KettleException { + JobEntryTrans trans = (JobEntryTrans)jobMeta.findJobEntry(teansName).getEntry(); + TransMeta transMeta = loadTrans(repoId, trans.getTransname(), trans.getDirectory()); + return transMeta; + } + + public static T loadJobEntry(String repoId, JobMeta jobMeta, String jobEntryName, T jobEntryMeta) throws KettleException { + return loadJobEntry(repoId, jobMeta.findJobEntry(jobEntryName).getEntry().getObjectId(), jobEntryMeta); + } + + public static T loadJobEntry(String repoId, ObjectId entryId, T jobEntryMeta) throws KettleException { + testConnect(repoId); + jobEntryMeta.loadRep((Repository)holder.get(repoId), (IMetaStore)null, entryId, (List)null, (List)null); + jobEntryMeta.setObjectId(entryId); + return jobEntryMeta; + } + + public static JobEntrySpecial findStart(JobMeta jobMeta) { + for(int i = 0; i < jobMeta.nrJobEntries(); ++i) { + JobEntryCopy jec = jobMeta.getJobEntry(i); + JobEntryInterface je = jec.getEntry(); + if (je.getPluginId().equals("SPECIAL")) { + return (JobEntrySpecial)je; + } + } + + return null; + } + + public static void saveRepositoryElement(String repoId, RepositoryElementInterface repositoryElement) throws KettleException { + testConnect(repoId); + saveRepositoryElement((Repository)holder.get(repoId), repositoryElement); + } + + public static void saveRepositoryElement(Repository repository, RepositoryElementInterface repositoryElement) throws KettleException { + repository.save(repositoryElement, (String)null, (ProgressMonitorListener)null, true); + } + + public static void saveTrans(String repoId, TransMeta transMeta) throws KettleException { + testConnect(repoId); + saveRepositoryElement((Repository)((Repository)holder.get(repoId)), transMeta); + } + + public static void saveTrans(Repository repository, TransMeta transMeta) throws KettleException { + saveRepositoryElement((Repository)repository, transMeta); + } + + public static void saveJob(String repoId, JobMeta jobMeta) throws KettleException { + testConnect(repoId); + saveRepositoryElement((Repository)((Repository)holder.get(repoId)), jobMeta); + } + + public static void saveJob(Repository repository, JobMeta jobMeta) throws KettleException { + saveRepositoryElement((Repository)repository, jobMeta); + } + + public static boolean isDirectoryExist(Repository repository, String directoryName) { + try { + RepositoryDirectoryInterface dir = repository.findDirectory(directoryName); + return dir != null; + } catch (KettleException var3) { + log.error("判断job目录是否存在失败!", var3); + return false; + } + } + + public static RepositoryDirectoryInterface getOrMakeDirectory(String repoId, String parentDirectory, String directoryName) throws KettleException { + testConnect(repoId); + RepositoryDirectoryInterface parent = ((Repository)holder.get(repoId)).findDirectory(parentDirectory); + if (StringUtils.isBlank(parentDirectory)) { + parent = ((Repository)holder.get(repoId)).findDirectory("/"); + } + + if (StringUtils.isNotBlank(directoryName)) { + RepositoryDirectoryInterface dir = ((Repository)holder.get(repoId)).findDirectory(parentDirectory + "/" + directoryName); + return dir == null ? ((Repository)holder.get(repoId)).createRepositoryDirectory(parent, directoryName) : dir; + } else { + return parent; + } + } + + public static RepositoryDirectoryInterface makeDirs(String repoId, String directoryName) throws KettleException { + if (!StringUtils.isNotBlank(directoryName)) { + return null; + } else { + String parentDirectory = ""; + String[] dirArr = directoryName.replace("\\", "/").split("/"); + String[] var6 = dirArr; + int var5 = dirArr.length; + + for(int var4 = 0; var4 < var5; ++var4) { + String dirStr = var6[var4]; + + try { + if (StringUtils.isNotBlank(dirStr)) { + RepositoryDirectoryInterface p = getOrMakeDirectory(repoId, parentDirectory, dirStr); + parentDirectory = p.getPath(); + } + } catch (Exception var9) { + log.error("创建目录失败:" + directoryName + "," + parentDirectory + "," + dirStr, var9); + } + } + + return getOrMakeDirectory(repoId, parentDirectory, (String)null); + } + } + + public static String getDirectory(String repoId, long dirId) throws KettleException { + return getDirectory(repoId, new LongObjectId(dirId)); + } + + public static String getDirectory(String repoId, ObjectId dirId) throws KettleException { + testConnect(repoId); + RepositoryDirectoryInterface dir = ((Repository)holder.get(repoId)).findDirectory(dirId); + return dir == null ? null : dir.getPath(); + } + + public static void setStepToTrans(TransMeta teans, String stepName, StepMetaInterface smi) { + StepMeta step = teans.findStep(stepName); + step.setStepMetaInterface(smi); + } + + public static void setStepToTransAndSave(String repoId, TransMeta teans, String stepName, StepMetaInterface smi) throws KettleException { + setStepToTrans(teans, stepName, smi); + saveTrans(repoId, teans); + } + + public static void jobStopAll(Job job) { + job.stopAll(); + JobMeta jobMeta = job.getJobMeta(); + Iterator var3 = jobMeta.getJobCopies().iterator(); + + while(var3.hasNext()) { + JobEntryCopy jec = (JobEntryCopy)var3.next(); + if (jec.isTransformation()) { + JobEntryTrans jet = (JobEntryTrans)jec.getEntry(); + if (jet.getTrans() != null) { + jet.getTrans().stopAll(); + } + } else if (jec.isJob()) { + JobEntryJob jej = (JobEntryJob)jec.getEntry(); + if (jej.getJob() != null) { + jobStopAll(jej.getJob()); + } + } + } + + } + + public static void jobKillAll(Job job) { + job.stopAll(); + JobMeta jobMeta = job.getJobMeta(); + Iterator var3 = jobMeta.getJobCopies().iterator(); + + while(var3.hasNext()) { + JobEntryCopy jec = (JobEntryCopy)var3.next(); + if (jec.isTransformation()) { + JobEntryTrans jet = (JobEntryTrans)jec.getEntry(); + if (jet.getTrans() != null) { + jet.getTrans().killAll(); + } + } else if (jec.isJob()) { + JobEntryJob jej = (JobEntryJob)jec.getEntry(); + if (jej.getJob() != null) { + jobKillAll(jej.getJob()); + } + } + } + + if (!job.getState().equals(Thread.State.BLOCKED) && !job.getState().equals(Thread.State.TIMED_WAITING)) { + job.interrupt(); + } else { + job.stop(); + } + + } + + public static void transCopy(Map param, Repository fromRepository, Repository toRepository) throws KettleException { + String jobName = param.get("transName") + ""; + String jobPath = param.get("transPath") + ""; + String newName = param.get("newName") + ""; + String newPath = param.get("newPath") + ""; + String des = param.get("transDescription") + ""; + TransMeta jobMeta = loadTrans(jobName, jobPath, fromRepository); + new TransMeta(); + jobMeta.setName(newName); + jobMeta.setDescription(des); + jobMeta.setRepositoryDirectory(makeDirs(param.get("repoId") + "", newPath)); + saveTrans(toRepository, jobMeta); + } + + public static void jobCopy(Map param, Repository fromRepository, Repository toRepository) throws KettleException { + String jobName = param.get("jobName") + ""; + String jobPath = param.get("jobPath") + ""; + String newName = param.get("newName") + ""; + String newPath = param.get("newPath") + ""; + String des = param.get("jobDescription") + ""; + JobMeta jobMeta = loadJob(jobName, jobPath, fromRepository); + jobMeta.setName(newName); + jobMeta.setDescription(des); + jobMeta.setRepositoryDirectory(makeDirs(param.get("repoId") + "", newPath)); + saveJob(toRepository, jobMeta); + } + + public static void jobCopy(String jobName, String jobPath, Repository fromRepository, Repository toRepository) throws KettleException { + JobMeta jobMeta = loadJob(jobName, jobPath, fromRepository); + Iterator var6 = jobMeta.getJobCopies().iterator(); + + while(var6.hasNext()) { + JobEntryCopy jec = (JobEntryCopy)var6.next(); + if (jec.isTransformation()) { + JobEntryTrans jet = (JobEntryTrans)jec.getEntry(); + transCopy(jet.getObjectName(), jet.getDirectory(), fromRepository, toRepository); + } else if (jec.isJob()) { + JobEntryJob jej = (JobEntryJob)jec.getEntry(); + jobCopy(jej.getObjectName(), jej.getDirectory(), fromRepository, toRepository); + } + } + + jobMeta.setRepository(toRepository); + jobMeta.setMetaStore(toRepository.getMetaStore()); + if (!isDirectoryExist(toRepository, jobPath)) { + toRepository.createRepositoryDirectory(toRepository.findDirectory("/"), jobPath); + } + + saveJob(toRepository, jobMeta); + } + + public static void transCopy(String transName, String transPath, Repository fromRepository, Repository toRepository) throws KettleException { + TransMeta tm = loadTrans(transName, transPath, fromRepository); + Iterator var6 = tm.getSteps().iterator(); + + while(var6.hasNext()) { + StepMeta sm = (StepMeta)var6.next(); + if (sm.isJobExecutor()) { + JobExecutorMeta jem = (JobExecutorMeta)sm.getStepMetaInterface(); + jobCopy(jem.getJobName(), jem.getDirectoryPath(), fromRepository, toRepository); + } else if (sm.getStepMetaInterface() instanceof TransExecutorMeta) { + TransExecutorMeta te = (TransExecutorMeta)sm.getStepMetaInterface(); + transCopy(te.getTransName(), te.getDirectoryPath(), fromRepository, toRepository); + } + } + + if (!isDirectoryExist(toRepository, transPath)) { + toRepository.createRepositoryDirectory(toRepository.findDirectory("/"), transPath); + } + + tm.setRepository(toRepository); + tm.setMetaStore(toRepository.getMetaStore()); + saveTrans(toRepository, tm); + } + + public static ObjectId getJobId(String repoId, JobMeta jm) { + return getJobId(repoId, jm.getName(), jm.getRepositoryDirectory()); + } + + public static ObjectId getJobId(String repoId, String name, RepositoryDirectoryInterface repositoryDirectory) { + try { + testConnect(repoId); + return ((Repository)holder.get(repoId)).getJobId(name, repositoryDirectory); + } catch (KettleException var4) { + log.info("获取作业id失败", var4); + return null; + } + } + + public static ObjectId getTransformationID(String repoId, TransMeta tm) { + return getTransformationID(repoId, tm.getName(), tm.getRepositoryDirectory()); + } + + public static ObjectId getTransformationID(String repoId, String name, RepositoryDirectoryInterface repositoryDirectory) { + try { + testConnect(repoId); + return ((Repository)holder.get(repoId)).getTransformationID(name, repositoryDirectory); + } catch (KettleException var4) { + log.info("获取转换id失败", var4); + return null; + } + } + + public static void repairTransHop(TransMeta tm) { + for(int i = 0; i < tm.nrTransHops(); ++i) { + TransHopMeta hop = tm.getTransHop(i); + hop.setFromStep(tm.findStep(hop.getFromStep().getName())); + hop.setToStep(tm.findStep(hop.getToStep().getName())); + } + + } + + public static void setParams(NamedParams target, NamedParams source, Map params) { + target.eraseParameters(); + + try { + String[] var6; + int var5 = (var6 = source.listParameters()).length; + + for(int var4 = 0; var4 < var5; ++var4) { + String key = var6[var4]; + String defaultVal = source.getParameterDefault(key); + if (params.containsKey(key)) { + defaultVal = (String)params.get(key); + } + + target.addParameterDefinition(key, defaultVal, source.getParameterDescription(key)); + } + } catch (Exception var8) { + log.error("保存JOB失败", var8); + } + + } + + public static void repairHop(JobMeta jm) { + Iterator var2 = jm.getJobhops().iterator(); + + while(var2.hasNext()) { + JobHopMeta hop = (JobHopMeta)var2.next(); + hop.setFromEntry(jm.findJobEntry(hop.getFromEntry().getName())); + hop.setToEntry(jm.findJobEntry(hop.getToEntry().getName())); + } + + } + + public static String getProp(VariableSpace vs, String key) { + String value = vs.environmentSubstitute("${" + key + "}"); + return value.startsWith("${") ? "" : value; + } + + public static JSONObject getPropJSONObject(VariableSpace vs, String key) { + String value = getProp(vs, key); + return StringUtils.isNotBlank(value) ? JSON.parseObject(value) : null; + } + + public static Job getRootJob(Job rootjob) { + while(rootjob != null && rootjob.getParentJob() != null) { + rootjob = rootjob.getParentJob(); + } + + return rootjob; + } + + public static Job getRootJob(JobEntryBase jee) { + Job rootjob = jee.getParentJob(); + return getRootJob(rootjob); + } + + public static Job getRootJob(StepInterface si) { + Job rootjob = si.getTrans().getParentJob(); + return getRootJob(rootjob); + } + + public static String getRootJobId(JobEntryBase jee) { + return getRootJob(jee).getObjectId().getId(); + } + + public static String getRootJobId(StepInterface si) { + Job rootjob = getRootJob(si); + return rootjob != null ? rootjob.getObjectId().getId() : null; + } + + public static String getRootJobName(StepInterface si) { + Job rootjob = getRootJob(si); + return rootjob != null ? rootjob.getObjectName() : null; + } + + public static BufferedImage generateTransformationImage(TransMeta transMeta) throws Exception { + float magnification = 1.0F; + Point maximum = transMeta.getMaximum(); + maximum.multiply(magnification); + SwingGC gc = new SwingGC((ImageObserver)null, maximum, 32, 0, 0); + TransPainter transPainter = new TransPainter(gc, transMeta, maximum, (ScrollBarInterface)null, (ScrollBarInterface)null, (TransHopMeta)null, (Point)null, (Rectangle)null, new ArrayList(), new ArrayList(), 32, 1, 0, 0, true, "Arial", 10); + transPainter.setMagnification(magnification); + transPainter.buildTransformationImage(); + BufferedImage image = (BufferedImage)gc.getImage(); + return image; + } + + public static BufferedImage generateJobImage(JobMeta jobMeta) throws Exception { + float magnification = 1.0F; + Point maximum = jobMeta.getMaximum(); + maximum.multiply(magnification); + SwingGC gc = new SwingGC((ImageObserver)null, maximum, 32, 0, 0); + JobPainter jobPainter = new JobPainter(gc, jobMeta, maximum, (ScrollBarInterface)null, (ScrollBarInterface)null, (JobHopMeta)null, (Point)null, (Rectangle)null, new ArrayList(), new ArrayList(), 32, 1, 0, 0, true, "Arial", 10); + jobPainter.setMagnification(magnification); + jobPainter.drawJob(); + BufferedImage image = (BufferedImage)gc.getImage(); + return image; + } + + public static XJobStatus getJobStatus(Job job) { + String status = job.getStatus(); + if (status.indexOf("errors") > -1) { + return XJobStatus.FAILED; + } else if (status.equals("Waiting")) { + return XJobStatus.PENDING; + } else if (status.equals("Halting")) { + return XJobStatus.HALTING; + } else if (status.equals("Running")) { + return XJobStatus.RUNNING; + } else if (status.equals("Stopped")) { + return XJobStatus.STOPPED; + } else { + return status.equalsIgnoreCase("Finished") ? XJobStatus.FINISHED : XJobStatus.UNKNOWN; + } + } + + public static XTransStatus getTransStatus(Trans trans) { + String status = trans.getStatus(); + if (status.indexOf("errors") > -1) { + return XTransStatus.FAILED; + } else if (status.equals("Waiting")) { + return XTransStatus.WAITING; + } else if (status.equals("Halting")) { + return XTransStatus.HALTING; + } else if (status.equals("Running")) { + return XTransStatus.RUNNING; + } else if (status.equals("Stopped")) { + return XTransStatus.STOPPED; + } else if (status.equals("Finished")) { + return XTransStatus.FINISHED; + } else if (status.equals("Paused")) { + return XTransStatus.PAUSED; + } else if (status.contains("Preparing")) { + return XTransStatus.PREPARING; + } else { + return status.equals("Initializing") ? XTransStatus.INITIALIZING : XTransStatus.UNKNOWN; + } + } + + private static void testConnect(String repoId) { + Repository repository = (Repository)holder.get(repoId); + if (repository instanceof KettleDatabaseRepository) { + KettleDatabaseRepository kettleDatabaseRepository = (KettleDatabaseRepository)repository; + Database database = kettleDatabaseRepository.getDatabase(); + Connection connection = database.getConnection(); + + try { + if (connection.isClosed()) { + holder.remove(repoId); + log.info("当前数据库连接已经关闭,准备重新连接......."); + DatabaseMeta databaseMeta = (DatabaseMeta)XRepoManager.databaseMeta.get("databaseMeta"); + XRepoManager.createDBRepByDesc(repoId, repository.getName(), "资源库", databaseMeta.getName(), databaseMeta.getDatabaseTypeDesc(), "Native", databaseMeta.getHostname(), databaseMeta.getDatabaseName(), databaseMeta.getDatabasePortNumberString(), databaseMeta.getUsername(), databaseMeta.getPassword()); + kettleDatabaseRepository = (KettleDatabaseRepository)connect(repoId, "admin", "admin"); + if (null != repository) { + holder.put(repoId, kettleDatabaseRepository); + } + } + } catch (SQLException var6) { + log.error("数据库重连出现异常,{}", var6); + } catch (KettleException var7) { + log.error("数据库重连出现异常,{}", var7); + } + } + + }*/ +} diff --git a/bps-kettle/src/main/resources/mapper/kettle/KettleJobMapper.xml b/bps-kettle/src/main/resources/mapper/kettle/KettleJobMapper.xml new file mode 100644 index 000000000..324cb0b46 --- /dev/null +++ b/bps-kettle/src/main/resources/mapper/kettle/KettleJobMapper.xml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select id, created_time, update_time, created_by, update_by, job_name, job_description, job_type, job_path, job_repository_id, job_log_level, job_status, is_del, is_monitor_enabled, role_key, tpl_key from kettle_job + + + + + + + + + insert into kettle_job + + created_time, + update_time, + created_by, + update_by, + job_name, + job_description, + job_type, + job_path, + job_repository_id, + job_log_level, + job_status, + is_del, + is_monitor_enabled, + role_key, + tpl_key, + + + #{createdTime}, + #{updateTime}, + #{createdBy}, + #{updateBy}, + #{jobName}, + #{jobDescription}, + #{jobType}, + #{jobPath}, + #{jobRepositoryId}, + #{jobLogLevel}, + #{jobStatus}, + #{isDel}, + #{isMonitorEnabled}, + #{roleKey}, + #{tplKey}, + + + + + update kettle_job + + created_time = #{createdTime}, + update_time = #{updateTime}, + created_by = #{createdBy}, + update_by = #{updateBy}, + job_name = #{jobName}, + job_description = #{jobDescription}, + job_type = #{jobType}, + job_path = #{jobPath}, + job_repository_id = #{jobRepositoryId}, + job_log_level = #{jobLogLevel}, + job_status = #{jobStatus}, + is_del = #{isDel}, + is_monitor_enabled = #{isMonitorEnabled}, + role_key = #{roleKey}, + tpl_key = #{tplKey}, + + where id = #{id} + + + + delete from kettle_job where id = #{id} + + + + delete from kettle_job where id in + + #{id} + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/mapper/kettle/KettleTransMapper.xml b/bps-kettle/src/main/resources/mapper/kettle/KettleTransMapper.xml new file mode 100644 index 000000000..4e562a405 --- /dev/null +++ b/bps-kettle/src/main/resources/mapper/kettle/KettleTransMapper.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select id, trans_name, trans_description, created_time, update_time, created_by, update_by, trans_type, trans_path, trans_repository_id, trans_log_level, trans_status, is_del, is_monitor_enabled, tpl_key, role_key, remark from kettle_trans + + + + + + + + + + + insert into kettle_trans + + trans_name, + trans_description, + created_time, + update_time, + created_by, + update_by, + trans_type, + trans_path, + trans_repository_id, + trans_log_level, + trans_status, + is_del, + is_monitor_enabled, + tpl_key, + role_key, + remark, + + + #{transName}, + #{transDescription}, + #{createdTime}, + #{updateTime}, + #{createdBy}, + #{updateBy}, + #{transType}, + #{transPath}, + #{transRepositoryId}, + #{transLogLevel}, + #{transStatus}, + #{isDel}, + #{isMonitorEnabled}, + #{tplKey}, + #{roleKey}, + #{remark}, + + + + + update kettle_trans + + trans_name = #{transName}, + trans_description = #{transDescription}, + created_time = #{createdTime}, + update_time = #{updateTime}, + created_by = #{createdBy}, + update_by = #{updateBy}, + trans_type = #{transType}, + trans_path = #{transPath}, + trans_repository_id = #{transRepositoryId}, + trans_log_level = #{transLogLevel}, + trans_status = #{transStatus}, + is_del = #{isDel}, + is_monitor_enabled = #{isMonitorEnabled}, + tpl_key = #{tplKey}, + role_key = #{roleKey}, + remark = #{remark}, + + where id = #{id} + + + + delete from kettle_trans where id = #{id} + + + + delete from kettle_trans where id in + + #{id} + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/mapper/kettle/XRepositoryMapper.xml b/bps-kettle/src/main/resources/mapper/kettle/XRepositoryMapper.xml new file mode 100644 index 000000000..3d82ca3c4 --- /dev/null +++ b/bps-kettle/src/main/resources/mapper/kettle/XRepositoryMapper.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, repo_id, repo_name, repo_username, repo_password, repo_type, db_access, db_host, db_port, db_name, db_username, db_password, is_del, created_time, update_time, created_by, update_by, type, base_dir from kettle_repository + + + + + + + + insert into kettle_repository + + repo_id, + repo_name, + repo_username, + repo_password, + repo_type, + db_access, + db_host, + db_port, + db_name, + db_username, + db_password, + is_del, + created_time, + update_time, + created_by, + update_by, + type, + base_dir, + + + #{repoId}, + #{repoName}, + #{repoUsername}, + #{repoPassword}, + #{repoType}, + #{dbAccess}, + #{dbHost}, + #{dbPort}, + #{dbName}, + #{dbUsername}, + #{dbPassword}, + #{isDel}, + #{createdTime}, + #{updateTime}, + #{createdBy}, + #{updateBy}, + #{type}, + #{baseDir}, + + + + + update kettle_repository + + repo_id = #{repoId}, + repo_name = #{repoName}, + repo_username = #{repoUsername}, + repo_password = #{repoPassword}, + repo_type = #{repoType}, + db_access = #{dbAccess}, + db_host = #{dbHost}, + db_port = #{dbPort}, + db_name = #{dbName}, + db_username = #{dbUsername}, + db_password = #{dbPassword}, + is_del = #{isDel}, + created_time = #{createdTime}, + update_time = #{updateTime}, + created_by = #{createdBy}, + update_by = #{updateBy}, + type = #{type}, + base_dir = #{baseDir}, + + where id = #{id} + + + update kettle_repository set is_del=1 where id = #{id} + + + update kettle_repository set is_del=1 where id IN + + #{id} + + + + delete from kettle_repository where id = #{id} + + + + delete from kettle_repository where id in + + #{id} + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/common/repository_tree.html b/bps-kettle/src/main/resources/templates/kettle/common/repository_tree.html new file mode 100644 index 000000000..c3b637b95 --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/common/repository_tree.html @@ -0,0 +1,88 @@ + + + + + + + + + + + + +
    + + +
    + +
    + 展开 / + 折叠 +
    +
    +
    + + + + + diff --git a/bps-kettle/src/main/resources/templates/kettle/job/add.html b/bps-kettle/src/main/resources/templates/kettle/job/add.html new file mode 100644 index 000000000..13867d1b8 --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/job/add.html @@ -0,0 +1,111 @@ + + + + + + + + + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/job/detail.html b/bps-kettle/src/main/resources/templates/kettle/job/detail.html new file mode 100644 index 000000000..1d95583f9 --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/job/detail.html @@ -0,0 +1,36 @@ + + + + + + +
    +
    + +
    + + +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/job/edit.html b/bps-kettle/src/main/resources/templates/kettle/job/edit.html new file mode 100644 index 000000000..5e55d8886 --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/job/edit.html @@ -0,0 +1,90 @@ + + + + + + + + + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/job/job.html b/bps-kettle/src/main/resources/templates/kettle/job/job.html new file mode 100644 index 000000000..9d2740b65 --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/job/job.html @@ -0,0 +1,160 @@ + + + + + + +
    +
    +
    +
    +
    +
      +
    • + + +
    • + +
    • + + +
    • +
    • +  搜索 +  重置 +
    • +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/quartz/addquartz.html b/bps-kettle/src/main/resources/templates/kettle/quartz/addquartz.html new file mode 100644 index 000000000..f5dc8da71 --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/quartz/addquartz.html @@ -0,0 +1,107 @@ + + + + + + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + +
    +
    +
    + +
    +
    + + +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + diff --git a/bps-kettle/src/main/resources/templates/kettle/quartz/editquartz.html b/bps-kettle/src/main/resources/templates/kettle/quartz/editquartz.html new file mode 100644 index 000000000..46f421948 --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/quartz/editquartz.html @@ -0,0 +1,108 @@ + + + + + + +
    +
    + + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + +
    +
    +
    + +
    +
    + + +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + diff --git a/bps-kettle/src/main/resources/templates/kettle/repository/add.html b/bps-kettle/src/main/resources/templates/kettle/repository/add.html new file mode 100644 index 000000000..e75ef192a --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/repository/add.html @@ -0,0 +1,135 @@ + + + + + + + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + + +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/repository/edit.html b/bps-kettle/src/main/resources/templates/kettle/repository/edit.html new file mode 100644 index 000000000..b175b3bf9 --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/repository/edit.html @@ -0,0 +1,132 @@ + + + + + + + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/repository/repository.html b/bps-kettle/src/main/resources/templates/kettle/repository/repository.html new file mode 100644 index 000000000..a2a66e6db --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/repository/repository.html @@ -0,0 +1,122 @@ + + + + + + +
    +
    +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/trans/add.html b/bps-kettle/src/main/resources/templates/kettle/trans/add.html new file mode 100644 index 000000000..dc470893b --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/trans/add.html @@ -0,0 +1,144 @@ + + + + + + + + + +
    +
    + + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + +
    + +
    + +
    +
    + + + + + + + + + +
    + +
    + +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/trans/detail.html b/bps-kettle/src/main/resources/templates/kettle/trans/detail.html new file mode 100644 index 000000000..c77d55e2c --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/trans/detail.html @@ -0,0 +1,36 @@ + + + + + + +
    +
    + +
    + + +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/trans/edit.html b/bps-kettle/src/main/resources/templates/kettle/trans/edit.html new file mode 100644 index 000000000..36c2f244d --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/trans/edit.html @@ -0,0 +1,105 @@ + + + + + + + + + +
    +
    + + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + +
    +
    + + +
    +
    + + + + + + + \ No newline at end of file diff --git a/bps-kettle/src/main/resources/templates/kettle/trans/trans.html b/bps-kettle/src/main/resources/templates/kettle/trans/trans.html new file mode 100644 index 000000000..6facd12cb --- /dev/null +++ b/bps-kettle/src/main/resources/templates/kettle/trans/trans.html @@ -0,0 +1,165 @@ + + + + + + +
    +
    +
    +
    +
    +
      +
    • + + +
    • + +
    • + + +
    • +
    • +  搜索 +  重置 +
    • +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9a2278801..5aba6fa31 100644 --- a/pom.xml +++ b/pom.xml @@ -161,8 +161,18 @@ org.apache.poi poi-ooxml ${poi.version} + + + org.apache.xmlbeans + xmlbeans + + + + + org.apache.xmlbeans + xmlbeans + 3.1.0 - org.apache.velocity @@ -218,6 +228,25 @@ ${ruoyi.version} + + + com.ruoyi + box-test + ${ruoyi.version} + + + + + com.ruoyi + box-bps + ${ruoyi.version} + + + + com.ruoyi + bps-kettle + ${ruoyi.version} + @@ -228,6 +257,9 @@ ruoyi-quartz ruoyi-generator ruoyi-common + box-test + box-bps + bps-kettle pom @@ -246,6 +278,7 @@ ${java.version} ${java.version} ${project.build.sourceEncoding} + -Xlint:unchecked diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 74855f53e..de11488db 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -8,7 +8,7 @@ 4.6.2 4.0.0 - jar + war ruoyi-admin @@ -49,6 +49,21 @@ mysql-connector-java + + + + com.oracle.database.jdbc + ojdbc6 + 11.2.0.4 + + + + + com.microsoft.sqlserver + mssql-jdbc + 8.4.1.jre8 + + com.ruoyi @@ -67,6 +82,21 @@ ruoyi-generator + + + com.ruoyi + box-test + + + + + com.ruoyi + box-bps + + + com.ruoyi + bps-kettle + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index 00e6f7ea0..f751e33b2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -1,6 +1,8 @@ package com.ruoyi.web.controller.system; import java.util.List; + +import com.ruoyi.system.service.ISysConfigService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -37,6 +39,9 @@ public class SysDeptController extends BaseController @Autowired private ISysDeptService deptService; + @Autowired + ISysConfigService configService; + @RequiresPermissions("system:dept:view") @GetMapping() public String dept() @@ -157,7 +162,7 @@ public class SysDeptController extends BaseController /** * 选择部门树 - * + * * @param deptId 部门ID * @param excludeId 排除ID */ @@ -204,4 +209,17 @@ public class SysDeptController extends BaseController List ztrees = deptService.roleDeptTreeData(role); return ztrees; } + + /** + * Ecology部门信息同步 + */ + @Log(title = "部门同步", businessType = BusinessType.UPDATE) + @RequiresPermissions("system:dept:sync") + @PostMapping("/syncDept") + @ResponseBody + public AjaxResult syncDept() { + String url = "http://192.168.2.85:90/api/hrm/resful/getHrmdepartmentWithPage"; + String params = "{\"params\":{\"pagesize\":999999}}"; + return deptService.syncEcologyDept(url, params); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java index 4ac9fb758..2cb8c985c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java @@ -4,6 +4,9 @@ import java.util.Date; import java.util.List; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.utils.http.HttpUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; @@ -126,6 +129,14 @@ public class SysIndexController extends BaseController @GetMapping("/system/main") public String main(ModelMap mmap) { + JSONObject wordsJson = JSONObject.parseObject(HttpUtils.sendGet("https://v1.jinrishici.com/all.json","")); + JSONObject oneWordJson = JSONObject.parseObject(HttpUtils.sendGet("https://api.xygeng.cn/one","")); + JSONObject oneWordDataJson = JSONObject.parseObject(oneWordJson.getString("data")); + mmap.put("wordsContent",wordsJson.get("content")); + mmap.put("wordsAuthor",wordsJson.get("author")); + mmap.put("wordsOrigin",wordsJson.getString("origin")); + mmap.put("oneWordOrigin",oneWordDataJson.get("origin")); + mmap.put("oneWordContent",oneWordDataJson.get("content")); mmap.put("version", RuoYiConfig.getVersion()); return "main"; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index 1652f74ef..5ee51536b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -2,44 +2,89 @@ package com.ruoyi.web.controller.system; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.utils.http.HttpUtils; +import com.ruoyi.framework.jwt.service.IJwtTokenService; +import com.ruoyi.framework.shiro.util.CustToken; +import com.ruoyi.system.service.IWechatApiService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.subject.Subject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.enums.UserStatus; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.jwt.utils.JwtUtils; +import com.ruoyi.framework.shiro.service.SysPasswordService; +import com.ruoyi.system.service.ISysUserService; + +import java.util.Map; /** * 登录验证 * * @author ruoyi */ +@Api(tags = "生成AccessToken接口") @Controller public class SysLoginController extends BaseController { + @Autowired + private IJwtTokenService jwtTokenService; + + @Autowired + private IWechatApiService wechatApiService; + @GetMapping("/login") - public String login(HttpServletRequest request, HttpServletResponse response) + public String login(HttpServletRequest request, HttpServletResponse response, Map map) { + String loginType= request.getParameter("loginType"); + if(StringUtils.isNotEmpty(loginType) && request.getParameter("loginType").equals("wechat")){ + String code= request.getParameter("code"); + //String state = request.getParameter("state"); + String username=wechatApiService.GetLoginNameWithWechatCode(code); + //如果没有获取到登录名,说明验证失败,跳转登录页 + if(StringUtils.isEmpty(username)){ + return "login"; + } + + String password=""; + map.put("loginType","wechat"); + map.put("username",username); + map.put("password",password); + return "loginwechat"; + + + } + // 如果是Ajax请求,返回Json字符串。 if (ServletUtils.isAjaxRequest(request)) { return ServletUtils.renderString(response, "{\"code\":\"1\",\"msg\":\"未登录或登录超时。请重新登录\"}"); } - return "login"; } @PostMapping("/login") @ResponseBody - public AjaxResult ajaxLogin(String username, String password, Boolean rememberMe) + public AjaxResult ajaxLogin(String username, String password, Boolean rememberMe,String loginType) { - UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe); + // UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe); + CustToken token=new CustToken(username,password,rememberMe,loginType); Subject subject = SecurityUtils.getSubject(); try { @@ -57,6 +102,26 @@ public class SysLoginController extends BaseController } } + @ApiOperation("获取Json格式AccessToken") + @ApiImplicitParams({ + @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class), + @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class), + }) + @PostMapping("/jwt/login") + @ResponseBody + public AjaxResult jwtLogin(String username, String password) + { + return jwtTokenService.AjaxResultJwtToken(username,password); + } + + @ApiOperation("获取String格式AccessToken") + @PostMapping("/jwt/topgplogin") + @ResponseBody + public String topgpJwtLogin(String username, String password) + { + return JSONObject.toJSONString(jwtTokenService.AjaxResultJwtToken(username,password)); + } + @GetMapping("/unauth") public String unauth() { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 9934afb22..cd51e33ff 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -2,6 +2,8 @@ package com.ruoyi.web.controller.system; import java.util.List; import java.util.stream.Collectors; + +import com.ruoyi.system.service.ISysConfigService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -52,6 +54,9 @@ public class SysUserController extends BaseController @Autowired private SysPasswordService passwordService; + @Autowired + private ISysConfigService configService; + @RequiresPermissions("system:user:view") @GetMapping() public String user() @@ -285,4 +290,18 @@ public class SysUserController extends BaseController userService.checkUserAllowed(user); return toAjax(userService.changeStatus(user)); } + + /** + * Ecology人员信息同步 + */ + @Log(title = "人员同步", businessType = BusinessType.UPDATE) + @RequiresPermissions("system:user:sync") + @PostMapping("/syncUser") + @ResponseBody + public AjaxResult syncUser() { + String url = "http://192.168.2.85:90/api/hrm/resful/getHrmUserInfoWithPage"; + String params = "{\"params\":{\"pagesize\":999999}}"; + return userService.syncEcologyUser(url, params); + } + } \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java index 4588a7a53..b609defb0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java @@ -47,7 +47,7 @@ public class TestController extends BaseController } @ApiOperation("获取用户详细") - @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") + @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path",dataTypeClass = Integer.class ) @GetMapping("/{userId}") public AjaxResult getUser(@PathVariable Integer userId) { @@ -63,10 +63,10 @@ public class TestController extends BaseController @ApiOperation("新增用户") @ApiImplicitParams({ - @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer"), - @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String"), - @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String"), - @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String") + @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class), + @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class), + @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class) }) @PostMapping("/save") public AjaxResult save(UserEntity user) @@ -95,7 +95,7 @@ public class TestController extends BaseController } @ApiOperation("删除用户信息") - @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") + @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) @DeleteMapping("/{userId}") public AjaxResult delete(@PathVariable Integer userId) { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java index 0cfbfbadb..0a3f38239 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java @@ -55,9 +55,9 @@ public class SwaggerConfig // 用ApiInfoBuilder进行定制 return new ApiInfoBuilder() // 设置标题 - .title("标题:若依管理系统_接口文档") + .title("BPS管理系统_接口文档") // 描述 - .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") + .description("描述:用于管理系统的各类接口的文档说明。") // 作者信息 .contact(new Contact(RuoYiConfig.getName(), null, null)) // 版本 diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 3c46fd50b..86ea6e820 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -2,20 +2,48 @@ spring: datasource: type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver + #driverClassName: com.mysql.cj.jdbc.Driver druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://192.168.2.18:3306/bps?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: password + password: abc.123 # 从库数据源 slave: # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: + enabled: true + url: jdbc:oracle:thin:@192.168.2.91:1521/toptest + username: ds7 + password: ds7 + driverClassName: oracle.jdbc.OracleDriver + #SQlServer数据源 + sqlsvr: + # 从数据源开关/默认关闭 + enabled: true + url: jdbc:sqlserver://192.168.2.84:1433;SelectMethod=cursor;DatabaseName=ITDemo + username: sa + password: abc.123 + driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver + + # Topprod_ds_report + topproddsreport: + # 从数据源开关/默认关闭 + enabled: true + url: jdbc:oracle:thin:@192.168.2.91:1521/topprod + username: ds_report + password: ds_report + driverClassName: oracle.jdbc.OracleDriver + + # Toptest_ds_report + toptestdsreport: + # 从数据源开关/默认关闭 + enabled: true + url: jdbc:oracle:thin:@192.168.2.91:1521/toptest + username: ds_report + password: ds_report + driverClassName: oracle.jdbc.OracleDriver + # 初始连接数 initialSize: 5 # 最小连接池数量 @@ -43,8 +71,8 @@ spring: allow: url-pattern: /druid/* # 控制台管理用户名和密码 - login-username: ruoyi - login-password: 123456 + login-username: admin + login-password: bps2019 filter: stat: enabled: true diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index b79e9b30f..3ccd384ad 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -9,7 +9,7 @@ ruoyi: # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) - profile: D:/ruoyi/uploadPath + profile: C:/bps-it/uploadPath # 获取ip地址开关 addressEnabled: false @@ -19,7 +19,7 @@ server: port: 80 servlet: # 应用的访问路径 - context-path: / + context-path: /it_war tomcat: # tomcat的URI编码 uri-encoding: UTF-8 @@ -69,6 +69,12 @@ spring: restart: # 热部署开关 enabled: true + #ldap + ldap: + urls: ldap://192.168.2.10:389 + base: OU=bp,DC=bpsemi,DC=com + username: administrator@bpsemi.com + password: Bps@2831! # MyBatis mybatis: @@ -95,7 +101,7 @@ shiro: # 首页地址 indexUrl: /index # 验证码开关 - captchaEnabled: true + captchaEnabled: false # 验证码类型 math 数组计算 char 字符 captchaType: math cookie: @@ -134,3 +140,11 @@ xss: swagger: # 是否开启swagger enabled: true + +#企业微信 +wechat: + corpId: ww4ed3771457e5f463 + agentId: 1000080 + secret: drtHKYabI9_EgjJQ8aqDPTQkY1WUYeWUTMkYw7D_z64 + token: 111 + aesKey: 111 \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/bps.png b/ruoyi-admin/src/main/resources/static/bps.png new file mode 100644 index 000000000..71c4a6854 Binary files /dev/null and b/ruoyi-admin/src/main/resources/static/bps.png differ diff --git a/ruoyi-admin/src/main/resources/static/img/profile.jpg b/ruoyi-admin/src/main/resources/static/img/profile.jpg index b3a940b21..91e9a7a35 100644 Binary files a/ruoyi-admin/src/main/resources/static/img/profile.jpg and b/ruoyi-admin/src/main/resources/static/img/profile.jpg differ diff --git a/ruoyi-admin/src/main/resources/static/ruoyi.png b/ruoyi-admin/src/main/resources/static/ruoyi.png index b0af01fef..74830eba6 100644 Binary files a/ruoyi-admin/src/main/resources/static/ruoyi.png and b/ruoyi-admin/src/main/resources/static/ruoyi.png differ diff --git a/ruoyi-admin/src/main/resources/static/ruoyi1.png b/ruoyi-admin/src/main/resources/static/ruoyi1.png new file mode 100644 index 000000000..b0af01fef Binary files /dev/null and b/ruoyi-admin/src/main/resources/static/ruoyi1.png differ diff --git a/ruoyi-admin/src/main/resources/templates/index-topnav.html b/ruoyi-admin/src/main/resources/templates/index-topnav.html index 1f7975ab7..6225e86bd 100644 --- a/ruoyi-admin/src/main/resources/templates/index-topnav.html +++ b/ruoyi-admin/src/main/resources/templates/index-topnav.html @@ -4,7 +4,7 @@ - 若依系统首页 + BPS管理系统首页 @@ -302,7 +302,7 @@ diff --git a/ruoyi-admin/src/main/resources/templates/index.html b/ruoyi-admin/src/main/resources/templates/index.html index ef861cec4..651e240f1 100644 --- a/ruoyi-admin/src/main/resources/templates/index.html +++ b/ruoyi-admin/src/main/resources/templates/index.html @@ -4,7 +4,7 @@ - 若依系统首页 + BPS管理系统首页 @@ -26,7 +26,8 @@ diff --git a/ruoyi-admin/src/main/resources/templates/login.html b/ruoyi-admin/src/main/resources/templates/login.html index 923665cf6..807382248 100644 --- a/ruoyi-admin/src/main/resources/templates/login.html +++ b/ruoyi-admin/src/main/resources/templates/login.html @@ -3,8 +3,8 @@ - 登录若依系统 - + BPS后台管理系统 + @@ -26,10 +26,10 @@