|
|
|
@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
@ -80,8 +81,6 @@ public class CallItemServiceImpl extends ServiceImpl<CallItemMapper, CallItem> i
|
|
|
|
|
callItem.setRequiredQty(sfcDispatchDto.getDispatchQty());
|
|
|
|
|
callItem.setRequiredDateTime(sfcDispatchDto.getPlannedStartDate());
|
|
|
|
|
callItem.setStatus(Constants.CALL_ITEM_STATUS_NEW);
|
|
|
|
|
callItem.setCallStatus(Constants.CALL_ITEM_STATUS_NEW);
|
|
|
|
|
callItem.setIssueStatus(Constants.CALL_ITEM_STATUS_NEW);
|
|
|
|
|
callItem.setCreateUser(user);
|
|
|
|
|
callItem.setCreatedDateTime(nowDate);
|
|
|
|
|
callItem.setModifyUser(user);
|
|
|
|
@ -101,8 +100,6 @@ public class CallItemServiceImpl extends ServiceImpl<CallItemMapper, CallItem> i
|
|
|
|
|
callItem.setHandle(HandleEnum.CALL_ITEM.getHandle(site, callItemNo));
|
|
|
|
|
callItem.setCallType(Constants.CALL_TYPE_MATERIAL);
|
|
|
|
|
callItem.setStatus(Constants.CALL_ITEM_STATUS_NEW);
|
|
|
|
|
callItem.setCallStatus(Constants.CALL_ITEM_STATUS_NEW);
|
|
|
|
|
callItem.setIssueStatus(Constants.CALL_ITEM_STATUS_NEW);
|
|
|
|
|
callItem.setCreateUser(user);
|
|
|
|
|
callItem.setCreatedDateTime(nowDate);
|
|
|
|
|
callItem.setModifyUser(user);
|
|
|
|
@ -143,8 +140,13 @@ public class CallItemServiceImpl extends ServiceImpl<CallItemMapper, CallItem> i
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocalDateTime dateTime = LocalDateTime.now();
|
|
|
|
|
callItemMapper.updateCallItemStatusByDispatchBo(Constants.CALL_ITEM_STATUS_CALLED, user, dateTime, callItemList);
|
|
|
|
|
//派工单号集合
|
|
|
|
|
List<String> dispatchBoList = new ArrayList<>();
|
|
|
|
|
for (CallItem callItem : callItemList) {
|
|
|
|
|
dispatchBoList.add(callItem.getSfcDispatchBo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.updateCallItemStatusByDispatchBo(Constants.CALL_ITEM_STATUS_CALLED, user, dispatchBoList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -153,6 +155,8 @@ public class CallItemServiceImpl extends ServiceImpl<CallItemMapper, CallItem> i
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//派工单号集合
|
|
|
|
|
List<String> dispatchBoList = new ArrayList<>();
|
|
|
|
|
for (CallItem callItem : callItemList) {
|
|
|
|
|
String sfcDispatchBo = callItem.getSfcDispatchBo();
|
|
|
|
|
List<CallItem> list = callItemMapper.selectCallItemAndType(sfcDispatchBo);
|
|
|
|
@ -167,20 +171,87 @@ public class CallItemServiceImpl extends ServiceImpl<CallItemMapper, CallItem> i
|
|
|
|
|
throw BusinessException.build("勾选的派工单包含原材料组件,不能触发确认到料");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dispatchBoList.add(sfcDispatchBo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocalDateTime dateTime = LocalDateTime.now();
|
|
|
|
|
callItemMapper.updateCallItemStatusByDispatchBo(Constants.CALL_ITEM_STATUS_ISSUED, user, dateTime, callItemList);
|
|
|
|
|
this.updateCallItemStatusByDispatchBo(Constants.CALL_ITEM_STATUS_ISSUED, user, dispatchBoList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void cancelCallItem(String site, String user, List<String> callItemNoList) {
|
|
|
|
|
public void cancelCallItem(String site, String user, List<CallItem> callItemNoList) {
|
|
|
|
|
if (callItemNoList == null || callItemNoList.size() <= 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> callItemList = new ArrayList<>();
|
|
|
|
|
for (CallItem callItem: callItemNoList) {
|
|
|
|
|
String status = callItem.getStatus();
|
|
|
|
|
if (Constants.CALL_ITEM_STATUS_ISSUED.equals(status)) {
|
|
|
|
|
throw BusinessException.build("领料单号【" +callItem.getCallItemNo()+ "】已发料,不允许取消!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callItemList.add(callItem.getCallItemNo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocalDateTime dateTime = LocalDateTime.now();
|
|
|
|
|
callItemMapper.updateCallItemStatusByCallItemNo(Constants.CALL_ITEM_STATUS_CANCELED, user, dateTime, callItemNoList);
|
|
|
|
|
callItemMapper.updateCallItemStatusByCallItemNo(Constants.CALL_ITEM_STATUS_CANCELED, user, dateTime, callItemList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void refreshCallItem(String site, String user, List<CallItem> callItemList) {
|
|
|
|
|
if (callItemList == null || callItemList.size() <= 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<SfcDispatchDto> sfcDispatchList = new ArrayList<>();
|
|
|
|
|
for (CallItem callItem: callItemList) {
|
|
|
|
|
SfcDispatchDto sfcDispatchDto = new SfcDispatchDto();
|
|
|
|
|
sfcDispatchDto.setHandle(callItem.getSfcDispatchBo());
|
|
|
|
|
sfcDispatchList.add(sfcDispatchDto);
|
|
|
|
|
}
|
|
|
|
|
List<CallItem> list = callItemMapper.selectDispatchCallItem(sfcDispatchList);
|
|
|
|
|
if (list == null || list.size() <= 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
LocalDateTime nowDate = LocalDateTime.now();
|
|
|
|
|
List<CallItem> addList = new ArrayList<>();
|
|
|
|
|
List<CallItem> modList = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
CallItem callItem = list.get(i);
|
|
|
|
|
String handle = callItem.getHandle();
|
|
|
|
|
BigDecimal reqQty = callItem.getRequiredQty();
|
|
|
|
|
if (reqQty.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
|
|
if (StringUtil.isBlank(handle)) {
|
|
|
|
|
String component = StringUtil.trimHandle(callItem.getComponentBo());
|
|
|
|
|
String callItemNo = callItem.getSfc() + callItem.getStepId() + component;
|
|
|
|
|
|
|
|
|
|
callItem.setCallItemNo(callItemNo);
|
|
|
|
|
callItem.setHandle(HandleEnum.CALL_ITEM.getHandle(site, callItemNo));
|
|
|
|
|
callItem.setCallType(Constants.CALL_TYPE_MATERIAL);
|
|
|
|
|
callItem.setStatus(Constants.CALL_ITEM_STATUS_NEW);
|
|
|
|
|
callItem.setCreateUser(user);
|
|
|
|
|
callItem.setCreatedDateTime(nowDate);
|
|
|
|
|
callItem.setModifyUser(user);
|
|
|
|
|
callItem.setModifiedDateTime(nowDate);
|
|
|
|
|
addList.add(callItem);
|
|
|
|
|
} else {
|
|
|
|
|
callItem.setRequiredQty(callItem.getIssueQty());
|
|
|
|
|
callItem.setModifyUser(user);
|
|
|
|
|
callItem.setModifiedDateTime(nowDate);
|
|
|
|
|
modList.add(callItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (addList != null && addList.size() > 0) {
|
|
|
|
|
this.saveBatch(addList);
|
|
|
|
|
}
|
|
|
|
|
if (modList != null && modList.size() > 0) {
|
|
|
|
|
this.updateBatchById(modList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -194,6 +265,12 @@ public class CallItemServiceImpl extends ServiceImpl<CallItemMapper, CallItem> i
|
|
|
|
|
callItemMapper.refreshRequiredTime(user, dateTime, callItemNoList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateCallItemStatusByDispatchBo(String status, String user, List<String> list) {
|
|
|
|
|
LocalDateTime dateTime = LocalDateTime.now();
|
|
|
|
|
callItemMapper.updateCallItemStatusByDispatchBo(status, user, dateTime, list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
@Override
|
|
|
|
@ -203,10 +280,64 @@ public class CallItemServiceImpl extends ServiceImpl<CallItemMapper, CallItem> i
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<CallItem> findIssueItemList(IssueItemDto issueItemDto) {
|
|
|
|
|
List<CallItem> list;
|
|
|
|
|
if (issueItemDto.getMatchResource()) {
|
|
|
|
|
return callItemMapper.finsIssueItemListToResource(issueItemDto);
|
|
|
|
|
list = callItemMapper.finsIssueItemListToResource(issueItemDto);
|
|
|
|
|
} else {
|
|
|
|
|
return callItemMapper.finsIssueItemListNoResource(issueItemDto);
|
|
|
|
|
list = callItemMapper.finsIssueItemListNoResource(issueItemDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (list == null || list.size() <= 0) {
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//计算合计(按下料尺寸)
|
|
|
|
|
//物料组为GB(钢板):合计=下料尺寸*号最后两位相乘*需求数量
|
|
|
|
|
//其他物料: 合计:下料尺寸*号最后一位*需求数量
|
|
|
|
|
Map<String, BigDecimal> compQtyMap = new HashMap<>();
|
|
|
|
|
for (CallItem callItem: list) {
|
|
|
|
|
String component = callItem.getItem();
|
|
|
|
|
String itemGroup = callItem.getItemGroup();
|
|
|
|
|
BigDecimal reqQty = callItem.getRequiredQty();
|
|
|
|
|
String blankingSize = callItem.getBlankingSize();
|
|
|
|
|
|
|
|
|
|
//工序叫料不需要计算数量
|
|
|
|
|
if (Constants.CALL_TYPE_OPERATION.equals(callItem.getCallType())) {
|
|
|
|
|
callItem.setSizeReqQty(BigDecimal.ONE);
|
|
|
|
|
compQtyMap.put(component, BigDecimal.ONE);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("GB".equals(itemGroup) && blankingSize.contains("*")) {
|
|
|
|
|
String []size = blankingSize.split("/*");
|
|
|
|
|
if (size != null && size.length >= 2) {
|
|
|
|
|
int sizeLength = size.length;
|
|
|
|
|
BigDecimal length = new BigDecimal(size[sizeLength-1]);
|
|
|
|
|
BigDecimal width = new BigDecimal(size[sizeLength-2]);
|
|
|
|
|
BigDecimal sizeReqQty = length.multiply(width).multiply(reqQty);
|
|
|
|
|
callItem.setSizeReqQty(sizeReqQty);
|
|
|
|
|
|
|
|
|
|
//按物料汇总需求数量
|
|
|
|
|
compQtyMap.put(component, (compQtyMap.get(component) != null ? compQtyMap.get(component).add(sizeReqQty) : sizeReqQty));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
String []size = blankingSize.split("/*");
|
|
|
|
|
if (size != null && size.length >= 1) {
|
|
|
|
|
int sizeLength = size.length;
|
|
|
|
|
BigDecimal length = new BigDecimal(size[sizeLength-1]);
|
|
|
|
|
BigDecimal sizeReqQty = length.multiply(reqQty);
|
|
|
|
|
callItem.setSizeReqQty(sizeReqQty);
|
|
|
|
|
|
|
|
|
|
//按物料汇总需求数量
|
|
|
|
|
compQtyMap.put(component, (compQtyMap.get(component) != null ? compQtyMap.get(component).add(sizeReqQty) : sizeReqQty));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//计算总数量(按数量汇总)
|
|
|
|
|
for (CallItem callItem : list) {
|
|
|
|
|
callItem.setCompReqQty(compQtyMap.get(callItem.getItem()));
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|