廖泽勇 1 mese fa
parent
commit
c04974fa83

+ 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);
+    }
+}

+ 54 - 13
src/main/java/com/jsh/erp/controller/pda/PdaController.java

@@ -1,27 +1,30 @@
 package com.jsh.erp.controller.pda;
 
+import cn.hutool.core.util.ObjectUtil;
 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.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.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.service.DepotHeadService;
-import com.jsh.erp.service.DepotItemService;
-import com.jsh.erp.service.SupplierService;
-import com.jsh.erp.service.TaskStocktakingService;
+import com.jsh.erp.service.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 
 @RestController
@@ -41,6 +44,12 @@ public class PdaController extends BaseController {
     @Resource
     private TaskStocktakingService taskStocktakingService;
 
+    @Resource
+    private TaskStocktakingItemService taskStocktakingItemService;
+
+    @Resource
+    private UserService userService;
+
     /**
      * 采购入库
      * @return
@@ -113,23 +122,55 @@ public class PdaController extends BaseController {
         return getDataTable(list);
     }
 
-//    @ApiModelProperty(value = "盘点任务详情-商品列表")
-//    @GetMapping("/taskStocktakingItemList/{taskId}")
-//    public TableDataInfo taskStocktakingItemList(@PathVariable("taskId") Long taskId){
-//        startPage();
-//        return getDataTable();
-//    }
+    @ApiModelProperty(value = "盘点任务详情-商品列表")
+    @GetMapping("/taskStocktakingItemList/{taskId}")
+    public TableDataInfo taskStocktakingItemList(@PathVariable("taskId") Long taskId){
+        startPage();
+        List<PDATaskStocktakingItemVO> list = taskStocktakingService.pdaItemList(taskId);
+        return getDataTable(list);
+    }
 
-    @ApiModelProperty("盘点任务详情")
+    @ApiOperation("盘点任务详情")
     @GetMapping("/taskStocktakingDetail/{taskId}")
-    public AjaxResult taskStocktakingDetail(@PathVariable("taskId") Long 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("用于返回字段说明")
+    @ApiOperation("订单-用于返回字段说明")
     @GetMapping("test")
     public AjaxResult test(PDADepotItemVO pdaDepotItemVO) {
         return AjaxResult.success();
     }
 
+    @ApiOperation("盘点-用于字段返回说明")
+    @GetMapping("taskTest")
+    public AjaxResult taskTest(PDATaskStocktakingVO pdaTaskStocktakingVO){
+        return AjaxResult.success();
+    }
+
 }

+ 13 - 2
src/main/java/com/jsh/erp/controller/stocktaking/StocktakingController.java

@@ -6,6 +6,7 @@ import com.jsh.erp.base.BaseController;
 import com.jsh.erp.base.TableDataInfo;
 import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
 import com.jsh.erp.datasource.dto.TaskStocktakingItemDTO;
+import com.jsh.erp.datasource.entities.TaskStocktaking;
 import com.jsh.erp.datasource.entities.TaskStocktakingItem;
 import com.jsh.erp.datasource.entities.User;
 import com.jsh.erp.datasource.vo.SpinnerVO;
@@ -20,6 +21,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.Arrays;
 import java.util.List;
 
 @RestController
@@ -63,7 +65,7 @@ public class StocktakingController extends BaseController {
      * @param id
      * @return
      */
-    @ApiModelProperty("任务详情")
+    @ApiOperation("任务详情")
     @GetMapping("/detail/{id}")
     public AjaxResult detail(@PathVariable("id") Long id) throws Exception{
         return AjaxResult.success(taskStocktakingService.detail(id));
@@ -74,7 +76,7 @@ public class StocktakingController extends BaseController {
      * @param taskStocktakingId 任务ID
      * @return
      */
-    @ApiModelProperty("任务详情-商品列表")
+    @ApiOperation("任务详情-商品列表")
     @GetMapping("/detailByItemList/{taskStocktakingId}")
     public AjaxResult detailByItemList(@PathVariable("taskStocktakingId") Long taskStocktakingId) {
         return AjaxResult.success(taskStocktakingService.listByTaskStocktakingId(taskStocktakingId));
@@ -111,4 +113,13 @@ public class StocktakingController extends BaseController {
         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 {
 
     @ApiModelProperty("商品扩展ID集合")
-    private List<Long> materialExtendIdList;
+    private List<String> materialExtendIdList;
 
 }

+ 4 - 0
src/main/java/com/jsh/erp/datasource/entities/Material.java

@@ -1,5 +1,7 @@
 package com.jsh.erp.datasource.entities;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
@@ -13,6 +15,7 @@ import java.util.List;
  */
 @Data
 @Accessors(chain = true)
+@TableName("jsh_material")
 public class Material {
 
     @ApiModelProperty("主键id")
@@ -84,6 +87,7 @@ public class Material {
     @ApiModelProperty("无动销提醒周期")
     private String movingPinReminderCycle;
 
+    @TableField(exist = false)
     private List<MaterialExtend> list;
 
 

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

@@ -1,5 +1,6 @@
 package com.jsh.erp.datasource.entities;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
@@ -26,6 +27,7 @@ public class TaskStocktaking {
     private Long createBy;
 
     @ApiModelProperty("创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date createTime;
 
     @ApiModelProperty("任务类型 1.全盘,2.抽盘")
@@ -43,7 +45,7 @@ public class TaskStocktaking {
     @ApiModelProperty("商品数")
     private int materialCount;
 
-    @ApiModelProperty("任务状态 0.未开始,1.进行中,2.已完成,3.已取消")
+    @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消")
     private Integer taskStatus;
 
     @ApiModelProperty("盘点范围")
@@ -56,6 +58,7 @@ public class TaskStocktaking {
     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;
 
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+@Data
+@TableName(value = "jsh_user")
 public class User {
     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;
 
 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.TaskStocktakingVO;
 import org.apache.ibatis.annotations.Param;
@@ -11,4 +12,6 @@ public interface TaskStocktakingItemMapper extends BaseMapperX<TaskStocktakingIt
 
     List<TaskStocktakingItemVO> listByTaskStocktakingId(@Param("taskStocktakingId") Long taskStocktakingId);
 
+    List<PDATaskStocktakingItemVO> pdaList(@Param("number") Long taskId);
+
 }

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

@@ -6,7 +6,7 @@ import lombok.Data;
 @Data
 public class PDATaskStocktakingDTO {
 
-    @ApiModelProperty("任务状态")
+    @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消")
     private Integer status;
 
     @ApiModelProperty("任务单号")

+ 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;
+
+}

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

@@ -41,7 +41,7 @@ public class PDATaskStocktakingVO {
     @ApiModelProperty("盘点时间")
     private Date operTime;
 
-    @ApiModelProperty("任务状态 0.未开始,1.进行中,2.已完成,3.已取消")
+    @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消")
     private Integer taskStatus;
 
 }

+ 3 - 0
src/main/java/com/jsh/erp/datasource/vo/TaskStocktakingVO.java

@@ -23,4 +23,7 @@ public class TaskStocktakingVO extends TaskStocktaking {
     @ApiModelProperty("仓库名称")
     private String depotName;
 
+    @ApiModelProperty("完成操作次数")
+    private Long finishCount;
+
 }

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

@@ -3,6 +3,7 @@ package com.jsh.erp.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
 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.TaskStocktakingVO;
@@ -45,5 +46,9 @@ public interface TaskStocktakingService extends IService<TaskStocktaking> {
      */
     List<PDATaskStocktakingVO> pdaList(String number , Integer taskStatus);
 
+    TaskStocktakingVO pdaDetail(Long id) throws Exception;
+
+    List<PDATaskStocktakingItemVO> pdaItemList(Long taskId);
+
 
 }

+ 29 - 7
src/main/java/com/jsh/erp/service/impl/TaskStocktakingServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
 import com.jsh.erp.datasource.entities.*;
 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.TaskStocktakingVO;
@@ -77,9 +78,10 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
                 taskStocktakingDTO.setCategoryCount(categoryIdList.size());
                 taskStocktakingDTO.setMaterialCount(materialExtendList.size());
             } else {
-                materialExtendList = materialExtendMapper.selectList(new LambdaQueryWrapper<MaterialExtend>().in(MaterialExtend::getId, taskStocktakingDTO.getMaterialExtendIdList()));
+                materialExtendList = materialExtendMapper.selectList(new LambdaQueryWrapper<MaterialExtend>().in(MaterialExtend::getBatchNumber, taskStocktakingDTO.getMaterialExtendIdList()));
                 collect = materialExtendList.stream().map(MaterialExtend::getPosition).collect(Collectors.toList());
-                List<Material> materialList = materialMapper.selectList(new LambdaQueryWrapperX<Material>().eq(Material::getId, materialExtendList.stream().map(MaterialExtend::getMaterialId)));
+                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());
@@ -90,15 +92,15 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
             User currentUser = userService.getCurrentUser();
             taskStocktakingDTO.setCreateBy(currentUser.getId());
             taskStocktakingDTO.setCreateTime(new Date());
-            taskStocktakingDTO.setTaskStatus(0);
+            taskStocktakingDTO.setTaskStatus(1);
             //生成任务
             this.save(taskStocktakingDTO);
             //生成任务明细
             List<TaskStocktakingItem> taskStocktakingItemList = new ArrayList<>();
-            taskStocktakingDTO.getMaterialExtendIdList().forEach(materialExtendId -> {
+            materialExtendList.forEach(item -> {
                 TaskStocktakingItem taskStocktakingItem = new TaskStocktakingItem();
                 taskStocktakingItem.setTaskStocktakingId(taskStocktakingDTO.getId());
-                taskStocktakingItem.setMaterialItemId(materialExtendId);
+                taskStocktakingItem.setMaterialItemId(item.getId());
                 taskStocktakingItemList.add(taskStocktakingItem);
             });
             taskStocktakingItemMapper.insertBatch(taskStocktakingItemList);
@@ -122,10 +124,14 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
         BeanUtils.copyProperties(one, taskStocktakingVO);
         //获取负责人名称
         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()));
-        taskStocktakingVO.setCreateByName(user1.getLoginName());
+        if (user1 != null) {
+            taskStocktakingVO.setCreateByName(user1.getLoginName());
+        }
         //获取仓库名称
         Depot depot = depotService.getDepot(one.getDepotId());
         taskStocktakingVO.setDepotName(depot.getName());
@@ -154,6 +160,22 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
         return taskStocktakingMapper.pdaList(number , taskStatus);
     }
 
+    @Override
+    public TaskStocktakingVO pdaDetail(Long id) throws Exception{
+        TaskStocktakingVO detail = detail(id);
+        //已操作数量
+        Long count = taskStocktakingItemMapper.selectCount(new LambdaQueryWrapper<TaskStocktakingItem>()
+                .eq(TaskStocktakingItem::getTaskStocktakingId, id)
+                .isNotNull(TaskStocktakingItem::getCreator));
+        detail.setFinishCount(count);
+        return detail;
+    }
+
+    @Override
+    public List<PDATaskStocktakingItemVO> pdaItemList(Long taskId) {
+        return taskStocktakingItemMapper.pdaList(taskId);
+    }
+
     /**
      * 计算库位范围
      * @param data 库位集合

+ 21 - 0
src/main/resources/mapper_xml/TaskStocktakingItemMapper.xml

@@ -30,4 +30,25 @@
             AND tsi.task_stocktaking_id = #{taskStocktakingId}
     </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}
+    </select>
+
 </mapper>