Commit 54216443 by MacBook Pro

项目首次提交

parents
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
wget "$jarUrl" -O "$wrapperJarPath"
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
curl -o "$wrapperJarPath" "$jarUrl"
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<!-- spring boot tomcat jsp 支持开启 -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.example.demo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan(basePackages = "club.sscai.userservice.user")
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
package com.example.demo.controller;
import com.alibaba.fastjson.JSON;
import com.example.demo.entity.Additive;
import com.example.demo.entity.Sheet;
import com.example.demo.service.AdditiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = "/CRUD", method = { RequestMethod.GET, RequestMethod.POST })
public class AdditiveController {
@RequestMapping("/match1")
@ResponseBody
public String Match1(String food_sort_no,String food_name){
String json1= JSON.toJSONString(additiveService.match(food_name,food_sort_no));
return json1;
}
@Autowired
private AdditiveService additiveService;
@RequestMapping("/ListAdditive")
@ResponseBody
public List<Additive> ListAddictiveByName(){
return additiveService.ListAdditive();
}
//对数据库进行查找操作
@RequestMapping("/ListAdditiveByName")
@ResponseBody
public List<Additive> ListUserByAddictiveByName(String additiveCname, String foodSortNo){
return additiveService.findByName(additiveCname,foodSortNo);
}
//对数据库进行的删除操作
@RequestMapping(value = "/deleteAdditiveByName", method = RequestMethod.GET)
public String delete(Additive additive) {
String json1= JSON.toJSONString("删除成功");
String json2= JSON.toJSONString("删除失败");
int result = additiveService.Update2(additive);
if (result >= 1) {
return json1;
} else {
return json2;
}
}
//对数据进行修改的操作
@RequestMapping(value = "/updateAdditiveByName", method = RequestMethod.GET)
public String update(Additive additive) {
String json1= JSON.toJSONString("修改成功");
String json2= JSON.toJSONString("修改失败");
if (additive.getAdditiveCname()==null)
{
additive.setAdditiveCname("");
}
if (additive.getAdditiveEname()==null)
{
additive.setAdditiveEname("");
}
if (additive.getFoodCname()==null)
{
additive.setFoodCname("");
}
if (additive.getFoodEname()==null)
{
additive.setFoodEname("");
}
if (additive.getCnsNo()==null)
{
additive.setCnsNo("");
}
if (additive.getInsNo()==null)
{
additive.setInsNo("");
}
if (additive.getCountryPlace()==null)
{
additive.setCountryPlace("");
}
if (additive.getFoodSortNo()==null)
{
additive.setFoodSortNo("");
}
if (additive.getMaxUsage()==null)
{
additive.setMaxUsage("");
}
if (additive.getFunction()==null)
{
additive.setFunction("");
}
if (additive.getInformationSources()==null)
{
additive.setInformationSources("");
}
if (additive.getSortExplain()==null)
{
additive.setSortExplain("");
}
if (additive.getRemarks()==null)
{
additive.setRemarks("");
}
int result = additiveService.Update(additive);
if (result >= 1) {
return json1;
} else {
return json2;
}
}
//对数据库进行增加字段操作
@RequestMapping(value = "/insertAdditiveByName", method = RequestMethod.GET)
public int insert(Additive additive)
{
if (additive.getAdditiveCname()==null)
{
additive.setAdditiveCname("");
}
if (additive.getAdditiveEname()==null)
{
additive.setAdditiveEname("");
}
if (additive.getFoodCname()==null)
{
additive.setFoodCname("");
}
if (additive.getFoodEname()==null)
{
additive.setFoodEname("");
}
if (additive.getCnsNo()==null)
{
additive.setCnsNo("");
}
if (additive.getInsNo()==null)
{
additive.setInsNo("");
}
if (additive.getCountryPlace()==null)
{
additive.setCountryPlace("");
}
if (additive.getFoodSortNo()==null)
{
additive.setFoodSortNo("");
}
if (additive.getMaxUsage()==null)
{
additive.setMaxUsage("");
}
if (additive.getFunction()==null)
{
additive.setFunction("");
}
if (additive.getInformationSources()==null)
{
additive.setInformationSources("");
}
if (additive.getSortExplain()==null)
{
additive.setSortExplain("");
}
if (additive.getRemarks()==null)
{
additive.setRemarks("");
}
return additiveService.insertAdditive(additive);
}
//导入表到库
/* @RequestMapping(value ="/aa", method = RequestMethod.GET )
public void read()
{
try {
List<PollutantLimit> aa = Readpollutant.read("C:\\测试表格3.xlsx");
System.out.println(aa.size());
for (int i = 0; i < aa.size(); i++) {
insert(aa.get(i));
}
} catch(Exception e){
System.out.println(e.getMessage());
}
}
*/
@RequestMapping("/getAdditiveCategory")
public List<Sheet> getSheet(){
return additiveService.getSheet();
}
}
\ No newline at end of file
package com.example.demo.controller;
import com.alibaba.fastjson.JSON;
import com.example.demo.entity.Additive;
import com.example.demo.entity.Base;
import com.example.demo.entity.Static;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.List;
import java.util.UUID;
@Controller
public class AdditiveUploadController {
@Autowired
AdditiveController crud=new AdditiveController();
/**
* 初始化上传文件界面,跳转到index.jsp
* @return
*/
@RequestMapping(value = "/CRUD/index4",method = RequestMethod.GET)
public String index(){
return "index";
}
/**
* 提取上传方法为公共方法
* @param uploadDir 上传文件目录
* @param file 上传对象
* @throws Exception
*/
private void executeUpload(String uploadDir,MultipartFile file) throws Exception
{
//文件后缀名
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//上传文件名
String filename = UUID.randomUUID() + suffix;
//服务器端保存的文件对象
File serverFile = new File(uploadDir + filename);
//将上传的文件写入到服务器端文件内
file.transferTo(serverFile);
}
//void read();
/**
* 上传文件方法
* @param file 前台上传的文件对象
* @return
*/
@RequestMapping(value = "/CRUD/AdditiveUpload",method = RequestMethod.POST)
public @ResponseBody
Base upload(HttpServletRequest request, MultipartFile file)
{
int success = 0;
int lose = 0;
String record ="";
Base base = new Base();
Static static1=new Static();
String json1= JSON.toJSONString("修改成功");
String json2= JSON.toJSONString("修改失败");
try {
//上传目录地址
String uploadDir = request.getSession().getServletContext().getRealPath("/") +"upload\\";
//如果目录不存在,自动创建文件夹
File dir = new File(uploadDir);
if(!dir.exists())
{
dir.mkdir();
}
//调用上传方法
//文件后缀名
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//上传文件名
String filename = UUID.randomUUID() + suffix;
//服务器端保存的文件对象
File serverFile = new File(uploadDir + filename);
//将上传的文件写入到服务器端文件内
file.transferTo(serverFile);
try {
List<Additive> aa = ReadAdditive.read(""+uploadDir+filename.replace("/","\\"));
for (int i = 0; i < aa.size(); i++) {
if(crud.insert(aa.get(i))==1)
success++;
else {
lose++;
String str = String.valueOf(i+1);
record = record +","+ str;
}
}
static1.setLose(lose);
static1.setSuccess(success);
static1.setRecord1(record.substring(1));
} catch(Exception e){
System.out.println(e.getMessage());
}
}catch (Exception e)
{
//打印错误堆栈信息
e.printStackTrace();
base.setCode("错误代码");
base.setMessage("错误信息");
base.setSuccess(false);
return base;
}
base.setDataobject(static1);
base.setMessage("成功信息");
base.setSuccess(true);
base.setCode("成功");
return base;
}
}
package com.example.demo.controller;
import com.alibaba.fastjson.JSON;
import com.example.demo.entity.FungimycinLimit;
import com.example.demo.entity.Sheet;
import com.example.demo.service.FungimycinLimitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = "/CRUD", method = { RequestMethod.GET, RequestMethod.POST })
public class FuncimycinController {
@Autowired
private FungimycinLimitService fungimycinLimitService;
@RequestMapping("/ListFungimycin")
@ResponseBody
public List<FungimycinLimit> ListFungimycinByName(){
return fungimycinLimitService.ListFungimycin();
}
//对数据库进行查找操作
@RequestMapping("/ListFungimycinByName")
@ResponseBody
public List<FungimycinLimit> ListUserByFungimycinByName(String fungimycinCname, String food_sort_no){
return fungimycinLimitService.findByName(fungimycinCname,food_sort_no);
}
//对数据库进行的删除操作
@RequestMapping(value = "/deleteFungimycinByName", method = RequestMethod.GET)
public String delete(FungimycinLimit fungimycinLimit) {
String json1= JSON.toJSONString("删除成功");
String json2= JSON.toJSONString("删除失败");
int result = fungimycinLimitService.Update2(fungimycinLimit);
if (result >= 1) {
return json1;
} else {
return json2;
}
}
//对数据进行修改的操作
@RequestMapping(value = "/updateFungimycinByName", method = RequestMethod.GET)
public String update(FungimycinLimit fungimycinLimit) {
String json1= JSON.toJSONString("修改成功");
String json2= JSON.toJSONString("修改失败");
int result = fungimycinLimitService.Update(fungimycinLimit);
if (result >= 1) {
return json1;
} else {
return json2;
}
}
//对数据库进行增加字段操作
@RequestMapping(value = "/insertFungimycinByName", method = RequestMethod.GET)
public int insert(FungimycinLimit fungimycinLimit)
{
return fungimycinLimitService.insertFungimycinLimit(fungimycinLimit);
}
//导入表到库
/* @RequestMapping(value ="/aa", method = RequestMethod.GET )
public void read()
{
try {
List<PollutantLimit> aa = Readpollutant.read("C:\\测试表格3.xlsx");
System.out.println(aa.size());
for (int i = 0; i < aa.size(); i++) {
insert(aa.get(i));
}
} catch(Exception e){
System.out.println(e.getMessage());
}
}
*/
@RequestMapping("/getFungimycinCategory")
public List<Sheet> getSheet(){
return fungimycinLimitService.getSheet();
}
}
\ No newline at end of file
package com.example.demo.controller;
import com.alibaba.fastjson.JSON;
import com.example.demo.entity.Base;
import com.example.demo.entity.FungimycinLimit;
import com.example.demo.entity.Static;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.List;
import java.util.UUID;
@Controller
public class FungimycinUploadController {
@Autowired
FuncimycinController crud=new FuncimycinController();
/**
* 初始化上传文件界面,跳转到index.jsp
* @return
*/
@RequestMapping(value = "/CRUD/index",method = RequestMethod.GET)
public String index(){
return "index";
}
/**
* 提取上传方法为公共方法
* @param uploadDir 上传文件目录
* @param file 上传对象
* @throws Exception
*/
private void executeUpload(String uploadDir,MultipartFile file) throws Exception
{
//文件后缀名
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//上传文件名
String filename = UUID.randomUUID() + suffix;
//服务器端保存的文件对象
File serverFile = new File(uploadDir + filename);
//将上传的文件写入到服务器端文件内
file.transferTo(serverFile);
}
//void read();
/**
* 上传文件方法
* @param file 前台上传的文件对象
* @return
*/
@RequestMapping(value = "/CRUD/FungimycinUpload",method = RequestMethod.POST)
public @ResponseBody Base upload(HttpServletRequest request,MultipartFile file)
{
int success = 0;
int lose = 0;
String record ="";
Base base = new Base();
Static static1=new Static();
String json1= JSON.toJSONString("修改成功");
String json2= JSON.toJSONString("修改失败");
try {
//上传目录地址
String uploadDir = request.getSession().getServletContext().getRealPath("/") +"upload\\";
//如果目录不存在,自动创建文件夹
File dir = new File(uploadDir);
if(!dir.exists())
{
dir.mkdir();
}
//调用上传方法
//文件后缀名
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//上传文件名
String filename = UUID.randomUUID() + suffix;
//服务器端保存的文件对象
File serverFile = new File(uploadDir + filename);
//将上传的文件写入到服务器端文件内
file.transferTo(serverFile);
try {
List<FungimycinLimit> aa = ReadFungimycin.read(""+uploadDir+filename.replace("/","\\"));
for (int i = 0; i < aa.size(); i++) {
if(crud.insert(aa.get(i))==1){
success++;
}
else{
lose++;
String str = String.valueOf(i+1);
record = record +","+ str;
}
}
static1.setLose(lose);
static1.setSuccess(success);
static1.setRecord1(record.substring(1));
} catch(Exception e){
System.out.println(e.getMessage());
}
}catch (Exception e)
{
//打印错误堆栈信息
System.out.println(e.getMessage());
base.setCode("错误代码");
base.setMessage("错误信息");
base.setSuccess(false);
return base;
}
base.setDataobject(static1);
base.setMessage("成功信息");
base.setSuccess(true);
base.setCode("成功");
return base;
}
}
package com.example.demo.controller;
import com.alibaba.fastjson.JSON;
import com.example.demo.entity.FungimycinLimit;
import com.example.demo.entity.PesticidesLimit;
import com.example.demo.entity.Sheet;
import com.example.demo.service.PesticidesLimitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = "/CRUD", method = { RequestMethod.GET, RequestMethod.POST })
public class PesticidesController {
@Autowired
private PesticidesLimitService pesticidesLimitService;
@RequestMapping("/ListPesticides")
@ResponseBody
public List<PesticidesLimit> ListPesticidesByName(){
return pesticidesLimitService.ListPesticides();
}
//对数据库进行查找操作
@RequestMapping("/ListPesticidesByName")
@ResponseBody
public List<PesticidesLimit> ListUserByPesticidesByName(String pesticidesCname, String food_sort_no){
return pesticidesLimitService.findByName(pesticidesCname,food_sort_no);
}
//对数据库进行的删除操作
@RequestMapping(value = "/deletePesticidesByName", method = RequestMethod.GET)
public String delete(PesticidesLimit pesticidesLimit) {
String json1= JSON.toJSONString("删除成功");
String json2= JSON.toJSONString("删除失败");
int result = pesticidesLimitService.Update2(pesticidesLimit);
if (result >= 1) {
return json1;
} else {
return json2;
}
}
//对数据进行修改的操作
@RequestMapping(value = "/updatePesticidesByName", method = RequestMethod.GET)
public String update(PesticidesLimit pesticidesLimit) {
String json1= JSON.toJSONString("修改成功");
String json2= JSON.toJSONString("修改失败");
if(pesticidesLimit.getAdi()==null){
pesticidesLimit.setAdi("");
}
if(pesticidesLimit.getCheckWay()==null){
pesticidesLimit.setCheckWay("");
}
if(pesticidesLimit.getCountryPlace()==null){
pesticidesLimit.setCountryPlace("");
}
if(pesticidesLimit.getDeterminePlace()==null){
pesticidesLimit.setDeterminePlace("");
}
if(pesticidesLimit.getFoodName() ==null){
pesticidesLimit.setFoodName("");
}
if(pesticidesLimit.getInformationSources()==null){
pesticidesLimit.setInformationSources("");
}
if(pesticidesLimit.getLimited()==null){
pesticidesLimit.setLimited("");
}
if(pesticidesLimit.getMainUses()==null){
pesticidesLimit.setMainUses("");
}
if(pesticidesLimit.getPesticidesCname()==null){
pesticidesLimit.setPesticidesCname("");
}
if(pesticidesLimit.getPesticidesEname()==null){
pesticidesLimit.setPesticidesEname("");
}
if(pesticidesLimit.getRemarks()==null){
pesticidesLimit.setRemarks("");
}
if(pesticidesLimit.getResidue()==null){
pesticidesLimit.setResidue("");
}
int result = pesticidesLimitService.Update(pesticidesLimit);
if (result >= 1) {
return json1;
} else {
return json2;
}
}
//对数据库进行增加字段操作
@RequestMapping(value = "/insertPesticidesByName", method = RequestMethod.GET)
public int insert(PesticidesLimit pesticidesLimit)
{
if(pesticidesLimit.getAdi()==null){
pesticidesLimit.setAdi("");
}
if(pesticidesLimit.getCheckWay()==null){
pesticidesLimit.setCheckWay("");
}
if(pesticidesLimit.getCountryPlace()==null){
pesticidesLimit.setCountryPlace("");
}
if(pesticidesLimit.getDeterminePlace()==null){
pesticidesLimit.setDeterminePlace("");
}
if(pesticidesLimit.getFoodName() ==null){
pesticidesLimit.setFoodName("");
}
if(pesticidesLimit.getInformationSources()==null){
pesticidesLimit.setInformationSources("");
}
if(pesticidesLimit.getLimited()==null){
pesticidesLimit.setLimited("");
}
if(pesticidesLimit.getMainUses()==null){
pesticidesLimit.setMainUses("");
}
if(pesticidesLimit.getPesticidesCname()==null){
pesticidesLimit.setPesticidesCname("");
}
if(pesticidesLimit.getPesticidesEname()==null){
pesticidesLimit.setPesticidesEname("");
}
if(pesticidesLimit.getRemarks()==null){
pesticidesLimit.setRemarks("");
}
if(pesticidesLimit.getResidue()==null){
pesticidesLimit.setResidue("");
}
return pesticidesLimitService.insertPesticidesLimit(pesticidesLimit);
}
//导入表到库
/* @RequestMapping(value ="/aa", method = RequestMethod.GET )
public void read()
{
try {
List<PollutantLimit> aa = Readpollutant.read("C:\\测试表格3.xlsx");
System.out.println(aa.size());
for (int i = 0; i < aa.size(); i++) {
insert(aa.get(i));
}
} catch(Exception e){
System.out.println(e.getMessage());
}
}
*/
@RequestMapping("/getPesticidesCategory")
public List<Sheet> getSheet(){
return pesticidesLimitService.getSheet();
}
}
\ No newline at end of file
package com.example.demo.controller;
import com.alibaba.fastjson.JSON;
import com.example.demo.entity.Base;
import com.example.demo.entity.PesticidesLimit;
import com.example.demo.entity.Static;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.List;
import java.util.UUID;
@Controller
public class PesticidesUploadController {
@Autowired
PesticidesController crud=new PesticidesController();
/**
* 初始化上传文件界面,跳转到index.jsp
* @return
*/
@RequestMapping(value = "/CRUD/index3",method = RequestMethod.GET)
public String index(){
return "index";
}
/**
* 提取上传方法为公共方法
* @param uploadDir 上传文件目录
* @param file 上传对象
* @throws Exception
*/
private void executeUpload(String uploadDir,MultipartFile file) throws Exception
{
//文件后缀名
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//上传文件名
String filename = UUID.randomUUID() + suffix;
//服务器端保存的文件对象
File serverFile = new File(uploadDir + filename);
//将上传的文件写入到服务器端文件内
file.transferTo(serverFile);
}
//void read();
/**
* 上传文件方法
* @param file 前台上传的文件对象
* @return
*/
@RequestMapping(value = "/CRUD/PesticidesUpload",method = RequestMethod.POST)
public @ResponseBody Base upload(HttpServletRequest request,MultipartFile file)
{
int success = 0;
int lose = 0;
String record ="";
Base base = new Base();
Static static1=new Static();
String json1= JSON.toJSONString("修改成功");
String json2= JSON.toJSONString("修改失败");
try {
//上传目录地址
String uploadDir = request.getSession().getServletContext().getRealPath("/") +"upload\\";
//如果目录不存在,自动创建文件夹
File dir = new File(uploadDir);
if(!dir.exists())
{
dir.mkdir();
}
//调用上传方法
//文件后缀名
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//上传文件名
String filename = UUID.randomUUID() + suffix;
//服务器端保存的文件对象
File serverFile = new File(uploadDir + filename);
//将上传的文件写入到服务器端文件内
file.transferTo(serverFile);
try {
List<PesticidesLimit> aa = ReadPesticides.read(""+uploadDir+filename.replace("/","\\"));
for (int i = 0; i < aa.size(); i++) {
if(crud.insert(aa.get(i))==1){
success++;
}
else{
lose++;
String str = String.valueOf(i+1);
record = record +","+ str;
}
}
static1.setLose(lose);
static1.setSuccess(success);
static1.setRecord1(record.substring(1));
} catch(Exception e){
System.out.println(e.getMessage());
}
}catch (Exception e)
{
//打印错误堆栈信息
System.out.println(e.getMessage());
base.setCode("错误代码");
base.setMessage("错误信息");
base.setSuccess(false);
return base;
}
base.setDataobject(static1);
base.setMessage("成功信息");
base.setSuccess(true);
base.setCode("成功");
return base;
}
}
package com.example.demo.controller;
import com.alibaba.fastjson.JSON;
import com.example.demo.entity.PollutantLimit;
import com.example.demo.entity.Sheet;
import com.example.demo.service.PollutantLimitService;
import org.apache.jasper.tagplugins.jstl.core.If;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = "/CRUD", method = { RequestMethod.GET, RequestMethod.POST })
public class PollutantController {
@RequestMapping("/ListUser")
@ResponseBody
public List<PollutantLimit> ListUser(){
return pollutantLimitservice.ListUser();
}
//对数据库进行查找操作
@RequestMapping("/ListPollutantLimitByName")
@ResponseBody
public List<PollutantLimit> ListUserByCNofPollutant(String pollutant_cname, String food_sort_no){
return pollutantLimitservice.findByName(pollutant_cname,food_sort_no);
}
@Autowired
private PollutantLimitService pollutantLimitservice;
//对数据库进行的删除操作
@RequestMapping(value = "/delete", method = RequestMethod.GET)
public String delete(PollutantLimit pollutantLimit) {
String json1= JSON.toJSONString("删除成功");
String json2= JSON.toJSONString("删除失败");
int result = pollutantLimitservice.Update2(pollutantLimit);
if (result >= 1) {
return json1;
} else {
return json2;
}
}
//对数据进行修改的操作
@RequestMapping(value = "/update", method = RequestMethod.GET)
public String update(PollutantLimit pollutantLimit) {
if(pollutantLimit.getCheck_way()==null)
pollutantLimit.setCheck_way("");
if(pollutantLimit.getCountry_place()==null)
pollutantLimit.setCountry_place("");
if(pollutantLimit.getFood_name() ==null)
pollutantLimit.setFood_name("");
if(pollutantLimit.getFood_sort_no()==null)
pollutantLimit.setFood_sort_no("");
if(pollutantLimit.getInformation_sources()==null)
pollutantLimit.setInformation_sources("");
if(pollutantLimit.getLimited()==null)
pollutantLimit.setLimited("");
if(pollutantLimit.getPollutant_cname()==null)
pollutantLimit.setPollutant_cname("");
if(pollutantLimit.getPollutant_ename()==null)
pollutantLimit.setPollutant_ename("");
if(pollutantLimit.getRemarks()==null)
pollutantLimit.setRemarks("");
if(pollutantLimit.getTips()==null)
pollutantLimit.setTips("");
if(pollutantLimit.getDoseUnit()==null)
pollutantLimit.setDoseUnit("");
String json1= JSON.toJSONString("修改成功");
String json2= JSON.toJSONString("修改失败");
int result = pollutantLimitservice.Update(pollutantLimit);
if (result==1) {
return json1;
} else {
return json2;
}
}
//对数据库进行增加字段操作
@RequestMapping(value = "/insert", method = RequestMethod.GET)
public int insert(PollutantLimit pollutantLimit)
{
return pollutantLimitservice.insertPollutantLimit(pollutantLimit);
}
//导入表到库
@RequestMapping(value ="/aa", method = RequestMethod.GET )
public void read()
{
try {
List<PollutantLimit> aa = Readpollutant.read("C:\\测试表格3.xlsx");
System.out.println(aa.size());
for (int i = 0; i < aa.size(); i++) {
insert(aa.get(i));
}
} catch(Exception e){
System.out.println(e.getMessage());
}
}
@RequestMapping("/getCategory")
public List<Sheet> getSheet(){
return pollutantLimitservice.getSheet();
}
}
\ No newline at end of file
package com.example.demo.controller;
import com.alibaba.fastjson.JSON;
import com.example.demo.entity.Base;
import com.example.demo.entity.PollutantLimit;
import com.example.demo.entity.Static;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.List;
import java.util.UUID;
@Controller
public class PollutantUploadController {
@Autowired
PollutantController pollutantController =new PollutantController();
/**
* 初始化上传文件界面,跳转到index.jsp
* @return
*/
@RequestMapping(value = "/CRUD/index2",method = RequestMethod.GET)
public String index(){
return "index";
}
/**
* 提取上传方法为公共方法
* @param uploadDir 上传文件目录
* @param file 上传对象
* @throws Exception
*/
private void executeUpload(String uploadDir,MultipartFile file) throws Exception
{
//文件后缀名
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//上传文件名
String filename = UUID.randomUUID() + suffix;
//服务器端保存的文件对象
File serverFile = new File(uploadDir + filename);
//将上传的文件写入到服务器端文件内
file.transferTo(serverFile);
}
//void read();
/**
* 上传文件方法
* @param file 前台上传的文件对象
* @return
*/
@RequestMapping(value = "/CRUD/upload",method = RequestMethod.POST)
public @ResponseBody Base upload(HttpServletRequest request,MultipartFile file)
{
int success = 0;
int lose = 0;
String record ="";
Base base = new Base();
Static static1=new Static();
String json1= JSON.toJSONString("修改成功");
String json2= JSON.toJSONString("修改失败");
String count="";
try {
//上传目录地址
String uploadDir = request.getSession().getServletContext().getRealPath("/") +"upload\\";
//如果目录不存在,自动创建文件夹
File dir = new File(uploadDir);
if(!dir.exists())
{
dir.mkdir();
}
//调用上传方法
//文件后缀名
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//上传文件名
String filename = UUID.randomUUID() + suffix;
//服务器端保存的文件对象
File serverFile = new File(uploadDir + filename);
//将上传的文件写入到服务器端文件内
file.transferTo(serverFile);
try {
List<PollutantLimit> aa = Readpollutant.read(""+uploadDir+filename.replace("/","\\"));
for (int i = 0; i < aa.size(); i++) {
if(pollutantController.insert(aa.get(i))==1){
success++;
}
else{
lose++;
String str = String.valueOf(i+1);
record = record +","+ str;
}
}
static1.setLose(lose);
static1.setSuccess(success);
static1.setRecord1(record.substring(1));
} catch(Exception e){
System.out.println(e.getMessage());
}
}catch (Exception e)
{
//打印错误堆栈信息
System.out.println(e.getMessage());
base.setCode("错误代码");
base.setMessage("错误信息");
base.setSuccess(false);
return base;
}
base.setDataobject(static1);
base.setMessage("成功信息");
base.setSuccess(true);
base.setCode("成功");
return base;
}
}
package com.example.demo.controller;
import com.example.demo.entity.Additive;
import com.example.demo.entity.PesticidesLimit;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
public class ReadAdditive {
public static ArrayList<Additive> read(String path) throws IOException, InvalidFormatException {
ArrayList<Additive> list = new ArrayList<>();
System.out.println(path);
File excel = new File(path);
if (excel.isFile() && excel.exists()) { //判断文件是否存在
String split = excel.getName();
Workbook wb;
//根据文件后缀(xls/xlsx)进行判断
if (split.endsWith(".xls")) {
FileInputStream fis = new FileInputStream(excel); //文件流对象
wb = new HSSFWorkbook(fis);
} else if (split.endsWith(".xlsx")) {
wb = new XSSFWorkbook(excel);
} else {
System.out.println("文件类型错误!");
return null;
}
//开始解析
Sheet sheet = wb.getSheetAt(0); //读取sheet 0
int firstRowIndex = sheet.getFirstRowNum() + 1; //第一行是列名,所以不读
int lastRowIndex = sheet.getLastRowNum();
System.out.println("firstRowIndex: " + firstRowIndex);
System.out.println("lastRowIndex: " + lastRowIndex);
for (int rIndex = firstRowIndex; rIndex <= lastRowIndex; rIndex++) { //遍历行
Row row = sheet.getRow(rIndex);
int rowNum = row.getRowNum();
if (row != null) {
Additive additive=new Additive();
//遍历列
Cell cell = row.getCell(0);
if (cell != null) {
Double bb=new Double(cell.getNumericCellValue());
additive.setId(bb.intValue());
System.out.println(" "+bb);
}
Cell cell1 = row.getCell(1);
if(rIndex==lastRowIndex&&(cell1==null||cell1.toString()==""))continue;
if (cell1 != null) {
additive.setAdditiveCname(cell1.toString());
System.out.println(cell1.toString());
}
Cell cell2 = row.getCell(2);
if (cell2 != null) {
additive.setAdditiveEname(cell2.toString());
System.out.println(cell2.toString());
}
Cell cell3 = row.getCell(3);
if (cell3 != null) {
additive.setCnsNo(cell3.toString());
System.out.println(cell3.toString());
}
Cell cell4 = row.getCell(4);
if (cell4 != null) {
additive.setCountryPlace(cell4.toString());
System.out.println(cell4.toString());
}
Cell cell5 = row.getCell(5);
if (cell5 != null) {
additive.setFoodCname(cell5.toString());
System.out.println(cell5.toString());
}
Cell cell6 = row.getCell(6);
if (cell6 != null) {
additive.setFoodEname(cell6.toString());
System.out.println(cell6.toString());
}
Cell cell7 = row.getCell(7);
if (cell7 != null) {
additive.setInformationSources(cell7.toString());
System.out.println(cell7.toString());
}
Cell cell8 = row.getCell(8);
if (cell8 != null) {
additive.setRemarks(cell8.toString());
System.out.println(cell8.toString());
}
Cell cell9 = row.getCell(9);
if (cell9 != null) {
additive.setFoodSortNo(cell9.toString());
System.out.println(cell9.toString());
}
Cell cell10 = row.getCell(10);
if (cell10 != null) {
additive.setFunction(cell10.toString());
System.out.println(cell10.toString());
}
Cell cell11 = row.getCell(11);
if (cell11 != null) {
additive.setMaxUsage(cell11.toString());
System.out.println(cell11.toString());
}
Cell cell12 = row.getCell(12);
if (cell12 != null) {
additive.setInsNo(cell12.toString());
System.out.println(cell12.toString());
}
Cell cell13 = row.getCell(13);
if (cell13 != null) {
additive.setSortExplain(cell13.toString());
System.out.println(cell13.toString());
}
list.add(additive);
}
}
}
return list;
}
}
package com.example.demo.controller;
import com.example.demo.entity.FungimycinLimit;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
public class ReadFungimycin {
public static ArrayList<FungimycinLimit> read(String path) throws IOException, InvalidFormatException {
ArrayList<FungimycinLimit> list = new ArrayList<>();
System.out.println(path);
File excel = new File(path);
if (excel.isFile() && excel.exists()) { //判断文件是否存在
String split = excel.getName();
Workbook wb;
//根据文件后缀(xls/xlsx)进行判断
if (split.endsWith(".xls")) {
FileInputStream fis = new FileInputStream(excel); //文件流对象
wb = new HSSFWorkbook(fis);
} else if (split.endsWith(".xlsx")) {
wb = new XSSFWorkbook(excel);
} else {
System.out.println("文件类型错误!");
return null;
}
//开始解析
Sheet sheet = wb.getSheetAt(0); //读取sheet 0
int firstRowIndex = sheet.getFirstRowNum() + 1; //第一行是列名,所以不读
int lastRowIndex = sheet.getLastRowNum();
System.out.println("firstRowIndex: " + firstRowIndex);
System.out.println("lastRowIndex: " + lastRowIndex);
for (int rIndex = firstRowIndex; rIndex <= lastRowIndex; rIndex++) { //遍历行
Row row = sheet.getRow(rIndex);
int rowNum = row.getRowNum();
if (row != null) {
FungimycinLimit fungimycinLimit=new FungimycinLimit();
//遍历列
Cell cell = row.getCell(0);
if (cell != null) {
Double bb=new Double(cell.getNumericCellValue());
fungimycinLimit.setId(bb.intValue());
System.out.println(" "+bb);
}
Cell cell1 = row.getCell(1);
if(rIndex==lastRowIndex&&(cell1==null||cell1.toString()==""))continue;
if (cell1 != null) {
fungimycinLimit.setFungimycinCname(cell1.toString());
System.out.println(cell1.toString());
}
Cell cell2 = row.getCell(2);
if (cell2 != null) {
fungimycinLimit.setFungimycinEname(cell2.toString());
System.out.println(cell2.toString());
}
Cell cell3 = row.getCell(3);
if (cell3 != null) {
fungimycinLimit.setFoodName(cell3.toString());
System.out.println(cell3.toString());
}
Cell cell4 = row.getCell(4);
if (cell4 != null) {
fungimycinLimit.setLimited(cell4.toString());
System.out.println(cell4.toString());
}
Cell cell5 = row.getCell(5);
if (cell5 != null) {
fungimycinLimit.setCountryPlace(cell5.toString());
System.out.println(cell5.toString());
}
Cell cell6 = row.getCell(6);
if (cell6 != null) {
fungimycinLimit.setCheckWay(cell6.toString());
System.out.println(cell6.toString());
}
Cell cell7 = row.getCell(7);
if (cell7 != null) {
fungimycinLimit.setInformationSources(cell7.toString());
System.out.println(cell7.toString());
}
Cell cell8 = row.getCell(8);
if (cell8 != null) {
fungimycinLimit.setRemarks(cell8.toString());
System.out.println(cell8.toString());
}
list.add(fungimycinLimit);
}
}
}
return list;
}
}
package com.example.demo.controller;
import com.example.demo.entity.FungimycinLimit;
import com.example.demo.entity.PesticidesLimit;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
public class ReadPesticides {
public static ArrayList<PesticidesLimit> read(String path) throws IOException, InvalidFormatException {
ArrayList<PesticidesLimit> list = new ArrayList<>();
System.out.println(path);
File excel = new File(path);
if (excel.isFile() && excel.exists()) { //判断文件是否存在
String split = excel.getName();
Workbook wb;
//根据文件后缀(xls/xlsx)进行判断
if (split.endsWith(".xls")) {
FileInputStream fis = new FileInputStream(excel); //文件流对象
wb = new HSSFWorkbook(fis);
} else if (split.endsWith(".xlsx")) {
wb = new XSSFWorkbook(excel);
} else {
System.out.println("文件类型错误!");
return null;
}
//开始解析
Sheet sheet = wb.getSheetAt(0); //读取sheet 0
int firstRowIndex = sheet.getFirstRowNum() + 1; //第一行是列名,所以不读
int lastRowIndex = sheet.getLastRowNum();
System.out.println("firstRowIndex: " + firstRowIndex);
System.out.println("lastRowIndex: " + lastRowIndex);
for (int rIndex = firstRowIndex; rIndex <= lastRowIndex; rIndex++) { //遍历行
Row row = sheet.getRow(rIndex);
int rowNum = row.getRowNum();
if (row != null) {
PesticidesLimit pesticidesLimit=new PesticidesLimit();
//遍历列
Cell cell = row.getCell(0);
if (cell != null) {
Double bb=new Double(cell.getNumericCellValue());
pesticidesLimit.setId(bb.intValue());
System.out.println(" "+bb);
}
Cell cell1 = row.getCell(1);
if(rIndex==lastRowIndex&&(cell1==null||cell1.toString()==""))continue;
if (cell1 != null) {
pesticidesLimit.setPesticidesCname(cell1.toString());
System.out.println(cell1.toString());
}
Cell cell2 = row.getCell(2);
if (cell2 != null) {
pesticidesLimit.setPesticidesEname(cell2.toString());
System.out.println(cell2.toString());
}
Cell cell3 = row.getCell(3);
if (cell3 != null) {
pesticidesLimit.setFoodName(cell3.toString());
System.out.println(cell3.toString());
}
Cell cell4 = row.getCell(4);
if (cell4 != null) {
pesticidesLimit.setLimited(cell4.toString());
System.out.println(cell4.toString());
}
Cell cell5 = row.getCell(5);
if (cell5 != null) {
pesticidesLimit.setCountryPlace(cell5.toString());
System.out.println(cell5.toString());
}
Cell cell6 = row.getCell(6);
if (cell6 != null) {
pesticidesLimit.setCheckWay(cell6.toString());
System.out.println(cell6.toString());
}
Cell cell7 = row.getCell(7);
if (cell7 != null) {
pesticidesLimit.setInformationSources(cell7.toString());
System.out.println(cell7.toString());
}
Cell cell8 = row.getCell(8);
if (cell8 != null) {
pesticidesLimit.setRemarks(cell8.toString());
System.out.println(cell8.toString());
}
Cell cell9 = row.getCell(9);
if (cell9 != null) {
pesticidesLimit.setMainUses(cell9.toString());
System.out.println(cell9.toString());
}
Cell cell10 = row.getCell(10);
if (cell10 != null) {
pesticidesLimit.setAdi(cell10.toString());
System.out.println(cell10.toString());
}
Cell cell11 = row.getCell(11);
if (cell11 != null) {
pesticidesLimit.setDeterminePlace(cell11.toString());
System.out.println(cell11.toString());
}
Cell cell12 = row.getCell(12);
if (cell12 != null) {
pesticidesLimit.setResidue(cell12.toString());
System.out.println(cell12.toString());
}
list.add(pesticidesLimit);
}
}
}
return list;
}
}
package com.example.demo.controller;
import com.example.demo.entity.PollutantLimit;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
public class Readpollutant {
public static ArrayList<PollutantLimit> read(String path) throws IOException, InvalidFormatException {
ArrayList<PollutantLimit> list = new ArrayList<>();
System.out.println(path);
File excel = new File(path);
if (excel.isFile() && excel.exists()) { //判断文件是否存在
String split = excel.getName();
Workbook wb;
//根据文件后缀(xls/xlsx)进行判断
if (split.endsWith(".xls")) {
FileInputStream fis = new FileInputStream(excel); //文件流对象
wb = new HSSFWorkbook(fis);
} else if (split.endsWith(".xlsx")) {
wb = new XSSFWorkbook(excel);
} else {
System.out.println("文件类型错误!");
return null;
}
//开始解析
Sheet sheet = wb.getSheetAt(0); //读取sheet 0
int firstRowIndex = sheet.getFirstRowNum() + 1; //第一行是列名,所以不读
int lastRowIndex = sheet.getLastRowNum();
System.out.println("firstRowIndex: " + firstRowIndex);
System.out.println("lastRowIndex: " + lastRowIndex);
for (int rIndex = firstRowIndex; rIndex <= lastRowIndex; rIndex++) { //遍历行
Row row = sheet.getRow(rIndex);
int rowNum = row.getRowNum();
if (row != null) {
PollutantLimit pollutantLimit=new PollutantLimit();
//遍历列
Cell cell = row.getCell(0);
if (cell != null) {
Double bb=new Double(cell.getNumericCellValue());
pollutantLimit.setId(bb.intValue());
System.out.println(" "+bb);
}
Cell cell1 = row.getCell(1);
if(cell1==null||cell1.toString()=="")continue;
if (cell1 != null) {
pollutantLimit.setPollutant_cname(cell1.toString());
System.out.println(cell1.toString());
}
Cell cell2 = row.getCell(2);
if (cell2 != null) {
pollutantLimit.setFood_name(cell2.toString());
System.out.println(cell2.toString());
}
Cell cell3 = row.getCell(3);
if (cell3 != null) {
pollutantLimit.setPollutant_ename(cell3.toString());
System.out.println(cell3.toString());
}
Cell cell4 = row.getCell(4);
if (cell4 != null) {
pollutantLimit.setCheck_way(cell4.toString());
System.out.println(cell4.toString());
}
Cell cell5 = row.getCell(5);
if (cell5 != null) {
pollutantLimit.setInformation_sources(cell5.toString());
System.out.println(cell5.toString());
}
Cell cell6 = row.getCell(6);
if (cell6 != null) {
pollutantLimit.setLimited(cell6.toString());
System.out.println(cell6.toString());
}
Cell cell7 = row.getCell(7);
if (cell7 != null) {
pollutantLimit.setCountry_place(cell7.toString());
System.out.println(cell7.toString());
}
Cell cell8 = row.getCell(8);
if (cell8 != null) {
pollutantLimit.setRemarks(cell8.toString());
System.out.println(cell8.toString());
}
list.add(pollutantLimit);
}
}
}
return list;
}
}
package com.example.demo.entity;
public class Additive {
private int id;
private String foodSortNo;
private String foodCname;
private String sortExplain;
private String foodEname;
private String additiveCname;
private String additiveEname;
private String cnsNo;
private String insNo;
private String function;
private String maxUsage;
private String informationSources;
private String countryPlace;
private String remarks;
private int state;
private String DoseUnit;
private String Tips;
@Override
public String toString() {
return "Additive{" +
"id=" + id +
", foodSortNo='" + foodSortNo + '\'' +
", foodCname='" + foodCname + '\'' +
", sortExplain='" + sortExplain + '\'' +
", foodEname='" + foodEname + '\'' +
", additiveCname='" + additiveCname + '\'' +
", additiveEname='" + additiveEname + '\'' +
", cnsNo='" + cnsNo + '\'' +
", insNo='" + insNo + '\'' +
", function='" + function + '\'' +
", maxUsage='" + maxUsage + '\'' +
", informationSources='" + informationSources + '\'' +
", countryPlace='" + countryPlace + '\'' +
", remarks='" + remarks + '\'' +
", state=" + state +
", DoseUnit='" + DoseUnit + '\'' +
", Tips='" + Tips + '\'' +
'}';
}
public String getTips() {
return Tips;
}
public void setTips(String tips) {
Tips = tips;
}
public String getDoseUnit() {
return DoseUnit;
}
public void setDoseUnit(String doseUnit) {
DoseUnit = doseUnit;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFoodSortNo() {
return foodSortNo;
}
public void setFoodSortNo(String foodSortNo) {
this.foodSortNo = foodSortNo;
}
public String getFoodCname() {
return foodCname;
}
public void setFoodCname(String foodCname) {
this.foodCname = foodCname;
}
public String getSortExplain() {
return sortExplain;
}
public void setSortExplain(String sortExplain) {
this.sortExplain = sortExplain;
}
public String getFoodEname() {
return foodEname;
}
public void setFoodEname(String foodEname) {
this.foodEname = foodEname;
}
public String getAdditiveCname() {
return additiveCname;
}
public void setAdditiveCname(String additiveCname) {
this.additiveCname = additiveCname;
}
public String getAdditiveEname() {
return additiveEname;
}
public void setAdditiveEname(String additiveEname) {
this.additiveEname = additiveEname;
}
public String getCnsNo() {
return cnsNo;
}
public void setCnsNo(String cnsNo) {
this.cnsNo = cnsNo;
}
public String getInsNo() {
return insNo;
}
public void setInsNo(String insNo) {
this.insNo = insNo;
}
public String getFunction() {
return function;
}
public void setFunction(String function) {
this.function = function;
}
public String getMaxUsage() {
return maxUsage;
}
public void setMaxUsage(String maxUsage) {
this.maxUsage = maxUsage;
}
public String getInformationSources() {
return informationSources;
}
public void setInformationSources(String informationSources) {
this.informationSources = informationSources;
}
public String getCountryPlace() {
return countryPlace;
}
public void setCountryPlace(String countryPlace) {
this.countryPlace = countryPlace;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
}
package com.example.demo.entity;
public class Base {
private boolean success;
private String message;
private String code;
private Object dataobject;
@Override
public String toString() {
return "MasterBase{" +
"success=" + success +
", message='" + message + '\'' +
", code='" + code + '\'' +
", dataobject=" + dataobject +
'}';
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Object getDataobject() {
return dataobject;
}
public void setDataobject(Object dataobject) {
this.dataobject = dataobject;
}
}
package com.example.demo.entity;
public class FungimycinLimit {
private int id;
private String fungimycinCname;
private String fungimycinEname;
private String foodName;
private String limited;
private String countryPlace;
private String checkWay;
private String informationSources;
private String remarks;
private String food_sort_no;
private String DoseUnit;
private String Tips;
@Override
public String toString() {
return "FungimycinLimit{" +
"id=" + id +
", fungimycinCname='" + fungimycinCname + '\'' +
", fungimycinEname='" + fungimycinEname + '\'' +
", foodName='" + foodName + '\'' +
", limited='" + limited + '\'' +
", countryPlace='" + countryPlace + '\'' +
", checkWay='" + checkWay + '\'' +
", informationSources='" + informationSources + '\'' +
", remarks='" + remarks + '\'' +
", food_sort_no='" + food_sort_no + '\'' +
", DoseUnit='" + DoseUnit + '\'' +
", Tips='" + Tips + '\'' +
", state=" + state +
'}';
}
public String getTips() {
return Tips;
}
public void setTips(String tips) {
Tips = tips;
}
public String getDoseUnit() {
return DoseUnit;
}
public void setDoseUnit(String doseUnit) {
DoseUnit = doseUnit;
}
public String getFood_sort_no() {
return food_sort_no;
}
public void setFood_sort_no(String food_sort_no) {
this.food_sort_no = food_sort_no;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFungimycinCname() {
return fungimycinCname;
}
public void setFungimycinCname(String fungimycinCname) {
this.fungimycinCname = fungimycinCname;
}
public String getFungimycinEname() {
return fungimycinEname;
}
public void setFungimycinEname(String fungimycinEname) {
this.fungimycinEname = fungimycinEname;
}
public String getFoodName() {
return foodName;
}
public void setFoodName(String foodName) {
this.foodName = foodName;
}
public String getLimited() {
return limited;
}
public void setLimited(String limited) {
this.limited = limited;
}
public String getCountryPlace() {
return countryPlace;
}
public void setCountryPlace(String countryPlace) {
this.countryPlace = countryPlace;
}
public String getCheckWay() {
return checkWay;
}
public void setCheckWay(String checkWay) {
this.checkWay = checkWay;
}
public String getInformationSources() {
return informationSources;
}
public void setInformationSources(String informationSources) {
this.informationSources = informationSources;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
private int state;
}
package com.example.demo.entity;
public class PesticidesLimit {
private int id;
private String pesticidesCname;
private String pesticidesEname;
private String mainUses;
private String adi;
private String foodName;
private String limited;
private String residue;
private String determinePlace;
private String countryPlace;
private String checkWay;
private String informationSources;
private String remarks;
private int state;
private String DoseUnit;
private String Tips;
@Override
public String toString() {
return "PesticidesLimit{" +
"id=" + id +
", pesticidesCname='" + pesticidesCname + '\'' +
", pesticidesEname='" + pesticidesEname + '\'' +
", mainUses='" + mainUses + '\'' +
", adi='" + adi + '\'' +
", foodName='" + foodName + '\'' +
", limited='" + limited + '\'' +
", residue='" + residue + '\'' +
", determinePlace='" + determinePlace + '\'' +
", countryPlace='" + countryPlace + '\'' +
", checkWay='" + checkWay + '\'' +
", informationSources='" + informationSources + '\'' +
", remarks='" + remarks + '\'' +
", state=" + state +
", DoseUnit='" + DoseUnit + '\'' +
", Tips='" + Tips + '\'' +
'}';
}
public String getTips() {
return Tips;
}
public void setTips(String tips) {
Tips = tips;
}
public String getDoseUnit() {
return DoseUnit;
}
public void setDoseUnit(String doseUnit) {
DoseUnit = doseUnit;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPesticidesCname() {
return pesticidesCname;
}
public void setPesticidesCname(String pesticidesCname) {
this.pesticidesCname = pesticidesCname;
}
public String getPesticidesEname() {
return pesticidesEname;
}
public void setPesticidesEname(String pesticidesEname) {
this.pesticidesEname = pesticidesEname;
}
public String getMainUses() {
return mainUses;
}
public void setMainUses(String mainUses) {
this.mainUses = mainUses;
}
public String getAdi() {
return adi;
}
public void setAdi(String adi) {
this.adi = adi;
}
public String getFoodName() {
return foodName;
}
public void setFoodName(String foodName) {
this.foodName = foodName;
}
public String getLimited() {
return limited;
}
public void setLimited(String limited) {
this.limited = limited;
}
public String getResidue() {
return residue;
}
public void setResidue(String residue) {
this.residue = residue;
}
public String getDeterminePlace() {
return determinePlace;
}
public void setDeterminePlace(String determinePlace) {
this.determinePlace = determinePlace;
}
public String getCountryPlace() {
return countryPlace;
}
public void setCountryPlace(String countryPlace) {
this.countryPlace = countryPlace;
}
public String getCheckWay() {
return checkWay;
}
public void setCheckWay(String checkWay) {
this.checkWay = checkWay;
}
public String getInformationSources() {
return informationSources;
}
public void setInformationSources(String informationSources) {
this.informationSources = informationSources;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
}
package com.example.demo.entity;
public class PollutantLimit {
private int id;
private String pollutant_cname;
private String pollutant_ename;
private String food_name;
private String limited;
private String country_place;
private String check_way;
private String information_sources;
private String remarks;
private int State;
private String food_sort_no;
private String DoseUnit;
private String Tips;
@Override
public String toString() {
return "PollutantLimit{" +
"id=" + id +
", pollutant_cname='" + pollutant_cname + '\'' +
", pollutant_ename='" + pollutant_ename + '\'' +
", food_name='" + food_name + '\'' +
", limited='" + limited + '\'' +
", country_place='" + country_place + '\'' +
", check_way='" + check_way + '\'' +
", information_sources='" + information_sources + '\'' +
", remarks='" + remarks + '\'' +
", State=" + State +
", food_sort_no='" + food_sort_no + '\'' +
", DoseUnit='" + DoseUnit + '\'' +
", Tips='" + Tips + '\'' +
'}';
}
public String getTips() {
return Tips;
}
public void setTips(String tips) {
Tips = tips;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPollutant_cname() {
return pollutant_cname;
}
public void setPollutant_cname(String pollutant_cname) {
this.pollutant_cname = pollutant_cname;
}
public String getPollutant_ename() {
return pollutant_ename;
}
public void setPollutant_ename(String pollutant_ename) {
this.pollutant_ename = pollutant_ename;
}
public String getFood_name() {
return food_name;
}
public void setFood_name(String food_name) {
this.food_name = food_name;
}
public String getLimited() {
return limited;
}
public void setLimited(String limited) {
this.limited = limited;
}
public String getCountry_place() {
return country_place;
}
public void setCountry_place(String country_place) {
this.country_place = country_place;
}
public String getCheck_way() {
return check_way;
}
public void setCheck_way(String check_way) {
this.check_way = check_way;
}
public String getInformation_sources() {
return information_sources;
}
public void setInformation_sources(String information_sources) {
this.information_sources = information_sources;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public int getState() {
return State;
}
public void setState(int state) {
State = state;
}
public String getFood_sort_no() {
return food_sort_no;
}
public void setFood_sort_no(String food_sort_no) {
this.food_sort_no = food_sort_no;
}
public String getDoseUnit() {
return DoseUnit;
}
public void setDoseUnit(String doseUnit) {
DoseUnit = doseUnit;
}
}
package com.example.demo.entity;
import java.util.List;
public class Sheet {
private String label;
private String parentId;
private String value;
private List<Sheet> children;
@Override
public String toString() {
return "Sheet{" +
"categoryName='" + label + '\'' +
", parentId='" + parentId + '\'' +
", categoryId='" + value + '\'' +
'}';
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public List<Sheet> getChildren() {
return children;
}
public void setChildren(List<Sheet> children) {
this.children = children;
}
}
package com.example.demo.entity;
public class Static {
int success;
int lose;
String record1 ="";
public int getSuccess() {
return success;
}
public void setSuccess(int success) {
this.success = success;
}
public int getLose() {
return lose;
}
public void setLose(int lose) {
this.lose = lose;
}
public String getRecord1() {
return record1;
}
public void setRecord1(String record1) {
this.record1 = record1;
}
@Override
public String toString() {
return "Static{" +
"success=" + success +
", lose=" + lose +
", record1='" + record1 + '\'' +
'}';
}
}
package com.example.demo.mapper;
import com.example.demo.entity.Additive;
import com.example.demo.entity.Sheet;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Mapper
public interface AdditiveMapper {
public List<Additive> findAdditiveByAdditiveCname(String additiveCname, String foodSortNo);
public List<Additive> ListAdditive();
public int insertAdditive(Additive additive);
//public int delete(String additiveCname);
public int Update(Additive additive);
public int Update2(Additive additive);
public String match(String food_name,String food_sort_no);
public Additive judge(String additiveCname,String foodCname,String remarks);
public Additive findById(Additive additive);
public List<Sheet> getsheet();
}
package com.example.demo.mapper;
import com.example.demo.entity.FungimycinLimit;
import com.example.demo.entity.PollutantLimit;
import com.example.demo.entity.Sheet;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Mapper
public interface FungimycinLimitMapper {
public List<FungimycinLimit> findFungimycinByFungimycinCname(String fungimycinCname, String food_sort_no);
public List<FungimycinLimit> ListFungimycin();
public int insertFungimycinLimit(FungimycinLimit fungimycinLimit);
public int delete(String pollutant_cname);
public int Update(FungimycinLimit fungimycinLimit);
public int Update2(FungimycinLimit fungimycinLimit);
public void read(String uploadDir, MultipartFile file);
public List<Sheet> getsheet();
public FungimycinLimit findById(FungimycinLimit fungimycinLimit);
public FungimycinLimit judge(String fungimycinCname,String foodName,String remarks);
}
package com.example.demo.mapper;
import com.example.demo.entity.PesticidesLimit;
import com.example.demo.entity.Sheet;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Mapper
public interface PesticidesLimitMapper {
public List<PesticidesLimit> findPesticidesByPesticidesCname(String pesticidesCname, String food_sort_no);
public List<PesticidesLimit> ListPesticides();
public int insertPesticidesLimit(PesticidesLimit pesticidesLimit);
public int delete(String pesticides_cname);
public int Update(PesticidesLimit pesticidesLimit);
public int Update2(PesticidesLimit pesticidesLimit);
public void read(String uploadDir, MultipartFile file);
public PesticidesLimit findById(PesticidesLimit pesticidesLimit);
public PesticidesLimit judge(String pesticidesCname,String foodName,String remarks);
public List<Sheet> getsheet();
}
package com.example.demo.mapper;
import java.util.List;
import com.example.demo.entity.Sheet;
import org.apache.ibatis.annotations.Mapper;
import com.example.demo.entity.PollutantLimit;
import org.springframework.web.multipart.MultipartFile;
@Mapper
public interface PollutantLimitMapper {
public List<PollutantLimit> findUserBypollutant_cname(String pollutant_cname,String food_sort_no);
public List<PollutantLimit> ListUser();
public int insertPollutantLimit(PollutantLimit pollutantLimit);
public int delete(String pollutant_cname);
public int Update(PollutantLimit pollutantLimit);
public int Update2(PollutantLimit pollutantLimit);
public void read(String uploadDir, MultipartFile file);
public PollutantLimit judge(String pollutant_cname,String food_name,String remarks);
public PollutantLimit findById(PollutantLimit pollutantLimit);
public List<Sheet> getsheet();
}
package com.example.demo.service;
import com.example.demo.entity.Additive;
import com.example.demo.entity.Sheet;
import com.example.demo.mapper.AdditiveMapper;
import org.apache.commons.lang.StringUtils;
import org.apache.jasper.tagplugins.jstl.core.If;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class AdditiveService {
@Autowired
private AdditiveMapper additiveLimitMapper;
public List<Additive> findByName(String additiveCname, String foodSortNo) {
List<Additive> additives=additiveLimitMapper.findAdditiveByAdditiveCname(additiveCname,foodSortNo);
for(int i = 0;i<additives.size();i++){
String aa = additives.get(i).getMaxUsage();//得到原始数据
if(aa.equals("")){
}
else if(aa.contains("按生产")){
additives.get(i).setDoseUnit("");
}
else if(aa.contains("mg/kg")){
additives.get(i).setDoseUnit("mg/kg");
additives.get(i).setMaxUsage(aa.substring(0,aa.lastIndexOf("mg/kg")));
}
else if(aa.contains("μg/kg")){
additives.get(i).setDoseUnit("μg/kg");
additives.get(i).setMaxUsage(aa.substring(0,aa.lastIndexOf("μg/kg")));
}
else if (aa.contains("g/kg"))
{
additives.get(i).setDoseUnit("g/kg");//赋予字段单位
additives.get(i).setMaxUsage(aa.substring(0,aa.lastIndexOf("g/kg")));//赋予字段数值
}
else if (aa.contains("mg/L"))
{
additives.get(i).setDoseUnit("mg/L");//赋予字段单位
additives.get(i).setMaxUsage(aa.substring(0,aa.lastIndexOf("mg/L")));//赋予字段数值
}
else if(aa.contains("mg/份"))
{
additives.get(i).setDoseUnit("mg/份");//赋予字段单位
additives.get(i).setMaxUsage(aa.substring(0,aa.lastIndexOf("mg/份")));//赋予字段数值
}
else{
additives.get(i).setDoseUnit("g/kg");//赋予字段单位
}
}
return additives;
}
public int insertAdditive(Additive additive)
{
Additive additives=additiveLimitMapper.judge(additive.getAdditiveCname(),additive.getFoodCname(),additive.getRemarks());
if(additives!=null)
{
additive.setTips("已有数据,请查找后进行编辑");
return 0;
}
if(additive.getFoodSortNo()==null||additive.getFoodCname()==null||additive.getAdditiveCname()==null||additive.getAdditiveEname()==null||additive.getFunction()==null||additive.getMaxUsage()==null||additive.getCountryPlace()==null){
return 0;
}
additive.setTips("新增数据成功");
additiveLimitMapper.insertAdditive(additive);
return 1;
}
public String match(String food_name,String food_sort_no){
return additiveLimitMapper.match(food_name,food_sort_no);
}
public List<Additive> ListAdditive(){
List<Additive> additives=additiveLimitMapper.ListAdditive();
for(int i = 0;i<additives.size();i++){
String aa = additives.get(i).getMaxUsage();//得到原始数据
if(aa.equals("")){
}
else if(aa.contains("按生产")){
additives.get(i).setDoseUnit("");
}
else if(aa.contains("mg/kg")){
additives.get(i).setDoseUnit("mg/kg");
additives.get(i).setMaxUsage(aa.substring(0,aa.lastIndexOf("mg/kg")));
}
else if(aa.contains("μg/kg")){
additives.get(i).setDoseUnit("μg/kg");
additives.get(i).setMaxUsage(aa.substring(0,aa.lastIndexOf("μg/kg")));
}
else if (aa.contains("g/kg"))
{
additives.get(i).setDoseUnit("g/kg");//赋予字段单位
additives.get(i).setMaxUsage(aa.substring(0,aa.lastIndexOf("g/kg")));//赋予字段数值
}
else if (aa.contains("mg/L"))
{
additives.get(i).setDoseUnit("mg/L");//赋予字段单位
additives.get(i).setMaxUsage(aa.substring(0,aa.lastIndexOf("mg/L")));//赋予字段数值
}
else if(aa.contains("mg/份"))
{
additives.get(i).setDoseUnit("mg/份");//赋予字段单位
additives.get(i).setMaxUsage(aa.substring(0,aa.lastIndexOf("mg/份")));//赋予字段数值
}
else{
additives.get(i).setDoseUnit("g/kg");//赋予字段单位
}
}
return additives;
}
public int Update(Additive additive){
Additive AA=additiveLimitMapper.findById(additive);//找到要编辑的数据
//没改关键词,直接修改
if(AA.getAdditiveCname()==additive.getAdditiveCname()&&AA.getFoodCname()==additive.getFoodCname()&&AA.getRemarks()==additive.getRemarks())
{
return additiveLimitMapper.Update(additive);
}
//改动关键词
else {
//若已存在数据,不做任何操作
if(additiveLimitMapper.judge(additive.getAdditiveCname(),additive.getFoodCname(),additive.getRemarks())!=null){
return 0;
}
//不存在数据将原先数据覆盖,插入新数据
else{
Update2(AA);
insertAdditive(additive);
return 1;
}
}
}
public int Update2(Additive additive){
return additiveLimitMapper.Update2(additive);
}
public void read(){};
public List<Sheet> getSheet(){
List<Sheet> rootSheet=additiveLimitMapper.getsheet();//原始数据
//输出结果用于检查
for(Sheet sheet: rootSheet){
System.out.println(sheet);
}
// 最后的结果
List<Sheet> sheetList=new ArrayList<Sheet>();
for(int i=0;i<rootSheet.size();i++){
if("peak".equals(rootSheet.get(i).getParentId())){
sheetList.add(rootSheet.get(i));
}
}
for(Sheet sheet: sheetList){
sheet.setChildren(getChild(sheet.getValue(),rootSheet));
}
return sheetList;
}
private List<Sheet> getChild(String id,List<Sheet> rootSheet){
List<Sheet> childList=new ArrayList<>();
for(Sheet sheet: rootSheet){
if(StringUtils.isNotBlank(sheet.getParentId())){
if(sheet.getParentId().equals(id)){
childList.add(sheet);
}
}
}
for(Sheet sheet: childList){
sheet.setChildren(getChild(sheet.getValue(),rootSheet));
}
if(childList.size()==0){
return null;
}
return childList;
}
}
\ No newline at end of file
package com.example.demo.service;
import com.example.demo.entity.FungimycinLimit;
import com.example.demo.entity.Sheet;
import com.example.demo.mapper.FungimycinLimitMapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class FungimycinLimitService {
@Autowired
private FungimycinLimitMapper fungimycinLimitMapper;
public List<FungimycinLimit> findByName(String fungimycinCname, String food_sort_no) {
List<FungimycinLimit> fungimycinLimits=fungimycinLimitMapper.findFungimycinByFungimycinCname(fungimycinCname,food_sort_no);
for(int i = 0;i<fungimycinLimits.size();i++){
String aa = fungimycinLimits.get(i).getLimited();//得到原始数据
if(aa.equals("")){
}
else if(aa.contains("按生产")){
fungimycinLimits.get(i).setDoseUnit("");
}
else if(aa.contains("mg/kg")){
fungimycinLimits.get(i).setDoseUnit("mg/kg");
fungimycinLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/kg")));
}
else if(aa.contains("μg/kg")){
fungimycinLimits.get(i).setDoseUnit("μg/kg");
fungimycinLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("μg/kg")));
}
else if (aa.contains("g/kg"))
{
fungimycinLimits.get(i).setDoseUnit("g/kg");//赋予字段单位
fungimycinLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("g/kg")));//赋予字段数值
}
else if (aa.contains("mg/L"))
{
fungimycinLimits.get(i).setDoseUnit("mg/L");//赋予字段单位
fungimycinLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/L")));//赋予字段数值
}
else if(aa.contains("mg/份"))
{
fungimycinLimits.get(i).setDoseUnit("mg/份");//赋予字段单位
fungimycinLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/份")));//赋予字段数值
}
else{
fungimycinLimits.get(i).setDoseUnit("g/kg");//赋予字段单位
}
}
return fungimycinLimits ;
}
public int insertFungimycinLimit(FungimycinLimit fungimycinLimit)
{
FungimycinLimit fungimycinLimits=fungimycinLimitMapper.judge(fungimycinLimit.getFungimycinCname(),fungimycinLimit.getFoodName(),fungimycinLimit.getRemarks());
if(fungimycinLimits!=null)
{
fungimycinLimit.setTips("已有数据,请查找后进行编辑");
return 0;
}
if(fungimycinLimit.getFungimycinEname()==null||fungimycinLimit.getFungimycinCname()==null||fungimycinLimit.getLimited()==null||fungimycinLimit.getCountryPlace()==null){
return 0;
}
fungimycinLimit.setTips("新增数据成功");
fungimycinLimitMapper.insertFungimycinLimit(fungimycinLimit);
return 1;
}
public List<FungimycinLimit> ListFungimycin(){
List<FungimycinLimit> fungimycinLimits=fungimycinLimitMapper.ListFungimycin();
for(int i = 0;i<fungimycinLimits.size();i++){
String aa = fungimycinLimits.get(i).getLimited();//得到原始数据
if(aa.equals("")){
}
else if(aa.contains("按生产")){
fungimycinLimits.get(i).setDoseUnit("");
}
else if(aa.contains("mg/kg")){
fungimycinLimits.get(i).setDoseUnit("mg/kg");
fungimycinLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/kg")));
}
else if(aa.contains("μg/kg")){
fungimycinLimits.get(i).setDoseUnit("μg/kg");
fungimycinLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("μg/kg")));
}
else if (aa.contains("g/kg"))
{
fungimycinLimits.get(i).setDoseUnit("g/kg");//赋予字段单位
fungimycinLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("g/kg")));//赋予字段数值
}
else if (aa.contains("mg/L"))
{
fungimycinLimits.get(i).setDoseUnit("mg/L");//赋予字段单位
fungimycinLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/L")));//赋予字段数值
}
else if(aa.contains("mg/份"))
{
fungimycinLimits.get(i).setDoseUnit("mg/份");//赋予字段单位
fungimycinLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/份")));//赋予字段数值
}
else{
fungimycinLimits.get(i).setDoseUnit("g/kg");//赋予字段单位
}
}
return fungimycinLimits ;
}
public int Update(FungimycinLimit fungimycinLimit) {
FungimycinLimit AA = fungimycinLimitMapper.findById(fungimycinLimit);
if (AA.getFungimycinCname() == fungimycinLimit.getFungimycinCname() && AA.getFoodName() == fungimycinLimit.getFoodName() && AA.getRemarks() == fungimycinLimit.getRemarks()) {
return fungimycinLimitMapper.Update(fungimycinLimit);
}
else{
if (fungimycinLimitMapper.judge(fungimycinLimit.getFungimycinCname(), fungimycinLimit.getFoodName(), fungimycinLimit.getRemarks()) != null) {
return 0;
}
else {
Update2(AA);
insertFungimycinLimit(fungimycinLimit);
return 1;
}
}
}
public int delete(String fungimycinCname){
return fungimycinLimitMapper.delete(fungimycinCname);
}
public int Update2(FungimycinLimit fungimycinLimit){
return fungimycinLimitMapper.Update2(fungimycinLimit);
}
public void read(){};
public List<Sheet> getSheet(){
List<Sheet> rootSheet=fungimycinLimitMapper.getsheet();//原始数据
//输出结果用于检查
for(Sheet sheet: rootSheet){
System.out.println(sheet);
}
// 最后的结果
List<Sheet> sheetList=new ArrayList<Sheet>();
for(int i=0;i<rootSheet.size();i++){
if("peak".equals(rootSheet.get(i).getParentId())){
sheetList.add(rootSheet.get(i));
}
}
for(Sheet sheet: sheetList){
sheet.setChildren(getChild(sheet.getValue(),rootSheet));
}
return sheetList;
}
private List<Sheet> getChild(String id,List<Sheet> rootSheet){
List<Sheet> childList=new ArrayList<>();
for(Sheet sheet: rootSheet){
if(StringUtils.isNotBlank(sheet.getParentId())){
if(sheet.getParentId().equals(id)){
childList.add(sheet);
}
}
}
for(Sheet sheet: childList){
sheet.setChildren(getChild(sheet.getValue(),rootSheet));
}
if(childList.size()==0){
return null;
}
return childList;
}
}
\ No newline at end of file
package com.example.demo.service;
import com.example.demo.entity.PesticidesLimit;
import com.example.demo.entity.Sheet;
import com.example.demo.mapper.PesticidesLimitMapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class PesticidesLimitService {
@Autowired
private PesticidesLimitMapper pesticidesLimitMapper;
public List<PesticidesLimit> findByName(String pesticidesCname, String food_sort_no) {
List<PesticidesLimit> pesticidesLimits=pesticidesLimitMapper.findPesticidesByPesticidesCname(pesticidesCname,food_sort_no);
for(int i = 0;i<pesticidesLimits.size();i++){
String aa = pesticidesLimits.get(i).getLimited();//得到原始数据
if(aa==null)
{}
else if(aa.contains("量")||aa.contains("可")||aa.contains("脂肪")||aa.contains("肉")||aa.contains("内脏")||aa.contains("原样")||aa.contains("鱼类")||aa.contains("豁免")){
pesticidesLimits.get(i).setDoseUnit("");
}
else if(aa.contains("mg/kg")){
pesticidesLimits.get(i).setDoseUnit("mg/kg");
pesticidesLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/kg")));
}
else if(aa.contains("μg/kg")){
pesticidesLimits.get(i).setDoseUnit("μg/kg");
pesticidesLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("μg/kg")));
}
else if (aa.contains("g/kg"))
{
pesticidesLimits.get(i).setDoseUnit("g/kg");//赋予字段单位
pesticidesLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("g/kg")));//赋予字段数值
}
else if (aa.contains("mg/L"))
{
pesticidesLimits.get(i).setDoseUnit("mg/L");//赋予字段单位
pesticidesLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/L")));//赋予字段数值
}
else {pesticidesLimits.get(i).setDoseUnit("mg/kg");}
}
return pesticidesLimits;
}
public int insertPesticidesLimit(PesticidesLimit pesticidesLimit)
{
PesticidesLimit pesticidesLimit1=pesticidesLimitMapper.judge(pesticidesLimit.getPesticidesCname(),pesticidesLimit.getFoodName(),pesticidesLimit.getRemarks());
if(pesticidesLimit1!=null)
{
pesticidesLimit.setTips("已有数据,请查找后进行编辑");
return 0;
}
if(pesticidesLimit.getPesticidesCname()==null||pesticidesLimit.getPesticidesEname()==null||pesticidesLimit.getFoodName()==null||pesticidesLimit.getLimited()==null||pesticidesLimit.getDeterminePlace()==null||pesticidesLimit.getCountryPlace()==null){
return 0;
}
else{
pesticidesLimit.setTips("新增数据成功");
pesticidesLimitMapper.insertPesticidesLimit(pesticidesLimit);
return 1;
}
}
public List<PesticidesLimit> ListPesticides(){
List<PesticidesLimit> pesticidesLimits=pesticidesLimitMapper.ListPesticides();
for(int i = 0;i<pesticidesLimits.size();i++){
String aa = pesticidesLimits.get(i).getLimited();//得到原始数据
if(aa==null)
{}
else if(aa.contains("量")||aa.contains("可")||aa.contains("脂肪")||aa.contains("肉")||aa.contains("内脏")||aa.contains("原样")||aa.contains("鱼类")||aa.contains("豁免")){
pesticidesLimits.get(i).setDoseUnit("");
}
else if(aa.contains("mg/kg")){
pesticidesLimits.get(i).setDoseUnit("mg/kg");
pesticidesLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/kg")));
}
else if(aa.contains("μg/kg")){
pesticidesLimits.get(i).setDoseUnit("μg/kg");
pesticidesLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("μg/kg")));
}
else if (aa.contains("g/kg"))
{
pesticidesLimits.get(i).setDoseUnit("g/kg");//赋予字段单位
pesticidesLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("g/kg")));//赋予字段数值
}
else if (aa.contains("mg/L"))
{
pesticidesLimits.get(i).setDoseUnit("mg/L");//赋予字段单位
pesticidesLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/L")));//赋予字段数值
}
else {pesticidesLimits.get(i).setDoseUnit("mg/kg");}
}
return pesticidesLimits;
}
public int Update(PesticidesLimit pesticidesLimit) {
PesticidesLimit AA = pesticidesLimitMapper.findById(pesticidesLimit);
if (AA.getPesticidesCname() == pesticidesLimit.getPesticidesCname() && AA.getFoodName() == pesticidesLimit.getFoodName() && AA.getRemarks() == pesticidesLimit.getRemarks()) {
return pesticidesLimitMapper.Update(pesticidesLimit);
} else {
if (pesticidesLimitMapper.judge(pesticidesLimit.getPesticidesCname(), pesticidesLimit.getFoodName(), pesticidesLimit.getRemarks()) != null) {
return 0;
} else {
Update2(AA);
insertPesticidesLimit(pesticidesLimit);
return 1;
}
}
}
public int delete(String pesticidesCname){
return pesticidesLimitMapper.delete(pesticidesCname);
}
public int Update2(PesticidesLimit pesticidesLimit){
return pesticidesLimitMapper.Update2(pesticidesLimit);
}
public void read(){};
public List<Sheet> getSheet(){
List<Sheet> rootSheet=pesticidesLimitMapper.getsheet();//原始数据
//输出结果用于检查
for(Sheet sheet: rootSheet){
System.out.println(sheet);
}
// 最后的结果
List<Sheet> sheetList=new ArrayList<Sheet>();
for(int i=0;i<rootSheet.size();i++){
if("peak".equals(rootSheet.get(i).getParentId())){
sheetList.add(rootSheet.get(i));
}
}
for(Sheet sheet: sheetList){
sheet.setChildren(getChild(sheet.getValue(),rootSheet));
}
return sheetList;
}
private List<Sheet> getChild(String id,List<Sheet> rootSheet){
List<Sheet> childList=new ArrayList<>();
for(Sheet sheet: rootSheet){
if(StringUtils.isNotBlank(sheet.getParentId())){
if(sheet.getParentId().equals(id)){
childList.add(sheet);
}
}
}
for(Sheet sheet: childList){
sheet.setChildren(getChild(sheet.getValue(),rootSheet));
}
if(childList.size()==0){
return null;
}
return childList;
}
}
\ No newline at end of file
package com.example.demo.service;
import java.util.ArrayList;
import java.util.List;
import com.example.demo.entity.Sheet;
import org.apache.commons.lang.StringUtils;
import org.apache.jasper.tagplugins.jstl.core.If;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.demo.entity.PollutantLimit;
import com.example.demo.mapper.PollutantLimitMapper;
@Service
public class PollutantLimitService {
@Autowired
private PollutantLimitMapper pollutantLimitMapper;
public List<PollutantLimit> findByName(String pollutant_cname,String food_sort_no) {
List<PollutantLimit> pollutantLimits=pollutantLimitMapper.findUserBypollutant_cname(pollutant_cname,food_sort_no);
for(int i = 0;i<pollutantLimits.size();i++){
String aa = pollutantLimits.get(i).getLimited();//得到原始数据
if(aa.contains("液态")||aa.contains("固态")||aa.contains("鱼类")){
pollutantLimits.get(i).setDoseUnit("");
}
else if(aa.contains("mg/kg")){
pollutantLimits.get(i).setDoseUnit("mg/kg");
pollutantLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/kg")));
}
else if(aa.contains("μg/kg")){
pollutantLimits.get(i).setDoseUnit("μg/kg");
pollutantLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("μg/kg")));
}
else if (aa.contains("g/kg"))
{
pollutantLimits.get(i).setDoseUnit("g/kg");//赋予字段单位
pollutantLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("g/kg")));//赋予字段数值
}
else if (aa.contains("mg/L"))
{
pollutantLimits.get(i).setDoseUnit("mg/L");//赋予字段单位
pollutantLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/L")));//赋予字段数值
}
}
return pollutantLimits;
}
public int insertPollutantLimit(PollutantLimit pollutantLimit) {
PollutantLimit pollutantLimits=pollutantLimitMapper.judge(pollutantLimit.getPollutant_cname(),pollutantLimit.getFood_name(),pollutantLimit.getRemarks());
if(pollutantLimits!=null)
{
pollutantLimit.setTips("已有数据,请查找后进行编辑");
return 0;
}
if(pollutantLimit.getPollutant_cname()==null||pollutantLimit.getPollutant_ename()==null||pollutantLimit.getLimited()==null||pollutantLimit.getCountry_place()==null){
return 0;
}
pollutantLimitMapper.insertPollutantLimit(pollutantLimit);
return 1;
}
public List<PollutantLimit> ListUser(){
List<PollutantLimit> pollutantLimits=pollutantLimitMapper.ListUser();
for(int i = 0;i<pollutantLimits.size();i++){
String aa = pollutantLimits.get(i).getLimited();//得到原始数据
if(aa==null)
{}
else if(aa.contains("液态")||aa.contains("固态")){
pollutantLimits.get(i).setDoseUnit("");
}
else if(aa.contains("mg/kg")){
pollutantLimits.get(i).setDoseUnit("mg/kg");
pollutantLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("mg/kg")));
}
else if(aa.contains("μg/kg")){
pollutantLimits.get(i).setDoseUnit("μg/kg");
pollutantLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("μg/kg")));
}
else if (aa.contains("g/kg"))
{
pollutantLimits.get(i).setDoseUnit("g/kg");//赋予字段单位
pollutantLimits.get(i).setLimited(aa.substring(0,aa.lastIndexOf("g/kg")));//赋予字段数值
}
}
return pollutantLimits;
}
public int Update(PollutantLimit pollutantLimit){
PollutantLimit AA=pollutantLimitMapper.findById(pollutantLimit);
if(AA.getPollutant_cname()==pollutantLimit.getPollutant_cname()&&AA.getFood_name()==pollutantLimit.getFood_name()&&AA.getRemarks()==pollutantLimit.getRemarks())
{
return pollutantLimitMapper.Update(pollutantLimit);
}
else {
if(pollutantLimitMapper.judge(pollutantLimit.getPollutant_cname(),pollutantLimit.getFood_name(),pollutantLimit.getRemarks())!=null){
return 0;
}
else{
Update2(AA);
insertPollutantLimit(pollutantLimit);
return 1;
}
}
}
public int delete(String pollutant_cname){
return pollutantLimitMapper.delete(pollutant_cname);
}
public int Update2(PollutantLimit pollutantLimit){
return pollutantLimitMapper.Update2(pollutantLimit);
}
public void read(){};
public List<Sheet> getSheet(){
List<Sheet> rootSheet=pollutantLimitMapper.getsheet();//原始数据
//输出结果用于检查
for(Sheet sheet: rootSheet){
System.out.println(sheet);
}
// 最后的结果
List<Sheet> sheetList=new ArrayList<Sheet>();
for(int i=0;i<rootSheet.size();i++){
if("peak".equals(rootSheet.get(i).getParentId())){
sheetList.add(rootSheet.get(i));
}
}
for(Sheet sheet: sheetList){
sheet.setChildren(getChild(sheet.getValue(),rootSheet));
}
return sheetList;
}
private List<Sheet> getChild(String id,List<Sheet> rootSheet){
List<Sheet> childList=new ArrayList<>();
for(Sheet sheet: rootSheet){
if(StringUtils.isNotBlank(sheet.getParentId())){
if(sheet.getParentId().equals(id)){
childList.add(sheet);
}
}
}
for(Sheet sheet: childList){
sheet.setChildren(getChild(sheet.getValue(),rootSheet));
}
if(childList.size()==0){
return null;
}
return childList;
}
}
\ No newline at end of file
spring.datasource.url = jdbc:mysql://47.99.58.80:6633/formulacheck?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username = foodpanel
spring.datasource.password = foodpanel2wsx@WSX@@**
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
spring.datasource.max-active=20 //指定连接池中最大的活跃连接数
spring.datasource.max-idle=8 //指定连接池中连接的最大的空闲连接数量
spring.datasource.min-idle=8 //指定必须保持连接的最小值
spring.datasource.initial-size=10 //指定启动连接池时,初始建立的连接数量
mybatis.mapper-locations= classpath:mapper/*.xml
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
server.port=8092
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE mapper PUBLIC
"-//mybatis.org//DTD com.example.Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.mapper.AdditiveMapper">
<resultMap id="result3" type="com.example.demo.entity.Additive">
<result property="additiveCname" column="additive_cname" />
<result property="additiveEname" column="additive_ename"/>
<result property="cnsNo" column="cns_no"/>
<result property="insNo" column="ins_no"/>
<result property="maxUsage" column="max_usage"/>
<result property="informationSources" column="information_sources"/>
<result property="countryPlace" column="country_place"/>
<result property="foodCname" column="food_cname"/>
<result property="sortExplain" column="sort_explain"/>
<result property="foodEname" column="food_ename"/>
<result property="foodSortNo" column="food_sort_no"/>
</resultMap>
<resultMap id="resultMap3" type="com.example.demo.entity.Sheet">
<result property="label" column="category_name"/>
<result property="parentId" column="parent_code"/>
<result property="value" column="category_code" />
</resultMap>
<select id="getsheet" resultMap="resultMap3">
select * from fc_food_category_additive
</select>
<select id="ListAdditive" resultMap="result3">
SELECT * FROM fc_additive_copy1 where state =1 order by id
</select>
<select id="findAdditiveByAdditiveCname" resultMap="result3">
<if test="additiveCname!= null and foodSortNo != null">
SELECT * FROM fc_additive_copy1 where additive_cname=#{additiveCname} AND food_sort_no=#{foodSortNo}AND state =1
</if>
<if test="additiveCname!= null and foodSortNo == null">
SELECT * FROM fc_additive_copy1 where additive_cname=#{additiveCname}AND state =1
</if>
<if test="additiveCname== null and foodSortNo != null">
SELECT * FROM fc_additive_copy1 where food_sort_no=#{foodSortNo}AND state =1
</if>
<if test="additiveCname==null and foodSortNo ==null">
SELECT * FROM fc_additive_copy1 where state =1 order by id
</if>
</select>
<select id="match" parameterType="com.example.demo.entity.PollutantLimit" resultType="String">
<if test="food_sort_no!=null">
select category_name from fc_food_category_additive where category_code=#{food_sort_no}
</if>
<if test="food_name!=null">
select category_code from fc_food_category_additive where category_name=#{food_name}
</if>
</select>
<select id="judge" resultMap="result3">
SELECT * FROM fc_additive_copy1
<where>
<if test="additiveCname!= null and foodCname != null and remarks !=null">
additive_cname=#{additiveCname} AND food_cname=#{foodCname} AND state =1 AND remarks=#{remarks}
</if>
<if test="additiveCname!= null and foodCname == null and remarks !=null ">
additive_cname=#{additiveCname}AND state =1 AND remarks=#{remarks}
</if>
<if test="additiveCname== null and foodCname != null and remarks !=null">
food_cname=#{foodCname}AND state =1 AND remarks=#{remarks}
</if>
<if test="additiveCname==null and foodCname ==null and remarks !=null">
state =1 AND remarks=#{remarks} order by id
</if>
<if test="additiveCname!= null and foodCname != null and remarks ==null">
additive_cname=#{additiveCname} AND food_cname=#{foodCname} AND state =1
</if>
<if test="additiveCname!= null and foodCname == null and remarks ==null ">
additive_cname=#{additiveCname}AND state =1
</if>
<if test="additiveCname== null and foodCname != null and remarks ==null">
food_cname=#{foodCname}AND state =1
</if>
<if test="additiveCname==null and foodCname ==null and remarks ==null">
state =1 order by id
</if>
</where>
</select>
<insert id="insertAdditive" parameterType="com.example.demo.entity.Additive"
keyProperty="id" useGeneratedKeys="true">
INSERT INTO fc_additive_copy1(additive_cname,additive_ename,food_cname,food_ename,cns_no,ins_no,country_place,max_usage,information_sources,sort_explain,function,remarks,food_sort_no,state)
VALUES (#{additiveCname, jdbcType=VARCHAR},#{additiveEname, jdbcType=VARCHAR},#{foodCname, jdbcType=VARCHAR},#{foodEname, jdbcType=VARCHAR},#{cnsNo, jdbcType=VARCHAR},#{insNo, jdbcType=VARCHAR},
#{countryPlace, jdbcType=VARCHAR},#{maxUsage, jdbcType=VARCHAR},#{informationSources, jdbcType=VARCHAR},#{sortExplain, jdbcType=VARCHAR},#{function, jdbcType=VARCHAR},#{remarks, jdbcType=VARCHAR},#{foodSortNo,jdbcType=VARCHAR},1 )
</insert>
<update id="Update" parameterType="com.example.demo.entity.Additive">
update fc_additive_copy1 set id=#{id},additive_cname=#{additiveCname},additive_ename=#{additiveEname},food_cname=#{foodCname},
food_ename=#{foodEname},cns_no=#{cnsNo},ins_no=#{insNo},max_usage=#{maxUsage},information_sources=#{informationSources},sort_explain=#{sortExplain},remarks=#{remarks},
information_sources=#{informationSources},sort_explain=#{sortExplain},function=#{function},country_place=#{countryPlace},food_sort_no=#{foodSortNo},
state=1 where id=#{id}
</update>
<update id="Update2" parameterType="com.example.demo.entity.Additive">
update fc_additive_copy1 set state=0 where id=#{id}
</update>
<select id="findById" resultMap="result3">
SELECT * FROM fc_additive_copy1 where id =#{id}
</select>
</mapper>
\ No newline at end of file
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE mapper PUBLIC
"-//mybatis.org//DTD com.example.Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.mapper.FungimycinLimitMapper">
<resultMap id="result1" type="com.example.demo.entity.FungimycinLimit">
<result property="fungimycinCname" column="fungimycin_cname" />
<result property="fungimycinEname" column="fungimycin_ename"/>
<result property="foodName" column="food_name"/>
<result property="countryPlace" column="country_place"/>
<result property="checkWay" column="check_way"/>
<result property="informationSources" column="information_sources"/>
</resultMap>
<resultMap id="resultMap1" type="com.example.demo.entity.Sheet">
<result property="label" column="category_name"/>
<result property="parentId" column="parent_code"/>
<result property="value" column="category_code" />
</resultMap>
<select id="getsheet" resultMap="resultMap1">
select * from fc_food_category_fungimycin
</select>
<select id="ListFungimycin" resultMap="result1">
SELECT * FROM fc_Fungimycin_limit_copy1 where state =1 order by id
</select>
<select id="findFungimycinByFungimycinCname" resultMap="result1">
<if test="fungimycinCname!= null and food_sort_no != null">
SELECT * FROM fc_fungimycin_limit_copy1 where fungimycin_cname=#{fungimycinCname} AND food_sort_no=#{food_sort_no}AND state =1
</if>
<if test="fungimycinCname!= null and food_sort_no == null">
SELECT * FROM fc_fungimycin_limit_copy1 where fungimycin_cname=#{fungimycinCname}AND state =1
</if>
<if test="fungimycinCname== null and food_sort_no != null">
SELECT * FROM fc_fungimycin_limit_copy1 where food_sort_no=#{food_sort_no}AND state =1
</if>
<if test="fungimycinCname==null and food_sort_no ==null">
SELECT * FROM fc_fungimycin_limit_copy1 where state =1 order by id
</if>
</select>
<select id="judge" resultMap="result1">
<if test="fungimycinCname!= null and foodName != null and remarks!=null">
SELECT * FROM fc_fungimycin_limit_copy1 where fungimycin_cname=#{fungimycinCname} AND food_name=#{foodName}AND state =1 AND remarks=#{remarks}
</if>
<if test="fungimycinCname!= null and foodName == null and remarks!=null">
SELECT * FROM fc_fungimycin_limit_copy1 where fungimycin_cname=#{fungimycinCname}AND state =1 AND remarks=#{remarks}
</if>
<if test="fungimycinCname== null and foodName != null and remarks!=null">
SELECT * FROM fc_fungimycin_limit_copy1 where food_name=#{foodName}AND state =1 AND remarks=#{remarks}
</if>
<if test="fungimycinCname==null and foodName ==null and remarks!=null">
SELECT * FROM fc_fungimycin_limit_copy1 where state =1 AND remarks=#{remarks} order by id
</if>
<if test="fungimycinCname!= null and foodName != null and remarks==null">
SELECT * FROM fc_fungimycin_limit_copy1 where fungimycin_cname=#{fungimycinCname} AND food_name=#{foodName}AND state =1
</if>
<if test="fungimycinCname!= null and foodName == null and remarks==null">
SELECT * FROM fc_fungimycin_limit_copy1 where fungimycin_cname=#{fungimycinCname}AND state =1
</if>
<if test="fungimycinCname== null and foodName != null and remarks==null">
SELECT * FROM fc_fungimycin_limit_copy1 where food_name=#{foodName}AND state =1
</if>
<if test="fungimycinCname==null and foodName ==null and remarks==null">
SELECT * FROM fc_fungimycin_limit_copy1 where state =1 order by id
</if>
</select>
<insert id="insertFungimycinLimit" parameterType="com.example.demo.entity.FungimycinLimit"
keyProperty="id" useGeneratedKeys="true">
INSERT INTO fc_fungimycin_limit_copy1(fungimycin_cname,fungimycin_ename,food_name,country_place,check_way,information_sources,limited,remarks,state)
VALUES (#{fungimycinCname, jdbcType=VARCHAR},#{fungimycinEname, jdbcType=VARCHAR},#{foodName, jdbcType=VARCHAR},
#{countryPlace, jdbcType=VARCHAR},#{checkWay, jdbcType=VARCHAR},#{informationSources, jdbcType=VARCHAR},#{limited, jdbcType=VARCHAR},#{remarks, jdbcType=VARCHAR},1 )
</insert>
<update id="Update" parameterType="com.example.demo.entity.FungimycinLimit">
update fc_fungimycin_limit_copy1 set id=#{id},fungimycin_cname=#{fungimycinCname},fungimycin_ename=#{fungimycinEname},food_name=#{foodName},
country_place=#{countryPlace},check_way=#{checkWay},information_sources=#{informationSources},limited=#{limited},remarks=#{remarks},
state=1 where id=#{id}
</update>
<update id="Update2" parameterType="com.example.demo.entity.FungimycinLimit">
update fc_fungimycin_limit_copy1 set state=0 where id=#{id}
</update>
<select id="findById" resultMap="result1">
SELECT * FROM fc_fungimycin_limit_copy1 where id =#{id}
</select>
</mapper>
\ No newline at end of file
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE mapper PUBLIC
"-//mybatis.org//DTD com.example.Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.mapper.PesticidesLimitMapper">
<resultMap id="result2" type="com.example.demo.entity.PesticidesLimit">
<result property="pesticidesCname" column="pesticides_cname" />
<result property="pesticidesEname" column="pesticides_ename"/>
<result property="foodName" column="food_name"/>
<result property="countryPlace" column="country_place"/>
<result property="checkWay" column="check_way"/>
<result property="informationSources" column="information_sources"/>
<result property="determinePlace" column="determine_place"/>
<result property="mainUses" column="main_uses"/>
</resultMap>
<resultMap id="resultMap2" type="com.example.demo.entity.Sheet">
<result property="label" column="category_name_pesticides"/>
<result property="parentId" column="parent_code"/>
<result property="value" column="category_code" />
</resultMap>
<select id="getsheet" resultMap="resultMap2">
select * from fc_food_category_pesticides
</select>
<select id="ListPesticides" resultMap="result2">
SELECT * FROM fc_pesticides_limit_copy1 where state =1 order by id
</select>
<select id="findPesticidesByPesticidesCname" resultMap="result2">
<if test="pesticidesCname!= null and food_sort_no != null">
SELECT * FROM fc_pesticides_limit_copy1 where pesticides_cname=#{pesticidesCname} AND food_sort_no=#{food_sort_no}AND state =1
</if>
<if test="pesticidesCname!= null and food_sort_no == null">
SELECT * FROM fc_pesticides_limit_copy1 where pesticides_cname=#{pesticidesCname}AND state =1
</if>
<if test="pesticidesCname== null and food_sort_no != null">
SELECT * FROM fc_pesticides_limit_copy1 where food_sort_no=#{food_sort_no}AND state =1
</if>
<if test="pesticidesCname==null and food_sort_no ==null">
SELECT * FROM fc_pesticides_limit_copy1 where state =1 order by id
</if>
</select>
<insert id="insertPesticidesLimit" parameterType="com.example.demo.entity.PesticidesLimit"
keyProperty="id" useGeneratedKeys="true">
INSERT INTO fc_pesticides_limit_copy1(pesticides_cname,pesticides_ename,food_name,main_uses,adi,residue,determine_place,country_place,check_way,information_sources,limited,remarks,state)
VALUES (#{pesticidesCname, jdbcType=VARCHAR},#{pesticidesEname, jdbcType=VARCHAR},#{foodName, jdbcType=VARCHAR},#{mainUses, jdbcType=VARCHAR},#{adi, jdbcType=VARCHAR},#{residue, jdbcType=VARCHAR},#{determinePlace, jdbcType=VARCHAR},
#{countryPlace, jdbcType=VARCHAR},#{checkWay, jdbcType=VARCHAR},#{informationSources, jdbcType=VARCHAR},#{limited, jdbcType=VARCHAR},#{remarks, jdbcType=VARCHAR},1 )
</insert>
<update id="Update" parameterType="com.example.demo.entity.PesticidesLimit">
update fc_pesticides_limit_copy1 set id=#{id},pesticides_cname=#{pesticidesCname},pesticides_ename=#{pesticidesEname},food_name=#{foodName},
country_place=#{countryPlace},check_way=#{checkWay},check_way=#{checkWay},main_uses=#{mainUses},adi=#{adi},residue=#{residue},determine_place=#{determinePlace},information_sources=#{informationSources},limited=#{limited},remarks=#{remarks},
state=1 where id=#{id}
</update>
<update id="Update2" parameterType="com.example.demo.entity.PesticidesLimit">
update fc_pesticides_limit_copy1 set state=0 where id=#{id}
</update>
<select id="judge" resultMap="result2">
SELECT * FROM fc_pesticides_limit_copy1
<where>
<if test="pesticidesCname!= null and foodName != null and remarks !=null">
pesticides_cname=#{pesticidesCname} AND food_name=#{foodName} AND state =1 AND remarks=#{remarks}
</if>
<if test="pesticidesCname!= null and foodName == null and remarks !=null ">
pesticides_cname=#{pesticidesCname}AND state =1 AND remarks=#{remarks}
</if>
<if test="pesticidesCname== null and foodName != null and remarks !=null">
food_name=#{foodName}AND state =1 AND remarks=#{remarks}
</if>
<if test="pesticidesCname==null and foodName ==null and remarks !=null">
state =1 AND remarks=#{remarks} order by id
</if>
<if test="pesticidesCname!= null and foodName != null and remarks ==null">
pesticides_cname=#{pesticidesCname} AND food_name=#{foodName} AND state =1
</if>
<if test="pesticidesCname!= null and foodName == null and remarks ==null ">
pesticides_cname=#{pesticidesCname}AND state =1
</if>
<if test="pesticidesCname== null and foodName != null and remarks ==null">
food_name=#{foodName}AND state =1
</if>
<if test="pesticidesCname==null and foodName ==null and remarks ==null">
state =1 order by id
</if>
</where>
</select>
<select id="findById" resultMap="result2">
SELECT * FROM fc_pesticides_limit_copy1 where id =#{id}
</select>
</mapper>
\ No newline at end of file
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE mapper PUBLIC
"-//mybatis.org//DTD com.example.Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.mapper.PollutantLimitMapper">
<resultMap id="result" type="com.example.demo.entity.PollutantLimit">
</resultMap>
<resultMap id="resultMap" type="com.example.demo.entity.Sheet">
<result property="label" column="category_name"/>
<result property="parentId" column="parent_code"/>
<result property="value" column="category_code" />
</resultMap>
<select id="getsheet" resultMap="resultMap">
select * from fc_food_category_pollutant
</select>
<select id="ListUser" resultMap="result">
SELECT * FROM fc_pollutant_limit_copy1 where state =1 order by id
</select>
<select id="findUserBypollutant_cname" resultMap="result">
SELECT * FROM fc_pollutant_limit_copy1
<where>
<if test="pollutant_cname!= null and food_sort_no != null">
pollutant_cname=#{pollutant_cname} AND food_sort_no=#{food_sort_no} AND state =1
</if>
<if test="pollutant_cname!= null and food_sort_no == null ">
pollutant_cname=#{pollutant_cname}AND state =1
</if>
<if test="pollutant_cname== null and food_sort_no != null">
food_sort_no=#{food_sort_no}AND state =1
</if>
<if test="pollutant_cname==null and food_sort_no ==null">
state =1 order by id
</if>
</where>
</select>
<select id="judge" resultMap="result">
SELECT * FROM fc_pollutant_limit_copy1
<where>
<if test="pollutant_cname!= null and food_name != null and remarks !=null">
pollutant_cname=#{pollutant_cname} AND food_name=#{food_name} AND state =1 AND remarks=#{remarks}
</if>
<if test="pollutant_cname!= null and food_name == null and remarks !=null ">
pollutant_cname=#{pollutant_cname}AND state =1 AND remarks=#{remarks}
</if>
<if test="pollutant_cname== null and food_name != null and remarks !=null">
food_name=#{food_name}AND state =1 AND remarks=#{remarks}
</if>
<if test="pollutant_cname==null and food_name ==null and remarks !=null">
state =1 AND remarks=#{remarks} order by id
</if>
<if test="pollutant_cname!= null and food_name != null and remarks ==null">
pollutant_cname=#{pollutant_cname} AND food_name=#{food_name} AND state =1
</if>
<if test="pollutant_cname!= null and food_name == null and remarks ==null ">
pollutant_cname=#{pollutant_cname}AND state =1
</if>
<if test="pollutant_cname== null and food_name != null and remarks ==null">
food_name=#{food_name}AND state =1
</if>
<if test="pollutant_cname==null and food_name ==null and remarks ==null">
state =1 order by id
</if>
</where>
</select>
<select id="findById" resultMap="result">
SELECT * FROM fc_pollutant_limit_copy1 where id =#{id}
</select>
<insert id="insertPollutantLimit" parameterType="com.example.demo.entity.PollutantLimit"
keyProperty="id" useGeneratedKeys="true">
INSERT INTO fc_pollutant_limit_copy1(pollutant_cname,pollutant_ename,food_name,limited,country_place,check_way,information_sources,remarks,state)
VALUES (#{pollutant_cname, jdbcType=VARCHAR},#{pollutant_ename, jdbcType=VARCHAR},#{food_name, jdbcType=VARCHAR},
#{limited, jdbcType=VARCHAR},#{country_place, jdbcType=VARCHAR},#{check_way, jdbcType=VARCHAR},#{information_sources, jdbcType=VARCHAR},
#{remarks, jdbcType=VARCHAR},1 )
</insert>
<update id="Update" parameterType="com.example.demo.entity.PollutantLimit">
update fc_pollutant_limit_copy1 set id=#{id},pollutant_cname=#{pollutant_cname},pollutant_ename=#{pollutant_ename},food_name=#{food_name},
limited=#{limited},country_place=#{country_place},check_way=#{check_way},information_sources=#{information_sources},remarks=#{remarks},
state=1 where id=#{id}
</update>
<update id="Update2" parameterType="com.example.demo.entity.PollutantLimit">
update fc_pollutant_limit_copy1 set state=0 where id=#{id}
</update>
</mapper>
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
单个文件上传:<br/>
<form action="/CRUD/AdditiveUpload" method="post" enctype="multipart/form-data">
<input type="file" name="file"/>
<input type="submit" value="提交上传"/>
</form>
<br/>
</body>
</html>
package com.example.demo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoApplicationTests {
@Test
public void contextLoads() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment