package com.usc.mms.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.usc.mms.mapper.RequisitionMapper;
import com.usc.mms.pojo.*;
import com.usc.mms.service.*;
import com.usc.mms.utils.DataGridViewResult;
import com.usc.mms.vo.MaterialVo;
import com.usc.mms.vo.PutinVo;
import com.usc.mms.vo.RequisitionVo;
import com.usc.mms.vo.StoreVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.nio.channels.DatagramChannel;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@RequestMapping("/mh")
public class MHController {
@Resource
private KindService kindService;
@Resource
private MaterialService materialService;
@Resource
private PutinService putinService;
@Resource
private StoreService storeService;
@Resource
private RequisitionService requisitionService;
@Resource
private IndexService indexService;
@RequestMapping(value = "/info.html")
public String materialInfo() {
return "/mh/material-info.html";
}
/**
* 获取全部种类
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/getOptions.action")
public String getSelectOptions() {
Map<String, Object> map = new HashMap<>();
List<Kind> list = kindService.findAllKind();
if (list != null) {
map.put("success", true);
map.put("data", list);
} else {
map.put("success", false);
Kind kind = new Kind("005", "其它");
map.put("data", kind);
}
System.out.println(map);
return JSON.toJSONString(map);
}
/**
* 上传物资图片
*
* @param file
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/uploadImage")
public String uploadImage(MultipartFile file, HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
HashMap<String, Object> data = new HashMap<>();
try {
if (file != null) {
String originalFilename = file.getOriginalFilename();
Date date = new Date();
String fileName = date.getTime() + "-" + originalFilename;
// 类路径
String classPath = "F:/IDEA/workspace/MMS/mms/target/classes/static";
// 父路径
String src = "/upload/";
File directory = new File(classPath, src);
if (!directory.exists()) {
directory.mkdir();
}
// 文件名
String imagePath = directory.getPath() + "\\" + fileName;
file.transferTo(new File(imagePath));
data.put("src", src + fileName);
map.put("code", 0);
map.put("msg", "上传成功!");
map.put("data", data);
return JSON.toJSONString(map);
} else {
map.put("code", -1);
map.put("msg", "请选择图片!");
return JSON.toJSONString(map);
}
} catch (Exception e) {
e.printStackTrace();
map.put("code", -1);
map.put("msg", "上传失败,请稍后重试!");
return JSON.toJSONString(map);
}
}
/**
* 添加物资信息
*
* @param mi
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/add")
public String addMaterialInfo(Material mi) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(mi);
boolean result = materialService.addMaterialInfo(mi);
if (result) {
map.put("success", true);
map.put("msg", "添加成功!");
} else {
map.put("success", false);
map.put("msg", "添加失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 查看物资信息列表
*
* @param mv
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/list")
public DataGridViewResult materialInfoList(MaterialVo mv) {
// 设置分页信息
PageHelper.startPage(mv.getPage(), mv.getLimit());
// 查询
List<Material> list = materialService.findMaterialInfoListByPage(mv);
// 创建分页对象
PageInfo<Material> pageInfo = new PageInfo<Material>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 修改物资信息
*
* @param mi
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/update")
public String updateMaterialInfo(Material mi) {
HashMap<String, Object> map = new HashMap<>();
boolean result = materialService.updateMaterialInfo(mi);
if (result) {
map.put("success", true);
map.put("msg", "更改成功!");
} else {
map.put("success", false);
map.put("msg", "更改失败!");
}
return JSON.toJSONString(map);
}
/**
* 删除物资信息
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/delete")
public String deleteMaterialInfo(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String params = request.getParameter("params");
try {
if (!params.equals("") && params != "") {
// 获取mid数组
JSONArray jsonArray = JSONArray.parseArray(params);
List<String> list = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject obj = jsonArray.getJSONObject(i);
String mid = (String) obj.get("mid");
System.out.println(mid);
list.add(mid);
}
boolean result = materialService.deleteMaterialInfo(list);
if (result) {
map.put("success", true);
map.put("msg", "删除成功!");
} else {
map.put("success", false);
map.put("msg", "删除失败!");
}
}
} catch (Exception e) {
e.printStackTrace();
map.put("success", false);
map.put("msg", "删除失败!");
}
return JSON.toJSONString(map);
}
/**
* 添加物资类别
*
* @param kd
* @return
*/
@ResponseBody
@RequestMapping(value = "/kind/add")
public String addKind(Kind kd) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(kd);
boolean result = kindService.addKind(kd);
if (result) {
map.put("success", true);
map.put("msg", "添加成功!");
} else {
map.put("success", false);
map.put("msg", "添加失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
@RequestMapping(value = "/putin.html")
public String putinRecords(){
return "/mh
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
SpringBoot+Mybatis+ssm + Layui+mysql物资发放管理系统源码,系统经多次测试,运行无误,大家放心下载
资源推荐
资源详情
资源评论
收起资源包目录
SpringBoot+Mybatis+ssm + Layui+mysql物资发放管理系统源码 (407个子文件)
MHController.class 15KB
StaffController.class 5KB
IndexController.class 4KB
Putin.class 4KB
Requisition.class 3KB
RequisitionServiceImpl.class 3KB
MenuServiceImpl.class 3KB
MenuNode.class 3KB
MaterialServiceImpl.class 2KB
Menu.class 2KB
Material.class 2KB
Store.class 2KB
PutinServiceImpl.class 2KB
DataGridViewResult.class 2KB
TreeUtil.class 2KB
User.class 2KB
Kind.class 2KB
PutinVo.class 2KB
KindServiceImpl.class 2KB
IndexServiceImpl.class 2KB
MaterialVo.class 1KB
StoreServiceImpl.class 1KB
MmsApplication.class 806B
RequisitionVo.class 785B
StoreVo.class 761B
MaterialService.class 684B
MaterialMapper.class 672B
RequisitionService.class 653B
RequisitionMapper.class 650B
MmsApplicationTests.class 518B
StoreMapper.class 466B
IndexService.class 417B
IndexMapper.class 398B
KindService.class 397B
KindMapper.class 394B
PutinService.class 385B
PutinMapper.class 382B
StoreService.class 320B
MenuMapper.class 306B
MenuService.class 226B
mvnw.cmd 6KB
layui.css 78KB
layui.css 78KB
font-awesome.css 37KB
font-awesome.css 37KB
font-awesome.min.css 30KB
font-awesome.min.css 30KB
layuimini.css 20KB
layuimini.css 20KB
wangEditor.css 17KB
wangEditor.css 17KB
wangEditor.min.css 15KB
wangEditor.min.css 15KB
layer.css 14KB
layer.css 14KB
zyupload-1.0.0.min.css 9KB
zyupload-1.0.0.min.css 9KB
laydate.css 7KB
laydate.css 7KB
default.css 4KB
default.css 4KB
public.css 1KB
public.css 1KB
code.css 1KB
code.css 1KB
step.css 1KB
step.css 1KB
treetable.css 294B
treetable.css 294B
fontawesome-webfont.eot 162KB
fontawesome-webfont.eot 162KB
iconfont.eot 46KB
iconfont.eot 46KB
loading-0.gif 6KB
loading-0.gif 6KB
loading-2.gif 2KB
loading-2.gif 2KB
loading-1.gif 701B
loading-1.gif 701B
.gitignore 395B
material-info.html 17KB
material-info.html 17KB
distribute.html 9KB
distribute.html 9KB
putin.html 9KB
putin.html 9KB
apply.html 9KB
apply.html 9KB
login.html 9KB
login.html 9KB
home.html 6KB
home.html 6KB
approve.html 4KB
approve.html 4KB
store.html 3KB
store.html 3KB
todo.html 2KB
todo.html 2KB
welcome.html 2KB
welcome.html 2KB
共 407 条
- 1
- 2
- 3
- 4
- 5
资源评论
reg183
- 粉丝: 1811
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功