package com.controller;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import com.entity.GoodsEntity;
import com.entity.InOutOrderListEntity;
import com.service.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.utils.StringUtil;
import java.lang.reflect.InvocationTargetException;
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.InOutOrderEntity;
import com.entity.view.InOutOrderView;
import com.utils.PageUtils;
import com.utils.R;
/**
* 出入库订单
* 后端接口
* @author
* @email
* @date
*/
@RestController
@Controller
@RequestMapping("/inOutOrder")
public class InOutOrderController {
private static final Logger logger = LoggerFactory.getLogger(InOutOrderController.class);
@Autowired
private InOutOrderService inOutOrderService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
// 商品表
@Autowired
private GoodsService goodsService;
//订单详情表
@Autowired
private InOutOrderListService inOutOrderListService;
/**
* 后端列表
*/
@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(StringUtil.isNotEmpty(role) && "用户".equals(role)){
params.put("yonghuId",request.getSession().getAttribute("userId"));
}
PageUtils page = inOutOrderService.queryPage(params);
//用品分类数据转换
List<InOutOrderView> list =(List<InOutOrderView>)page.getList();
for(InOutOrderView c:list){
//修改对应用品分类字段
dictionaryService.dictionaryConvert(c);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
InOutOrderEntity inOutOrder = inOutOrderService.selectById(id);
if(inOutOrder !=null){
//entity转view
InOutOrderView view = new InOutOrderView();
BeanUtils.copyProperties( inOutOrder , view );//把实体数据重构到view中
//修改对应用品分类字段
dictionaryService.dictionaryConvert(view);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody InOutOrderEntity inOutOrder, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,inOutOrder:{}",this.getClass().getName(),inOutOrder.toString());
Wrapper<InOutOrderEntity> queryWrapper = new EntityWrapper<InOutOrderEntity>()
.eq("order_name", inOutOrder.getOrderName())
.eq("caozuo_name", inOutOrder.getCaozuoName())
.eq("caozuo_table", inOutOrder.getCaozuoTable())
.eq("order_types", inOutOrder.getOrderTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
InOutOrderEntity inOutOrderEntity = inOutOrderService.selectOne(queryWrapper);
if(inOutOrderEntity==null){
inOutOrder.setInsertTime(new Date());
inOutOrder.setCreateTime(new Date());
// String role = String.valueOf(request.getSession().getAttribute("role"));
// if("".equals(role)){
// inOutOrder.set
// }
inOutOrderService.insert(inOutOrder);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody InOutOrderEntity inOutOrder, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,inOutOrder:{}",this.getClass().getName(),inOutOrder.toString());
//根据字段查询是否有相同数据
Wrapper<InOutOrderEntity> queryWrapper = new EntityWrapper<InOutOrderEntity>()
.notIn("id",inOutOrder.getId())
.eq("order_name", inOutOrder.getOrderName())
.eq("caozuo_name", inOutOrder.getCaozuoName())
.eq("caozuo_table", inOutOrder.getCaozuoTable())
.eq("order_types", inOutOrder.getOrderTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
InOutOrderEntity inOutOrderEntity = inOutOrderService.selectOne(queryWrapper);
if(inOutOrderEntity==null){
// String role = String.valueOf(request.getSession().getAttribute("role"));
// if("".equals(role)){
// inOutOrder.set
// }
inOutOrderService.updateById(inOutOrder);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 出库
*/
@RequestMapping("/outOrder")
public R outGoods(@RequestBody Map<String, Object> params,HttpServletRequest request){
logger.debug("outGoods方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
Map<String, Integer> map = (Map<String, Integer>) params.get("map");
String orderName = String.valueOf(params.get("orderName"));
InOutOrderEntity one = inOutOrderService.selectOne(new EntityWrapper<InOutOrderEntity>().eq("order_name", orderName));
if(one != null){
return R.error(orderName+"的订单名已经被使用");
}
Set<String> ids = map.keySet();
List<GoodsEntity> list = goodsService.selectList(new EntityWrapper<GoodsEntity>().in("id", ids));
Date date = new Date();
for(GoodsEntity g:list){
Integer shiyongnumber = map.get(String.valueOf(g.getId()));
if(g.getGoodsNumber()==null || shiyongnumber == null){
return R.error(g.getGoodsName()+"的库存数量为空或者出库数量为空");
}else if(g.getGoodsNumber()-shiyongnumber<0){
return R.error(g.getGoodsName()+"的出库数量:"+shiyongnumber+"不能大于库存数量"+g.getGoodsNumber());
}else{
//正常出库
g.setGoodsNumber(g.getGoodsNumber()-shiyongnumber);
}
}
//修改库存
goodsService.updateBatchById(list);
//新增订单
InOutOrderEntity inOutOrderEntity = new InOutOrderEntity();
inOutOrderEntity.setCreateTime(date);
inOutOrderEntity.setInsertTime(date);
inOutOrderEntity.setCaozuoName(String.valueOf(request.getSession().getAttribute("username")));
inOutOrderEntity.setCaozuoTable(String.valueOf(request.getSession().getAttribute("tableName")));
inOutOrderEntity.setOrderTypes(1);//设置订单为出库
inOutOrderEntity.setOrderName(orderName);
inOutOrderService.insert(inOutOrderEntity);
if(inOutOrderEntity.getId()!=null){
//新增订单详情
List<InOutOrderListEntity> inOutOrderListEntityList = new ArrayList<>();
for(String i:ids){
InOutOrderListEntity inOutOr
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于SSM+JSP的办公用品管理系统毕业设计(源码+演示视频+说明).rar 【项目技术】 开发语言:Java 框架:ssm+jsp 架构:B/S 数据库:mysql 【演示视频-编号:129】 https://pan.quark.cn/s/b3a97032fae7
资源推荐
资源详情
资源评论
收起资源包目录
基于SSM+JSP的办公用品管理系统毕业设计(源码+演示视频+说明).rar (874个子文件)
style.css 835KB
bootstrap4.2.1.min.css 150KB
bootstrap.min.css 141KB
bootstrap.css 120KB
bootstrap.min.css 118KB
material-design-iconic-font.min.css 93KB
animate.css 68KB
style.css 66KB
style.default.css 66KB
linea-icon.css 46KB
ueditor.css 44KB
font-awesome.min.css 38KB
ueditor.min.css 34KB
font-awesome.min.css 30KB
jquery.treetable.theme.default.css 25KB
lightgallery.css 25KB
animate.css 23KB
styles.css 23KB
entypo-icon.css 23KB
all.css 21KB
font-awesome.css 21KB
video-js.css 21KB
image.css 19KB
jquery.idealforms.css 17KB
themify-icons.css 16KB
themify-icons.css 16KB
jquery.dataTables.min.css 15KB
video.css 15KB
attachment.css 15KB
square.min.css 14KB
simple-line-icons.css 14KB
all.css 13KB
bootstrap-select.css 13KB
dropzone.css 11KB
video-js.min.css 11KB
bootstrap-switch.css 11KB
bootstrap-datetimepicker.min.css 11KB
extra-pages.css 11KB
ladda.min.css 10KB
filter.css 9KB
tooltipster.css 9KB
pe-icon-7-stroke.css 9KB
awesome-bootstrap-checkbox.css 9KB
calendar.css 9KB
responsive.css 8KB
laydate.css 8KB
shCoreDefault.css 7KB
pe-icon-7-styles.css 7KB
css.css 7KB
social.css 7KB
jquery-jvectormap.css 6KB
clockface.css 6KB
jquery.steps.css 6KB
dripicon.css 5KB
weather-icons.min.css 5KB
footable.core.css 5KB
jquery.toast.min.css 5KB
dataTables.bootstrap4.min.css 5KB
datepicker.css 5KB
tabelizer.min.css 5KB
datepicker.css 5KB
datepicker.css 5KB
footable.standalone.css 5KB
signin.css 5KB
media.css 5KB
slidebars.css 4KB
skin-select.css 4KB
datepicker.css 4KB
scrawl.css 4KB
DT_bootstrap.css 4KB
datepicker.css 4KB
bootstrap-timepicker.css 3KB
green.css 3KB
yellow.css 3KB
red.css 3KB
blue.css 3KB
violet.css 3KB
codemirror.css 3KB
owl.carousel.min.css 3KB
bootstrap-colorpicker.css 3KB
maki-icons.css 3KB
jquery.treeview.css 3KB
profile.css 3KB
charts.css 3KB
jquery.searchableSelect.css 3KB
background.css 2KB
bootstrap-wysihtml5.css 2KB
awwwards.css 2KB
jquery.stepy.css 2KB
responsive-table.css 2KB
emotion.css 2KB
dialogbase.css 2KB
jquery.pnotify.default.css 2KB
music.css 2KB
demo.css 1KB
acc-wizard.min.css 1KB
jquery.easy-pie-chart.css 1KB
pace-theme-center-simple.css 1KB
uploader.css 1KB
edittable.css 1KB
共 874 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
职场程序猿
- 粉丝: 2870
- 资源: 3683
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 优先编码器除法电微分运算电路 全加器函数发生电路等电路经典Multisim仿真实验源文件合集(25个).zip
- 2331308JS课堂案例.zip
- STM32H750VBT6单片机最小系统开发板AD设计硬件(原理图+PCB+3D封装库)工程文件.zip
- 基于74LS161+ 74LS192芯片实现倒计时定时器Multisim仿真源文件,Multisim10以上版本可打开运行
- 科大讯飞语音引擎 jar包 demo,科大讯飞语音合成引擎3.0,支持4.0系统以上,文字转语音输出.zip
- Java架构面试笔试专题资料及经验(含答案)SpringBoot面试Linux面试专题及答案 合集.zip
- 头歌c语言实验答案tion-model-for-ne开发笔记
- docker配置使用-model-for-networK开发demo
- docker配置使用vaWeb-mas笔记
- c语言连接两个字符串-mas开发笔记
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功