浏览代码

Merge remote-tracking branch 'origin/master_liaozeyong'

# Conflicts:
#	src/main/java/com/jsh/erp/controller/pda/PdaController.java
13660505945 1 月之前
父节点
当前提交
314fa15adb

+ 41 - 0
src/main/java/com/jsh/erp/config/JacksonConfig.java

@@ -0,0 +1,41 @@
+package com.jsh.erp.config;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+
+import java.util.TimeZone;
+
+/**
+ * Jackson配置
+ *
+ * @author ruoyi
+ *
+ */
+@Configuration
+public class JacksonConfig
+{
+    @Bean
+    public MappingJackson2HttpMessageConverter jackson2HttpMessageConverter()
+    {
+        final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
+        builder.serializationInclusion(JsonInclude.Include.NON_NULL);
+        final ObjectMapper objectMapper = builder.build();
+        SimpleModule simpleModule = new SimpleModule();
+        // Long 转为 String 防止 js 丢失精度
+        simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
+        //simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
+        objectMapper.registerModule(simpleModule);
+        // 忽略 transient 关键词属性
+        objectMapper.configure(MapperFeature.PROPAGATE_TRANSIENT_MARKER, true);
+        // 设置时区
+        objectMapper.setTimeZone(TimeZone.getDefault());
+        return new MappingJackson2HttpMessageConverter(objectMapper);
+    }
+}

+ 72 - 4
src/main/java/com/jsh/erp/controller/pda/PdaController.java

@@ -1,24 +1,30 @@
 package com.jsh.erp.controller.pda;
 package com.jsh.erp.controller.pda;
 
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.jsh.erp.base.AjaxResult;
 import com.jsh.erp.base.AjaxResult;
 import com.jsh.erp.base.BaseController;
 import com.jsh.erp.base.BaseController;
 import com.jsh.erp.base.TableDataInfo;
 import com.jsh.erp.base.TableDataInfo;
 import com.jsh.erp.datasource.entities.DepotHead;
 import com.jsh.erp.datasource.entities.DepotHead;
 import com.jsh.erp.datasource.entities.Supplier;
 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.pda.dto.PDADepotHeadDTO;
 import com.jsh.erp.datasource.pda.dto.PDADepotHeadDTO;
+import com.jsh.erp.datasource.pda.dto.PDATaskStocktakingDTO;
 import com.jsh.erp.datasource.pda.vo.PDADepotHeadVO;
 import com.jsh.erp.datasource.pda.vo.PDADepotHeadVO;
 import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
 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.TaskStocktakingVO;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.query.LambdaQueryWrapperX;
-import com.jsh.erp.service.DepotHeadService;
-import com.jsh.erp.service.DepotItemService;
-import com.jsh.erp.service.SupplierService;
+import com.jsh.erp.service.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 @RestController
 @RestController
@@ -35,6 +41,15 @@ public class PdaController extends BaseController {
     @Resource
     @Resource
     private SupplierService supplierService;
     private SupplierService supplierService;
 
 
+    @Resource
+    private TaskStocktakingService taskStocktakingService;
+
+    @Resource
+    private TaskStocktakingItemService taskStocktakingItemService;
+
+    @Resource
+    private UserService userService;
+
     /**
     /**
      * 采购入库
      * 采购入库
      * @return
      * @return
@@ -99,12 +114,65 @@ public class PdaController extends BaseController {
         return getDataTable(list);
         return getDataTable(list);
     }
     }
 
 
-    @ApiOperation("用于返回字段说明")
+    @ApiOperation("盘点任务列表")
+    @PostMapping("/taskStocktakingList")
+    public TableDataInfo taskStocktakingList(@RequestBody PDATaskStocktakingDTO pdaTaskStocktakingDTO) {
+        startPage();
+        List<PDATaskStocktakingVO> list = taskStocktakingService.pdaList(pdaTaskStocktakingDTO.getNumber(), pdaTaskStocktakingDTO.getStatus());
+        return getDataTable(list);
+    }
+
+    @ApiOperation(value = "盘点任务详情-商品列表")
+    @GetMapping("/taskStocktakingItemList/{taskId}")
+    public TableDataInfo taskStocktakingItemList(@PathVariable("taskId") Long taskId){
+        startPage();
+        List<PDATaskStocktakingItemVO> list = taskStocktakingService.pdaItemList(taskId);
+        return getDataTable(list);
+    }
+
+    @ApiOperation("盘点任务详情")
+    @GetMapping("/taskStocktakingDetail/{taskId}")
+    public AjaxResult taskStocktakingDetail(@PathVariable("taskId") Long taskId) throws Exception{
+        TaskStocktakingVO taskStocktakingVO = taskStocktakingService.pdaDetail(taskId);
+        return AjaxResult.success(taskStocktakingVO);
+    }
+
+    @ApiOperation("盘点")
+    @PostMapping("/stocktaking")
+    public AjaxResult stocktaking(@RequestBody TaskStocktakingItem taskStocktakingItem) throws Exception{
+        User currentUser = userService.getCurrentUser();
+        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());
+        }
+        if (ObjectUtil.isNotEmpty(taskStocktakingItem.getNewPosition())) {
+            updateWrapper.set("new_position", taskStocktakingItem.getNewPosition());
+        }
+        if (ObjectUtil.isNotEmpty(taskStocktakingItem.getDifferenceCount())) {
+            updateWrapper.set("difference_count", taskStocktakingItem.getDifferenceCount());
+        }
+        if (ObjectUtil.isNotEmpty(taskStocktakingItem.getDifferenceReason())){
+            updateWrapper.set("difference_reason", taskStocktakingItem.getDifferenceReason());
+        }
+        taskStocktakingItemService.update(updateWrapper);
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("订单-用于返回字段说明")
     @GetMapping("test")
     @GetMapping("test")
     public AjaxResult test(PDADepotItemVO pdaDepotItemVO) {
     public AjaxResult test(PDADepotItemVO pdaDepotItemVO) {
         return AjaxResult.success();
         return AjaxResult.success();
     }
     }
 
 
+    @ApiOperation("盘点-用于字段返回说明")
+    @GetMapping("taskTest")
+    public AjaxResult taskTest(PDATaskStocktakingVO pdaTaskStocktakingVO){
+        return AjaxResult.success();
+    }
+
     /**
     /**
      * PDA订单提交
      * PDA订单提交
      */
      */

+ 48 - 4
src/main/java/com/jsh/erp/controller/stocktaking/StocktakingController.java

@@ -8,16 +8,20 @@ import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
 import com.jsh.erp.datasource.dto.TaskStocktakingItemDTO;
 import com.jsh.erp.datasource.dto.TaskStocktakingItemDTO;
 import com.jsh.erp.datasource.entities.TaskStocktaking;
 import com.jsh.erp.datasource.entities.TaskStocktaking;
 import com.jsh.erp.datasource.entities.TaskStocktakingItem;
 import com.jsh.erp.datasource.entities.TaskStocktakingItem;
+import com.jsh.erp.datasource.entities.User;
 import com.jsh.erp.datasource.vo.SpinnerVO;
 import com.jsh.erp.datasource.vo.SpinnerVO;
-import com.jsh.erp.query.LambdaQueryWrapperX;
+import com.jsh.erp.datasource.vo.TaskStocktakingVO;
 import com.jsh.erp.service.TaskStocktakingItemService;
 import com.jsh.erp.service.TaskStocktakingItemService;
 import com.jsh.erp.service.TaskStocktakingService;
 import com.jsh.erp.service.TaskStocktakingService;
 import com.jsh.erp.service.UserService;
 import com.jsh.erp.service.UserService;
+import com.jsh.erp.utils.DateUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import java.util.Arrays;
 import java.util.List;
 import java.util.List;
 
 
 @RestController
 @RestController
@@ -38,14 +42,17 @@ public class StocktakingController extends BaseController {
     @PostMapping("/list")
     @PostMapping("/list")
     public TableDataInfo list(){
     public TableDataInfo list(){
         startPage();
         startPage();
-        List<TaskStocktaking> list = taskStocktakingService.list();
+        List<TaskStocktakingVO> list = taskStocktakingService.listBy();
         return getDataTable(list);
         return getDataTable(list);
     }
     }
 
 
     @ApiOperation("新增盘点任务")
     @ApiOperation("新增盘点任务")
     @PostMapping("/add")
     @PostMapping("/add")
     public AjaxResult add(@RequestBody TaskStocktakingDTO taskStocktakingDTO) {
     public AjaxResult add(@RequestBody TaskStocktakingDTO taskStocktakingDTO) {
-        taskStocktakingService.add(taskStocktakingDTO);
+        boolean b = taskStocktakingService.add(taskStocktakingDTO);
+        if (!b){
+            return AjaxResult.error("创建失败,请联系系统管理员");
+        }
         return AjaxResult.success();
         return AjaxResult.success();
     }
     }
 
 
@@ -61,6 +68,7 @@ public class StocktakingController extends BaseController {
      * @param id
      * @param id
      * @return
      * @return
      */
      */
+    @ApiOperation("任务详情")
     @GetMapping("/detail/{id}")
     @GetMapping("/detail/{id}")
     public AjaxResult detail(@PathVariable("id") Long id) throws Exception{
     public AjaxResult detail(@PathVariable("id") Long id) throws Exception{
         return AjaxResult.success(taskStocktakingService.detail(id));
         return AjaxResult.success(taskStocktakingService.detail(id));
@@ -71,24 +79,60 @@ public class StocktakingController extends BaseController {
      * @param taskStocktakingId 任务ID
      * @param taskStocktakingId 任务ID
      * @return
      * @return
      */
      */
+    @ApiOperation("任务详情-商品列表")
     @GetMapping("/detailByItemList/{taskStocktakingId}")
     @GetMapping("/detailByItemList/{taskStocktakingId}")
     public AjaxResult detailByItemList(@PathVariable("taskStocktakingId") Long taskStocktakingId) {
     public AjaxResult detailByItemList(@PathVariable("taskStocktakingId") Long taskStocktakingId) {
         return AjaxResult.success(taskStocktakingService.listByTaskStocktakingId(taskStocktakingId));
         return AjaxResult.success(taskStocktakingService.listByTaskStocktakingId(taskStocktakingId));
     }
     }
 
 
+    @ApiOperation("任务详情-修改")
+    @PostMapping("/detailUpdate")
+    public AjaxResult detailUpdate(@RequestBody TaskStocktakingDTO taskStocktakingDTO) {
+        boolean b = taskStocktakingService.detailUpdate(taskStocktakingDTO);
+        if (!b){
+            return AjaxResult.error("修改失败,请联系系统管理员");
+        }
+        return AjaxResult.success();
+    }
+
     /**
     /**
      * 任务详情-商品列表-编辑
      * 任务详情-商品列表-编辑
      * @return
      * @return
      */
      */
+    @ApiModelProperty("任务详情-商品-编辑")
     @PostMapping("/itemUpdate")
     @PostMapping("/itemUpdate")
-    public AjaxResult itemUpdate(@RequestBody TaskStocktakingItemDTO taskStocktakingItemDTO) {
+    public AjaxResult itemUpdate(@RequestBody TaskStocktakingItemDTO taskStocktakingItemDTO) throws Exception {
+        User currentUser = userService.getCurrentUser();
         taskStocktakingItemService.update(new UpdateWrapper<TaskStocktakingItem>()
         taskStocktakingItemService.update(new UpdateWrapper<TaskStocktakingItem>()
                 .set("new_inventory", taskStocktakingItemDTO.getNewInventory())
                 .set("new_inventory", taskStocktakingItemDTO.getNewInventory())
                 .set("new_position", taskStocktakingItemDTO.getNewPosition())
                 .set("new_position", taskStocktakingItemDTO.getNewPosition())
                 .set("difference_count", taskStocktakingItemDTO.getDifferenceCount())
                 .set("difference_count", taskStocktakingItemDTO.getDifferenceCount())
                 .set("difference_reason", taskStocktakingItemDTO.getDifferenceReason())
                 .set("difference_reason", taskStocktakingItemDTO.getDifferenceReason())
+                .set("creator", currentUser.getId())
+                .set("oper_time", DateUtils.getTime())
                 .eq("id", taskStocktakingItemDTO.getId()));
                 .eq("id", taskStocktakingItemDTO.getId()));
         return AjaxResult.success();
         return AjaxResult.success();
     }
     }
 
 
+    /**
+     * 任务详情-商品-删除
+     * @param id 商品ID
+     * @return
+     */
+    @ApiModelProperty("任务详情-商品-删除")
+    @GetMapping("/itemDelete/{id}")
+    public AjaxResult itemDelete(@PathVariable("id") Long id) {
+        taskStocktakingItemService.update(new UpdateWrapper<TaskStocktakingItem>().set("delete_flag", true).eq("id", id));
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("取消任务")
+    @GetMapping("/taskCancel/{ids}")
+    public AjaxResult taskCancel(@PathVariable("ids") Long[] ids) {
+        Arrays.asList(ids).forEach(id -> {
+            taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().eq("id", id).set("task_status", "4"));
+        });
+        return AjaxResult.success();
+    }
+
 }
 }

+ 1 - 1
src/main/java/com/jsh/erp/datasource/dto/TaskStocktakingDTO.java

@@ -16,6 +16,6 @@ import java.util.List;
 public class TaskStocktakingDTO extends TaskStocktaking {
 public class TaskStocktakingDTO extends TaskStocktaking {
 
 
     @ApiModelProperty("商品扩展ID集合")
     @ApiModelProperty("商品扩展ID集合")
-    private List<Long> materialExtendIdList;
+    private List<String> materialExtendIdList;
 
 
 }
 }

+ 2 - 1
src/main/java/com/jsh/erp/datasource/entities/Material.java

@@ -1,12 +1,12 @@
 package com.jsh.erp.datasource.entities;
 package com.jsh.erp.datasource.entities;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 import lombok.experimental.Accessors;
 import lombok.experimental.Accessors;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
-import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -86,6 +86,7 @@ public class Material {
     @ApiModelProperty("无动销提醒周期")
     @ApiModelProperty("无动销提醒周期")
     private String movingPinReminderCycle;
     private String movingPinReminderCycle;
 
 
+    @TableField(exist = false)
     private List<MaterialExtend> list;
     private List<MaterialExtend> list;
 
 
 
 

+ 13 - 1
src/main/java/com/jsh/erp/datasource/entities/TaskStocktaking.java

@@ -1,5 +1,6 @@
 package com.jsh.erp.datasource.entities;
 package com.jsh.erp.datasource.entities;
 
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 import lombok.experimental.Accessors;
 import lombok.experimental.Accessors;
@@ -26,6 +27,7 @@ public class TaskStocktaking {
     private Long createBy;
     private Long createBy;
 
 
     @ApiModelProperty("创建时间")
     @ApiModelProperty("创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date createTime;
     private Date createTime;
 
 
     @ApiModelProperty("任务类型 1.全盘,2.抽盘")
     @ApiModelProperty("任务类型 1.全盘,2.抽盘")
@@ -37,10 +39,13 @@ public class TaskStocktaking {
     @ApiModelProperty("任务单号")
     @ApiModelProperty("任务单号")
     private String number;
     private String number;
 
 
+    @ApiModelProperty("种类数")
+    private Integer categoryCount;
+
     @ApiModelProperty("商品数")
     @ApiModelProperty("商品数")
     private int materialCount;
     private int materialCount;
 
 
-    @ApiModelProperty("任务状态 0.未开始,1.进行中,2.已完成,3.已取消")
+    @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消")
     private Integer taskStatus;
     private Integer taskStatus;
 
 
     @ApiModelProperty("盘点范围")
     @ApiModelProperty("盘点范围")
@@ -49,4 +54,11 @@ public class TaskStocktaking {
     @ApiModelProperty("删除标记,0.未删除,1.已删除")
     @ApiModelProperty("删除标记,0.未删除,1.已删除")
     private boolean deleteFlag;
     private boolean deleteFlag;
 
 
+    @ApiModelProperty("盘点人")
+    private Long operBy;
+
+    @ApiModelProperty("盘点时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date operTime;
+
 }
 }

+ 5 - 0
src/main/java/com/jsh/erp/datasource/entities/User.java

@@ -1,5 +1,10 @@
 package com.jsh.erp.datasource.entities;
 package com.jsh.erp.datasource.entities;
 
 
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+@Data
+@TableName(value = "jsh_user")
 public class User {
 public class User {
     private Long id;
     private Long id;
 
 

+ 3 - 0
src/main/java/com/jsh/erp/datasource/mappers/TaskStocktakingItemMapper.java

@@ -1,6 +1,7 @@
 package com.jsh.erp.datasource.mappers;
 package com.jsh.erp.datasource.mappers;
 
 
 import com.jsh.erp.datasource.entities.TaskStocktakingItem;
 import com.jsh.erp.datasource.entities.TaskStocktakingItem;
+import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
@@ -10,4 +11,6 @@ public interface TaskStocktakingItemMapper extends BaseMapperX<TaskStocktakingIt
 
 
     List<TaskStocktakingItemVO> listByTaskStocktakingId(@Param("taskStocktakingId") Long taskStocktakingId);
     List<TaskStocktakingItemVO> listByTaskStocktakingId(@Param("taskStocktakingId") Long taskStocktakingId);
 
 
+    List<PDATaskStocktakingItemVO> pdaList(@Param("taskId") Long taskId);
+
 }
 }

+ 9 - 0
src/main/java/com/jsh/erp/datasource/mappers/TaskStocktakingMapper.java

@@ -1,6 +1,15 @@
 package com.jsh.erp.datasource.mappers;
 package com.jsh.erp.datasource.mappers;
 
 
 import com.jsh.erp.datasource.entities.TaskStocktaking;
 import com.jsh.erp.datasource.entities.TaskStocktaking;
+import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO;
+import com.jsh.erp.datasource.vo.TaskStocktakingVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 
 public interface TaskStocktakingMapper extends BaseMapperX<TaskStocktaking> {
 public interface TaskStocktakingMapper extends BaseMapperX<TaskStocktaking> {
+
+    List<TaskStocktakingVO> listBy();
+
+    List<PDATaskStocktakingVO> pdaList(@Param("number") String number , @Param("taskStatus") Integer taskStatus);
 }
 }

+ 15 - 0
src/main/java/com/jsh/erp/datasource/pda/dto/PDATaskStocktakingDTO.java

@@ -0,0 +1,15 @@
+package com.jsh.erp.datasource.pda.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class PDATaskStocktakingDTO {
+
+    @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消")
+    private Integer status;
+
+    @ApiModelProperty("任务单号")
+    private String number;
+
+}

+ 43 - 0
src/main/java/com/jsh/erp/datasource/pda/vo/PDATaskStocktakingItemVO.java

@@ -0,0 +1,43 @@
+package com.jsh.erp.datasource.pda.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * 盘点任务明细
+ */
+@Data
+@Accessors(chain = true)
+public class PDATaskStocktakingItemVO {
+
+    @ApiModelProperty("主键ID")
+    private Long id;
+
+    @ApiModelProperty("库位")
+    private String position;
+
+    @ApiModelProperty("商品总类")
+    private String categoryName;
+
+    @ApiModelProperty("商品名称")
+    private String materialName;
+
+    @ApiModelProperty("商品规格")
+    private String standard;
+
+    @ApiModelProperty("盘点人名称")
+    private String createName;
+
+    @ApiModelProperty("盘点时间")
+    private Date operTime;
+
+    @ApiModelProperty("库存数")
+    private Integer inventory;
+
+    @ApiModelProperty("盘点库存数")
+    private Integer newInventory;
+
+}

+ 47 - 0
src/main/java/com/jsh/erp/datasource/pda/vo/PDATaskStocktakingVO.java

@@ -0,0 +1,47 @@
+package com.jsh.erp.datasource.pda.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class PDATaskStocktakingVO {
+
+    @ApiModelProperty("任务ID")
+    private Long id;
+
+    @ApiModelProperty("任务名称")
+    private String taskName;
+
+    @ApiModelProperty("任务单号")
+    private String number;
+
+    @ApiModelProperty("仓库名称")
+    private String depotName;
+
+    @ApiModelProperty("创建人名称")
+    private String createByName;
+
+    @ApiModelProperty("负责人名称")
+    private String creatorName;
+
+    @ApiModelProperty("种类数")
+    private Integer categoryCount;
+
+    @ApiModelProperty("商品数")
+    private Integer materialCount;
+
+    @ApiModelProperty("盘点人名称")
+    private String operName;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+
+    @ApiModelProperty("盘点时间")
+    private Date operTime;
+
+    @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消")
+    private Integer taskStatus;
+
+}

+ 30 - 0
src/main/java/com/jsh/erp/datasource/vo/TaskStocktakingItemVO.java

@@ -1,5 +1,6 @@
 package com.jsh.erp.datasource.vo;
 package com.jsh.erp.datasource.vo;
 
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 import lombok.experimental.Accessors;
 import lombok.experimental.Accessors;
@@ -20,6 +21,34 @@ public class TaskStocktakingItemVO {
     @ApiModelProperty("任务ID")
     @ApiModelProperty("任务ID")
     private Long taskStocktakingId;
     private Long taskStocktakingId;
 
 
+    @ApiModelProperty("商品名称")
+    private String materialName;
+
+    @ApiModelProperty("系统编码")
+    private String systemSku;
+
+    @ApiModelProperty("商品单位")
+    private String commodityUnit;
+
+    @ApiModelProperty("生产日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date productionDate;
+
+    @ApiModelProperty("供应商名称")
+    private String supplierName;
+
+    @ApiModelProperty("商品编码")
+    private String barCode;
+
+    @ApiModelProperty("库存数量")
+    private String inventory;
+
+    @ApiModelProperty("仓库名称")
+    private String depotName;
+
+    @ApiModelProperty("商品种类名称")
+    private String categoryName;
+
     @ApiModelProperty("商品ID")
     @ApiModelProperty("商品ID")
     private Long materialItemId;
     private Long materialItemId;
 
 
@@ -27,6 +56,7 @@ public class TaskStocktakingItemVO {
     private Long creator;
     private Long creator;
 
 
     @ApiModelProperty("操作时间")
     @ApiModelProperty("操作时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date operTime;
     private Date operTime;
 
 
     @ApiModelProperty("新仓位货架")
     @ApiModelProperty("新仓位货架")

+ 12 - 2
src/main/java/com/jsh/erp/datasource/vo/TaskStocktakingVO.java

@@ -5,8 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 import lombok.experimental.Accessors;
 import lombok.experimental.Accessors;
 
 
-import java.util.List;
-
 /**
 /**
  * 盘点任务
  * 盘点任务
  */
  */
@@ -23,4 +21,16 @@ public class TaskStocktakingVO extends TaskStocktaking {
     @ApiModelProperty("仓库名称")
     @ApiModelProperty("仓库名称")
     private String depotName;
     private String depotName;
 
 
+    @ApiModelProperty("完成操作次数")
+    private Long finishCount;
+
+    @ApiModelProperty("商品总数量")
+    private Long itemCount;
+
+    @ApiModelProperty("差异率")
+    private double differenceRate;
+
+    @ApiModelProperty("准确率")
+    private double accuracyRate;
+
 }
 }

+ 33 - 0
src/main/java/com/jsh/erp/service/TaskStocktakingService.java

@@ -3,6 +3,8 @@ package com.jsh.erp.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
 import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
 import com.jsh.erp.datasource.entities.TaskStocktaking;
 import com.jsh.erp.datasource.entities.TaskStocktaking;
+import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO;
+import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingVO;
 
 
@@ -11,6 +13,12 @@ import java.util.List;
 public interface TaskStocktakingService extends IService<TaskStocktaking> {
 public interface TaskStocktakingService extends IService<TaskStocktaking> {
 
 
     /**
     /**
+     *
+     * @return
+     */
+    List<TaskStocktakingVO> listBy();
+
+    /**
      * 新增任务
      * 新增任务
      * @param taskStocktakingDTO
      * @param taskStocktakingDTO
      * @return
      * @return
@@ -24,11 +32,36 @@ public interface TaskStocktakingService extends IService<TaskStocktaking> {
     TaskStocktakingVO detail(Long id) throws Exception;
     TaskStocktakingVO detail(Long id) throws Exception;
 
 
     /**
     /**
+     * 任务详情-修改
+     * @param taskStocktakingDTO
+     * @return
+     */
+    boolean detailUpdate(TaskStocktakingDTO taskStocktakingDTO);
+
+    /**
      * 任务详情-商品明细
      * 任务详情-商品明细
      * @param taskStocktakingId 盘点任务ID
      * @param taskStocktakingId 盘点任务ID
      * @return
      * @return
      */
      */
     List<TaskStocktakingItemVO> listByTaskStocktakingId(Long taskStocktakingId);
     List<TaskStocktakingItemVO> listByTaskStocktakingId(Long taskStocktakingId);
 
 
+    /**
+     * PDA-盘点任务列表
+     * @param number 盘点单号或者任务名称
+     * @param taskStatus 盘点任务状态
+     * @return
+     */
+    List<PDATaskStocktakingVO> pdaList(String number , Integer taskStatus);
+
+    /**
+     * PAD-盘点任务详情
+     * @param id 盘点任务ID
+     * @return
+     * @throws Exception
+     */
+    TaskStocktakingVO pdaDetail(Long id) throws Exception;
+
+    List<PDATaskStocktakingItemVO> pdaItemList(Long taskId);
+
 
 
 }
 }

+ 194 - 14
src/main/java/com/jsh/erp/service/impl/TaskStocktakingServiceImpl.java

@@ -1,27 +1,33 @@
 package com.jsh.erp.service.impl;
 package com.jsh.erp.service.impl;
 
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
 import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.entities.*;
-import com.jsh.erp.datasource.mappers.MaterialExtendMapper;
-import com.jsh.erp.datasource.mappers.TaskStocktakingItemMapper;
-import com.jsh.erp.datasource.mappers.TaskStocktakingMapper;
-import com.jsh.erp.datasource.mappers.UserMapper;
+import com.jsh.erp.datasource.mappers.*;
+import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO;
+import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingVO;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.service.DepotService;
 import com.jsh.erp.service.DepotService;
 import com.jsh.erp.service.TaskStocktakingService;
 import com.jsh.erp.service.TaskStocktakingService;
+import com.jsh.erp.service.UserService;
+import com.jsh.erp.utils.DateUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -39,22 +45,71 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
 
 
     private final TaskStocktakingItemMapper taskStocktakingItemMapper;
     private final TaskStocktakingItemMapper taskStocktakingItemMapper;
 
 
+    private final TaskStocktakingMapper taskStocktakingMapper;
+
+    private final MaterialMapper materialMapper;
+
+    private final UserService userService;
+
+    @Override
+    public List<TaskStocktakingVO> listBy() {
+        return taskStocktakingMapper.listBy();
+    }
+
     /**
     /**
      * 创建盘点任务
      * 创建盘点任务
      * @param taskStocktakingDTO
      * @param taskStocktakingDTO
      * @return
      * @return
      */
      */
     @Override
     @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public boolean add(TaskStocktakingDTO taskStocktakingDTO) {
     public boolean add(TaskStocktakingDTO taskStocktakingDTO) {
-        //商品库位范围处理
-        List<String> collect;
-        if (taskStocktakingDTO.getTaskType() == 1) {
-            collect = materialExtendMapper.selectList(new LambdaQueryWrapper<MaterialExtend>().ne(MaterialExtend::getInventory, BigDecimal.ZERO)).stream().map(MaterialExtend::getPosition).collect(Collectors.toList());
-        } else {
-            collect = materialExtendMapper.selectList(new LambdaQueryWrapper<MaterialExtend>().in(MaterialExtend::getId, taskStocktakingDTO.getMaterialExtendIdList())).stream().map(MaterialExtend::getPosition).collect(Collectors.toList());
+        try {
+            List<String> collect;
+            List<MaterialExtend> materialExtendList;
+            //全盘,抽盘,处理任务明细
+            if (taskStocktakingDTO.getTaskType() == 1) {
+                materialExtendList = materialExtendMapper.selectList(new LambdaQueryWrapper<MaterialExtend>().ne(MaterialExtend::getInventory, BigDecimal.ZERO).isNotNull(MaterialExtend::getInventory));
+                collect = materialExtendList
+                        .stream()
+                        .map(MaterialExtend::getPosition)
+                        .collect(Collectors.toList());
+                List<Long> materialIdList = materialExtendList.stream().map(MaterialExtend::getMaterialId).distinct().collect(Collectors.toList());
+                List<Material> materialList = materialMapper.selectList(new LambdaQueryWrapperX<Material>().eq(Material::getId, materialIdList));
+                List<Long> categoryIdList = materialList.stream().map(Material::getCategoryId).distinct().collect(Collectors.toList());
+                taskStocktakingDTO.setCategoryCount(categoryIdList.size());
+                taskStocktakingDTO.setMaterialCount(materialExtendList.size());
+            } else {
+                materialExtendList = materialExtendMapper.selectList(new LambdaQueryWrapper<MaterialExtend>().in(MaterialExtend::getBatchNumber, taskStocktakingDTO.getMaterialExtendIdList()));
+                collect = materialExtendList.stream().map(MaterialExtend::getPosition).collect(Collectors.toList());
+                List<Long> materialIdList = materialExtendList.stream().map(MaterialExtend::getMaterialId).collect(Collectors.toList());
+                List<Material> materialList = materialMapper.selectList(new LambdaQueryWrapperX<Material>().in(Material::getId, materialIdList));
+                List<Long> categoryIdList = materialList.stream().map(Material::getCategoryId).distinct().collect(Collectors.toList());
+                taskStocktakingDTO.setCategoryCount(categoryIdList.size());
+                taskStocktakingDTO.setMaterialCount(materialExtendList.size());
+            }
+            //处理商品库位范围处理
+            String positionRange = extractRangePair(collect);
+            taskStocktakingDTO.setPositionRange(positionRange);
+            User currentUser = userService.getCurrentUser();
+            taskStocktakingDTO.setCreateBy(currentUser.getId());
+            taskStocktakingDTO.setCreateTime(new Date());
+            taskStocktakingDTO.setTaskStatus(1);
+            //生成任务
+            this.save(taskStocktakingDTO);
+            //生成任务明细
+            List<TaskStocktakingItem> taskStocktakingItemList = new ArrayList<>();
+            materialExtendList.forEach(item -> {
+                TaskStocktakingItem taskStocktakingItem = new TaskStocktakingItem();
+                taskStocktakingItem.setTaskStocktakingId(taskStocktakingDTO.getId());
+                taskStocktakingItem.setMaterialItemId(item.getId());
+                taskStocktakingItemList.add(taskStocktakingItem);
+            });
+            taskStocktakingItemMapper.insertBatch(taskStocktakingItemList);
+        } catch (Exception e) {
+            log.error("创建盘点任务失败", e);
+            return false;
         }
         }
-        String positionRange = extractRangePair(collect);
-        this.save(taskStocktakingDTO);
         return true;
         return true;
     }
     }
 
 
@@ -71,10 +126,14 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
         BeanUtils.copyProperties(one, taskStocktakingVO);
         BeanUtils.copyProperties(one, taskStocktakingVO);
         //获取负责人名称
         //获取负责人名称
         User user = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getId, one.getCreator()));
         User user = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getId, one.getCreator()));
-        taskStocktakingVO.setCreatorName(user.getLoginName());
+        if (user != null) {
+            taskStocktakingVO.setCreatorName(user.getLoginName());
+        }
         //获取创建人名称
         //获取创建人名称
         User user1 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getId, one.getCreateBy()));
         User user1 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getId, one.getCreateBy()));
-        taskStocktakingVO.setCreateByName(user1.getLoginName());
+        if (user1 != null) {
+            taskStocktakingVO.setCreateByName(user1.getLoginName());
+        }
         //获取仓库名称
         //获取仓库名称
         Depot depot = depotService.getDepot(one.getDepotId());
         Depot depot = depotService.getDepot(one.getDepotId());
         taskStocktakingVO.setDepotName(depot.getName());
         taskStocktakingVO.setDepotName(depot.getName());
@@ -83,6 +142,74 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
     }
     }
 
 
     /**
     /**
+     * 任务详情-修改
+     * @param taskStocktakingDTO
+     * @return
+     */
+    @Override
+    public boolean detailUpdate(TaskStocktakingDTO taskStocktakingDTO) {
+        try {
+            List<String> collect;
+            List<MaterialExtend> materialExtendList;
+            //全盘,抽盘,处理任务明细
+            if (taskStocktakingDTO.getTaskType() == 1) {
+                materialExtendList = materialExtendMapper.selectList(new LambdaQueryWrapper<MaterialExtend>().ne(MaterialExtend::getInventory, BigDecimal.ZERO).isNotNull(MaterialExtend::getInventory));
+                collect = materialExtendList
+                        .stream()
+                        .map(MaterialExtend::getPosition)
+                        .collect(Collectors.toList());
+                List<Long> materialIdList = materialExtendList.stream().map(MaterialExtend::getMaterialId).distinct().collect(Collectors.toList());
+                List<Material> materialList = materialMapper.selectList(new LambdaQueryWrapperX<Material>().eq(Material::getId, materialIdList));
+                List<Long> categoryIdList = materialList.stream().map(Material::getCategoryId).distinct().collect(Collectors.toList());
+                taskStocktakingDTO.setCategoryCount(categoryIdList.size());
+                taskStocktakingDTO.setMaterialCount(materialExtendList.size());
+            } else {
+                materialExtendList = materialExtendMapper.selectList(new LambdaQueryWrapper<MaterialExtend>().in(MaterialExtend::getBatchNumber, taskStocktakingDTO.getMaterialExtendIdList()));
+                collect = materialExtendList.stream().map(MaterialExtend::getPosition).collect(Collectors.toList());
+                List<Long> materialIdList = materialExtendList.stream().map(MaterialExtend::getMaterialId).collect(Collectors.toList());
+                List<Material> materialList = materialMapper.selectList(new LambdaQueryWrapperX<Material>().in(Material::getId, materialIdList));
+                List<Long> categoryIdList = materialList.stream().map(Material::getCategoryId).distinct().collect(Collectors.toList());
+                taskStocktakingDTO.setCategoryCount(categoryIdList.size());
+                taskStocktakingDTO.setMaterialCount(materialExtendList.size());
+            }
+            //处理商品库位范围处理
+            String positionRange = extractRangePair(collect);
+            taskStocktakingDTO.setPositionRange(positionRange);
+            User currentUser = userService.getCurrentUser();
+            taskStocktakingDTO.setCreateBy(currentUser.getId());
+            taskStocktakingDTO.setCreateTime(new Date());
+            taskStocktakingDTO.setTaskStatus(1);
+            //生成任务
+            this.save(taskStocktakingDTO);
+            List<Long> taskStocktakingItemIdList = taskStocktakingItemMapper.selectList(new LambdaQueryWrapperX<TaskStocktakingItem>().eq(TaskStocktakingItem::getTaskStocktakingId, taskStocktakingDTO.getId())).stream().map(TaskStocktakingItem::getId).collect(Collectors.toList());
+            //生成任务明细
+            List<TaskStocktakingItem> addTaskStocktakingItemList = new ArrayList<>();
+            materialExtendList.forEach(item -> {
+                if (!taskStocktakingItemIdList.contains(item.getId())) {
+                    TaskStocktakingItem taskStocktakingItem = new TaskStocktakingItem();
+                    taskStocktakingItem.setTaskStocktakingId(taskStocktakingDTO.getId());
+                    taskStocktakingItem.setMaterialItemId(item.getId());
+                    addTaskStocktakingItemList.add(taskStocktakingItem);
+                }
+            });
+            List<Long> materialExtendIdList = materialExtendList.stream().map(MaterialExtend::getId).collect(Collectors.toList());
+            taskStocktakingItemIdList.forEach(item -> {
+                if (!materialExtendIdList.contains(item)) {
+
+//                    taskStocktakingItemMapper.updateById();
+                }
+            });
+            if (addTaskStocktakingItemList.size() > 0) {
+                taskStocktakingItemMapper.insertBatch(addTaskStocktakingItemList);
+            }
+        } catch (Exception e) {
+            log.error("创建盘点任务失败", e);
+            return false;
+        }
+        return true;
+    }
+
+    /**
      * 任务详情-商品明细
      * 任务详情-商品明细
      * @param taskStocktakingId 盘点任务ID
      * @param taskStocktakingId 盘点任务ID
      * @return
      * @return
@@ -93,6 +220,59 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
     }
     }
 
 
     /**
     /**
+     * PDA-盘点任务列表
+     * @param number 盘点单号或者任务名称
+     * @param taskStatus 盘点任务状态
+     * @return
+     */
+    @Override
+    public List<PDATaskStocktakingVO> pdaList(String number , Integer taskStatus) {
+        return taskStocktakingMapper.pdaList(number , taskStatus);
+    }
+
+    /**
+     * PDA-盘点任务详情
+     * @param id 盘点任务ID
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public TaskStocktakingVO pdaDetail(Long id) throws Exception{
+        TaskStocktakingVO detail = detail(id);
+        List<TaskStocktakingItem> itemList = taskStocktakingItemMapper.selectList(new LambdaQueryWrapper<TaskStocktakingItem>().eq(TaskStocktakingItem::getTaskStocktakingId, id));
+        //已操作数量
+        long finishCount = itemList.stream().filter(item -> item.getCreator() != null).count();
+        //商品总数量
+        long itemCount = itemList.size();
+        //商品差异条数
+        long itemDifferenceCount = itemList.stream().filter(item -> item.getCreator() != null
+                && item.getDifferenceCount() != null
+                && item.getDifferenceCount() > 0).count();
+        //差异率
+        double differenceRate = 0;
+        //准确率
+        double accuracyRate = 0;
+        if (itemDifferenceCount > 0) {
+            differenceRate = BigDecimal.valueOf(itemCount)
+                    .divide(BigDecimal.valueOf(itemDifferenceCount), 4, RoundingMode.HALF_UP)
+                    .doubleValue();
+            accuracyRate = BigDecimal.valueOf(itemCount)
+                    .divide(BigDecimal.valueOf(finishCount)
+                            .subtract(BigDecimal.valueOf(itemDifferenceCount)), 4, RoundingMode.HALF_UP)
+                    .doubleValue();
+        }
+        detail.setDifferenceRate(differenceRate);
+        detail.setAccuracyRate(accuracyRate);
+        detail.setFinishCount(finishCount);
+        return detail;
+    }
+
+    @Override
+    public List<PDATaskStocktakingItemVO> pdaItemList(Long taskId) {
+        return taskStocktakingItemMapper.pdaList(taskId);
+    }
+
+    /**
      * 计算库位范围
      * 计算库位范围
      * @param data 库位集合
      * @param data 库位集合
      * @return
      * @return

+ 34 - 5
src/main/resources/mapper_xml/TaskStocktakingItemMapper.xml

@@ -4,12 +4,13 @@
 
 
     <select id="listByTaskStocktakingId" resultType="com.jsh.erp.datasource.vo.TaskStocktakingItemVO">
     <select id="listByTaskStocktakingId" resultType="com.jsh.erp.datasource.vo.TaskStocktakingItemVO">
         SELECT
         SELECT
-            m.`name` AS category_name,
+            tsi.id AS id,
+            mc.`name` AS category_name,
             m.`name` AS material_name,
             m.`name` AS material_name,
             m.system_sku AS system_sku,
             m.system_sku AS system_sku,
-            m.commodity_unit AS commodity_unit,
+            me.commodity_unit AS commodity_unit,
             me.production_date AS production_date,
             me.production_date AS production_date,
-            s.`name` AS supplier_name,
+            s.supplier AS supplier_name,
             me.bar_code AS bar_code,
             me.bar_code AS bar_code,
             me.inventory AS inventory,
             me.inventory AS inventory,
             d.`name` AS depot_name,
             d.`name` AS depot_name,
@@ -23,9 +24,37 @@
                 LEFT JOIN jsh_material m ON me.material_id = m.id
                 LEFT JOIN jsh_material m ON me.material_id = m.id
                 LEFT JOIN jsh_material_category mc ON mc.id = m.category_id
                 LEFT JOIN jsh_material_category mc ON mc.id = m.category_id
                 LEFT JOIN jsh_supplier s ON me.supplier_id = s.id
                 LEFT JOIN jsh_supplier s ON me.supplier_id = s.id
-                LEFT JOIN jsh_depot d AS me.depot_id = d.id
+                LEFT JOIN jsh_depot d ON me.depot_id = d.id
         WHERE
         WHERE
-            tsi.task_stocktaking_id = #{taskStocktakingId}
+            tsi.delete_flag = 0
+            AND tsi.task_stocktaking_id = #{taskStocktakingId}
+        ORDER BY
+            tsi.oper_time DESC,
+            tsi.id DESC
+    </select>
+
+    <select id="pdaList" resultType="com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO">
+        SELECT
+            me.position AS position,
+            mc.`name` AS category_name,
+            m.`name` AS material_name,
+            m.standard AS standard,
+            u.username AS creator_name,
+            tsi.oper_time AS oper_time,
+            me.inventory AS inventory,
+            tsi.new_inventory AS new_inventory
+        FROM
+            task_stocktaking_item tsi
+                LEFT JOIN jsh_material_extend me ON tsi.material_item_id = me.id
+                LEFT JOIN jsh_material m ON me.material_id = m.id
+                LEFT JOIN jsh_material_category mc ON m.category_id = mc.id
+                LEFT JOIN jsh_user u ON u.id = tsi.creator
+        WHERE
+            tsi.delete_flag = 0
+            AND tsi.task_stocktaking_id = #{taskId}
+        ORDER BY
+            tsi.oper_time DESC,
+            tsi.id DESC
     </select>
     </select>
 
 
 </mapper>
 </mapper>

+ 62 - 0
src/main/resources/mapper_xml/TaskStocktakingMapper.xml

@@ -2,4 +2,66 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jsh.erp.datasource.mappers.TaskStocktakingMapper">
 <mapper namespace="com.jsh.erp.datasource.mappers.TaskStocktakingMapper">
 
 
+    <select id="pdaList" resultType="com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO">
+        SELECT
+            ts.id AS id,
+            ts.task_name AS task_name,
+            ts.number AS number,
+            d.`name` AS depot_name,
+            ju.username AS create_name,
+            u.username AS creator_name,
+            ts.category_count AS category_count,
+            ts.material_count AS material_count,
+            ts.position_range AS position_range,
+            ts.create_time AS create_time,
+            ts.oper_time AS oper_time,
+            ou.username AS oper_name,
+            ts.task_status AS task_status
+        FROM
+            task_stocktaking ts
+                LEFT JOIN jsh_depot d ON ts.depot_id = d.id
+                LEFT JOIN jsh_user ju ON ts.create_by = ju.id
+                LEFT JOIN jsh_user ou ON ts.oper_by = ou.id
+                LEFT JOIN jsh_user u ON ts.creator = u.id
+        <where>
+            ts.delete_flag = 0
+            <if test="number != null and number != ''">
+                AND (ts.task_name LIKE CONCAT('%',#{taskName},'%') OR ts.number LIKE CONCAT('%',#{number},'%'))
+            </if>
+            <if test="taskStatus != null and taskStatus != 0">
+                AND ts.task_status = #{taskStatus}
+            </if>
+            ORDER BY
+                ts.create_time DESC,
+                ts.id DESC
+        </where>
+    </select>
+
+    <select id="listBy" resultType="com.jsh.erp.datasource.vo.TaskStocktakingVO">
+        SELECT
+            ts.id AS id,
+            ts.number AS number,
+            ts.task_name AS task_name,
+            ts.task_type AS task_type,
+            d.`name` AS depot_name,
+            ts.position_range AS position_range,
+            ju.username AS create_name,
+            ts.create_time AS create_time,
+            u.username AS creator_name,
+            ts.task_status AS task_status,
+            ts.oper_time AS oper_time
+        FROM
+            task_stocktaking ts
+                LEFT JOIN jsh_depot d ON ts.depot_id = d.id
+                LEFT JOIN jsh_user ju ON ts.create_by = ju.id
+                LEFT JOIN jsh_user ou ON ts.oper_by = ou.id
+                LEFT JOIN jsh_user u ON ts.creator = u.id
+        <where>
+            ts.delete_flag = 0
+        ORDER BY
+            ts.create_time DESC,
+            ts.id DESC
+        </where>
+    </select>
+
 </mapper>
 </mapper>