| | |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | |
| | | @Component |
| | | public class monitor { |
| | | //ftp服务器IP地址 |
| | |
| | | //ftp服务器密码 |
| | | private static String ftpPassword = "Yly@123"; |
| | | //ftp服务器路径 |
| | | private static String ftpPath = "anbao/sql.json"; |
| | | private static String ftpPath = "anbao/nsql.json"; |
| | | //本地路径 |
| | | private static String localPath = "D:\\anbao"; |
| | | //文件名 |
| | | private static String fileName = "nsql.json"; |
| | | |
| | | |
| | | @Scheduled(cron = "*/5 * * * * ?") |
| | | public static boolean isFTPFileExist() { |
| | |
| | | InputStream is = ftp.retrieveFileStream(new String(file.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING)); |
| | | |
| | | if (is == null || ftp.getReplyCode() == FTPReply.FILE_UNAVAILABLE) { |
| | | System.out.println(false); |
| | | return false; |
| | | |
| | | } |
| | | |
| | | if (is != null) { |
| | | System.out.println(true); |
| | | is.close(); |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | // |
| | | String s = OutJson.TestJson(); |
| | | //sql语句 |
| | | String sql = OutJson.stringReplace(s); |
| | | //判断是否是新增,删除,修改 |
| | | String substring = sql.substring(0, 2); |
| | | //新增 |
| | | if (substring.equals("in")){ |
| | | //运行sql语句 |
| | | MysqlCenlint.inster(sql); |
| | | } |
| | | //修改 |
| | | else if (substring.equals("up")){ |
| | | |
| | | } |
| | | //删除 |
| | | else { |
| | | |
| | | } |
| | | //删除本地文件 |
| | | MysqlCenlint.delete(); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "nsql.json"); |
| | | is.close(); |
| | | ftp.completePendingCommand(); |
| | | |
| | | } |
| | |
| | | |
| | | import javax.validation.Valid; |
| | | import java.io.*; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | |
| | | @RequestMapping("/information") |
| | | @Api(value = "", tags = "接口") |
| | | public class InformationController extends BladeController { |
| | | //ftp服务器IP地址 |
| | | private static String ftpHost = "192.168.0.105"; |
| | | //ftp服务器端口 |
| | | private static int ftpPort = 21; |
| | | //ftp服务器用户名 |
| | | private static String ftpUserName = "yly"; |
| | | //ftp服务器密码 |
| | | private static String ftpPassword = "Yly@123"; |
| | | //ftp服务器路径 |
| | | private static String ftpPath = "anbao/sql.json"; |
| | | //本地路径 |
| | | private static String localPath = "D:\\anbao"; |
| | | //文件名 |
| | | private static String fileName = "nsql.json"; |
| | | |
| | | private final IInformationService informationService; |
| | | private final IDeptService iDeptService; |
| | |
| | | String id = kv.get("id").toString(); |
| | | information.setDepartmentid(id); |
| | | } |
| | | //String json=JSON.toJSONString(information); |
| | | //com.util.OutJson.createJsonFile(json,"d:/anbao/information/","informationSave"); |
| | | //arg.test01(arg.url + "/information/save", information); |
| | | return R.status(informationService.save(information)); |
| | | informationService.insertIn(information); |
| | | String formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(information.getEstablishtime()); |
| | | Integer id = information.getId(); |
| | | String s = "insert into sys_information(id,creditcode,enterprisename,representative,establishtime," + |
| | | "registeredcapital,organizationcode,registrationnumber,identificationnumber, enterprises, address," + |
| | | " business,region,registration,industry,departmentid,stats,jurisdiction,representativecell,contacts,contactscell) " + |
| | | "values(" + "'" + id + "'" + "," + "'" + information.getCreditcode() + "'" + "," + "'" + information.getEnterprisename() + "'" + "," + "'" + information.getRepresentative() + "'" + "," + |
| | | "'" + formatStr + "'" + "," + "'" + information.getRegisteredcapital() + "'" + "," + "'" + information.getOrganizationcode() + "'" + "," + "'" + information.getRegistrationnumber() + "'" + "," + |
| | | "'" + information.getIdentificationnumber() + "'" + "," + "'" + information.getEnterprises() + "'" + "," + "'" + |
| | | information.getAddress() + "'" + "," + "'" + information.getBusiness() + "'" + "," + "'" + |
| | | information.getRegion() + "'" + "," + "'" + information.getRegistration() + "'" + "," + "'" + information.getIndustry() + "'" + "," + "'" + information.getDepartmentid() + "'" + "," + |
| | | "'" + information.getStats() + "'" + "," + "'" + information.getJurisdiction() + "'" + "," + "'" + information.getRepresentativecell() + "'" + "," + |
| | | "'" + information.getContacts() + "'" + "," + "'" + information.getContactscell() + "'" + ");" + |
| | | "insert into blade_dept(id,parent_id,tenant_id,dept_name,ancestors,dept_category) values(" + "'" + information.getDepartmentid() + "'" + "," + "'" + dept.getParentId() + "'" + "," |
| | | + "'" + dept.getTenantId() + "'" + "," + "'" + information.getEnterprisename() + "'" + "," + "'" + dept.getAncestors() + "'" + "," + "'" + dept.getDeptCategory() + "'" + ")"; |
| | | Object o = s; |
| | | String json = JSON.toJSONString(o); |
| | | OutJson.createJsonFile(json, "d:/", "nsql"); |
| | | FileInputStream in = new FileInputStream(new File("D:\\" + fileName)); |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", fileName, in); |
| | | return R.success("成功"); |
| | | } |
| | | |
| | | /** |
| | |
| | | // } |
| | | |
| | | |
| | | @PostMapping("ss") |
| | | public void ss() throws FileNotFoundException { |
| | | //ftp服务器IP地址 |
| | | String ftpHost = "192.168.0.105"; |
| | | //ftp服务器端口 |
| | | int ftpPort = 21; |
| | | //ftp服务器用户名 |
| | | String ftpUserName = "yly"; |
| | | //ftp服务器密码 |
| | | String ftpPassword = "Yly@123"; |
| | | //ftp服务器路径 |
| | | String ftpPath = ""; |
| | | //本地路径 |
| | | String localPath = "D:\\anbao"; |
| | | //文件名 |
| | | String fileName = "sql.json"; |
| | | Information information = new Information(); |
| | | information.setCreditcode("1"); |
| | | informationService.insertIn(information); |
| | | Integer id = information.getId(); |
| | | String s = "insert into sys_information(id,creditcode) values(" + "'" + id + "'" + "," + "'" + 1 + "'" + ")"; |
| | | System.out.println(s); |
| | | Object o = s; |
| | | String json = JSON.toJSONString(o); |
| | | OutJson.createJsonFile(json, "d:/", "sql"); |
| | | FileInputStream in = new FileInputStream(new File("D:\\" + fileName)); |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", fileName, in); |
| | | } |
| | | // @PostMapping("ss") |
| | | // public void ss() throws FileNotFoundException { |
| | | // //ftp服务器IP地址 |
| | | // String ftpHost = "192.168.0.105"; |
| | | // //ftp服务器端口 |
| | | // int ftpPort = 21; |
| | | // //ftp服务器用户名 |
| | | // String ftpUserName = "yly"; |
| | | // //ftp服务器密码 |
| | | // String ftpPassword = "Yly@123"; |
| | | // //ftp服务器路径 |
| | | // String ftpPath = ""; |
| | | // //本地路径 |
| | | // String localPath = "D:\\anbao"; |
| | | // //文件名 |
| | | // String fileName = "sql.json"; |
| | | // Information information = new Information(); |
| | | // information.setCreditcode("1"); |
| | | // informationService.insertIn(information); |
| | | // Integer id = information.getId(); |
| | | // String s = "insert into sys_information(id,creditcode) values(" + "'" + id + "'" + "," + "'" + 1 + "'" + ")"; |
| | | // Object o = s; |
| | | // String json = JSON.toJSONString(o); |
| | | // OutJson.createJsonFile(json, "d:/", "nsql"); |
| | | // FileInputStream in = new FileInputStream(new File("D:\\" + fileName)); |
| | | // FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", fileName, in); |
| | | // } |
| | | |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | //ftp服务器IP地址 |
| | | String ftpHost = "192.168.0.105"; |
| | | //ftp服务器端口 |
| | | int ftpPort = 21; |
| | | //ftp服务器用户名 |
| | | String ftpUserName = "yly"; |
| | | //ftp服务器密码 |
| | | String ftpPassword = "Yly@123"; |
| | | //ftp服务器路径 |
| | | String ftpPath = "anbao/sql.json"; |
| | | //本地路径 |
| | | String localPath = "D:\\anbao"; |
| | | //文件名 |
| | | String fileName = "sql.json"; |
| | | // FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | String s = OutJson.TestJson(); |
| | | String sql = OutJson.stringReplace(s); |
| | | System.out.println(sql); |
| | | //boolean ftpFileExist = FtpUtil.isFTPFileExist(ftpPath, ftpUserName, ftpPassword, ftpHost, ftpPort); |
| | | //System.out.println(ftpFileExist); |
| | | } |
| | | |
| | | // public static void main(String[] args) throws Exception { |
| | | // //ftp服务器IP地址 |
| | | // String ftpHost = "192.168.0.105"; |
| | | // //ftp服务器端口 |
| | | // int ftpPort = 21; |
| | | // //ftp服务器用户名 |
| | | // String ftpUserName = "yly"; |
| | | // //ftp服务器密码 |
| | | // String ftpPassword = "Yly@123"; |
| | | // //ftp服务器路径 |
| | | // String ftpPath = "anbao/sql.json"; |
| | | // //本地路径 |
| | | // String localPath = "D:\\anbao"; |
| | | // //文件名 |
| | | // String fileName = "sql.json"; |
| | | //// FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | // String s = OutJson.TestJson(); |
| | | // String sql = OutJson.stringReplace(s); |
| | | // System.out.println(sql); |
| | | // //boolean ftpFileExist = FtpUtil.isFTPFileExist(ftpPath, ftpUserName, ftpPassword, ftpHost, ftpPort); |
| | | // //System.out.println(ftpFileExist); |
| | | // } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | <insert id="insertIn" useGeneratedKeys="true" keyProperty="id"> |
| | | insert into sys_information (creditcode) values (#{information.creditcode}) |
| | | insert into sys_information(creditcode, enterprisename,representative, establishtime, registeredcapital,organizationcode, registrationnumber, identificationnumber, enterprises, address,business, region, registration, industry, departmentid, stats, jurisdiction, |
| | | representativecell, contacts, contactscell) |
| | | values (#{information.creditcode}, #{information.enterprisename}, #{information.representative}, |
| | | #{information.establishtime}, #{information.registeredcapital}, |
| | | #{information.organizationcode}, #{information.registrationnumber}, |
| | | #{information.identificationnumber}, #{information.enterprises}, #{information.address}, |
| | | #{information.business}, |
| | | #{information.region}, #{information.registration}, #{information.industry}, |
| | | #{information.departmentid}, #{information.stats}, #{information.jurisdiction}, |
| | | #{information.representativecell}, #{information.contacts}, #{information.contactscell}) |
| | | </insert> |
| | | |
| | | |
| | |
| | | */ |
| | | package org.springblade.modules.permit.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.FTP.OutJson; |
| | | import org.springblade.modules.permit.entity.Permit; |
| | | import org.springblade.modules.permit.service.IPermitService; |
| | | import org.springblade.modules.permit.vo.PermitVO; |
| | |
| | | @RequestMapping("/permit") |
| | | @Api(value = "", tags = "接口") |
| | | public class PermitController extends BladeController { |
| | | //ftp服务器IP地址 |
| | | private static String ftpHost = "192.168.0.105"; |
| | | //ftp服务器端口 |
| | | private static int ftpPort = 21; |
| | | //ftp服务器用户名 |
| | | private static String ftpUserName = "yly"; |
| | | //ftp服务器密码 |
| | | private static String ftpPassword = "Yly@123"; |
| | | //ftp服务器路径 |
| | | private static String ftpPath = ""; |
| | | //本地路径 |
| | | private static String localPath = "D:\\anbao"; |
| | | //文件名 |
| | | private static String fileName = "sql.json"; |
| | | |
| | | private final IPermitService permitService; |
| | | |
| | |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入permit") |
| | | public R save(@Valid @RequestBody Permit permit) { |
| | | public R save(@Valid @RequestBody Permit permit) throws FileNotFoundException { |
| | | String cardid = permit.getCardid(); |
| | | Map map = permitService.selectIn(cardid); |
| | | if (map!=null){ |
| | |
| | | permit.setType("2"); |
| | | permit.setStorage("1"); |
| | | permit.setPermitime(new Date()); |
| | | return R.status(permitService.save(permit)); |
| | | return R.success("新增成功"); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.modules.information.entity.Information; |
| | | import org.springblade.modules.permit.entity.Permit; |
| | | import org.springblade.modules.permit.vo.PermitVO; |
| | | |
| | |
| | | List<PermitVO> selectPermitPage(IPage page, PermitVO permit); |
| | | |
| | | Map selectIn(String cardid); |
| | | |
| | | void insertPer(@Param("permit") Permit permit); |
| | | } |
| | |
| | | |
| | | |
| | | <select id="selectPermitPage" resultMap="permitResultMap"> |
| | | select * from sys_permit |
| | | select * |
| | | from sys_permit |
| | | </select> |
| | | |
| | | <select id="selectIn" resultType="java.util.HashMap"> |
| | | select * from sys_permit where storage=0 and cardid=#{cardid} |
| | | select * |
| | | from sys_permit |
| | | where storage = 0 |
| | | and cardid = #{cardid} |
| | | </select> |
| | | |
| | | <insert id="insertPer" useGeneratedKeys="true" keyProperty="id"> |
| | | insert into sys_permit (creditcode, enterprisename, |
| | | representative, establishtime, permitime, registeredcapital, |
| | | organizationcode, registrationnumber, |
| | | identificationnumber, enterprises, address, business, |
| | | region, registration, industry, type, deptid, |
| | | ptype, storage, cardid, |
| | | representativecell, contacts, contactscell) |
| | | values (#{permit.creditcode}, #{permit.enterprisename}, |
| | | #{permit.representative}, #{permit.establishtime}, #{permit.permitime}, #{permit.registeredcapital}, |
| | | #{permit.organizationcode}, #{permit.registrationnumber}, |
| | | #{permit.identificationnumber}, #{permit.enterprises}, #{permit.address}, #{permit.business}, |
| | | #{permit.region}, #{permit.registration}, #{permit.industry}, #{permit.type}, #{permit.deptid}, |
| | | #{permit.ptype}, #{permit.storage}, #{permit.cardid}, |
| | | #{permit.representativecell}, #{permit.contacts}, #{permit.contactscell}) |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.modules.permit.entity.Permit; |
| | | import org.springblade.modules.permit.vo.PermitVO; |
| | | |
| | |
| | | */ |
| | | IPage<PermitVO> selectPermitPage(IPage<PermitVO> page, PermitVO permit); |
| | | Map selectIn(String cardid); |
| | | void insertPer(@Param("permit") Permit permit); |
| | | } |
| | |
| | | return baseMapper.selectIn(cardid); |
| | | } |
| | | |
| | | @Override |
| | | public void insertPer(Permit permit) { |
| | | baseMapper.insertPer(permit); |
| | | } |
| | | |
| | | } |