add:收货允许批量修改工厂
This commit is contained in:
@@ -87,11 +87,12 @@ public class SapDeliveryController {
|
||||
}
|
||||
List<String> vbelns = dto.getVbelns();
|
||||
String lgort = dto.getLgort() == null ? null : dto.getLgort().trim();
|
||||
String werks = dto.getWerks() == null ? null : dto.getWerks().trim();
|
||||
List<String> success = new ArrayList<>();
|
||||
List<String> failed = new ArrayList<>();
|
||||
for (String vbeln : vbelns) {
|
||||
try {
|
||||
sapDeliveryService.confirmReceipt(vbeln, lgort);
|
||||
sapDeliveryService.confirmReceipt(vbeln, lgort, werks);
|
||||
success.add(vbeln);
|
||||
} catch (Exception e) {
|
||||
log.error("交货单{}收货确认失败", vbeln, e);
|
||||
|
||||
@@ -23,11 +23,21 @@ public interface SapDeliveryService {
|
||||
*/
|
||||
JSONObject confirmReceipt(String vbeln, String lgort);
|
||||
|
||||
/**
|
||||
* 收货确认,可同时指定存储地点与工厂(为空则按明细原值)
|
||||
*/
|
||||
JSONObject confirmReceipt(String vbeln, String lgort, String werks);
|
||||
|
||||
/**
|
||||
* 按行收货确认:只确认勾选的明细行,已确认的行不会重复回传
|
||||
*/
|
||||
JSONObject confirmItems(String vbeln, List<Long> itemIds, String lgort);
|
||||
|
||||
/**
|
||||
* 按行收货确认,可同时指定存储地点与工厂
|
||||
*/
|
||||
JSONObject confirmItems(String vbeln, List<Long> itemIds, String lgort, String werks);
|
||||
|
||||
IPage<SapDeliveryOrder> queryPage(SapDeliveryQuery query, PageQuery page);
|
||||
|
||||
SapDeliveryOrderDto getDetail(String vbeln);
|
||||
|
||||
@@ -15,4 +15,7 @@ public class SapDeliveryConfirmDto {
|
||||
|
||||
/** 批量指定的存储地点,为空则按单据明细原存储地点收货 */
|
||||
private String lgort;
|
||||
|
||||
/** 批量指定的工厂,为空则按单据明细原工厂收货 */
|
||||
private String werks;
|
||||
}
|
||||
|
||||
@@ -121,6 +121,12 @@ public class SapDeliveryServiceImpl implements SapDeliveryService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject confirmReceipt(String vbeln, String lgort) {
|
||||
return confirmReceipt(vbeln, lgort, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject confirmReceipt(String vbeln, String lgort, String werks) {
|
||||
SapDeliveryOrder order = loadConfirmableOrder(vbeln, "收货确认失败");
|
||||
List<SapDeliveryItem> items = listAllItems(vbeln);
|
||||
// 整单确认:过滤掉已按行确认过的明细
|
||||
@@ -131,12 +137,18 @@ public class SapDeliveryServiceImpl implements SapDeliveryService {
|
||||
if (pendingPosnr.isEmpty()) {
|
||||
throw new BadRequestException("收货确认失败:交货单" + vbeln + "的明细已全部确认");
|
||||
}
|
||||
return doConfirm(order, items, pendingPosnr, lgort);
|
||||
return doConfirm(order, items, pendingPosnr, lgort, werks);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject confirmItems(String vbeln, List<Long> itemIds, String lgort) {
|
||||
return confirmItems(vbeln, itemIds, lgort, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject confirmItems(String vbeln, List<Long> itemIds, String lgort, String werks) {
|
||||
if (CollectionUtils.isEmpty(itemIds)) {
|
||||
throw new BadRequestException("按行确认失败:未选择要确认的明细行");
|
||||
}
|
||||
@@ -156,7 +168,7 @@ public class SapDeliveryServiceImpl implements SapDeliveryService {
|
||||
}
|
||||
targetPosnr.add(item.getPosnr());
|
||||
}
|
||||
return doConfirm(order, items, targetPosnr, lgort);
|
||||
return doConfirm(order, items, targetPosnr, lgort, werks);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +176,7 @@ public class SapDeliveryServiceImpl implements SapDeliveryService {
|
||||
* 成功后维护行确认状态,全部行确认完才把整单置为完成。
|
||||
*/
|
||||
private JSONObject doConfirm(SapDeliveryOrder order, List<SapDeliveryItem> allItems,
|
||||
Set<String> targetPosnr, String lgort) {
|
||||
Set<String> targetPosnr, String lgort, String werks) {
|
||||
if (CollectionUtils.isEmpty(targetPosnr)) {
|
||||
throw new BadRequestException("确认失败:未匹配到待确认的明细行");
|
||||
}
|
||||
@@ -190,6 +202,21 @@ public class SapDeliveryServiceImpl implements SapDeliveryService {
|
||||
.and(w -> w.isNull(SapDeliveryItem::getRspos).or().eq(SapDeliveryItem::getRspos, 0)));
|
||||
}
|
||||
|
||||
// 收货确认时可批量指定工厂:只更新本次确认的主行
|
||||
String targetWerks = StrUtil.trim(werks);
|
||||
if (StrUtil.isNotBlank(targetWerks)) {
|
||||
for (SapDeliveryItem item : targetItems) {
|
||||
if (isMainItem(item)) {
|
||||
item.setWerks(targetWerks);
|
||||
}
|
||||
}
|
||||
itemMapper.update(null, new LambdaUpdateWrapper<SapDeliveryItem>()
|
||||
.set(SapDeliveryItem::getWerks, targetWerks)
|
||||
.eq(SapDeliveryItem::getHeader_vbeln, order.getVbeln())
|
||||
.in(SapDeliveryItem::getPosnr, targetPosnr)
|
||||
.and(w -> w.isNull(SapDeliveryItem::getRspos).or().eq(SapDeliveryItem::getRspos, 0)));
|
||||
}
|
||||
|
||||
order.setStatus(SapDeliveryStatus.EXECUTING.getCode());
|
||||
orderMapper.updateById(order);
|
||||
|
||||
|
||||
@@ -244,6 +244,20 @@
|
||||
所选交货单的全部明细存储地点将更新为该仓库,并按该存储地点回传 SAP。
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 12px;">
|
||||
<el-checkbox v-model="batchWerks">批量修改工厂</el-checkbox>
|
||||
<div v-if="batchWerks" style="margin-top: 12px;">
|
||||
<el-input
|
||||
v-model.trim="confirmWerks"
|
||||
clearable
|
||||
placeholder="请输入工厂,如 1060"
|
||||
@change="cacheWerks"
|
||||
/>
|
||||
<div style="margin-top: 8px; color: #e6a23c; font-size: 12px; line-height: 20px;">
|
||||
所选交货单的全部明细工厂将更新为该工厂,并按该工厂回传 SAP(输入后自动记住,下次打开带出)。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="confirmVisible = false">取消</el-button>
|
||||
<el-button size="mini" type="primary" :loading="confirming" @click="submitConfirmReceipt">确定</el-button>
|
||||
@@ -421,6 +435,9 @@ import udOperation from '@crud/UD.operation.vue'
|
||||
import rrOperation from '@crud/RR.operation.vue'
|
||||
import pagination from '@crud/Pagination.vue'
|
||||
|
||||
// 收货确认「批量修改工厂」本地缓存 key,避免每次重复输入
|
||||
const WERKS_CACHE_KEY = 'sapDelivery.confirmWerks'
|
||||
|
||||
const createItem = () => ({
|
||||
posnr: '',
|
||||
material: '',
|
||||
@@ -483,6 +500,8 @@ export default {
|
||||
confirmVbelns: [],
|
||||
batchLgort: false,
|
||||
confirmLgort: '',
|
||||
batchWerks: false,
|
||||
confirmWerks: '',
|
||||
lineConfirmVisible: false,
|
||||
lineVbeln: '',
|
||||
lineItems: [],
|
||||
@@ -681,6 +700,8 @@ export default {
|
||||
this.confirmVbelns = selections.map(item => item.vbeln)
|
||||
this.batchLgort = false
|
||||
this.confirmLgort = ''
|
||||
this.batchWerks = false
|
||||
this.confirmWerks = this.readCachedWerks()
|
||||
this.confirmVisible = true
|
||||
},
|
||||
openSyncDialog() {
|
||||
@@ -703,6 +724,26 @@ export default {
|
||||
this.syncing = false
|
||||
})
|
||||
},
|
||||
// 记住上次输入的工厂,下次打开收货确认自动带出
|
||||
cacheWerks() {
|
||||
try {
|
||||
const value = (this.confirmWerks || '').trim()
|
||||
if (value) {
|
||||
localStorage.setItem(WERKS_CACHE_KEY, value)
|
||||
} else {
|
||||
localStorage.removeItem(WERKS_CACHE_KEY)
|
||||
}
|
||||
} catch (e) {
|
||||
// 隐私模式等 localStorage 不可用时忽略
|
||||
}
|
||||
},
|
||||
readCachedWerks() {
|
||||
try {
|
||||
return localStorage.getItem(WERKS_CACHE_KEY) || ''
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
submitConfirmReceipt() {
|
||||
if (!this.confirmVbelns.length) {
|
||||
this.confirmVisible = false
|
||||
@@ -712,9 +753,17 @@ export default {
|
||||
this.crud.notify('请选择存储地点', CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return
|
||||
}
|
||||
if (this.batchWerks && !(this.confirmWerks || '').trim()) {
|
||||
this.crud.notify('请输入工厂', CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return
|
||||
}
|
||||
const lgort = this.batchLgort ? this.confirmLgort : null
|
||||
const werks = this.batchWerks ? this.confirmWerks.trim() : null
|
||||
if (werks) {
|
||||
this.cacheWerks()
|
||||
}
|
||||
this.confirming = true
|
||||
confirmReceipt(this.confirmVbelns, lgort).then(res => {
|
||||
confirmReceipt(this.confirmVbelns, lgort, werks).then(res => {
|
||||
const result = res.data || {}
|
||||
const failed = result.failed || []
|
||||
if (failed.length) {
|
||||
|
||||
@@ -36,12 +36,13 @@ export function getDetail(vbeln) {
|
||||
* 收货确认
|
||||
* @param {Array} vbelns 交货单号集合
|
||||
* @param {String} lgort 批量指定的存储地点,为空则按单据明细原存储地点收货
|
||||
* @param {String} werks 批量指定的工厂,为空则按单据明细原工厂收货
|
||||
*/
|
||||
export function confirmReceipt(vbelns, lgort) {
|
||||
export function confirmReceipt(vbelns, lgort, werks) {
|
||||
return request({
|
||||
url: 'api/sapDelivery/confirmReceipt',
|
||||
method: 'post',
|
||||
data: { vbelns, lgort }
|
||||
data: { vbelns, lgort, werks }
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user