Research background and significance
China is a large agricultural country. Agricultural economy has always been of great significance in the whole national economic and social development. Since the 1990s, information technologies such as electronic information, network communication and automatic control have been widely used in the field of agriculture. At present, China's agricultural development has developed from traditional agriculture to modern agriculture. Agricultural informatization is the process of using information technology to promote the sustainable and stable development of agriculture. It is timely and effective, especially sending farm information to farmers by mistake, realizing the informatization of farm production, management and sales, and improving the efficiency of farm management. China has always attached importance to the development of agriculture, but it lacks the pace of modernization synchronized with agricultural modernization. At present, China's agricultural information construction is still in its infancy. In terms of policy, the Chinese government has established pilot areas of information farms in many places. At the technical level, various farm management systems have also been developed and applied to various farms. Agricultural production management system with sensor is a widely used information technology. Through the investigation and research of the farm, analyze and establish the farm information management system and database, process the sensor data, and help the managers make correct decisions. Information collection and inquiry through traditional channels is very cumbersome, inefficient and difficult to grasp time. In this case, I decided to develop an online intelligent farm management system based on Java around side independent pages, including login module, ordinary user management, data analysis and display, farm plot planning and growth information management, production early warning management, production management and other modules, which are used to collect and publish relevant information. Greatly improve work efficiency and shorten working time. So that we can more conveniently experience and practice the management mode completely different from the traditional management mode. [contact for source code at the end of the article] How do computer majors charge during the winter vacation? Do a java project
Main module design:
Language Technology:
Development tools: IDEA 2021.3, navicat for mysql and postman.
Development language: java, jdk1 8,mysql5,node.js 14.
Main technologies: springboot, mybatis plus, vue, element UI, mysql, etc
Hardware environment: Windows 10 operating system, Google browser, etc.
Video presentation: How do computer majors charge during the winter vacation?
Function screenshot:
User input login address: http://localhost:8001/#/login Enter the login page Enter the account and password for login verification
Farm information management home page: the home page can be used for basic introduction, customized display, graphics and videos
Here, we use the echarts Tree Icon simulation.
User management:
Role menu:
Menu list: it can be controlled to the button level
Plot file:
Planting plan:
Means of production:
Early warning management:
Notice and announcement:
Documents: view, upload, download, etc
Paper report:
Key source code:
User login:
/** * Login related * * @author lyy */ @RestController public class SysLoginController extends AbstractController { @Autowired private SysUserService sysUserService; @Autowired private SysUserTokenService sysUserTokenService; @Autowired private SysCaptchaService sysCaptchaService; /** * Verification Code */ @GetMapping("captcha.jpg") public void captcha(HttpServletResponse response, String uuid)throws IOException { response.setHeader("Cache-Control", "no-store, no-cache"); response.setContentType("image/jpeg"); //Get picture verification code BufferedImage image = sysCaptchaService.getCaptcha(uuid); ServletOutputStream out = response.getOutputStream(); ImageIO.write(image, "jpg", out); IOUtils.closeQuietly(out); } /** * Sign in */ @PostMapping("/sys/login") public Map<String, Object> login(@RequestBody SysLoginForm form)throws IOException { boolean captcha = sysCaptchaService.validate(form.getUuid(), form.getCaptcha()); // if(!captcha){ // return R.error("incorrect verification code"); // } //User information SysUserEntity user = sysUserService.queryByUserName(form.getUsername()); //Account does not exist, password error if(user == null || !user.getPassword().equals(new Sha256Hash(form.getPassword(), user.getSalt()).toHex())) { return R.error("Incorrect account or password"); } //account lockout if(user.getStatus() == 0){ return R.error("Account locked,Please contact the administrator"); } //Generate a token and save it to the database R r = sysUserTokenService.createToken(user.getUserId()); return r; } /** * sign out */ @PostMapping("/sys/logout") public R logout() { sysUserTokenService.logout(getUserId()); return R.ok(); } }
service layer implementation:
/** * System user * * @author admin */ @Service("sysUserService") public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> implements SysUserService { @Autowired private SysUserRoleService sysUserRoleService; @Autowired private SysRoleService sysRoleService; @Override public PageUtils queryPage(Map<String, Object> params) { String username = (String)params.get("username"); Long createUserId = (Long)params.get("createUserId"); IPage<SysUserEntity> page = this.page( new Query<SysUserEntity>().getPage(params), new QueryWrapper<SysUserEntity>() .like(StringUtils.isNotBlank(username),"username", username) .eq(createUserId != null,"create_user_id", createUserId) ); return new PageUtils(page); } @Override @Transactional public void saveUser(SysUserEntity user) { user.setCreateTime(new Date()); //sha256 encryption String salt = RandomStringUtils.randomAlphanumeric(20); user.setPassword(new Sha256Hash(user.getPassword(), salt).toHex()); user.setSalt(salt); this.save(user); //Check whether the role exceeds its authority checkRole(user); //Save user role relationship sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList()); } @Override @Transactional public void update(SysUserEntity user) { if(StringUtils.isBlank(user.getPassword())){ user.setPassword(null); }else{ user.setPassword(new Sha256Hash(user.getPassword(), user.getSalt()).toHex()); } this.updateById(user); //Check whether the role exceeds its authority checkRole(user); //Save user role relationship sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList()); } @Override public void deleteBatch(Long[] userId) { this.removeByIds(Arrays.asList(userId)); } @Override public boolean updatePassword(Long userId, String password, String newPassword) { SysUserEntity userEntity = new SysUserEntity(); userEntity.setPassword(newPassword); return this.update(userEntity, new QueryWrapper<SysUserEntity>().eq("user_id", userId).eq("password", password)); } @Override public List<String> queryAllPerms(Long userId) { return baseMapper.queryAllPerms(userId); } /** * Check whether the role exceeds its authority */ private void checkRole(SysUserEntity user){ if(user.getRoleIdList() == null || user.getRoleIdList().size() == 0){ return; } //If you are not a super administrator, you need to determine whether the user's role is created by yourself if(user.getCreateUserId() == Constant.SUPER_ADMIN){ return ; } //Query the role list created by the user List<Long> roleIdList = sysRoleService.queryRoleIdList(user.getCreateUserId()); //Judge whether to exceed authority if(!roleIdList.containsAll(user.getRoleIdList())){ throw new RRException("The role selected by the new user is not created by himself"); } } }
Permission control:
/** * Shiro to configure * * @author admin */ @Configuration public class ShiroConfig { @Bean("securityManager") public SecurityManager securityManager(OAuth2Realm oAuth2Realm) { DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); securityManager.setRealm(oAuth2Realm); securityManager.setRememberMeManager(null); return securityManager; } @Bean("shiroFilter") public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) { ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean(); shiroFilter.setSecurityManager(securityManager); //oauth filtering Map<String, Filter> filters = new HashMap<>(); filters.put("oauth2", new OAuth2Filter()); shiroFilter.setFilters(filters); Map<String, String> filterMap = new LinkedHashMap<>(); filterMap.put("/webjars/**", "anon"); filterMap.put("/druid/**", "anon"); filterMap.put("/app/**", "anon"); filterMap.put("/sys/login", "anon"); filterMap.put("/swagger/**", "anon"); filterMap.put("/v2/api-docs", "anon"); filterMap.put("/swagger-ui.html", "anon"); filterMap.put("/swagger-resources/**", "anon"); filterMap.put("/captcha.jpg", "anon"); filterMap.put("/aaa.txt", "anon"); filterMap.put("/virtuel/**", "anon"); filterMap.put("/**", "oauth2"); shiroFilter.setFilterChainDefinitionMap(filterMap); return shiroFilter; } @Bean public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor(); advisor.setSecurityManager(securityManager); return advisor; } @Bean("lifecycleBeanPostProcessor") public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { return new LifecycleBeanPostProcessor(); } }
Global configuration:
# Tomcat server: tomcat: uri-encoding: UTF-8 max-threads: 1000 min-spare-threads: 30 port: 80 connection-timeout: 5000ms servlet: context-path: /renren-fast spring: # Environment dev|test|prod profiles: active: dev # jackson time formatting jackson: time-zone: GMT+8 date-format: yyyy-MM-dd HH:mm:ss servlet: multipart: max-file-size: 100MB max-request-size: 100MB enabled: true mvc: throw-exception-if-no-handler-found: true #mybatis mybatis-plus: mapper-locations: classpath*:/mapper/**/*.xml #For entity scanning, multiple package s are separated by commas or semicolons typeAliasesPackage: io.renren.modules.*.entity global-config: #Database related configuration db-config: #Primary key type AUTO: "self increment of database ID", INPUT: "user INPUT ID", ID_WORKER: "globally unique ID (unique ID of digital type)", UUID: "globally unique ID UUID"; id-type: AUTO logic-delete-value: -1 logic-not-delete-value: 0 banner: false #Native configuration configuration: map-underscore-to-camel-case: true cache-enabled: false call-setters-on-nulls: true jdbc-type-for-null: 'null' #File virtual path virtuel: filePath: C:/Users/Administrator/Desktop/lyy/
Summary:
After the recent mastery and learning of java object-oriented programming, front-end knowledge and java framework, as well as the development of this education and teaching system during this period, I have better understood the importance of java learning. In developing which system this system is, I have completed many experiments and functional tests of the land management platform. During the system development and learning stage, I learned that I am familiar with java, and then I can independently use relevant technologies. I found that it does have many conveniences, such as java integrates abstraction and encapsulation, inheritance and polymorphism, The functions of code reuse and code expansion are realized, and the speed and efficiency of the overall software development are improved. For example, when the administrator adds a user, it reports java Lang.nullpointexception. Solution: check the console print information, find that relevant information is not filled in when adding, and report to java Lang.nullpointexception, the data item with empty user information found through power-off debugging, the user's complete relevant information must be filled in when saving at the front end, or the database setting field can be empty. The main purpose of learning program design is to improve the key skills and technologies of program solutions to my actual problems.
Source code acquisition:
Everyone likes, collects, pays attention to, comments and views 👇🏻👇🏻👇🏻 WeChat official account for contact information 👇🏻👇🏻👇🏻
Punch in article update 115 / 365 days