|
@@ -1,21 +1,24 @@
|
|
|
package com.jsh.erp.controller.pda;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.jsh.erp.base.AjaxResult;
|
|
|
import com.jsh.erp.base.BaseController;
|
|
|
import com.jsh.erp.base.TableDataInfo;
|
|
|
-import com.jsh.erp.datasource.entities.DepotHead;
|
|
|
-import com.jsh.erp.datasource.entities.Supplier;
|
|
|
-import com.jsh.erp.datasource.entities.TaskStocktakingItem;
|
|
|
-import com.jsh.erp.datasource.entities.User;
|
|
|
+import com.jsh.erp.datasource.entities.*;
|
|
|
import com.jsh.erp.datasource.pda.dto.PDADepotHeadDTO;
|
|
|
import com.jsh.erp.datasource.pda.dto.PDATaskStocktakingDTO;
|
|
|
+import com.jsh.erp.datasource.pda.dto.PDATaskStocktakingItemDTO;
|
|
|
import com.jsh.erp.datasource.pda.vo.PDADepotHeadVO;
|
|
|
import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
|
|
|
import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO;
|
|
|
import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO;
|
|
|
+import com.jsh.erp.datasource.vo.SpinnerVO;
|
|
|
import com.jsh.erp.datasource.vo.TaskStocktakingVO;
|
|
|
+import com.jsh.erp.datasource.vo.TreeNode;
|
|
|
import com.jsh.erp.query.LambdaQueryWrapperX;
|
|
|
import com.jsh.erp.service.*;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -24,6 +27,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -50,6 +54,12 @@ public class PdaController extends BaseController {
|
|
|
@Resource
|
|
|
private UserService userService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MaterialCategoryService materialCategoryService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private MaterialExtendService materialExtendService;
|
|
|
+
|
|
|
/**
|
|
|
* 采购入库
|
|
|
* @return
|
|
@@ -123,10 +133,10 @@ public class PdaController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "盘点任务详情-商品列表")
|
|
|
- @GetMapping("/taskStocktakingItemList/{taskId}")
|
|
|
- public TableDataInfo taskStocktakingItemList(@PathVariable("taskId") Long taskId){
|
|
|
+ @PostMapping("/taskStocktakingItemList")
|
|
|
+ public TableDataInfo taskStocktakingItemList(@RequestBody PDATaskStocktakingItemDTO pdaTaskStocktakingItemDTO){
|
|
|
startPage();
|
|
|
- List<PDATaskStocktakingItemVO> list = taskStocktakingService.pdaItemList(taskId);
|
|
|
+ List<PDATaskStocktakingItemVO> list = taskStocktakingService.pdaItemList(pdaTaskStocktakingItemDTO);
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
@@ -137,16 +147,64 @@ public class PdaController extends BaseController {
|
|
|
return AjaxResult.success(taskStocktakingVO);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取商品类别树数据
|
|
|
+ * @Param:
|
|
|
+ * @return com.alibaba.fastjson.JSONArray
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取商品类别树数据")
|
|
|
+ @GetMapping(value = "/getMaterialCategoryTree")
|
|
|
+ public JSONArray getMaterialCategoryTree(@RequestParam("id") Long id) throws Exception{
|
|
|
+ JSONArray arr=new JSONArray();
|
|
|
+ List<TreeNode> materialCategoryTree = materialCategoryService.getMaterialCategoryTree(id);
|
|
|
+ if(materialCategoryTree!=null&&materialCategoryTree.size()>0){
|
|
|
+ for(TreeNode node:materialCategoryTree){
|
|
|
+ String str= JSON.toJSONString(node);
|
|
|
+ JSONObject obj=JSON.parseObject(str);
|
|
|
+ arr.add(obj) ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("开始任务")
|
|
|
+ @GetMapping("/startTask/{id}")
|
|
|
+ public AjaxResult startTask(@PathVariable("id") Long id) {
|
|
|
+ taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status", 2).eq("id", id));
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("任务完成")
|
|
|
+ @GetMapping("/taskComplete/{id}")
|
|
|
+ public AjaxResult taskComplete(@PathVariable("id") Long id) {
|
|
|
+ taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status", 3).eq("id", id));
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("盘点")
|
|
|
@PostMapping("/stocktaking")
|
|
|
public AjaxResult stocktaking(@RequestBody TaskStocktakingItem taskStocktakingItem) throws Exception{
|
|
|
User currentUser = userService.getCurrentUser();
|
|
|
+ MaterialExtend materialExtend = materialExtendService.getMaterialExtend(taskStocktakingItem.getMaterialItemId());
|
|
|
+ if (materialExtend == null) {
|
|
|
+ return AjaxResult.error("商品信息不存在");
|
|
|
+ }
|
|
|
UpdateWrapper<TaskStocktakingItem> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.eq("id", taskStocktakingItem.getId())
|
|
|
.set("creator", currentUser.getId())
|
|
|
.set("oper_time", new Date());
|
|
|
if (ObjectUtil.isNotEmpty(taskStocktakingItem.getNewInventory())) {
|
|
|
updateWrapper.set("new_inventory", taskStocktakingItem.getNewInventory());
|
|
|
+ BigDecimal subtract = taskStocktakingItem.getNewInventory().subtract(materialExtend.getInventory());
|
|
|
+ updateWrapper.set("difference_count", subtract);
|
|
|
+ //差异数量,设置盘点状态为1.未盘,2.盘盈,3.盘亏 4.无差异
|
|
|
+ if (subtract.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ updateWrapper.set("status", 2);
|
|
|
+ } else if (subtract.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ updateWrapper.set("status", 3);
|
|
|
+ } else {
|
|
|
+ updateWrapper.set("status", 4);
|
|
|
+ }
|
|
|
}
|
|
|
if (ObjectUtil.isNotEmpty(taskStocktakingItem.getNewPosition())) {
|
|
|
updateWrapper.set("new_position", taskStocktakingItem.getNewPosition());
|
|
@@ -161,6 +219,14 @@ public class PdaController extends BaseController {
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @ApiOperation("负责人下拉列表")
|
|
|
+ @GetMapping("/creatorSpinnerList/{taskId}")
|
|
|
+ public AjaxResult creatorSpinnerList(@PathVariable("taskId") Long taskId) {
|
|
|
+ List<SpinnerVO> spinnerVOList = taskStocktakingItemService.creatorSpinnerList(taskId);
|
|
|
+ return AjaxResult.success(spinnerVOList);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("订单-用于返回字段说明")
|
|
|
@GetMapping("test")
|
|
|
public AjaxResult test(PDADepotItemVO pdaDepotItemVO) {
|