Commit 73933aeb by zhangtw

入库新增按照单号批次号入库类型分组

parent 1a8aa820
......@@ -187,7 +187,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
*/
@Override
@Transactional(rollbackFor = Exception.class)
public <T> String importInboundOrders(List<T> inboundOrdersList, Integer isUpdateSupport, String operName, Integer orderType) {
public <T> String importInboundOrders(List<T> inboundOrdersList, Integer isUpdateSupport, String operName, Integer orderTypeId) {
if (StringUtils.isNull(inboundOrdersList) || inboundOrdersList.size() == 0) {
throw new ServiceException("导入数据不能为空!");
}
......@@ -230,6 +230,13 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
.map(Object::toString)
.map(String::trim)
.orElse("");
// 反射获取getOrderType方法
Method getOrderType = vo.getClass().getMethod("getOrderType");
String orderType = Optional.ofNullable(getOrderType.invoke(vo))
.map(Object::toString)
.map(String::trim)
.orElse("");
// 反射调用setOrderId方法回写处理后的单号
Method setOrderIdMethod = vo.getClass().getMethod("setOrderId", String.class);
......@@ -237,6 +244,9 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
// 反射调用setBatchId方法回写处理后的批次号
Method setBatchIdMethod = vo.getClass().getMethod("setBatchId",String.class);
setBatchIdMethod.invoke(vo,batchId);
// 反射调用setOrderTypeMethod方法回写处理后的orderType
Method setOrderTypeMethod = vo.getClass().getMethod("setOrderType",String.class);
setOrderTypeMethod.invoke(vo, orderType);
} catch (Exception e) {
throw new ServiceException("实体类缺少orderId的getter/setter方法" + e);
}
......@@ -261,6 +271,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
try {
Method getOrderIdMethod = vo.getClass().getMethod("getOrderId");
Method getBatchIdMethod = vo.getClass().getMethod("getBatchId");
Method getOrderType = vo.getClass().getMethod("getOrderType");
return Optional.ofNullable(getOrderIdMethod.invoke(vo))
.map(Object::toString)
.map(String::trim)
......@@ -269,7 +280,12 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
Optional.ofNullable(getBatchIdMethod.invoke(vo))
.map(Object::toString)
.map(String::trim)
.orElse("");
.orElse("")
+ "--" +
Optional.ofNullable(getOrderType.invoke(vo))
.map(Object::toString)
.map(String::trim)
.orElse("");
} catch (Exception e) {
throw new ServiceException("分组获取orderId失败" + e);
}
......@@ -287,11 +303,13 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
String orderKey = entry.getKey();
String orderId = "";
String batchId = "";
String orderType = "";
try{
orderId = orderKey.split("--")[0];
batchId = orderKey.split("--")[1];
orderType = orderKey.split("--")[2];
}catch (IndexOutOfBoundsException e){
throw new ServiceException("请检查表头单号和批次号是否正确?");
throw new ServiceException("请检查表头单号和批次号和订单类型是否正确?");
}
List<T> voList = entry.getValue();
InboundOrders mainDO = null;
......@@ -305,6 +323,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
InboundOrders query = new InboundOrders();
query.setOrderId(orderId);
query.setBatchId(batchId);
query.setOrderType(orderType);
List<InboundOrders> existMain = inboundOrdersMapper.selectInboundOrdersList(query);
if (existMain != null && !existMain.isEmpty()) {
......@@ -322,7 +341,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
mainDO.setUpdateBy(operId);
mainDO.setUpdateTime(now);
mainDO.setUpdateUserCode(operId);
mainDO.setOrderTypeId(Optional.ofNullable(orderType).map(String::valueOf).orElse(""));
mainDO.setOrderTypeId(Optional.ofNullable(orderTypeId).map(String::valueOf).orElse(""));
// 更新主表
inboundOrdersMapper.updateInboundOrders(mainDO);
totalMainSuccess++;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论