add:库存调拨

This commit is contained in:
zhangzq
2026-07-23 18:37:46 +08:00
parent 8298df2cf6
commit e48c784094
24 changed files with 2138 additions and 0 deletions

View File

@@ -0,0 +1,134 @@
package org.nl.wms.warehouse_manage.invtransfer.controller;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.base.ResponseData;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.warehouse_manage.invtransfer.service.IStIvtTransferService;
import org.nl.wms.warehouse_manage.invtransfer.service.dto.TransferCancelReq;
import org.nl.wms.warehouse_manage.invtransfer.service.dto.TransferDivReq;
import org.nl.wms.warehouse_manage.invtransfer.service.dto.TransferManualDivReq;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
@RestController
@RequestMapping("/api/invtransfer")
@Slf4j
public class StIvtTransferController {
@Resource
private IStIvtTransferService transferService;
@GetMapping
@Log("查询调拨单")
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page,
String[] source_stor_code, String[] target_stor_code,
String[] bill_status, String[] bill_type) {
return ResponseData.build(transferService.pageQuery(whereJson, page, source_stor_code, target_stor_code, bill_status, bill_type), HttpStatus.OK);
}
@GetMapping("/getCanuseIvt")
@Log("获取可用调拨库存")
public ResponseEntity<Object> getCanuseIvt(@RequestParam Map whereJson, PageQuery page) {
return ResponseData.build(transferService.getCanuseIvt(whereJson, page), HttpStatus.OK);
}
@GetMapping("/getStructIvt")
@Log("查询可分配调拨库存")
public ResponseEntity<Object> getStructIvt(@RequestParam Map whereJson) {
return ResponseData.build(transferService.queryAvailableInv(whereJson), HttpStatus.OK);
}
@PostMapping
@Log("新增调拨单")
public ResponseEntity<Object> insert(@RequestBody JSONObject whereJson) {
transferService.saveBill(whereJson);
return ResponseData.build(HttpStatus.CREATED);
}
@PutMapping
@Log("修改调拨单")
public ResponseEntity<Object> update(@RequestBody JSONObject whereJson) {
transferService.update(whereJson);
return ResponseData.build();
}
@DeleteMapping
@Log("删除调拨单")
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
transferService.deleteAll(ids);
return ResponseData.build();
}
@GetMapping("/getDtl")
@Log("查询调拨明细")
public ResponseEntity<Object> getDtl(@RequestParam Map whereJson) {
return ResponseData.build(transferService.getDtl(whereJson), HttpStatus.OK);
}
@GetMapping("/getDis")
@Log("查询调拨分配")
public ResponseEntity<Object> getDis(@RequestParam Map whereJson) {
return ResponseData.build(transferService.getDis(whereJson), HttpStatus.OK);
}
@PostMapping("/allDiv")
@Log("调拨单全部分配")
public ResponseEntity<Object> allDiv(@RequestBody TransferDivReq req) {
transferService.doDiv(req, false);
return ResponseData.build();
}
@PostMapping("/autoDiv")
@Log("调拨单按行分配")
public ResponseEntity<Object> autoDiv(@RequestBody TransferDivReq req) {
transferService.doDiv(req, true);
return ResponseData.build();
}
@PostMapping("/manualDiv")
@Log("调拨单手工分配")
public ResponseEntity<Object> manualDiv(@RequestBody TransferManualDivReq req) {
transferService.manualDiv(req);
return ResponseData.build();
}
@PostMapping("/allCancel")
@Log("调拨单全部取消")
public ResponseEntity<Object> allCancel(@RequestBody TransferCancelReq req) {
transferService.doCancel(req.getTransfer_id(), null);
return ResponseData.build();
}
@PostMapping("/autoCancel")
@Log("调拨单按行取消")
public ResponseEntity<Object> autoCancel(@RequestBody TransferDivReq req) {
transferService.doCancel(req.getTransfer_id(), req.getItransferdtl_id());
return ResponseData.build();
}
@PostMapping("/allSetPoint")
@Log("调拨单一键下发")
public ResponseEntity<Object> allSetPoint(@RequestBody JSONObject whereJson) {
transferService.allSetPoint(whereJson);
return ResponseData.build();
}
@PostMapping("/confirm")
@Log("调拨单强制确认")
public ResponseEntity<Object> confirm(@RequestBody JSONObject whereJson) {
transferService.confirm(whereJson);
return ResponseData.build();
}
@PostMapping("/getTask")
@Log("调拨单作业明细查询")
public ResponseEntity<Object> getTask(@RequestBody JSONObject whereJson) {
return ResponseData.build(transferService.getTask(whereJson), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,48 @@
package org.nl.wms.warehouse_manage.invtransfer.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.query.PageQuery;
import org.nl.wms.basedata_manage.service.dto.MdPbStoragevehicleextDto;
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransfer;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransferDis;
import org.nl.wms.warehouse_manage.invtransfer.service.dto.*;
import java.util.List;
import java.util.Map;
public interface IStIvtTransferService extends IService<StIvtTransfer> {
IPage<StIvtTransfer> pageQuery(Map whereJson, PageQuery page, String[] source_stor_code, String[] target_stor_code, String[] bill_status, String[] bill_type);
IPage<JSONObject> getCanuseIvt(Map whereJson, PageQuery page);
String saveBill(JSONObject whereJson);
void update(JSONObject whereJson);
void deleteAll(String[] ids);
List<StIvtTransferDtlDto> getDtl(Map whereJson);
List<StIvtTransferDisDto> getDis(Map whereJson);
List<MdPbStoragevehicleextDto> queryAvailableInv(Map whereJson);
void doDiv(TransferDivReq req, boolean singleDtl);
void manualDiv(TransferManualDivReq req);
void doCancel(String transferId, String itransferdtlId);
void allSetPoint(JSONObject whereJson);
void confirm(JSONObject whereJson);
List<StIvtTransferDisDto> getTask(Map whereJson);
void taskFinish(SchBaseTask task);
void disFinish(List<StIvtTransferDis> disList);
}

View File

@@ -0,0 +1,42 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dao;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@TableName("st_ivt_transfer")
public class StIvtTransfer implements Serializable {
private static final long serialVersionUID = 1L;
@TableId("transfer_id")
private String transfer_id;
private String bill_code;
private String bill_type;
private String biz_date;
private String source_stor_code;
private String source_stor_name;
private String source_sect_code;
private String source_sect_name;
private String target_stor_code;
private String target_stor_name;
private String target_sect_code;
private String target_sect_name;
private BigDecimal total_qty;
private BigDecimal total_weight;
private Integer detail_count;
private String bill_status;
private String remark;
private String update_name;
private String update_time;
@TableField("create__name")
private String create_name;
@TableField("create__time")
private String create_time;
}

View File

@@ -0,0 +1,39 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dao;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@TableName("st_ivt_transferdis")
public class StIvtTransferDis implements Serializable {
private static final long serialVersionUID = 1L;
@TableId("transferdis_id")
private String transferdis_id;
private String transfer_id;
private String itransferdtl_id;
private String seq_no;
private String source_sect_code;
@TableField("source_struct_code")
private String source_struct_code;
private String target_sect_code;
private String target_struct_code;
private String material_code;
private String pcsn;
private String bill_status;
private String task_id;
private String storagevehicle_code;
private String is_issued;
private String qty_unit_name;
private BigDecimal plan_qty;
private BigDecimal assign_qty;
private String point_code;
private Boolean hand_type;
}

View File

@@ -0,0 +1,32 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dao;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@TableName("st_ivt_transferdtl")
public class StIvtTransferDtl implements Serializable {
private static final long serialVersionUID = 1L;
@TableId("itransferdtl_id")
private String itransferdtl_id;
private String transfer_id;
private Integer seq_no;
private String bill_status;
private String qty_unit_name;
private BigDecimal plan_qty;
private BigDecimal assign_qty;
private String source_billdtl_id;
private String source_bill_type;
private String source_bill_code;
private String source_bill_table;
private String remark;
private String material_code;
private String pcsn;
private String source_load_port;
private String callback_strategy;
}

View File

@@ -0,0 +1,19 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransferDis;
import org.nl.wms.warehouse_manage.invtransfer.service.dto.StIvtTransferDisDto;
import java.util.List;
import java.util.Map;
@Mapper
public interface StIvtTransferDisMapper extends BaseMapper<StIvtTransferDis> {
List<StIvtTransferDisDto> queryTransferDisDtl(@Param("params") Map whereJson);
List<StIvtTransferDisDto> getBillTaskDtl(@Param("itransferdtl_id") String itransferdtl_id);
int batchSave(@Param("list") List<StIvtTransferDis> list);
}

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.wms.warehouse_manage.invtransfer.service.dao.mapper.StIvtTransferDisMapper">
<select id="queryTransferDisDtl" resultType="org.nl.wms.warehouse_manage.invtransfer.service.dto.StIvtTransferDisDto">
SELECT dis.*, mb.material_name, task.task_code, task.task_status,
src.struct_name AS source_struct_name,
tar.struct_name AS target_struct_name,
ext.create_time AS insert_time,
ext.qty
FROM st_ivt_transferdis dis
LEFT JOIN md_me_materialbase mb ON mb.material_code = dis.material_code
LEFT JOIN sch_base_task task ON task.task_id = dis.task_id
LEFT JOIN st_ivt_structattr src ON src.struct_code = dis.source_struct_code
LEFT JOIN st_ivt_structattr tar ON tar.struct_code = dis.target_struct_code
LEFT JOIN md_pb_groupplate ext
ON ext.storagevehicle_code = dis.storagevehicle_code
AND ext.material_code = dis.material_code
AND ext.pcsn = dis.pcsn
WHERE 1 = 1
<if test="params.itransferdtl_id != null and params.itransferdtl_id != ''">
AND dis.itransferdtl_id = #{params.itransferdtl_id}
</if>
<if test="params.bill_status != null and params.bill_status != ''">
AND dis.bill_status &lt;= #{params.bill_status}
</if>
ORDER BY dis.seq_no ASC
</select>
<select id="getBillTaskDtl" resultType="org.nl.wms.warehouse_manage.invtransfer.service.dto.StIvtTransferDisDto">
SELECT dis.*, mb.material_name, task.task_code, task.task_status,
src.struct_name AS source_struct_name,
tar.struct_name AS target_struct_name
FROM st_ivt_transferdis dis
LEFT JOIN md_me_materialbase mb ON mb.material_code = dis.material_code
LEFT JOIN sch_base_task task ON task.task_id = dis.task_id
LEFT JOIN st_ivt_structattr src ON src.struct_code = dis.source_struct_code
LEFT JOIN st_ivt_structattr tar ON tar.struct_code = dis.target_struct_code
WHERE dis.itransferdtl_id = #{itransferdtl_id}
ORDER BY dis.seq_no ASC
</select>
<insert id="batchSave" parameterType="list">
INSERT INTO st_ivt_transferdis (
transferdis_id,
transfer_id,
itransferdtl_id,
seq_no,
source_sect_code,
source_struct_code,
target_sect_code,
target_struct_code,
material_code,
pcsn,
bill_status,
task_id,
storagevehicle_code,
is_issued,
qty_unit_name,
plan_qty,
assign_qty,
point_code,
hand_type
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.transferdis_id},
#{item.transfer_id},
#{item.itransferdtl_id},
#{item.seq_no},
#{item.source_sect_code},
#{item.source_struct_code},
#{item.target_sect_code},
#{item.target_struct_code},
#{item.material_code},
#{item.pcsn},
#{item.bill_status},
#{item.task_id},
#{item.storagevehicle_code},
#{item.is_issued},
#{item.qty_unit_name},
#{item.plan_qty},
#{item.assign_qty},
#{item.point_code},
#{item.hand_type}
)
</foreach>
</insert>
</mapper>

View File

@@ -0,0 +1,16 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransferDtl;
import java.util.List;
import java.util.Set;
@Mapper
public interface StIvtTransferDtlMapper extends BaseMapper<StIvtTransferDtl> {
int batchInsert(@Param("list") List<StIvtTransferDtl> list);
int batchUpdateUnassignQty(@Param("dtlSet") Set<String> dtlSet, @Param("billStatus") String billStatus);
}

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.wms.warehouse_manage.invtransfer.service.dao.mapper.StIvtTransferDtlMapper">
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO st_ivt_transferdtl (
itransferdtl_id,
transfer_id,
seq_no,
bill_status,
qty_unit_name,
plan_qty,
assign_qty,
source_billdtl_id,
source_bill_type,
source_bill_code,
source_bill_table,
remark,
material_code,
pcsn,
source_load_port,
callback_strategy
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.itransferdtl_id},
#{item.transfer_id},
#{item.seq_no},
#{item.bill_status},
#{item.qty_unit_name},
#{item.plan_qty},
#{item.assign_qty},
#{item.source_billdtl_id},
#{item.source_bill_type},
#{item.source_bill_code},
#{item.source_bill_table},
#{item.remark},
#{item.material_code},
#{item.pcsn},
#{item.source_load_port},
#{item.callback_strategy}
)
</foreach>
</insert>
<update id="batchUpdateUnassignQty">
UPDATE st_ivt_transferdtl
SET assign_qty = 0,
bill_status = #{billStatus}
WHERE itransferdtl_id IN
<foreach collection="dtlSet" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>

View File

@@ -0,0 +1,18 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransfer;
import org.nl.wms.warehouse_manage.invtransfer.service.dto.StIvtTransferDtlDto;
import java.util.List;
import java.util.Map;
@Mapper
public interface StIvtTransferMapper extends BaseMapper<StIvtTransfer> {
IPage<StIvtTransfer> queryPage(IPage<StIvtTransfer> page, @Param("params") Map whereJson);
List<StIvtTransferDtlDto> getDtl(@Param("params") Map whereJson);
}

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.wms.warehouse_manage.invtransfer.service.dao.mapper.StIvtTransferMapper">
<select id="queryPage" resultType="org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransfer">
SELECT DISTINCT mst.* FROM st_ivt_transfer mst
LEFT JOIN st_ivt_transferdtl dtl ON mst.transfer_id = dtl.transfer_id
LEFT JOIN st_ivt_transferdis dis ON dtl.itransferdtl_id = dis.itransferdtl_id
<where>
1 = 1
<if test="params.bill_code != null and params.bill_code != ''">
AND mst.bill_code LIKE #{params.bill_code}
</if>
<if test="params.material_code != null and params.material_code != ''">
AND dtl.material_code = #{params.material_code}
</if>
<if test="params.sourceStorCodes != null">
AND mst.source_stor_code IN ${params.sourceStorCodes}
</if>
<if test="params.targetStorCodes != null">
AND mst.target_stor_code IN ${params.targetStorCodes}
</if>
<if test="params.billStatuses != null">
AND mst.bill_status IN ${params.billStatuses}
</if>
<if test="params.billTypes != null">
AND mst.bill_type IN ${params.billTypes}
</if>
<if test="params.pcsn != null and params.pcsn != ''">
AND dis.pcsn LIKE #{params.pcsn}
</if>
</where>
ORDER BY mst.transfer_id DESC
</select>
<select id="getDtl" resultType="org.nl.wms.warehouse_manage.invtransfer.service.dto.StIvtTransferDtlDto">
SELECT dtl.*, mb.material_name, mst.bill_code
FROM st_ivt_transferdtl dtl
LEFT JOIN md_me_materialbase mb ON mb.material_code = dtl.material_code
LEFT JOIN st_ivt_transfer mst ON mst.transfer_id = dtl.transfer_id
WHERE 1 = 1
<if test="params.transfer_id != null and params.transfer_id != ''">
AND mst.transfer_id = #{params.transfer_id}
</if>
<if test="params.bill_code != null and params.bill_code != ''">
AND mst.bill_code = #{params.bill_code}
</if>
<if test="params.bill_status != null and params.bill_status != ''">
AND dtl.bill_status &lt;= #{params.bill_status}
</if>
<if test="params.unassign_flag != null and params.unassign_flag != ''">
AND (dtl.plan_qty - IFNULL(dtl.assign_qty, 0)) &gt; 0
</if>
<if test="params.itransferdtl_id != null and params.itransferdtl_id != ''">
AND dtl.itransferdtl_id = #{params.itransferdtl_id}
</if>
ORDER BY dtl.seq_no ASC
</select>
</mapper>

View File

@@ -0,0 +1,15 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dto;
import lombok.Data;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransferDis;
@Data
public class StIvtTransferDisDto extends StIvtTransferDis {
private String material_name;
private String qty;
private String source_struct_name;
private String target_struct_name;
private String task_code;
private String task_status;
private String insert_time;
}

View File

@@ -0,0 +1,10 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dto;
import lombok.Data;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransferDtl;
@Data
public class StIvtTransferDtlDto extends StIvtTransferDtl {
private String material_name;
private String bill_code;
}

View File

@@ -0,0 +1,8 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dto;
import lombok.Data;
@Data
public class TransferCancelReq {
private String transfer_id;
}

View File

@@ -0,0 +1,10 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dto;
import lombok.Data;
@Data
public class TransferDivReq {
private String transfer_id;
private String itransferdtl_id;
private String source_sect_code;
}

View File

@@ -0,0 +1,33 @@
package org.nl.wms.warehouse_manage.invtransfer.service.dto;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class TransferManualDivReq {
private Row row;
private List<Item> rows;
@Data
public static class Row {
private String transfer_id;
private String itransferdtl_id;
private String target_sect_code;
}
@Data
public static class Item {
private String sect_id;
private String sect_name;
private String sect_code;
private String struct_id;
private String struct_name;
private String struct_code;
private String storagevehicle_code;
private String material_code;
private String pcsn;
private BigDecimal change_qty;
}
}

View File

@@ -0,0 +1,770 @@
package org.nl.wms.warehouse_manage.invtransfer.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.CodeUtil;
import org.nl.common.utils.IdUtil;
import org.nl.common.utils.MapOf;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.SpringContextHolder;
import org.nl.wms.basedata_manage.enums.BaseDataEnum;
import org.nl.wms.basedata_manage.service.IBsrealStorattrService;
import org.nl.wms.basedata_manage.service.ISectattrService;
import org.nl.wms.basedata_manage.service.IStructattrService;
import org.nl.wms.basedata_manage.service.dao.BsrealStorattr;
import org.nl.wms.basedata_manage.service.dao.Sectattr;
import org.nl.wms.basedata_manage.service.dao.Structattr;
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleextMapper;
import org.nl.wms.basedata_manage.service.dto.*;
import org.nl.wms.sch_manage.enums.TaskStatus;
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
import org.nl.wms.sch_manage.service.core.tasks.MoveTask;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.inventory.IStInventoryService;
import org.nl.wms.warehouse_manage.inventory.core.enums.InventoryChangeType;
import org.nl.wms.warehouse_manage.inventory.core.param.impl.AddInvParam;
import org.nl.wms.warehouse_manage.inventory.core.param.impl.OutDisParam;
import org.nl.wms.warehouse_manage.inventory.core.param.impl.OutDisReverseParam;
import org.nl.wms.warehouse_manage.inventory.core.param.impl.OutFinishParam;
import org.nl.wms.warehouse_manage.invtransfer.service.IStIvtTransferService;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransfer;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransferDis;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.StIvtTransferDtl;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.mapper.StIvtTransferDisMapper;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.mapper.StIvtTransferDtlMapper;
import org.nl.wms.warehouse_manage.invtransfer.service.dao.mapper.StIvtTransferMapper;
import org.nl.wms.warehouse_manage.invtransfer.service.dto.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class StIvtTransferServiceImpl extends ServiceImpl<StIvtTransferMapper, StIvtTransfer> implements IStIvtTransferService {
@Resource
private StIvtTransferMapper transferMapper;
@Resource
private StIvtTransferDtlMapper transferDtlMapper;
@Resource
private StIvtTransferDisMapper transferDisMapper;
@Resource
private IBsrealStorattrService storattrService;
@Resource
private IStructattrService structattrService;
@Resource
private ISectattrService sectattrService;
@Resource
private ISchBaseTaskService taskService;
@Autowired
private IStInventoryService inventoryService;
@Autowired
private MdPbStoragevehicleextMapper mdPbStoragevehicleextMapper;
@Override
public IPage<StIvtTransfer> pageQuery(Map whereJson, PageQuery page, String[] source_stor_code, String[] target_stor_code, String[] bill_status, String[] bill_type) {
HashMap<String, String> map = new HashMap<>(whereJson);
if (StrUtil.isNotEmpty(map.get("bill_code"))) {
map.put("bill_code", "%" + map.get("bill_code") + "%");
}
if (StrUtil.isNotEmpty(map.get("pcsn"))) {
map.put("pcsn", "%" + map.get("pcsn") + "%");
}
if (ObjectUtil.isNotEmpty(source_stor_code)) {
map.put("sourceStorCodes", wrapInClause(source_stor_code));
}
if (ObjectUtil.isNotEmpty(target_stor_code)) {
map.put("targetStorCodes", wrapInClause(target_stor_code));
}
if (ObjectUtil.isNotEmpty(bill_status)) {
map.put("billStatuses", wrapInClause(bill_status));
}
if (ObjectUtil.isNotEmpty(bill_type)) {
map.put("billTypes", wrapInClause(bill_type));
}
return transferMapper.queryPage(new Page<>(page.getPage() + 1, page.getSize()), map);
}
@Override
public IPage<JSONObject> getCanuseIvt(Map whereJson, PageQuery page) {
return mdPbStoragevehicleextMapper.getCanuseIvt(new Page<>(page.getPage() + 1, page.getSize()), whereJson);
}
@Override
@Transactional(rollbackFor = Exception.class)
public String saveBill(JSONObject form) {
JSONArray array = form.getJSONArray("tableData");
if (CollectionUtils.isEmpty(array)) {
throw new BadRequestException("请至少录入一条调拨明细");
}
final BsrealStorattr sourceStor = requireStor(form.getString("source_stor_code"));
final BsrealStorattr targetStor = requireStor(form.getString("target_stor_code"));
if (sourceStor.getStor_code().equals(targetStor.getStor_code())) {
throw new BadRequestException("调出仓库和调入仓库不能相同");
}
final String transferId = IdUtil.getStringId();
String now = DateUtil.now();
String nickName = SecurityUtils.getCurrentNickName();
BigDecimal totalQty = BigDecimal.ZERO;
List<StIvtTransferDtl> dtls = new ArrayList<>();
for (int i = 0; i < array.size(); i++) {
JSONObject row = array.getJSONObject(i);
BigDecimal planQty = firstBigDecimal(row, "plan_qty", "qty");
if (planQty == null || planQty.compareTo(BigDecimal.ZERO) <= 0) {
throw new BadRequestException(String.format("第%d行计划数量必须大于0", i + 1));
}
StIvtTransferDtl dtl = new StIvtTransferDtl();
dtl.setItransferdtl_id(IdUtil.getStringId());
dtl.setTransfer_id(transferId);
dtl.setSeq_no(i + 1);
dtl.setBill_status(IOSEnum.BILL_STATUS.code("生成"));
dtl.setQty_unit_name(row.getString("qty_unit_name"));
dtl.setPlan_qty(planQty);
dtl.setAssign_qty(BigDecimal.ZERO);
dtl.setSource_billdtl_id(row.getString("source_billdtl_id"));
dtl.setSource_bill_type(row.getString("source_bill_type"));
dtl.setSource_bill_code(row.getString("source_bill_code"));
dtl.setSource_bill_table(row.getString("source_bill_table"));
dtl.setRemark(row.getString("remark"));
dtl.setMaterial_code(row.getString("material_code"));
dtl.setPcsn(row.getString("pcsn"));
dtl.setSource_load_port(row.getString("source_load_port"));
dtl.setCallback_strategy(row.getString("callback_strategy"));
dtls.add(dtl);
totalQty = totalQty.add(planQty);
}
transferDtlMapper.batchInsert(dtls);
StIvtTransfer mst = new StIvtTransfer();
mst.setTransfer_id(transferId);
mst.setBill_code(CodeUtil.getNewCode("OUT_STORE_CODE"));
mst.setBill_type(form.getString("bill_type"));
mst.setBiz_date(form.getString("biz_date").substring(0, 10));
mst.setSource_stor_code(sourceStor.getStor_code());
mst.setSource_stor_name(sourceStor.getStor_name());
mst.setSource_sect_code(form.getString("source_sect_code"));
mst.setSource_sect_name(form.getString("source_sect_name"));
mst.setTarget_stor_code(targetStor.getStor_code());
mst.setTarget_stor_name(targetStor.getStor_name());
mst.setTarget_sect_code(form.getString("target_sect_code"));
mst.setTarget_sect_name(form.getString("target_sect_name"));
mst.setTotal_qty(totalQty);
mst.setDetail_count(dtls.size());
mst.setBill_status(IOSEnum.BILL_STATUS.code("生成"));
mst.setRemark(form.getString("remark"));
mst.setCreate_name(nickName);
mst.setCreate_time(now);
mst.setUpdate_name(nickName);
mst.setUpdate_time(now);
transferMapper.insert(mst);
return transferId;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(JSONObject form) {
String transferId = form.getString("transfer_id");
StIvtTransfer transfer = transferMapper.selectById(transferId);
if (transfer == null) {
throw new BadRequestException("未找到调拨单");
}
if (!IOSEnum.BILL_STATUS.code("生成").equals(transfer.getBill_status())) {
throw new BadRequestException("仅生成状态允许修改");
}
final BsrealStorattr sourceStor = requireStor(form.getString("source_stor_code"));
final BsrealStorattr targetStor = requireStor(form.getString("target_stor_code"));
JSONArray array = form.getJSONArray("tableData");
if (CollectionUtils.isEmpty(array)) {
throw new BadRequestException("请至少录入一条调拨明细");
}
transferDisMapper.delete(new LambdaQueryWrapper<StIvtTransferDis>().eq(StIvtTransferDis::getTransfer_id, transferId));
transferDtlMapper.delete(new LambdaQueryWrapper<StIvtTransferDtl>().eq(StIvtTransferDtl::getTransfer_id, transferId));
BigDecimal totalQty = BigDecimal.ZERO;
List<StIvtTransferDtl> dtls = new ArrayList<>();
for (int i = 0; i < array.size(); i++) {
JSONObject row = array.getJSONObject(i);
BigDecimal planQty = firstBigDecimal(row, "plan_qty", "qty");
if (planQty == null || planQty.compareTo(BigDecimal.ZERO) <= 0) {
throw new BadRequestException(String.format("第%d行计划数量必须大于0", i + 1));
}
StIvtTransferDtl dtl = new StIvtTransferDtl();
dtl.setItransferdtl_id(IdUtil.getStringId());
dtl.setTransfer_id(transferId);
dtl.setSeq_no(i + 1);
dtl.setBill_status(IOSEnum.BILL_STATUS.code("生成"));
dtl.setQty_unit_name(row.getString("qty_unit_name"));
dtl.setPlan_qty(planQty);
dtl.setAssign_qty(BigDecimal.ZERO);
dtl.setSource_billdtl_id(row.getString("source_billdtl_id"));
dtl.setSource_bill_type(row.getString("source_bill_type"));
dtl.setSource_bill_code(row.getString("source_bill_code"));
dtl.setSource_bill_table(row.getString("source_bill_table"));
dtl.setRemark(row.getString("remark"));
dtl.setMaterial_code(row.getString("material_code"));
dtl.setPcsn(row.getString("pcsn"));
dtl.setSource_load_port(row.getString("source_load_port"));
dtl.setCallback_strategy(row.getString("callback_strategy"));
dtls.add(dtl);
totalQty = totalQty.add(planQty);
}
transferDtlMapper.batchInsert(dtls);
transfer.setBill_type(form.getString("bill_type"));
transfer.setBiz_date(form.getString("biz_date"));
transfer.setSource_stor_code(sourceStor.getStor_code());
transfer.setSource_stor_name(sourceStor.getStor_name());
transfer.setSource_sect_code(form.getString("source_sect_code"));
transfer.setSource_sect_name(form.getString("source_sect_name"));
transfer.setTarget_stor_code(targetStor.getStor_code());
transfer.setTarget_stor_name(targetStor.getStor_name());
transfer.setTarget_sect_code(form.getString("target_sect_code"));
transfer.setTarget_sect_name(form.getString("target_sect_name"));
transfer.setTotal_qty(totalQty);
transfer.setDetail_count(dtls.size());
transfer.setRemark(form.getString("remark"));
transfer.setUpdate_name(SecurityUtils.getCurrentNickName());
transfer.setUpdate_time(DateUtil.now());
transferMapper.updateById(transfer);
}
@Override
public void deleteAll(String[] ids) {
for (String id : ids) {
transferMapper.deleteById(id);
transferDtlMapper.delete(new LambdaQueryWrapper<StIvtTransferDtl>().eq(StIvtTransferDtl::getTransfer_id, id));
transferDisMapper.delete(new LambdaQueryWrapper<StIvtTransferDis>().eq(StIvtTransferDis::getTransfer_id, id));
}
}
@Override
public List<StIvtTransferDtlDto> getDtl(Map whereJson) {
List<StIvtTransferDtlDto> list = transferMapper.getDtl(whereJson);
for (StIvtTransferDtlDto dto : list) {
BigDecimal plan = ObjectUtil.defaultIfNull(dto.getPlan_qty(), BigDecimal.ZERO);
BigDecimal assign = ObjectUtil.defaultIfNull(dto.getAssign_qty(), BigDecimal.ZERO);
dto.setAssign_qty(assign);
dto.setPlan_qty(plan);
}
return list;
}
@Override
public List<StIvtTransferDisDto> getDis(Map whereJson) {
return transferDisMapper.queryTransferDisDtl(whereJson);
}
@Override
public List<MdPbStoragevehicleextDto> queryAvailableInv(Map whereJson) {
return mdPbStoragevehicleextMapper.queryAvailableInv(whereJson);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void doDiv(TransferDivReq req, boolean singleDtl) {
StIvtTransfer mst = transferMapper.selectById(req.getTransfer_id());
if (mst == null) {
throw new BadRequestException("查不到调拨单信息");
}
List<StIvtTransferDtlDto> dtls = transferMapper.getDtl(new JSONObject(MapOf.of(
"transfer_id", req.getTransfer_id(),
"bill_status", IOSEnum.BILL_STATUS.code("分配完"),
"unassign_flag", BaseDataEnum.IS_YES_NOT.code(""),
"itransferdtl_id", req.getItransferdtl_id())));
if (CollectionUtils.isEmpty(dtls)) {
throw new BadRequestException("当前订单无可分配调拨明细");
}
List<String> flatWarehouse = getFlatWarehouseCodes();
for (StIvtTransferDtlDto dtl : dtls) {
BigDecimal unassignQty = dtl.getPlan_qty().subtract(ObjectUtil.defaultIfNull(dtl.getAssign_qty(), BigDecimal.ZERO));
if (unassignQty.compareTo(BigDecimal.ZERO) <= 0) {
continue;
}
StrategyMater mater = new StrategyMater();
mater.setQty(unassignQty);
mater.setPcsn(dtl.getPcsn());
mater.setMaterial_code(dtl.getMaterial_code());
List<StrategyMater> maters = Collections.singletonList(mater);
StrategyStructParam.StrategyStructParamBuilder outBuilder = StrategyStructParam.builder()
.sect_code(StrUtil.blankToDefault(req.getSource_sect_code(), mst.getSource_sect_code()))
.strategyMaters(maters);
if (singleDtl) {
outBuilder.inv_code(mst.getBill_code());
}
List<StrategyStructMaterialVO> sourceAllocations = structattrService.outBoundSectDiv(outBuilder.build());
int seqNo = getNextSeqNo(dtl.getItransferdtl_id());
BigDecimal totalAssign = BigDecimal.ZERO;
List<StIvtTransferDis> disList = new ArrayList<>();
List<OutDisParam> outParams = new ArrayList<>();
List<String> sourceStructs = new ArrayList<>();
List<String> targetStructs = new ArrayList<>();
for (StrategyStructMaterialVO source : sourceAllocations) {
if (unassignQty.compareTo(BigDecimal.ZERO) <= 0) {
break;
}
BigDecimal currentQty = source.getFrozen_qty();
StrategyStructParam inParam = StrategyStructParam.builder()
.sect_code(mst.getTarget_sect_code())
.storagevehicle_code(source.getStoragevehicle_code())
.strategyMaters(Collections.singletonList(mater))
.build();
List<Structattr> targetAttrs = structattrService.inBoundSectDiv(inParam);
if (CollectionUtils.isEmpty(targetAttrs)) {
throw new BadRequestException("调入库区无可用目标仓位");
}
Structattr target = targetAttrs.get(0);
StIvtTransferDis dis = new StIvtTransferDis();
dis.setTransferdis_id(IdUtil.getStringId());
dis.setTransfer_id(dtl.getTransfer_id());
dis.setItransferdtl_id(dtl.getItransferdtl_id());
dis.setSeq_no(String.valueOf(seqNo++));
dis.setSource_sect_code(source.getSect_code());
dis.setSource_struct_code(source.getStruct_code());
dis.setTarget_sect_code(target.getSect_code());
dis.setTarget_struct_code(target.getStruct_code());
dis.setMaterial_code(source.getMaterial_code());
dis.setPcsn(source.getPcsn());
dis.setBill_status(IOSEnum.INBILL_DIS_STATUS.code("生成"));
dis.setStoragevehicle_code(source.getStoragevehicle_code());
dis.setIs_issued(BaseDataEnum.IS_YES_NOT.code(""));
dis.setQty_unit_name(dtl.getQty_unit_name());
dis.setPlan_qty(currentQty);
dis.setAssign_qty(BigDecimal.ZERO);
dis.setHand_type(false);
if (StringUtils.isNotBlank(dtl.getSource_load_port())) {
dis.setPoint_code(dtl.getSource_load_port());
}
if (!flatWarehouse.contains(source.getSect_code()) || !flatWarehouse.contains(target.getSect_code())) {
dis.setBill_status(IOSEnum.INBILL_DIS_STATUS.code("未生成"));
}
disList.add(dis);
outParams.add(OutDisParam.builder()
.storagevehicleCode(source.getStoragevehicle_code())
.materialCode(source.getMaterial_code())
.pcsn(source.getPcsn())
.storCode(mst.getSource_stor_code())
.sectCode(source.getSect_code())
.structCode(source.getStruct_code())
.frozenQty(currentQty)
.build());
sourceStructs.add(source.getStruct_code());
targetStructs.add(target.getStruct_code());
totalAssign = totalAssign.add(currentQty);
unassignQty = unassignQty.subtract(currentQty);
}
lockSourceStructs(mst, sourceStructs);
lockTargetStructs(mst, targetStructs);
inventoryService.changeInventory(InventoryChangeType.OUT_DIS, outParams);
transferDisMapper.batchSave(disList);
StIvtTransferDtl entity = transferDtlMapper.selectById(dtl.getItransferdtl_id());
entity.setAssign_qty(ObjectUtil.defaultIfNull(entity.getAssign_qty(), BigDecimal.ZERO).add(totalAssign));
entity.setBill_status(unassignQty.compareTo(BigDecimal.ZERO) <= 0 ? IOSEnum.BILL_STATUS.code("分配完") : IOSEnum.BILL_STATUS.code("分配中"));
transferDtlMapper.updateById(entity);
}
updateBillStatus(req.getTransfer_id());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void manualDiv(TransferManualDivReq req) {
TransferManualDivReq.Row row = req.getRow();
StIvtTransfer mst = transferMapper.selectById(row.getTransfer_id());
if (mst == null) {
throw new BadRequestException("未找到调拨单");
}
StIvtTransferDtl dtl = transferDtlMapper.selectById(row.getItransferdtl_id());
if (dtl == null) {
throw new BadRequestException("未找到调拨明细");
}
BigDecimal unassignQty = dtl.getPlan_qty().subtract(ObjectUtil.defaultIfNull(dtl.getAssign_qty(), BigDecimal.ZERO));
if (unassignQty.compareTo(BigDecimal.ZERO) <= 0) {
throw new BadRequestException("当前明细已全部分配");
}
List<String> flatWarehouse = getFlatWarehouseCodes();
List<StIvtTransferDis> disList = new ArrayList<>();
List<OutDisParam> outParams = new ArrayList<>();
List<String> sourceStructs = new ArrayList<>();
List<String> targetStructs = new ArrayList<>();
BigDecimal totalAssign = BigDecimal.ZERO;
int seqNo = getNextSeqNo(dtl.getItransferdtl_id());
for (TransferManualDivReq.Item item : req.getRows()) {
Structattr target = pickManualTarget(mst.getTarget_sect_code(), item.getStoragevehicle_code());
StIvtTransferDis dis = new StIvtTransferDis();
dis.setTransferdis_id(IdUtil.getStringId());
dis.setTransfer_id(dtl.getTransfer_id());
dis.setItransferdtl_id(dtl.getItransferdtl_id());
dis.setSeq_no(String.valueOf(seqNo++));
dis.setSource_sect_code(item.getSect_code());
dis.setSource_struct_code(item.getStruct_code());
dis.setTarget_sect_code(target.getSect_code());
dis.setTarget_struct_code(target.getStruct_code());
dis.setMaterial_code(dtl.getMaterial_code());
dis.setPcsn(item.getPcsn());
dis.setBill_status(IOSEnum.INBILL_DIS_STATUS.code("生成"));
dis.setStoragevehicle_code(item.getStoragevehicle_code());
dis.setIs_issued(BaseDataEnum.IS_YES_NOT.code(""));
dis.setQty_unit_name(dtl.getQty_unit_name());
dis.setPlan_qty(item.getChange_qty());
dis.setAssign_qty(BigDecimal.ZERO);
dis.setHand_type(true);
if (!flatWarehouse.contains(item.getSect_code()) || !flatWarehouse.contains(target.getSect_code())) {
dis.setBill_status(IOSEnum.INBILL_DIS_STATUS.code("未生成"));
}
disList.add(dis);
outParams.add(OutDisParam.builder()
.storagevehicleCode(item.getStoragevehicle_code())
.materialCode(item.getMaterial_code())
.pcsn(item.getPcsn())
.storCode(mst.getSource_stor_code())
.sectCode(item.getSect_code())
.structCode(item.getStruct_code())
.frozenQty(item.getChange_qty())
.build());
sourceStructs.add(item.getStruct_code());
targetStructs.add(target.getStruct_code());
totalAssign = totalAssign.add(item.getChange_qty());
}
if (totalAssign.compareTo(BigDecimal.ZERO) <= 0) {
throw new BadRequestException("请先录入分配数量");
}
lockSourceStructs(mst, sourceStructs);
lockTargetStructs(mst, targetStructs);
inventoryService.changeInventory(InventoryChangeType.OUT_DIS, outParams);
transferDisMapper.batchSave(disList);
dtl.setAssign_qty(ObjectUtil.defaultIfNull(dtl.getAssign_qty(), BigDecimal.ZERO).add(totalAssign));
BigDecimal remain = dtl.getPlan_qty().subtract(dtl.getAssign_qty());
dtl.setBill_status(remain.compareTo(BigDecimal.ZERO) <= 0 ? IOSEnum.BILL_STATUS.code("分配完") : IOSEnum.BILL_STATUS.code("分配中"));
transferDtlMapper.updateById(dtl);
updateBillStatus(dtl.getTransfer_id());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void doCancel(String transferId, String itransferdtlId) {
LambdaQueryWrapper<StIvtTransferDis> wrapper = new LambdaQueryWrapper<StIvtTransferDis>()
.le(StIvtTransferDis::getBill_status, IOSEnum.INBILL_DIS_STATUS.code("生成"))
.eq(StIvtTransferDis::getIs_issued, BaseDataEnum.IS_YES_NOT.code(""))
.isNull(StIvtTransferDis::getTask_id)
.eq(StIvtTransferDis::getTransfer_id, transferId);
if (StrUtil.isNotBlank(itransferdtlId)) {
wrapper.eq(StIvtTransferDis::getItransferdtl_id, itransferdtlId);
}
List<StIvtTransferDis> list = transferDisMapper.selectList(wrapper);
if (CollectionUtils.isEmpty(list)) {
throw new BadRequestException("不存在可取消的调拨分配明细");
}
Set<String> dtlSet = new HashSet<>();
Set<String> sourceStructs = new HashSet<>();
Set<String> targetStructs = new HashSet<>();
List<OutDisReverseParam> reverseParams = new ArrayList<>();
for (StIvtTransferDis dis : list) {
dtlSet.add(dis.getItransferdtl_id());
sourceStructs.add(dis.getSource_struct_code());
targetStructs.add(dis.getTarget_struct_code());
reverseParams.add(OutDisReverseParam.builder()
.materialCode(dis.getMaterial_code())
.changeQty(dis.getPlan_qty())
.structCode(dis.getSource_struct_code())
.storagevehicleCode(dis.getStoragevehicle_code())
.build());
}
inventoryService.changeInventory(InventoryChangeType.OUT_DIS_REVERSE, reverseParams);
unlockStructs(sourceStructs);
unlockStructs(targetStructs);
transferDisMapper.deleteBatchIds(list.stream().map(StIvtTransferDis::getTransferdis_id).collect(Collectors.toList()));
rebuildDtlAssignQty(dtlSet);
updateBillStatus(transferId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void allSetPoint(JSONObject whereJson) {
String transferId = whereJson.getString("transfer_id");
List<StIvtTransferDis> list = transferDisMapper.selectList(new LambdaQueryWrapper<StIvtTransferDis>()
.eq(StIvtTransferDis::getTransfer_id, transferId)
.eq(StIvtTransferDis::getIs_issued, BaseDataEnum.IS_YES_NOT.code(""))
.eq(StIvtTransferDis::getBill_status, IOSEnum.INBILL_DIS_STATUS.code("未生成"))
.and(w -> w.isNotNull(StIvtTransferDis::getSource_struct_code).isNotNull(StIvtTransferDis::getTarget_struct_code)));
if (CollectionUtils.isEmpty(list)) {
throw new BadRequestException("当前没有可下发的调拨分配明细");
}
MoveTask moveTask = SpringContextHolder.getBean("MoveTask");
for (StIvtTransferDis dis : list) {
JSONObject taskForm = new JSONObject();
taskForm.put("config_code", "MoveTask");
taskForm.put("point_code1", dis.getSource_struct_code());
taskForm.put("point_code2", dis.getTarget_struct_code());
taskForm.put("vehicle_code", dis.getStoragevehicle_code());
String taskId = moveTask.create(taskForm);
dis.setTask_id(taskId);
dis.setIs_issued(BaseDataEnum.IS_YES_NOT.code(""));
dis.setBill_status(IOSEnum.INBILL_DIS_STATUS.code("生成"));
transferDisMapper.updateById(dis);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void confirm(JSONObject whereJson) {
String transferId = whereJson.getString("transfer_id");
StIvtTransfer mst = transferMapper.selectById(transferId);
if (mst == null) {
throw new BadRequestException("未查到相关调拨单");
}
if (!IOSEnum.BILL_STATUS.code("分配完").equals(mst.getBill_status())) {
throw new BadRequestException("主表状态必须为分配完");
}
List<StIvtTransferDis> list = transferDisMapper.selectList(new LambdaQueryWrapper<StIvtTransferDis>()
.eq(StIvtTransferDis::getTransfer_id, transferId)
.eq(StIvtTransferDis::getBill_status, IOSEnum.INBILL_DIS_STATUS.code("生成")));
if (CollectionUtils.isEmpty(list)) {
throw new BadRequestException("当前没有可确认的调拨分配明细");
}
List<String> taskIds = list.stream().map(StIvtTransferDis::getTask_id).filter(StringUtils::isNotBlank).collect(Collectors.toList());
boolean finish = true;
if (!CollectionUtils.isEmpty(taskIds)) {
finish = taskService.list(new QueryWrapper<SchBaseTask>().lambda()
.in(SchBaseTask::getTask_id, taskIds))
.stream().allMatch(row -> row.getTask_status().equals(TaskStatus.FINISHED.getCode()));
}
if (!finish) {
throw new BadRequestException("当前有未完成的任务不能强制确认");
}
finishTransfer(list, mst);
}
@Override
public List<StIvtTransferDisDto> getTask(Map whereJson) {
return transferDisMapper.getBillTaskDtl(MapUtil.getStr(whereJson, "itransferdtl_id"));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void taskFinish(SchBaseTask task) {
List<StIvtTransferDis> list = transferDisMapper.selectList(new LambdaQueryWrapper<StIvtTransferDis>()
.eq(StIvtTransferDis::getTask_id, task.getTask_id()));
if (CollectionUtils.isEmpty(list)) {
throw new BadRequestException("未找到任务对应的调拨分配明细");
}
disFinish(list);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void disFinish(List<StIvtTransferDis> disList) {
if (CollectionUtils.isEmpty(disList)) {
return;
}
String transferId = disList.get(0).getTransfer_id();
StIvtTransfer mst = transferMapper.selectById(transferId);
finishTransfer(disList, mst);
}
private void finishTransfer(List<StIvtTransferDis> disList, StIvtTransfer mst) {
List<OutFinishParam> outParams = new ArrayList<>();
List<AddInvParam> inParams = new ArrayList<>();
Set<String> dtlIds = new HashSet<>();
Set<String> sourceStructs = new HashSet<>();
Set<String> targetStructs = new HashSet<>();
for (StIvtTransferDis dis : disList) {
outParams.add(OutFinishParam.builder()
.storagevehicleCode(dis.getStoragevehicle_code())
.changeQty(dis.getPlan_qty())
.pcsn(dis.getPcsn())
.sectCode(dis.getSource_sect_code())
.structCode(dis.getSource_struct_code())
.storCode(mst.getSource_stor_code())
.materialCode(dis.getMaterial_code())
.build());
Structattr target = structattrService.getByCode(dis.getTarget_struct_code());
AddInvParam add = new AddInvParam();
add.setPcsn(dis.getPcsn());
add.setMaterialCode(dis.getMaterial_code());
add.setStoragevehicleCode(dis.getStoragevehicle_code());
add.setUnitName(dis.getQty_unit_name());
add.setQty(dis.getPlan_qty());
add.setStorCode(mst.getTarget_stor_code());
add.setSectCode(target.getSect_code());
add.setStructCode(target.getStruct_code());
inParams.add(add);
dis.setBill_status(IOSEnum.INBILL_DIS_STATUS.code("完成"));
dis.setAssign_qty(dis.getPlan_qty());
transferDisMapper.updateById(dis);
dtlIds.add(dis.getItransferdtl_id());
sourceStructs.add(dis.getSource_struct_code());
targetStructs.add(dis.getTarget_struct_code());
}
inventoryService.changeInventory(InventoryChangeType.OUT_FINS, outParams);
inventoryService.changeInventory(InventoryChangeType.ADD_INV, inParams);
unlockStructs(sourceStructs);
unlockStructs(targetStructs);
for (String dtlId : dtlIds) {
boolean hasRunning = transferDisMapper.selectCount(new LambdaQueryWrapper<StIvtTransferDis>()
.eq(StIvtTransferDis::getItransferdtl_id, dtlId)
.ne(StIvtTransferDis::getBill_status, IOSEnum.INBILL_DIS_STATUS.code("完成"))) > 0;
if (!hasRunning) {
StIvtTransferDtl dtl = transferDtlMapper.selectById(dtlId);
dtl.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
dtl.setAssign_qty(dtl.getPlan_qty());
transferDtlMapper.updateById(dtl);
}
}
boolean allDone = transferDtlMapper.selectCount(new LambdaQueryWrapper<StIvtTransferDtl>()
.eq(StIvtTransferDtl::getTransfer_id, mst.getTransfer_id())
.ne(StIvtTransferDtl::getBill_status, IOSEnum.BILL_STATUS.code("完成"))) == 0;
if (allDone) {
mst.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
mst.setUpdate_name(SecurityUtils.getCurrentNickName());
mst.setUpdate_time(DateUtil.now());
transferMapper.updateById(mst);
}
}
private Structattr pickManualTarget(String targetSectCode, String storagevehicleCode) {
StrategyStructParam param = StrategyStructParam.builder()
.sect_code(targetSectCode)
.storagevehicle_code(storagevehicleCode)
.strategyMaters(Collections.singletonList(new StrategyMater()))
.build();
List<Structattr> list = structattrService.inBoundSectDiv(param);
if (CollectionUtils.isEmpty(list)) {
throw new BadRequestException("调入库区无可用目标仓位");
}
return list.get(0);
}
private void rebuildDtlAssignQty(Set<String> dtlSet) {
for (String dtlId : dtlSet) {
BigDecimal assign = transferDisMapper.selectList(new LambdaQueryWrapper<StIvtTransferDis>()
.eq(StIvtTransferDis::getItransferdtl_id, dtlId))
.stream()
.map(StIvtTransferDis::getPlan_qty)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
StIvtTransferDtl dtl = transferDtlMapper.selectById(dtlId);
dtl.setAssign_qty(assign);
if (assign.compareTo(BigDecimal.ZERO) <= 0) {
dtl.setBill_status(IOSEnum.BILL_STATUS.code("生成"));
} else if (assign.compareTo(dtl.getPlan_qty()) >= 0) {
dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完"));
} else {
dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配中"));
}
transferDtlMapper.updateById(dtl);
}
}
private void updateBillStatus(String transferId) {
List<StIvtTransferDtl> dtls = transferDtlMapper.selectList(new LambdaQueryWrapper<StIvtTransferDtl>()
.eq(StIvtTransferDtl::getTransfer_id, transferId)
.select(StIvtTransferDtl::getBill_status));
long generateCount = dtls.stream().filter(d -> IOSEnum.BILL_STATUS.code("生成").equals(d.getBill_status())).count();
long completeCount = dtls.stream().filter(d -> IOSEnum.BILL_STATUS.code("分配完").equals(d.getBill_status())).count();
String status;
if (completeCount == dtls.size()) {
status = IOSEnum.BILL_STATUS.code("分配完");
} else if (generateCount == dtls.size()) {
status = IOSEnum.BILL_STATUS.code("生成");
} else {
status = IOSEnum.BILL_STATUS.code("分配中");
}
StIvtTransfer mst = new StIvtTransfer();
mst.setTransfer_id(transferId);
mst.setBill_status(status);
mst.setUpdate_name(SecurityUtils.getCurrentNickName());
mst.setUpdate_time(DateUtil.now());
transferMapper.updateById(mst);
}
private void lockSourceStructs(StIvtTransfer mst, Collection<String> structs) {
if (CollectionUtils.isEmpty(structs)) {
return;
}
structattrService.update(new LambdaUpdateWrapper<Structattr>()
.set(Structattr::getInv_id, mst.getTransfer_id())
.set(Structattr::getInv_code, mst.getBill_code())
.set(Structattr::getInv_type, mst.getBill_type())
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("出库锁"))
.in(Structattr::getStruct_code, structs));
}
private void lockTargetStructs(StIvtTransfer mst, Collection<String> structs) {
if (CollectionUtils.isEmpty(structs)) {
return;
}
structattrService.update(new LambdaUpdateWrapper<Structattr>()
.set(Structattr::getInv_id, mst.getTransfer_id())
.set(Structattr::getInv_code, mst.getBill_code())
.set(Structattr::getInv_type, mst.getBill_type())
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("入库锁"))
.in(Structattr::getStruct_code, structs));
}
private void unlockStructs(Collection<String> structs) {
if (CollectionUtils.isEmpty(structs)) {
return;
}
structattrService.update(new LambdaUpdateWrapper<Structattr>()
.set(Structattr::getInv_id, null)
.set(Structattr::getInv_code, null)
.set(Structattr::getInv_type, null)
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定"))
.in(Structattr::getStruct_code, structs));
}
private List<String> getFlatWarehouseCodes() {
return sectattrService.getSectType()
.getOrDefault(IOSEnum.ST_SECT_TYPE.code("平库"), Collections.emptyList())
.stream()
.map(Sectattr::getSect_code)
.collect(Collectors.toList());
}
private BsrealStorattr requireStor(String storCode) {
if (StringUtils.isBlank(storCode)) {
throw new BadRequestException("仓库编码不能为空");
}
BsrealStorattr stor = storattrService.findByCode(storCode);
if (stor == null) {
throw new BadRequestException("仓库编码不存在:" + storCode);
}
return stor;
}
private BigDecimal firstBigDecimal(JSONObject row, String... keys) {
for (String key : keys) {
BigDecimal val = row.getBigDecimal(key);
if (val != null) {
return val;
}
}
return null;
}
private String wrapInClause(String[] values) {
return Arrays.stream(values).map(v -> "'" + v + "'").collect(Collectors.joining(",", "(", ")"));
}
private int getNextSeqNo(String dtlId) {
List<StIvtTransferDis> list = transferDisMapper.selectList(new LambdaQueryWrapper<StIvtTransferDis>()
.eq(StIvtTransferDis::getItransferdtl_id, dtlId));
return list.stream().map(StIvtTransferDis::getSeq_no).filter(StringUtils::isNotBlank).mapToInt(Integer::parseInt).max().orElse(0) + 1;
}
}

View File

@@ -0,0 +1,90 @@
<template>
<el-dialog title="调拨单编辑" append-to-body fullscreen :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0 || crud.status.view > 0" @open="open" @close="close">
<el-row v-show="crud.status.cu > 0" :gutter="20">
<el-col :span="20" style="border: 1px solid white">
<span />
</el-col>
<el-col :span="4">
<span>
<el-button icon="el-icon-check" size="mini" :loading="crud.cu === 2" type="primary" @click="crud.submitCU">保存</el-button>
<el-button icon="el-icon-close" size="mini" type="info" @click="crud.cancelCU">关闭</el-button>
</span>
</el-col>
</el-row>
<el-form ref="form" style="border: 1px solid #cfe0df;margin-top: 10px;padding-top: 10px;" :inline="true" :model="form" :rules="rules" size="mini" label-width="100px" label-suffix=":">
<el-form-item label="单据号"><el-input v-model="form.bill_code" disabled placeholder="系统生成" clearable style="width: 210px" /></el-form-item>
<el-form-item label="调出仓库" prop="source_stor_code"><el-select v-model="form.source_stor_code" clearable placeholder="调出仓库" class="filter-item" style="width: 210px" :disabled="crud.status.view > 0" @change="sourceStorChange"><el-option v-for="item in storlist" :key="item.stor_code" :label="item.stor_name" :value="item.stor_code" /></el-select></el-form-item>
<el-form-item label="调出库区" prop="source_sect_code"><el-cascader v-model="sourceSectValue" :options="sourceSects" :props="{ checkStrictly: true }" clearable style="width:210px" @change="sourceSectChange" /></el-form-item>
<el-form-item label="调入仓库" prop="target_stor_code"><el-select v-model="form.target_stor_code" clearable placeholder="调入仓库" class="filter-item" style="width: 210px" :disabled="crud.status.view > 0" @change="targetStorChange"><el-option v-for="item in storlist" :key="item.stor_code + 't'" :label="item.stor_name" :value="item.stor_code" /></el-select></el-form-item>
<el-form-item label="调入库区" prop="target_sect_code"><el-cascader v-model="targetSectValue" :options="targetSects" :props="{ checkStrictly: true }" clearable style="width:210px" @change="targetSectChange" /></el-form-item>
<el-form-item label="业务类型" prop="bill_type"><el-select v-model="form.bill_type" clearable filterable size="mini" placeholder="业务类型" class="filter-item"><el-option v-for="item in dict.ST_INV_OUT_TYPE" :key="item.value" :label="item.label" :value="item.value" /></el-select></el-form-item>
<el-form-item label="单据状态"><el-select v-model="form.bill_status" disabled style="width: 210px"><el-option v-for="item in dict.io_bill_status" :key="item.id" :label="item.label" :value="item.value" /></el-select></el-form-item>
<el-form-item label="明细数"><el-input v-model="form.detail_count" size="mini" disabled style="width: 210px" /></el-form-item>
<el-form-item label="总数量"><el-input-number v-model="form.total_qty" :controls="false" :precision="3" :min="0" disabled style="width: 210px" /></el-form-item>
<el-form-item label="业务日期" prop="biz_date"><el-date-picker v-model="form.biz_date" type="date" placeholder="选择日期" style="width: 210px" value-format="yyyy-MM-dd" :disabled="crud.status.view > 0" /></el-form-item>
<el-form-item label="备注" prop="remark"><el-input v-model="form.remark" style="width: 380px;" rows="2" type="textarea" :disabled="crud.status.view > 0" /></el-form-item>
</el-form>
<div class="crud-opts2">
<span class="role-span">调拨明细</span>
<span v-if="crud.status.cu > 0" class="crud-opts-right2">
<!--左侧插槽-->
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
@click="queryDtl()"
>
调拨物料
</el-button>
</span>
</div>
<el-table ref="table" :data="form.tableData" style="width: 100%;" border :header-cell-style="{background:'#f5f7fa',color:'#606266'}">
<el-table-column type="index" label="序号" width="50" align="center" />
<el-table-column prop="material_code" label="物料编码" width="190" align="center" />
<el-table-column prop="material_name" label="物料名称" align="center" min-width="150px" show-overflow-tooltip />
<el-table-column prop="pcsn" label="批次号" width="150px" align="center" />
<el-table-column prop="plan_qty" label="调拨数量" width="150" align="center"><template slot-scope="scope"><el-input-number v-model="scope.row.plan_qty" :precision="3" :controls="false" :min="1" style="width: 120px" :disabled="crud.status.view > 0" /></template></el-table-column>
<el-table-column prop="qty_unit_name" label="单位" align="center" />
<el-table-column prop="remark" label="明细备注" align="center"><template slot-scope="scope"><el-input v-model="scope.row.remark" size="mini" :disabled="crud.status.view > 0" /></template></el-table-column>
<el-table-column v-if="crud.status.cu > 0" align="center" label="操作" width="120" fixed="right"><template slot-scope="scope"><el-button type="danger" class="filter-item" size="mini" icon="el-icon-delete" @click.native.prevent="deleteRow(scope.$index, form.tableData)" /></template></el-table-column>
</el-table>
<AddDtl :dialog-show.sync="dtlShow" :stor-id="sourceStorId" @tableChanged="tableChanged" />
</el-dialog>
</template>
<script>
import CRUD, { crud, form } from '@crud/crud'
import AddDtl from '@/views/wms/st/invtransfer/AddDtl'
import invtransfer from '@/views/wms/st/invtransfer/invtransfer'
import crudBsrealstorattr from '@/views/wms/basedata/bsrealstorattr/bsrealstorattr'
import crudSectattr from '@/views/wms/basedata/sectattr/sectattr'
const defaultForm = { bill_code: '', source_stor_code: '', source_stor_name: '', source_sect_code: '', source_sect_name: '', target_stor_code: '', target_stor_name: '', target_sect_code: '', target_sect_name: '', bill_status: '10', total_qty: '0', detail_count: '0', bill_type: '', remark: '', biz_date: new Date(), tableData: [] }
export default {
name: 'InvtransferAddDialog',
components: { AddDtl },
mixins: [crud(), form(defaultForm)],
dicts: ['io_bill_status', 'ST_INV_OUT_TYPE'],
data() { return { dtlShow: false, storlist: [], sourceSects: [], targetSects: [], sourceSectValue: [], targetSectValue: [], sourceStorId: null, targetStorId: null, rules: { source_stor_code: [{ required: true, message: '调出仓库不能为空', trigger: 'blur' }], source_sect_code: [{ required: true, message: '调出库区不能为空', trigger: 'blur' }], target_stor_code: [{ required: true, message: '调入仓库不能为空', trigger: 'blur' }], target_sect_code: [{ required: true, message: '调入库区不能为空', trigger: 'blur' }], bill_type: [{ required: true, message: '业务类型不能为空', trigger: 'blur' }], biz_date: [{ required: true, message: '业务日期不能为空', trigger: 'blur' }] } } },
methods: {
open() { crudBsrealstorattr.getStor().then(res => { this.storlist = res.data }); if (this.form.source_stor_code) { this.loadSourceSects() } if (this.form.target_stor_code) { this.loadTargetSects() } },
close() { this.$emit('AddChanged') },
[CRUD.HOOK.beforeSubmit]() { if (this.form.tableData.length === 0) { this.crud.notify('请至少选择一条明细', CRUD.NOTIFICATION_TYPE.INFO); return false } },
[CRUD.HOOK.afterToEdit]() { this.fillFormDtl() },
[CRUD.HOOK.afterToView]() { this.fillFormDtl() },
fillFormDtl() { invtransfer.getDtl({ transfer_id: this.form.transfer_id }).then(res => { this.form.tableData = res.data }) },
sourceStorChange(code) { const row = this.storlist.find(item => item.stor_code === code); this.form.source_stor_name = row ? row.stor_name : ''; this.sourceStorId = row ? row.stor_id : null; this.form.source_sect_code = ''; this.form.source_sect_name = ''; this.sourceSectValue = []; this.loadSourceSects() },
targetStorChange(code) { const row = this.storlist.find(item => item.stor_code === code); this.form.target_stor_name = row ? row.stor_name : ''; this.targetStorId = row ? row.stor_id : null; this.form.target_sect_code = ''; this.form.target_sect_name = ''; this.targetSectValue = []; this.loadTargetSects() },
loadSourceSects() { const row = this.storlist.find(item => item.stor_code === this.form.source_stor_code); if (!row) return; this.sourceStorId = row.stor_id; crudSectattr.getSectCode({ stor_code: row.stor_code }).then(res => { this.sourceSects = res.data }) },
loadTargetSects() { const row = this.storlist.find(item => item.stor_code === this.form.target_stor_code); if (!row) return; crudSectattr.getSectCode({ stor_code: row.stor_code }).then(res => { this.targetSects = res.data }) },
sourceSectChange(val) { this.form.source_sect_code = val.length ? val[val.length - 1] : ''; const node = this.findNode(this.sourceSects, this.form.source_sect_code); this.form.source_sect_name = node ? node.label : '' },
targetSectChange(val) { this.form.target_sect_code = val.length ? val[val.length - 1] : ''; const node = this.findNode(this.targetSects, this.form.target_sect_code); this.form.target_sect_name = node ? node.label : '' },
findNode(list, value) { for (const item of list) { if (item.value === value) return item; if (item.children) { const child = this.findNode(item.children, value); if (child) return child } } return null },
queryDtl() { if (!this.form.source_stor_code) { this.crud.notify('请选择调出仓库', CRUD.NOTIFICATION_TYPE.INFO); return } this.dtlShow = true },
tableChanged(rows) { rows.forEach(item => { item.plan_qty = item.qty; item.edit = true; this.form.tableData.push(item); this.form.total_qty = parseFloat(this.form.total_qty) + parseFloat(item.plan_qty) }); this.form.detail_count = this.form.tableData.length },
deleteRow(index, rows) { this.form.total_qty = parseFloat(this.form.total_qty) - parseFloat(rows[index].plan_qty); rows.splice(index, 1); this.form.detail_count = this.form.tableData.length }
}
}
</script>

View File

@@ -0,0 +1,48 @@
<template>
<el-dialog title="库存选择" append-to-body :visible.sync="dialogVisible" destroy-on-close width="1000px" @close="close" @open="open">
<el-form :inline="true" class="demo-form-inline" label-position="right" label-width="80px" label-suffix=":">
<el-form-item label="库区查询"><el-cascader v-model="storQuery" placeholder="库区" :options="sects" :props="{ checkStrictly: true }" @change="sectQueryChange" /></el-form-item>
<el-form-item label="货位编码"><el-input v-model="query.struct_code" clearable size="mini" placeholder="货位号模糊查询" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" /></el-form-item>
<el-form-item label="物料编码"><el-input v-model="query.material_code" clearable size="mini" placeholder="物料" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" /></el-form-item>
<el-form-item label="批次"><el-input v-model="query.pcsn" clearable size="mini" placeholder="批次" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" /></el-form-item>
<rrOperation />
</el-form>
<el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" border :header-cell-style="{background:'#f5f7fa',color:'#606266'}">
<el-table-column type="selection" width="55" />
<el-table-column prop="turnout_sect_name" label="库区名称" />
<el-table-column prop="turnout_struct_code" label="货位编码" />
<el-table-column prop="storagevehicle_code" label="载具编码" />
<el-table-column prop="material_code" label="物料编码" />
<el-table-column prop="material_name" label="物料名称" />
<el-table-column prop="pcsn" label="批次" />
<el-table-column prop="qty" label="数量" :formatter="crud.formatNum3" />
<el-table-column prop="frozen_qty" label="冻结数量" :formatter="crud.formatNum3" />
<el-table-column prop="qty_unit_name" label="单位" />
</el-table>
<pagination />
<span slot="footer" class="dialog-footer"><el-button @click="dialogVisible = false"> </el-button><el-button type="primary" @click="submit"> </el-button></span>
</el-dialog>
</template>
<script>
import CRUD, { header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
import crudSectattr from '@/views/wms/basedata/sectattr/sectattr'
export default {
name: 'InvtransferAddDtl',
components: { rrOperation, pagination },
cruds() { return CRUD({ title: '库存物料', optShow: { add: false, edit: false, del: false, reset: true, download: false }, url: 'api/invtransfer/getCanuseIvt', idField: 'struct_id', sort: 'storagevehicleext_id,desc' }) },
mixins: [presenter(), header()],
props: { dialogShow: { type: Boolean, default: false }, storId: { type: String } },
data() { return { sects: [], dialogVisible: false, storQuery: [], rows: [] } },
watch: { dialogShow: { handler(newValue) { this.dialogVisible = newValue } } },
methods: {
open() { this.crud.resetQuery(false); crudSectattr.getSect({ stor_id: this.storId }).then(res => { this.sects = res.data }); this.query.is_used = '1'; this.query.is_delete = '0'; this.query.stor_id = this.storId; this.crud.toQuery() },
sectQueryChange(val) { if (val.length === 1) { this.query.stor_id = val[0]; this.query.sect_id = '' } if (val.length === 0) { this.query.sect_id = ''; this.query.stor_id = '' } if (val.length === 2) { this.query.stor_id = val[0]; this.query.sect_id = val[1] } this.crud.toQuery() },
close() { this.sects = null; this.$emit('update:dialogShow', false) },
submit() { this.rows = this.$refs.table.selection; if (this.rows.length <= 0) { this.$message('请先勾选库存'); return } this.$emit('update:dialogShow', false); this.$emit('tableChanged', this.rows) }
}
}
</script>

View File

@@ -0,0 +1,47 @@
<template>
<el-dialog append-to-body :visible.sync="dialogVisible" destroy-on-close :show-close="false" fullscreen @close="close" @open="open">
<span slot="title" class="dialog-footer"><div class="crud-opts2"><span class="el-dialog__title2">调拨分配</span><span class="crud-opts-right2"><el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button></span></div></span>
<div class="crud-opts2"><span class="role-span">调拨明细</span><div class="crud-opts-form"><el-form ref="form" :inline="true" :model="form" size="mini"><el-form-item label="调出库区"><el-cascader placeholder="请选择" :options="sects" :props="{ checkStrictly: true }" clearable @change="sectQueryChange" /></el-form-item></el-form></div><span class="crud-opts-right2"><el-button class="filter-item" :loading="loadingAlldiv" type="primary" size="mini" @click="allDiv">全部分配</el-button><el-button class="filter-item" :loading="loadingAlldiv" type="primary" size="mini" @click="allCancel">全部取消</el-button><el-button class="filter-item" :loading="loadingAlldiv" type="primary" size="mini" :disabled="button1" @click="oneDiv">按行分配</el-button><el-button class="filter-item" type="primary" :loading="loadingAlldiv" size="mini" :disabled="button2" @click="oneCancel">按行取消</el-button><el-button class="filter-item" type="primary" size="mini" :loading="loadingAlldiv" :disabled="button3" @click="openStructIvt">手工分配</el-button><el-button class="filter-item" type="warning" :loading="loadingSetAllPoint" size="mini" @click="allSetPointAllDtl">一键下发</el-button></span></div>
<el-card class="box-card" shadow="never" :body-style="{padding:'0'}"><el-table ref="table" :data="tableDtl" style="width: 100%;" max-height="300" border :cell-style="cellStyle" :highlight-current-row="true" :header-cell-style="{background:'#f5f7fa',color:'#606266'}" @current-change="handleDtlCurrentChange"><el-table-column prop="bill_status" label="状态" align="center" width="110px" :formatter="bill_statusFormat" /><el-table-column show-overflow-tooltip prop="material_code" label="物料编码" align="center" /><el-table-column show-overflow-tooltip prop="material_name" label="物料名称" align="center" /><el-table-column show-overflow-tooltip prop="pcsn" label="批次号" align="center" width="140px" /><el-table-column show-overflow-tooltip prop="plan_qty" label="调拨数量" :formatter="crud.formatNum3" align="center" /><el-table-column show-overflow-tooltip prop="assign_qty" label="已分配数量" :formatter="crud.formatNum3" align="center" /><el-table-column show-overflow-tooltip label="未分配数量" :formatter="unassignFormat" align="center" /></el-table></el-card>
<div class="crud-opts2"><span class="role-span">分配明细</span></div>
<el-card class="box-card" shadow="never" :body-style="{padding:'0'}"><el-table ref="table2" :data="tabledis" style="width: 100%;" max-height="400" size="mini" border :highlight-current-row="true" :header-cell-style="{background:'#f5f7fa',color:'#606266'}"><el-table-column type="index" label="序号" width="50" align="center" /><el-table-column prop="bill_status" label="状态" align="center" width="110px"><template slot-scope="scope"><el-select v-model="scope.row.bill_status" :disabled="true"><el-option v-for="item in dict.work_status" :key="item.value" :label="item.label" :value="item.value" /></el-select></template></el-table-column><el-table-column prop="material_code" label="物料编码" width="150px" /><el-table-column prop="material_name" label="物料名称" width="170px" /><el-table-column prop="storagevehicle_code" label="载具号" width="150px" /><el-table-column prop="pcsn" label="批次号" width="150px" /><el-table-column prop="plan_qty" label="调拨数量" :formatter="crud.formatNum3" align="center" width="120px" /><el-table-column prop="source_sect_code" width="120px" label="调出库区" align="center" /><el-table-column prop="source_struct_code" width="150px" label="调出仓位" align="center" /><el-table-column prop="target_sect_code" width="120px" label="调入库区" align="center" /><el-table-column prop="target_struct_code" width="150px" label="调入仓位" align="center" /><el-table-column prop="task_code" width="150px" label="任务号" align="center" /><el-table-column align="center" label="操作" width="120" fixed="right"><template slot-scope="scope"><el-button :disabled="tabledisabled(scope.row)" type="danger" class="filter-item" size="mini" icon="el-icon-delete" @click.native.prevent="deleteRow(scope.row)" /></template></el-table-column></el-table></el-card>
<StructIvt :dialog-show.sync="structshow" :stor-code="sourceStorCode" :open-array="openParam" :rowmst="openRow" @StructIvtClosed="queryTableDtl" />
</el-dialog>
</template>
<script>
import CRUD, { crud } from '@crud/crud'
import invtransfer from '@/views/wms/st/invtransfer/invtransfer'
import StructIvt from '@/views/wms/st/invtransfer/StructIvt'
import crudSectattr from '@/views/wms/basedata/sectattr/sectattr'
import crudBsrealstorattr from '@/views/wms/basedata/bsrealstorattr/bsrealstorattr'
export default {
name: 'InvtransferDivDialog',
components: { StructIvt },
mixins: [crud()],
dicts: ['io_bill_status', 'work_status'],
props: { dialogShow: { type: Boolean, default: false }, rowmst: { type: Object }, openArray: { type: Array, default: () => [] } },
data() { return { dialogVisible: false, loadingAlldiv: false, loadingSetAllPoint: false, structshow: false, button1: true, button2: true, button3: true, tableDtl: [], openParam: [], mstrow: {}, openRow: {}, tabledis: [], currentRow: {}, form: { }, sects: [], sourceStorCode: null } },
watch: { dialogShow: { handler(newValue) { this.dialogVisible = newValue } }, openArray: { handler(newValue) { this.tableDtl = newValue } }, rowmst: { handler(newValue) { this.mstrow = { ...newValue } } } },
methods: {
open() { crudBsrealstorattr.getStor().then(res => { const stor = res.data.find(item => item.stor_code === this.mstrow.source_stor_code); this.sourceStorCode = stor ? stor.stor_code : null; if (this.sourceStorCode) { crudSectattr.getSectCode({ stor_code: this.sourceStorCode }).then(resp => { this.sects = resp.data }) } }) },
close() { this.tabledis = []; this.$emit('DivChanged'); this.$emit('update:dialogShow', false) },
bill_statusFormat(row) { return this.dict.label.io_bill_status[row.bill_status] },
unassignFormat(row) { return (parseFloat(row.plan_qty || 0) - parseFloat(row.assign_qty || 0)).toFixed(3) },
openStructIvt() { this.loadingAlldiv = true; const query = { ...this.currentRow, source_sect_code: this.mstrow.source_sect_code, target_sect_code: this.mstrow.target_sect_code }; invtransfer.getStructIvt(query).then(res => { this.openParam = res.data; this.structshow = true; this.openRow = query; this.loadingAlldiv = false }).catch(() => { this.loadingAlldiv = false }) },
sectQueryChange(val) { this.mstrow.source_sect_code = val.length ? val[val.length - 1] : '' },
tabledisabled(row) { return !((row.bill_status === '00' || row.bill_status === '01') && row.is_issued === '0') },
deleteRow(row) { invtransfer.autoCancel({ transfer_id: row.transfer_id, itransferdtl_id: row.itransferdtl_id }).then(() => { this.queryTableDtl() }) },
handleDtlCurrentChange(current) { if (current !== null) { this.currentRow = current; if (current.bill_status === '10') { this.button1 = false; this.button2 = true; this.button3 = false } else if (current.bill_status === '30' || current.bill_status === '40') { this.button1 = true; this.button2 = false; this.button3 = true } this.queryTableDdis(current.itransferdtl_id) } else { this.button1 = true; this.button2 = true; this.button3 = true; this.currentRow = {}; this.tabledis = [] } },
allDiv() { this.loadingAlldiv = true; invtransfer.allDiv({ transfer_id: this.mstrow.transfer_id, source_sect_code: this.mstrow.source_sect_code }).then(() => { this.crud.notify('分配成功!', CRUD.NOTIFICATION_TYPE.INFO); this.queryTableDtl(); this.loadingAlldiv = false }).catch(() => { this.loadingAlldiv = false }) },
oneDiv() { this.loadingAlldiv = true; invtransfer.allDivOne({ transfer_id: this.mstrow.transfer_id, itransferdtl_id: this.currentRow.itransferdtl_id, source_sect_code: this.mstrow.source_sect_code }).then(() => { this.queryTableDtl(); this.loadingAlldiv = false }).catch(() => { this.loadingAlldiv = false }) },
allCancel() { this.loadingAlldiv = true; invtransfer.allCancel({ transfer_id: this.mstrow.transfer_id }).then(() => { this.queryTableDtl(); this.loadingAlldiv = false }).catch(() => { this.loadingAlldiv = false }) },
oneCancel() { this.loadingAlldiv = true; invtransfer.autoCancel({ transfer_id: this.mstrow.transfer_id, itransferdtl_id: this.currentRow.itransferdtl_id }).then(() => { this.queryTableDtl(); this.loadingAlldiv = false }).catch(() => { this.loadingAlldiv = false }) },
allSetPointAllDtl() { this.loadingSetAllPoint = true; invtransfer.allSetPoint({ transfer_id: this.mstrow.transfer_id }).then(() => { this.queryTableDdis(this.currentRow.itransferdtl_id); this.crud.notify('下发成功!', CRUD.NOTIFICATION_TYPE.INFO); this.loadingSetAllPoint = false }).catch(() => { this.loadingSetAllPoint = false }) },
queryTableDtl() { invtransfer.getDtl({ transfer_id: this.mstrow.transfer_id }).then(res => { this.tableDtl = res.data }) },
queryTableDdis(itransferdtl_id) { invtransfer.getDis({ itransferdtl_id, bill_status: '01' }).then(res => { this.tabledis = res.data }).catch(() => { this.tabledis = [] }) },
cellStyle({ row, column }) { if (column.property === 'assign_qty' && parseFloat(row.assign_qty || 0) > parseFloat(row.plan_qty || 0)) { return 'background: yellow' } }
}
}
</script>

View File

@@ -0,0 +1,301 @@
<template>
<el-dialog
append-to-body
:visible.sync="dialogVisible"
destroy-on-close
:show-close="false"
fullscreen
@close="close"
@open="open"
>
<span slot="title" class="dialog-footer">
<div class="crud-opts2">
<span class="el-dialog__title2">手工库存分配</span>
<span class="crud-opts-right2">
<!--左侧插槽-->
<slot name="left" />
<el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
<el-button slot="left" v-loading.fullscreen.lock="fullscreenLoading" type="primary" @click="submit">保存</el-button>
</span>
</div>
</span>
<div class="crud-opts2">
<span class="role-span" style="width: 100px">可分配库存</span>
<div class="crud-opts-form">
<el-form ref="form2" :inline="true" :model="queryrow" size="mini">
<el-form-item label="物料" prop="material_code">
<el-input-number
v-model="queryrow.material_code"
:controls="false"
:precision="3"
:min="0"
disabled
/>
</el-form-item>
<el-form-item label="调出库区" prop="source_sect_code">
<el-input
v-model="queryrow.source_sect_code"
:controls="false"
disabled
/>
</el-form-item>
<el-form-item label="调入库区" prop="target_sect_code">
<el-input
v-model="queryrow.target_sect_code"
:controls="false"
disabled
/>
</el-form-item>
<el-form-item label="待分配" prop="unassign_qty">
<el-input-number
v-model="queryrow.unassign_qty"
:controls="false"
:precision="3"
:min="0"
disabled
/>
</el-form-item>
<el-form-item label="已分配" prop="assign_qty">
<el-input-number
v-model="queryrow.assign_qty"
:controls="false"
:precision="3"
:min="0"
disabled
/>
</el-form-item>
<el-form-item label="手动分配库区" prop="sect_id">
<el-cascader
placeholder="请选择"
:options="sects"
:props="{ checkStrictly: true }"
clearable
@change="sectQueryChange"
/>
</el-form-item>
<el-form-item label="货位编码" prop="struct_code">
<el-input
v-model="queryrow.struct_code"
clearable
style="width: 220px"
size="mini"
placeholder="货位编码"
prefix-icon="el-icon-search"
class="filter-item"
/>
</el-form-item>
<el-form-item label="批次号" prop="pcsn">
<el-input
v-model="queryrow.pcsn"
clearable
style="width: 220px"
size="mini"
:disabled="pscnDisabled"
placeholder="批次号"
prefix-icon="el-icon-search"
class="filter-item"
/>
</el-form-item>
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="queryStruct">搜索</el-button>
</el-form>
</div>
</div>
<!--表格渲染-->
<el-table
ref="table"
:data="tableDtl"
style="width: 100%;"
max-height="500"
border
:highlight-current-row="true"
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
>
<el-table-column type="index" label="序号" width="50" align="center" />
<el-table-column show-overflow-tooltip prop="sect_name" label="库区" align="center" />
<el-table-column show-overflow-tooltip prop="struct_code" label="仓位" align="center" />
<el-table-column show-overflow-tooltip prop="storagevehicle_code" label="托盘编码" align="center" width="250px" />
<el-table-column show-overflow-tooltip prop="material_name" label="物料名称" align="center" />
<el-table-column show-overflow-tooltip sortable prop="pcsn" label="批次号" align="center" width="150px" />
<el-table-column show-overflow-tooltip sortable prop="qty" label="库存数量" align="center" width="150px" />
<el-table-column show-overflow-tooltip sortable prop="frozen_qty" label="冻结数量" align="center" width="150px" />
<el-table-column show-overflow-tooltip prop="qty" label="分配数量" :formatter="crud.formatNum3" align="center">
<template slot-scope="scope">
<el-input-number v-model="scope.row.change_qty" :max="scope.row.qty" clearable style="width: 100px" />
</template>
</el-table-column>
<el-table-column align="center" label="操作" width="160" fixed="right">
<template scope="scope">
<el-button v-show="!scope.row.edit" type="primary" class="filter-item" size="mini" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button v-show="scope.row.edit" type="success" class="filter-item" size="mini" icon="el-icon-check" @click="handleEdit(scope.$index, scope.row)">完成</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
</template>
<script>
import CRUD, { header } from '@crud/crud'
import checkoutbill from '@/views/wms/st/outbill/checkoutbill'
import crudSectattr from '@/views/wms/basedata/sectattr/sectattr'
export default {
name: 'StructIvt',
components: { },
mixins: [header()],
props: {
dialogShow: {
type: Boolean,
default: false
},
rowmst: {
type: Object
},
openArray: {
type: Array,
default: () => { return [] }
},
storId: {
type: String,
default: null
}
},
data() {
return {
dialogVisible: false,
dialogVisible2: false,
fullscreenLoading: false,
pscnDisabled: false,
goal_unassign_qty: 0,
queryrow: {},
sects: [],
tableDtl: []
}
},
watch: {
dialogShow: {
handler(newValue, oldValue) {
this.dialogVisible = newValue
}
},
openArray: {
handler(newValue, oldValue) {
this.tableDtl = newValue
}
},
rowmst: {
handler(newValue, oldValue) {
this.queryrow = newValue
if (this.queryrow.pcsn !== '' && this.queryrow.pcsn !== null) {
this.pscnDisabled = true
}
this.goal_unassign_qty = JSON.parse(JSON.stringify(this.queryrow.unassign_qty))
}
}
},
methods: {
open() {
crudSectattr.getSect({ 'stor_id': this.storId }).then(res => {
this.sects = res.data
})
this.query.source_bill_code = this.queryrow.source_bill_code
this.query.material_id = this.queryrow.material_id
},
queryStruct() {
this.queryrow.unassign_qty = parseFloat(this.queryrow.unassign_qty) + parseFloat(this.queryrow.assign_qty)
this.queryrow.assign_qty = 0
checkoutbill.getStructIvt(this.queryrow).then(res => {
this.tableDtl = res.data
})
},
sectQueryChange(val) {
if (val.length === 1) {
this.queryrow.stor_id = val[0]
this.queryrow.sect_id = ''
}
if (val.length === 0) {
this.queryrow.sect_id = ''
this.queryrow.stor_id = ''
}
if (val.length === 2) {
this.queryrow.stor_id = val[0]
this.queryrow.sect_id = val[1]
}
},
handleEdit(index, row) {
// 判断是否可以关闭编辑状态
if (row.edit === undefined) {
this.$set(row, 'edit', false)
}
row.edit = !row.edit
if (row.edit) {
this.queryrow.unassign_qty = parseFloat(this.queryrow.unassign_qty) - parseFloat(row.change_qty)
this.queryrow.assign_qty = parseFloat(this.queryrow.assign_qty) + parseFloat(row.change_qty)
} else {
this.queryrow.assign_qty = parseFloat(this.queryrow.assign_qty) - parseFloat(row.change_qty)
// 如果待分配重量等于0则 明细重量 - 已分配重量
if (parseInt(this.queryrow.unassign_qty) === 0) {
this.queryrow.unassign_qty = parseFloat(this.goal_unassign_qty) - parseFloat(this.queryrow.assign_qty)
} else {
this.queryrow.unassign_qty = parseFloat(this.queryrow.unassign_qty) + parseFloat(row.change_qty)
}
if (this.queryrow.unassign_qty > this.goal_unassign_qty) {
this.queryrow.unassign_qty = JSON.parse(JSON.stringify(this.goal_unassign_qty))
}
// 如果已分配汇总量 > 明细重量 则待分配重量为0
if (this.queryrow.assign_qty > this.goal_unassign_qty) {
this.queryrow.unassign_qty = parseFloat('0')
}
}
this.tableDtl.splice(index, 1, row) // 通过splice 替换数据 触发视图更新
},
close() {
this.$emit('update:dialogShow', false)
this.$emit('StructIvtClosed')
},
submit() {
if (parseFloat(this.queryrow.assign_qty) === 0) {
this.crud.notify('请分配后再提交', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
if (parseFloat(this.queryrow.unassign_qty) === 0) {
const rows = []
this.tableDtl.forEach((item) => {
if (item.edit) {
rows.push(item)
}
})
this.fullscreenLoading = true
checkoutbill.manualDiv({ 'row': this.queryrow, 'rows': rows }).then(res => {
this.$emit('update:dialogShow', false)
this.$emit('StructIvtClosed')
this.fullscreenLoading = false
}).catch(() => {
this.fullscreenLoading = false
})
} else {
this.$confirm('未分配重量不为0,是否继续提交?')
.then(_ => {
const rows = []
this.tableDtl.forEach((item) => {
if (item.edit) {
rows.push(item)
}
})
this.fullscreenLoading = true
checkoutbill.manualDiv({ 'row': this.queryrow, 'rows': rows }).then(res => {
this.$emit('update:dialogShow', false)
this.$emit('StructIvtClosed')
this.fullscreenLoading = false
}).catch(() => {
this.fullscreenLoading = false
})
})
.catch(_ => {
})
}
}
}
}
</script>

View File

@@ -0,0 +1,45 @@
<template>
<el-dialog append-to-body title="调拨单详情" :visible.sync="dialogVisible" destroy-on-close fullscreen @close="close" @open="open">
<el-form ref="form" style="border: 1px solid #cfe0df;margin-top: 10px;padding-top: 10px;" :inline="true" :model="form" size="mini" label-width="100px" label-suffix=":">
<el-form-item label="单据号"><el-input v-model="form.bill_code" disabled style="width: 210px" /></el-form-item>
<el-form-item label="调出仓库"><el-input v-model="form.source_stor_name" disabled style="width: 210px" /></el-form-item>
<el-form-item label="调出库区"><el-input v-model="form.source_sect_name" disabled style="width: 210px" /></el-form-item>
<el-form-item label="调入仓库"><el-input v-model="form.target_stor_name" disabled style="width: 210px" /></el-form-item>
<el-form-item label="调入库区"><el-input v-model="form.target_sect_name" disabled style="width: 210px" /></el-form-item>
<el-form-item label="业务类型"><el-select v-model="form.bill_type" disabled><el-option v-for="item in dict.ST_INV_OUT_TYPE" :key="item.value" :label="item.label" :value="item.value" /></el-select></el-form-item>
<el-form-item label="单据状态"><el-select v-model="form.bill_status" disabled><el-option v-for="item in dict.io_bill_status" :key="item.id" :label="item.label" :value="item.value" /></el-select></el-form-item>
<el-form-item label="明细数"><el-input v-model="form.detail_count" disabled style="width: 210px" /></el-form-item>
<el-form-item label="总数量"><el-input-number v-model="form.total_qty" :controls="false" :precision="3" :min="0" disabled style="width: 210px" /></el-form-item>
<el-form-item label="业务日期"><el-date-picker v-model="form.biz_date" type="date" style="width: 210px" value-format="yyyy-MM-dd" :disabled="true" /></el-form-item>
<el-form-item label="备注"><el-input v-model="form.remark" style="width: 380px;" rows="2" type="textarea" :disabled="true" /></el-form-item>
</el-form>
<div class="crud-opts2"><span class="role-span2">调拨明细</span></div>
<el-card class="box-card" shadow="never" :body-style="{padding:'0'}"><el-table ref="table" :data="tableDtl" style="width: 100%;" max-height="300" size="mini" border :highlight-current-row="true" :header-cell-style="{background:'#f5f7fa',color:'#606266'}" @current-change="handleDtlCurrentChange"><el-table-column type="index" label="序号" width="55" align="center" /><el-table-column :formatter="bill_statusFormat" prop="bill_status" label="状态" /><el-table-column min-width="140" show-overflow-tooltip prop="material_code" label="物料编码" align="center" /><el-table-column min-width="120" show-overflow-tooltip prop="material_name" label="物料名称" align="center" /><el-table-column prop="pcsn" label="批次号" width="150px" align="center" show-overflow-tooltip /><el-table-column prop="plan_qty" :formatter="crud.formatNum3" label="数量" align="center" /><el-table-column prop="assign_qty" :formatter="crud.formatNum3" label="已分配数量" align="center" width="100px" /><el-table-column :formatter="unassignFormat" label="未分配数量" align="center" width="100px" /><el-table-column prop="qty_unit_name" label="单位" align="center" /><el-table-column show-overflow-tooltip prop="remark" label="明细备注" align="center" /></el-table></el-card>
<div class="crud-opts2"><span class="role-span">作业明细</span></div>
<el-card class="box-card" shadow="never" :body-style="{padding:'0'}"><el-table ref="table2" :data="tabledis" style="width: 100%;" max-height="300" size="mini" border :highlight-current-row="true" :header-cell-style="{background:'#f5f7fa',color:'#606266'}"><el-table-column min-width="120" show-overflow-tooltip prop="material_code" label="物料编码" align="center" /><el-table-column min-width="120" show-overflow-tooltip prop="material_name" label="物料名称" align="center" /><el-table-column prop="storagevehicle_code" label="载具号" width="150px" /><el-table-column prop="pcsn" label="批次号" align="center" show-overflow-tooltip /><el-table-column prop="plan_qty" :formatter="crud.formatNum3" label="数量" align="center" /><el-table-column prop="source_struct_code" label="调出仓位" align="center" show-overflow-tooltip /><el-table-column prop="target_struct_code" label="调入仓位" align="center" show-overflow-tooltip /><el-table-column prop="task_code" label="任务号" align="center" /><el-table-column prop="task_status" label="状态" align="center" width="110px" :formatter="work_statusFormat" /></el-table></el-card>
</el-dialog>
</template>
<script>
import { crud } from '@crud/crud'
import invtransfer from '@/views/wms/st/invtransfer/invtransfer'
export default {
name: 'InvtransferViewDialog',
mixins: [crud()],
dicts: ['io_bill_status', 'work_status', 'ST_INV_OUT_TYPE'],
props: { dialogShow: { type: Boolean, default: false }, rowmst: { type: Object } },
data() { return { dialogVisible: false, tableDtl: [], tabledis: [], currentdtl: null, form: {} } },
watch: { dialogShow: { handler(newValue) { this.dialogVisible = newValue } }, rowmst: { handler(newValue) { this.form = newValue } } },
methods: {
open() { this.queryTableDtl() },
close() { this.$emit('update:dialogShow', false); this.currentdtl = null; this.tableDtl = []; this.tabledis = []; this.$emit('AddChanged') },
bill_statusFormat(row) { return this.dict.label.io_bill_status[row.bill_status] },
work_statusFormat(row) { return this.dict.label.work_status[row.bill_status] || row.bill_status },
unassignFormat(row) { return (parseFloat(row.plan_qty || 0) - parseFloat(row.assign_qty || 0)).toFixed(3) },
handleDtlCurrentChange(current) { if (current !== null) { this.currentdtl = current; this.queryTableDdis() } else { this.tabledis = []; this.currentdtl = {} } },
queryTableDtl() { invtransfer.getDtl({ transfer_id: this.form.transfer_id }).then(res => { this.tableDtl = res.data }) },
queryTableDdis() { if (this.currentdtl !== null) { invtransfer.getTask({ itransferdtl_id: this.currentdtl.itransferdtl_id }).then(res => { this.tabledis = res.data }).catch(() => { this.tabledis = [] }) } }
}
}
</script>

View File

@@ -0,0 +1,153 @@
<template>
<div class="app-container">
<div class="head-container">
<div v-if="crud.props.searchToggle">
<el-form :inline="true" class="demo-form-inline" label-position="right" label-width="90px" label-suffix=":">
<el-form-item label="模糊查询">
<el-input v-model="query.bill_code" size="mini" clearable placeholder="单据号" @keyup.enter.native="crud.toQuery" />
</el-form-item>
<el-form-item label="物料编码">
<el-input v-model="query.material_code" size="mini" clearable placeholder="物料编码" @keyup.enter.native="crud.toQuery" />
</el-form-item>
<el-form-item label="调出仓库">
<el-select v-model="query.source_stor_code" multiple collapse-tags clearable size="mini" placeholder="全部" class="filter-item">
<el-option v-for="item in storlist" :key="item.stor_code" :label="item.stor_name" :value="item.stor_code" />
</el-select>
</el-form-item>
<el-form-item label="调入仓库">
<el-select v-model="query.target_stor_code" multiple collapse-tags clearable size="mini" placeholder="全部" class="filter-item">
<el-option v-for="item in storlist" :key="item.stor_code + 't'" :label="item.stor_name" :value="item.stor_code" />
</el-select>
</el-form-item>
<el-form-item label="单据状态">
<el-select v-model="query.bill_status" multiple collapse-tags clearable size="mini" placeholder="单据状态" class="filter-item">
<el-option v-for="item in dict.io_bill_status" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="业务类型">
<el-select v-model="query.bill_type" multiple collapse-tags clearable filterable size="mini" placeholder="业务类型" class="filter-item">
<el-option v-for="item in dict.ST_INV_OUT_TYPE" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="批次号">
<el-input v-model="query.pcsn" size="mini" clearable placeholder="批次号" @keyup.enter.native="crud.toQuery" />
</el-form-item>
<rrOperation />
</el-form>
</div>
<crudOperation :permission="permission">
<el-button slot="right" class="filter-item" type="success" icon="el-icon-position" size="mini" :disabled="dis_flag" @click="divOpen">分配</el-button>
<el-button slot="right" class="filter-item" type="warning" :loading="loadingConfirm" :disabled="confirm_flag" icon="el-icon-check" size="mini" @click="confirm">强制确认</el-button>
</crudOperation>
<el-table ref="table" v-loading="crud.loading" size="mini" :data="crud.data" style="width: 100%" :highlight-current-row="true" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange" @select="handleSelectionChange" @select-all="onSelectAll">
<el-table-column label="操作" width="250" align="center" fixed="right">
<template slot-scope="scope">
<udOperation :data="scope.row" style="display: inline" :permission="permission" :disabled-edit="canUd(scope.row)" :disabled-dle="canUd(scope.row)" />
</template>
</el-table-column>
<el-table-column :selectable="checkboxT" type="selection" width="55" />
<el-table-column show-overflow-tooltip prop="bill_code" width="130" label="单据号">
<template slot-scope="scope">
<el-link type="warning" @click="toView(scope.$index, scope.row)">{{ scope.row.bill_code }}</el-link>
</template>
</el-table-column>
<el-table-column show-overflow-tooltip :formatter="stateFormat" width="80" prop="bill_status" label="单据状态" />
<el-table-column show-overflow-tooltip prop="source_stor_name" label="调出仓库" width="120" />
<el-table-column show-overflow-tooltip prop="target_stor_name" label="调入仓库" width="120" />
<el-table-column show-overflow-tooltip prop="source_sect_name" label="调出库区" width="120" />
<el-table-column show-overflow-tooltip prop="target_sect_name" label="调入库区" width="120" />
<el-table-column show-overflow-tooltip prop="bill_type" :formatter="bill_typeFormat" label="业务类型" />
<el-table-column show-overflow-tooltip width="100" prop="biz_date" label="业务日期" />
<el-table-column show-overflow-tooltip label="明细数" align="center" prop="detail_count" width="60" />
<el-table-column show-overflow-tooltip label="计划数量" align="center" prop="total_qty" width="100" :formatter="crud.formatNum3" />
<el-table-column show-overflow-tooltip label="备注" align="center" prop="remark" width="180" />
<el-table-column show-overflow-tooltip label="创建人" align="center" prop="create_name" />
<el-table-column show-overflow-tooltip label="创建时间" align="center" prop="create_time" width="140" />
<el-table-column show-overflow-tooltip label="修改人" align="center" prop="update_optname" />
<el-table-column show-overflow-tooltip label="修改时间" align="center" prop="update_time" width="140" />
</el-table>
<pagination />
</div>
<AddDialog @AddChanged="querytable" />
<ViewDialog :dialog-show.sync="viewShow" :rowmst="mstrow" @AddChanged="querytable" />
<DivDialog :dialog-show.sync="divShow" :open-array="openParam" :rowmst="mstrow" @DivChanged="querytable" />
</div>
</template>
<script>
import invtransfer from '@/views/wms/st/invtransfer/invtransfer'
import CRUD, { crud, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import AddDialog from '@/views/wms/st/invtransfer/AddDialog'
import DivDialog from '@/views/wms/st/invtransfer/DivDialog'
import ViewDialog from '@/views/wms/st/invtransfer/ViewDialog'
import crudBsrealstorattr from '@/views/wms/basedata/bsrealstorattr/bsrealstorattr'
export default {
name: 'Invtransfer',
components: { ViewDialog, AddDialog, crudOperation, rrOperation, udOperation, pagination, DivDialog },
cruds() {
return CRUD({ title: '库存调拨', idField: 'transfer_id', url: 'api/invtransfer', crudMethod: { ...invtransfer }, optShow: { add: true, edit: false, del: false, reset: true, download: false }, queryOnPresenterCreated: true })
},
mixins: [presenter(), header(), crud()],
dicts: ['io_bill_status', 'ST_INV_OUT_TYPE'],
data() {
return {
permission: { add: ['admin', 'invtransfer:add'], edit: ['admin', 'invtransfer:edit'], del: ['admin', 'invtransfer:del'], confirm: ['admin', 'invtransfer:confirm'] },
loadingConfirm: false,
divShow: false,
dis_flag: true,
confirm_flag: true,
openParam: [],
mstrow: {},
viewShow: false,
currentRow: null,
storlist: []
}
},
created() {
crudBsrealstorattr.getStor().then(res => { this.storlist = res.data })
},
methods: {
canUd(row) { return row.bill_status !== '10' },
toView(index, row) { this.mstrow = row; this.viewShow = true },
[CRUD.HOOK.beforeRefresh]() { this.handleCurrentChange(null) },
handleSelectionChange(val, row) {
if (val.length > 1) { this.$refs.table.clearSelection(); this.$refs.table.toggleRowSelection(val.pop()); this.buttonChange(row) } else if (val.length === 1) { this.buttonChange(row) } else { this.handleCurrentChange(null) }
},
onSelectAll() { this.$refs.table.clearSelection(); this.handleCurrentChange(null) },
buttonChange(current) {
if (current !== null) {
this.currentRow = current
this.dis_flag = !(current.bill_status === '10' || current.bill_status === '20' || current.bill_status === '30' || current.bill_status === '40')
this.confirm_flag = !(current.bill_status === '30' || current.bill_status === '40')
}
},
stateFormat(row) { return this.dict.label.io_bill_status[row.bill_status] },
bill_typeFormat(row) { return this.dict.label.ST_INV_OUT_TYPE[row.bill_type] },
handleCurrentChange(current) {
if (current === null) { this.dis_flag = true; this.confirm_flag = true; this.currentRow = {} }
},
checkboxT(row) { return row.bill_status !== '99' },
divOpen() {
invtransfer.getDtl({ transfer_id: this.currentRow.transfer_id }).then(res => {
this.openParam = res.data
this.divShow = true
this.mstrow = this.currentRow
})
},
confirm() {
this.loadingConfirm = true
invtransfer.confirm({ transfer_id: this.currentRow.transfer_id }).then(() => {
this.querytable()
this.crud.notify('调拨确认成功!', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.loadingConfirm = false
}).catch(() => { this.loadingConfirm = false })
},
querytable() { this.onSelectAll(); this.crud.toQuery(); this.handleCurrentChange(null) }
}
}
</script>

View File

@@ -0,0 +1,59 @@
import request from '@/utils/request'
export function add(data) {
return request({ url: 'api/invtransfer', method: 'post', data })
}
export function del(ids) {
return request({ url: 'api/invtransfer/', method: 'delete', data: ids })
}
export function edit(data) {
return request({ url: 'api/invtransfer', method: 'put', data })
}
export function getDtl(params) {
return request({ url: '/api/invtransfer/getDtl', method: 'get', params })
}
export function getDis(params) {
return request({ url: '/api/invtransfer/getDis', method: 'get', params })
}
export function allDiv(data) {
return request({ url: '/api/invtransfer/allDiv', method: 'post', data })
}
export function allDivOne(data) {
return request({ url: '/api/invtransfer/autoDiv', method: 'post', data })
}
export function allCancel(data) {
return request({ url: '/api/invtransfer/allCancel', method: 'post', data })
}
export function autoCancel(data) {
return request({ url: '/api/invtransfer/autoCancel', method: 'post', data })
}
export function getStructIvt(params) {
return request({ url: '/api/invtransfer/getStructIvt', method: 'get', params })
}
export function manualDiv(data) {
return request({ url: '/api/invtransfer/manualDiv', method: 'post', data })
}
export function confirm(data) {
return request({ url: '/api/invtransfer/confirm', method: 'post', data })
}
export function getTask(data) {
return request({ url: '/api/invtransfer/getTask', method: 'post', data })
}
export function allSetPoint(data) {
return request({ url: '/api/invtransfer/allSetPoint', method: 'post', data })
}
export default { add, edit, del, allDiv, allCancel, getDtl, getDis, autoCancel, getStructIvt, manualDiv, confirm, allDivOne, getTask, allSetPoint }