Commit 257c641a by wangchunyang
parents 9853355c ca09c205
...@@ -101,6 +101,19 @@ ...@@ -101,6 +101,19 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="入库日期" prop="inboundDateRange">
<el-date-picker
v-model="inboundDateRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
</page-wrapper-search> </page-wrapper-search>
<!-- 表格区域 --> <!-- 表格区域 -->
...@@ -110,7 +123,7 @@ ...@@ -110,7 +123,7 @@
height="100%" height="100%"
:data="inboundList" :data="inboundList"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
:row-key="(row) => row.materialId + '_' + row.orderId + '_' + row.warehousesName + '_' + row.locationName" :row-key="(row) => row.materialId + '_' + row.batchId +'_' + row.orderId + '_' + row.warehousesName + '_' + row.locationName"
> >
<el-table-column label="物料SAPNO" align="center" prop="sapNo" min-width="200"/> <el-table-column label="物料SAPNO" align="center" prop="sapNo" min-width="200"/>
<el-table-column label="物料名称" align="center" prop="materialName" min-width="200"/> <el-table-column label="物料名称" align="center" prop="materialName" min-width="200"/>
...@@ -184,6 +197,8 @@ export default { ...@@ -184,6 +197,8 @@ export default {
}, },
data() { data() {
return { return {
// 入库日期选择数组
inboundDateRange: null,
// 仓库选择相关 // 仓库选择相关
warehouseSelectorVisible: false, warehouseSelectorVisible: false,
queryWarehouseName: null, queryWarehouseName: null,
...@@ -212,7 +227,9 @@ export default { ...@@ -212,7 +227,9 @@ export default {
batchId: null, batchId: null,
warehouseId: null, warehouseId: null,
locationId: null, locationId: null,
labelColor: null labelColor: null,
inboundDateStart: null,
inboundDateEnd: null
} }
} }
}, },
...@@ -247,6 +264,14 @@ export default { ...@@ -247,6 +264,14 @@ export default {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1 this.queryParams.pageNum = 1
if (Array.isArray(this.inboundDateRange) && this.inboundDateRange.length === 2) {
this.queryParams.inboundDateStart = this.inboundDateRange[0];
this.queryParams.inboundDateEnd = this.inboundDateRange[1];
} else {
// 清空开始/结束日期(避免残留旧值)
this.queryParams.inboundDateStart = "";
this.queryParams.inboundDateEnd = "";
}
this.getList() this.getList()
}, },
...@@ -261,10 +286,13 @@ export default { ...@@ -261,10 +286,13 @@ export default {
batchId: null, batchId: null,
warehouseId: null, warehouseId: null,
locationId: null, locationId: null,
labelColor: null labelColor: null,
inboundDateStart: null,
inboundDateStart: null
} }
this.queryWarehouseName = null this.queryWarehouseName = null
this.queryLocationName = null this.queryLocationName = null
this.inboundDateRange = null
this.handleQuery() this.handleQuery()
}, },
......
...@@ -364,6 +364,7 @@ export default { ...@@ -364,6 +364,7 @@ export default {
{ prop: 'voucherNumber', label: '凭证号', width: '150', editable: true }, { prop: 'voucherNumber', label: '凭证号', width: '150', editable: true },
{ prop: 'unitPrice', label: '单价', width: '100', type: 'number', editable: true }, { prop: 'unitPrice', label: '单价', width: '100', type: 'number', editable: true },
{ prop: 'receivedBy', label: '收货人', width: '150', editable: true }, { prop: 'receivedBy', label: '收货人', width: '150', editable: true },
{ prop: 'labelQuantity', label: '贴标数量', width: '150',type: 'number', editable: true },
{ prop: 'remark', label: '备注', minWidth: '150', editable: true }, { prop: 'remark', label: '备注', minWidth: '150', editable: true },
] ]
}, },
......
...@@ -12,6 +12,7 @@ import com.alibaba.excel.context.AnalysisContext; ...@@ -12,6 +12,7 @@ import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.exception.ExcelAnalysisException; import com.alibaba.excel.exception.ExcelAnalysisException;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.uuid.UUID; import com.ruoyi.common.utils.uuid.UUID;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -22,6 +23,7 @@ import com.ruoyi.inventory.domain.vo.InboundMaterialTotalVO; ...@@ -22,6 +23,7 @@ import com.ruoyi.inventory.domain.vo.InboundMaterialTotalVO;
import com.ruoyi.inventory.domain.vo.inboundVO.InboundTRDCTemplateVO; import com.ruoyi.inventory.domain.vo.inboundVO.InboundTRDCTemplateVO;
import com.ruoyi.inventory.domain.vo.inboundVO.InboundTemplateVO; import com.ruoyi.inventory.domain.vo.inboundVO.InboundTemplateVO;
import com.ruoyi.inventory.service.impl.InboundOrdersServiceImpl; import com.ruoyi.inventory.service.impl.InboundOrdersServiceImpl;
import com.ruoyi.system.service.ISysDictDataService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -50,6 +52,8 @@ public class InboundOrdersController extends BaseController ...@@ -50,6 +52,8 @@ public class InboundOrdersController extends BaseController
{ {
@Autowired @Autowired
private IInboundOrdersService inboundOrdersService; private IInboundOrdersService inboundOrdersService;
@Autowired
private ISysDictDataService iSysDictDataService;
private static final Logger log = LoggerFactory.getLogger(InboundOrdersServiceImpl.class); private static final Logger log = LoggerFactory.getLogger(InboundOrdersServiceImpl.class);
/** /**
* 查询入库单主列表 * 查询入库单主列表
...@@ -62,7 +66,14 @@ public class InboundOrdersController extends BaseController ...@@ -62,7 +66,14 @@ public class InboundOrdersController extends BaseController
List<InboundOrders> list = inboundOrdersService.selectInboundOrdersList(inboundOrders); List<InboundOrders> list = inboundOrdersService.selectInboundOrdersList(inboundOrders);
return getDataTable(list); return getDataTable(list);
} }
private Map<Object, Object> getDictMap(String dictType) {
List<SysDictData> dictList = iSysDictDataService.selectDictDataByType(dictType);
Map<Object, Object> dictMap = new HashMap<>();
for (SysDictData dictData : dictList) {
dictMap.put(dictData.getDictValue(), dictData.getDictLabel());
}
return dictMap;
}
/** /**
* 导出入库单主列表 * 导出入库单主列表
*/ */
...@@ -72,18 +83,24 @@ public class InboundOrdersController extends BaseController ...@@ -72,18 +83,24 @@ public class InboundOrdersController extends BaseController
public void export(HttpServletResponse response, InboundOrders inboundOrders) public void export(HttpServletResponse response, InboundOrders inboundOrders)
{ {
List<InboundItemsTO> list = inboundOrdersService.selectInboundOrdersAndItems(inboundOrders); List<InboundItemsTO> list = inboundOrdersService.selectInboundOrdersAndItems(inboundOrders);
Map<Object, Object> colorDictMap = getDictMap("label_color");
for (InboundItemsTO inboundItem : list) { for (InboundItemsTO inboundItem : list) {
if (inboundItem != null) { if (inboundItem != null) {
inboundItem.setPackageWeight(inboundItem.getWeight() * (inboundItem.getActualQuantity() / inboundItem.getActualPackages())); inboundItem.setPackageWeight(inboundItem.getWeight() * (inboundItem.getActualQuantity() / inboundItem.getActualPackages()));
inboundItem.setUnitWeight(inboundItem.getWeight() * (inboundItem.getActualQuantity() / inboundItem.getActualPackages())); inboundItem.setUnitWeight(inboundItem.getWeight() * (inboundItem.getActualQuantity() / inboundItem.getActualPackages()));
if (inboundItem.getOrderStatus() == 1) { inboundItem.setLabelColorName((String) colorDictMap.get(inboundItem.getLabelColor()+""));
switch (inboundItem.getOrderTypeId()) {
case "1":
inboundItem.setRelocation(inboundItem.getRemark()); inboundItem.setRelocation(inboundItem.getRemark());
}else if (inboundItem.getOrderStatus() == 2) { break;
case "2":
inboundItem.setFinishedLocation(inboundItem.getRemark()); inboundItem.setFinishedLocation(inboundItem.getRemark());
}else if (inboundItem.getOrderStatus() == 3) { break;
case "3":
inboundItem.setRemarkTrdc(inboundItem.getRemark()); inboundItem.setRemarkTrdc(inboundItem.getRemark());
inboundItem.setFinishedSystemNo(inboundItem.getSystemNo()); inboundItem.setFinishedSystemNo(inboundItem.getSystemNo());
inboundItem.setFinishedOrderId(inboundItem.getOrderId()); inboundItem.setFinishedOrderId(inboundItem.getOrderId());
break;
} }
} }
} }
......
...@@ -275,7 +275,7 @@ public class InventoryController extends BaseController ...@@ -275,7 +275,7 @@ public class InventoryController extends BaseController
inventory.setLocationId(location.getId()); inventory.setLocationId(location.getId());
inventory.setQuantity(qty == null ? 0 : qty.longValue()); inventory.setQuantity(qty == null ? 0 : qty.longValue());
inventory.setLockedQuantity(0L); inventory.setLockedQuantity(0L);
inventory.setUnitWeight(unitWeight == null ? null : Math.round(unitWeight)); inventory.setUnitWeight(unitWeight);
inventory.setTotalWeight(totalWeight == null ? null : Math.round(totalWeight)); inventory.setTotalWeight(totalWeight == null ? null : Math.round(totalWeight));
inventory.setInventoryStatus(1L); inventory.setInventoryStatus(1L);
inventory.setIsUsed(1L); inventory.setIsUsed(1L);
......
...@@ -74,7 +74,7 @@ public class InboundOrderItems extends BaseEntity ...@@ -74,7 +74,7 @@ public class InboundOrderItems extends BaseEntity
/** 单价 */ /** 单价 */
@Excel(name = "单价") @Excel(name = "单价")
private Long unitPrice; private Double unitPrice;
/** 状态1-待收货 2-部分收货 3-已完成 暂无用 */ /** 状态1-待收货 2-部分收货 3-已完成 暂无用 */
// @Excel(name = "状态") // @Excel(name = "状态")
...@@ -106,6 +106,10 @@ public class InboundOrderItems extends BaseEntity ...@@ -106,6 +106,10 @@ public class InboundOrderItems extends BaseEntity
/** 排序号 */ /** 排序号 */
// @Excel(name = "排序号") // @Excel(name = "排序号")
private String updateUserCode; private String updateUserCode;
/** 单件重量 */
private Double packageWeight;
/** 单位重量 */
private Double unitWeight;
public void setId(String id) public void setId(String id)
{ {
...@@ -237,14 +241,12 @@ public class InboundOrderItems extends BaseEntity ...@@ -237,14 +241,12 @@ public class InboundOrderItems extends BaseEntity
return voucherNumber; return voucherNumber;
} }
public void setUnitPrice(Long unitPrice) public Double getUnitPrice() {
{ return unitPrice;
this.unitPrice = unitPrice;
} }
public Long getUnitPrice() public void setUnitPrice(Double unitPrice) {
{ this.unitPrice = unitPrice;
return unitPrice;
} }
public void setItemStatus(Long itemStatus) public void setItemStatus(Long itemStatus)
...@@ -341,6 +343,22 @@ public class InboundOrderItems extends BaseEntity ...@@ -341,6 +343,22 @@ public class InboundOrderItems extends BaseEntity
this.labelQuantity = labelQuantity; this.labelQuantity = labelQuantity;
} }
public Double getUnitWeight() {
return unitWeight;
}
public void setUnitWeight(Double unitWeight) {
this.unitWeight = unitWeight;
}
public Double getPackageWeight() {
return packageWeight;
}
public void setPackageWeight(Double packageWeight) {
this.packageWeight = packageWeight;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
...@@ -72,7 +72,7 @@ public class Inventory extends BaseEntity ...@@ -72,7 +72,7 @@ public class Inventory extends BaseEntity
/** 单位重量 */ /** 单位重量 */
@Excel(name = "单位重量") @Excel(name = "单位重量")
private Long unitWeight; private Double unitWeight;
/** 总重量 暂无用 */ /** 总重量 暂无用 */
@Excel(name = "总重量 暂无用") @Excel(name = "总重量 暂无用")
...@@ -181,4 +181,23 @@ public class Inventory extends BaseEntity ...@@ -181,4 +181,23 @@ public class Inventory extends BaseEntity
private Double unitPrice; private Double unitPrice;
private String inboundOrderId; private String inboundOrderId;
public Inventory() {
}
/**
* 入库导入批量新增库存映射字段
* */
public Inventory(Long inventoryType, String orderId,String materialId, String batchId, String warehousesId, String locationId, String ownerId, Long quantity, Double unitWeight, Long inventoryStatus, Double unitPrice) {
this.inventoryType = inventoryType;
this.orderId = orderId;
this.materialId = materialId;
this.batchId = batchId;
this.warehousesId = warehousesId;
this.locationId = locationId;
this.ownerId = ownerId;
this.quantity = quantity;
this.unitWeight = unitWeight;
this.inventoryStatus = inventoryStatus;
this.unitPrice = unitPrice;
}
} }
...@@ -83,7 +83,7 @@ public class InboundItemsTO extends BaseEntity { ...@@ -83,7 +83,7 @@ public class InboundItemsTO extends BaseEntity {
/** 标签颜色 */ /** 标签颜色 */
@Excel(name = "标签颜色") @Excel(name = "标签颜色")
private Long labelColor; private String labelColorName;
/** 凭证号 */ /** 凭证号 */
@Excel(name = "凭证号") @Excel(name = "凭证号")
...@@ -143,8 +143,10 @@ public class InboundItemsTO extends BaseEntity { ...@@ -143,8 +143,10 @@ public class InboundItemsTO extends BaseEntity {
/** 仓库名称 */ /** 仓库名称 */
private String warehousesName; private String warehousesName;
/** 库位ID */
private String locationId;
private Long labelColor;
/** 计划件数 暂无用 */ /** 计划件数 暂无用 */
private Long plannedPackages; private Long plannedPackages;
...@@ -185,4 +187,6 @@ public class InboundItemsTO extends BaseEntity { ...@@ -185,4 +187,6 @@ public class InboundItemsTO extends BaseEntity {
private String updateUserCode; private String updateUserCode;
private Integer orderStatus; private Integer orderStatus;
private String orderTypeId;
} }
\ No newline at end of file
...@@ -53,6 +53,9 @@ public class InboundDetailsVO { ...@@ -53,6 +53,9 @@ public class InboundDetailsVO {
@Excel(name = "入库时间") @Excel(name = "入库时间")
private Date inboundDate; private Date inboundDate;
// 开始入库日期结束日库日期,仅作查询
private Date inboundDateStart;
private Date inboundDateEnd;
public String getMaterialId() { public String getMaterialId() {
return materialId; return materialId;
...@@ -182,6 +185,22 @@ public class InboundDetailsVO { ...@@ -182,6 +185,22 @@ public class InboundDetailsVO {
this.sapNo = sapNo; this.sapNo = sapNo;
} }
public Date getInboundDateStart() {
return inboundDateStart;
}
public void setInboundDateStart(Date inboundDateStart) {
this.inboundDateStart = inboundDateStart;
}
public Date getInboundDateEnd() {
return inboundDateEnd;
}
public void setInboundDateEnd(Date inboundDateEnd) {
this.inboundDateEnd = inboundDateEnd;
}
@Override @Override
public String toString() { public String toString() {
return "InboundDetailsVO{" + return "InboundDetailsVO{" +
......
...@@ -12,6 +12,7 @@ import com.ruoyi.inventory.domain.*; ...@@ -12,6 +12,7 @@ import com.ruoyi.inventory.domain.*;
import com.ruoyi.inventory.domain.TO.InboundItemsTO; import com.ruoyi.inventory.domain.TO.InboundItemsTO;
import com.ruoyi.inventory.domain.vo.InboundMaterialTotalVO; import com.ruoyi.inventory.domain.vo.InboundMaterialTotalVO;
import com.ruoyi.inventory.mapper.*; import com.ruoyi.inventory.mapper.*;
import com.ruoyi.inventory.service.IInventoryService;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -48,7 +49,8 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService ...@@ -48,7 +49,8 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
private WarehousesMapper warehousesMapper; private WarehousesMapper warehousesMapper;
@Autowired @Autowired
private StorageLocationsMapper storageLocationsMapper; private StorageLocationsMapper storageLocationsMapper;
@Autowired
private IInventoryService iInventoryService;
private static final Logger log = LoggerFactory.getLogger(InboundOrdersServiceImpl.class); private static final Logger log = LoggerFactory.getLogger(InboundOrdersServiceImpl.class);
/** /**
...@@ -293,7 +295,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService ...@@ -293,7 +295,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
List<T> voList = entry.getValue(); List<T> voList = entry.getValue();
InboundOrders mainDO = null; InboundOrders mainDO = null;
List<InboundOrderItems> itemDOList = new ArrayList<>(); List<InboundOrderItems> itemDOList = new ArrayList<>();
List<Inventory> inventoryList = new ArrayList<>();
try { try {
// 4.1 处理主表(每个入库单号只处理一次主表) // 4.1 处理主表(每个入库单号只处理一次主表)
T firstVO = voList.get(0); // 取第一条VO的主表信息 T firstVO = voList.get(0); // 取第一条VO的主表信息
...@@ -344,7 +346,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService ...@@ -344,7 +346,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
mainDO.setSortNo(0L); mainDO.setSortNo(0L);
} }
if (mainDO.getOrderStatus() == null) { if (mainDO.getOrderStatus() == null) {
mainDO.setOrderStatus(1L); // 默认草稿状态 mainDO.setOrderStatus(2L); // 默认草稿状态
} }
// ========== 货主查询(反射获取ownerId) ========== // ========== 货主查询(反射获取ownerId) ==========
...@@ -376,6 +378,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService ...@@ -376,6 +378,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
for (T vo : voList) { for (T vo : voList) {
try { try {
InboundOrderItems itemDO = new InboundOrderItems(); InboundOrderItems itemDO = new InboundOrderItems();
// 反射复制子表字段(物料相关) // 反射复制子表字段(物料相关)
BeanUtils.copyProperties(vo, itemDO, BeanUtils.copyProperties(vo, itemDO,
"orderId", "systemNo", "orderTypeId", "batchId"); // 排除主表字段 "orderId", "systemNo", "orderTypeId", "batchId"); // 排除主表字段
...@@ -470,6 +473,20 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService ...@@ -470,6 +473,20 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
itemDO.setLocationId(locationId); itemDO.setLocationId(locationId);
} }
itemDOList.add(itemDO); itemDOList.add(itemDO);
Inventory inventoryDO = new Inventory(
Long.parseLong(mainDO.getOrderTypeId()),
orderId,
itemDO.getMaterialId(),
batchId,
itemDO.getWarehouseId(),
itemDO.getLocationId(),
mainDO.getOwnerId(),
itemDO.getActualQuantity(),
itemDO.getPackageWeight() / itemDO.getActualPackages(),
1L,
itemDO.getUnitPrice()
);
inventoryList.add(inventoryDO);
} catch (Exception e) { } catch (Exception e) {
// 单个明细失败:仅统计,不影响整单 // 单个明细失败:仅统计,不影响整单
totalItemFailure++; totalItemFailure++;
...@@ -492,10 +509,12 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService ...@@ -492,10 +509,12 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
// 4.3 批量插入明细 // 4.3 批量插入明细
if (!CollectionUtils.isEmpty(itemDOList)) { if (!CollectionUtils.isEmpty(itemDOList)) {
int itemSuccess = inboundOrdersMapper.batchInboundOrderItems(itemDOList); int itemSuccess = inboundOrdersMapper.batchInboundOrderItems(itemDOList);
if (itemSuccess != itemDOList.size()) { int inventorySuccess = iInventoryService.insertInventoryList(inventoryList);
if (itemSuccess != itemDOList.size() && itemSuccess != inventorySuccess) {
// 批量插入部分失败,主动回滚事务 // 批量插入部分失败,主动回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new ServiceException("明细批量插入失败,成功" + itemSuccess + "条,总" + itemDOList.size() + "条"); throw new ServiceException("明细批量插入失败,成功" + itemSuccess + "条,总" + itemDOList.size() + "条");
} }
totalItemSuccess += itemSuccess; totalItemSuccess += itemSuccess;
successMsg.append(String.format("入库单号【%s】成功导入%d条物料明细;\n", orderId, itemSuccess)); successMsg.append(String.format("入库单号【%s】成功导入%d条物料明细;\n", orderId, itemSuccess));
...@@ -507,7 +526,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService ...@@ -507,7 +526,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
totalItemFailure += voList.size(); totalItemFailure += voList.size();
failureMsg.append(String.format("入库单号【%s】处理失败:%s;\n", orderId, e.getMessage())); failureMsg.append(String.format("入库单号【%s】处理失败:%s;\n", orderId, e.getMessage()));
// 打印异常栈,方便调试 // 打印异常栈,方便调试
log.error("导入入库单【{}】失败", orderId, e); log.error("导入【{}】批次的入库单【{}】失败", orderId, batchId, e);
// 整单失败回滚 // 整单失败回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
} }
......
...@@ -94,7 +94,7 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -94,7 +94,7 @@ public class InventoryServiceImpl implements IInventoryService
} }
/** /**
* 批量库存 * 批量新增库存
* *
* @param inventoryList 库存 * @param inventoryList 库存
* @return 结果 * @return 结果
...@@ -108,6 +108,7 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -108,6 +108,7 @@ public class InventoryServiceImpl implements IInventoryService
inventory.setId(UUID.randomUUID().toString()); inventory.setId(UUID.randomUUID().toString());
inventory.setCreateBy(SystemUtils.getUserName()); inventory.setCreateBy(SystemUtils.getUserName());
inventory.setCreateUserCode(SystemUtils.getUserName()); inventory.setCreateUserCode(SystemUtils.getUserName());
inventory.setIsUsed(1L);
createInventoryInboundLog(inventory,inventory.getQuantity(),inventory.getCreateUserCode(),inventory.getCreateTime()); createInventoryInboundLog(inventory,inventory.getQuantity(),inventory.getCreateUserCode(),inventory.getCreateTime());
count = inventoryMapper.insertInventory(inventory); count = inventoryMapper.insertInventory(inventory);
} }
...@@ -224,10 +225,17 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -224,10 +225,17 @@ public class InventoryServiceImpl implements IInventoryService
// 新建实体,查看该物料在库存中数量,避免其他条件干扰 // 新建实体,查看该物料在库存中数量,避免其他条件干扰
Inventory inventoryBefore = new Inventory(); Inventory inventoryBefore = new Inventory();
inventoryBefore.setMaterialId(inventory.getMaterialId()); inventoryBefore.setMaterialId(inventory.getMaterialId());
inventoryBefore = inventoryMapper.selectInventory(inventoryBefore); List<Inventory> inventoryList = inventoryMapper.selectInventoryList(inventoryBefore);
if (inventoryBefore == null) {
if (inventoryList == null) {
inventoryBefore = new Inventory(); inventoryBefore = new Inventory();
inventoryBefore.setQuantity(0L); inventoryBefore.setQuantity(0L);
}else{
Long quantity = 0L;
for (Inventory inventoryItem : inventoryList) {
quantity += inventoryItem.getQuantity();
}
inventoryBefore.setQuantity(quantity);
} }
transactions.setQuantityBefore(inventoryBefore.getQuantity()); transactions.setQuantityBefore(inventoryBefore.getQuantity());
transactions.setQuantityAfter(inventory.getQuantity() + addQty); transactions.setQuantityAfter(inventory.getQuantity() + addQty);
......
...@@ -368,6 +368,12 @@ ...@@ -368,6 +368,12 @@
left join storage_locations sl on ioi.location_id = sl.id left join storage_locations sl on ioi.location_id = sl.id
<where> <where>
io.order_status = 2 io.order_status = 2
<if test="inboundDateStart != null">
AND DATE(io.inbound_date) &gt;= #{inboundDateStart}
</if>
<if test="inboundDateEnd != null">
AND DATE(io.inbound_date) &lt;= #{inboundDateEnd}
</if>
<if test="sapNo != null and sapNo != ''"> <if test="sapNo != null and sapNo != ''">
AND ms.sap_no = #{sapNo} AND ms.sap_no = #{sapNo}
</if> </if>
......
...@@ -84,10 +84,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -84,10 +84,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="orderStatus != null "> and order_status = #{orderStatus}</if> <if test="orderStatus != null "> and order_status = #{orderStatus}</if>
<!-- 新增按照日期范围查询--> <!-- 新增按照日期范围查询-->
<if test="inboundDateStart != null"> <if test="inboundDateStart != null">
AND inbound_date &gt;= #{inboundDateStart} AND date(inbound_date) &gt;= #{inboundDateStart}
</if> </if>
<if test="inboundDateEnd != null"> <if test="inboundDateEnd != null">
AND inbound_date &lt;= #{inboundDateEnd} AND date(inbound_date) &lt;= #{inboundDateEnd}
</if> </if>
<if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if> <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
<if test="totalPlannedQuantity != null "> and total_planned_quantity = #{totalPlannedQuantity}</if> <if test="totalPlannedQuantity != null "> and total_planned_quantity = #{totalPlannedQuantity}</if>
...@@ -253,36 +253,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -253,36 +253,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result column="total_money" property="totalMoney" jdbcType="DECIMAL"/> <result column="total_money" property="totalMoney" jdbcType="DECIMAL"/>
</resultMap> </resultMap>
<select id="countInboundMaterialQuantity" resultMap="InboundMaterialTotalResultMap" parameterType="String"> <select id="countInboundMaterialQuantity" resultMap="InboundMaterialTotalResultMap" parameterType="String">
SELECT t.material_name, t.total_quantity select t.material_name,t.total_quantity from (
FROM ( SELECT
SELECT m.material_name, m.material_name,
COALESCE(SUM(ioi.actual_quantity), 0) as total_quantity COALESCE(SUM(ioi.actual_quantity), 0) AS total_quantity
FROM materials as m FROM materials AS m
LEFT JOIN inbound_order_items as ioi ON m.id = ioi.material_id LEFT JOIN (
LEFT JOIN inbound_orders as io ON io.id = ioi.inbound_order_id AND io.order_status = 2 SELECT ioi.material_id, ioi.actual_quantity
WHERE m.is_used = 1 AND m.is_active = 1 FROM
GROUP BY m.id, m.material_name inbound_order_items AS ioi
ORDER BY total_quantity DESC INNER JOIN
LIMIT 10 inbound_orders AS io
) t ON
ORDER BY t.total_quantity ASC; io.id = ioi.inbound_order_id
AND
io.order_status = 2
) AS ioi ON m.id = ioi.material_id
WHERE
m.is_used = 1
AND
m.is_active = 1
GROUP BY
m.id, m.material_name
ORDER BY
total_quantity DESC
) as t
order by total_quantity asc
</select> </select>
<select id="countInboundMaterialMoney" resultMap="InboundMaterialTotalResultMap" parameterType="String"> <select id="countInboundMaterialMoney" resultMap="InboundMaterialTotalResultMap" parameterType="String">
select t.material_name,t.total_money select t.material_name,t.total_money
from( from(
select m.material_name, SELECT
COALESCE(sum(ioi.actual_quantity * ioi.unit_price), 0) as total_money m.material_name,
from materials as m COALESCE(SUM(ioi.actual_quantity * ioi.unit_price), 0) AS total_money
left join inbound_order_items as ioi FROM materials AS m
on m.id = ioi.material_id LEFT JOIN (
left join inbound_orders as io SELECT ioi.material_id, ioi.actual_quantity,ioi.unit_price
on io.id = ioi.inbound_order_id FROM
and io.order_status = 2 inbound_order_items AS ioi
where m.is_used = 1 and m.is_active = 1 INNER JOIN
group by m.id inbound_orders AS io
order by total_money desc ON
limit 10 io.id = ioi.inbound_order_id
) t AND
io.order_status = 2
) AS ioi ON m.id = ioi.material_id
WHERE
m.is_used = 1
AND
m.is_active = 1
GROUP BY
m.id, m.material_name
ORDER BY
total_money DESC
) as t
order by total_money asc order by total_money asc
</select> </select>
...@@ -291,10 +315,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -291,10 +315,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select io.inbound_date, m.sap_no, m.material_name, select io.inbound_date, m.sap_no, m.material_name,
m.ts_code, io.batch_id, ioi.planned_quantity, m.ts_code, io.batch_id, ioi.planned_quantity,
ioi.divisor, ioi.actual_packages, ioi.actual_quantity, ioi.divisor, ioi.actual_packages, ioi.actual_quantity,
m.total_weight, storage_locations.location_name, ioi.warehouse_id, m.total_weight, sl.location_name, ioi.warehouse_id,
ioi.label_color, ioi.voucher_number, m.storage_temperature, ioi.label_color, ioi.voucher_number, m.storage_temperature,
m.hazard_id, io.order_id, io.system_no, io.owner_id, m.hazard_id, io.order_id, io.system_no, io.owner_id,
ioi.label_quantity, io.order_type, io.order_status, ioi.remark ioi.label_quantity, io.order_type, io.order_type_id, ioi.remark
from materials as m from materials as m
inner join inbound_order_items as ioi on ioi.material_id = m.id inner join inbound_order_items as ioi on ioi.material_id = m.id
inner join inbound_orders as io on ioi.inbound_order_id = io.id inner join inbound_orders as io on ioi.inbound_order_id = io.id
...@@ -333,6 +357,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -333,6 +357,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result column="owner_id" property="ownerId" /> <result column="owner_id" property="ownerId" />
<result column="label_quantity" property="labelQuantity" /> <result column="label_quantity" property="labelQuantity" />
<result column="order_type" property="orderType" /> <result column="order_type" property="orderType" />
<result column="order_status" property="orderStatus"/> <result column="order_type_id" property="orderTypeId"/>
</resultMap> </resultMap>
</mapper> </mapper>
\ No newline at end of file
...@@ -17,7 +17,13 @@ public interface ISysDictDataService ...@@ -17,7 +17,13 @@ public interface ISysDictDataService
* @return 字典数据集合信息 * @return 字典数据集合信息
*/ */
public List<SysDictData> selectDictDataList(SysDictData dictData); public List<SysDictData> selectDictDataList(SysDictData dictData);
/**
* 根据字典类型查询字典数据
*
* @param dictType 字典数据信息
* @return 字典数据集合信息
*/
public List<SysDictData> selectDictDataByType(String dictType);
/** /**
* 根据字典类型和字典键值查询字典数据信息 * 根据字典类型和字典键值查询字典数据信息
* *
......
...@@ -32,6 +32,15 @@ public class SysDictDataServiceImpl implements ISysDictDataService ...@@ -32,6 +32,15 @@ public class SysDictDataServiceImpl implements ISysDictDataService
} }
/** /**
* 根据字典类型查询字典数据
*
* @param dictType 字典数据信息
* @return 字典数据集合信息
*/
public List<SysDictData> selectDictDataByType(String dictType){
return dictDataMapper.selectDictDataByType(dictType);
}
/**
* 根据字典类型和字典键值查询字典数据信息 * 根据字典类型和字典键值查询字典数据信息
* *
* @param dictType 字典类型 * @param dictType 字典类型
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论