| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.constant.FtpConstant; |
| | | import org.springblade.common.utils.arg; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.directive.entity.Directive; |
| | | import org.springblade.modules.directive.entity.DirectiveFile; |
| | | import org.springblade.modules.directive.service.DirectiveService; |
| | | import org.springblade.modules.directive.vo.DirectiveVo; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * @param query page,size |
| | | * |
| | | * @param query page,size |
| | | * @param directive 指令信息对象 |
| | | */ |
| | | @GetMapping("/page") |
| | |
| | | |
| | | /** |
| | | * 新增 |
| | | * |
| | | * @param directive 指令信息对象 |
| | | */ |
| | | @PostMapping("/save") |
| | |
| | | |
| | | /** |
| | | * 指令信息新增,同时新增图片到指令文件表中 |
| | | * |
| | | * @param directive 指令信息对象 |
| | | */ |
| | | @PostMapping("/saveDirectiveAndFile") |
| | |
| | | boolean status = false; |
| | | directive.setSendTime(new Date()); |
| | | status = directiveService.save(directive); |
| | | //内网新增 |
| | | arg.test01(arg.url+"/directive/saveDirectiveAndFile",directive); |
| | | if (status){ |
| | | //数据同步 |
| | | String s1 = |
| | | "insert into sys_directive(id,type,send_directive_id,receive_directive_ids,send_time,content) " + |
| | | "values(" + "'" + directive.getId() + "'" + "," + |
| | | "'" + directive.getType() + "'" + "," + |
| | | "'" + directive.getSendDirectiveId() + "'" + "," + |
| | | "'" + directive.getReceiveDirectiveIds() + "'" + "," + |
| | | "'" + directive.getSendTime() + "'" + "," + |
| | | "'" + directive.getContent() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | if (status) { |
| | | //新增图片 |
| | | if (null!=directive.getUrl() && directive.getUrl()!=""){ |
| | | if (null != directive.getUrl() && directive.getUrl() != "") { |
| | | String[] directiveUrl = directive.getUrl().split(","); |
| | | for (String url : directiveUrl) { |
| | | String s = url.substring(26, url.length()); |
| | | String urls = FtpConstant.ip + s; |
| | | DirectiveFile directiveFile = new DirectiveFile(); |
| | | directiveFile.setType(1); |
| | | directiveFile.setDirectiveId(directive.getId()); |
| | | directiveFile.setUrl(url); |
| | | directiveFile.setUrl(urls); |
| | | status = directiveService.saveDirectiveFile(directiveFile); |
| | | if (!status){ |
| | | String s2 = |
| | | "insert into sys_directive_file(id,type,directive_id,url) " + |
| | | "values(" + "'" + directiveFile.getId() + "'" + "," + |
| | | "'" + directiveFile.getType() + "'" + "," + |
| | | "'" + directiveFile.getDirectiveId() + "'" + "," + |
| | | "'" + urls+ "'"+ ")"; |
| | | FtpUtil.sqlFileUpload(s2); |
| | | if (!status) { |
| | | return R.status(false); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 指令信息修改,同时新增图片到指令文件表中 |
| | | * |
| | | * @param directive 指令信息对象 |
| | | */ |
| | | @PostMapping("/updateDirectiveAndFile") |
| | | public R updateDirectiveAndFile(@RequestBody DirectiveVo directive) throws Exception { |
| | | //新增指令信息 |
| | | boolean update = directiveService.updateById(directive); |
| | | //内网同步 |
| | | String s1 = "update sys_directive set type = " + "'" + directive.getType() + "'" + |
| | | ",send_directive_id = " + "'" + directive.getSendDirectiveId() + "'" + |
| | | ",receive_directive_ids = " + "'" + directive.getReceiveDirectiveIds() + "'" + |
| | | ",send_time = " + "'" + directive.getSendTime() + "'" + |
| | | ",content = " + "'" + directive.getContent() + "'" + |
| | | " " + "where id = " + "'" + directive.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | boolean status = false; |
| | | //内网新增 |
| | | arg.test01(arg.url+"/directive/updateDirectiveAndFile",directive); |
| | | if (update){ |
| | | if (update) { |
| | | //先删除图片 |
| | | int i = directiveService.deleleByDirectiveId(directive.getId()); |
| | | //新增图片 |
| | | if (null!=directive.getUrl() && directive.getUrl()!=""){ |
| | | if (null != directive.getUrl() && directive.getUrl() != "") { |
| | | String[] directiveUrl = directive.getUrl().split(","); |
| | | for (String url : directiveUrl) { |
| | | String s = url.substring(26, url.length()); |
| | | String urls = FtpConstant.ip + s; |
| | | DirectiveFile directiveFile = new DirectiveFile(); |
| | | directiveFile.setType(1); |
| | | directiveFile.setDirectiveId(directive.getId()); |
| | | directiveFile.setUrl(url); |
| | | status = directiveService.saveDirectiveFile(directiveFile); |
| | | if (!status){ |
| | | String s2 = |
| | | "insert into sys_directive_file(id,type,directive_id,url) " + |
| | | "values(" + "'" + directiveFile.getId() + "'" + "," + |
| | | "'" + directiveFile.getType() + "'" + "," + |
| | | "'" + directiveFile.getDirectiveId() + "'" + "," + |
| | | "'" + urls + "'"+ ")"; |
| | | FtpUtil.sqlFileUpload(s2); |
| | | if (!status) { |
| | | R.status(false); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param directive 指令信息对象 |
| | | */ |
| | | @PostMapping("/update") |
| | |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * |
| | | * @param directive 指令信息对象 |
| | | */ |
| | | @PostMapping("/submit") |
| | |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param ids 指令信息ids 数组 |
| | | */ |
| | | @PostMapping("/remove") |
| | | public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) { |
| | | //图片也删除 |
| | | if (null!=ids && ids!=""){ |
| | | if (null != ids && ids != "") { |
| | | String[] directiveIds = ids.split(","); |
| | | for (String directiveId : directiveIds) { |
| | | directiveService.deleleByDirectiveId(Long.parseLong(directiveId)); |
| | | } |
| | | } |
| | | //内网删除 |
| | | arg.sendPostRemoveByIds(arg.url+"/directive/remove",ids); |
| | | //arg.sendPostRemoveByIds(arg.url+"/directive/remove",ids); |
| | | return R.status(directiveService.removeByIds(Func.toLongList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | * |
| | | * @param directive 指令信息对象 |
| | | */ |
| | | @GetMapping("/detail") |
| | |
| | | |
| | | /** |
| | | * 自定义详情查询 |
| | | * |
| | | * @param directive 指令信息对象 |
| | | */ |
| | | @GetMapping("/details") |