Selaa lähdekoodia

盘点计划 手动生成盘点任务

oyq28 1 vuosi sitten
vanhempi
commit
d93467d54d

+ 87 - 0
src/main/java/com/imcs/admin/business/controller/WPInventoryCountTaskController.java

@@ -0,0 +1,87 @@
+package com.imcs.admin.business.controller;
+
+import com.imcs.admin.common.Result;
+import com.imcs.admin.entity.WPInventoryCountPlan;
+import com.imcs.admin.entity.WPInventoryCountTask;
+import com.imcs.admin.business.service.WPInventoryCountTaskService;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+/**
+ * 盘点任务表(WPInventoryCountTask)表控制层
+ *
+ * @author wds
+ * @since 2024-06-04 13:01:01
+ */
+@RestController
+@RequestMapping("wPInventoryCountTask")
+public class WPInventoryCountTaskController {
+    /**
+     * 服务对象
+     */
+    @Resource
+    private WPInventoryCountTaskService wPInventoryCountTaskService;
+
+    /**
+     * 分页查询
+     *
+     * @param wPInventoryCountTask 筛选条件
+     * @param pageRequest      分页对象
+     * @return 查询结果
+     */
+    @GetMapping
+    public ResponseEntity<Page<WPInventoryCountTask>> queryByPage(WPInventoryCountTask wPInventoryCountTask, PageRequest pageRequest) {
+        return ResponseEntity.ok(this.wPInventoryCountTaskService.queryByPage(wPInventoryCountTask, pageRequest));
+    }
+
+    /**
+     * 通过主键查询单条数据
+     *
+     * @param id 主键
+     * @return 单条数据
+     */
+    @GetMapping("{id}")
+    public ResponseEntity<WPInventoryCountTask> queryById(@PathVariable("id") Long id) {
+        return ResponseEntity.ok(this.wPInventoryCountTaskService.queryById(id));
+    }
+
+    /**
+     * 新增数据
+     *
+     * @param plan 实体
+     * @return 新增结果
+     */
+    @PostMapping
+    public Result add(@RequestBody WPInventoryCountPlan plan) {
+        return Result.success(this.wPInventoryCountTaskService.insert(plan));
+    }
+
+    /**
+     * 编辑数据
+     *
+     * @param wPInventoryCountTask 实体
+     * @return 编辑结果
+     */
+    @PutMapping
+    public ResponseEntity<WPInventoryCountTask> edit(WPInventoryCountTask wPInventoryCountTask) {
+        return ResponseEntity.ok(this.wPInventoryCountTaskService.update(wPInventoryCountTask));
+    }
+
+    /**
+     * 删除数据
+     *
+     * @param id 主键
+     * @return 删除是否成功
+     */
+    @DeleteMapping
+    public ResponseEntity<Boolean> deleteById(Long id) {
+        return ResponseEntity.ok(this.wPInventoryCountTaskService.deleteById(id));
+    }
+
+
+}
+

+ 57 - 0
src/main/java/com/imcs/admin/business/service/WPInventoryCountTaskService.java

@@ -0,0 +1,57 @@
+package com.imcs.admin.business.service;
+
+import com.imcs.admin.entity.WPInventoryCountPlan;
+import com.imcs.admin.entity.WPInventoryCountTask;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+
+/**
+ * 盘点任务表(WPInventoryCountTask)表服务接口
+ *
+ * @author wds
+ * @since 2024-06-04 13:01:01
+ */
+public interface WPInventoryCountTaskService {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    WPInventoryCountTask queryById(Long id);
+
+    /**
+     * 分页查询
+     *
+     * @param wPInventoryCountTask 筛选条件
+     * @param pageRequest      分页对象
+     * @return 查询结果
+     */
+    Page<WPInventoryCountTask> queryByPage(WPInventoryCountTask wPInventoryCountTask, PageRequest pageRequest);
+
+    /**
+     * 新增数据
+     *
+     * @param plan 实例对象
+     * @return 实例对象
+     */
+    WPInventoryCountTask insert(WPInventoryCountPlan plan);
+
+    /**
+     * 修改数据
+     *
+     * @param wPInventoryCountTask 实例对象
+     * @return 实例对象
+     */
+    WPInventoryCountTask update(WPInventoryCountTask wPInventoryCountTask);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 是否成功
+     */
+    boolean deleteById(Long id);
+
+}

+ 8 - 1
src/main/java/com/imcs/admin/business/service/impl/BaseServiceImpl.java

@@ -12,6 +12,7 @@ import com.imcs.admin.entity.*;
 import com.imcs.admin.entity.assemble.PolicyInputResult;
 import com.imcs.admin.entity.query.PolicyInputQuery;
 import com.imcs.admin.util.GenerateSerial;
+import lombok.extern.java.Log;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.transaction.annotation.Transactional;
@@ -75,7 +76,13 @@ public class BaseServiceImpl {
      * @return
      */
     public Long getUserId(){
-        Long userId = SessionContext.getSession().getUserId();
+        Long userId=null;
+        try {
+             userId = SessionContext.getSession().getUserId();
+        }catch (Exception e){
+            userId=0l;
+        }
+
         return userId;
     }
 

+ 92 - 0
src/main/java/com/imcs/admin/business/service/impl/WPInventoryCountTaskServiceImpl.java

@@ -0,0 +1,92 @@
+package com.imcs.admin.business.service.impl;
+
+import com.imcs.admin.entity.WPInventoryCountPlan;
+import com.imcs.admin.entity.WPInventoryCountTask;
+import com.imcs.admin.business.dao.WPInventoryCountTaskDao;
+import com.imcs.admin.business.service.WPInventoryCountTaskService;
+import org.springframework.stereotype.Service;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+/**
+ * 盘点任务表(WPInventoryCountTask)表服务实现类
+ *
+ * @author wds
+ * @since 2024-06-04 13:01:01
+ */
+@Service("wPInventoryCountTaskService")
+public class WPInventoryCountTaskServiceImpl extends BaseServiceImpl implements WPInventoryCountTaskService {
+    @Resource
+    private WPInventoryCountTaskDao wPInventoryCountTaskDao;
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    @Override
+    public WPInventoryCountTask queryById(Long id) {
+        return this.wPInventoryCountTaskDao.queryById(id);
+    }
+
+    /**
+     * 分页查询
+     *
+     * @param wPInventoryCountTask 筛选条件
+     * @param pageRequest      分页对象
+     * @return 查询结果
+     */
+    @Override
+    public Page<WPInventoryCountTask> queryByPage(WPInventoryCountTask wPInventoryCountTask, PageRequest pageRequest) {
+        long total = this.wPInventoryCountTaskDao.count(wPInventoryCountTask);
+        return new PageImpl<>(this.wPInventoryCountTaskDao.queryAllByLimit(wPInventoryCountTask, pageRequest), pageRequest, total);
+    }
+
+    /**
+     * 新增数据
+     *
+     * @param plan 实例对象
+     * @return 实例对象
+     */
+    @Override
+    public WPInventoryCountTask insert(WPInventoryCountPlan plan) {
+
+
+        WPInventoryCountTask wpInventoryCountTask=new WPInventoryCountTask();
+        wpInventoryCountTask.setTaskCode(generateSerial.generateSerialNumber("planTaskCode"));
+        wpInventoryCountTask.setStatus(0);
+        wpInventoryCountTask.setWPInventoryCountPlanId(plan.getId());
+        wpInventoryCountTask.setCreatedAt(new Date());
+        wpInventoryCountTask.setCreatedBy(getUserId());
+        this.wPInventoryCountTaskDao.insert(wpInventoryCountTask);
+        return wpInventoryCountTask;
+    }
+
+    /**
+     * 修改数据
+     *
+     * @param wPInventoryCountTask 实例对象
+     * @return 实例对象
+     */
+    @Override
+    public WPInventoryCountTask update(WPInventoryCountTask wPInventoryCountTask) {
+        this.wPInventoryCountTaskDao.update(wPInventoryCountTask);
+        return this.queryById(wPInventoryCountTask.getId());
+    }
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 是否成功
+     */
+    @Override
+    public boolean deleteById(Long id) {
+        return this.wPInventoryCountTaskDao.deleteById(id) > 0;
+    }
+}

+ 4 - 4
src/main/java/com/imcs/admin/entity/WPInventoryCountTask.java

@@ -25,7 +25,7 @@ public class WPInventoryCountTask implements Serializable {
 /**
      * 盘点计划表ID
      */
-    private String wPInventoryCountPlanId;
+    private Long wPInventoryCountPlanId;
 /**
      * 盘点任务编码
      */
@@ -33,7 +33,7 @@ public class WPInventoryCountTask implements Serializable {
 /**
      * 任务状态
      */
-    private String status;
+    private Integer status;
 /**
      * 盘点开始时间
      */
@@ -53,7 +53,7 @@ public class WPInventoryCountTask implements Serializable {
 /**
      * 创建人
      */
-    private Integer createdBy;
+    private Long createdBy;
 /**
      * 修改时间
      */
@@ -61,7 +61,7 @@ public class WPInventoryCountTask implements Serializable {
 /**
      * 修改人
      */
-    private Integer updatedBy;
+    private Long updatedBy;
 
 
 }

+ 2 - 2
src/main/resources/mapper/WPInventoryCountTaskDao.xml

@@ -110,8 +110,8 @@
 
     <!--新增所有列-->
     <insert id="insert" keyProperty="id" useGeneratedKeys="true">
-        insert into w_p_inventory_count_task(w_p_inventory_count_plan_idtask_codestatusstart_timeend_timeplan_usercreated_atcreated_byupdated_atupdated_by)
-        values (#{wPInventoryCountPlanId}#{taskCode}#{status}#{startTime}#{endTime}#{planUser}#{createdAt}#{createdBy}#{updatedAt}#{updatedBy})
+        insert into w_p_inventory_count_task(w_p_inventory_count_plan_id,task_code,status,start_time,end_time,plan_user,created_at,created_by,updated_at,updated_by)
+        values (#{wPInventoryCountPlanId},#{taskCode},#{status},#{startTime},#{endTime},#{planUser},#{createdAt},#{createdBy},#{updatedAt},#{updatedBy})
     </insert>
 
     <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">

+ 57 - 6
src/main/resources/static/wms/plan/index.html

@@ -60,14 +60,15 @@
                 </el-table-column>
                 <el-table-column prop="planInput" label="盘点数据" :show-overflow-tooltip="true"></el-table-column>
                 <el-table-column prop="remarks" label="备注" :show-overflow-tooltip="true"></el-table-column>
-                <el-table-column label="操作" :show-overflow-tooltip="true" fixed="right"  width="380px">
+                <el-table-column label="操作" :show-overflow-tooltip="true" fixed="right"  width="430px">
                     <template #default="scope">
                         <!-- 这里放置操作按钮 -->
                         <div class="button-group">
-                            <el-button type="primary" @click="edit(scope.row)" icon="el-icon-edit" circle>编辑</el-button>
+                            <el-button type="primary" @click="edit(scope.row,'edit')" icon="el-icon-edit" circle>编辑</el-button>
                             <el-button type="primary" @click="view(scope.row)" icon="el-icon-edit" circle>查看</el-button>
                             <el-button type="danger" @click="orderDelete(scope.row)" icon="el-icon-delete" circle>删除</el-button>
-                            <el-button type="primary" @click="toDo(scope.row)" icon="el-icon-check" circle>启用</el-button>
+                            <el-button type="primary" @click="updateStatus(scope.row)" icon="el-icon-check" :disabled="scope.row.status === 1" circle>启用</el-button>
+                            <el-button type="primary" @click="savePlanTask(scope.row)" icon="el-icon-check"  circle>执行</el-button>
                         </div>
                     </template>
                 </el-table-column>
@@ -438,7 +439,12 @@
                 this.dialogVisible=true;
                 this.isViewMode=false;
                 this.clearForm();
-            },edit(row){
+            },edit(row,view){
+                if(view === 'view'){
+                    this.isViewMode=true;
+                }else{
+                    this.isViewMode=false;
+                }
                 this.dialogVisible=true;
                 axios.get('/wPInventoryCountPlan/'+row.id, {
                 })
@@ -463,8 +469,7 @@
 
 
             },view(row){
-                this.isViewMode=true;
-                this.edit(row);
+                this.edit(row,'view');
             },orderDelete(row){
                 this.$confirm('确认删除?')
                     .then(_ => {
@@ -490,6 +495,28 @@
                     })
                     .catch(_ => {});
 
+            },updateStatus(row){
+                this.$confirm('确认开启?')
+                    .then(_ => {
+                        axios.get('/wPInventoryCountPlan/updateStatus/'+row.id, {
+                        })
+                            .then(response => {
+                                console.log(response)
+                                if(response.data){
+                                    this.$message({
+                                        message: '开启成功',
+                                        type: "success"
+                                    })
+                                    this.queryClick();
+                                }
+                            })
+                            .catch(error => {
+                                // 处理错误
+                            });
+                        done();
+                    })
+                    .catch(_ => {});
+
             },handleSelectionChange(selection) {
                 this.selection = selection
             },addNewRow() {
@@ -789,6 +816,30 @@
                         // 处理错误
                     });
 
+            },savePlanTask(row){
+
+                this.$confirm('确认生成盘点任务吗?')
+                    .then(_ => {
+                        axios.post('/wPInventoryCountTask', {
+                            id:row.id
+                        })
+                            .then(response => {
+                                if(response.data.success){
+                                    this.$message({
+                                        message: '盘点任务生成成功',
+                                        type: 'success'
+                                    });
+                                }
+
+                            })
+                            .catch(error => {
+                                // 处理错误
+                            });
+                        done();
+                    })
+                    .catch(_ => {});
+
+
             }
         }