| | |
| | | import org.springblade.modules.directive.entity.DirectiveFile; |
| | | import org.springblade.modules.directive.service.DirectiveService; |
| | | import org.springblade.modules.directive.vo.DirectiveVo; |
| | | import org.springblade.modules.system.service.MyAsyncService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | |
| | | public class DirectiveController { |
| | | |
| | | private final DirectiveService directiveService; |
| | | private final MyAsyncService myAsyncService; |
| | | |
| | | /** |
| | | * 自定义分页 |
| | |
| | | boolean status = false; |
| | | directive.setSendTime(new Date()); |
| | | status = directiveService.save(directive); |
| | | //数据同步 |
| | | 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){ |
| | | //数据同步 |
| | | 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); |
| | | myAsyncService.dataSync(s1); |
| | | } |
| | | if (status) { |
| | | //新增图片 |
| | | if (null != directive.getUrl() && directive.getUrl() != "") { |
| | |
| | | "'" + directiveFile.getType() + "'" + "," + |
| | | "'" + directiveFile.getDirectiveId() + "'" + "," + |
| | | "'" + urls+ "'"+ ")"; |
| | | FtpUtil.sqlFileUpload(s2); |
| | | //FtpUtil.sqlFileUpload(s2); |
| | | myAsyncService.dataSync(s2); |
| | | if (!status) { |
| | | return R.status(false); |
| | | } |
| | |
| | | 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); |
| | | if (update) { |
| | | //内网同步 |
| | | 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); |
| | | myAsyncService.dataSync(s1); |
| | | } |
| | | boolean status = false; |
| | | if (update) { |
| | | //先删除图片 |
| | |
| | | "'" + directiveFile.getType() + "'" + "," + |
| | | "'" + directiveFile.getDirectiveId() + "'" + "," + |
| | | "'" + urls + "'"+ ")"; |
| | | FtpUtil.sqlFileUpload(s2); |
| | | //FtpUtil.sqlFileUpload(s2); |
| | | myAsyncService.dataSync(s2); |
| | | if (!status) { |
| | | R.status(false); |
| | | } |