|
@@ -0,0 +1,191 @@
|
|
|
+package com.iamberry.rst.controllers.pts;
|
|
|
+
|
|
|
+import com.iamberry.rst.core.cm.*;
|
|
|
+import com.iamberry.rst.core.page.PageRequest;
|
|
|
+import com.iamberry.rst.core.page.PagedResult;
|
|
|
+import com.iamberry.rst.core.pts.PtsDevice;
|
|
|
+import com.iamberry.rst.core.pts.PtsMachine;
|
|
|
+import com.iamberry.rst.faces.cm.InventoryLogService;
|
|
|
+import com.iamberry.rst.faces.cm.InventoryService;
|
|
|
+import com.iamberry.rst.utils.StitchAttrUtil;
|
|
|
+import com.iamberry.wechat.tools.ResponseJson;
|
|
|
+import com.iamberry.wechat.tools.payUtil.StringUtil;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+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.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by Administrator on 2018/8/15.
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping("/admin/inventory")
|
|
|
+public class InventoryController {
|
|
|
+ @Autowired
|
|
|
+ private InventoryService inventoryService;
|
|
|
+ @Autowired
|
|
|
+ private InventoryLogService inventoryLogService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询库存列表信息
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param pageNO
|
|
|
+ * @param pageTotal
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequiresPermissions("inventory:select:inventory")
|
|
|
+ @RequestMapping("/select_inventory_list")
|
|
|
+ public ModelAndView selectInventoryList(HttpServletRequest request,
|
|
|
+ @RequestParam(value = "pageNO", defaultValue = "1", required = false) int pageNO,
|
|
|
+ @RequestParam(value = "pageTotal", required = false) Integer pageTotal,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize,
|
|
|
+ InventoryInfo inventoryInfo
|
|
|
+ ) throws Exception {
|
|
|
+ ModelAndView mv = new ModelAndView("cm/inventory/inventory_list");
|
|
|
+ StringBuilder url = new StringBuilder("/admin/inventory/select_inventory_list?pageSize=" + pageSize);
|
|
|
+ // 封装请求数据
|
|
|
+ PageRequest<InventoryInfo> pageRequest = new PageRequest<>(inventoryInfo, pageNO, pageSize, pageTotal == null);
|
|
|
+ // 查询订单列表
|
|
|
+ PagedResult<InventoryInfo> result = inventoryService.listByInventoryId(pageRequest);
|
|
|
+ long total = 0;
|
|
|
+ if (pageTotal == null) {
|
|
|
+ total = result.getPages();
|
|
|
+ } else {
|
|
|
+ total = pageTotal;
|
|
|
+ result.setPages(total);
|
|
|
+ }
|
|
|
+ StitchAttrUtil.getSa().setModelAndView(inventoryInfo, mv, "/admin/inventory/select_inventory_list", result);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询日志列表信息
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param pageNO
|
|
|
+ * @param pageTotal
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequiresPermissions("inventoryLog:select:inventoryLog")
|
|
|
+ @RequestMapping("/select_inventoryLog_list")
|
|
|
+ public ModelAndView selectInventoryLogList(HttpServletRequest request,
|
|
|
+ @RequestParam(value = "pageNO", defaultValue = "1", required = false) int pageNO,
|
|
|
+ @RequestParam(value = "pageTotal", required = false) Integer pageTotal,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize,
|
|
|
+ InventoryLog inventoryLog
|
|
|
+ ) throws Exception {
|
|
|
+ ModelAndView mv = new ModelAndView("cm/inventory/inventoryLog_list");
|
|
|
+ StringBuilder url = new StringBuilder("/admin/inventory/select_inventoryLog_list?pageSize=" + pageSize);
|
|
|
+ // 封装请求数据
|
|
|
+ PageRequest<InventoryLog> pageRequest = new PageRequest<>(inventoryLog, pageNO, pageSize, pageTotal == null);
|
|
|
+ // 查询订单列表
|
|
|
+ PagedResult<InventoryLog> result = inventoryLogService.listByInventoryLogId(pageRequest);
|
|
|
+ long total = 0;
|
|
|
+ if (pageTotal == null) {
|
|
|
+ total = result.getPages();
|
|
|
+ } else {
|
|
|
+ total = pageTotal;
|
|
|
+ result.setPages(total);
|
|
|
+ }
|
|
|
+ //查询所有仓库
|
|
|
+ List<WarehouseInfo> warehouseList = inventoryLogService.listFactoryInfo();
|
|
|
+ mv.addObject("warehouseList",warehouseList);
|
|
|
+ StitchAttrUtil.getSa().setModelAndView(inventoryLog, mv, "/admin/Inventory/select_InventoryLog_list", result);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取库存信息
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequiresPermissions("inventory:select:inventory")
|
|
|
+ @RequestMapping("/get_Inventory_id")
|
|
|
+ public ResponseJson getInventoryId(Integer inventoryId) throws Exception {
|
|
|
+ ResponseJson rj = new ResponseJson();
|
|
|
+ InventoryInfo inventoryInfo = inventoryService.getByInventoryId(inventoryId);
|
|
|
+ if(inventoryInfo == null){
|
|
|
+ rj.setReturnCode(500);
|
|
|
+ rj.setResultMsg("ERROR");
|
|
|
+ }else{
|
|
|
+ rj.addResponseKeyValue("inventoryInfo",inventoryInfo);
|
|
|
+ }
|
|
|
+ return rj;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改库存
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequiresPermissions("signclosed:select:signclosed")
|
|
|
+ @RequestMapping(value = "/update_num")
|
|
|
+ public ResponseJson updateRemark(HttpServletRequest request,InventoryInfo inventoryInfo,Integer operationType,Integer type){
|
|
|
+ ResponseJson msg = new ResponseJson();
|
|
|
+ if(inventoryInfo == null){
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(500);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ InventoryLog inventoryLog = new InventoryLog();
|
|
|
+ InventoryInfo info = inventoryService.getByInventoryId(inventoryInfo.getInventoryId());
|
|
|
+ if(operationType == 1){//增加
|
|
|
+ info.setInventoryRemainingNum(info.getInventoryRemainingNum()+inventoryInfo.getInventoryRemainingNum());
|
|
|
+ inventoryLog.setLogOperationType(1);
|
|
|
+ }else if(operationType == 2){//减少
|
|
|
+ info.setInventoryRemainingNum(info.getInventoryRemainingNum()-inventoryInfo.getInventoryRemainingNum());
|
|
|
+ inventoryLog.setLogOperationType(2);
|
|
|
+ }
|
|
|
+ Integer num = inventoryService.updateById(inventoryInfo);
|
|
|
+ if (num < 1) {
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(500);
|
|
|
+ } else {
|
|
|
+ msg.setResultCode(200);
|
|
|
+ msg.setReturnCode(200);
|
|
|
+ inventoryLog.setLogCreateTime(new Date());
|
|
|
+ inventoryLog.setLogProductBar(info.getInventoryProductBar());
|
|
|
+ inventoryLog.setLogProductName(info.getInventoryProductName());
|
|
|
+ inventoryLog.setLogType(type);
|
|
|
+ inventoryLog.setLogWarehouseId(inventoryInfo.getInventoryId());
|
|
|
+ inventoryLogService.insert(inventoryLog);
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 跳转到修改库存数量页面
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequiresPermissions("signclosed:update:signclosed")
|
|
|
+ @RequestMapping(value = "/to_update_inventory")
|
|
|
+ public ModelAndView toUpdateInventory(HttpServletRequest request,Integer inventoryId) {
|
|
|
+ ModelAndView mv = new ModelAndView("cm/inventory/update_inventory");
|
|
|
+ if(inventoryId == null){
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+ //查询所有仓库
|
|
|
+ List<WarehouseInfo> warehouseList = inventoryLogService.listFactoryInfo();
|
|
|
+ InventoryInfo info = inventoryService.getByInventoryId(inventoryId);
|
|
|
+ mv.addObject("warehouseList",warehouseList);
|
|
|
+ mv.addObject("info",info);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|