Commit 19bd4ddb by yubin

导入

parent bdfed8f5
......@@ -236,4 +236,5 @@ public class DictUtils
{
return CacheConstants.SYS_DICT_KEY + configKey;
}
}
......@@ -7,7 +7,7 @@
<groupId>com.ruoyi</groupId>
<version>3.9.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
</parent><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin></plugins></build>
<modelVersion>4.0.0</modelVersion>
<artifactId>ruoyi-inventory</artifactId>
......
......@@ -137,30 +137,5 @@ public class OutboundOrderItemsController extends BaseController
{
return toAjax(outboundOrderItemsService.deleteOutboundOrderItemsByIds(ids));
}
/**
* 下载入库单导入模板
*/
@PreAuthorize("@ss.hasPermi('inventory:inbound:importTemplate')")
@Log(title = "入库导入模板", businessType = BusinessType.IMPORT)
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<InboundTemplateVO> util = new ExcelUtil<InboundTemplateVO>(InboundTemplateVO.class);
util.importTemplateExcel(response, "入库单及入库物料明细信息");
}
/**
* 导入入库单物料明细
*/
@PreAuthorize("@ss.hasPermi('inventory:inbound:import')")
@Log(title = "入库信息导入", businessType = BusinessType.IMPORT)
@PostMapping("/import")
public AjaxResult importTemplate(MultipartFile file , boolean updateSupport) throws Exception
{
ExcelUtil<OutboundTemplateVO> util = new ExcelUtil<OutboundTemplateVO>(OutboundTemplateVO.class);
List<OutboundTemplateVO> inboundOrders = util.importExcel(file.getInputStream());
String operName = getUsername();
String message = outboundOrderItemsService.importOutoundOrders(inboundOrders, updateSupport, operName);
return success(message);
}
}
......@@ -5,6 +5,8 @@ import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.inventory.domain.Inventory;
import com.ruoyi.inventory.domain.vo.InboundTemplateVO;
import com.ruoyi.inventory.domain.vo.OutboundTemplateVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -23,6 +25,7 @@ import com.ruoyi.inventory.domain.OutboundOrders;
import com.ruoyi.inventory.service.IOutboundOrdersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 出库单主Controller
......@@ -136,5 +139,30 @@ public class OutboundOrdersController extends BaseController
String resultMap = outboundOrdersService.outboundOrdersCount();
return AjaxResult.success(resultMap);
}
/**
* 下载入库单导入模板
*/
@PreAuthorize("@ss.hasPermi('inventory:inbound:importTemplate')")
@Log(title = "入库导入模板", businessType = BusinessType.IMPORT)
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<InboundTemplateVO> util = new ExcelUtil<InboundTemplateVO>(InboundTemplateVO.class);
util.importTemplateExcel(response, "入库单及入库物料明细信息");
}
/**
* 导入入库单物料明细
*/
@PreAuthorize("@ss.hasPermi('inventory:inbound:import')")
@Log(title = "入库信息导入", businessType = BusinessType.IMPORT)
@PostMapping("/import")
public AjaxResult importTemplate(MultipartFile file , boolean updateSupport) throws Exception
{
ExcelUtil<OutboundTemplateVO> util = new ExcelUtil<OutboundTemplateVO>(OutboundTemplateVO.class);
List<OutboundTemplateVO> inboundOrders = util.importExcel(file.getInputStream());
String operName = getUsername();
String message = outboundOrdersService.importOutboundOrders(inboundOrders, updateSupport, operName);
return success(message);
}
}
......@@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.inventory.domain.vo.OwnerTemplateVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -67,8 +68,8 @@ public class OwnersController extends BaseController
@PostMapping("/import")
public AjaxResult importTemplate(MultipartFile file , boolean updateSupport) throws Exception
{
ExcelUtil<Owners> util = new ExcelUtil<Owners>(Owners.class);
List<Owners> ownersList = util.importExcel(file.getInputStream());
ExcelUtil<OwnerTemplateVO> util = new ExcelUtil<OwnerTemplateVO>(OwnerTemplateVO.class);
List<OwnerTemplateVO> ownersList = util.importExcel(file.getInputStream());
String operName = getUsername();
String message = ownersService.importOwners(ownersList, updateSupport, operName);
return success(message);
......@@ -77,7 +78,7 @@ public class OwnersController extends BaseController
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<Owners> util = new ExcelUtil<Owners>(Owners.class);
ExcelUtil<OwnerTemplateVO> util = new ExcelUtil<OwnerTemplateVO>(OwnerTemplateVO.class);
util.importTemplateExcel(response, "货主数据");
}
......
......@@ -4,6 +4,10 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.inventory.domain.Owners;
import com.ruoyi.inventory.domain.vo.OwnerTemplateVO;
import com.ruoyi.inventory.domain.vo.StorageLocationsLocationTemplateVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -15,6 +19,7 @@ import com.ruoyi.inventory.domain.StorageLocations;
import com.ruoyi.inventory.service.IStorageLocationsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 库位Controller
......@@ -124,4 +129,23 @@ public class StorageLocationsController extends BaseController
List<StorageLocations> list = storageLocationsService.getStorageLocationsList(storageLocations);
return getDataTable(list);
}
@PreAuthorize("@ss.hasPermi('inventory:owners:add')")
@Log(title = "货主信息", businessType = BusinessType.IMPORT)
@PostMapping("/import")
public AjaxResult importTemplate(MultipartFile file , boolean updateSupport) throws Exception
{
ExcelUtil<StorageLocationsLocationTemplateVO> util = new ExcelUtil<StorageLocationsLocationTemplateVO>(StorageLocationsLocationTemplateVO.class);
List<StorageLocationsLocationTemplateVO> storageLocationsLocationTemplateVOS = util.importExcel(file.getInputStream());
String operName = getUsername();
String message = storageLocationsService.importStorageLocationsLocation(storageLocationsLocationTemplateVOS, updateSupport, operName);
return success(message);
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<StorageLocationsLocationTemplateVO> util = new ExcelUtil<StorageLocationsLocationTemplateVO>(StorageLocationsLocationTemplateVO.class);
util.importTemplateExcel(response, "货主数据");
}
}
......@@ -28,9 +28,13 @@ public class Inventory extends BaseEntity
@Excel(name = "入库单号")
private String orderId;
/** 货物名称 */
private String orderName;
/** 物料ID 检索条件 */
@Excel(name = "物料ID 检索条件")
private String materialId;
/** 货物名称 */
private String materialName;
/** 批次ID 检索条件 */
@Excel(name = "批次ID 检索条件")
......@@ -40,15 +44,20 @@ public class Inventory extends BaseEntity
private String warehousesId;
/** 仓库编码 检索条件 */
private String warehousesCode;
/** 仓库编码 检索条件 */
private String warehousesName;
/** 库位ID 检索条件 */
@Excel(name = "库位ID 检索条件")
private String locationId;
/** 库位名称 */
private String locationName;
/** 货主ID 检索条件 */
@Excel(name = "货主ID 检索条件")
private String ownerId;
private String ownerName;
/** 库存数量 */
@Excel(name = "库存数量")
private Long quantity;
......@@ -112,6 +121,54 @@ public class Inventory extends BaseEntity
/** 预警类型 */
private String alertType;
public String getOrderName() {
return orderName;
}
public void setOrderName(String orderName) {
this.orderName = orderName;
}
public String getMaterialName() {
return materialName;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
public String getWarehousesName() {
return warehousesName;
}
public void setWarehousesName(String warehousesName) {
this.warehousesName = warehousesName;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public String getWarehousesCode() {
return warehousesCode;
}
public void setWarehousesCode(String warehousesCode) {
this.warehousesCode = warehousesCode;
}
public String getOwnerName() {
return ownerName;
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
public String getWarehousesId() {
return warehousesId;
}
......@@ -330,16 +387,6 @@ public class Inventory extends BaseEntity
return updateUserCode;
}
public void setWarehousesCode(String warehousesCode)
{
this.warehousesCode = warehousesCode;
}
public String getWarehousesCode()
{
return warehousesCode;
}
public void setAlertType(String alertType)
{
this.alertType = alertType;
......@@ -356,10 +403,17 @@ public class Inventory extends BaseEntity
.append("id", getId())
.append("inventoryType", getInventoryType())
.append("orderId", getOrderId())
.append("orderName", getOrderName())
.append("materialId", getMaterialId())
.append("materialName", getMaterialName())
.append("batchId", getBatchId())
.append("warehousesId", getWarehousesId())
.append("warehousesName", getWarehousesName())
.append("warehousesCode", getWarehousesCode())
.append("locationId", getLocationId())
.append("locationName", getLocationName())
.append("ownerId", getOwnerId())
.append("ownerName", getOwnerName())
.append("quantity", getQuantity())
.append("lockedQuantity", getLockedQuantity())
.append("unitWeight", getUnitWeight())
......@@ -376,6 +430,7 @@ public class Inventory extends BaseEntity
.append("createUserCode", getCreateUserCode())
.append("updateTime", getUpdateTime())
.append("updateUserCode", getUpdateUserCode())
.append("alertType", getAlertType())
.toString();
}
}
......@@ -3,6 +3,7 @@ package com.ruoyi.inventory.domain;
import java.util.List;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
......@@ -14,6 +15,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author ruoyi
* @date 2025-12-03
*/
@Data
public class OutboundOrders extends BaseEntity
{
private static final long serialVersionUID = 1L;
......@@ -57,6 +59,8 @@ public class OutboundOrders extends BaseEntity
@Excel(name = "出库单状态1-草稿 2-已完成 3-已取消 字典,检索条件")
private Long orderStatus;
/** 出库日期 日期无时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "出库日期 日期无时间", width = 30, dateFormat = "yyyy-MM-dd")
......@@ -86,6 +90,8 @@ public class OutboundOrders extends BaseEntity
@Excel(name = "排序")
private Long sortNo;
private Long orderType;
/** 创建日期 */
@Excel(name = "创建日期")
private String createUserCode;
......@@ -97,230 +103,4 @@ public class OutboundOrders extends BaseEntity
/** 出库单明细信息 */
private List<OutboundOrderItems> outboundOrderItemsList;
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setOrderId(String orderId)
{
this.orderId = orderId;
}
public String getOrderId()
{
return orderId;
}
public void setSystemNo(String systemNo)
{
this.systemNo = systemNo;
}
public String getSystemNo()
{
return systemNo;
}
public void setOrderTypeId(String orderTypeId)
{
this.orderTypeId = orderTypeId;
}
public String getOrderTypeId()
{
return orderTypeId;
}
public void setBatchCode(String batchCode)
{
this.batchCode = batchCode;
}
public String getBatchCode()
{
return batchCode;
}
public void setWarehouseId(String warehouseId)
{
this.warehouseId = warehouseId;
}
public String getWarehouseId()
{
return warehouseId;
}
public void setOwnerId(String ownerId)
{
this.ownerId = ownerId;
}
public String getOwnerId()
{
return ownerId;
}
public void setOrderStatus(Long orderStatus)
{
this.orderStatus = orderStatus;
}
public Long getOrderStatus()
{
return orderStatus;
}
public void setInboundDate(Date inboundDate)
{
this.inboundDate = inboundDate;
}
public Date getInboundDate()
{
return inboundDate;
}
public void setDestination(String destination)
{
this.destination = destination;
}
public String getDestination()
{
return destination;
}
public void setTotalPlannedQuantity(Long totalPlannedQuantity)
{
this.totalPlannedQuantity = totalPlannedQuantity;
}
public Long getTotalPlannedQuantity()
{
return totalPlannedQuantity;
}
public void setTotalActualQuantity(Long totalActualQuantity)
{
this.totalActualQuantity = totalActualQuantity;
}
public Long getTotalActualQuantity()
{
return totalActualQuantity;
}
public void setTotalPackages(Long totalPackages)
{
this.totalPackages = totalPackages;
}
public Long getTotalPackages()
{
return totalPackages;
}
public void setIsUsed(Long isUsed)
{
this.isUsed = isUsed;
}
public Long getIsUsed()
{
return isUsed;
}
public void setSortNo(Long sortNo)
{
this.sortNo = sortNo;
}
public Long getSortNo()
{
return sortNo;
}
public void setCreateUserCode(String createUserCode)
{
this.createUserCode = createUserCode;
}
public String getCreateUserCode()
{
return createUserCode;
}
public void setUpdateUserCode(String updateUserCode)
{
this.updateUserCode = updateUserCode;
}
public String getUpdateUserCode()
{
return updateUserCode;
}
public List<OutboundOrderItems> getOutboundOrderItemsList()
{
return outboundOrderItemsList;
}
public void setOutboundOrderItemsList(List<OutboundOrderItems> outboundOrderItemsList)
{
this.outboundOrderItemsList = outboundOrderItemsList;
}
// 补充 warehouseName 的 getter/setter 方法
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
// 补充 ownerName 的 getter/setter 方法
public String getOwnerName() {
return ownerName;
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("orderId", getOrderId())
.append("systemNo", getSystemNo())
.append("orderTypeId", getOrderTypeId())
.append("batchCode", getBatchCode())
.append("warehouseId", getWarehouseId())
.append("warehouseName", getWarehouseName()) // 新增
.append("ownerId", getOwnerId())
.append("ownerName", getOwnerName()) // 新增
.append("orderStatus", getOrderStatus())
.append("inboundDate", getInboundDate())
.append("destination", getDestination())
.append("totalPlannedQuantity", getTotalPlannedQuantity())
.append("totalActualQuantity", getTotalActualQuantity())
.append("totalPackages", getTotalPackages())
.append("remark", getRemark())
.append("isUsed", getIsUsed())
.append("sortNo", getSortNo())
.append("createTime", getCreateTime())
.append("createUserCode", getCreateUserCode())
.append("updateTime", getUpdateTime())
.append("updateUserCode", getUpdateUserCode())
.append("outboundOrderItemsList", getOutboundOrderItemsList())
.toString();
}
}
\ No newline at end of file
......@@ -28,8 +28,11 @@ public class Owners extends BaseEntity
@Excel(name = "货主名称")
private String ownerName;
@Excel(name = "货主名称")
private String englishName;
/** 货主类型 1-供应商 2-客户 3-内部 检索条件 */
@Excel(name = "货主类型",dictType="owner_type")
@Excel(name = "货主类型")
private Long ownerType;
/** 联系人 */
......@@ -123,6 +126,14 @@ public class Owners extends BaseEntity
return contactPerson;
}
public String getEnglishName() {
return englishName;
}
public void setEnglishName(String englishName) {
this.englishName = englishName;
}
public void setContactPhone(String contactPhone)
{
this.contactPhone = contactPhone;
......@@ -237,6 +248,7 @@ public class Owners extends BaseEntity
.append("taxNumber", getTaxNumber())
.append("bankAccount", getBankAccount())
.append("isActive", getIsActive())
.append("english_name", getEnglishName())
.append("sortNo", getSortNo())
.append("createTime", getCreateTime())
.append("createUserCode", getCreateUserCode())
......
......@@ -26,6 +26,44 @@ public class StorageLocations extends BaseEntity
@Excel(name = "库位编码 检索条件")
private String locationCode;
/**
* 上架顺序(数字越小优先级越高)
*/
private String putawayOrder;
/**
* 拣货顺序(数字越小优先级越高)
*/
private String pickingOrder;
/**
* 库位使用(
*/
private Integer LocationUsage;
/**
* 库位处理状态(如:正常/冻结/锁定/禁用)
*/
private String locationHandling;
/**
* 周转需求(如:高周转/中周转/低周转)
*/
private String turnoverDemand;
/**
* 所属拣货区域(编码/名称)
*/
private String pickingArea;
/**
* 是否允许混放产品(true=允许,false=不允许)
*/
private String allowMixedProducts;
/**
* 是否允许混放批次(true=允许,false=不允许)
*/
private String allowMixedBatches;
/** 库位名称 检索条件 */
@Excel(name = "库位名称 检索条件")
private String locationName;
......@@ -77,7 +115,7 @@ public class StorageLocations extends BaseEntity
@Excel(name = "温区")
private String temperatureZone;
/** 应用状态1使用0未使用 */
/** 库位属性 */
@Excel(name = "应用状态1使用0未使用")
private Long isEnabled;
......
package com.ruoyi.inventory.domain.vo;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
/**
* 客户信息实体类
*
* @author 豆包编程助手
* @date 2025-12-11
*/
@Data
public class OwnerTemplateVO {
/**
* 客户编码/客户名称(根据业务场景调整,若为编码建议命名为 customerCode)
*/
@Excel(name = "客户")
private String ownerCode;
/**
* 激活状态(如:是/否、已激活/未激活,建议用布尔值或枚举)
*/
@Excel(name = "激活",dictType = "yorn")
private String isActive;
/**
* 客户类型(如:个人/企业、经销商/终端客户等)
*/
@Excel(name = "类型",dictType="owner_type")
private String ownerType;
/**
* 客户中文名称
*/
@Excel(name = "中文名称")
private String ownerName;
/**
* 客户英文名称
*/
@Excel(name = "英文名称")
private String englishName;
/**
* 地址1(主地址)
*/
@Excel(name = "地址1")
private String address;
/**
* 联系人1(主要联系人)
*/
@Excel(name = "电话1")
private String contactPerson;
/**
* 电话1(主要联系电话)
*/
@Excel(name = "联系人1")
private String contactPhone;
}
\ No newline at end of file
package com.ruoyi.inventory.domain.vo;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Log;
import lombok.Data;
/**
* 库位信息实体类
*
* @author 豆包编程助手
* @date 2025-12-11
*/
@Data
public class StorageLocationsLocationTemplateVO {
@Excel(name = "库位编码")
private String locationCode;
@Excel(name = "上架顺序")
private String putawayOrder;
@Excel(name = "拣货顺序")
private String pickingOrder;
@Excel(name = "库位使用",dictType = "location_usage")
private String LocationUsage;
@Excel(name = "库位类型",dictType = "location_type")
private String locationType;
@Excel(name = "库位属性",dictType = "is_enabled")
private String isEnabled;
@Excel(name = "库位处理")
private String locationHandling;
@Excel(name = "周转需求")
private String turnoverDemand;
@Excel(name = "上架区")
private String zoneCode;
@Excel(name = "拣货区")
private String pickingArea;
@Excel(name = "允许混放产品",dictType="yorn")
private String allowMixedProducts;
@Excel(name = "允许混放批次")
private String allowMixedBatches;
}
\ No newline at end of file
......@@ -70,7 +70,7 @@ public interface OutboundOrderItemsMapper
public int deleteOutboundOrderItemsById(String[] ids);
public int batchInsertOutboundOrderItems(List<InboundOrderItems> inboundOrderItems);
public int batchInsertOutboundOrderItems(List<OutboundOrderItems> inboundOrderItems);
}
......@@ -2,6 +2,7 @@ package com.ruoyi.inventory.mapper;
import java.util.List;
import com.ruoyi.common.annotation.SerialExecution;
import com.ruoyi.inventory.domain.OutboundOrderItems;
import com.ruoyi.inventory.domain.OutboundOrderLog;
......@@ -96,6 +97,7 @@ public interface OutboundOrderLogMapper
* @param outboundOrderItemsList 出库单明细列表
* @return 结果
*/
public int batchOutboundOrderLog(List<OutboundOrderLog> outboundOrderLogs);
}
......@@ -61,5 +61,6 @@ public interface OwnersMapper
*/
public int deleteOwnersByIds(String[] ids);
public int batchInsertOwners(List<Owners> list);
}
......@@ -97,4 +97,7 @@ public interface StorageLocationsMapper
* @return 库位集合
*/
List<StorageLocations> getStorageLocationsList(StorageLocations storageLocations);
int batchInsertStorageLocations(List<StorageLocations> storageLocations);
}
......@@ -70,6 +70,4 @@ public interface IOutboundOrderItemsService
public int deleteOutboundOrderItemsById(String id);
@Transactional(rollbackFor = Exception.class)
String importOutoundOrders(List<OutboundTemplateVO> inboundOrdersList, Boolean isUpdateSupport, String operName);
}
......@@ -4,6 +4,8 @@ import java.util.List;
import java.util.Map;
import com.ruoyi.inventory.domain.OutboundOrders;
import com.ruoyi.inventory.domain.vo.OutboundTemplateVO;
import org.springframework.transaction.annotation.Transactional;
/**
* 出库单主Service接口
......@@ -74,4 +76,7 @@ public interface IOutboundOrdersService
public List<Map<String,String>> outboundOrdersTopTenByAmount();
public String outboundOrdersCount();
@Transactional(rollbackFor = Exception.class)
String importOutboundOrders(List<OutboundTemplateVO> inboundOrdersList, Boolean isUpdateSupport, String operName);
}
......@@ -2,6 +2,7 @@ package com.ruoyi.inventory.service;
import java.util.List;
import com.ruoyi.inventory.domain.Owners;
import com.ruoyi.inventory.domain.vo.OwnerTemplateVO;
/**
* 货主信息Service接口
......@@ -42,7 +43,7 @@ public interface IOwnersService
* @param ownersList 货主信息
* @return 结果
*/
public String importOwners(List<Owners> ownersList, Boolean isUpdateSupport, String operName);
public String importOwners(List<OwnerTemplateVO> ownersList, Boolean isUpdateSupport, String operName);
/**
* 修改货主信息
......@@ -67,4 +68,5 @@ public interface IOwnersService
* @return 结果
*/
public int deleteOwnersById(String id);
}
......@@ -5,6 +5,9 @@ import java.util.List;
import java.util.Map;
import com.ruoyi.inventory.domain.StorageLocations;
import com.ruoyi.inventory.domain.vo.OutboundTemplateVO;
import com.ruoyi.inventory.domain.vo.OwnerTemplateVO;
import com.ruoyi.inventory.domain.vo.StorageLocationsLocationTemplateVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -97,4 +100,7 @@ public interface IStorageLocationsService
* @return 库位集合
*/
public List<StorageLocations> getStorageLocationsList(StorageLocations storageLocations);
public String importStorageLocationsLocation(List<StorageLocationsLocationTemplateVO> ownersList, Boolean isUpdateSupport, String operName);
}
......@@ -4,6 +4,7 @@ import java.util.*;
import java.util.stream.Collectors;
import com.ruoyi.common.annotation.SerialExecution;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.inventory.domain.InboundOrderItems;
import com.ruoyi.inventory.domain.OutboundOrderItems;
......@@ -139,6 +140,11 @@ public class InventoryServiceImpl implements IInventoryService
for (OutboundOrderItems outboundOrderItem : outboundOrderItems) {
OutboundOrderLog outboundOrderLog = outboundOrderLogMapper.selectOutboundOrderLogById(outboundOrderItem.getId());
// ========== 新增空值校验(兜底) ==========
if (outboundOrderLog == null) {
throw new ServiceException("明细ID【" + outboundOrderItem.getId() + "】对应的出库日志不存在");
}
// ==========================================
Inventory inventory =inventoryMapper.selectInventoryById(outboundOrderLog.getInventoryId());
inventory.setQuantity(inventory.getQuantity()-outboundOrderItem.getActualQuantity());
if (inventory.getQuantity()==0){
......
......@@ -109,154 +109,5 @@ public class OutboundOrderItemsServiceImpl implements IOutboundOrderItemsService
return outboundOrderItemsMapper.deleteOutboundOrderItemsById(id);
}
/**
* 导入入库单明细信息
*
* @param inboundOrdersList,isUpdateSupport,operName 入库单数据信息
* @return 结果
*/
@Transactional(rollbackFor = Exception.class)
@Override
public String importOutoundOrders(List<OutboundTemplateVO> inboundOrdersList, Boolean isUpdateSupport, String operName) {
if (StringUtils.isNull(inboundOrdersList) || inboundOrdersList.size() == 0) {
throw new ServiceException("导入数据不能为空!");
}
// 2. 初始化统计变量
int totalMainSuccess = 0; // 成功的主表数量
int totalMainFailure = 0; // 失败的主表数量
int totalItemSuccess = 0; // 成功的明细数量
int totalItemFailure = 0; // 失败的明细数量
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
Date now = DateUtils.getNowDate();
Long userId = SecurityUtils.getUserId();
String operId = userId.toString();
// 3. 按入库单号分组(核心:同一入库单的多条明细归为一组)
Map<String, List<OutboundTemplateVO>> orderGroupMap = inboundOrdersList.stream()
.filter(vo -> StringUtils.isNotBlank(vo.getOrderId())) // 过滤无入库单号的无效行
.collect(Collectors.groupingBy(OutboundTemplateVO::getOrderId));
// 4. 遍历每个入库单分组处理
for (Map.Entry<String, List<OutboundTemplateVO>> entry : orderGroupMap.entrySet()) {
String orderId = entry.getKey();
List<OutboundTemplateVO> voList = entry.getValue();
OutboundOrderItems mainDO = null;
List<InboundOrderItems> itemDOList = new ArrayList<>();
try {
// 4.1 处理主表(每个入库单号只处理一次主表)
OutboundTemplateVO firstVO = voList.get(0); // 取第一条VO的主表信息
// 检查入库单是否已存在
OutboundOrderItems existMain = outboundOrderItemsMapper.selectOutboundOrderItemsById(orderId);
if (existMain != null) {
if (!isUpdateSupport) {
// 不支持更新,跳过该入库单
totalMainFailure++;
failureMsg.append(String.format("入库单号【%s】已存在,且不支持更新,跳过导入;\n", orderId));
totalItemFailure += voList.size(); // 该单的明细全部失败
continue;
}
// 支持更新,复用已有主表ID
mainDO = existMain;
// 复制VO中的主表字段到已有主表(只更新可修改的字段)
BeanUtils.copyProperties(firstVO, mainDO, "id", "createBy", "createTime"); // 排除不可更新字段
mainDO.setUpdateBy(operId);
mainDO.setUpdateTime(now);
mainDO.setUpdateUserCode(operId);
// 更新主表
outboundOrderItemsMapper.updateOutboundOrderItems(mainDO);
totalMainSuccess++;
successMsg.append(String.format("入库单号【%s】已更新;\n", orderId));
} else {
// 新增主表
mainDO = new OutboundOrderItems();
// 复制主表字段(只复制主表相关字段,避免物料字段污染)
BeanUtils.copyProperties(firstVO, mainDO,
"sapNo", "materialName", "plannedQuantity", "actualQuantity",
"plannedPackages", "materialUnit", "materialRemark"); // 排除子表字段
// 填充主表必填字段
mainDO.setId(UUID.randomUUID().toString());
mainDO.setOrderId(orderId);
mainDO.setCreateBy(operId);
mainDO.setCreateTime(now);
mainDO.setCreateUserCode(operId);
mainDO.setUpdateBy(operId);
mainDO.setUpdateTime(now);
mainDO.setUpdateUserCode(operId);
// 设置默认值
if (mainDO.getSortNo() == null) {
mainDO.setSortNo(0L);
}
if (mainDO.getItemStatus() == null) {
mainDO.setItemStatus(1L); // 默认草稿状态
}
// 插入主表
outboundOrderItemsMapper.insertOutboundOrderItems(mainDO);
totalMainSuccess++;
successMsg.append(String.format("入库单号【%s】已新增;\n", orderId));
}
// 4.2 处理子表明细(每条VO对应一条明细)
for (OutboundTemplateVO vo : voList) {
InboundOrderItems itemDO = new InboundOrderItems();
// 复制子表字段(物料相关)
BeanUtils.copyProperties(vo, itemDO,
"orderId", "systemNo", "orderTypeId", "batchId"); // 排除主表字段
// 填充明细必填字段
itemDO.setId(UUID.randomUUID().toString());
Materials materials = new Materials();
materials.setSapNo(vo.getSapNo());
itemDO.setMaterialId(vo.getSapNo());
itemDO.setOrderId(orderId); // 关联入库单号
itemDO.setBatchId(mainDO.getBatchCode());
itemDO.setInboundOrderId(mainDO.getId()); // 关联主表ID(核心!)
itemDO.setCreateBy(operId);
itemDO.setCreateTime(now);
itemDO.setCreateUserCode(operId);
itemDO.setSortNo(0L);
// 校验物料字段(示例:必填sapNo)
if (StringUtils.isBlank(vo.getSapNo())) {
throw new ServiceException(String.format("入库单号【%s】的物料SAP号为空,明细导入失败", orderId));
}
System.out.println(itemDO);
itemDOList.add(itemDO);
}
// 4.3 批量插入明细
if (!CollectionUtils.isEmpty(itemDOList)) {
int itemSuccess = outboundOrderItemsMapper.batchInsertOutboundOrderItems(itemDOList);
totalItemSuccess += itemSuccess;
totalItemFailure += (itemDOList.size() - itemSuccess);
successMsg.append(String.format("入库单号【%s】成功导入%d条物料明细;\n", orderId, itemSuccess));
if (itemDOList.size() - itemSuccess > 0) {
failureMsg.append(String.format("入库单号【%s】有%d条物料明细导入失败;\n", orderId, itemDOList.size() - itemSuccess));
}
}
} catch (Exception e) {
// 单个入库单处理失败,统计错误
totalMainFailure++;
totalItemFailure += voList.size();
failureMsg.append(String.format("入库单号【%s】处理失败:%s;\n", orderId, e.getMessage()));
}
}
// 5. 结果汇总
if (totalMainFailure > 0 || totalItemFailure > 0) {
// 有失败数据,抛出异常提示
String finalFailureMsg = String.format(
"导入结果:成功新增/更新%d个入库单,失败%d个;成功导入%d条明细,失败%d条。失败详情:%s",
totalMainSuccess, totalMainFailure, totalItemSuccess, totalItemFailure, failureMsg.toString()
);
throw new ServiceException(finalFailureMsg);
} else {
// 全部成功
String finalSuccessMsg = String.format(
"恭喜您,数据已全部导入成功!共处理%d个入库单,成功导入%d条物料明细。详情:%s",
totalMainSuccess, totalItemSuccess, successMsg.toString()
);
return finalSuccessMsg;
}
}
}
package com.ruoyi.inventory.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.inventory.domain.vo.OwnerTemplateVO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.OwnersMapper;
......@@ -21,8 +26,7 @@ import com.ruoyi.inventory.service.IOwnersService;
* @date 2025-11-28
*/
@Service
public class OwnersServiceImpl implements IOwnersService
{
public class OwnersServiceImpl implements IOwnersService {
@Autowired
private OwnersMapper ownersMapper;
......@@ -33,8 +37,7 @@ public class OwnersServiceImpl implements IOwnersService
* @return 货主信息
*/
@Override
public Owners selectOwnersById(String id)
{
public Owners selectOwnersById(String id) {
return ownersMapper.selectOwnersById(id);
}
......@@ -45,8 +48,7 @@ public class OwnersServiceImpl implements IOwnersService
* @return 货主信息
*/
@Override
public List<Owners> selectOwnersList(Owners owners)
{
public List<Owners> selectOwnersList(Owners owners) {
return ownersMapper.selectOwnersList(owners);
}
......@@ -57,40 +59,36 @@ public class OwnersServiceImpl implements IOwnersService
* @return 结果
*/
@Override
public int insertOwners(Owners owners)
{
public int insertOwners(Owners owners) {
Long userId = SecurityUtils.getUserId();
String operId = userId.toString();
Date now = DateUtils.getNowDate();
// 填充创建人、创建时间、修改人、修改时间
owners.setId(UUID.randomUUID().toString());
owners.setCreateBy(operId);
owners.setCreateTime(now);
// 填充创建用户编码和更新用户编码
owners.setCreateUserCode(operId);
// 设置默认值
if (owners.getIsActive() == null)
{
if (owners.getIsActive() == null) {
owners.setIsActive(1L); // 默认激活
}
if (owners.getIsUsed() == null)
{
owners.setIsUsed(0L); // 默认未删除
if (owners.getIsUsed() == null) {
owners.setIsUsed(1L); // 默认未删除
}
if (owners.getSortNo() == null)
{
if (owners.getSortNo() == null) {
owners.setSortNo(0L); // 默认排序号
}
return ownersMapper.insertOwners(owners);
}
@Override
public String importOwners(List<Owners> ownersList, Boolean isUpdateSupport, String operName)
{
if (StringUtils.isNull(ownersList) || ownersList.size() == 0)
{
public String importOwners(List<OwnerTemplateVO> ownersList, Boolean isUpdateSupport, String operName) {
if (CollectionUtils.isEmpty(ownersList)) {
throw new ServiceException("导入用户数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
......@@ -99,48 +97,73 @@ public class OwnersServiceImpl implements IOwnersService
// 获取当前登录用户ID
Long userId = SecurityUtils.getUserId();
String operId = userId.toString();
for (Owners owners : ownersList)
{
try
{
// 批量插入的有效数据集合
List<Owners> batchInsertList = new ArrayList<>();
for (OwnerTemplateVO ownerTemp : ownersList) {
try {
Owners owners = new Owners();
// 处理激活状态转换
BeanUtils.copyProperties(ownerTemp, owners);
if (ownerTemp.getIsActive()!=null) {
owners.setIsActive(Long.valueOf(ownerTemp.getIsActive()));
}
// 类型转换
if (ownerTemp.getOwnerType()!=null) {
owners.setOwnerType(Long.valueOf(ownerTemp.getOwnerType()));
}
// 生成UUID主键
owners.setId(UUID.randomUUID().toString());
// 填充创建人、创建时间、修改人、修改时间
// 填充公共字段
owners.setCreateBy(operId);
owners.setCreateTime(now);
// 填充创建用户编码和更新用户编码
owners.setCreateUserCode(operId);
// 设置默认值
if (owners.getIsActive() == null)
{
if (owners.getIsActive() == null) {
owners.setIsActive(1L); // 默认激活
}
if (owners.getIsUsed() == null)
{
owners.setIsUsed(0L); // 默认未删除
if (owners.getIsUsed() == null) {
owners.setIsUsed(1L); // 默认未删除
}
if (owners.getSortNo() == null)
{
if (owners.getSortNo() == null) {
owners.setSortNo(0L); // 默认排序号
}
ownersMapper.insertOwners(owners);
// 加入批量集合
batchInsertList.add(owners);
successNum++;
successMsg.append("<br/>" + successNum + "、用户 " + owners.getOwnerName() + " 导入成功");
}
catch (Exception e)
{
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、账号 " + owners.getOwnerName() + " 导入失败:";
String ownerName = ownerTemp.getOwnerCode() != null ? ownerTemp.getOwnerCode() : "未知名称";
String msg = "<br/>" + failureNum + "、账号 " + ownerName + " 导入失败:";
failureMsg.append(msg + e.getMessage());
// 异常数据不加入批量集合,继续处理下一条
continue;
}
}
// 批量插入有效数据(如果有)
if (!CollectionUtils.isEmpty(batchInsertList)) {
try {
ownersMapper.batchInsertOwners(batchInsertList);
} catch (Exception e) {
// 批量插入失败时,统计失败数量并抛出异常
failureNum += batchInsertList.size();
successNum -= batchInsertList.size();
failureMsg.insert(0, String.format("<br/>批量插入失败:%s,已失败数据条数追加 %d 条",
e.getMessage(), batchInsertList.size()));
}
}
if (failureNum > 0)
{
// 处理结果反馈
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确");
throw new ServiceException(failureMsg.toString());
}
else
{
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
......@@ -188,4 +211,5 @@ public class OwnersServiceImpl implements IOwnersService
{
return ownersMapper.deleteOwnersById(id);
}
}
package com.ruoyi.inventory.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.ruoyi.common.core.domain.entity.Materials;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.inventory.domain.Owners;
import com.ruoyi.inventory.domain.StorageLocationsCategory;
import com.ruoyi.inventory.domain.vo.StorageLocationsLocationTemplateVO;
import com.ruoyi.inventory.mapper.MaterialsMapper;
import com.ruoyi.inventory.mapper.StorageLocationsCategoryMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.StorageLocationsMapper;
......@@ -222,4 +229,91 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
List<StorageLocations> storageLocations1 =storageLocationsMapper.getStorageLocationsList(storageLocations);
return storageLocations1;
}
@Override
public String importStorageLocationsLocation(List<StorageLocationsLocationTemplateVO> storageLocationsLocationTemplateVOS,
Boolean isUpdateSupport,
String operName) {
// 空数据校验
if (CollectionUtils.isEmpty(storageLocationsLocationTemplateVOS)) {
throw new ServiceException("导入库位数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
Date now = DateUtils.getNowDate();
// 获取当前登录用户ID
Long userId = SecurityUtils.getUserId();
String operId = userId.toString();
// 批量插入数据集合
List<StorageLocations> batchInsertList = new ArrayList<>();
for (StorageLocationsLocationTemplateVO templateVO : storageLocationsLocationTemplateVOS) {
try {
StorageLocations storageLocations = new StorageLocations();
// 拷贝基础属性
BeanUtils.copyProperties(templateVO, storageLocations);
// 字段类型转换与赋值
storageLocations.setId(UUID.randomUUID().toString());
if (StringUtils.isNotBlank(templateVO.getLocationUsage())) {
storageLocations.setLocationUsage(Integer.valueOf(templateVO.getLocationUsage()));
}
if (StringUtils.isNotBlank(templateVO.getIsEnabled())) {
storageLocations.setIsEnabled(Long.valueOf(templateVO.getIsEnabled()));
}
// 填充公共字段
storageLocations.setCreateBy(operId);
storageLocations.setCreateTime(now);
storageLocations.setCreateUserCode(operId);
// 设置默认值
if (storageLocations.getIsUsed() == null) {
storageLocations.setIsUsed(1L); // 默认未删除
}
if (storageLocations.getSortNo() == null) {
storageLocations.setSortNo(0L); // 默认排序号
}
// 加入批量集合
batchInsertList.add(storageLocations);
successNum++;
String locationName = storageLocations.getLocationName() != null ? storageLocations.getLocationName() : "未知名称";
successMsg.append("<br/>" + successNum + "、库位 " + locationName + " 导入成功");
} catch (Exception e) {
failureNum++;
String locationName = templateVO.getLocationCode() != null ? templateVO.getLocationCode() : "未知名称";
String msg = "<br/>" + failureNum + "、库位 " + locationName + " 导入失败:";
failureMsg.append(msg + e.getMessage());
// 异常数据跳过,继续处理下一条
continue;
}
}
// 执行批量插入(有有效数据时)
if (!CollectionUtils.isEmpty(batchInsertList)) {
try {
storageLocationsMapper.batchInsertStorageLocations(batchInsertList);
} catch (Exception e) {
// 批量插入失败,更新失败统计
failureNum += batchInsertList.size();
successNum -= batchInsertList.size();
failureMsg.insert(0, String.format("<br/>批量插入失败:%s,失败条数追加 %d 条",
e.getMessage(), batchInsertList.size()));
}
}
// 结果反馈处理
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
}
......@@ -9,9 +9,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="inventoryType" column="inventory_type" />
<result property="orderId" column="order_id" />
<result property="materialId" column="material_id" />
<result property="materialName" column="material_name"/>
<result property="batchId" column="batch_id" />
<result property="warehousesCode" column="warehouses_code" />
<result property="warehousesName" column="warehouses_name"/>
<result property="locationId" column="location_id" />
<result property="locationName" column="location_name"/>
<result property="ownerId" column="owner_id" />
<result property="quantity" column="quantity" />
<result property="lockedQuantity" column="locked_quantity" />
......@@ -30,6 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="updateUserCode" column="update_user_code" />
<result property="warehousesId" column="warehouses_id" />
<result property="oderCode" column="order_code" />
</resultMap>
<resultMap type="com.ruoyi.inventory.domain.TO.StocktakeItemsTo" id="StocktakeItemsResult">
......@@ -212,14 +216,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<select id="listByMaterialId" parameterType="String" resultMap="InventoryResult">
<include refid="selectInventoryVo"/>
where 1=1
SELECT
i.id,
i.inventory_type,
i.warehouses_id,
w.warehouses_name,
i.order_id,
i.material_id,
m.material_name,
i.batch_id,
i.location_id,
sl.location_name,
i.owner_id,
i.quantity,
i.locked_quantity,
i.unit_weight,
i.total_weight,
i.total_volume,
i.production_date,
i.expiration_date,
i.inventory_status,
i.last_inbound_time,
i.last_outbound_time,
i.is_used,
i.sort_no,
i.create_time,
i.create_user_code,
i.update_time,
i.update_user_code
FROM inventory i
LEFT JOIN materials m ON i.material_id = m.id AND m.is_used = 1
LEFT JOIN warehouses w ON i.warehouses_id = w.id AND w.is_enabled = 1 AND w.is_used = 1
LEFT JOIN storage_locations sl ON i.location_id = sl.id AND sl.is_enabled = 1 AND sl.is_used = 1
WHERE 1=1
<if test="materialId != null and materialId.trim() != ''">
and material_id = #{materialId}
AND i.material_id = #{materialId}
</if>
<![CDATA[
and inventory_status = '1'
]]>
AND i.inventory_status = '1'
]]>
ORDER BY i.expiration_date ASC
</select>
<insert id="insertInventory" parameterType="Inventory">
insert into inventory
......@@ -345,8 +381,8 @@ and inventory_status = '1'
sum(i.quantity) as value
from inventory i
left join materials m on i.material_id = m.id
where i.is_used = 1 and i.production_date &gt;= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and i.production_date &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
where i.is_used = 1 and i.last_inbound_time &gt;= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and i.last_inbound_time &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
group by m.material_name
order by sum(i.quantity) desc
</select>
......@@ -357,8 +393,8 @@ and inventory_status = '1'
sum(i.quantity)*i.unit_price as value
from inventory i
left join materials m on i.material_id = m.id
where i.is_used = 1 and i.production_date &gt;= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and i.production_date &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
where i.is_used = 1 and i.last_inbound_time &gt;= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and i.last_inbound_time &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
group by m.material_name
order by sum(i.quantity)*i.unit_price desc
</select>
......
......@@ -257,7 +257,7 @@
o.order_id as main_order_id
from outbound_order_items oi
left join outbound_orders o on oi.outbound_order_id = o.id
left join materials m on oi.material_id = m.sap_no
left join materials m on oi.material_id = m.id
left join warehouses w on oi.warehouse_id = w.id
left join storage_locations sl on oi.location_id = sl.id
<where>
......
......@@ -9,6 +9,7 @@
<result property="orderId" column="order_id" />
<result property="systemNo" column="system_no" />
<result property="orderTypeId" column="order_type_id" />
<result property="orderType" column="order_type" /> <!-- 新增order_type字段映射 -->
<result property="batchCode" column="batch_code" />
<result property="warehouseId" column="warehouse_id" />
<result property="warehouseName" column="warehouse_name" />
......@@ -74,6 +75,7 @@
oo.order_id,
oo.system_no,
oo.order_type_id,
oo.order_type, -- 新增order_type字段查询
oo.batch_code,
oo.warehouse_id,
w.warehouses_name as warehouse_name,
......@@ -103,6 +105,7 @@
<if test="orderId != null and orderId != ''"> and oo.order_id = #{orderId}</if>
<if test="systemNo != null and systemNo != ''"> and oo.system_no = #{systemNo}</if>
<if test="orderTypeId != null and orderTypeId != ''"> and oo.order_type_id = #{orderTypeId}</if>
<if test="orderType != null and orderType != ''"> and oo.order_type = #{orderType}</if> <!-- 新增order_type查询条件 -->
<if test="batchCode != null and batchCode != ''"> and oo.batch_code = #{batchCode}</if>
<if test="warehouseId != null and warehouseId != ''"> and oo.warehouse_id = #{warehouseId}</if>
<if test="ownerId != null and ownerId != ''"> and oo.owner_id = #{ownerId}</if>
......@@ -123,9 +126,9 @@
oo.order_id,
oo.system_no,
oo.order_type_id,
oo.order_type, -- 新增order_type字段查询
oo.batch_code,
oo.warehouse_id,
w.warehouses_name as warehouse_name,
oo.owner_id,
o.owner_name,
oo.order_status,
......@@ -190,6 +193,7 @@
<if test="orderId != null">order_id,</if>
<if test="systemNo != null">system_no,</if>
<if test="orderTypeId != null">order_type_id,</if>
<if test="orderType != null">order_type,</if> <!-- 新增order_type字段插入 -->
<if test="batchCode != null">batch_code,</if>
<if test="warehouseId != null">warehouse_id,</if>
<if test="ownerId != null">owner_id,</if>
......@@ -212,6 +216,7 @@
<if test="orderId != null">#{orderId},</if>
<if test="systemNo != null">#{systemNo},</if>
<if test="orderTypeId != null">#{orderTypeId},</if>
<if test="orderType != null">#{orderType},</if> <!-- 新增order_type值插入 -->
<if test="batchCode != null">#{batchCode},</if>
<if test="warehouseId != null">#{warehouseId},</if>
<if test="ownerId != null">#{ownerId},</if>
......@@ -237,6 +242,7 @@
<if test="orderId != null">order_id = #{orderId},</if>
<if test="systemNo != null">system_no = #{systemNo},</if>
<if test="orderTypeId != null">order_type_id = #{orderTypeId},</if>
<if test="orderType != null">order_type = #{orderType},</if> <!-- 新增order_type字段更新 -->
<if test="batchCode != null">batch_code = #{batchCode},</if>
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
<if test="ownerId != null">owner_id = #{ownerId},</if>
......@@ -303,7 +309,7 @@
m.material_name as name,
sum(ooi.actual_quantity) as value
from outbound_order_items ooi
left join materials m on ooi.material_id = m.sap_no
left join materials m on ooi.material_id = m.id
where ooi.is_used = 1 and ooi.shipped_at &gt;= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and ooi.shipped_at &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
group by m.material_name
......@@ -316,7 +322,7 @@
m.material_name as name,
sum(ooi.actual_quantity)*ooi.unit_price as value
from outbound_order_items ooi
left join materials m on ooi.material_id = m.sap_no
left join materials m on ooi.material_id = m.id
where ooi.is_used = 1 and ooi.shipped_at &gt;= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and ooi.shipped_at &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
group by m.material_name
......
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.inventory.mapper.OwnersMapper">
<resultMap type="Owners" id="OwnersResult">
......@@ -19,20 +19,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="sortNo" column="sort_no" />
<result property="createTime" column="create_time" />
<result property="createUserCode" column="create_user_code" />
<result property="englishName" column="english_name" />
<result property="updateTime" column="update_time" />
<result property="updateUserCode" column="update_user_code" />
<result property="isUsed" column="is_used" />
</resultMap>
<sql id="selectOwnersVo">
select id, owner_code, owner_name, owner_type, contact_person, contact_phone, email, address, tax_number, bank_account, is_active, sort_no, create_time, create_user_code, update_time, update_user_code, is_used from owners
select id, owner_code, owner_name, owner_type, english_name ,contact_person, contact_phone, email, address, tax_number, bank_account, is_active, sort_no, create_time, create_user_code, update_time, update_user_code, is_used from owners
</sql>
<select id="selectOwnersList" parameterType="Owners" resultMap="OwnersResult">
<include refid="selectOwnersVo"/>
where is_used = 0
where is_used = 1
<if test="ownerCode != null and ownerCode != ''"> and owner_code = #{ownerCode}</if>
<if test="ownerName != null and ownerName != ''"> and owner_name like concat('%', #{ownerName}, '%')</if>
<!-- 新增englishName查询条件 -->
<if test="englishName != null and englishName != ''"> and english_name like concat('%', #{englishName}, '%')</if>
<if test="ownerType != null "> and owner_type = #{ownerType}</if>
<if test="contactPerson != null and contactPerson != ''"> and contact_person = #{contactPerson}</if>
<if test="contactPhone != null and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
......@@ -59,6 +63,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ownerCode != null">owner_code,</if>
<if test="ownerName != null">owner_name,</if>
<if test="ownerType != null">owner_type,</if>
<!-- 新增english_name插入字段 -->
<if test="englishName != null">english_name,</if>
<if test="contactPerson != null">contact_person,</if>
<if test="contactPhone != null">contact_phone,</if>
<if test="email != null">email,</if>
......@@ -77,6 +83,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ownerCode != null">#{ownerCode},</if>
<if test="ownerName != null">#{ownerName},</if>
<if test="ownerType != null">#{ownerType},</if>
<!-- 新增englishName插入值 -->
<if test="englishName != null">#{englishName},</if>
<if test="contactPerson != null">#{contactPerson},</if>
<if test="contactPhone != null">#{contactPhone},</if>
<if test="email != null">#{email},</if>
......@@ -92,12 +100,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<!-- 新增批量插入方法 -->
<insert id="batchInsertOwners" parameterType="java.util.List">
insert into owners (
id, owner_code, owner_name, owner_type, english_name,
contact_person, contact_phone, email, address, tax_number,
bank_account, is_active, sort_no, create_time, create_user_code,
update_time, update_user_code, is_used
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id}, #{item.ownerCode}, #{item.ownerName}, #{item.ownerType}, #{item.englishName},
#{item.contactPerson}, #{item.contactPhone}, #{item.email}, #{item.address}, #{item.taxNumber},
#{item.bankAccount}, #{item.isActive}, #{item.sortNo}, #{item.createTime}, #{item.createUserCode},
#{item.updateTime}, #{item.updateUserCode}, #{item.isUsed}
)
</foreach>
</insert>
<update id="updateOwners" parameterType="Owners">
update owners
<trim prefix="SET" suffixOverrides=",">
<if test="ownerCode != null">owner_code = #{ownerCode},</if>
<if test="ownerName != null">owner_name = #{ownerName},</if>
<if test="ownerType != null">owner_type = #{ownerType},</if>
<!-- 新增english_name更新字段 -->
<if test="englishName != null">english_name = #{englishName},</if>
<if test="contactPerson != null">contact_person = #{contactPerson},</if>
<if test="contactPhone != null">contact_phone = #{contactPhone},</if>
<if test="email != null">email = #{email},</if>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论