校園失物招領系統帶萬字文檔java項目失物招領管理系統java課程設計java畢業設計springboot vue

文章目錄

  • 校園失物招領系統
    • 一、項目演示
    • 二、項目介紹
    • 三、萬字字項目文檔
    • 四、部分功能截圖
    • 五、部分代碼展示
    • 六、底部獲取項目源碼帶萬字文檔(9.9¥帶走)

校園失物招領系統

一、項目演示

校園失物招領系統

二、項目介紹

語言: Java 數據庫:MySQL

技術棧 : SpringBoot+MybatisPlus+Vue+Html

系統角色:管理員、用戶

管理員:管理員:登錄、基礎數據管理、系統管理、留言板管理、失物信息管理、失物認領管理、尋物啟事管理等功能

用戶:登錄、注冊、留言板、公告信息、失物招領、失物認領、尋物啟事、個人中心、我發布的失物信息、我的失物認領、我發布的尋物啟事、尋物啟事留言等功能

三、萬字字項目文檔

在這里插入圖片描述

在這里插入圖片描述

四、部分功能截圖

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

五、部分代碼展示


package com.controller;import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;/*** 操作日志* 后端接口* @author* @email
*/
@RestController
@Controller
@RequestMapping("/caozuorizhi")
public class CaozuorizhiController {private static final Logger logger = LoggerFactory.getLogger(CaozuorizhiController.class);private static final String TABLE_NAME = "caozuorizhi";@Autowiredprivate CaozuorizhiService caozuorizhiService;@Autowiredprivate TokenService tokenService;@Autowiredprivate DictionaryService dictionaryService;//字典@Autowiredprivate LiuyanService liuyanService;//留言板@Autowiredprivate NewsService newsService;//公告信息@Autowiredprivate ShiwuzhaolingService shiwuzhaolingService;//失物信息@Autowiredprivate ShiwuzhaolingYuyueService shiwuzhaolingYuyueService;//失物認領@Autowiredprivate XunwuqishiService xunwuqishiService;//尋物啟事@Autowiredprivate XunwuqishiLiuyanService xunwuqishiLiuyanService;//尋物啟事留言@Autowiredprivate YonghuService yonghuService;//用戶@Autowiredprivate UsersService usersService;//管理員/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永不會進入");else if("用戶".equals(role))params.put("yonghuId",request.getSession().getAttribute("userId"));CommonUtil.checkMap(params);PageUtils page = caozuorizhiService.queryPage(params);//字典表數據轉換List<CaozuorizhiView> list =(List<CaozuorizhiView>)page.getList();for(CaozuorizhiView c:list){//修改對應字典表字段dictionaryService.dictionaryConvert(c, request);}return R.ok().put("data", page);}/*** 后端詳情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);CaozuorizhiEntity caozuorizhi = caozuorizhiService.selectById(id);if(caozuorizhi !=null){//entity轉viewCaozuorizhiView view = new CaozuorizhiView();BeanUtils.copyProperties( caozuorizhi , view );//把實體數據重構到view中//修改對應字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到數據");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody CaozuorizhiEntity caozuorizhi, HttpServletRequest request){logger.debug("save方法:,,Controller:{},,caozuorizhi:{}",this.getClass().getName(),caozuorizhi.toString());String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永遠不會進入");Wrapper<CaozuorizhiEntity> queryWrapper = new EntityWrapper<CaozuorizhiEntity>().eq("caozuorizhi_this_biao", caozuorizhi.getCaozuorizhiThisBiao()).eq("caozuorizhi_caozuobiao", caozuorizhi.getCaozuorizhiCaozuobiao()).eq("caozuorizhi_caozuozhanghu", caozuorizhi.getCaozuorizhiCaozuozhanghu()).eq("caozuorizhi_caozuoleixing", caozuorizhi.getCaozuorizhiCaozuoleixing());logger.info("sql語句:"+queryWrapper.getSqlSegment());CaozuorizhiEntity caozuorizhiEntity = caozuorizhiService.selectOne(queryWrapper);if(caozuorizhiEntity==null){caozuorizhi.setInsertTime(new Date());caozuorizhi.setCreateTime(new Date());caozuorizhiService.insert(caozuorizhi);return R.ok();}else {return R.error(511,"表中有相同數據");}}/*** 后端修改*/@RequestMapping("/update")public R update(@RequestBody CaozuorizhiEntity caozuorizhi, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {logger.debug("update方法:,,Controller:{},,caozuorizhi:{}",this.getClass().getName(),caozuorizhi.toString());CaozuorizhiEntity oldCaozuorizhiEntity = caozuorizhiService.selectById(caozuorizhi.getId());//查詢原先數據String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永遠不會進入");caozuorizhiService.updateById(caozuorizhi);//根據id更新return R.ok();}/*** 刪除*/@RequestMapping("/delete")public R delete(@RequestBody Integer[] ids, HttpServletRequest request){logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());List<CaozuorizhiEntity> oldCaozuorizhiList =caozuorizhiService.selectBatchIds(Arrays.asList(ids));//要刪除的數據caozuorizhiService.deleteBatchIds(Arrays.asList(ids));return R.ok();}/*** 批量上傳*/@RequestMapping("/batchInsert")public R save( String fileName, HttpServletRequest request){logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))try {List<CaozuorizhiEntity> caozuorizhiList = new ArrayList<>();//上傳的東西Map<String, List<String>> seachFields= new HashMap<>();//要查詢的字段Date date = new Date();int lastIndexOf = fileName.lastIndexOf(".");if(lastIndexOf == -1){return R.error(511,"該文件沒有后綴");}else{String suffix = fileName.substring(lastIndexOf);if(!".xls".equals(suffix)){return R.error(511,"只支持后綴為xls的excel文件");}else{URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//獲取文件路徑File file = new File(resource.getFile());if(!file.exists()){return R.error(511,"找不到上傳文件,請聯系管理員");}else{List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//讀取xls文件dataList.remove(0);//刪除第一行,因為第一行是提示for(List<String> data:dataList){//循環CaozuorizhiEntity caozuorizhiEntity = new CaozuorizhiEntity();
//                            caozuorizhiEntity.setCaozuorizhiThisBiao(data.get(0));                    //操作人所在表 要改的
//                            caozuorizhiEntity.setCaozuorizhiCaozuobiao(data.get(0));                    //操作表 要改的
//                            caozuorizhiEntity.setCaozuorizhiCaozuozhanghu(data.get(0));                    //操作賬戶 要改的
//                            caozuorizhiEntity.setCaozuorizhiCaozuoleixing(data.get(0));                    //操作類型 要改的
//                            caozuorizhiEntity.setCaozuorizhiText(data.get(0));                    //操作內容 要改的
//                            caozuorizhiEntity.setInsertTime(date);//時間
//                            caozuorizhiEntity.setCreateTime(date);//時間caozuorizhiList.add(caozuorizhiEntity);//把要查詢是否重復的字段放入map中}//查詢是否重復caozuorizhiService.insertBatch(caozuorizhiList);return R.ok();}}}}catch (Exception e){e.printStackTrace();return R.error(511,"批量插入數據異常,請聯系管理員");}}/*** 前端列表*/@IgnoreAuth@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));CommonUtil.checkMap(params);PageUtils page = caozuorizhiService.queryPage(params);//字典表數據轉換List<CaozuorizhiView> list =(List<CaozuorizhiView>)page.getList();for(CaozuorizhiView c:list)dictionaryService.dictionaryConvert(c, request); //修改對應字典表字段return R.ok().put("data", page);}/*** 前端詳情*/@RequestMapping("/detail/{id}")public R detail(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);CaozuorizhiEntity caozuorizhi = caozuorizhiService.selectById(id);if(caozuorizhi !=null){//entity轉viewCaozuorizhiView view = new CaozuorizhiView();BeanUtils.copyProperties( caozuorizhi , view );//把實體數據重構到view中//修改對應字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到數據");}}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody CaozuorizhiEntity caozuorizhi, HttpServletRequest request){logger.debug("add方法:,,Controller:{},,caozuorizhi:{}",this.getClass().getName(),caozuorizhi.toString());Wrapper<CaozuorizhiEntity> queryWrapper = new EntityWrapper<CaozuorizhiEntity>().eq("caozuorizhi_this_biao", caozuorizhi.getCaozuorizhiThisBiao()).eq("caozuorizhi_caozuobiao", caozuorizhi.getCaozuorizhiCaozuobiao()).eq("caozuorizhi_caozuozhanghu", caozuorizhi.getCaozuorizhiCaozuozhanghu()).eq("caozuorizhi_caozuoleixing", caozuorizhi.getCaozuorizhiCaozuoleixing()).eq("caozuorizhi_text", caozuorizhi.getCaozuorizhiText())
//            .notIn("caozuorizhi_types", new Integer[]{102});logger.info("sql語句:"+queryWrapper.getSqlSegment());CaozuorizhiEntity caozuorizhiEntity = caozuorizhiService.selectOne(queryWrapper);if(caozuorizhiEntity==null){caozuorizhi.setInsertTime(new Date());caozuorizhi.setCreateTime(new Date());caozuorizhiService.insert(caozuorizhi);return R.ok();}else {return R.error(511,"表中有相同數據");}}}
package com.controller;import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;import javax.servlet.http.HttpServletRequest;import com.alibaba.fastjson.JSON;
import com.utils.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;import com.annotation.IgnoreAuth;
import com.baidu.aip.face.AipFace;
import com.baidu.aip.face.MatchRequest;
import com.baidu.aip.util.Base64Util;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.ConfigEntity;
import com.service.CommonService;
import com.service.ConfigService;
import com.utils.BaiduUtil;
import com.utils.FileUtil;
import com.utils.R;/*** 通用接口*/
@RestController
public class CommonController {private static final Logger logger = LoggerFactory.getLogger(CommonController.class);@Autowiredprivate CommonService commonService;/*** Java代碼實現MySQL數據庫導出** @param mysqlUrl     MySQL安裝路徑* @param hostIP       MySQL數據庫所在服務器地址IP* @param userName     進入數據庫所需要的用戶名* @param hostPort     數據庫端口* @param password     進入數據庫所需要的密碼* @param savePath     數據庫文件保存路徑* @param fileName     數據庫導出文件文件名* @param databaseName 要導出的數據庫名* @return 返回true表示導出成功,否則返回false。*/@IgnoreAuth@RequestMapping("/beifen")public R beifen(String mysqlUrl, String hostIP, String userName, String hostPort, String password, String savePath, String fileName, String databaseName) {File saveFile = new File(savePath);if (!saveFile.exists()) {// 如果目錄不存在 saveFile.mkdirs();// 創建文件夾 }if (!savePath.endsWith(File.separator)) {savePath = savePath + File.separator;}PrintWriter printWriter = null;BufferedReader bufferedReader = null;try {Runtime runtime = Runtime.getRuntime();String cmd = mysqlUrl + "mysqldump -h" + hostIP + " -u" + userName + " -P" + hostPort + " -p" + password + " " + databaseName;runtime.exec(cmd);Process process = runtime.exec(cmd);InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream(), "utf8");bufferedReader = new BufferedReader(inputStreamReader);printWriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(savePath + fileName), "utf8"));String line;while ((line = bufferedReader.readLine()) != null) {printWriter.println(line);}printWriter.flush();} catch (Exception e) {e.printStackTrace();return R.error("備份數據出錯");} finally {try {if (bufferedReader != null) {bufferedReader.close();}if (printWriter != null) {printWriter.close();}} catch (Exception e) {e.printStackTrace();}}return R.ok();}/*** Java實現MySQL數據庫導入** @param mysqlUrl     MySQL安裝路徑* @param hostIP       MySQL數據庫所在服務器地址IP* @param userName     進入數據庫所需要的用戶名* @param hostPort     數據庫端口* @param password     進入數據庫所需要的密碼* @param savePath     數據庫文件保存路徑* @param fileName     數據庫導出文件文件名* @param databaseName 要導出的數據庫名*/@IgnoreAuth@RequestMapping("/huanyuan")public R huanyuan(String mysqlUrl, String hostIP, String userName, String hostPort, String password, String savePath, String fileName, String databaseName) {try {Runtime rt = Runtime.getRuntime();Process child1 = rt.exec(mysqlUrl+"mysql.exe  -h" + hostIP + " -u" + userName + " -P" + hostPort + " -p" + password + " " + databaseName);OutputStream out = child1.getOutputStream();//控制臺的輸入信息作為輸出流String inStr;StringBuffer sb = new StringBuffer("");String outStr;BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(savePath+"/"+fileName), "utf-8"));while ((inStr = br.readLine()) != null) {sb.append(inStr + "\r\n");}outStr = sb.toString();OutputStreamWriter writer = new OutputStreamWriter(out, "utf8");writer.write(outStr);
// 注:這里如果用緩沖方式寫入文件的話,會導致中文亂碼,用flush()方法則可以避免writer.flush();out.close();br.close();writer.close();} catch (Exception e) {e.printStackTrace();return R.error("數據導入出錯");}return R.ok();}/*** 餅狀圖求和* @return*/@RequestMapping("/pieSum")public R pieSum(@RequestParam Map<String,Object> params) {logger.debug("餅狀圖求和:,,Controller:{},,params:{}",this.getClass().getName(),params);List<Map<String, Object>> result = commonService.pieSum(params);return R.ok().put("data", result);}/*** 餅狀圖統計* @return*/@RequestMapping("/pieCount")public R pieCount(@RequestParam Map<String,Object> params) {logger.debug("餅狀圖統計:,,Controller:{},,params:{}",this.getClass().getName(),params);List<Map<String, Object>> result = commonService.pieCount(params);return R.ok().put("data", result);}/*** 柱狀圖求和單列* @return*/@RequestMapping("/barSumOne")public R barSumOne(@RequestParam Map<String,Object> params) {logger.debug("柱狀圖求和單列:,,Controller:{},,params:{}",this.getClass().getName(),params);List<Map<String, Object>> result = commonService.barSumOne(params);List<String> xAxis = new ArrayList<>();//報表x軸List<List<String>> yAxis = new ArrayList<>();//y軸List<String> legend = new ArrayList<>();//標題List<String> yAxis0 = new ArrayList<>();yAxis.add(yAxis0);legend.add("");for(Map<String, Object> map :result){String oneValue = String.valueOf(map.get("name"));String value = String.valueOf(map.get("value"));xAxis.add(oneValue);yAxis0.add(value);}Map<String, Object> resultMap = new HashMap<>();resultMap.put("xAxis",xAxis);resultMap.put("yAxis",yAxis);resultMap.put("legend",legend);return R.ok().put("data", resultMap);}/*** 柱狀圖統計單列* @return*/@RequestMapping("/barCountOne")public R barCountOne(@RequestParam Map<String,Object> params) {logger.debug("柱狀圖統計單列:,,Controller:{},,params:{}",this.getClass().getName(),params);List<Map<String, Object>> result = commonService.barCountOne(params);List<String> xAxis = new ArrayList<>();//報表x軸List<List<String>> yAxis = new ArrayList<>();//y軸List<String> legend = new ArrayList<>();//標題List<String> yAxis0 = new ArrayList<>();yAxis.add(yAxis0);legend.add("");for(Map<String, Object> map :result){String oneValue = String.valueOf(map.get("name"));String value = String.valueOf(map.get("value"));xAxis.add(oneValue);yAxis0.add(value);}Map<String, Object> resultMap = new HashMap<>();resultMap.put("xAxis",xAxis);resultMap.put("yAxis",yAxis);resultMap.put("legend",legend);return R.ok().put("data", resultMap);}/*** 柱狀圖統計雙列* @return*/@RequestMapping("/barSumTwo")public R barSumTwo(@RequestParam Map<String,Object> params) {logger.debug("柱狀圖統計雙列:,,Controller:{},,params:{}",this.getClass().getName(),params);List<Map<String, Object>> result = commonService.barSumTwo(params);List<String> xAxis = new ArrayList<>();//報表x軸List<List<String>> yAxis = new ArrayList<>();//y軸List<String> legend = new ArrayList<>();//標題Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();for(Map<String, Object> map :result){String name1Value = String.valueOf(map.get("name1"));String name2Value = String.valueOf(map.get("name2"));String value = String.valueOf(map.get("value"));if(!legend.contains(name2Value)){legend.add(name2Value);//添加完成后 就是最全的第二列的類型}if(dataMap.containsKey(name1Value)){dataMap.get(name1Value).put(name2Value,value);}else{HashMap<String, String> name1Data = new HashMap<>();name1Data.put(name2Value,value);dataMap.put(name1Value,name1Data);}}for(int i =0; i<legend.size(); i++){yAxis.add(new ArrayList<String>());}Set<String> keys = dataMap.keySet();for(String key:keys){xAxis.add(key);HashMap<String, String> map = dataMap.get(key);for(int i =0; i<legend.size(); i++){List<String> data = yAxis.get(i);if(StringUtil.isNotEmpty(map.get(legend.get(i)))){data.add(map.get(legend.get(i)));}else{data.add("0");}}}System.out.println();Map<String, Object> resultMap = new HashMap<>();resultMap.put("xAxis",xAxis);resultMap.put("yAxis",yAxis);resultMap.put("legend",legend);return R.ok().put("data", resultMap);}/*** 柱狀圖統計雙列* @return*/@RequestMapping("/barCountTwo")public R barCountTwo(@RequestParam Map<String,Object> params) {logger.debug("柱狀圖統計雙列:,,Controller:{},,params:{}",this.getClass().getName(),params);List<Map<String, Object>> result = commonService.barCountTwo(params);List<String> xAxis = new ArrayList<>();//報表x軸List<List<String>> yAxis = new ArrayList<>();//y軸List<String> legend = new ArrayList<>();//標題Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();for(Map<String, Object> map :result){String name1Value = String.valueOf(map.get("name1"));String name2Value = String.valueOf(map.get("name2"));String value = String.valueOf(map.get("value"));if(!legend.contains(name2Value)){legend.add(name2Value);//添加完成后 就是最全的第二列的類型}if(dataMap.containsKey(name1Value)){dataMap.get(name1Value).put(name2Value,value);}else{HashMap<String, String> name1Data = new HashMap<>();name1Data.put(name2Value,value);dataMap.put(name1Value,name1Data);}}for(int i =0; i<legend.size(); i++){yAxis.add(new ArrayList<String>());}Set<String> keys = dataMap.keySet();for(String key:keys){xAxis.add(key);HashMap<String, String> map = dataMap.get(key);for(int i =0; i<legend.size(); i++){List<String> data = yAxis.get(i);if(StringUtil.isNotEmpty(map.get(legend.get(i)))){data.add(map.get(legend.get(i)));}else{data.add("0");}}}System.out.println();Map<String, Object> resultMap = new HashMap<>();resultMap.put("xAxis",xAxis);resultMap.put("yAxis",yAxis);resultMap.put("legend",legend);return R.ok().put("data", resultMap);}/**tableName 查詢表condition1 條件1condition1Value 條件1值average 計算平均評分取值有值 Number(res.data.value.toFixed(1))無值 if(res.data){}* */@IgnoreAuth@RequestMapping("/queryScore")public R queryScore(@RequestParam Map<String, Object> params) {logger.debug("queryScore:,,Controller:{},,params:{}",this.getClass().getName(),params);Map<String, Object> queryScore = commonService.queryScore(params);return R.ok().put("data", queryScore);}/*** 查詢字典表的分組統計總條數*  tableName  		表名*	groupColumn  	分組字段* @return*/@RequestMapping("/newSelectGroupCount")public R newSelectGroupCount(@RequestParam Map<String,Object> params) {logger.debug("newSelectGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params);List<Map<String, Object>> result = commonService.newSelectGroupCount(params);return R.ok().put("data", result);}/*** 查詢字典表的分組求和* tableName  		表名* groupColumn  		分組字段* sumCloum			統計字段* @return*/@RequestMapping("/newSelectGroupSum")public R newSelectGroupSum(@RequestParam Map<String,Object> params) {logger.debug("newSelectGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params);List<Map<String, Object>> result = commonService.newSelectGroupSum(params);return R.ok().put("data", result);}/*** 柱狀圖求和 老的*/@RequestMapping("/barSum")public R barSum(@RequestParam Map<String,Object> params) {logger.debug("barSum方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));Boolean isJoinTableFlag =  false;//是否有級聯表相關String one =  "";//第一優先String two =  "";//第二優先//處理thisTable和joinTable 處理內容是把json字符串轉為Map并把帶有,的切割為數組//當前表Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);params.put("thisTable",thisTable);//級聯表String joinTableString = String.valueOf(params.get("joinTable"));if(StringUtil.isNotEmpty(joinTableString)) {Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);params.put("joinTable", joinTable);isJoinTableFlag = true;}if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//當前表日期thisTable.put("date",String.valueOf(thisTable.get("date")).split(","));one = "thisDate0";}if(isJoinTableFlag){//級聯表日期Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){joinTable.put("date",String.valueOf(joinTable.get("date")).split(","));if(StringUtil.isEmpty(one)){one ="joinDate0";}else{if(StringUtil.isEmpty(two)){two ="joinDate0";}}}}if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//當前表字符串thisTable.put("string",String.valueOf(thisTable.get("string")).split(","));if(StringUtil.isEmpty(one)){one ="thisString0";}else{if(StringUtil.isEmpty(two)){two ="thisString0";}}}if(isJoinTableFlag){//級聯表字符串Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){joinTable.put("string",String.valueOf(joinTable.get("string")).split(","));if(StringUtil.isEmpty(one)){one ="joinString0";}else{if(StringUtil.isEmpty(two)){two ="joinString0";}}}}if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//當前表類型thisTable.put("types",String.valueOf(thisTable.get("types")).split(","));if(StringUtil.isEmpty(one)){one ="thisTypes0";}else{if(StringUtil.isEmpty(two)){two ="thisTypes0";}}}if(isJoinTableFlag){//級聯表類型Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){joinTable.put("types",String.valueOf(joinTable.get("types")).split(","));if(StringUtil.isEmpty(one)){one ="joinTypes0";}else{if(StringUtil.isEmpty(two)){two ="joinTypes0";}}}}List<Map<String, Object>> result = commonService.barSum(params);List<String> xAxis = new ArrayList<>();//報表x軸List<List<String>> yAxis = new ArrayList<>();//y軸List<String> legend = new ArrayList<>();//標題if(StringUtil.isEmpty(two)){//不包含第二列List<String> yAxis0 = new ArrayList<>();yAxis.add(yAxis0);legend.add("");for(Map<String, Object> map :result){String oneValue = String.valueOf(map.get(one));String value = String.valueOf(map.get("value"));xAxis.add(oneValue);yAxis0.add(value);}}else{//包含第二列Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();if(StringUtil.isNotEmpty(two)){for(Map<String, Object> map :result){String oneValue = String.valueOf(map.get(one));String twoValue = String.valueOf(map.get(two));String value = String.valueOf(map.get("value"));if(!legend.contains(twoValue)){legend.add(twoValue);//添加完成后 就是最全的第二列的類型}if(dataMap.containsKey(oneValue)){dataMap.get(oneValue).put(twoValue,value);}else{HashMap<String, String> oneData = new HashMap<>();oneData.put(twoValue,value);dataMap.put(oneValue,oneData);}}}for(int i =0; i<legend.size(); i++){yAxis.add(new ArrayList<String>());}Set<String> keys = dataMap.keySet();for(String key:keys){xAxis.add(key);HashMap<String, String> map = dataMap.get(key);for(int i =0; i<legend.size(); i++){List<String> data = yAxis.get(i);if(StringUtil.isNotEmpty(map.get(legend.get(i)))){data.add(map.get(legend.get(i)));}else{data.add("0");}}}System.out.println();}Map<String, Object> resultMap = new HashMap<>();resultMap.put("xAxis",xAxis);resultMap.put("yAxis",yAxis);resultMap.put("legend",legend);return R.ok().put("data", resultMap);}/*** 柱狀圖統計 老的*/@RequestMapping("/barCount")public R barCount(@RequestParam Map<String,Object> params) {logger.debug("barCount方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));Boolean isJoinTableFlag =  false;//是否有級聯表相關String one =  "";//第一優先String two =  "";//第二優先//處理thisTable和joinTable 處理內容是把json字符串轉為Map并把帶有,的切割為數組//當前表Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);params.put("thisTable",thisTable);//級聯表String joinTableString = String.valueOf(params.get("joinTable"));if(StringUtil.isNotEmpty(joinTableString)) {Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);params.put("joinTable", joinTable);isJoinTableFlag = true;}if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//當前表日期thisTable.put("date",String.valueOf(thisTable.get("date")).split(","));one = "thisDate0";}if(isJoinTableFlag){//級聯表日期Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){joinTable.put("date",String.valueOf(joinTable.get("date")).split(","));if(StringUtil.isEmpty(one)){one ="joinDate0";}else{if(StringUtil.isEmpty(two)){two ="joinDate0";}}}}if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//當前表字符串thisTable.put("string",String.valueOf(thisTable.get("string")).split(","));if(StringUtil.isEmpty(one)){one ="thisString0";}else{if(StringUtil.isEmpty(two)){two ="thisString0";}}}if(isJoinTableFlag){//級聯表字符串Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){joinTable.put("string",String.valueOf(joinTable.get("string")).split(","));if(StringUtil.isEmpty(one)){one ="joinString0";}else{if(StringUtil.isEmpty(two)){two ="joinString0";}}}}if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//當前表類型thisTable.put("types",String.valueOf(thisTable.get("types")).split(","));if(StringUtil.isEmpty(one)){one ="thisTypes0";}else{if(StringUtil.isEmpty(two)){two ="thisTypes0";}}}if(isJoinTableFlag){//級聯表類型Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){joinTable.put("types",String.valueOf(joinTable.get("types")).split(","));if(StringUtil.isEmpty(one)){one ="joinTypes0";}else{if(StringUtil.isEmpty(two)){two ="joinTypes0";}}}}List<Map<String, Object>> result = commonService.barCount(params);List<String> xAxis = new ArrayList<>();//報表x軸List<List<String>> yAxis = new ArrayList<>();//y軸List<String> legend = new ArrayList<>();//標題if(StringUtil.isEmpty(two)){//不包含第二列List<String> yAxis0 = new ArrayList<>();yAxis.add(yAxis0);legend.add("");for(Map<String, Object> map :result){String oneValue = String.valueOf(map.get(one));String value = String.valueOf(map.get("value"));xAxis.add(oneValue);yAxis0.add(value);}}else{//包含第二列Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();if(StringUtil.isNotEmpty(two)){for(Map<String, Object> map :result){String oneValue = String.valueOf(map.get(one));String twoValue = String.valueOf(map.get(two));String value = String.valueOf(map.get("value"));if(!legend.contains(twoValue)){legend.add(twoValue);//添加完成后 就是最全的第二列的類型}if(dataMap.containsKey(oneValue)){dataMap.get(oneValue).put(twoValue,value);}else{HashMap<String, String> oneData = new HashMap<>();oneData.put(twoValue,value);dataMap.put(oneValue,oneData);}}}for(int i =0; i<legend.size(); i++){yAxis.add(new ArrayList<String>());}Set<String> keys = dataMap.keySet();for(String key:keys){xAxis.add(key);HashMap<String, String> map = dataMap.get(key);for(int i =0; i<legend.size(); i++){List<String> data = yAxis.get(i);if(StringUtil.isNotEmpty(map.get(legend.get(i)))){data.add(map.get(legend.get(i)));}else{data.add("0");}}}System.out.println();}Map<String, Object> resultMap = new HashMap<>();resultMap.put("xAxis",xAxis);resultMap.put("yAxis",yAxis);resultMap.put("legend",legend);return R.ok().put("data", resultMap);}
}

package com.controller;import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;/*** 失物認領* 后端接口* @author* @email
*/
@RestController
@Controller
@RequestMapping("/shiwuzhaolingYuyue")
public class ShiwuzhaolingYuyueController {private static final Logger logger = LoggerFactory.getLogger(ShiwuzhaolingYuyueController.class);private static final String TABLE_NAME = "shiwuzhaolingYuyue";@Autowiredprivate ShiwuzhaolingYuyueService shiwuzhaolingYuyueService;@Autowiredprivate TokenService tokenService;@Autowiredprivate CaozuorizhiService caozuorizhiService;//操作日志@Autowiredprivate DictionaryService dictionaryService;//字典@Autowiredprivate LiuyanService liuyanService;//留言板@Autowiredprivate NewsService newsService;//公告信息@Autowiredprivate ShiwuzhaolingService shiwuzhaolingService;//失物信息@Autowiredprivate XunwuqishiService xunwuqishiService;//尋物啟事@Autowiredprivate XunwuqishiLiuyanService xunwuqishiLiuyanService;//尋物啟事留言@Autowiredprivate YonghuService yonghuService;//用戶@Autowiredprivate UsersService usersService;//管理員/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永不會進入");else if("用戶".equals(role))params.put("yonghuId",request.getSession().getAttribute("userId"));CommonUtil.checkMap(params);PageUtils page = shiwuzhaolingYuyueService.queryPage(params);//字典表數據轉換List<ShiwuzhaolingYuyueView> list =(List<ShiwuzhaolingYuyueView>)page.getList();for(ShiwuzhaolingYuyueView c:list){//修改對應字典表字段dictionaryService.dictionaryConvert(c, request);}caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"列表查詢",list.toString());return R.ok().put("data", page);}/*** 后端詳情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);ShiwuzhaolingYuyueEntity shiwuzhaolingYuyue = shiwuzhaolingYuyueService.selectById(id);if(shiwuzhaolingYuyue !=null){//entity轉viewShiwuzhaolingYuyueView view = new ShiwuzhaolingYuyueView();BeanUtils.copyProperties( shiwuzhaolingYuyue , view );//把實體數據重構到view中//級聯表 失物信息//級聯表ShiwuzhaolingEntity shiwuzhaoling = shiwuzhaolingService.selectById(shiwuzhaolingYuyue.getShiwuzhaolingId());if(shiwuzhaoling != null){BeanUtils.copyProperties( shiwuzhaoling , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把級聯的數據添加到view中,并排除id和創建時間字段,當前表的級聯注冊表view.setShiwuzhaolingId(shiwuzhaoling.getId());}//級聯表 用戶//級聯表YonghuEntity yonghu = yonghuService.selectById(shiwuzhaolingYuyue.getYonghuId());if(yonghu != null){BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把級聯的數據添加到view中,并排除id和創建時間字段,當前表的級聯注冊表view.setYonghuId(yonghu.getId());}//修改對應字典表字段dictionaryService.dictionaryConvert(view, request);caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"單條數據查看",view.toString());return R.ok().put("data", view);}else {return R.error(511,"查不到數據");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody ShiwuzhaolingYuyueEntity shiwuzhaolingYuyue, HttpServletRequest request){logger.debug("save方法:,,Controller:{},,shiwuzhaolingYuyue:{}",this.getClass().getName(),shiwuzhaolingYuyue.toString());String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永遠不會進入");else if("用戶".equals(role))shiwuzhaolingYuyue.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));Wrapper<ShiwuzhaolingYuyueEntity> queryWrapper = new EntityWrapper<ShiwuzhaolingYuyueEntity>().eq("shiwuzhaoling_id", shiwuzhaolingYuyue.getShiwuzhaolingId()).eq("yonghu_id", shiwuzhaolingYuyue.getYonghuId()).in("shiwuzhaoling_yuyue_yesno_types", new Integer[]{1,2});logger.info("sql語句:"+queryWrapper.getSqlSegment());ShiwuzhaolingYuyueEntity shiwuzhaolingYuyueEntity = shiwuzhaolingYuyueService.selectOne(queryWrapper);if(shiwuzhaolingYuyueEntity==null){shiwuzhaolingYuyue.setShiwuzhaolingYuyueYesnoTypes(1);shiwuzhaolingYuyue.setInsertTime(new Date());shiwuzhaolingYuyue.setCreateTime(new Date());shiwuzhaolingYuyueService.insert(shiwuzhaolingYuyue);caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"新增",shiwuzhaolingYuyue.toString());return R.ok();}else {if(shiwuzhaolingYuyueEntity.getShiwuzhaolingYuyueYesnoTypes()==1)return R.error(511,"有相同的待審核的數據");else if(shiwuzhaolingYuyueEntity.getShiwuzhaolingYuyueYesnoTypes()==2)return R.error(511,"有相同的審核通過的數據");elsereturn R.error(511,"表中有相同數據");}}/*** 后端修改*/@RequestMapping("/update")public R update(@RequestBody ShiwuzhaolingYuyueEntity shiwuzhaolingYuyue, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {logger.debug("update方法:,,Controller:{},,shiwuzhaolingYuyue:{}",this.getClass().getName(),shiwuzhaolingYuyue.toString());ShiwuzhaolingYuyueEntity oldShiwuzhaolingYuyueEntity = shiwuzhaolingYuyueService.selectById(shiwuzhaolingYuyue.getId());//查詢原先數據String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永遠不會進入");
//        else if("用戶".equals(role))
//            shiwuzhaolingYuyue.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));shiwuzhaolingYuyueService.updateById(shiwuzhaolingYuyue);//根據id更新List<String> strings = caozuorizhiService.clazzDiff(shiwuzhaolingYuyue, oldShiwuzhaolingYuyueEntity, request,new String[]{"updateTime"});caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"修改",strings.toString());return R.ok();}/*** 審核*/@RequestMapping("/shenhe")public R shenhe(@RequestBody ShiwuzhaolingYuyueEntity shiwuzhaolingYuyueEntity, HttpServletRequest request){logger.debug("shenhe方法:,,Controller:{},,shiwuzhaolingYuyueEntity:{}",this.getClass().getName(),shiwuzhaolingYuyueEntity.toString());ShiwuzhaolingYuyueEntity oldShiwuzhaolingYuyue = shiwuzhaolingYuyueService.selectById(shiwuzhaolingYuyueEntity.getId());//查詢原先數據if(shiwuzhaolingYuyueEntity.getShiwuzhaolingYuyueYesnoTypes() == 2){//通過ShiwuzhaolingEntity shiwuzhaolingEntity = shiwuzhaolingService.selectById(oldShiwuzhaolingYuyue.getShiwuzhaolingId());shiwuzhaolingEntity.setRenlingzhuangtaiTypes(2);shiwuzhaolingService.updateById(shiwuzhaolingEntity);}else if(shiwuzhaolingYuyueEntity.getShiwuzhaolingYuyueYesnoTypes() == 3){//拒絕}shiwuzhaolingYuyueService.updateById(shiwuzhaolingYuyueEntity);//審核caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"審核數據","審核"+oldShiwuzhaolingYuyue+"數據,審核結果是"+(shiwuzhaolingYuyueEntity.getShiwuzhaolingYuyueYesnoTypes()==2?"通過":"拒絕"));return R.ok();}/*** 刪除*/@RequestMapping("/delete")public R delete(@RequestBody Integer[] ids, HttpServletRequest request){logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());List<ShiwuzhaolingYuyueEntity> oldShiwuzhaolingYuyueList =shiwuzhaolingYuyueService.selectBatchIds(Arrays.asList(ids));//要刪除的數據shiwuzhaolingYuyueService.deleteBatchIds(Arrays.asList(ids));caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"刪除",oldShiwuzhaolingYuyueList.toString());return R.ok();}/*** 批量上傳*/@RequestMapping("/batchInsert")public R save( String fileName, HttpServletRequest request){logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))try {List<ShiwuzhaolingYuyueEntity> shiwuzhaolingYuyueList = new ArrayList<>();//上傳的東西Map<String, List<String>> seachFields= new HashMap<>();//要查詢的字段Date date = new Date();int lastIndexOf = fileName.lastIndexOf(".");if(lastIndexOf == -1){return R.error(511,"該文件沒有后綴");}else{String suffix = fileName.substring(lastIndexOf);if(!".xls".equals(suffix)){return R.error(511,"只支持后綴為xls的excel文件");}else{URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//獲取文件路徑File file = new File(resource.getFile());if(!file.exists()){return R.error(511,"找不到上傳文件,請聯系管理員");}else{List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//讀取xls文件dataList.remove(0);//刪除第一行,因為第一行是提示for(List<String> data:dataList){//循環ShiwuzhaolingYuyueEntity shiwuzhaolingYuyueEntity = new ShiwuzhaolingYuyueEntity();
//                            shiwuzhaolingYuyueEntity.setShiwuzhaolingId(Integer.valueOf(data.get(0)));   //失物id 要改的
//                            shiwuzhaolingYuyueEntity.setYonghuId(Integer.valueOf(data.get(0)));   //認領用戶 要改的
//                            shiwuzhaolingYuyueEntity.setShiwuzhaolingYuyueText(data.get(0));                    //認領憑證 要改的
//                            shiwuzhaolingYuyueEntity.setShiwuzhaolingYuyueYesnoTypes(Integer.valueOf(data.get(0)));   //審核 要改的
//                            shiwuzhaolingYuyueEntity.setShiwuzhaolingYuyueYesnoText(data.get(0));                    //詳情 要改的
//                            shiwuzhaolingYuyueEntity.setInsertTime(date);//時間
//                            shiwuzhaolingYuyueEntity.setCreateTime(date);//時間shiwuzhaolingYuyueList.add(shiwuzhaolingYuyueEntity);//把要查詢是否重復的字段放入map中}//查詢是否重復shiwuzhaolingYuyueService.insertBatch(shiwuzhaolingYuyueList);caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"批量新增",shiwuzhaolingYuyueList.toString());return R.ok();}}}}catch (Exception e){e.printStackTrace();return R.error(511,"批量插入數據異常,請聯系管理員");}}/*** 前端列表*/@IgnoreAuth@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));CommonUtil.checkMap(params);PageUtils page = shiwuzhaolingYuyueService.queryPage(params);//字典表數據轉換List<ShiwuzhaolingYuyueView> list =(List<ShiwuzhaolingYuyueView>)page.getList();for(ShiwuzhaolingYuyueView c:list)dictionaryService.dictionaryConvert(c, request); //修改對應字典表字段caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"列表查詢",list.toString());return R.ok().put("data", page);}/*** 前端詳情*/@RequestMapping("/detail/{id}")public R detail(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);ShiwuzhaolingYuyueEntity shiwuzhaolingYuyue = shiwuzhaolingYuyueService.selectById(id);if(shiwuzhaolingYuyue !=null){//entity轉viewShiwuzhaolingYuyueView view = new ShiwuzhaolingYuyueView();BeanUtils.copyProperties( shiwuzhaolingYuyue , view );//把實體數據重構到view中//級聯表ShiwuzhaolingEntity shiwuzhaoling = shiwuzhaolingService.selectById(shiwuzhaolingYuyue.getShiwuzhaolingId());if(shiwuzhaoling != null){BeanUtils.copyProperties( shiwuzhaoling , view ,new String[]{ "id", "createDate"});//把級聯的數據添加到view中,并排除id和創建時間字段view.setShiwuzhaolingId(shiwuzhaoling.getId());}//級聯表YonghuEntity yonghu = yonghuService.selectById(shiwuzhaolingYuyue.getYonghuId());if(yonghu != null){BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把級聯的數據添加到view中,并排除id和創建時間字段view.setYonghuId(yonghu.getId());}//修改對應字典表字段dictionaryService.dictionaryConvert(view, request);caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"單條數據查看",view.toString());return R.ok().put("data", view);}else {return R.error(511,"查不到數據");}}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody ShiwuzhaolingYuyueEntity shiwuzhaolingYuyue, HttpServletRequest request){logger.debug("add方法:,,Controller:{},,shiwuzhaolingYuyue:{}",this.getClass().getName(),shiwuzhaolingYuyue.toString());Wrapper<ShiwuzhaolingYuyueEntity> queryWrapper = new EntityWrapper<ShiwuzhaolingYuyueEntity>().eq("shiwuzhaoling_id", shiwuzhaolingYuyue.getShiwuzhaolingId()).eq("yonghu_id", shiwuzhaolingYuyue.getYonghuId()).eq("shiwuzhaoling_yuyue_text", shiwuzhaolingYuyue.getShiwuzhaolingYuyueText()).in("shiwuzhaoling_yuyue_yesno_types", new Integer[]{1,2}).eq("shiwuzhaoling_yuyue_yesno_text", shiwuzhaolingYuyue.getShiwuzhaolingYuyueYesnoText())
//            .notIn("shiwuzhaoling_yuyue_types", new Integer[]{102});logger.info("sql語句:"+queryWrapper.getSqlSegment());ShiwuzhaolingYuyueEntity shiwuzhaolingYuyueEntity = shiwuzhaolingYuyueService.selectOne(queryWrapper);if(shiwuzhaolingYuyueEntity==null){shiwuzhaolingYuyue.setShiwuzhaolingYuyueYesnoTypes(1);shiwuzhaolingYuyue.setInsertTime(new Date());shiwuzhaolingYuyue.setCreateTime(new Date());shiwuzhaolingYuyueService.insert(shiwuzhaolingYuyue);caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"前臺新增",shiwuzhaolingYuyue.toString());return R.ok();}else {if(shiwuzhaolingYuyueEntity.getShiwuzhaolingYuyueYesnoTypes()==1)return R.error(511,"有相同的待審核的數據");else if(shiwuzhaolingYuyueEntity.getShiwuzhaolingYuyueYesnoTypes()==2)return R.error(511,"有相同的審核通過的數據");elsereturn R.error(511,"表中有相同數據");}}}

六、底部獲取項目源碼帶萬字文檔(9.9¥帶走)

有問題,或者需要協助調試運行項目的也可以

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/39853.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/39853.shtml
英文地址,請注明出處:http://en.pswp.cn/web/39853.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

JAVA導出數據庫字典到Excel

文章目錄 1、查詢某張表字段信息2、TableVo接收sql查詢得到的數據3、excel導出4、導出案例 1、查詢某張表字段信息 select column_name as columnName, -- 字段名 COLUMN_DEFAULT as colDefault, -- 默認值 column_key as columnKey, -- PRI-主鍵&#xff0c;UNI-唯一鍵&…

【Tools】 Postman 接口測試工具詳解

那年夏天我和你躲在 這一大片寧靜的海 直到后來我們都還在 對這個世界充滿期待 今年冬天你已經不在 我的心空出了一塊 很高興遇見你 讓我終究明白 回憶比真實精彩 &#x1f3b5; 王心凌《那年夏天寧靜的海》 在現代軟件開發中&#xff0c;API&#xff08;…

【Python實戰因果推斷】21_傾向分1

目錄 The Impact of Management Training Adjusting with Regression 之前學習了如何使用線性回歸調整混雜因素。此外&#xff0c;還向您介紹了通過正交化去偏差的概念&#xff0c;這是目前最有用的偏差調整技術之一。不過&#xff0c;您還需要學習另一種技術--傾向加權。這種…

Ionic 卡片:設計和使用指南

Ionic 卡片&#xff1a;設計和使用指南 Ionic 是一個強大的開源框架&#xff0c;用于構建跨平臺的移動應用程序。它結合了 Angular、React 和 Vue 的強大功能&#xff0c;允許開發者使用 Web 技術創建高性能的移動應用。Ionic 卡片是框架中的一個核心組件&#xff0c;用于展示…

js使用插件完成xml轉json

插件&#xff1a;xml2json.min.js 插件文件下載&#xff08;不能上傳附件&#xff09;&#xff1a;https://download.csdn.net/download/zhu_zhu_xia/89513965 html代碼&#xff1a; <!DOCTYPE html> <html lang"en"><head><meta charset&qu…

我認為一般信息管理應用中使用存儲過程高效

總看有些人反對使用存儲過程&#xff0c;原因無非是以下幾點 1.不利于更換數據庫&#xff0c;就是沒有移植性 2.不利用調試和擴展 就依據我們大大小小項目&#xff0c;風風雨雨走過近20年&#xff0c;每個系統的業務邏輯處理幾乎都是用存儲過程實現的&#xff0c;沒發現多不…

p標簽文本段落中因編輯器換行引起的空格問題完美解決方案

目錄 1.修改前的代碼&#xff1a;2.修改后的代碼3.總結 在HTML文檔中&#xff0c;如何要在&#xff08;p標簽&#xff09;內寫一段很長的文本段落&#xff0c;并且沒有 換行。由于IDE或者編輯器界面大小有限或需要在vue中邏輯處理動態顯示文本&#xff0c;一行寫完太長&#x…

Eslint prettier airbnb規范 配置

1.安裝vscode的Eslint和prettier 插件 eslint&#xff1a;代碼質量檢查工具 https://eslint.nodejs.cn/docs/latest/use/getting-started prettier&#xff1a;代碼風格格式化工具 https://www.prettier.cn/docs/index.html /* eslint-config-airbnb-base airbnb 規范 esl…

高德地圖軌跡回放并提示具體信息

先上效果圖 到達某地點后顯示提示語&#xff1a;比如&#xff1a;12&#xff1a;56分駛入康莊大道、左轉駛入xx大道等 <!doctype html> <html> <head><meta charset"utf-8"><meta http-equiv"X-UA-Compatible" content"…

【前端CSS3】CSS顯示模式(黑馬程序員)

文章目錄 一、前言&#x1f680;&#x1f680;&#x1f680;二、CSS元素顯示模式&#xff1a;??????2.1 什么是元素顯示模式2.2 塊元素2.3 行內元素2.4 行塊元素2.5 元素顯示模式的轉換 三、總結&#x1f680;&#x1f680;&#x1f680; 一、前言&#x1f680;&#x1f…

巴圖自動化Modbus協議轉Profinet協議網關模塊連智能儀表與PLC通訊

一、現場要求:PLC作為控制器&#xff0c;儀表設備作為執行設備。執行設備可以實時響應PLC傳送的指令&#xff0c;并將數據反饋給PLC&#xff0c;從而實現PLC對儀表設備的控制和監控&#xff0c;實現對生產過程的精確控制。 二、解決方案:通過巴圖自動化Modbus協議轉Profinet協議…

前端面試題4(瀏覽器對http請求處理過程)

瀏覽器對http請求處理過程 當我們在瀏覽器中輸入URL并按下回車鍵時&#xff0c;瀏覽器會執行一系列步驟來處理HTTP請求并與服務器通信。下面是瀏覽器處理過程 1. 解析URL 瀏覽器首先解析輸入的URL&#xff0c;提取出協議&#xff08;通常是http://或https://&#xff09;、主…

Robust Test-Time Adaptation in Dynamic Scenarios--論文閱讀

論文筆記 資料 1.代碼地址 https://github.com/BIT-DA/RoTTA 2.論文地址 https://arxiv.org/abs/2303.13899 3.數據集地址 coming soon 1論文摘要的翻譯 測試時間自適應(TTA)旨在使預先7訓練的模型適用于僅具有未標記測試數據流的測試分布。大多數以前的TTA方法已經在…

為什么要卸載手機上面的抖音?

刪除抖音等社交媒體應用可能出于多種原因&#xff0c;這里列舉一些常見的考慮因素&#xff1a; 1. **時間管理**&#xff1a; 抖音和其他社交媒體平臺可能會占用大量時間&#xff0c;影響個人的日常生活和工作學習效率。 這個對于自己而言是一個客觀存在的事情&#xff1a; 2.…

安卓請求服務器[根據服務器的內容來更新spinner]

根據服務器的內容來更新spinner 本文內容請結合如下兩篇文章一起看: 騰訊云函數node.js返回自動帶反斜杠 騰訊云函數部署環境[使用函數URL] 現在有這樣一個需求,APP有一個下拉選擇框作為版本選擇,因為改個管腳就變成一個版本,客戶需求也很零散,所以后期會大量增加版本,這時候每…

數據預處理:統計關聯性分析/數據清洗/數據增強/特征工程實例

專欄介紹 1.專欄面向零基礎或基礎較差的機器學習入門的讀者朋友,旨在利用實際代碼案例和通俗化文字說明,使讀者朋友快速上手機器學習及其相關知識體系。 2.專欄內容上包括數據采集、數據讀寫、數據預處理、分類\回歸\聚類算法、可視化等技術。 3.需要強調的是,專欄僅介紹主…

gitLab使用流程

標題1.配置賬戶 git config --global user.name git config --global user.email mygitlabmali.cn 標題2.生成秘匙 ssh-keygen -t rsa -C “mygitlabmail.cn” 。 //輸入命令后一直回車 &#xff0c;輸入命令后一直回車&#xff08;密碼可以不填&#xff09;&#xff0c;至…

Java面試題系列 - 第2天

題目&#xff1a;Java中的線程池模型及其配置策略 背景說明&#xff1a;在Java多線程編程中&#xff0c;線程池是一種高效的線程復用機制&#xff0c;能夠有效管理和控制線程的創建與銷毀&#xff0c;避免頻繁創建和銷毀線程帶來的性能開銷。理解和掌握線程池的配置策略對于優…

Anaconda+Pycharm兩個軟件從頭到尾下載流程

前言&#xff1a; 1、使用教程前&#xff0c;請將電腦上的所有的Python卸載掉。再下載Anaconda&#xff0c;Anaconda這個軟件里面就含有python。 徹底刪除python方法&#xff1a; 1、計算機——屬性——高級系統設置——環境變量 2、查看電腦用戶自己設計的環境變量&#x…

【智能制造-8】輸送線運動控制算法

輸送線運動控制算法包含哪些內容&#xff1f; 輸送線運動控制算法包含以下幾個主要內容: 速度控制算法: 根據目標速度和當前實際速度,調整電機的輸出功率,達到所需的輸送線速度。 常見的算法包括PID控制、自適應控制等。位置/距離控制算法: 監控輸送線上物料的位置或移動距離…