Merge branch 'wms_dev' into wms_dev_hbbf

# Conflicts:
#	mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/UserServiceFeign.java
#	mhd_oms/pom.xml
This commit is contained in:
王奎兴
2026-02-09 14:29:47 +08:00
228 changed files with 17780 additions and 684 deletions
@@ -275,6 +275,12 @@ public interface SystemServiceFeign {
@GetMapping("/associationWarehouseApi/setWarehouseInfo") @GetMapping("/associationWarehouseApi/setWarehouseInfo")
public AjaxResult setWarehouseInfo(@RequestBody AssociationWarehouseFeign associationWarehouseFeign); public AjaxResult setWarehouseInfo(@RequestBody AssociationWarehouseFeign associationWarehouseFeign);
/**
* 查询仓库关联的用户ID集合
*/
@GetMapping("/associationWarehouseApi/queryListCorrelationId")
public AjaxResult queryListCorrelationId(@RequestParam(value = "warehouseId", required = false) Long warehouseId);
/** /**
* 根据code编码查询费用科目 * 根据code编码查询费用科目
@@ -109,6 +109,13 @@ public interface UserServiceFeign {
@GetMapping("/userApi/getInfo/{userId}") @GetMapping("/userApi/getInfo/{userId}")
public AjaxResult getInfo(@PathVariable("userId") Long userId); public AjaxResult getInfo(@PathVariable("userId") Long userId);
/**
* 根据用户ID查询用户详细信息
*/
@ApiOperation("根据用户ID查询用户详细信息")
@GetMapping("/userApi/getInfoByName/{userName}")
public AjaxResult getInfoByName(@PathVariable("userName") String userName);
/** /**
* 查询车辆绑定的承运人列表 * 查询车辆绑定的承运人列表
@@ -3,12 +3,15 @@ package com.mhd.system.api;
import com.mhd.common.core.constant.ServiceNameConstants; import com.mhd.common.core.constant.ServiceNameConstants;
import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.system.api.domain.MaterialBaseInfoFeign; import com.mhd.system.api.domain.MaterialBaseInfoFeign;
import com.mhd.system.api.domain.MaterialInventoryDTO;
import com.mhd.system.api.domain.NoticeOrderDTO; import com.mhd.system.api.domain.NoticeOrderDTO;
import com.mhd.system.api.factory.RemoteTicketFeignFallbackFactory; import com.mhd.system.api.factory.RemoteTicketFeignFallbackFactory;
import com.mhd.system.api.feign.FeignAutoConfiguration; import com.mhd.system.api.feign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Map;
/** /**
* @author ZhouGY * @author ZhouGY
* @title WmsServiceFeign * @title WmsServiceFeign
@@ -57,4 +60,9 @@ public interface WmsServiceFeign {
@PostMapping("/noticeOrderApi/insert") @PostMapping("/noticeOrderApi/insert")
public AjaxResult stockOutOrInInsert(@RequestBody NoticeOrderDTO noticeOrderDTO); public AjaxResult stockOutOrInInsert(@RequestBody NoticeOrderDTO noticeOrderDTO);
/**
* 查询物料库存列表不分页
*/
@GetMapping("/materialInventoryApi/listAll")
public AjaxResult materialInventoryApiListAll(MaterialInventoryDTO materialInventoryDTO);
} }
@@ -44,6 +44,10 @@ public class BatchDetailFeignPO extends BaseVOEntity{
@Excel(name = "批次标签") @Excel(name = "批次标签")
private String batchLabels; private String batchLabels;
@ApiModelProperty("字段名称")
@Excel(name = "字段名称")
private String fieldName;
@ApiModelProperty("输入控制: 1-必填 2-可选") @ApiModelProperty("输入控制: 1-必填 2-可选")
@Excel(name = "输入控制: 1-必填 2-可选") @Excel(name = "输入控制: 1-必填 2-可选")
private String inputControl; private String inputControl;
@@ -56,6 +60,10 @@ public class BatchDetailFeignPO extends BaseVOEntity{
@Excel(name = "属性选项") @Excel(name = "属性选项")
private String attributeOption; private String attributeOption;
@ApiModelProperty("是否显示: 0-不显示 1-显示")
@Excel(name = "是否显示: 0-不显示 1-显示")
private Integer isDisplay;
@ApiModelProperty("备注") @ApiModelProperty("备注")
@Excel(name = "备注") @Excel(name = "备注")
private String remark; private String remark;
@@ -181,5 +181,35 @@ public class MaterialBaseInfoFeign extends BaseVOEntity{
@ApiModelProperty("是否公用: 1-是 2-否") @ApiModelProperty("是否公用: 1-是 2-否")
@Excel(name = "是否公用: 1-是 2-否") @Excel(name = "是否公用: 1-是 2-否")
private Integer common; private Integer common;
@ApiModelProperty("SKU码")
private String skuCode;
@ApiModelProperty("单价")
private BigDecimal unitPrice;
@ApiModelProperty("原产国")
private String originCountry;
@ApiModelProperty("HS码")
private String hsCode;
@ApiModelProperty("申报单位")
private String declarationUnit;
@ApiModelProperty("法定单位")
private String statutoryUnit;
@ApiModelProperty("法定第二单位")
private String statutorySecondUnit;
/**
* 规格型号
*/
@ApiModelProperty("规格型号")
@Excel(name = "规格型号")
private String specificationModel;
@ApiModelProperty("币制")
private String currency;
} }
@@ -0,0 +1,149 @@
package com.mhd.system.api.domain;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 物料库存对象 material_inventory
*
* @author gen
* @date 2024-05-29
*/
@Data
public class MaterialInventoryDTO {
private static final long serialVersionUID = 1L;
@ApiModelProperty("物料库存id")
private Long materialInventoryId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("物料基础信息id")
@Excel(name = "物料基础信息id")
private Long materialBaseInfoId;
@ApiModelProperty("上架单物料明细id")
@Excel(name = "上架单物料明细id")
private Long materialDetailId;
@ApiModelProperty("仓库id")
@Excel(name = "仓库id")
private Long warehouseId;
@ApiModelProperty("仓库编码")
@Excel(name = "仓库编码")
private String warehouseCode;
@ApiModelProperty("仓库名称")
@Excel(name = "仓库名称")
private String warehouseName;
@ApiModelProperty("库区id")
@Excel(name = "库区id")
private Long storageSectionId;
@ApiModelProperty("库区编码")
@Excel(name = "库区编码")
private String storageCode;
@ApiModelProperty("库区名称")
@Excel(name = "库区名称")
private String storageName;
@ApiModelProperty("库位id")
@Excel(name = "库位id")
private Long storageLocationId;
@ApiModelProperty("库位编码")
@Excel(name = "库位编码")
private String storageLocationCode;
@ApiModelProperty("库位名称")
@Excel(name = "库位名称")
private String storageLocationName;
@ApiModelProperty("批次号")
@Excel(name = "批次号")
private String batchNumber;
@ApiModelProperty("物料状态编码")
@Excel(name = "物料状态编码")
private String materialStatusCode;
@ApiModelProperty("物料状态名称")
@Excel(name = "物料状态名称")
private String materialStatusName;
@ApiModelProperty("容器id")
@Excel(name = "容器id")
private Long containerId;
@ApiModelProperty("容器编码")
@Excel(name = "容器编码")
private String containerCode;
@ApiModelProperty("容器类型 数据字典")
@Excel(name = "容器类型 数据字典")
private String containerType;
@ApiModelProperty("容器类型名称 数据字典")
@Excel(name = "容器类型名称 数据字典")
private String containerTypeName;
@ApiModelProperty("库存数量")
@Excel(name = "库存数量")
private BigDecimal inventoryQuantity;
@ApiModelProperty("可用数量")
@Excel(name = "可用数量")
private BigDecimal allocationQuantity;
@ApiModelProperty("冻结数量")
@Excel(name = "冻结数量")
private BigDecimal freezeQuantity;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty("盘点是否可用:0-禁用 1-可用")
@Excel(name = "盘点是否可用:0-禁用 1-可用")
private Integer isAble;
@ApiModelProperty("货主信息")
@Excel(name = "货主信息")
private String shipperInfo;
@ApiModelProperty("物料信息")
@Excel(name = "物料信息")
private String materialInfo;
@ApiModelProperty("物料/库位信息")
@Excel(name = "物料/库位信息")
private String storageInfo;
@ApiModelProperty("货主id")
private Long shipperId;
}
@@ -219,6 +219,11 @@ public class RemoteSystemFeignFallbackFactory implements FallbackFactory<SystemS
return AjaxResult.error("查询关联仓库列表根据关联id查询失败"); return AjaxResult.error("查询关联仓库列表根据关联id查询失败");
} }
@Override
public AjaxResult queryListCorrelationId(Long warehouseId) {
return AjaxResult.error("查询仓库关联的用户ID集合失败");
}
@Override @Override
public AjaxResult getSubInfoByCode(String subjectCode) { public AjaxResult getSubInfoByCode(String subjectCode) {
return AjaxResult.error("获取科目信息失败" + throwable.getMessage()); return AjaxResult.error("获取科目信息失败" + throwable.getMessage());
@@ -14,6 +14,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -78,11 +79,17 @@ public class RemoteUserFeignFallbackFactory implements FallbackFactory<UserServi
return AjaxResult.error("根据车辆id查询司机失败:" + throwable.getMessage()); return AjaxResult.error("根据车辆id查询司机失败:" + throwable.getMessage());
} }
@GetMapping("/userApi/getInfo/{userId}")
@Override @Override
public AjaxResult getInfo(Long userId) { public AjaxResult getInfo(Long userId) {
return AjaxResult.error("根据用户ID查询用户详细信息失败:" + throwable.getMessage()); return AjaxResult.error("根据用户ID查询用户详细信息失败:" + throwable.getMessage());
} }
@Override
public AjaxResult getInfoByName(String userName) {
return AjaxResult.error("根据用户userName查询用户详细信息失败:" + throwable.getMessage());
}
@Override @Override
public AjaxResult bindDriverShipList(Long vehicleId) { public AjaxResult bindDriverShipList(Long vehicleId) {
return AjaxResult.error("查询车辆绑定的承运人列表信息失败:" + throwable.getMessage()); return AjaxResult.error("查询车辆绑定的承运人列表信息失败:" + throwable.getMessage());
@@ -5,6 +5,7 @@ import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.system.api.WlhyServiceFeign; import com.mhd.system.api.WlhyServiceFeign;
import com.mhd.system.api.WmsServiceFeign; import com.mhd.system.api.WmsServiceFeign;
import com.mhd.system.api.domain.MaterialBaseInfoFeign; import com.mhd.system.api.domain.MaterialBaseInfoFeign;
import com.mhd.system.api.domain.MaterialInventoryDTO;
import com.mhd.system.api.domain.NoticeOrderDTO; import com.mhd.system.api.domain.NoticeOrderDTO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -12,6 +13,8 @@ import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import java.util.Map;
/** /**
* @author ZhouGY * @author ZhouGY
* @title RemoteWmsFallbackFactory * @title RemoteWmsFallbackFactory
@@ -46,6 +49,11 @@ public class RemoteWmsFallbackFactory implements FallbackFactory<WmsServiceFeign
public AjaxResult stockOutOrInInsert(NoticeOrderDTO noticeOrderDTO) { public AjaxResult stockOutOrInInsert(NoticeOrderDTO noticeOrderDTO) {
return AjaxResult.error(cause.getMessage()); return AjaxResult.error(cause.getMessage());
} }
@Override
public AjaxResult materialInventoryApiListAll(MaterialInventoryDTO materialInventoryDTO) {
return AjaxResult.error(cause.getMessage());
}
}; };
} }
} }
+4 -4
View File
@@ -12,9 +12,9 @@ spring:
cloud: cloud:
nacos: nacos:
discovery: discovery:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
@@ -22,9 +22,9 @@ spring:
# username: nacos # username: nacos
# password: manhuoda@2023 # password: manhuoda@2023
config: config:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
@@ -220,4 +220,34 @@ public class UserPo {
@ApiModelProperty(name = "制单员nc编码") @ApiModelProperty(name = "制单员nc编码")
private String documentPreparerNcCode; private String documentPreparerNcCode;
@ApiModelProperty("法人代表")
private String legalRepresentative;
@ApiModelProperty("统一编码")
private String unifiedCode;
@ApiModelProperty("注册电话")
private String registeredPhone;
@ApiModelProperty("注册地址")
private String registeredAddress;
@ApiModelProperty("传真")
private String fax;
@ApiModelProperty("付款银行")
private String paymentBank;
@ApiModelProperty("付款账户")
private String paymentAccount;
@ApiModelProperty("发票抬头")
private String invoiceTitle;
@ApiModelProperty("税号")
private String taxNumber;
@ApiModelProperty("备注")
private String remark;
} }
+4 -2
View File
@@ -18,7 +18,8 @@ spring:
# server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
# server-addr: 10.33.0.129:6010 # server-addr: 10.33.0.129:6010
#线上正式环境 #线上正式环境
server-addr: 10.102.192.5:6848 server-addr: 127.0.0.1:8848
# server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
config: config:
@@ -26,7 +27,8 @@ spring:
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
# server-addr: 10.33.0.129:6010 # server-addr: 10.33.0.129:6010
#线上正式环境 #线上正式环境
server-addr: 10.102.192.5:6848 server-addr: 127.0.0.1:8848
# server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置 group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
@@ -14,10 +14,14 @@ spring:
nacos: nacos:
discovery: discovery:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
username: nacos
password: manhuoda@2023
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
#server-addr: mhd-nacos:8848 #server-addr: mhd-nacos:8848
config: config:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
username: nacos
password: manhuoda@2023
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
#server-addr: mhd-nacos:8848 #server-addr: mhd-nacos:8848
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置 group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
@@ -6,6 +6,7 @@ import com.mhd.common.security.annotation.EnableCustomConfig;
import com.mhd.common.security.annotation.EnableRyFeignClients; import com.mhd.common.security.annotation.EnableRyFeignClients;
import com.mhd.common.swagger.annotation.EnableCustomSwagger2; import com.mhd.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
/** /**
* 系统模块 * 系统模块
@@ -17,6 +18,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
@EnableRyFeignClients @EnableRyFeignClients
@SpringBootApplication @SpringBootApplication
@EnableAsync @EnableAsync
@EnableScheduling
public class MhdSystemApplication public class MhdSystemApplication
{ {
public static void main(String[] args) public static void main(String[] args)
@@ -0,0 +1,318 @@
package com.mhd.basic.application.service.Lease;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mhd.basic.application.service.storageSection.StorageSectionApplicationService;
import com.mhd.basic.domain.lease.entity.Lease;
import com.mhd.basic.domain.lease.repository.facade.ILeaseService;
import com.mhd.basic.domain.lease.repository.po.LeasePO;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import com.mhd.basic.domain.lease.service.LeaseDomainService;
import com.mhd.basic.domain.shipperLeaseDetails.entity.ShipperLeaseDetails;
import com.mhd.basic.domain.shipperLeaseDetails.entity.WarehouseOccupancyRate;
import com.mhd.basic.domain.shipperLeaseDetails.repository.facade.IShipperLeaseDetailsService;
import com.mhd.basic.domain.shipperLeaseDetails.repository.po.ShipperLeaseDetailsPO;
import com.mhd.basic.domain.shipperLeaseDetails.repository.todo.ShipperLeaseDetailsDO;
import com.mhd.basic.domain.storageSection.repository.po.StorageSectionPO;
import com.mhd.basic.domain.storageSection.repository.todo.StorageSectionDO;
import com.mhd.basic.interfaces.dto.lease.LeaseDTO;
import com.mhd.basic.interfaces.dto.shipperLeaseDetailsApi.ShipperLeaseDetailsDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.WmsServiceFeign;
import com.mhd.system.api.domain.MaterialInventoryDTO;
import com.mhd.system.api.domain.WarehouseFeignPO;
import com.mhd.system.api.model.LoginUser;
import com.mhd.system.service.ISysDictTypeService;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* 租赁管理ApplicationService
*
* @author gen
* @date 2024-05-07
*/
@Service
@Slf4j
public class LeaseApplicationService {
@Autowired
private LeaseDomainService leaseDomainService;
@Autowired
private ILeaseService leaseService;
@Autowired
private ISysDictTypeService dictTypeService;
@Autowired
private WmsServiceFeign wmsServiceFeign;
@Autowired
private StorageSectionApplicationService storageSectionApplicationService;
@Autowired
private IShipperLeaseDetailsService shipperLeaseDetailsService;
/**
* 分页查询租赁管理列表
*/
public List<LeasePO> queryList(LeaseDO leaseDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null){
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
// 数据权限:根据organizationId来设置查询权限
// organizationId等于2827时查询全部,其他仅查询各自组织的信息
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
// 南光组织(organizationId=2827):可以查询所有组织的数据
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
if (leaseDO.getOrganizationId() == null) {
leaseDO.setOrganizationId(null);
leaseDO.setTopOrganizationId(null);
}
} else {
// 其他组织:设置organizationId,只查询当前组织的数据
if (topOrganizationId != null && topOrganizationId != 1){
leaseDO.setTopOrganizationId(topOrganizationId);
}
// 如果前端传递了organizationId,验证是否与当前登录用户的组织ID一致
if (leaseDO.getOrganizationId() != null && !leaseDO.getOrganizationId().equals(loginUserOrganizationId)) {
// 前端传递了其他组织的organizationId,强制使用当前登录用户的组织ID,防止越权查询
leaseDO.setOrganizationId(loginUserOrganizationId);
}
}
}
return leaseDomainService.queryList(leaseDO);
}
/**
* 新增租赁管理
*/
public Boolean insert(LeaseDO leaseDO) {
// 设置当前登录用户的组织信息
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null) {
leaseDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
leaseDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
leaseDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
List<Lease> timeOverlapSimple = isTimeOverlapSimple(leaseDO.getCargoOwnerName(), leaseDO.getStartDate(), leaseDO.getEndDate(), null);
if (ObjectUtil.isNotEmpty(timeOverlapSimple)) {
throw new ServiceException("同一货主租赁信息时间不能重叠");
}
setWarehouseInfo(leaseDO);
return leaseDomainService.insert(leaseDO);
}
@Autowired
private SystemServiceFeign systemServiceFeign;
private void setWarehouseInfo(LeaseDO leaseDO) {
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(leaseDO.getWarehouseId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取仓库信息失败");
}
WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
leaseDO.setWarehouseName(warehouseFeignPO.getWarehouseName());
}
private List<Lease> isTimeOverlapSimple(String cargoOwnerName, Date startDate, Date endDate, Long excludeId) {
LambdaQueryWrapper<Lease> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Lease::getCargoOwnerName, cargoOwnerName)
.eq(Lease::getDelFlag, 1) // 只查询正常状态
.le(Lease::getStartDate, endDate)
.ge(Lease::getEndDate, startDate);
if (excludeId != null) {
wrapper.ne(Lease::getId, excludeId);
}
return leaseService.list(wrapper);
}
/**
* 修改租赁管理
*/
public Boolean update(LeaseDO leaseDO) {
List<Lease> timeOverlapSimple = isTimeOverlapSimple(leaseDO.getCargoOwnerName(), leaseDO.getStartDate(), leaseDO.getEndDate(), leaseDO.getId());
if (ObjectUtil.isNotEmpty(timeOverlapSimple)) {
throw new ServiceException("同一货主租赁信息时间不能重叠");
}
return leaseDomainService.update(leaseDO);
}
/**
* 批量删除租赁管理
*/
public boolean delete(Long[] leaseIds) {
return leaseDomainService.delete(leaseIds);
}
/**
* 获取租赁管理详细信息
*/
public LeasePO getInfo(Long leaseId)
{
return leaseDomainService.getInfo(leaseId);
}
/**
* @description 批量作废租赁
* @author ZhouGY
* @date 2024/5/13 9:46
* @param leaseIds
* @return Boolean
*/
public Boolean nullifyByIds(List<Long> leaseIds){
return leaseDomainService.nullifyByIds(leaseIds);
}
/**
* 货主租赁明细
*/
@Scheduled(cron = "0 0 1 * * ?")
public void shipperLeaseDetails() {
LeaseDO leaseDO = new LeaseDO();
leaseDO.setTime(new Date());
//查询租赁
List<LeasePO> leasePOS = queryList(leaseDO);
// List<LeasePO> leasePOS = leaseDomainService.queryList(leaseDO);
List<LeasePO> entireUnit = leasePOS.stream()
.filter(lease -> lease.getLeaseType().equals("整租"))
.collect(Collectors.toList());
List<LeasePO> casualRental = leasePOS.stream()
.filter(lease -> lease.getLeaseType().equals("散租"))
.collect(Collectors.toList());
List<ShipperLeaseDetails> shipperLeaseDetailsList = new ArrayList<>(); //建表后保存
for (LeasePO en : entireUnit) {//整租
ShipperLeaseDetails shipperLeaseDetails = new ShipperLeaseDetails();
BeanUtils.copyProperties(en, shipperLeaseDetails);
shipperLeaseDetails.setBusinessDate(new Date());
shipperLeaseDetailsList.add(shipperLeaseDetails);
}
//当前货主当前仓库,库存查询页面所有面积加起来就是散租面积
for (LeasePO ca : casualRental) {//散租
ShipperLeaseDetails shipperLeaseDetails = new ShipperLeaseDetails();
BeanUtils.copyProperties(ca, shipperLeaseDetails);
shipperLeaseDetails.setBusinessDate(new Date());
//物料库存
MaterialInventoryDTO materialInventoryDTO = new MaterialInventoryDTO();
materialInventoryDTO.setShipperId(ca.getShipperId());
materialInventoryDTO.setWarehouseId(ca.getWarehouseId());
AjaxResult ajaxResult = wmsServiceFeign.materialInventoryApiListAll(materialInventoryDTO);
BigDecimal area = BigDecimal.ZERO;
if(String.valueOf(ajaxResult.get("code")).equals("200")) {
JSONArray data = JSONObject.parseArray(JSON.toJSONString(ajaxResult.get("data")));
for (Object datum : data) {
JSONObject json = (JSONObject) datum;
BigDecimal area1 = json.getBigDecimal("area");
if (area1 == null) {
area1 = BigDecimal.ZERO;
}
area = area.add(area1);
}
}
shipperLeaseDetails.setLeaseArea(area);
shipperLeaseDetailsList.add(shipperLeaseDetails);
}
// 保存货主租赁明细(新建表)
if (shipperLeaseDetailsList.size() > 0) {
shipperLeaseDetailsService.saveBatch(shipperLeaseDetailsList);
}
}
/**
* 计算仓库出租率
* warehouseId 仓库id
* businessDateStart 业务开始时间
* businessDateEnd 业务结束时间
*/
public List<WarehouseOccupancyRate> warehouseOccupancyRate(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
//仓库id 和 开始结束时间作为查询条件 查数据库 差出来当前仓库所有的
List<ShipperLeaseDetailsPO> shipperLeaseDetailsList = shipperLeaseDetailsService.queryList(shipperLeaseDetailsDO);
ShipperLeaseDetailsPO shipperLeaseDetailsPO = shipperLeaseDetailsList.get(0);
//按业务日期分组,并按日期排序
TreeMap<Date, List<ShipperLeaseDetailsPO>> groupedByDate = shipperLeaseDetailsList.stream().collect(
Collectors.groupingBy(
ShipperLeaseDetailsPO::getBusinessDate,
TreeMap::new,
Collectors.toList()
)
);
//获取总面积
BigDecimal totalArea = BigDecimal.ZERO;
StorageSectionDO storageSectionDO = new StorageSectionDO();
storageSectionDO.setWarehouseId(shipperLeaseDetailsDO.getWarehouseId());
storageSectionDO.setOpeningUp(1);
List<StorageSectionPO> storageSectionPOS = storageSectionApplicationService.queryList(storageSectionDO);
for (StorageSectionPO storageSectionPO : storageSectionPOS) {
totalArea = totalArea.add(storageSectionPO.getStorageRegion());
}
List<WarehouseOccupancyRate> warehouseOccupancyRatesList = new ArrayList<>();
//组装仓库返回数据
BigDecimal finalTotalArea = totalArea;
groupedByDate.forEach((date, shipperLeaseDetails) -> {
WarehouseOccupancyRate warehouseOccupancyRate = new WarehouseOccupancyRate();
warehouseOccupancyRate.setBusinessDate(date);
BigDecimal entireLeaseArea = BigDecimal.ZERO;
BigDecimal fractionalLeaseArea = BigDecimal.ZERO;
//计算整租和散租
for (ShipperLeaseDetailsPO shipperLeaseDetail : shipperLeaseDetails) {
if (shipperLeaseDetail.getLeaseType().equals("整租")){
entireLeaseArea = entireLeaseArea.add(shipperLeaseDetail.getLeaseArea());
}else {
fractionalLeaseArea = fractionalLeaseArea.add(shipperLeaseDetail.getLeaseArea());
}
warehouseOccupancyRate.setWarehouseName(shipperLeaseDetail.getWarehouseName());
warehouseOccupancyRate.setBusinessDate(date);
warehouseOccupancyRate.setWarehouseId(shipperLeaseDetail.getWarehouseId());
}
warehouseOccupancyRate.setEntireLeaseArea(entireLeaseArea);
warehouseOccupancyRate.setFractionalLeaseArea(fractionalLeaseArea);
warehouseOccupancyRate.setTotalArea(finalTotalArea);
BigDecimal dailyRentalRate = entireLeaseArea.add(fractionalLeaseArea).divide(finalTotalArea, 2, BigDecimal.ROUND_HALF_UP);
warehouseOccupancyRate.setDailyRentalRate(dailyRentalRate);
warehouseOccupancyRatesList.add(warehouseOccupancyRate);
});
return warehouseOccupancyRatesList;
}
// /**
// * @description 设置数据字典键值
// * @author ZhouGY
// * @date 2024/4/7 14:33
// * @param containerDO
// */
// private void setDataDict(LeaseDO leaseDO){
// //翻译租赁类型
// List<SysDictData> storageTypeDictDataList = dictTypeService.selectDictDataByType(DictCode.CONTAINER_TYPE.getCode());
// if (null == storageTypeDictDataList) {
// throw new ServiceException("租赁类型数据字典不存在 请联系管理员");
// }
// SysDictData storageTypeDictData = storageTypeDictDataList.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), containerDO.getContainerType())).findAny().orElse(null);
// if (null == storageTypeDictData) {
// throw new ServiceException("租赁类型【" + leaseDO.getContainerType() + "】数据字典不存在 请联系管理员");
// }
// leaseDO.setContainerTypeName(storageTypeDictData.getDictLabel());
// }
}
@@ -1,15 +1,22 @@
package com.mhd.basic.application.service.batch; package com.mhd.basic.application.service.batch;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mhd.basic.domain.batch.repository.po.BatchPO; import com.mhd.basic.domain.batch.repository.po.BatchPO;
import com.mhd.basic.domain.batch.repository.todo.BatchDO; import com.mhd.basic.domain.batch.repository.todo.BatchDO;
import com.mhd.basic.domain.batch.service.BatchDomainService; import com.mhd.basic.domain.batch.service.BatchDomainService;
import com.mhd.basic.domain.batchDetail.entity.BatchDetail;
import com.mhd.basic.domain.batchDetail.repository.facade.IBatchDetailService;
import com.mhd.basic.domain.batchDetail.repository.po.BatchDetailPO;
import com.mhd.basic.domain.pack.repository.todo.PackDO; import com.mhd.basic.domain.pack.repository.todo.PackDO;
import com.mhd.common.core.domain.po.UserPo; import com.mhd.common.core.domain.po.UserPo;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* 批次管理ApplicationService * 批次管理ApplicationService
@@ -22,6 +29,8 @@ import java.util.List;
public class BatchApplicationService { public class BatchApplicationService {
@Autowired @Autowired
private BatchDomainService batchDomainService; private BatchDomainService batchDomainService;
@Autowired
private IBatchDetailService batchDetailService;
/** /**
@@ -36,7 +45,21 @@ public class BatchApplicationService {
batchDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); batchDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
} }
} }
return batchDomainService.queryList(batchDO); List<BatchPO> batchPOS = batchDomainService.queryList(batchDO);
for (BatchPO batchPO : batchPOS) {
List<BatchDetail> batchDetailList = batchDetailService.list(new LambdaQueryWrapper<BatchDetail>()
.eq(BatchDetail::getBatchId, batchPO.getBatchId())
.eq(BatchDetail::getDelFlag, "1"));
List<BatchDetailPO> batchDetailPOS = new ArrayList<>();
// 逐个对象拷贝
for (BatchDetail detail : batchDetailList) {
BatchDetailPO detailPO = new BatchDetailPO();
BeanUtils.copyProperties(detail, detailPO);
batchDetailPOS.add(detailPO);
}
batchPO.setBatchDetailList(batchDetailPOS);
}
return batchPOS;
} }
@@ -45,6 +45,10 @@ public class BatchDetailApplicationService {
batchDetailDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); batchDetailDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
} }
} }
// 如果未指定isDisplay,默认只查询显示的数据(isDisplay=1
if (batchDetailDO.getIsDisplay() == null) {
batchDetailDO.setIsDisplay(1);
}
return batchDetailDomainService.queryList(batchDetailDO); return batchDetailDomainService.queryList(batchDetailDO);
} }
@@ -79,8 +79,6 @@ public class ContainerApplicationService {
containerDO.setOrganizationName(loginUser.getUserPo().getOrganizationName()); containerDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
containerDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); containerDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
} }
//翻译库区类型
setDataDict(containerDO);
return containerDomainService.insert(containerDO); return containerDomainService.insert(containerDO);
} }
@@ -117,22 +115,4 @@ public class ContainerApplicationService {
return containerDomainService.nullifyByIds(containerIds); return containerDomainService.nullifyByIds(containerIds);
} }
/**
* @description 设置数据字典键值
* @author ZhouGY
* @date 2024/4/7 14:33
* @param containerDO
*/
private void setDataDict(ContainerDO containerDO){
//翻译容器类型
List<SysDictData> storageTypeDictDataList = dictTypeService.selectDictDataByType(DictCode.CONTAINER_TYPE.getCode());
if (null == storageTypeDictDataList) {
throw new ServiceException("容器类型数据字典不存在 请联系管理员");
}
SysDictData storageTypeDictData = storageTypeDictDataList.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), containerDO.getContainerType())).findAny().orElse(null);
if (null == storageTypeDictData) {
throw new ServiceException("容器类型【" + containerDO.getContainerType() + "】数据字典不存在 请联系管理员");
}
containerDO.setContainerTypeName(storageTypeDictData.getDictLabel());
}
} }
@@ -120,7 +120,11 @@ public class MaterialBaseInfoApplicationService {
throw new ServiceException("获取货主信息失败"); throw new ServiceException("获取货主信息失败");
} }
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class); UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
materialBaseInfoDO.setShipperName(userPo.getUserName()); // 如果原始shipperName不为空,保留原始值(导入或手动输入时应该保留完整名称)
// 只有在原始shipperName为空时,才使用查询到的userName
if (materialBaseInfoDO.getShipperName() == null || materialBaseInfoDO.getShipperName().trim().isEmpty()) {
materialBaseInfoDO.setShipperName(userPo.getUserName());
}
} }
public List<MaterialStockInfoVo> getMaterialStockList(String shipperName, String materialName, public List<MaterialStockInfoVo> getMaterialStockList(String shipperName, String materialName,
@@ -0,0 +1,160 @@
package com.mhd.basic.application.service.shipperLeaseDetails;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mhd.basic.application.service.storageSection.StorageSectionApplicationService;
import com.mhd.basic.domain.lease.entity.Lease;
import com.mhd.basic.domain.lease.repository.facade.ILeaseService;
import com.mhd.basic.domain.lease.repository.po.LeasePO;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import com.mhd.basic.domain.lease.service.LeaseDomainService;
import com.mhd.basic.domain.shipperLeaseDetails.entity.ShipperLeaseDetails;
import com.mhd.basic.domain.shipperLeaseDetails.entity.WarehouseOccupancyRate;
import com.mhd.basic.domain.shipperLeaseDetails.repository.facade.IShipperLeaseDetailsService;
import com.mhd.basic.domain.shipperLeaseDetails.repository.po.ShipperLeaseDetailsPO;
import com.mhd.basic.domain.shipperLeaseDetails.repository.todo.ShipperLeaseDetailsDO;
import com.mhd.basic.domain.shipperLeaseDetails.service.ShipperLeaseDetailsDomainService;
import com.mhd.basic.domain.storageSection.repository.po.StorageSectionPO;
import com.mhd.basic.domain.storageSection.repository.todo.StorageSectionDO;
import com.mhd.basic.interfaces.dto.lease.LeaseDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.WmsServiceFeign;
import com.mhd.system.api.domain.MaterialInventoryDTO;
import com.mhd.system.api.model.LoginUser;
import com.mhd.system.service.ISysDictTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TreeMap;
import java.util.stream.Collectors;
/**
* 货主租赁明细ApplicationService
*
* @author gen
* @date 2024-05-07
*/
@Service
@Slf4j
public class ShipperLeaseDetailsApplicationService {
@Autowired
private ShipperLeaseDetailsDomainService shipperLeaseDetailsDomainService;
@Autowired
private ISysDictTypeService dictTypeService;
/**
* 分页查询货主租赁明细列表
*/
public List<ShipperLeaseDetailsPO> queryList(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null){
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
// 数据权限:根据organizationId来设置查询权限
// organizationId等于2827时查询全部,其他仅查询各自组织的信息
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
// 南光组织(organizationId=2827):可以查询所有组织的数据
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
if (shipperLeaseDetailsDO.getOrganizationId() == null) {
shipperLeaseDetailsDO.setOrganizationId(null);
shipperLeaseDetailsDO.setTopOrganizationId(null);
}
} else {
// 其他组织:设置organizationId,只查询当前组织的数据
if (topOrganizationId != null && topOrganizationId != 1){
shipperLeaseDetailsDO.setTopOrganizationId(topOrganizationId);
}
// 如果前端传递了organizationId,验证是否与当前登录用户的组织ID一致
if (shipperLeaseDetailsDO.getOrganizationId() != null && !shipperLeaseDetailsDO.getOrganizationId().equals(loginUserOrganizationId)) {
// 前端传递了其他组织的organizationId,强制使用当前登录用户的组织ID,防止越权查询
shipperLeaseDetailsDO.setOrganizationId(loginUserOrganizationId);
}
}
}
return shipperLeaseDetailsDomainService.queryList(shipperLeaseDetailsDO);
}
/**
* 新增货主租赁明细
*/
public Boolean insert(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
// 设置当前登录用户的组织信息
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null) {
shipperLeaseDetailsDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
shipperLeaseDetailsDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
shipperLeaseDetailsDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
return shipperLeaseDetailsDomainService.insert(shipperLeaseDetailsDO);
}
/**
* 修改货主租赁明细
*/
public Boolean update(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
return shipperLeaseDetailsDomainService.update(shipperLeaseDetailsDO);
}
/**
* 批量删除货主租赁明细
*/
public boolean delete(Long[] shipperLeaseDetailsIds) {
return shipperLeaseDetailsDomainService.delete(shipperLeaseDetailsIds);
}
/**
* 获取货主租赁明细详细信息
*/
public ShipperLeaseDetailsPO getInfo(Long shipperLeaseDetailsId)
{
return shipperLeaseDetailsDomainService.getInfo(shipperLeaseDetailsId);
}
/**
* @description 批量作废租赁
* @author ZhouGY
* @date 2024/5/13 9:46
* @return Boolean
*/
public Boolean nullifyByIds(List<Long> shipperLeaseDetailsIds){
return shipperLeaseDetailsDomainService.nullifyByIds(shipperLeaseDetailsIds);
}
// /**
// * @description 设置数据字典键值
// * @author ZhouGY
// * @date 2024/4/7 14:33
// * @param containerDO
// */
// private void setDataDict(LeaseDO leaseDO){
// //翻译租赁类型
// List<SysDictData> storageTypeDictDataList = dictTypeService.selectDictDataByType(DictCode.CONTAINER_TYPE.getCode());
// if (null == storageTypeDictDataList) {
// throw new ServiceException("租赁类型数据字典不存在 请联系管理员");
// }
// SysDictData storageTypeDictData = storageTypeDictDataList.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), containerDO.getContainerType())).findAny().orElse(null);
// if (null == storageTypeDictData) {
// throw new ServiceException("租赁类型【" + leaseDO.getContainerType() + "】数据字典不存在 请联系管理员");
// }
// leaseDO.setContainerTypeName(storageTypeDictData.getDictLabel());
// }
}
@@ -49,8 +49,30 @@ public class StorageLocationApplicationService {
if (topOrganizationId != null && topOrganizationId != 1){ if (topOrganizationId != null && topOrganizationId != 1){
storageLocationDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); storageLocationDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
} }
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); // 只有当前端没有明确传仓库条件时,才使用用户关联仓库缓存进行过滤;
storageLocationDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); // 避免出现“单据仓库=常温仓,但库位列表仍显示保税仓”的错配问题。
boolean hasWarehouseFilter = storageLocationDO.getWarehouseId() != null
|| (storageLocationDO.getWarehouseCode() != null && !storageLocationDO.getWarehouseCode().trim().isEmpty())
|| (storageLocationDO.getWarehouseName() != null && !storageLocationDO.getWarehouseName().trim().isEmpty());
if (!hasWarehouseFilter) {
try {
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
if (associationWarehouseCacheDO != null) {
if (associationWarehouseCacheDO.getWarehouseId() != null) {
storageLocationDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
}
if (associationWarehouseCacheDO.getWarehouseCode() != null && !associationWarehouseCacheDO.getWarehouseCode().trim().isEmpty()) {
storageLocationDO.setWarehouseCode(associationWarehouseCacheDO.getWarehouseCode());
}
if (associationWarehouseCacheDO.getWarehouseName() != null && !associationWarehouseCacheDO.getWarehouseName().trim().isEmpty()) {
storageLocationDO.setWarehouseName(associationWarehouseCacheDO.getWarehouseName());
}
}
} catch (Exception e) {
// 获取失败不影响查询(允许查询所有仓库,或由前端传参控制)
log.warn("获取用户关联仓库信息失败,将按前端条件查询库位数据,用户ID:{},错误:{}", loginUser.getUserid(), e.getMessage());
}
}
} }
return storageLocationDomainService.queryList(storageLocationDO); return storageLocationDomainService.queryList(storageLocationDO);
} }
@@ -43,9 +43,9 @@ public class WarehouseApplicationService {
public List<WarehousePO> queryList(WarehouseDO warehouseDO) { public List<WarehousePO> queryList(WarehouseDO warehouseDO) {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){ if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId(); Long organizationId = loginUser.getUserPo().getOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){ if (organizationId != null && organizationId != 1){
warehouseDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); warehouseDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
} }
} }
return warehouseDomainService.queryList(warehouseDO); return warehouseDomainService.queryList(warehouseDO);
@@ -46,6 +46,10 @@ public class BatchDetail extends BaseVOEntity{
@Excel(name = "批次标签") @Excel(name = "批次标签")
private String batchLabels; private String batchLabels;
@ApiModelProperty("字段名称")
@Excel(name = "字段名称")
private String fieldName;
@ApiModelProperty("输入控制: 1-必填 2-可选") @ApiModelProperty("输入控制: 1-必填 2-可选")
@Excel(name = "输入控制: 1-必填 2-可选") @Excel(name = "输入控制: 1-必填 2-可选")
private String inputControl; private String inputControl;
@@ -58,6 +62,10 @@ public class BatchDetail extends BaseVOEntity{
@Excel(name = "属性选项") @Excel(name = "属性选项")
private String attributeOption; private String attributeOption;
@ApiModelProperty("是否显示: 0-不显示 1-显示")
@Excel(name = "是否显示: 0-不显示 1-显示")
private Integer isDisplay;
@ApiModelProperty("备注") @ApiModelProperty("备注")
@Excel(name = "备注") @Excel(name = "备注")
private String remark; private String remark;
@@ -62,24 +62,40 @@ public class BatchDetailImpl extends ServiceImpl<BatchDetailMapper, BatchDetail>
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
UserPo userPo = loginUser.getUserPo(); UserPo userPo = loginUser.getUserPo();
List<BatchDetailDO> batchDetailDOList = batchDO.getBatchDetailList(); List<BatchDetailDO> batchDetailDOList = batchDO.getBatchDetailList();
//验证提交的数据是否存在重复 // 验证本次提交的数据是否存在重复(同一批次内不允许重复标签)
long count = batchDetailDOList.stream().map(BatchDetailDO::getBatchLabels).distinct().count(); long count = batchDetailDOList.stream().map(BatchDetailDO::getBatchLabels).distinct().count();
if (batchDetailDOList.size() != count){ if (batchDetailDOList.size() != count){
throw new ServiceException("批次标签不允许重复,请检查提交的数据"); throw new ServiceException("批次标签不允许重复,请检查提交的数据");
} }
// 查询当前批次原有的标签明细
List<BatchDetail> batchDetailDbList = batchDetailMapper.selectList(new QueryWrapper<BatchDetail>().lambda() List<BatchDetail> batchDetailDbList = batchDetailMapper.selectList(new QueryWrapper<BatchDetail>().lambda()
.eq(BatchDetail::getBatchId, batchDO.getBatchId())); .eq(BatchDetail::getBatchId, batchDO.getBatchId()));
// 如果数据库里已经有明细,并且这次前端传过来的所有明细都没有明细ID,
// 说明前端没有带回原来的主键,这种情况我们视为“完全替换”:
// 先物理删除当前批次下所有旧的明细,再按本次数据重新插入,避免命中数据库唯一索引冲突。
boolean allNewWithoutId = CollectionUtil.isNotEmpty(batchDetailDOList)
&& batchDetailDOList.stream().allMatch(detail -> detail.getBatchDetailId() == null);
if (CollectionUtil.isNotEmpty(batchDetailDbList) && allNewWithoutId) {
batchDetailMapper.delete(new QueryWrapper<BatchDetail>().lambda()
.eq(BatchDetail::getBatchId, batchDO.getBatchId()));
batchDetailDbList = new ArrayList<>();
}
List<BatchDetail> batchDetailListSave = new ArrayList<>(); List<BatchDetail> batchDetailListSave = new ArrayList<>();
List<BatchDetail> batchDetailListSave2 = new ArrayList<>();
List<BatchDetail> batchDetailListUpdates = new ArrayList<>(); List<BatchDetail> batchDetailListUpdates = new ArrayList<>();
if (CollectionUtil.isNotEmpty(batchDetailDbList)){ if (CollectionUtil.isNotEmpty(batchDetailDbList)){
Map<String, BatchDetail> batchDetailMap = batchDetailDbList.stream().collect(Collectors.toMap(BatchDetail::getBatchLabels, Function.identity())); Map<Long, BatchDetail> batchDetailMap = batchDetailDbList.stream().collect(Collectors.toMap(BatchDetail::getBatchDetailId, Function.identity()));
for (BatchDetailDO batchDetailDO : batchDetailDOList){ for (BatchDetailDO batchDetailDO : batchDetailDOList){
BatchDetail batchDetailDb = batchDetailMap.get(batchDetailDO.getBatchLabels()); BatchDetail batchDetailDb = batchDetailMap.get(batchDetailDO.getBatchDetailId());
if (batchDetailDb != null){ if (batchDetailDb != null){
batchDetailDb.setBatchLabels(batchDetailDO.getBatchLabels()); batchDetailDb.setBatchLabels(batchDetailDO.getBatchLabels());
batchDetailDb.setFieldName(batchDetailDO.getFieldName());
batchDetailDb.setInputControl(batchDetailDO.getInputControl()); batchDetailDb.setInputControl(batchDetailDO.getInputControl());
batchDetailDb.setAttributeFormat(batchDetailDO.getAttributeFormat()); batchDetailDb.setAttributeFormat(batchDetailDO.getAttributeFormat());
batchDetailDb.setAttributeOption(batchDetailDO.getAttributeOption()); batchDetailDb.setAttributeOption(batchDetailDO.getAttributeOption());
batchDetailDb.setIsDisplay(batchDetailDO.getIsDisplay());
batchDetailDb.setRemark(batchDetailDO.getRemark()); batchDetailDb.setRemark(batchDetailDO.getRemark());
batchDetailDb.setDelFlag(1); batchDetailDb.setDelFlag(1);
batchDetailListUpdates.add(batchDetailDb); batchDetailListUpdates.add(batchDetailDb);
@@ -96,6 +112,20 @@ public class BatchDetailImpl extends ServiceImpl<BatchDetailMapper, BatchDetail>
batchDetailListSave.add(batchDetail); batchDetailListSave.add(batchDetail);
} }
} }
}else {
//是空没有详情 新增
for (BatchDetailDO batchDetailDO : batchDetailDOList) {
BatchDetail batchDetail = new BatchDetail();
BeanUtils.copyProperties(batchDetailDO, batchDetail);
batchDetail.setBatchId(batchDO.getBatchId());
batchDetail.setOrganizationId(batchDO.getOrganizationId());
batchDetail.setOrganizationName(batchDO.getOrganizationName());
batchDetail.setTopOrganizationId(batchDO.getTopOrganizationId());
batchDetail.setCreateBy(userPo.getUserId());
batchDetail.setCreateByName(userPo.getUserName());
batchDetail.setCreateTime(new Date());
batchDetailListSave2.add(batchDetail);
}
} }
//删除 之前存在 现在没有的 //删除 之前存在 现在没有的
List<Long> batchDetailIds = batchDetailDbList.stream().map(BatchDetail::getBatchDetailId).collect(Collectors.toList()); List<Long> batchDetailIds = batchDetailDbList.stream().map(BatchDetail::getBatchDetailId).collect(Collectors.toList());
@@ -113,6 +143,8 @@ public class BatchDetailImpl extends ServiceImpl<BatchDetailMapper, BatchDetail>
//新增 //新增
if (CollectionUtil.isNotEmpty(batchDetailListSave)){ if (CollectionUtil.isNotEmpty(batchDetailListSave)){
saveBatch(batchDetailListSave); saveBatch(batchDetailListSave);
}else if (CollectionUtil.isNotEmpty(batchDetailListSave2)){
saveBatch(batchDetailListSave2);
} }
//修改 //修改
if (CollectionUtil.isNotEmpty(batchDetailListUpdates)){ if (CollectionUtil.isNotEmpty(batchDetailListUpdates)){
@@ -45,6 +45,10 @@ public class BatchDetailPO extends BaseVOEntity{
@Excel(name = "批次标签") @Excel(name = "批次标签")
private String batchLabels; private String batchLabels;
@ApiModelProperty("字段名称")
@Excel(name = "字段名称")
private String fieldName;
@ApiModelProperty("输入控制: 1-必填 2-可选") @ApiModelProperty("输入控制: 1-必填 2-可选")
@Excel(name = "输入控制: 1-必填 2-可选") @Excel(name = "输入控制: 1-必填 2-可选")
private String inputControl; private String inputControl;
@@ -57,6 +61,10 @@ public class BatchDetailPO extends BaseVOEntity{
@Excel(name = "属性选项") @Excel(name = "属性选项")
private String attributeOption; private String attributeOption;
@ApiModelProperty("是否显示: 0-不显示 1-显示")
@Excel(name = "是否显示: 0-不显示 1-显示")
private Integer isDisplay;
@ApiModelProperty("备注") @ApiModelProperty("备注")
@Excel(name = "备注") @Excel(name = "备注")
private String remark; private String remark;
@@ -1,5 +1,7 @@
package com.mhd.basic.domain.batchDetail.repository.todo; package com.mhd.basic.domain.batchDetail.repository.todo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel; import com.mhd.common.core.annotation.Excel;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@@ -23,6 +25,7 @@ public class BatchDetailDO extends BaseVOEntity{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("批次管理详情id") @ApiModelProperty("批次管理详情id")
@TableId(type = IdType.AUTO)
private Long batchDetailId; private Long batchDetailId;
@ApiModelProperty("组织表ID") @ApiModelProperty("组织表ID")
@@ -45,6 +48,14 @@ public class BatchDetailDO extends BaseVOEntity{
@Excel(name = "批次标签") @Excel(name = "批次标签")
private String batchLabels; private String batchLabels;
@ApiModelProperty("字段名称")
@Excel(name = "字段名称")
private String fieldName;
@ApiModelProperty("是否显示: 0-不显示 1-显示")
@Excel(name = "是否显示: 0-不显示 1-显示")
private Integer isDisplay;
@ApiModelProperty("输入控制: 1-必填 2-可选") @ApiModelProperty("输入控制: 1-必填 2-可选")
@Excel(name = "输入控制: 1-必填 2-可选") @Excel(name = "输入控制: 1-必填 2-可选")
private String inputControl; private String inputControl;
@@ -57,6 +68,8 @@ public class BatchDetailDO extends BaseVOEntity{
@Excel(name = "属性选项") @Excel(name = "属性选项")
private String attributeOption; private String attributeOption;
@ApiModelProperty("备注") @ApiModelProperty("备注")
@Excel(name = "备注") @Excel(name = "备注")
private String remark; private String remark;
@@ -0,0 +1,64 @@
package com.mhd.basic.domain.lease.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 租赁管理对象 container
*
*/
@Data
public class Lease extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
@TableId(type = IdType.AUTO)
private Long id;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("仓库ID")
private Long warehouseId;
@ApiModelProperty("仓库名字")
private String warehouseName;
@ApiModelProperty("货主id")
private Long shipperId;
@ApiModelProperty("货主名称")
private String cargoOwnerName;
@ApiModelProperty(value = "租赁方式(整租/散租)")
private String leaseType;
@ApiModelProperty("租赁面积(m²)")
private BigDecimal leaseArea;
@ApiModelProperty("开始日期")
private Date startDate;
@ApiModelProperty("结束日期")
private Date endDate;
@ApiModelProperty("备注")
private String remark;
}
@@ -0,0 +1,43 @@
package com.mhd.basic.domain.lease.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.basic.domain.lease.entity.Lease;
import com.mhd.basic.domain.lease.repository.po.LeasePO;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import java.util.List;
/**
* 租赁管理Service接口
*
* @author gen
* @date 2024-05-07
*/
public interface ILeaseService extends IService<Lease>
{
/**
* 分页查询租赁管理列表
*/
public List<LeasePO> queryList(LeaseDO leaseDO);
/**
* 新增租赁管理
*/
public Boolean insert(LeaseDO leaseDO);
/**
* 修改租赁管理
*/
public Boolean update(LeaseDO leaseDO);
/**
* 批量删除租赁管理
*/
public Boolean delete(Long[] leaseIds);
/**
* 查询租赁管理
*/
public LeasePO getInfo(Long leaseId);
}
@@ -0,0 +1,21 @@
package com.mhd.basic.domain.lease.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.basic.domain.lease.entity.Lease;
import com.mhd.basic.domain.lease.repository.po.LeasePO;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import java.util.List;
/**
* 租赁管理Mapper接口
*
*/
public interface LeaseMapper extends BaseMapper<Lease>
{
/**
* 查询租赁管理列表
*/
public List<LeasePO> queryList(LeaseDO leaseDO);
}
@@ -0,0 +1,114 @@
package com.mhd.basic.domain.lease.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.basic.domain.lease.entity.Lease;
import com.mhd.basic.domain.lease.repository.facade.ILeaseService;
import com.mhd.basic.domain.lease.repository.mapper.LeaseMapper;
import com.mhd.basic.domain.lease.repository.po.LeasePO;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 容器管理Service业务层处理
*
* @author gen
* @date 2024-05-07
*/
@Service
public class LeaseImpl extends ServiceImpl<LeaseMapper, Lease> implements ILeaseService {
@Autowired
private LeaseMapper leaseMapper;
/**
* 查询容器管理列表
*/
@Override
public List<LeasePO> queryList(LeaseDO leaseDO)
{
return leaseMapper.queryList(leaseDO);
}
/**
* 新增容器管理
*/
@Override
public Boolean insert(LeaseDO leaseDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
Lease lease = new Lease();
BeanUtils.copyProperties(leaseDO,lease);
return this.save(lease);
}
/**
* 修改容器管理
*/
@Override
public Boolean update(LeaseDO leaseDO) {
Lease lease = new Lease();
BeanUtils.copyProperties(leaseDO,lease);
return this.updateById(lease);
}
/**
* 批量删除容器管理
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean delete(Long[] leaseIds ) {
LoginUser loginUser = SecurityUtils.getLoginUser();
List<Lease> list = new ArrayList<>();
for (Long id : leaseIds) {
Lease lease = new Lease();
lease.setId(id);
lease.setDelFlag(2);
lease.setUpdateBy(loginUser.getUserid());
lease.setUpdateByName(loginUser.getUsername());
lease.setUpdateTime(new Date());
list.add(lease);
}
return this.updateBatchById(list);
}
/**
* 修改容器管理
*/
@Override
public LeasePO getInfo(Long leaseId) {
Lease lease = this.getById(leaseId);
LeasePO leasePO = new LeasePO();
BeanUtils.copyProperties(lease,leasePO);
return leasePO;
}
// /**
// * @description 校验唯一
// * @author ZhouGY
// * @date 2024/5/9 21:10
// * @param containerDO
// */
// private void verifyUniqueness(ContainerDO containerDO){
// LoginUser loginUser = SecurityUtils.getLoginUser();
// Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
// if (topOrganizationId == null || topOrganizationId == 0 ){
// throw new ServiceException("获取当前登陆人组织失败!");
// }
// int count = leaseMapper.selectCount(new QueryWrapper<Container>().lambda()
// .eq(Container::getTopOrganizationId, topOrganizationId)
// .eq(Container::getContainerCode,containerDO.getContainerCode())
// .eq(Container::getOrganizationId, containerDO.getOrganizationId())
// .ne(containerDO.getContainerId() != null, Container::getContainerId, containerDO.getContainerId() )
// .eq(Container::getDelFlag,1));
// if (count > 0){
// throw new ServiceException("容器编码【" + containerDO.getContainerCode() + "】已存在");
// }
// }
}
@@ -0,0 +1,67 @@
package com.mhd.basic.domain.lease.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 租赁管理对象 container
*
*/
@Data
public class LeasePO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("仓库ID")
private Long warehouseId;
@ApiModelProperty("仓库名字")
private String warehouseName;
@ApiModelProperty("货主id")
private Long shipperId;
@ApiModelProperty("货主名称")
private String cargoOwnerName;
@ApiModelProperty(value = "租赁方式(整租/散租)")
private String leaseType;
@ApiModelProperty("租赁面积(m²)")
private BigDecimal leaseArea;
@ApiModelProperty("开始日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date startDate;
@ApiModelProperty("结束日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date endDate;
@ApiModelProperty("备注")
private String remark;
}
@@ -0,0 +1,82 @@
package com.mhd.basic.domain.lease.repository.todo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 租赁管理对象 container
*
*/
@Data
public class LeaseDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("仓库ID")
private Long warehouseId;
@ApiModelProperty("仓库名字")
private String warehouseName;
@ApiModelProperty("货主id")
private Long shipperId;
@ApiModelProperty("货主名称")
private String cargoOwnerName;
@ApiModelProperty(value = "租赁方式(整租/散租)")
private String leaseType;
@ApiModelProperty("租赁面积(m²)")
private BigDecimal leaseArea;
@ApiModelProperty("开始日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startDate;
@ApiModelProperty("结束日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endDate;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("当前时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date time;
@ApiModelProperty(name = "创建时间查询条件开始日期")
private String createTimeStart;
@ApiModelProperty(name = "创建时间查询条件结束日期")
private String createTimeEnd;
@ApiModelProperty(name = "修改时间查询条件开始日期")
private String updateTimeStart;
@ApiModelProperty(name = "修改时间查询条件结束日期")
private String updateTimeEnd;
}
@@ -0,0 +1,87 @@
package com.mhd.basic.domain.lease.service;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.mhd.basic.domain.container.entity.Container;
import com.mhd.basic.domain.container.repository.facade.IContainerService;
import com.mhd.basic.domain.container.repository.po.ContainerPO;
import com.mhd.basic.domain.container.repository.todo.ContainerDO;
import com.mhd.basic.domain.lease.entity.Lease;
import com.mhd.basic.domain.lease.repository.facade.ILeaseService;
import com.mhd.basic.domain.lease.repository.po.LeasePO;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 租赁管理
*
*/
@Service
@Slf4j
public class LeaseDomainService {
@Autowired
private ILeaseService leaseService;
/**
* 分页查询租赁管理列表
*/
public List<LeasePO> queryList(LeaseDO leaseDO) {
return leaseService.queryList(leaseDO);
}
/**
* 新增租赁管理
*/
public Boolean insert(LeaseDO leaseDO) {
return leaseService.insert(leaseDO);
}
/**
* 修改租赁管理
*/
public Boolean update(LeaseDO leaseDO) {
return leaseService.update(leaseDO);
}
/**
* 批量删除租赁管理
*/
public Boolean delete(Long[] leaseIds) {
return leaseService.delete(leaseIds);
}
/**
* 获取租赁管理详细信息
*/
public LeasePO getInfo(Long leaseId)
{
return leaseService.getInfo(leaseId);
}
/**
* @description 批量作废租赁
* @author ZhouGY
* @date 2024/5/13 9:46
* @param leaseIds
* @return Boolean
*/
public Boolean nullifyByIds(List<Long> leaseIds) {
LoginUser loginUser = SecurityUtils.getLoginUser();
return leaseService.update(new UpdateWrapper<Lease>().lambda()
.set(Lease::getUpdateBy, loginUser.getUserid())
.set(Lease::getUpdateTime, new Date())
.in(Lease::getId, leaseIds)
.eq(Lease::getDelFlag, 1));
}
}
@@ -158,6 +158,7 @@ public class MaterialBaseInfo extends BaseVOEntity{
@ApiModelProperty("单位数量") @ApiModelProperty("单位数量")
@Excel(name = "单位数量") @Excel(name = "单位数量")
@TableField(exist = false)
private BigDecimal unitNumber; private BigDecimal unitNumber;
@ApiModelProperty("是否公用: 1-是 2-否") @ApiModelProperty("是否公用: 1-是 2-否")
@@ -184,4 +185,204 @@ public class MaterialBaseInfo extends BaseVOEntity{
@ApiModelProperty("整机编码") @ApiModelProperty("整机编码")
@Excel(name = "整机编号") @Excel(name = "整机编号")
private String machineCode; private String machineCode;
/**
* 商品名称
*/
@ApiModelProperty("商品名称")
@Excel(name = "商品名称")
@TableField(exist = false)
private String commodityName;
/**
* 商品编码
*/
@ApiModelProperty("商品编码")
@Excel(name = "商品编码")
@TableField(exist = false)
private String commodityNo;
/**
* 料号
*/
@ApiModelProperty("料号")
@Excel(name = "料号")
@TableField(exist = false)
private String materialNo;
/**
* 规格型号
*/
@ApiModelProperty("规格型号")
@Excel(name = "规格型号")
@TableField(exist = false)
private String specificationModel;
/**
* Invoice No
*/
@ApiModelProperty("Invoice No")
@Excel(name = "Invoice No")
@TableField(exist = false)
private String invoiceNo;
/**
* 升
*/
@ApiModelProperty("")
@Excel(name = "")
@TableField(exist = false)
private String liter;
/**
* 尺寸
*/
@ApiModelProperty("尺寸")
@Excel(name = "尺寸")
@TableField(exist = false)
private String size;
/**
* 申报单位
*/
@ApiModelProperty("申报单位")
@Excel(name = "申报单位")
@TableField(exist = false)
private String declareUnit;
/**
* Batch Ref NO's
*/
@ApiModelProperty("Batch Ref NO's")
@Excel(name = "Batch Ref NO's")
@TableField(exist = false)
private String batchRefNo;
/**
* Sheet Ref NO's
*/
@ApiModelProperty("Sheet Ref NO's")
@Excel(name = "Sheet Ref NO's")
@TableField(exist = false)
private String sheetRefNo;
/**
* 原产国
*/
@ApiModelProperty("原产国")
@Excel(name = "原产国")
@TableField(exist = false)
private String countryOfOrigin;
/**
* 箱号/卡板号
*/
@ApiModelProperty("箱号/卡板号")
@Excel(name = "箱号/卡板号")
@TableField(exist = false)
private String casePalletNo;
/**
* 币制
*/
@ApiModelProperty("币制")
@Excel(name = "币制")
private String currency;
/**
* 申报数量
*/
@ApiModelProperty("申报数量")
@Excel(name = "申报数量")
@TableField(exist = false)
private Double declareQuantity;
/**
* 箱数
*/
@ApiModelProperty("箱数")
@Excel(name = "箱数")
@TableField(exist = false)
private Double caseCount;
/**
* 件数
*/
@ApiModelProperty("件数")
@Excel(name = "件数")
@TableField(exist = false)
private Double pieceCount;
/**
* 出库数量
*/
@ApiModelProperty("出库数量")
@Excel(name = "出库数量")
@TableField(exist = false)
private Double outboundQuantity;
/**
* 总净重(KG)
*/
@ApiModelProperty("总净重(KG)")
@Excel(name = "总净重(KG)")
@TableField(exist = false)
private Double totalNetWeight;
/**
* 总毛重(KG)
*/
@ApiModelProperty("总毛重(KG)")
@Excel(name = "总毛重(KG)")
@TableField(exist = false)
private Double totalGrossWeight;
/**
* 总体积(CBM)
*/
@ApiModelProperty("总体积(CBM)")
@Excel(name = "总体积(CBM)")
@TableField(exist = false)
private Double totalVolume;
/**
* 总面积(SQM)
*/
@ApiModelProperty("总面积(SQM)")
@Excel(name = "总面积(SQM)")
@TableField(exist = false)
private Double totalArea;
/**
* 总价
*/
@ApiModelProperty("总价")
@Excel(name = "总价")
@TableField(exist = false)
private Double totalAmount;
/**
* 单位
*/
@ApiModelProperty("单位")
@Excel(name = "单位")
@TableField(exist = false)
private String unit;
@ApiModelProperty("SKU码")
private String skuCode;
@ApiModelProperty("单价")
private BigDecimal unitPrice;
@ApiModelProperty("原产国")
private String originCountry;
@ApiModelProperty("HS码")
private String hsCode;
@ApiModelProperty("申报单位")
private String declarationUnit;
@ApiModelProperty("法定单位")
private String statutoryUnit;
@ApiModelProperty("法定第二单位")
private String statutorySecondUnit;
} }
@@ -5,6 +5,7 @@ import com.mhd.basic.domain.batch.repository.po.BatchPO;
import com.mhd.common.core.annotation.Excel; import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.handler.ListTypeHandler; import com.mhd.common.core.handler.ListTypeHandler;
import com.mhd.common.core.web.domain.BaseVOEntity; import com.mhd.common.core.web.domain.BaseVOEntity;
import com.mhd.system.api.domain.*;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@@ -182,4 +183,197 @@ public class MaterialBaseInfoPO extends BaseVOEntity{
@Excel(name = "整机编号") @Excel(name = "整机编号")
private String machineCode; private String machineCode;
/**
* 商品名称
*/
@ApiModelProperty("商品名称")
@Excel(name = "商品名称")
private String commodityName;
/**
* 商品编码
*/
@ApiModelProperty("商品编码")
@Excel(name = "商品编码")
private String commodityNo;
/**
* 料号
*/
@ApiModelProperty("料号")
@Excel(name = "料号")
private String materialNo;
/**
* 规格型号
*/
@ApiModelProperty("规格型号")
@Excel(name = "规格型号")
private String specificationModel;
/**
* Invoice No
*/
@ApiModelProperty("Invoice No")
@Excel(name = "Invoice No")
private String invoiceNo;
/**
* 升
*/
@ApiModelProperty("")
@Excel(name = "")
private String liter;
/**
* 尺寸
*/
@ApiModelProperty("尺寸")
@Excel(name = "尺寸")
private String size;
/**
* 申报单位
*/
@ApiModelProperty("申报单位")
@Excel(name = "申报单位")
private String declareUnit;
/**
* Batch Ref NOs
*/
@ApiModelProperty("Batch Ref NOs")
@Excel(name = "Batch Ref NOs")
private String batchRefNo;
/**
* Sheet Ref NOs
*/
@ApiModelProperty("Sheet Ref NOs")
@Excel(name = "Sheet Ref NOs")
private String sheetRefNo;
/**
* 原产国
*/
@ApiModelProperty("原产国")
@Excel(name = "原产国")
private String countryOfOrigin;
/**
* 箱号/卡板号
*/
@ApiModelProperty("箱号/卡板号")
@Excel(name = "箱号/卡板号")
private String casePalletNo;
/**
* 币制
*/
@ApiModelProperty("币制")
@Excel(name = "币制")
private String currency;
/**
* 申报数量
*/
@ApiModelProperty("申报数量")
@Excel(name = "申报数量")
private Double declareQuantity;
/**
* 箱数
*/
@ApiModelProperty("箱数")
@Excel(name = "箱数")
private Double caseCount;
/**
* 件数
*/
@ApiModelProperty("件数")
@Excel(name = "件数")
private Double pieceCount;
/**
* 出库数量
*/
@ApiModelProperty("出库数量")
@Excel(name = "出库数量")
private Double outboundQuantity;
/**
* 总净重(KG)
*/
@ApiModelProperty("总净重(KG)")
@Excel(name = "总净重(KG)")
private Double totalNetWeight;
/**
* 总毛重(KG)
*/
@ApiModelProperty("总毛重(KG)")
@Excel(name = "总毛重(KG)")
private Double totalGrossWeight;
/**
* 总体积(CBM)
*/
@ApiModelProperty("总体积(CBM)")
@Excel(name = "总体积(CBM)")
private Double totalVolume;
/**
* 总面积(SQM)
*/
@ApiModelProperty("总面积(SQM)")
@Excel(name = "总面积(SQM)")
private Double totalArea;
/**
* 总价
*/
@ApiModelProperty("总价")
@Excel(name = "总价")
private Double totalAmount;
/**
* 单位
*/
@ApiModelProperty("单位")
@Excel(name = "单位")
private String unit;
@ApiModelProperty("SKU码")
private String skuCode;
@ApiModelProperty("单价")
private BigDecimal unitPrice;
@ApiModelProperty("原产国")
private String originCountry;
@ApiModelProperty("HS码")
private String hsCode;
@ApiModelProperty("申报单位")
private String declarationUnit;
@ApiModelProperty("法定单位")
private String statutoryUnit;
@ApiModelProperty("法定第二单位")
private String statutorySecondUnit;
@ApiModelProperty("商品规则")
private MaterialGoodsRuleFeign materialGoodsRule;
@ApiModelProperty("公共信息")
private MaterialCommonFeign materialCommon;
@ApiModelProperty("仓库控制信息")
private MaterialWarehouseControlFeign materialWarehouseControl;
@ApiModelProperty("库存预警信息")
private List<MaterialInventoryWarningFeign> materialInventoryWarningList;
@ApiModelProperty("条码信息")
private List<MaterialBarCodeFeign> materialBarCodeList;
} }
@@ -203,4 +203,182 @@ public class MaterialBaseInfoDO extends BaseVOEntity{
@ApiModelProperty("整机编码") @ApiModelProperty("整机编码")
@Excel(name = "整机编号") @Excel(name = "整机编号")
private String machineCode; private String machineCode;
/**
* 商品名称
*/
@ApiModelProperty("商品名称")
@Excel(name = "商品名称")
private String commodityName;
/**
* 商品编码
*/
@ApiModelProperty("商品编码")
@Excel(name = "商品编码")
private String commodityNo;
/**
* 料号
*/
@ApiModelProperty("料号")
@Excel(name = "料号")
private String materialNo;
/**
* 规格型号
*/
@ApiModelProperty("规格型号")
@Excel(name = "规格型号")
private String specificationModel;
/**
* Invoice No
*/
@ApiModelProperty("Invoice No")
@Excel(name = "Invoice No")
private String invoiceNo;
/**
* 升
*/
@ApiModelProperty("")
@Excel(name = "")
private String liter;
/**
* 尺寸
*/
@ApiModelProperty("尺寸")
@Excel(name = "尺寸")
private String size;
/**
* 申报单位
*/
@ApiModelProperty("申报单位")
@Excel(name = "申报单位")
private String declareUnit;
/**
* Batch Ref NOs
*/
@ApiModelProperty("Batch Ref NOs")
@Excel(name = "Batch Ref NOs")
private String batchRefNo;
/**
* Sheet Ref NOs
*/
@ApiModelProperty("Sheet Ref NOs")
@Excel(name = "Sheet Ref NOs")
private String sheetRefNo;
/**
* 原产国
*/
@ApiModelProperty("原产国")
@Excel(name = "原产国")
private String countryOfOrigin;
/**
* 箱号/卡板号
*/
@ApiModelProperty("箱号/卡板号")
@Excel(name = "箱号/卡板号")
private String casePalletNo;
/**
* 币制
*/
@ApiModelProperty("币制")
@Excel(name = "币制")
private String currency;
/**
* 申报数量
*/
@ApiModelProperty("申报数量")
@Excel(name = "申报数量")
private Double declareQuantity;
/**
* 箱数
*/
@ApiModelProperty("箱数")
@Excel(name = "箱数")
private Double caseCount;
/**
* 件数
*/
@ApiModelProperty("件数")
@Excel(name = "件数")
private Double pieceCount;
/**
* 出库数量
*/
@ApiModelProperty("出库数量")
@Excel(name = "出库数量")
private Double outboundQuantity;
/**
* 总净重(KG)
*/
@ApiModelProperty("总净重(KG)")
@Excel(name = "总净重(KG)")
private Double totalNetWeight;
/**
* 总毛重(KG)
*/
@ApiModelProperty("总毛重(KG)")
@Excel(name = "总毛重(KG)")
private Double totalGrossWeight;
/**
* 总体积(CBM)
*/
@ApiModelProperty("总体积(CBM)")
@Excel(name = "总体积(CBM)")
private Double totalVolume;
/**
* 总面积(SQM)
*/
@ApiModelProperty("总面积(SQM)")
@Excel(name = "总面积(SQM)")
private Double totalArea;
/**
* 总价
*/
@ApiModelProperty("总价")
@Excel(name = "总价")
private Double totalAmount;
/**
* 单位
*/
@ApiModelProperty("单位")
@Excel(name = "单位")
private String unit;
@ApiModelProperty("SKU码")
private String skuCode;
@ApiModelProperty("单价")
private BigDecimal unitPrice;
@ApiModelProperty("原产国")
private String originCountry;
@ApiModelProperty("HS码")
private String hsCode;
@ApiModelProperty("申报单位")
private String declarationUnit;
@ApiModelProperty("法定单位")
private String statutoryUnit;
@ApiModelProperty("法定第二单位")
private String statutorySecondUnit;
} }
@@ -68,6 +68,10 @@ public class PackPO extends BaseVOEntity{
@Excel(name = "是否作废: 1-否 2-是") @Excel(name = "是否作废: 1-否 2-是")
private Integer nullify; private Integer nullify;
@ApiModelProperty("包装单位(取第一条包装详情的单位名称)")
@Excel(name = "包装单位")
private String unitName;
@ApiModelProperty("包装明细") @ApiModelProperty("包装明细")
private List<PackDetailPO> packDetailList; private List<PackDetailPO> packDetailList;
@@ -0,0 +1,65 @@
package com.mhd.basic.domain.shipperLeaseDetails.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 货主租赁明细
*
*/
@Data
public class ShipperLeaseDetails extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
@TableId(type = IdType.AUTO)
private Long id;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("仓库ID")
private Long warehouseId;
@ApiModelProperty("仓库名字")
private String warehouseName;
@ApiModelProperty("货主id")
private Long shipperId;
@ApiModelProperty("货主名称")
private String cargoOwnerName;
@ApiModelProperty(value = "租赁方式(整租/散租)")
private String leaseType;
@ApiModelProperty("租赁面积(m²)")
private BigDecimal leaseArea;
@ApiModelProperty("业务日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date businessDate;
}
@@ -0,0 +1,58 @@
package com.mhd.basic.domain.shipperLeaseDetails.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 仓库出租率返回类 没有表
*
*/
@Data
public class WarehouseOccupancyRate extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("仓库ID")
private Long warehouseId;
@ApiModelProperty("仓库名字")
private String warehouseName;
@ApiModelProperty("业务日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date businessDate;
@ApiModelProperty("整租面积(m²)")
private BigDecimal entireLeaseArea;
@ApiModelProperty("散租面积(m²)")
private BigDecimal fractionalLeaseArea;
@ApiModelProperty("总面积(m²)")
private BigDecimal totalArea;
@ApiModelProperty("日租率(%)")
private BigDecimal dailyRentalRate;
}
@@ -0,0 +1,43 @@
package com.mhd.basic.domain.shipperLeaseDetails.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.basic.domain.shipperLeaseDetails.entity.ShipperLeaseDetails;
import com.mhd.basic.domain.shipperLeaseDetails.repository.po.ShipperLeaseDetailsPO;
import com.mhd.basic.domain.shipperLeaseDetails.repository.todo.ShipperLeaseDetailsDO;
import java.util.List;
/**
* 货主租赁明细Service接口
*
* @author gen
* @date 2024-05-07
*/
public interface IShipperLeaseDetailsService extends IService<ShipperLeaseDetails>
{
/**
* 分页查询货主租赁明细列表
*/
public List<ShipperLeaseDetailsPO> queryList(ShipperLeaseDetailsDO shipperLeaseDetailsDO);
/**
* 新增货主租赁明细
*/
public Boolean insert(ShipperLeaseDetailsDO shipperLeaseDetailsDO);
/**
* 修改货主租赁明细
*/
public Boolean update(ShipperLeaseDetailsDO shipperLeaseDetailsDO);
/**
* 批量删除货主租赁明细
*/
public Boolean delete(Long[] leaseIds);
/**
* 查询货主租赁明细
*/
public ShipperLeaseDetailsPO getInfo(Long leaseId);
}
@@ -0,0 +1,21 @@
package com.mhd.basic.domain.shipperLeaseDetails.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.basic.domain.shipperLeaseDetails.entity.ShipperLeaseDetails;
import com.mhd.basic.domain.shipperLeaseDetails.repository.po.ShipperLeaseDetailsPO;
import com.mhd.basic.domain.shipperLeaseDetails.repository.todo.ShipperLeaseDetailsDO;
import java.util.List;
/**
* 货主租赁明细Mapper接口
*
*/
public interface ShipperLeaseDetailsMapper extends BaseMapper<ShipperLeaseDetails>
{
/**
* 查询货主租赁明细列表
*/
public List<ShipperLeaseDetailsPO> queryList(ShipperLeaseDetailsDO shipperLeaseDetailsDO);
}
@@ -0,0 +1,114 @@
package com.mhd.basic.domain.shipperLeaseDetails.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.basic.domain.shipperLeaseDetails.entity.ShipperLeaseDetails;
import com.mhd.basic.domain.shipperLeaseDetails.repository.facade.IShipperLeaseDetailsService;
import com.mhd.basic.domain.shipperLeaseDetails.repository.mapper.ShipperLeaseDetailsMapper;
import com.mhd.basic.domain.shipperLeaseDetails.repository.po.ShipperLeaseDetailsPO;
import com.mhd.basic.domain.shipperLeaseDetails.repository.todo.ShipperLeaseDetailsDO;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 货主租赁明细Service业务层处理
*
* @author gen
* @date 2024-05-07
*/
@Service
public class ShipperLeaseDetailsImpl extends ServiceImpl<ShipperLeaseDetailsMapper, ShipperLeaseDetails> implements IShipperLeaseDetailsService {
@Autowired
private ShipperLeaseDetailsMapper shipperLeaseDetailsMapper;
/**
* 查询货主租赁明细列表
*/
@Override
public List<ShipperLeaseDetailsPO> queryList(ShipperLeaseDetailsDO shipperLeaseDetailsDO)
{
return shipperLeaseDetailsMapper.queryList(shipperLeaseDetailsDO);
}
/**
* 新增货主租赁明细
*/
@Override
public Boolean insert(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
ShipperLeaseDetails shipperLeaseDetails = new ShipperLeaseDetails();
BeanUtils.copyProperties(shipperLeaseDetailsDO,shipperLeaseDetails);
return this.save(shipperLeaseDetails);
}
/**
* 修改货主租赁明细
*/
@Override
public Boolean update(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
ShipperLeaseDetails shipperLeaseDetails = new ShipperLeaseDetails();
BeanUtils.copyProperties(shipperLeaseDetailsDO,shipperLeaseDetails);
return this.updateById(shipperLeaseDetails);
}
/**
* 批量删除货主租赁明细
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean delete(Long[] leaseIds ) {
LoginUser loginUser = SecurityUtils.getLoginUser();
List<ShipperLeaseDetails> list = new ArrayList<>();
for (Long id : leaseIds) {
ShipperLeaseDetails shipperLeaseDetails = new ShipperLeaseDetails();
shipperLeaseDetails.setId(id);
shipperLeaseDetails.setDelFlag(2);
shipperLeaseDetails.setUpdateBy(loginUser.getUserid());
shipperLeaseDetails.setUpdateByName(loginUser.getUsername());
shipperLeaseDetails.setUpdateTime(new Date());
list.add(shipperLeaseDetails);
}
return this.updateBatchById(list);
}
/**
* 修改货主租赁明细
*/
@Override
public ShipperLeaseDetailsPO getInfo(Long ShipperLeaseDetailsId) {
ShipperLeaseDetails shipperLeaseDetails = this.getById(ShipperLeaseDetailsId);
ShipperLeaseDetailsPO shipperLeaseDetailsPO = new ShipperLeaseDetailsPO();
BeanUtils.copyProperties(shipperLeaseDetails,shipperLeaseDetailsPO);
return shipperLeaseDetailsPO;
}
// /**
// * @description 校验唯一
// * @author ZhouGY
// * @date 2024/5/9 21:10
// * @param containerDO
// */
// private void verifyUniqueness(ContainerDO containerDO){
// LoginUser loginUser = SecurityUtils.getLoginUser();
// Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
// if (topOrganizationId == null || topOrganizationId == 0 ){
// throw new ServiceException("获取当前登陆人组织失败!");
// }
// int count = leaseMapper.selectCount(new QueryWrapper<Container>().lambda()
// .eq(Container::getTopOrganizationId, topOrganizationId)
// .eq(Container::getContainerCode,containerDO.getContainerCode())
// .eq(Container::getOrganizationId, containerDO.getOrganizationId())
// .ne(containerDO.getContainerId() != null, Container::getContainerId, containerDO.getContainerId() )
// .eq(Container::getDelFlag,1));
// if (count > 0){
// throw new ServiceException("容器编码【" + containerDO.getContainerCode() + "】已存在");
// }
// }
}
@@ -0,0 +1,65 @@
package com.mhd.basic.domain.shipperLeaseDetails.repository.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 货主租赁明细
*
*/
@Data
public class ShipperLeaseDetailsPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
@TableId(type = IdType.AUTO)
private Long id;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("仓库ID")
private Long warehouseId;
@ApiModelProperty("仓库名字")
private String warehouseName;
@ApiModelProperty("货主id")
private Long shipperId;
@ApiModelProperty("货主名称")
private String cargoOwnerName;
@ApiModelProperty(value = "租赁方式(整租/散租)")
private String leaseType;
@ApiModelProperty("租赁面积(m²)")
private BigDecimal leaseArea;
@ApiModelProperty("业务日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date businessDate;
}
@@ -0,0 +1,73 @@
package com.mhd.basic.domain.shipperLeaseDetails.repository.todo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 货主租赁明细
*
*/
@Data
public class ShipperLeaseDetailsDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
@TableId(type = IdType.AUTO)
private Long id;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("仓库ID")
private Long warehouseId;
@ApiModelProperty("仓库名字")
private String warehouseName;
@ApiModelProperty("货主id")
private Long shipperId;
@ApiModelProperty("货主名称")
private String cargoOwnerName;
@ApiModelProperty(value = "租赁方式(整租/散租)")
private String leaseType;
@ApiModelProperty("租赁面积(m²)")
private BigDecimal leaseArea;
@ApiModelProperty("业务日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date businessDate;
@ApiModelProperty("业务日期开始时间")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date businessDateStart;
@ApiModelProperty("业务日期结束时间")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date businessDateEnd;
}
@@ -0,0 +1,87 @@
package com.mhd.basic.domain.shipperLeaseDetails.service;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.mhd.basic.domain.lease.entity.Lease;
import com.mhd.basic.domain.lease.repository.facade.ILeaseService;
import com.mhd.basic.domain.lease.repository.po.LeasePO;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import com.mhd.basic.domain.shipperLeaseDetails.entity.ShipperLeaseDetails;
import com.mhd.basic.domain.shipperLeaseDetails.repository.facade.IShipperLeaseDetailsService;
import com.mhd.basic.domain.shipperLeaseDetails.repository.po.ShipperLeaseDetailsPO;
import com.mhd.basic.domain.shipperLeaseDetails.repository.todo.ShipperLeaseDetailsDO;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 租赁管理
*
*/
@Service
@Slf4j
public class ShipperLeaseDetailsDomainService {
@Autowired
private IShipperLeaseDetailsService shipperLeaseDetailsService;
/**
* 分页查询租赁管理列表
*/
public List<ShipperLeaseDetailsPO> queryList(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
return shipperLeaseDetailsService.queryList(shipperLeaseDetailsDO);
}
/**
* 新增租赁管理
*/
public Boolean insert(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
return shipperLeaseDetailsService.insert(shipperLeaseDetailsDO);
}
/**
* 修改租赁管理
*/
public Boolean update(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
return shipperLeaseDetailsService.update(shipperLeaseDetailsDO);
}
/**
* 批量删除租赁管理
*/
public Boolean delete(Long[] shipperLeaseDetailsIds) {
return shipperLeaseDetailsService.delete(shipperLeaseDetailsIds);
}
/**
* 获取租赁管理详细信息
*/
public ShipperLeaseDetailsPO getInfo(Long shipperLeaseDetailsId)
{
return shipperLeaseDetailsService.getInfo(shipperLeaseDetailsId);
}
/**
* @description 批量作废租赁
* @author ZhouGY
* @date 2024/5/13 9:46
* @param leaseIds
* @return Boolean
*/
public Boolean nullifyByIds(List<Long> leaseIds) {
LoginUser loginUser = SecurityUtils.getLoginUser();
return shipperLeaseDetailsService.update(new UpdateWrapper<ShipperLeaseDetails>().lambda()
.set(ShipperLeaseDetails::getUpdateBy, loginUser.getUserid())
.set(ShipperLeaseDetails::getUpdateTime, new Date())
.in(ShipperLeaseDetails::getId, leaseIds)
.eq(ShipperLeaseDetails::getDelFlag, 1));
}
}
@@ -0,0 +1,116 @@
package com.mhd.basic.interfaces.assember.lease;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.mhd.basic.domain.container.repository.todo.ContainerDO;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import com.mhd.basic.interfaces.dto.container.ContainerDTO;
import com.mhd.basic.interfaces.dto.lease.LeaseDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.IgnoreNullUtil;
import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.domain.WarehouseFeignPO;
import com.mhd.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* 容器管理Assembler
*
*/
@Component
public class LeaseAssembler {
@Autowired
private SystemServiceFeign systemServiceFeign;
/**
* 转换实体
*/
public LeaseDO toDO(LeaseDTO leaseDTO) {
LeaseDO leaseDO = new LeaseDO();
// 拷贝
BeanUtils.copyProperties(leaseDTO, leaseDO, IgnoreNullUtil.getNullPropertyNames(leaseDTO));
// 确保查询条件字段被正确传递(查询条件字段需要明确传递,避免被IgnoreNullUtil忽略)
leaseDO.setCreateTimeStart(leaseDTO.getCreateTimeStart());
leaseDO.setCreateTimeEnd(leaseDTO.getCreateTimeEnd());
leaseDO.setUpdateTimeStart(leaseDTO.getUpdateTimeStart());
leaseDO.setUpdateTimeEnd(leaseDTO.getUpdateTimeEnd());
return leaseDO;
}
/**
* 转换实体
*/
public LeaseDO toDOByEdit(LeaseDTO leaseDTO) {
LeaseDO leaseDO = new LeaseDO();
// 拷贝
BeanUtils.copyProperties(leaseDTO, leaseDO, IgnoreNullUtil.getNullPropertyNames(leaseDTO));
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(leaseDTO.getId() != null){
leaseDO.setUpdateBy(loginUser.getUserid());
leaseDO.setUpdateByName(loginUser.getUsername());
leaseDO.setUpdateTime(new Date());
}else {
leaseDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
leaseDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
leaseDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
leaseDO.setCreateBy(loginUser.getUserid());
leaseDO.setCreateByName(loginUser.getUsername());
leaseDO.setCreateTime(new Date());
// 新增时根据仓库ID查询仓库名字
if (leaseDO.getWarehouseId() != null) {
setWarehouseInfo(leaseDO);
}
}
return leaseDO;
}
/**
* 设置仓库信息
*/
private void setWarehouseInfo(LeaseDO leaseDO) {
if (leaseDO.getWarehouseId() == null) {
return;
}
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(leaseDO.getWarehouseId());
if (ajaxResult == null) {
throw new ServiceException("获取仓库信息失败:返回结果为空,仓库ID:" + leaseDO.getWarehouseId());
}
Object codeObj = ajaxResult.get("code");
if (codeObj == null || !"200".equals(String.valueOf(codeObj))) {
String errorMsg = ajaxResult.get("msg") != null ? String.valueOf(ajaxResult.get("msg")) : "未知错误";
throw new ServiceException("获取仓库信息失败,仓库ID" + leaseDO.getWarehouseId() + ",错误信息:" + errorMsg);
}
Object dataObj = ajaxResult.get("data");
if (dataObj == null) {
throw new ServiceException("获取仓库信息失败:返回数据为空,仓库ID:" + leaseDO.getWarehouseId());
}
String dataJsonString = JSONObject.toJSONString(dataObj);
if (dataJsonString == null || dataJsonString.isEmpty() || "null".equals(dataJsonString)) {
throw new ServiceException("获取仓库信息失败:返回数据为空或格式不正确,仓库ID:" + leaseDO.getWarehouseId());
}
WarehouseFeignPO warehouseFeignPO;
try {
warehouseFeignPO = JSON.parseObject(dataJsonString, WarehouseFeignPO.class);
} catch (Exception e) {
throw new ServiceException("获取仓库信息失败:数据解析异常,仓库ID:" + leaseDO.getWarehouseId() + ",错误信息:" + e.getMessage());
}
if (warehouseFeignPO == null) {
throw new ServiceException("获取仓库信息失败:数据解析失败,仓库ID:" + leaseDO.getWarehouseId());
}
leaseDO.setWarehouseName(warehouseFeignPO.getWarehouseName());
}
}
@@ -0,0 +1,61 @@
package com.mhd.basic.interfaces.assember.shipperLeaseDetails;
import cn.hutool.core.util.ObjectUtil;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import com.mhd.basic.domain.shipperLeaseDetails.repository.todo.ShipperLeaseDetailsDO;
import com.mhd.basic.interfaces.dto.lease.LeaseDTO;
import com.mhd.basic.interfaces.dto.shipperLeaseDetailsApi.ShipperLeaseDetailsDTO;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.IgnoreNullUtil;
import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* 货主租赁明细Assembler
*
*/
@Component
public class ShipperLeaseDetailsAssembler {
/**
* 转换实体
*/
public ShipperLeaseDetailsDO toDO(ShipperLeaseDetailsDTO shipperLeaseDetailsDTO) {
ShipperLeaseDetailsDO shipperLeaseDetailsDO = new ShipperLeaseDetailsDO();
// 拷贝
BeanUtils.copyProperties(shipperLeaseDetailsDTO, shipperLeaseDetailsDO, IgnoreNullUtil.getNullPropertyNames(shipperLeaseDetailsDTO));
return shipperLeaseDetailsDO;
}
/**
* 转换实体
*/
public ShipperLeaseDetailsDO toDOByEdit(ShipperLeaseDetailsDTO shipperLeaseDetailsDTO) {
ShipperLeaseDetailsDO shipperLeaseDetailsDO = new ShipperLeaseDetailsDO();
// 拷贝
BeanUtils.copyProperties(shipperLeaseDetailsDTO, shipperLeaseDetailsDO, IgnoreNullUtil.getNullPropertyNames(shipperLeaseDetailsDTO));
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(shipperLeaseDetailsDTO.getId() != null){
shipperLeaseDetailsDO.setUpdateBy(loginUser.getUserid());
shipperLeaseDetailsDO.setUpdateByName(loginUser.getUsername());
shipperLeaseDetailsDO.setUpdateTime(new Date());
}else {
shipperLeaseDetailsDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
shipperLeaseDetailsDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
shipperLeaseDetailsDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
shipperLeaseDetailsDO.setCreateBy(loginUser.getUserid());
shipperLeaseDetailsDO.setCreateByName(loginUser.getUsername());
shipperLeaseDetailsDO.setCreateTime(new Date());
}
return shipperLeaseDetailsDO;
}
}
@@ -44,6 +44,10 @@ public class BatchDetailDTO extends BaseVOEntity{
@Excel(name = "批次标签") @Excel(name = "批次标签")
private String batchLabels; private String batchLabels;
@ApiModelProperty("字段名称")
@Excel(name = "字段名称")
private String fieldName;
@ApiModelProperty("输入控制: 1-必填 2-可选") @ApiModelProperty("输入控制: 1-必填 2-可选")
@Excel(name = "输入控制: 1-必填 2-可选") @Excel(name = "输入控制: 1-必填 2-可选")
private String inputControl; private String inputControl;
@@ -56,6 +60,10 @@ public class BatchDetailDTO extends BaseVOEntity{
@Excel(name = "属性选项") @Excel(name = "属性选项")
private String attributeOption; private String attributeOption;
@ApiModelProperty("是否显示: 0-不显示 1-显示")
@Excel(name = "是否显示: 0-不显示 1-显示")
private Integer isDisplay;
@ApiModelProperty("备注") @ApiModelProperty("备注")
@Excel(name = "备注") @Excel(name = "备注")
private String remark; private String remark;
@@ -0,0 +1,80 @@
package com.mhd.basic.interfaces.dto.lease;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 租赁管理对象 container
*
*/
@Data
public class LeaseDTO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("仓库ID")
private Long warehouseId;
@ApiModelProperty("仓库名字")
private String warehouseName;
@ApiModelProperty("货主id")
private Long shipperId;
@ApiModelProperty("货主名称")
private String cargoOwnerName;
@ApiModelProperty(value = "租赁方式(整租/散租)")
private String leaseType;
@ApiModelProperty("租赁面积(m²)")
private BigDecimal leaseArea;
@ApiModelProperty("开始日期")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date startDate;
@ApiModelProperty("结束日期")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date endDate;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty(name = "创建时间查询条件开始日期")
private String createTimeStart;
@ApiModelProperty(name = "创建时间查询条件结束日期")
private String createTimeEnd;
@ApiModelProperty(name = "修改时间查询条件开始日期")
private String updateTimeStart;
@ApiModelProperty(name = "修改时间查询条件结束日期")
private String updateTimeEnd;
}
@@ -181,4 +181,183 @@ public class MaterialBaseInfoDTO extends BaseVOEntity{
@ApiModelProperty("是否公用: 1-是 2-否") @ApiModelProperty("是否公用: 1-是 2-否")
@Excel(name = "是否公用: 1-是 2-否") @Excel(name = "是否公用: 1-是 2-否")
private Integer common; private Integer common;
/**
* 商品名称
*/
@ApiModelProperty("商品名称")
@Excel(name = "商品名称")
private String commodityName;
/**
* 商品编码
*/
@ApiModelProperty("商品编码")
@Excel(name = "商品编码")
private String commodityNo;
/**
* 料号
*/
@ApiModelProperty("料号")
@Excel(name = "料号")
private String materialNo;
/**
* 规格型号
*/
@ApiModelProperty("规格型号")
@Excel(name = "规格型号")
private String specificationModel;
/**
* Invoice No
*/
@ApiModelProperty("Invoice No")
@Excel(name = "Invoice No")
private String invoiceNo;
/**
* 升
*/
@ApiModelProperty("")
@Excel(name = "")
private String liter;
/**
* 尺寸
*/
@ApiModelProperty("尺寸")
@Excel(name = "尺寸")
private String size;
/**
* 申报单位
*/
@ApiModelProperty("申报单位")
@Excel(name = "申报单位")
private String declareUnit;
/**
* Batch Ref NOs
*/
@ApiModelProperty("Batch Ref NOs")
@Excel(name = "Batch Ref NOs")
private String batchRefNo;
/**
* Sheet Ref NOs
*/
@ApiModelProperty("Sheet Ref NOs")
@Excel(name = "Sheet Ref NOs")
private String sheetRefNo;
/**
* 原产国
*/
@ApiModelProperty("原产国")
@Excel(name = "原产国")
private String countryOfOrigin;
/**
* 箱号/卡板号
*/
@ApiModelProperty("箱号/卡板号")
@Excel(name = "箱号/卡板号")
private String casePalletNo;
/**
* 币制
*/
@ApiModelProperty("币制")
@Excel(name = "币制")
private String currency;
/**
* 申报数量
*/
@ApiModelProperty("申报数量")
@Excel(name = "申报数量")
private Double declareQuantity;
/**
* 箱数
*/
@ApiModelProperty("箱数")
@Excel(name = "箱数")
private Double caseCount;
/**
* 件数
*/
@ApiModelProperty("件数")
@Excel(name = "件数")
private Double pieceCount;
/**
* 出库数量
*/
@ApiModelProperty("出库数量")
@Excel(name = "出库数量")
private Double outboundQuantity;
/**
* 总净重(KG)
*/
@ApiModelProperty("总净重(KG)")
@Excel(name = "总净重(KG)")
private Double totalNetWeight;
/**
* 总毛重(KG)
*/
@ApiModelProperty("总毛重(KG)")
@Excel(name = "总毛重(KG)")
private Double totalGrossWeight;
/**
* 总体积(CBM)
*/
@ApiModelProperty("总体积(CBM)")
@Excel(name = "总体积(CBM)")
private Double totalVolume;
/**
* 总面积(SQM)
*/
@ApiModelProperty("总面积(SQM)")
@Excel(name = "总面积(SQM)")
private Double totalArea;
/**
* 总价
*/
@ApiModelProperty("总价")
@Excel(name = "总价")
private Double totalAmount;
/**
* 单位
*/
@ApiModelProperty("单位")
@Excel(name = "单位")
private String unit;
@ApiModelProperty("SKU码")
private String skuCode;
@ApiModelProperty("单价")
private BigDecimal unitPrice;
@ApiModelProperty("原产国")
private String originCountry;
@ApiModelProperty("HS码")
private String hsCode;
@ApiModelProperty("申报单位")
private String declarationUnit;
@ApiModelProperty("法定单位")
private String statutoryUnit;
@ApiModelProperty("法定第二单位")
private String statutorySecondUnit;
} }
@@ -0,0 +1,74 @@
package com.mhd.basic.interfaces.dto.shipperLeaseDetailsApi;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 货主租赁明细
*
*/
@Data
public class ShipperLeaseDetailsDTO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
@TableId(type = IdType.AUTO)
private Long id;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("仓库ID")
private Long warehouseId;
@ApiModelProperty("仓库名字")
private String warehouseName;
@ApiModelProperty("货主id")
private Long shipperId;
@ApiModelProperty("货主名称")
private String cargoOwnerName;
@ApiModelProperty(value = "租赁方式(整租/散租)")
private String leaseType;
@ApiModelProperty("租赁面积(m²)")
private BigDecimal leaseArea;
@ApiModelProperty("业务日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date businessDate;
@ApiModelProperty("业务日期开始时间")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date businessDateStart;
@ApiModelProperty("业务日期结束时间")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date businessDateEnd;
}
@@ -0,0 +1,112 @@
package com.mhd.basic.interfaces.facadeApi.lease;
import com.mhd.basic.application.service.Lease.LeaseApplicationService;
import com.mhd.basic.application.service.container.ContainerApplicationService;
import com.mhd.basic.domain.container.repository.po.ContainerPO;
import com.mhd.basic.domain.container.repository.todo.ContainerDO;
import com.mhd.basic.domain.lease.repository.po.LeasePO;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import com.mhd.basic.domain.shipperLeaseDetails.entity.WarehouseOccupancyRate;
import com.mhd.basic.interfaces.assember.container.ContainerAssembler;
import com.mhd.basic.interfaces.assember.lease.LeaseAssembler;
import com.mhd.basic.interfaces.dto.container.ContainerDTO;
import com.mhd.basic.interfaces.dto.lease.LeaseDTO;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 租赁管理Api
*/
@RestController
@RequestMapping("/LeaseApi")
public class LeaseApi extends BaseController{
@Autowired
private LeaseApplicationService leaseApplicationService;
@Resource
private LeaseAssembler leaseAssembler;
/**
* 分页查询租赁管理列表
*/
@ApiOperation("查询租赁管理列表")
@GetMapping("/list")
public TableDataInfo list(LeaseDTO leaseDTO)
{
//转换实体
LeaseDO leaseDO = leaseAssembler.toDO(leaseDTO);
startPage();
List<LeasePO> list = leaseApplicationService.queryList(leaseDO);
return getDataTable(list);
}
/**
* 分页查询租赁管理列表
*/
@ApiOperation("查询租赁管理列表")
@GetMapping("/listByApp")
public AjaxResult listByApp(LeaseDTO leaseDTO)
{
//转换实体
LeaseDO leaseDO = leaseAssembler.toDO(leaseDTO);
List<LeasePO> list = leaseApplicationService.queryList(leaseDO);
return AjaxResult.success(list);
}
/**
* 编辑租赁管理
*/
@ApiOperation("编辑租赁管理")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody LeaseDTO leaseDTO)
{
//转换实体
LeaseDO leaseDO = leaseAssembler.toDOByEdit(leaseDTO);
if(leaseDTO.getId() != null){
return toAjax(leaseApplicationService.update(leaseDO));
}else {
return toAjax(leaseApplicationService.insert(leaseDO));
}
}
/**
* 批量删除租赁管理
*/
@ApiOperation("批量删除租赁管理")
@DeleteMapping("/deleteByIds/{leaseIds}")
public AjaxResult delete(@PathVariable Long[] leaseIds)
{
return toAjax(leaseApplicationService.delete(leaseIds));
}
/**
* 获取租赁管理详细信息
*/
@ApiOperation("获取租赁管理")
@GetMapping(value = "/getInfo/{leaseId}")
public AjaxResult getInfo(@PathVariable("leaseId") Long leaseId)
{
return AjaxResult.success(leaseApplicationService.getInfo(leaseId));
}
/**
* 批量作废租赁
*/
@ApiOperation("批量作废租赁")
@GetMapping("/nullifyByIds/{leaseIds}")
public AjaxResult nullifyByIds(@PathVariable("leaseIds") List<Long> leaseIds)
{
return toAjax(leaseApplicationService.nullifyByIds(leaseIds));
}
}
@@ -0,0 +1,161 @@
package com.mhd.basic.interfaces.facadeApi.shipperLeaseDetails;
import com.mhd.basic.application.service.Lease.LeaseApplicationService;
import com.mhd.basic.application.service.shipperLeaseDetails.ShipperLeaseDetailsApplicationService;
import com.mhd.basic.domain.lease.repository.po.LeasePO;
import com.mhd.basic.domain.lease.repository.todo.LeaseDO;
import com.mhd.basic.domain.shipperLeaseDetails.entity.ShipperLeaseDetails;
import com.mhd.basic.domain.shipperLeaseDetails.entity.WarehouseOccupancyRate;
import com.mhd.basic.domain.shipperLeaseDetails.repository.po.ShipperLeaseDetailsPO;
import com.mhd.basic.domain.shipperLeaseDetails.repository.todo.ShipperLeaseDetailsDO;
import com.mhd.basic.interfaces.assember.lease.LeaseAssembler;
import com.mhd.basic.interfaces.assember.shipperLeaseDetails.ShipperLeaseDetailsAssembler;
import com.mhd.basic.interfaces.dto.lease.LeaseDTO;
import com.mhd.basic.interfaces.dto.shipperLeaseDetailsApi.ShipperLeaseDetailsDTO;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* 货主租赁明细Api
*/
@RestController
@RequestMapping("/ShipperLeaseDetailsApi")
public class ShipperLeaseDetailsApi extends BaseController{
@Autowired
private LeaseApplicationService leaseApplicationService;
@Autowired
private ShipperLeaseDetailsApplicationService shipperLeaseDetailsApplicationService;
@Resource
private ShipperLeaseDetailsAssembler shipperLeaseDetailsAssembler;
/**
* 分页查询货主租赁明细列表
*/
@ApiOperation("查询货主租赁明细列表")
@GetMapping("/list")
public TableDataInfo list(ShipperLeaseDetailsDTO shipperLeaseDetailsDTO)
{
//转换实体
ShipperLeaseDetailsDO shipperLeaseDetailsDO = shipperLeaseDetailsAssembler.toDO(shipperLeaseDetailsDTO);
startPage();
List<ShipperLeaseDetailsPO> list = shipperLeaseDetailsApplicationService.queryList(shipperLeaseDetailsDO);
return getDataTable(list);
}
/**
* 分页查询货主租赁明细列表
*/
@ApiOperation("查询货主租赁明细列表")
@GetMapping("/listByApp")
public AjaxResult listByApp(ShipperLeaseDetailsDTO shipperLeaseDetailsDTO)
{
//转换实体
ShipperLeaseDetailsDO shipperLeaseDetailsDO = shipperLeaseDetailsAssembler.toDO(shipperLeaseDetailsDTO);
List<ShipperLeaseDetailsPO> list = shipperLeaseDetailsApplicationService.queryList(shipperLeaseDetailsDO);
return AjaxResult.success(list);
}
/**
* 编辑货主租赁明细
*/
@ApiOperation("编辑货主租赁明细")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody ShipperLeaseDetailsDTO shipperLeaseDetailsDTO)
{
//转换实体
ShipperLeaseDetailsDO shipperLeaseDetailsDO = shipperLeaseDetailsAssembler.toDOByEdit(shipperLeaseDetailsDTO);
if(shipperLeaseDetailsDTO.getId() != null){
return toAjax(shipperLeaseDetailsApplicationService.update(shipperLeaseDetailsDO));
}else {
return toAjax(shipperLeaseDetailsApplicationService.insert(shipperLeaseDetailsDO));
}
}
/**
* 编辑货主租赁明细
*/
@ApiOperation("编辑货主租赁明细")
@PostMapping("/editList")
public AjaxResult edit(@RequestBody List<ShipperLeaseDetailsDTO> shipperLeaseDetailsDTO)
{
for (ShipperLeaseDetailsDTO leaseDetailsDTO : shipperLeaseDetailsDTO) {
//转换实体
ShipperLeaseDetailsDO shipperLeaseDetailsDO = shipperLeaseDetailsAssembler.toDOByEdit(leaseDetailsDTO);
shipperLeaseDetailsApplicationService.update(shipperLeaseDetailsDO);
}
return AjaxResult.success();
}
/**
* 批量删除货主租赁明细
*/
@ApiOperation("批量删除货主租赁明细")
@DeleteMapping("/deleteByIds/{shipperLeaseDetailsIds}")
public AjaxResult delete(@PathVariable Long[] shipperLeaseDetailsIds)
{
return toAjax(shipperLeaseDetailsApplicationService.delete(shipperLeaseDetailsIds));
}
/**
* 获取货主租赁明细详细信息
*/
@ApiOperation("获取货主租赁明细")
@GetMapping(value = "/getInfo/{shipperLeaseDetailsId}")
public AjaxResult getInfo(@PathVariable("shipperLeaseDetailsId") Long shipperLeaseDetailsId)
{
return AjaxResult.success(shipperLeaseDetailsApplicationService.getInfo(shipperLeaseDetailsId));
}
/**
* 批量作废租赁
*/
@ApiOperation("批量作废租赁")
@GetMapping("/nullifyByIds/{shipperLeaseDetailsIds}")
public AjaxResult nullifyByIds(@PathVariable("shipperLeaseDetailsIds") List<Long> shipperLeaseDetailsIds)
{
return toAjax(shipperLeaseDetailsApplicationService.nullifyByIds(shipperLeaseDetailsIds));
}
/**
* 计算货主租赁明细
*/
@ApiOperation("货主租赁明细")
@PostMapping("/shipperLeaseDetails")
public AjaxResult shipperLeaseDetails()
{
leaseApplicationService.shipperLeaseDetails();
return AjaxResult.success();
}
/**
* 计算仓库出租率
* warehouseId 仓库id
*/
@ApiOperation("仓库出租率")
@PostMapping("/warehouseOccupancyRate")
public TableDataInfo warehouseOccupancyRate(@RequestBody ShipperLeaseDetailsDTO shipperLeaseDetailsDTO)
{
ShipperLeaseDetailsDO shipperLeaseDetailsDO = shipperLeaseDetailsAssembler.toDO(shipperLeaseDetailsDTO);
List<WarehouseOccupancyRate> warehouseOccupancyRates = leaseApplicationService.warehouseOccupancyRate(shipperLeaseDetailsDO);
// 按照businessDate倒序排序
warehouseOccupancyRates = warehouseOccupancyRates.stream()
.sorted(Comparator.comparing(WarehouseOccupancyRate::getBusinessDate, Comparator.nullsLast(Comparator.reverseOrder())))
.collect(Collectors.toList());
return getDataTable(warehouseOccupancyRates);
}
}
@@ -13,10 +13,10 @@ spring:
cloud: cloud:
nacos: nacos:
discovery: discovery:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# server-addr: 10.33.0.129:6010 # server-addr: 10.33.0.129:6010
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
@@ -25,7 +25,7 @@ spring:
# server-addr: 127.0.0.1:8848 # server-addr: 127.0.0.1:8848
# server-addr: 10.33.0.129:6010 # server-addr: 10.33.0.129:6010
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
@@ -11,9 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="topOrganizationId" column="top_organization_id" /> <result property="topOrganizationId" column="top_organization_id" />
<result property="batchId" column="batch_id" /> <result property="batchId" column="batch_id" />
<result property="batchLabels" column="batch_labels" /> <result property="batchLabels" column="batch_labels" />
<result property="fieldName" column="field_name" />
<result property="inputControl" column="input_control" /> <result property="inputControl" column="input_control" />
<result property="attributeFormat" column="attribute_format" /> <result property="attributeFormat" column="attribute_format" />
<result property="attributeOption" column="attribute_option" /> <result property="attributeOption" column="attribute_option" />
<result property="isDisplay" column="is_display" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
@@ -26,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectBatchDetailPo"> <sql id="selectBatchDetailPo">
select batch_detail_id, organization_id, organization_name, top_organization_id, batch_id, batch_labels, input_control, attribute_format, attribute_option, remark, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from batch_detail select batch_detail_id, organization_id, organization_name, top_organization_id, batch_id, batch_labels, field_name, input_control, attribute_format, attribute_option, is_display, remark, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from batch_detail
</sql> </sql>
<sql id="selectBatchDetailPo1"> <sql id="selectBatchDetailPo1">
@@ -46,6 +48,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="batchLabels != null and batchLabels != ''"> <if test="batchLabels != null and batchLabels != ''">
and batch_labels = #{batchLabels} and batch_labels = #{batchLabels}
</if> </if>
<if test="fieldName != null and fieldName != ''">
and field_name = #{fieldName}
</if>
<if test="inputControl != null "> <if test="inputControl != null ">
and input_control = #{inputControl} and input_control = #{inputControl}
</if> </if>
@@ -55,6 +60,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attributeOption != null and attributeOption != ''"> <if test="attributeOption != null and attributeOption != ''">
and attribute_option = #{attributeOption} and attribute_option = #{attributeOption}
</if> </if>
<if test="isDisplay != null ">
and is_display = #{isDisplay}
</if>
<if test="createByName != null and createByName != ''"> <if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%') and create_by_name like concat('%', #{createByName}, '%')
</if> </if>
@@ -0,0 +1,129 @@
<?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">
<mapper namespace="com.mhd.basic.domain.lease.repository.mapper.LeaseMapper">
<resultMap type="com.mhd.basic.domain.lease.repository.po.LeasePO" id="LeaseResult">
<!-- 租赁相关字段 -->
<result property="id" column="id" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="topOrganizationId" column="top_organization_id" />
<result property="cargoOwnerName" column="cargo_owner_name" />
<result property="leaseType" column="lease_type" />
<result property="leaseArea" column="lease_area" />
<result property="startDate" column="start_date" />
<result property="endDate" column="end_date" />
<result property="remark" column="remark" />
<!-- 继承自BaseVOEntity的字段 -->
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="createByName" column="create_by_name" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="updateByName" column="update_by_name" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectLeasePo">
select
a.id,
a.organization_id,
a.organization_name,
a.top_organization_id,
a.warehouse_id,
COALESCE(w.warehouse_name, a.warehouse_name) as warehouse_name,
a.shipper_id,
a.cargo_owner_name,
a.lease_type,
a.lease_area,
a.start_date,
a.end_date,
a.remark,
a.create_time,
a.create_by,
a.create_by_name,
a.update_time,
a.update_by,
a.update_by_name,
a.del_flag
from lease a
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
</sql>
<sql id="selectLeasePo1">
<where>
<!-- 租赁查询条件 -->
<if test="organizationId != null ">
and a.organization_id = #{organizationId}
</if>
<if test="topOrganizationId != null ">
and a.top_organization_id = #{topOrganizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and a.organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="warehouseId != null ">
and a.warehouse_id = #{warehouseId}
</if>
<if test="warehouseName != null and warehouseName != ''">
and (w.warehouse_name like concat('%', #{warehouseName}, '%') or a.warehouse_name like concat('%', #{warehouseName}, '%'))
</if>
<if test="cargoOwnerName != null and cargoOwnerName != ''">
and a.cargo_owner_name like concat('%', #{cargoOwnerName}, '%')
</if>
<if test="leaseType != null and leaseType != ''">
and a.lease_type = #{leaseType}
</if>
<if test="createTime != null ">
and a.create_time = #{createTime}
</if>
<if test="leaseArea != null ">
and a.lease_area = #{leaseArea}
</if>
<if test="remark != null and remark != ''">
and a.remark like concat('%', #{remark}, '%')
</if>
<!-- 创建和更新相关条件 -->
<if test="createByName != null and createByName != ''">
and a.create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="updateByName != null and updateByName != ''">
and a.update_by_name like concat('%', #{updateByName}, '%')
</if>
<if test="createTimeStart != null and createTimeStart != ''">
and date_format(a.create_time,'%Y-%m-%d') &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''">
and date_format(a.create_time,'%Y-%m-%d') &lt;= #{createTimeEnd}
</if>
<if test="updateTimeStart != null and updateTimeStart != ''">
and date_format(a.update_time,'%Y-%m-%d') &gt;= #{updateTimeStart}
</if>
<if test="updateTimeEnd != null and updateTimeEnd != ''">
and date_format(a.update_time,'%Y-%m-%d') &lt;= #{updateTimeEnd}
</if>
<!-- 时间范围查询(如果需要) -->
<if test="startDate != null and endDate != null">
and a.start_date &gt;= #{startDate} and a.start_date &lt;= #{endDate}
</if>
<if test="time != null">
AND a.start_date &lt;= #{time}
AND a.end_date &gt;= #{time}
</if>
<!-- 删除标记 -->
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</where>
</sql>
<select id="queryList" parameterType="com.mhd.basic.domain.lease.repository.po.LeasePO" resultMap="LeaseResult">
<include refid="selectLeasePo"/>
<include refid="selectLeasePo1"/>
ORDER BY a.create_time DESC
</select>
</mapper>
@@ -54,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select material_base_info_id, organization_id, organization_name, top_organization_id, shipper_id, shipper_name, material_code, material_name, bar_code, material_classify_code, select material_base_info_id, organization_id, organization_name, top_organization_id, shipper_id, shipper_name, material_code, material_name, bar_code, material_classify_code,
material_classify_name, material_type, material_type_name, pack_id, pack_code, pack_name, unit_code, unit_name, brand_id, brand_code, brand_name, shelf_life, weight_limit, material_classify_name, material_type, material_type_name, pack_id, pack_code, pack_name, unit_code, unit_name, brand_id, brand_code, brand_name, shelf_life, weight_limit,
volume_limit, material_shape, material_shape_name, material_size, material_length, material_width, material_height, remark, nullify, create_time, create_by, create_by_name, volume_limit, material_shape, material_shape_name, material_size, material_length, material_width, material_height, remark, nullify, create_time, create_by, create_by_name,
update_time, update_by, update_by_name, del_flag, common,material_model,material_unit,machine_code update_time, update_by, update_by_name, del_flag, common,material_model,material_unit,machine_code,sku_code, unit_price, currency, origin_country, hs_code, declaration_unit, statutory_unit, statutory_second_unit
from material_base_info from material_base_info
</sql> </sql>
@@ -82,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and material_name like concat('%', #{materialName}, '%') and material_name like concat('%', #{materialName}, '%')
</if> </if>
<if test="barCode != null and barCode != ''"> <if test="barCode != null and barCode != ''">
and bar_code = #{barCode} and bar_code like concat('%',#{barCode},'%')
</if> </if>
<if test="materialClassifyCode != null and materialClassifyCode != ''"> <if test="materialClassifyCode != null and materialClassifyCode != ''">
and material_classify_code = #{materialClassifyCode} and material_classify_code = #{materialClassifyCode}
@@ -170,7 +170,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
and material_base_info_id in (SELECT and material_base_info_id in (SELECT
DISTINCT material_base_info_id DISTINCT material_base_info_id
FROM test_szwl_wms.material_inventory FROM ngwl_test_wms.material_inventory
WHERE WHERE
allocation_quantity > 0 allocation_quantity > 0
AND del_flag = 1) AND del_flag = 1)
@@ -178,6 +178,118 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="queryList" parameterType="com.mhd.basic.domain.materialBaseInfo.repository.todo.MaterialBaseInfoDO" resultMap="MaterialBaseInfoResult"> <select id="queryList" parameterType="com.mhd.basic.domain.materialBaseInfo.repository.todo.MaterialBaseInfoDO" resultMap="MaterialBaseInfoResult">
<include refid="selectMaterialBaseInfoPo"/> <include refid="selectMaterialBaseInfoPo"/>
<include refid="selectMaterialBaseInfoPo1"/> <include refid="selectMaterialBaseInfoPo2"/>
</select> </select>
<sql id="selectMaterialBaseInfoPo2">
<where>
<if test="organizationId != null ">
and organization_id = #{organizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId}
</if>
<if test="shipperId != null ">
and shipper_id = #{shipperId}
</if>
<if test="shipperName != null and shipperName != ''">
and shipper_name like concat('%', #{shipperName}, '%')
</if>
<if test="materialCode != null and materialCode != ''">
and material_code = #{materialCode}
</if>
<if test="materialName != null and materialName != ''">
and material_name like concat('%', #{materialName}, '%')
</if>
<if test="barCode != null and barCode != ''">
and bar_code like concat('%',#{barCode},'%')
</if>
<if test="materialClassifyCode != null and materialClassifyCode != ''">
and material_classify_code = #{materialClassifyCode}
</if>
<if test="materialClassifyName != null and materialClassifyName != ''">
and material_classify_name like concat('%', #{materialClassifyName}, '%')
</if>
<if test="materialType != null and materialType != ''">
and material_type = #{materialType}
</if>
<if test="materialTypeName != null and materialTypeName != ''">
and material_type_name like concat('%', #{materialTypeName}, '%')
</if>
<if test="unitCode != null and unitCode != ''">
and unit_code = #{unitCode}
</if>
<if test="unitName != null and unitName != ''">
and unit_name like concat('%', #{unitName}, '%')
</if>
<if test="packId != null ">
and pack_id = #{packId}
</if>
<if test="packCode != null and packCode != ''">
and pack_code = #{packCode}
</if>
<if test="packName != null and packName != ''">
and pack_name like concat('%', #{packName}, '%')
</if>
<if test="brandId != null ">
and brand_id = #{brandId}
</if>
<if test="brandCode != null and brandCode != ''">
and brand_code = #{brandCode}
</if>
<if test="brandName != null and brandName != ''">
and brand_name like concat('%', #{brandName}, '%')
</if>
<if test="shelfLife != null ">
and shelf_life = #{shelfLife}
</if>
<if test="weightLimit != null ">
and weight_limit = #{weightLimit}
</if>
<if test="volumeLimit != null ">
and volume_limit = #{volumeLimit}
</if>
<if test="materialShape != null and materialShape != ''">
and material_shape = #{materialShape}
</if>
<if test="materialShapeName != null and materialShapeName != ''">
and material_shape_name like concat('%', #{materialShapeName}, '%')
</if>
<if test="materialSize != null and materialSize != ''">
and material_size = #{materialSize}
</if>
<if test="materialLength != null ">
and material_length = #{materialLength}
</if>
<if test="materialWidth != null ">
and material_width = #{materialWidth}
</if>
<if test="materialHeight != null ">
and material_height = #{materialHeight}
</if>
<if test="nullify != null ">
and nullify = #{nullify}
</if>
<if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="updateByName != null and updateByName != ''">
and update_by_name like concat('%', #{updateByName}, '%')
</if>
<!-- 传 1:只查公共 , 2:只查自己的 ,3:公共的和自己的 -->
<choose>
<when test="common != null and (common == 1 or common == 2) "> and common = #{common} </when>
<otherwise> and (
1 = 1
or common = 1 )</otherwise>
</choose>
<choose>
<when test="delFlag != null"> and del_flag = #{delFlag} </when>
<otherwise> and del_flag = 1 </otherwise>
</choose>
</where>
</sql>
</mapper> </mapper>
@@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="openingUp" column="opening_up" /> <result property="openingUp" column="opening_up" />
<result property="nullify" column="nullify" /> <result property="nullify" column="nullify" />
<result property="unitName" column="unit_name" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createByName" column="create_by_name" /> <result property="createByName" column="create_by_name" />
@@ -27,7 +28,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectPackPo"> <sql id="selectPackPo">
select pack_id, organization_id, organization_name, top_organization_id, shipper_id, shipper_name, pack_code, pack_name, remark, opening_up, nullify, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from pack select a.pack_id, a.organization_id, a.organization_name, a.top_organization_id, a.shipper_id, a.shipper_name, a.pack_code, a.pack_name, a.remark, a.opening_up, a.nullify, a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name, a.del_flag,
(SELECT b.name FROM (SELECT name, pack_id FROM pack_detail WHERE pack_id = a.pack_id AND del_flag = 1 ORDER BY pack_detail_id) b WHERE ROWNUM = 1) as unit_name
from pack a
</sql> </sql>
<sql id="selectPackPo1"> <sql id="selectPackPo1">
@@ -0,0 +1,127 @@
<?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">
<mapper namespace="com.mhd.basic.domain.shipperLeaseDetails.repository.mapper.ShipperLeaseDetailsMapper">
<resultMap type="com.mhd.basic.domain.shipperLeaseDetails.repository.po.ShipperLeaseDetailsPO" id="ShipperLeaseDetailsResult">
<!-- 货主租赁明细字段 -->
<result property="id" column="id" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="topOrganizationId" column="top_organization_id" />
<result property="warehouseId" column="warehouse_id" />
<result property="warehouseName" column="warehouse_name" />
<result property="shipperId" column="shipper_id" />
<result property="cargoOwnerName" column="cargo_owner_name" />
<result property="leaseType" column="lease_type" />
<result property="leaseArea" column="lease_area" />
<result property="businessDate" column="business_date" />
<!-- 继承自BaseVOEntity的字段 -->
<result property="createBy" column="create_by" />
<result property="createByName" column="create_by_name" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateByName" column="update_by_name" />
<result property="updateTime" column="update_time" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectShipperLeaseDetailsVo">
select
id,
organization_id,
organization_name,
top_organization_id,
warehouse_id,
warehouse_name,
shipper_id,
cargo_owner_name,
lease_type,
lease_area,
business_date,
create_by,
create_by_name,
create_time,
update_by,
update_by_name,
update_time,
del_flag
from shipper_lease_details
</sql>
<sql id="selectShipperLeaseDetailsWhere">
<where>
<!-- 组织相关条件 -->
<if test="organizationId != null">
and organization_id = #{organizationId}
</if>
<if test="topOrganizationId != null">
and top_organization_id = #{topOrganizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%')
</if>
<!-- 仓库相关条件 -->
<if test="warehouseId != null">
and warehouse_id = #{warehouseId}
</if>
<!-- 业务日期时间范围 -->
<if test="businessDateStart != null">
and business_date &gt;= #{businessDateStart}
</if>
<if test="businessDateEnd != null">
and business_date &lt;= #{businessDateEnd}
</if>
<if test="warehouseName != null and warehouseName != ''">
and warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<!-- 货主相关条件 -->
<if test="shipperId != null">
and shipper_id = #{shipperId}
</if>
<if test="cargoOwnerName != null and cargoOwnerName != ''">
and cargo_owner_name like concat('%', #{cargoOwnerName}, '%')
</if>
<!-- 租赁相关条件 -->
<if test="leaseType != null and leaseType != ''">
and lease_type = #{leaseType}
</if>
<if test="leaseArea != null">
and lease_area = #{leaseArea}
</if>
<!-- 业务日期条件 -->
<if test="businessDate != null">
and business_date = #{businessDate}
</if>
<!-- 创建和更新相关条件 -->
<if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="updateByName != null and updateByName != ''">
and update_by_name like concat('%', #{updateByName}, '%')
</if>
<!-- 删除标记 -->
<choose>
<when test="delFlag != null"> and del_flag = #{delFlag} </when>
<otherwise> and del_flag = 1 </otherwise>
</choose>
</where>
</sql>
<select id="queryList" parameterType="com.mhd.basic.domain.shipperLeaseDetails.repository.po.ShipperLeaseDetailsPO" resultMap="ShipperLeaseDetailsResult">
<include refid="selectShipperLeaseDetailsVo"/>
<include refid="selectShipperLeaseDetailsWhere"/>
ORDER BY create_time DESC
</select>
</mapper>
@@ -51,130 +51,147 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectStorageLocationPo"> <sql id="selectStorageLocationPo">
select storage_location_id, organization_id, organization_name, top_organization_id, warehouse_id, warehouse_code, warehouse_name, storage_section_id, storage_code, storage_name, storage_location_code, storage_location_name, storage_location_classify, storage_location_classify_name, storage_location_type, storage_location_type_name, mixing_strategy, mixing_strategy_name, storage_location_group_id, storage_location_group_code, storage_location_group_name, weight_limit, volume_limit, location_size, location_length, location_width, location_height, coordinate, coordinate_area, coordinate_column, coordinate_row, coordinate_layer, remark, opening_up, nullify, status, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from storage_location select a.storage_location_id, a.organization_id, a.organization_name, a.top_organization_id, a.warehouse_id,
COALESCE(w.warehouse_code, a.warehouse_code) as warehouse_code,
COALESCE(w.warehouse_name, a.warehouse_name) as warehouse_name,
a.storage_section_id, a.storage_code, a.storage_name, a.storage_location_code, a.storage_location_name,
a.storage_location_classify, a.storage_location_classify_name, a.storage_location_type, a.storage_location_type_name,
a.mixing_strategy, a.mixing_strategy_name, a.storage_location_group_id, a.storage_location_group_code, a.storage_location_group_name,
a.weight_limit, a.volume_limit, a.location_size, a.location_length, a.location_width, a.location_height,
a.coordinate, a.coordinate_area, a.coordinate_column, a.coordinate_row, a.coordinate_layer, a.remark,
a.opening_up, a.nullify, a.status, a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name, a.del_flag
from storage_location a
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
</sql> </sql>
<sql id="selectStorageLocationPo1"> <sql id="selectStorageLocationPo1">
<where> <where>
<if test="organizationId != null "> <if test="organizationId != null ">
and organization_id = #{organizationId} and a.organization_id = #{organizationId}
</if> </if>
<if test="organizationName != null and organizationName != ''"> <if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%') and a.organization_name like concat('%', #{organizationName}, '%')
</if> </if>
<if test="topOrganizationId != null "> <if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId} and a.top_organization_id = #{topOrganizationId}
</if> </if>
<if test="warehouseId != null "> <if test="warehouseId != null ">
and warehouse_id = #{warehouseId} and a.warehouse_id = #{warehouseId}
</if> </if>
<if test="warehouseCode != null and warehouseCode != ''"> <if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode} and (w.warehouse_code like concat('%', #{warehouseCode}, '%') or a.warehouse_code like concat('%', #{warehouseCode}, '%'))
</if> </if>
<if test="warehouseName != null and warehouseName != ''"> <if test="warehouseName != null and warehouseName != ''">
and warehouse_name like concat('%', #{warehouseName}, '%') and (w.warehouse_name like concat('%', #{warehouseName}, '%') or a.warehouse_name like concat('%', #{warehouseName}, '%'))
</if> </if>
<if test="storageSectionId != null "> <if test="storageSectionId != null ">
and storage_section_id = #{storageSectionId} and a.storage_section_id = #{storageSectionId}
</if> </if>
<if test="storageCode != null and storageCode != ''"> <if test="storageCode != null and storageCode != ''">
and storage_code = #{storageCode} and a.storage_code = #{storageCode}
</if> </if>
<if test="storageName != null and storageName != ''"> <if test="storageName != null and storageName != ''">
and storage_name like concat('%', #{storageName}, '%') and a.storage_name like concat('%', #{storageName}, '%')
</if> </if>
<if test="storageLocationCode != null and storageLocationCode != ''"> <if test="storageLocationCode != null and storageLocationCode != ''">
and storage_location_code = #{storageLocationCode} and a.storage_location_code = #{storageLocationCode}
</if> </if>
<if test="storageLocationName != null and storageLocationName != ''"> <if test="storageLocationName != null and storageLocationName != ''">
and storage_location_name like concat('%', #{storageLocationName}, '%') and a.storage_location_name like concat('%', #{storageLocationName}, '%')
</if> </if>
<if test="storageLocationClassify != null and storageLocationClassify != ''"> <if test="storageLocationClassify != null and storageLocationClassify != ''">
and storage_location_classify = #{storageLocationClassify} and a.storage_location_classify = #{storageLocationClassify}
</if> </if>
<if test="storageLocationClassifyName != null and storageLocationClassifyName != ''"> <if test="storageLocationClassifyName != null and storageLocationClassifyName != ''">
and storage_location_classify_name like concat('%', #{storageLocationClassifyName}, '%') and a.storage_location_classify_name like concat('%', #{storageLocationClassifyName}, '%')
</if> </if>
<if test="storageLocationType != null and storageLocationType != ''"> <if test="storageLocationType != null and storageLocationType != ''">
and storage_location_type = #{storageLocationType} and a.storage_location_type = #{storageLocationType}
</if> </if>
<if test="storageLocationTypeName != null and storageLocationTypeName != ''"> <if test="storageLocationTypeName != null and storageLocationTypeName != ''">
and storage_location_type_name like concat('%', #{storageLocationTypeName}, '%') and a.storage_location_type_name like concat('%', #{storageLocationTypeName}, '%')
</if> </if>
<if test="mixingStrategy != null and mixingStrategy != ''"> <if test="mixingStrategy != null and mixingStrategy != ''">
and mixing_strategy = #{mixingStrategy} and a.mixing_strategy = #{mixingStrategy}
</if> </if>
<if test="mixingStrategyName != null and mixingStrategyName != ''"> <if test="mixingStrategyName != null and mixingStrategyName != ''">
and mixing_strategy_name like concat('%', #{mixingStrategyName}, '%') and a.mixing_strategy_name like concat('%', #{mixingStrategyName}, '%')
</if> </if>
<if test="storageLocationGroupId != null "> <if test="storageLocationGroupId != null ">
and storage_location_group_id = #{storageLocationGroupId} and a.storage_location_group_id = #{storageLocationGroupId}
</if> </if>
<if test="storageLocationGroupCode != null and storageLocationGroupCode != ''"> <if test="storageLocationGroupCode != null and storageLocationGroupCode != ''">
and storage_location_group_code = #{storageLocationGroupCode} and a.storage_location_group_code = #{storageLocationGroupCode}
</if> </if>
<if test="storageLocationGroupName != null and storageLocationGroupName != ''"> <if test="storageLocationGroupName != null and storageLocationGroupName != ''">
and storage_location_group_name like concat('%', #{storageLocationGroupName}, '%') and a.storage_location_group_name like concat('%', #{storageLocationGroupName}, '%')
</if> </if>
<if test="weightLimit != null "> <if test="weightLimit != null ">
and weight_limit = #{weightLimit} and a.weight_limit = #{weightLimit}
</if> </if>
<if test="volumeLimit != null "> <if test="volumeLimit != null ">
and volume_limit = #{volumeLimit} and a.volume_limit = #{volumeLimit}
</if> </if>
<if test="locationSize != null and locationSize != ''"> <if test="locationSize != null and locationSize != ''">
and location_size = #{locationSize} and a.location_size = #{locationSize}
</if> </if>
<if test="locationLength != null "> <if test="locationLength != null ">
and location_length = #{locationLength} and a.location_length = #{locationLength}
</if> </if>
<if test="locationWidth != null "> <if test="locationWidth != null ">
and location_width = #{locationWidth} and a.location_width = #{locationWidth}
</if> </if>
<if test="locationHeight != null "> <if test="locationHeight != null ">
and location_height = #{locationHeight} and a.location_height = #{locationHeight}
</if> </if>
<if test="coordinate != null and coordinate != ''"> <if test="coordinate != null and coordinate != ''">
and coordinate = #{coordinate} and a.coordinate = #{coordinate}
</if> </if>
<if test="coordinateArea != null and coordinateArea != ''"> <if test="coordinateArea != null and coordinateArea != ''">
and coordinate_area = #{coordinateArea} and a.coordinate_area = #{coordinateArea}
</if> </if>
<if test="coordinateColumn != null and coordinateColumn != ''"> <if test="coordinateColumn != null and coordinateColumn != ''">
and coordinate_column = #{coordinateColumn} and a.coordinate_column = #{coordinateColumn}
</if> </if>
<if test="coordinateRow != null and coordinateRow != ''"> <if test="coordinateRow != null and coordinateRow != ''">
and coordinate_row = #{coordinateRow} and a.coordinate_row = #{coordinateRow}
</if> </if>
<if test="coordinateLayer != null and coordinateLayer != ''"> <if test="coordinateLayer != null and coordinateLayer != ''">
and coordinate_layer = #{coordinateLayer} and a.coordinate_layer = #{coordinateLayer}
</if> </if>
<if test="openingUp != null "> <if test="openingUp != null ">
and opening_up = #{openingUp} and a.opening_up = #{openingUp}
</if> </if>
<if test="nullify != null "> <if test="nullify != null ">
and nullify = #{nullify} and a.nullify = #{nullify}
</if> </if>
<if test="createByName != null and createByName != ''"> <if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%') and a.create_by_name like concat('%', #{createByName}, '%')
</if> </if>
<if test="updateByName != null and updateByName != ''"> <if test="updateByName != null and updateByName != ''">
and update_by_name like concat('%', #{updateByName}, '%') and a.update_by_name like concat('%', #{updateByName}, '%')
</if> </if>
<if test="remark != null and remark != ''"> <if test="remark != null and remark != ''">
and remark like concat('%',#{remark},'%') and a.remark like concat('%',#{remark},'%')
</if> </if>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</where> </where>
</sql> </sql>
<select id="queryList" parameterType="com.mhd.basic.domain.storageLocation.repository.todo.StorageLocationDO" resultMap="StorageLocationResult"> <select id="queryList" parameterType="com.mhd.basic.domain.storageLocation.repository.todo.StorageLocationDO" resultMap="StorageLocationResult">
<include refid="selectStorageLocationPo"/> <include refid="selectStorageLocationPo"/>
<include refid="selectStorageLocationPo1"/> <include refid="selectStorageLocationPo1"/>
-- 按照创建时间倒序排序
order by a.create_time desc
</select> </select>
<select id="getStorageLocationCount" parameterType="com.mhd.basic.domain.storageLocation.repository.todo.StorageLocationDO" resultMap="StorageLocationResult"> <select id="getStorageLocationCount" parameterType="com.mhd.basic.domain.storageLocation.repository.todo.StorageLocationDO" resultType="java.lang.Long">
SELECT count(1) SELECT count(1)
from storage_locationfrom from storage_location a
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
<include refid="selectStorageLocationPo1"/> <include refid="selectStorageLocationPo1"/>
</select> </select>
</mapper> </mapper>
@@ -31,67 +31,78 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectStorageLocationGroupPo"> <sql id="selectStorageLocationGroupPo">
select storage_location_group_id, organization_id, organization_name, top_organization_id, warehouse_id, warehouse_code, warehouse_name, storage_section_id, storage_code, storage_name, storage_location_group_code, storage_location_group_name, remark, number, opening_up, nullify, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from storage_location_group select a.storage_location_group_id, a.organization_id, a.organization_name, a.top_organization_id, a.warehouse_id,
COALESCE(w.warehouse_code, a.warehouse_code) as warehouse_code,
COALESCE(w.warehouse_name, a.warehouse_name) as warehouse_name,
a.storage_section_id, a.storage_code, a.storage_name, a.storage_location_group_code, a.storage_location_group_name,
a.remark, a.number, a.opening_up, a.nullify, a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name, a.del_flag
from storage_location_group a
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
</sql> </sql>
<sql id="selectStorageLocationGroupPo1"> <sql id="selectStorageLocationGroupPo1">
<where> <where>
<if test="organizationId != null "> <if test="organizationId != null ">
and organization_id = #{organizationId} and a.organization_id = #{organizationId}
</if> </if>
<if test="organizationName != null and organizationName != ''"> <if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%') and a.organization_name like concat('%', #{organizationName}, '%')
</if> </if>
<if test="topOrganizationId != null "> <if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId} and a.top_organization_id = #{topOrganizationId}
</if> </if>
<if test="warehouseId != null "> <if test="warehouseId != null ">
and warehouse_id = #{warehouseId} and a.warehouse_id = #{warehouseId}
</if> </if>
<if test="warehouseCode != null and warehouseCode != ''"> <if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode} and (w.warehouse_code like concat('%', #{warehouseCode}, '%') or a.warehouse_code like concat('%', #{warehouseCode}, '%'))
</if> </if>
<if test="warehouseName != null and warehouseName != ''"> <if test="warehouseName != null and warehouseName != ''">
and warehouse_name like concat('%', #{warehouseName}, '%') and (w.warehouse_name like concat('%', #{warehouseName}, '%') or a.warehouse_name like concat('%', #{warehouseName}, '%'))
</if> </if>
<if test="storageSectionId != null "> <if test="storageSectionId != null ">
and storage_section_id = #{storageSectionId} and a.storage_section_id = #{storageSectionId}
</if> </if>
<if test="storageCode != null and storageCode != ''"> <if test="storageCode != null and storageCode != ''">
and storage_code = #{storageCode} and a.storage_code = #{storageCode}
</if> </if>
<if test="storageName != null and storageName != ''"> <if test="storageName != null and storageName != ''">
and storage_name like concat('%', #{storageName}, '%') and a.storage_name like concat('%', #{storageName}, '%')
</if> </if>
<if test="storageLocationGroupCode != null and storageLocationGroupCode != ''"> <if test="storageLocationGroupCode != null and storageLocationGroupCode != ''">
and storage_location_group_code = #{storageLocationGroupCode} and a.storage_location_group_code = #{storageLocationGroupCode}
</if> </if>
<if test="storageLocationGroupName != null and storageLocationGroupName != ''"> <if test="storageLocationGroupName != null and storageLocationGroupName != ''">
and storage_location_group_name like concat('%', #{storageLocationGroupName}, '%') and a.storage_location_group_name like concat('%', #{storageLocationGroupName}, '%')
</if> </if>
<if test="openingUp != null "> <if test="openingUp != null ">
and opening_up = #{openingUp} and a.opening_up = #{openingUp}
</if> </if>
<if test="nullify != null "> <if test="nullify != null ">
and nullify = #{nullify} and a.nullify = #{nullify}
</if> </if>
<if test="createByName != null and createByName != ''"> <if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%') and a.create_by_name like concat('%', #{createByName}, '%')
</if> </if>
<if test="updateByName != null and updateByName != ''"> <if test="updateByName != null and updateByName != ''">
and update_by_name like concat('%', #{updateByName}, '%') and a.update_by_name like concat('%', #{updateByName}, '%')
</if> </if>
<if test="number != null"> <if test="number != null">
and number = #{number} and a.number = #{number}
</if> </if>
<if test="remark != null and remark != ''"> <if test="remark != null and remark != ''">
and remark like concat('%',#{remark},'%') and a.remark like concat('%',#{remark},'%')
</if> </if>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</where> </where>
</sql> </sql>
<select id="queryList" parameterType="com.mhd.basic.domain.storageLocationGroup.repository.todo.StorageLocationGroupDO" resultMap="StorageLocationGroupResult"> <select id="queryList" parameterType="com.mhd.basic.domain.storageLocationGroup.repository.todo.StorageLocationGroupDO" resultMap="StorageLocationGroupResult">
<include refid="selectStorageLocationGroupPo"/> <include refid="selectStorageLocationGroupPo"/>
<include refid="selectStorageLocationGroupPo1"/> <include refid="selectStorageLocationGroupPo1"/>
order by a.create_time desc
</select> </select>
</mapper> </mapper>
@@ -31,64 +31,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectStorageSectionPo"> <sql id="selectStorageSectionPo">
select storage_section_id, organization_id, organization_name, top_organization_id, warehouse_id, warehouse_code, warehouse_name, storage_code, storage_name, storage_type, storage_type_name, storage_region, remark, opening_up, nullify, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from storage_section select a.storage_section_id, a.organization_id, a.organization_name, a.top_organization_id, a.warehouse_id,
COALESCE(w.warehouse_code, a.warehouse_code) as warehouse_code,
COALESCE(w.warehouse_name, a.warehouse_name) as warehouse_name,
a.storage_code, a.storage_name, a.storage_type, a.storage_type_name, a.storage_region, a.remark, a.opening_up, a.nullify,
a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name, a.del_flag
from storage_section a
LEFT JOIN warehouse w ON a.warehouse_id = w.warehouse_id AND w.del_flag = 1
</sql> </sql>
<sql id="selectStorageSectionPo1"> <sql id="selectStorageSectionPo1">
<where> <where>
<if test="organizationId != null "> <if test="organizationId != null ">
and organization_id = #{organizationId} and a.organization_id = #{organizationId}
</if> </if>
<if test="organizationName != null and organizationName != ''"> <if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%') and a.organization_name like concat('%', #{organizationName}, '%')
</if> </if>
<if test="topOrganizationId != null "> <if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId} and a.top_organization_id = #{topOrganizationId}
</if> </if>
<if test="warehouseId != null "> <if test="warehouseId != null ">
and warehouse_id = #{warehouseId} and a.warehouse_id = #{warehouseId}
</if> </if>
<if test="warehouseCode != null and warehouseCode != ''"> <if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode} and (w.warehouse_code like concat('%', #{warehouseCode}, '%') or a.warehouse_code like concat('%', #{warehouseCode}, '%'))
</if> </if>
<if test="warehouseName != null and warehouseName != ''"> <if test="warehouseName != null and warehouseName != ''">
and warehouse_name like concat('%', #{warehouseName}, '%') and (w.warehouse_name like concat('%', #{warehouseName}, '%') or a.warehouse_name like concat('%', #{warehouseName}, '%'))
</if> </if>
<if test="storageCode != null and storageCode != ''"> <if test="storageCode != null and storageCode != ''">
and storage_code = #{storageCode} and a.storage_code = #{storageCode}
</if> </if>
<if test="storageName != null and storageName != ''"> <if test="storageName != null and storageName != ''">
and storage_name like concat('%', #{storageName}, '%') and a.storage_name like concat('%', #{storageName}, '%')
</if> </if>
<if test="storageType != null and storageType != ''"> <if test="storageType != null and storageType != ''">
and storage_type = #{storageType} and a.storage_type = #{storageType}
</if> </if>
<if test="storageTypeName != null and storageTypeName != ''"> <if test="storageTypeName != null and storageTypeName != ''">
and storage_type_name like concat('%', #{storageTypeName}, '%') and a.storage_type_name like concat('%', #{storageTypeName}, '%')
</if> </if>
<if test="storageRegion != null "> <if test="storageRegion != null ">
and storage_region = #{storageRegion} and a.storage_region = #{storageRegion}
</if> </if>
<if test="openingUp != null "> <if test="openingUp != null ">
and opening_up = #{openingUp} and a.opening_up = #{openingUp}
</if> </if>
<if test="nullify != null "> <if test="nullify != null ">
and nullify = #{nullify} and a.nullify = #{nullify}
</if> </if>
<if test="createByName != null and createByName != ''"> <if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%') and a.create_by_name like concat('%', #{createByName}, '%')
</if> </if>
<if test="updateByName != null and updateByName != ''"> <if test="updateByName != null and updateByName != ''">
and update_by_name like concat('%', #{updateByName}, '%') and a.update_by_name like concat('%', #{updateByName}, '%')
</if> </if>
<if test="remark != null and remark != ''"> <if test="remark != null and remark != ''">
and remark like concat('%',#{remark},'%') and a.remark like concat('%',#{remark},'%')
</if> </if>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</where> </where>
</sql> </sql>
<select id="queryList" parameterType="com.mhd.basic.domain.storageSection.repository.todo.StorageSectionDO" resultMap="StorageSectionResult"> <select id="queryList" parameterType="com.mhd.basic.domain.storageSection.repository.todo.StorageSectionDO" resultMap="StorageSectionResult">
<include refid="selectStorageSectionPo"/> <include refid="selectStorageSectionPo"/>
<include refid="selectStorageSectionPo1"/> <include refid="selectStorageSectionPo1"/>
order by a.create_time desc
</select> </select>
</mapper> </mapper>
@@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and top_organization_id = #{topOrganizationId} and top_organization_id = #{topOrganizationId}
</if> </if>
<if test="warehouseCode != null and warehouseCode != ''"> <if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode} and warehouse_code like concat('%', #{warehouseCode}, '%')
</if> </if>
<if test="warehouseName != null and warehouseName != ''"> <if test="warehouseName != null and warehouseName != ''">
and warehouse_name like concat('%', #{warehouseName}, '%') and warehouse_name like concat('%', #{warehouseName}, '%')
@@ -139,5 +139,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="queryList" parameterType="com.mhd.basic.domain.warehouse.repository.todo.WarehouseDO" resultMap="WarehouseResult"> <select id="queryList" parameterType="com.mhd.basic.domain.warehouse.repository.todo.WarehouseDO" resultMap="WarehouseResult">
<include refid="selectWarehousePo"/> <include refid="selectWarehousePo"/>
<include refid="selectWarehousePo1"/> <include refid="selectWarehousePo1"/>
order by create_time desc
</select> </select>
</mapper> </mapper>
@@ -157,6 +157,10 @@ public class CommonApplicationService {
UserDO queryAccount = new UserDO(); UserDO queryAccount = new UserDO();
queryAccount.setTopOrganizationId(topOrganizationId); queryAccount.setTopOrganizationId(topOrganizationId);
queryAccount.setUserAccount(userDO.getUserAccount()); queryAccount.setUserAccount(userDO.getUserAccount());
// 如果指定了角色,只检查相同角色的用户
if (StrUtil.isNotEmpty(userDO.getRoleCode())) {
queryAccount.setRoleCode(userDO.getRoleCode());
}
userPo = userDomainService.findByTopOrganizationIdAndUserAccount(queryAccount); userPo = userDomainService.findByTopOrganizationIdAndUserAccount(queryAccount);
} }
//根据手机号查询 //根据手机号查询
@@ -165,6 +169,10 @@ public class CommonApplicationService {
UserDO queryPhone = new UserDO(); UserDO queryPhone = new UserDO();
queryPhone.setTopOrganizationId(topOrganizationId); queryPhone.setTopOrganizationId(topOrganizationId);
queryPhone.setUserPhone(userDO.getUserPhone()); queryPhone.setUserPhone(userDO.getUserPhone());
// 如果指定了角色,只检查相同角色的用户
if (StrUtil.isNotEmpty(userDO.getRoleCode())) {
queryPhone.setRoleCode(userDO.getRoleCode());
}
userPoTwo = userDomainService.findByTopOrganizationIdAndUserPhone(queryPhone); userPoTwo = userDomainService.findByTopOrganizationIdAndUserPhone(queryPhone);
} }
//根据身份证号查询 //根据身份证号查询
@@ -441,6 +441,32 @@ public class UserApplicationService {
return userPo; return userPo;
} }
/**
* @Description 根据用户ID获取用户信息
* @Author Alex
* @Date 2022/12/20 17:12
*/
public UserPo selectByUserName(String userName) {
if (StringUtils.isEmpty(userName)) {
LoginUser loginUser = SecurityUtils.getLoginUser();
userName = loginUser.getUsername();
}
UserPo userPo = userDomainService.selectByUserName(userName);
if (userPo != null){
userPo.setPrincipalAccount(userPo.getUserAccount());
}
if (StringUtils.isNotEmpty(userPo.getRoleCode())){
String[] split = userPo.getRoleCode().split(";");
List<String> list = CollectionUtil.toList(split);
userPo.setRoleCodeList(list);
}
UserShipperPo userShipperPo = userShipperDomainService.selectByUserId(userPo.getUserId());
if(null != userShipperPo){
userPo.setEsignEnterpriseStatus(userShipperPo.getEsignEnterpriseStatus());
}
return userPo;
}
/** /**
* @Description 分配用户默认普通用户角色 * @Description 分配用户默认普通用户角色
* @Author Alex * @Author Alex
@@ -1196,7 +1222,7 @@ public class UserApplicationService {
(userDO.getUserAccountType() == null || userDO.getUserAccountType() < 4)) { (userDO.getUserAccountType() == null || userDO.getUserAccountType() < 4)) {
//给用户分配默认普通角色权限 //给用户分配默认普通角色权限
RoleDo roleDo = new RoleDo(); RoleDo roleDo = new RoleDo();
roleDo.setRoleCode(RoleEnum.MUST.getCode()); roleDo.setRoleCode(RoleEnum.OWNER_CARGO.getCode());
roleDo.setOrganizationId(userEntity.getOrganizationId()); roleDo.setOrganizationId(userEntity.getOrganizationId());
RoleEntity roleEntity = roleDomainService.selectByOrganizationIdAndRoleCode(roleDo); RoleEntity roleEntity = roleDomainService.selectByOrganizationIdAndRoleCode(roleDo);
if (roleEntity != null) { if (roleEntity != null) {
@@ -1206,8 +1232,8 @@ public class UserApplicationService {
userDO.setRoleId(roleEntity.getRoleId()); userDO.setRoleId(roleEntity.getRoleId());
userRoleDomainService.addUserRole(userRoleDo); userRoleDomainService.addUserRole(userRoleDo);
} }
userDO.setRoleCode(RoleEnum.MUST.getCode()); userDO.setRoleCode(RoleEnum.OWNER_CARGO.getCode());
userDO.setRoleName(RoleEnum.MUST.getName()); userDO.setRoleName(RoleEnum.OWNER_CARGO.getName());
userDO.setUserId(userEntity.getUserId()); userDO.setUserId(userEntity.getUserId());
userDomainService.updateUser(userDO); userDomainService.updateUser(userDO);
}else{ }else{
@@ -4913,7 +4939,7 @@ public class UserApplicationService {
Map<String, SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPoMap = sysDepartInterfaceInfoPos.stream().collect(Collectors.toMap(SysDepartInterfaceInfoPo::getInterfaceTypeKey, Function.identity())); Map<String, SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPoMap = sysDepartInterfaceInfoPos.stream().collect(Collectors.toMap(SysDepartInterfaceInfoPo::getInterfaceTypeKey, Function.identity()));
SysDepartInterfaceInfoPo sysDepartInterfaceInfoPo = sysDepartInterfaceInfoPoMap.get("isWT"); SysDepartInterfaceInfoPo sysDepartInterfaceInfoPo = sysDepartInterfaceInfoPoMap.get("isWT");
//是否开启 //是否开启
if ("1".equals(sysDepartInterfaceInfoPo.getInterfaceTypeValue())) { if (sysDepartInterfaceInfoPo != null && "1".equals(sysDepartInterfaceInfoPo.getInterfaceTypeValue())) {
return true; return true;
} }
return false; return false;
@@ -165,4 +165,31 @@ public class UserEntity extends BaseVOEntity {
@ApiModelProperty(name = "制单员nc编码") @ApiModelProperty(name = "制单员nc编码")
private String documentPreparerNcCode; private String documentPreparerNcCode;
@ApiModelProperty("法人代表")
private String legalRepresentative;
@ApiModelProperty("统一编码")
private String unifiedCode;
@ApiModelProperty("注册电话")
private String registeredPhone;
@ApiModelProperty("注册地址")
private String registeredAddress;
@ApiModelProperty("传真")
private String fax;
@ApiModelProperty("付款银行")
private String paymentBank;
@ApiModelProperty("付款账户")
private String paymentAccount;
@ApiModelProperty("发票抬头")
private String invoiceTitle;
@ApiModelProperty("税号")
private String taxNumber;
} }
@@ -27,6 +27,8 @@ public interface UserRepositoryInterface extends IService<UserEntity> {
UserPo findAdminUserByOrganizationId(UserDO userDO); UserPo findAdminUserByOrganizationId(UserDO userDO);
UserPo findByUserId(Long userId); UserPo findByUserId(Long userId);
UserPo selectByUserName(String userName);
UserPo findByTopOrganizationIdAndUserAccount(UserDO userDO); UserPo findByTopOrganizationIdAndUserAccount(UserDO userDO);
UserPo getUserByDingUserId(String dingUserId); UserPo getUserByDingUserId(String dingUserId);
@@ -74,4 +76,3 @@ public interface UserRepositoryInterface extends IService<UserEntity> {
String finShipperEnterpriseNamedByUserId(Long userId); String finShipperEnterpriseNamedByUserId(Long userId);
} }
@@ -24,6 +24,8 @@ public interface UserMapper extends BaseMapper<UserEntity> {
UserPo selectByUserId(Long userId); UserPo selectByUserId(Long userId);
UserPo selectByUserName(String userName);
UserPo selectUserShipperList(UserPo userPo); UserPo selectUserShipperList(UserPo userPo);
List<UserPo> selectUserShipperListWaybill(UserPo userPo); List<UserPo> selectUserShipperListWaybill(UserPo userPo);
@@ -64,6 +64,11 @@ public class UserRepositoryImpl extends ServiceImpl<UserMapper,UserEntity> imple
return userMapper.selectByUserId(userId); return userMapper.selectByUserId(userId);
} }
@Override
public UserPo selectByUserName(String userName) {
return userMapper.selectByUserName(userName);
}
@Override @Override
public UserEntity selectById(Long userId) { public UserEntity selectById(Long userId) {
return userMapper.selectById(userId); return userMapper.selectById(userId);
@@ -45,4 +45,37 @@ public class CustomerDO extends BaseVOEntity {
@ApiModelProperty(name = "用户ID集合") @ApiModelProperty(name = "用户ID集合")
private List<Long> userIds; private List<Long> userIds;
@ApiModelProperty("法人代表")
private String legalRepresentative;
@ApiModelProperty("统一编码")
private String unifiedCode;
@ApiModelProperty("注册电话")
private String registeredPhone;
@ApiModelProperty("注册地址")
private String registeredAddress;
@ApiModelProperty("传真")
private String fax;
@ApiModelProperty("付款银行")
private String paymentBank;
@ApiModelProperty("付款账户")
private String paymentAccount;
@ApiModelProperty("发票抬头")
private String invoiceTitle;
@ApiModelProperty("税号")
private String taxNumber;
@ApiModelProperty(name = "邮箱")
private String userEmail;
@ApiModelProperty(name = "备注")
private String userRemark;
} }
@@ -254,4 +254,31 @@ public class UserDO extends BaseVOEntity {
@ApiModelProperty(name = "制单员nc编码") @ApiModelProperty(name = "制单员nc编码")
private String documentPreparerNcCode; private String documentPreparerNcCode;
@ApiModelProperty("法人代表")
private String legalRepresentative;
@ApiModelProperty("统一编码")
private String unifiedCode;
@ApiModelProperty("注册电话")
private String registeredPhone;
@ApiModelProperty("注册地址")
private String registeredAddress;
@ApiModelProperty("传真")
private String fax;
@ApiModelProperty("付款银行")
private String paymentBank;
@ApiModelProperty("付款账户")
private String paymentAccount;
@ApiModelProperty("发票抬头")
private String invoiceTitle;
@ApiModelProperty("税号")
private String taxNumber;
} }
@@ -125,6 +125,10 @@ public class UserDomainService {
return userRepositoryInterface.findByUserId(userId); return userRepositoryInterface.findByUserId(userId);
} }
public UserPo selectByUserName(String userName) {
return userRepositoryInterface.selectByUserName(userName);
}
public void updateWhenLogin(UserDO userDO) { public void updateWhenLogin(UserDO userDO) {
userRepositoryInterface.update(new UpdateWrapper<UserEntity>().lambda() userRepositoryInterface.update(new UpdateWrapper<UserEntity>().lambda()
.set(UserEntity::getLastLoginIp,userDO.getLastLoginIp()).set(UserEntity::getLastLoginTime,userDO.getLastLoginTime()) .set(UserEntity::getLastLoginIp,userDO.getLastLoginIp()).set(UserEntity::getLastLoginTime,userDO.getLastLoginTime())
@@ -47,4 +47,36 @@ public class CustomerDTO extends BaseVOEntity {
@ApiModelProperty("详细地址") @ApiModelProperty("详细地址")
private String userAreaAddress; private String userAreaAddress;
@ApiModelProperty("法人代表")
private String legalRepresentative;
@ApiModelProperty("统一编码")
private String unifiedCode;
@ApiModelProperty("注册电话")
private String registeredPhone;
@ApiModelProperty("注册地址")
private String registeredAddress;
@ApiModelProperty("传真")
private String fax;
@ApiModelProperty("付款银行")
private String paymentBank;
@ApiModelProperty("付款账户")
private String paymentAccount;
@ApiModelProperty("发票抬头")
private String invoiceTitle;
@ApiModelProperty("税号")
private String taxNumber;
@ApiModelProperty(name = "邮箱")
private String userEmail;
@ApiModelProperty(name = "备注")
private String userRemark;
} }
@@ -241,4 +241,10 @@ public class UserDTO extends BaseVOEntity {
@ApiModelProperty( "制单员nc编码") @ApiModelProperty( "制单员nc编码")
private String documentPreparerNcCode; private String documentPreparerNcCode;
@ApiModelProperty(value = "紧急联系人姓名")
private String emergencyContactName;
@ApiModelProperty(value = "紧急联系电话")
private String emergencyContactPhone;
} }
@@ -201,6 +201,14 @@ public class UserAPI extends BaseController {
return AjaxResult.success(userPo); return AjaxResult.success(userPo);
} }
@Log(title = "用户中台管理-查询", description ="根据用户ID查询用户详细信息",businessType = BusinessType.INQUIRE)
@ApiOperation("根据用户ID查询用户详细信息")
@GetMapping("/getInfoByName/{userName}")
public AjaxResult getInfoByName(@PathVariable("userName") String userName) {
UserPo userPo = userApplicationService.selectByUserName(userName);
return AjaxResult.success(userPo);
}
/** /**
* @Description 新增租户新增货主新增司机新增员工用户注册等 * @Description 新增租户新增货主新增司机新增员工用户注册等
* @Author Alex * @Author Alex
@@ -18,17 +18,17 @@ spring:
cloud: cloud:
nacos: nacos:
discovery: discovery:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
# server-addr: 10.33.0.129:6010 # server-addr: 10.33.0.129:6010
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
config: config:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
# server-addr: 10.33.0.129:6010 # server-addr: 10.33.0.129:6010
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置 group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
@@ -70,7 +70,16 @@
a.department_id, a.department_id,
a.ding_user_id, a.ding_user_id,
a.ding_dept_id, a.ding_dept_id,
a.validity_period_management,a.salesperson_nc_code,a.document_preparer_nc_code a.validity_period_management,a.salesperson_nc_code,a.document_preparer_nc_code,
a.legal_representative,
a.unified_code,
a.registered_phone,
a.registered_address,
a.fax,
a.payment_bank,
a.payment_account,
a.invoice_title,
a.tax_number
FROM "USER" a FROM "USER" a
where a.del_flag = 1 where a.del_flag = 1
</sql> </sql>
@@ -131,6 +140,9 @@
<include refid="selectUserVo"/> <include refid="selectUserVo"/>
and a.top_organization_id = #{topOrganizationId} and a.top_organization_id = #{topOrganizationId}
and a.user_account = #{userAccount} and a.user_account = #{userAccount}
<if test="roleCode != null and roleCode != ''">
and a.role_code = #{roleCode}
</if>
<if test="userId !=null and userId !='' "> <if test="userId !=null and userId !='' ">
and a.user_id != #{userId} and a.user_id != #{userId}
</if> </if>
@@ -159,6 +171,10 @@
and a.user_id = #{value} and a.user_id = #{value}
</select> </select>
<select id="selectByUserName" parameterType="java.lang.String" resultType="com.mhd.common.core.domain.po.UserPo">
<include refid="selectUserVo"/>
and a.user_name = #{value}</select>
<!-- 根据用户手机号查询自己以外的用户 --> <!-- 根据用户手机号查询自己以外的用户 -->
<select id="findByTopOrganizationIdAndUserPhone" <select id="findByTopOrganizationIdAndUserPhone"
@@ -170,6 +186,9 @@
</if> </if>
and a.user_phone = #{userPhone} and a.user_phone = #{userPhone}
and a.top_organization_id = #{topOrganizationId} and a.top_organization_id = #{topOrganizationId}
<if test="roleCode != null and roleCode != ''">
and a.role_code = #{roleCode}
</if>
<if test="userId !=null and userId !='' "> <if test="userId !=null and userId !='' ">
and a.user_id != #{userId} and a.user_id != #{userId}
</if> </if>
@@ -213,6 +232,13 @@
OR a.create_by = #{createBy}) OR a.create_by = #{createBy})
</if> </if>
<if test="userIds !=null and userIds.size() > 0 ">
and a.user_id in
<foreach item="id" collection="userIds" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="userId !=null and userId !='' "> <if test="userId !=null and userId !='' ">
and a.user_id = #{userId} and a.user_id = #{userId}
</if> </if>
@@ -386,14 +412,6 @@
<if test="userMemberCode != null and userMemberCode != ''"> <if test="userMemberCode != null and userMemberCode != ''">
and a.user_member_code = #{userMemberCode} and a.user_member_code = #{userMemberCode}
</if> </if>
/*联系人*/
<if test="emergencyContactName != null and emergencyContactName != ''">
and a.emergency_contact_name = #{emergencyContactName}
</if>
/*联系电话*/
<if test="emergencyContactPhone != null and emergencyContactPhone != ''">
and a.emergency_contact_phone = #{emergencyContactPhone}
</if>
/*详细地址*/ /*详细地址*/
<if test="userAreaAddress != null and userAreaAddress != ''"> <if test="userAreaAddress != null and userAreaAddress != ''">
and a.user_area_address like concat('%' , #{userAreaAddress} , '%') and a.user_area_address like concat('%' , #{userAreaAddress} , '%')
@@ -406,6 +424,9 @@
<if test="emergencyContactPhone != null and emergencyContactPhone != ''"> <if test="emergencyContactPhone != null and emergencyContactPhone != ''">
and a.emergency_contact_phone like concat('%' , #{emergencyContactPhone} , '%') and a.emergency_contact_phone like concat('%' , #{emergencyContactPhone} , '%')
</if> </if>
<if test="userAreaCountyId != null and userAreaCountyId != ''">
and a.user_area_county_id = #{userAreaCountyId}
</if>
</sql> </sql>
<select id="selectAppUserList" resultType="com.mhd.common.core.domain.po.app.UserAppPo" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDO"> <select id="selectAppUserList" resultType="com.mhd.common.core.domain.po.app.UserAppPo" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDO">
+4 -2
View File
@@ -25,7 +25,8 @@ spring:
# username: nacos # username: nacos
# password: manhuoda@2023 # password: manhuoda@2023
#线上正式环境 #线上正式环境
server-addr: 10.102.192.5:6848 server-addr: 127.0.0.1:8848
# server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
@@ -39,7 +40,8 @@ spring:
# username: nacos # username: nacos
# password: manhuoda@2023 # password: manhuoda@2023
#线上正式环境 #线上正式环境
server-addr: 10.102.192.5:6848 server-addr: 127.0.0.1:8848
# server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
+1 -14
View File
@@ -90,7 +90,7 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.38</version> <version>1.18.30</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--链路追踪--> <!--链路追踪-->
@@ -127,19 +127,6 @@
<groupId>com.mhd</groupId> <groupId>com.mhd</groupId>
<artifactId>mhd-common-log</artifactId> <artifactId>mhd-common-log</artifactId>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.mhd</groupId>-->
<!-- <artifactId>mhd-modules-system</artifactId>-->
<!-- <version>3.6.0</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>com.mhd</groupId>
<artifactId>mhd-user-center</artifactId>
<version>3.6.0</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
+4
View File
@@ -17,6 +17,8 @@ spring:
nacos: nacos:
discovery: discovery:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
username: nacos
password: manhuoda@2023
# 演示环境 # 演示环境
# server-addr: 47.92.229.169:8848 # server-addr: 47.92.229.169:8848
# 测试开发环境 # 测试开发环境
@@ -31,6 +33,8 @@ spring:
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
username: nacos
password: manhuoda@2023
# 演示环境 # 演示环境
# server-addr: 47.92.229.169:8848 # server-addr: 47.92.229.169:8848
# 测试开发环境 # 测试开发环境
+4 -4
View File
@@ -18,9 +18,9 @@ spring:
cloud: cloud:
nacos: nacos:
discovery: discovery:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
@@ -30,9 +30,9 @@ spring:
#线上正式环境 #线上正式环境
# server-addr: 10.102.192.105:6848 # server-addr: 10.102.192.105:6848
config: config:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
@@ -18,9 +18,9 @@ spring:
cloud: cloud:
nacos: nacos:
discovery: discovery:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
@@ -30,9 +30,9 @@ spring:
#线上正式环境 #线上正式环境
# server-addr: 10.102.192.105:6848 # server-addr: 10.102.192.105:6848
config: config:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号 # 线上测试环境配置 容器名+端口号
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
@@ -18,10 +18,10 @@ spring:
cloud: cloud:
nacos: nacos:
discovery: discovery:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 线上测试环境配置使用ip+端口号 # 线上测试环境配置使用ip+端口号
# server-addr: 10.33.0.129:6010 # server-addr: 10.33.0.129:6010
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
@@ -31,9 +31,9 @@ spring:
#线上正式环境 #线上正式环境
# server-addr: 10.102.192.105:6848 # server-addr: 10.102.192.105:6848
config: config:
# server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 线上测试环境配置使用ip+端口号 # 线上测试环境配置使用ip+端口号
server-addr: 10.102.192.5:6848 # server-addr: 10.102.192.5:6848
username: nacos username: nacos
password: manhuoda@2023 password: manhuoda@2023
#线上正式环境 #线上正式环境
+7
View File
@@ -131,6 +131,13 @@
<version>4.1.2</version> <version>4.1.2</version>
</dependency> </dependency>
<!-- EasyExcel 解析Excel -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.2</version>
</dependency>
<!-- Mhd Api System--> <!-- Mhd Api System-->
<dependency> <dependency>
<groupId>com.mhd</groupId> <groupId>com.mhd</groupId>
@@ -109,4 +109,7 @@ public class DeliveTaskApplicationService {
return deliveTaskDomainService.querySum(deliveTaskDO); return deliveTaskDomainService.querySum(deliveTaskDO);
} }
public Boolean forward(DeliveTaskDO deliveTaskDO) {
return deliveTaskDomainService.updateById(deliveTaskDO);
}
} }
@@ -2,20 +2,31 @@ package com.mhd.wms.application.service.handoverTaskOrder;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.mhd.common.core.domain.po.UserPo;
import com.mhd.common.core.exception.ServiceException; import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.utils.DateUtils; import com.mhd.common.core.utils.DateUtils;
import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign; import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.UserServiceFeign;
import com.mhd.system.api.domain.PlatformFeignPO; import com.mhd.system.api.domain.PlatformFeignPO;
import com.mhd.system.api.domain.PlatformUseTimeFeignPO; import com.mhd.system.api.domain.PlatformUseTimeFeignPO;
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO; import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil; import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.handoverTaskOrder.entity.HandoverTaskOrder;
import com.mhd.wms.domain.handoverTaskOrder.repository.facade.IHandoverTaskOrderService;
import com.mhd.wms.domain.handoverTaskOrder.repository.po.HandoverTaskOrderPO; import com.mhd.wms.domain.handoverTaskOrder.repository.po.HandoverTaskOrderPO;
import com.mhd.wms.domain.handoverTaskOrder.repository.todo.HandoverTaskOrderDO; import com.mhd.wms.domain.handoverTaskOrder.repository.todo.HandoverTaskOrderDO;
import com.mhd.wms.domain.handoverTaskOrder.service.HandoverTaskOrderDomainService; import com.mhd.wms.domain.handoverTaskOrder.service.HandoverTaskOrderDomainService;
import com.mhd.wms.domain.shiftManage.repository.todo.ShiftManageDO;
import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder;
import com.mhd.wms.domain.stockOutOrder.repository.facade.IStockOutOrderService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -36,6 +47,15 @@ public class HandoverTaskOrderApplicationService {
@Autowired @Autowired
private SystemServiceFeign systemServiceFeign; private SystemServiceFeign systemServiceFeign;
@Autowired
private UserServiceFeign userServiceFeign;
@Autowired
private IHandoverTaskOrderService handoverTaskOrderService;
@Autowired
private IStockOutOrderService stockOutOrderService;
/** /**
* 分页查询交接作业单列表 * 分页查询交接作业单列表
@@ -148,4 +168,36 @@ public class HandoverTaskOrderApplicationService {
} }
} }
public boolean taskDistribution(HandoverTaskOrderDO handoverTaskOrderDO) {
// 设置作业员信息
operatorsParam(handoverTaskOrderDO);
return handoverTaskOrderDomainService.taskDistribution(handoverTaskOrderDO);
}
/**
* @description 封装作业人员信息
* @param handoverTaskOrderDO
*/
private void operatorsParam(HandoverTaskOrderDO handoverTaskOrderDO){
AjaxResult ajaxResult = userServiceFeign.getInfo(handoverTaskOrderDO.getOperatorsBy());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取作业人员信息失败");
}
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
handoverTaskOrderDO.setOperatorsName(userPo.getUserName());
}
public void pictureApp(HandoverTaskOrderDO handoverTaskOrderDO) {
//pda上传图片插入交接作业单
handoverTaskOrderService.update(new LambdaUpdateWrapper<HandoverTaskOrder>()
.eq(HandoverTaskOrder::getOrderNumber,handoverTaskOrderDO.getOrderNumber())
.set(HandoverTaskOrder::getPictureApp,handoverTaskOrderDO.getPictureApp()));
//pda上传图片插入出库管理
stockOutOrderService.update(new LambdaUpdateWrapper<StockOutOrder>()
.eq(StockOutOrder::getOutOrderNumber,handoverTaskOrderDO.getOrderNumber())
.set(StockOutOrder::getStatus,"9")//设置为出库
.set(StockOutOrder::getPictureApp,handoverTaskOrderDO.getPictureApp())//多张图片以逗号隔开
);
}
} }
@@ -1,17 +1,31 @@
package com.mhd.wms.application.service.inventoryAdjustmentRecord; package com.mhd.wms.application.service.inventoryAdjustmentRecord;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.domain.BatchDetailFeignPO;
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO; import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil; import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.inventoryAdjustmentRecord.repository.po.InventoryAdjustmentRecordPO; import com.mhd.wms.domain.inventoryAdjustmentRecord.repository.po.InventoryAdjustmentRecordPO;
import com.mhd.wms.domain.inventoryAdjustmentRecord.repository.todo.InventoryAdjustmentRecordDO; import com.mhd.wms.domain.inventoryAdjustmentRecord.repository.todo.InventoryAdjustmentRecordDO;
import com.mhd.wms.domain.inventoryAdjustmentRecord.service.InventoryAdjustmentRecordDomainService; import com.mhd.wms.domain.inventoryAdjustmentRecord.service.InventoryAdjustmentRecordDomainService;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
import com.mhd.wms.domain.statementStatistics.po.ImmediateInventoryPO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List; import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* 库存调整记录ApplicationService * 库存调整记录ApplicationService
@@ -24,6 +38,10 @@ import java.util.List;
public class InventoryAdjustmentRecordApplicationService { public class InventoryAdjustmentRecordApplicationService {
@Autowired @Autowired
private InventoryAdjustmentRecordDomainService inventoryAdjustmentRecordDomainService; private InventoryAdjustmentRecordDomainService inventoryAdjustmentRecordDomainService;
@Autowired
private MaterialInventoryMapper materialInventoryMapper;
@Autowired
private SystemServiceFeign systemServiceFeign;
/** /**
@@ -40,7 +58,262 @@ public class InventoryAdjustmentRecordApplicationService {
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
inventoryAdjustmentRecordDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); inventoryAdjustmentRecordDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
} }
return inventoryAdjustmentRecordDomainService.queryList(inventoryAdjustmentRecordDO); List<InventoryAdjustmentRecordPO> inventoryAdjustmentRecordPOS = inventoryAdjustmentRecordDomainService.queryList(inventoryAdjustmentRecordDO);
// 性能优化批量获取批次属性避免N+1查询问题
// 1. 收集所有唯一的materialBaseInfoId
Set<Long> materialBaseInfoIdSet = inventoryAdjustmentRecordPOS.stream()
.map(InventoryAdjustmentRecordPO::getMaterialBaseInfoId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 2. 批量查询批次属性使用Map缓存避免重复查询相同的materialBaseInfoId
Map<Long, List<BatchDetailFeignPO>> batchDetailMap = new HashMap<>();
for (Long materialBaseInfoId : materialBaseInfoIdSet) {
try {
AjaxResult ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(materialBaseInfoId);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<BatchDetailFeignPO> batchDetailFeignPOList = JSON.parseArray(
JSONObject.toJSONString(ajaxResult.get("data")), BatchDetailFeignPO.class);
if (!CollectionUtils.isEmpty(batchDetailFeignPOList)) {
// 过滤isDisplay=1的属性
List<BatchDetailFeignPO> filteredList = batchDetailFeignPOList.stream()
.filter(batchDetail -> batchDetail.getIsDisplay() != null && batchDetail.getIsDisplay() == 1)
.collect(Collectors.toList());
batchDetailMap.put(materialBaseInfoId, filteredList);
}
}
} catch (Exception e) {
log.warn("获取物料批次属性失败,物料基础信息ID:{},错误:{}", materialBaseInfoId, e.getMessage());
}
}
// 3. 为每个物料明细设置更多属性从库存表中获取值
setMaterialMoreDetailListFromInventory(inventoryAdjustmentRecordPOS, batchDetailMap);
return inventoryAdjustmentRecordPOS;
}
/**
* 为物料库存设置更多属性从库存表中获取值
* @param materialInventoryPOList 物料库存列表
* @param batchDetailMap 批次属性Map
*/
private void setMaterialMoreDetailListFromInventory(List<InventoryAdjustmentRecordPO> materialInventoryPOList,
Map<Long, List<BatchDetailFeignPO>> batchDetailMap) {
if (CollectionUtils.isEmpty(materialInventoryPOList)) {
return;
}
materialInventoryPOList.forEach(materialInventoryPO -> {
Long materialBaseInfoId = materialInventoryPO.getMaterialBaseInfoId();
Long materialInventoryId = materialInventoryPO.getMaterialInventoryId();
// 创建新的materialMoreDetailList只包含isDisplay=1的属性
List<MaterialMoreDetailPO> materialMoreDetailList = new ArrayList<>();
// 从库存表获取数据包含批次属性字段
MaterialInventoryPO inventoryPO = null;
if (materialInventoryId != null) {
inventoryPO = materialInventoryMapper.selectByIdWithBatchAttributes(materialInventoryId);
}
if (materialBaseInfoId != null && batchDetailMap.containsKey(materialBaseInfoId)) {
List<BatchDetailFeignPO> batchDetailFeignPOList = batchDetailMap.get(materialBaseInfoId);
// 用于跟踪已添加到列表中的batchDetailId
Set<Long> addedBatchDetailIds = new HashSet<>();
for (BatchDetailFeignPO batchDetailFeignPO : batchDetailFeignPOList) {
MaterialMoreDetailPO materialMoreDetailPO = new MaterialMoreDetailPO();
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchDetailId(batchDetailFeignPO.getBatchDetailId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
// 确保添加到列表中使用batchDetailId来避免重复
Long batchDetailId = batchDetailFeignPO.getBatchDetailId();
if (batchDetailId != null && !addedBatchDetailIds.contains(batchDetailId)) {
materialMoreDetailList.add(materialMoreDetailPO);
addedBatchDetailIds.add(batchDetailId);
}
// 根据fieldName或batchLabels从库存表中获取对应的字段值
if (inventoryPO != null) {
String fieldValue = null;
String usedFieldName = null;
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(inventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, fieldName={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射到字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(inventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
}
}
// 只有当获取到值时才更新attributeValue
if (fieldValue != null) {
materialMoreDetailPO.setAttributeValue(fieldValue);
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
materialMoreDetailPO.getAttributeValue());
}
}
}
}
materialInventoryPO.setMaterialMoreDetailList(materialMoreDetailList);
log.info("物料库存 materialInventoryId={}, materialBaseInfoId={}, materialMoreDetailList大小={}",
materialInventoryPO.getMaterialInventoryId(), materialInventoryPO.getMaterialBaseInfoId(),
materialMoreDetailList != null ? materialMoreDetailList.size() : 0);
});
}
/**
* 根据字段名从对象中获取字段值使用反射
* @param obj 对象
* @param fieldName 字段名
* @return 字段值转换为字符串
*/
private String getFieldValueByFieldName(Object obj, String fieldName) {
if (obj == null || StringUtils.isBlank(fieldName)) {
return null;
}
try {
// 兼容如果传的是下划线命名数据库列名风格先转成驼峰字段名再取
String normalizedFieldName = fieldName;
if (normalizedFieldName.contains("_")) {
normalizedFieldName = snakeToCamel(normalizedFieldName);
}
// 获取对象的Class
Class<?> clazz = obj.getClass();
// 尝试获取字段包括父类字段
Field field = null;
Class<?> currentClass = clazz;
while (currentClass != null && field == null) {
try {
field = currentClass.getDeclaredField(normalizedFieldName);
} catch (NoSuchFieldException e) {
currentClass = currentClass.getSuperclass();
}
}
if (field == null) {
log.warn("字段不存在:{}(normalized{}),对象类型:{}", fieldName, normalizedFieldName, clazz.getName());
return null;
}
// 设置可访问
field.setAccessible(true);
// 获取字段值
Object value = field.get(obj);
// 转换为字符串
if (value == null) {
log.info("字段 {} 的值为 null,对象类型:{}", normalizedFieldName, clazz.getName());
return null;
}
String result;
// 处理日期类型字段
if (value instanceof Date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
result = sdf.format((Date) value);
} else {
result = value.toString();
}
log.info("通过反射获取字段值成功,字段名:{}(原始:{}),值:{},对象类型:{}",
normalizedFieldName, fieldName, result, clazz.getName());
return result;
} catch (Exception e) {
log.warn("通过反射获取字段值失败,字段名:{},对象类型:{},错误:{}", fieldName, obj.getClass().getName(), e.getMessage());
return null;
}
}
private String snakeToCamel(String snake) {
if (StringUtils.isBlank(snake)) {
return null;
}
String s = snake.trim().toLowerCase();
StringBuilder sb = new StringBuilder();
boolean upperNext = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '_') {
upperNext = true;
continue;
}
if (upperNext) {
sb.append(Character.toUpperCase(c));
upperNext = false;
} else {
sb.append(c);
}
}
return sb.toString();
}
/**
* 根据批次标签batchLabels映射到字段名
* @param batchLabel 批次标签
* @return 字段名如果找不到映射则返回null
*/
private String getFieldNameByBatchLabel(String batchLabel) {
if (StringUtils.isBlank(batchLabel)) {
return null;
}
// 批次标签到字段名的映射关系
Map<String, String> labelToFieldNameMap = new HashMap<>();
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("Invoice No", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
labelToFieldNameMap.put("Batch Ref NO's", "batchRefNo");
labelToFieldNameMap.put("Batch Ref NO", "batchRefNo");
labelToFieldNameMap.put("批次参考号", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("Sheet Ref NO", "sheetRefNo");
labelToFieldNameMap.put("单据参考号", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("箱号", "boxPalletNo");
labelToFieldNameMap.put("卡板号", "boxPalletNo");
labelToFieldNameMap.put("生产日期", "productionDate");
labelToFieldNameMap.put("过期日期", "expiryDate");
labelToFieldNameMap.put("存货日期", "inventoryDate");
labelToFieldNameMap.put("扩展字段1", "extAttr1");
labelToFieldNameMap.put("扩展字段2", "extAttr2");
labelToFieldNameMap.put("扩展字段3", "extAttr3");
labelToFieldNameMap.put("扩展字段4", "extAttr4");
// 精确匹配
String fieldName = labelToFieldNameMap.get(batchLabel.trim());
if (StringUtils.isNotBlank(fieldName)) {
return fieldName;
}
// 模糊匹配包含关系
for (Map.Entry<String, String> entry : labelToFieldNameMap.entrySet()) {
if (batchLabel.contains(entry.getKey()) || entry.getKey().contains(batchLabel)) {
return entry.getValue();
}
}
return null;
} }
@@ -5,11 +5,13 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.mhd.common.core.domain.po.UserPo; import com.mhd.common.core.domain.po.UserPo;
import com.mhd.common.core.exception.ServiceException; import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.utils.bean.BeanUtils; import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign; import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.UserServiceFeign; import com.mhd.system.api.UserServiceFeign;
import com.mhd.system.api.domain.BatchDetailFeignPO;
import com.mhd.system.api.domain.WarehouseFeignPO; import com.mhd.system.api.domain.WarehouseFeignPO;
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO; import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil; import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
@@ -20,14 +22,18 @@ import com.mhd.wms.domain.investigationManage.service.InvestigationManageDomainS
import com.mhd.wms.domain.investigetionManageDetail.repository.po.InvestigetionManageDetailPO; import com.mhd.wms.domain.investigetionManageDetail.repository.po.InvestigetionManageDetailPO;
import com.mhd.wms.domain.investigetionManageDetail.repository.todo.InvestigetionManageDetailDO; import com.mhd.wms.domain.investigetionManageDetail.repository.todo.InvestigetionManageDetailDO;
import com.mhd.wms.domain.investigetionManageDetail.service.InvestigetionManageDetailDomainService; import com.mhd.wms.domain.investigetionManageDetail.service.InvestigetionManageDetailDomainService;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -48,6 +54,8 @@ public class InvestigationManageApplicationService {
private UserServiceFeign userServiceFeign; private UserServiceFeign userServiceFeign;
@Autowired @Autowired
private SystemServiceFeign systemServiceFeign; private SystemServiceFeign systemServiceFeign;
@Autowired
private MaterialInventoryMapper materialInventoryMapper;
/** /**
@@ -94,10 +102,273 @@ public class InvestigationManageApplicationService {
} }
/** /**
* 获取盘点管理详细信息 * 获取盘点管理详细信息带批次属性
*/ */
public InvestigationManagePO getInfo(Long investigationManageId) { public InvestigationManagePO getInfo(Long investigationManageId) {
return investigationManageDomainService.getInfo(investigationManageId); InvestigationManagePO investigationManagePO = investigationManageDomainService.getInfo(investigationManageId);
if (investigationManagePO == null || CollectionUtils.isEmpty(investigationManagePO.getInvestigetionManageDetailList())) {
return investigationManagePO;
}
List<InvestigetionManageDetailPO> detailList = investigationManagePO.getInvestigetionManageDetailList();
// 性能优化批量获取批次属性避免N+1查询问题
// 1. 收集所有唯一的materialBaseInfoId
Set<Long> materialBaseInfoIdSet = detailList.stream()
.map(InvestigetionManageDetailPO::getMaterialBaseInfoId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 2. 批量查询批次属性使用Map缓存避免重复查询相同的materialBaseInfoId
Map<Long, List<BatchDetailFeignPO>> batchDetailMap = new HashMap<>();
for (Long materialBaseInfoId : materialBaseInfoIdSet) {
try {
AjaxResult ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(materialBaseInfoId);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<BatchDetailFeignPO> batchDetailFeignPOList = JSON.parseArray(
JSONObject.toJSONString(ajaxResult.get("data")), BatchDetailFeignPO.class);
if (!CollectionUtils.isEmpty(batchDetailFeignPOList)) {
// 过滤isDisplay=1的属性
List<BatchDetailFeignPO> filteredList = batchDetailFeignPOList.stream()
.filter(batchDetail -> batchDetail.getIsDisplay() != null && batchDetail.getIsDisplay() == 1)
.collect(Collectors.toList());
batchDetailMap.put(materialBaseInfoId, filteredList);
}
}
} catch (Exception e) {
log.warn("获取物料批次属性失败,物料基础信息ID:{},错误:{}", materialBaseInfoId, e.getMessage());
}
}
// 3. 为每个物料明细设置更多属性从库存表中获取值
setMaterialMoreDetailListFromInventory(detailList, batchDetailMap);
return investigationManagePO;
}
/**
* 为盘点物料明细设置更多属性从库存表中获取值
* @param investigetionManageDetailPOList 盘点物料明细列表
* @param batchDetailMap 批次属性Map
*/
private void setMaterialMoreDetailListFromInventory(List<InvestigetionManageDetailPO> investigetionManageDetailPOList,
Map<Long, List<BatchDetailFeignPO>> batchDetailMap) {
if (CollectionUtils.isEmpty(investigetionManageDetailPOList)) {
return;
}
investigetionManageDetailPOList.forEach(investigetionManageDetailPO -> {
Long materialBaseInfoId = investigetionManageDetailPO.getMaterialBaseInfoId();
Long materialInventoryId = investigetionManageDetailPO.getMaterialInventoryId();
// 创建新的materialMoreDetailList只包含isDisplay=1的属性
List<MaterialMoreDetailPO> materialMoreDetailList = new ArrayList<>();
// 从库存表获取数据包含批次属性字段
MaterialInventoryPO materialInventoryPO = null;
if (materialInventoryId != null) {
materialInventoryPO = materialInventoryMapper.selectByIdWithBatchAttributes(materialInventoryId);
}
if (materialBaseInfoId != null && batchDetailMap.containsKey(materialBaseInfoId)) {
List<BatchDetailFeignPO> batchDetailFeignPOList = batchDetailMap.get(materialBaseInfoId);
// 用于跟踪已添加到列表中的batchDetailId
Set<Long> addedBatchDetailIds = new HashSet<>();
for (BatchDetailFeignPO batchDetailFeignPO : batchDetailFeignPOList) {
MaterialMoreDetailPO materialMoreDetailPO = new MaterialMoreDetailPO();
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchDetailId(batchDetailFeignPO.getBatchDetailId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
// 确保添加到列表中使用batchDetailId来避免重复
Long batchDetailId = batchDetailFeignPO.getBatchDetailId();
if (batchDetailId != null && !addedBatchDetailIds.contains(batchDetailId)) {
materialMoreDetailList.add(materialMoreDetailPO);
addedBatchDetailIds.add(batchDetailId);
}
// 根据fieldName或batchLabels从库存表中获取对应的字段值
if (materialInventoryPO != null) {
String fieldValue = null;
String usedFieldName = null;
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(materialInventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, fieldName={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射到字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(materialInventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
}
}
// 只有当获取到值时才更新attributeValue
if (fieldValue != null) {
materialMoreDetailPO.setAttributeValue(fieldValue);
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
materialMoreDetailPO.getAttributeValue());
}
}
}
}
investigetionManageDetailPO.setMaterialMoreDetailList(materialMoreDetailList);
log.info("盘点物料明细 investigationManageDetailId={}, materialBaseInfoId={}, materialInventoryId={}, materialMoreDetailList大小={}",
investigetionManageDetailPO.getInvestigationManageDetailId(), investigetionManageDetailPO.getMaterialBaseInfoId(),
investigetionManageDetailPO.getMaterialInventoryId(),
materialMoreDetailList != null ? materialMoreDetailList.size() : 0);
});
}
/**
* 根据批次标签batchLabels映射到字段名
* @param batchLabel 批次标签
* @return 字段名如果找不到映射则返回null
*/
private String getFieldNameByBatchLabel(String batchLabel) {
if (StringUtils.isBlank(batchLabel)) {
return null;
}
// 批次标签到字段名的映射关系
Map<String, String> labelToFieldNameMap = new HashMap<>();
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("Invoice No", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
labelToFieldNameMap.put("Batch Ref NO's", "batchRefNo");
labelToFieldNameMap.put("Batch Ref NO", "batchRefNo");
labelToFieldNameMap.put("批次参考号", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("Sheet Ref NO", "sheetRefNo");
labelToFieldNameMap.put("单据参考号", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("箱号", "boxPalletNo");
labelToFieldNameMap.put("卡板号", "boxPalletNo");
labelToFieldNameMap.put("生产日期", "productionDate");
labelToFieldNameMap.put("过期日期", "expiryDate");
labelToFieldNameMap.put("存货日期", "inventoryDate");
labelToFieldNameMap.put("扩展字段1", "extAttr1");
labelToFieldNameMap.put("扩展字段2", "extAttr2");
labelToFieldNameMap.put("扩展字段3", "extAttr3");
labelToFieldNameMap.put("扩展字段4", "extAttr4");
// 精确匹配
String fieldName = labelToFieldNameMap.get(batchLabel.trim());
if (StringUtils.isNotBlank(fieldName)) {
return fieldName;
}
// 模糊匹配包含关系
for (Map.Entry<String, String> entry : labelToFieldNameMap.entrySet()) {
if (batchLabel.contains(entry.getKey()) || entry.getKey().contains(batchLabel)) {
return entry.getValue();
}
}
return null;
}
/**
* 根据字段名从对象中获取字段值使用反射
* @param obj 对象
* @param fieldName 字段名
* @return 字段值转换为字符串
*/
private String getFieldValueByFieldName(Object obj, String fieldName) {
if (obj == null || StringUtils.isBlank(fieldName)) {
return null;
}
try {
// 兼容如果传的是下划线命名数据库列名风格先转成驼峰字段名再取
String normalizedFieldName = fieldName;
if (normalizedFieldName.contains("_")) {
normalizedFieldName = snakeToCamel(normalizedFieldName);
}
// 获取对象的Class
Class<?> clazz = obj.getClass();
// 尝试获取字段包括父类字段
Field field = null;
Class<?> currentClass = clazz;
while (currentClass != null && field == null) {
try {
field = currentClass.getDeclaredField(normalizedFieldName);
} catch (NoSuchFieldException e) {
currentClass = currentClass.getSuperclass();
}
}
if (field == null) {
log.warn("字段不存在:{}(normalized{}),对象类型:{}", fieldName, normalizedFieldName, clazz.getName());
return null;
}
// 设置可访问
field.setAccessible(true);
// 获取字段值
Object value = field.get(obj);
// 转换为字符串
if (value == null) {
log.info("字段 {} 的值为 null,对象类型:{}", normalizedFieldName, clazz.getName());
return null;
}
String result;
// 处理日期类型字段
if (value instanceof Date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
result = sdf.format((Date) value);
} else {
result = value.toString();
}
log.info("通过反射获取字段值成功,字段名:{}(原始:{}),值:{},对象类型:{}",
normalizedFieldName, fieldName, result, clazz.getName());
return result;
} catch (Exception e) {
log.warn("通过反射获取字段值失败,字段名:{},对象类型:{},错误:{}", fieldName, obj.getClass().getName(), e.getMessage());
return null;
}
}
private String snakeToCamel(String snake) {
if (StringUtils.isBlank(snake)) {
return null;
}
String s = snake.trim().toLowerCase();
StringBuilder sb = new StringBuilder();
boolean upperNext = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '_') {
upperNext = true;
continue;
}
if (upperNext) {
sb.append(Character.toUpperCase(c));
upperNext = false;
} else {
sb.append(c);
}
}
return sb.toString();
} }
/** /**
@@ -1,5 +1,6 @@
package com.mhd.wms.application.service.materialBaseInfo; package com.mhd.wms.application.service.materialBaseInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.materialBarCode.service.MaterialBarCodeDomainService; import com.mhd.wms.domain.materialBarCode.service.MaterialBarCodeDomainService;
@@ -8,17 +9,24 @@ import com.mhd.wms.domain.materialBaseInfo.repository.todo.MaterialBaseInfoDO;
import com.mhd.wms.domain.materialBaseInfo.service.MaterialBaseInfoDomainService; import com.mhd.wms.domain.materialBaseInfo.service.MaterialBaseInfoDomainService;
import com.mhd.wms.domain.materialCommon.repository.todo.MaterialCommonDO; import com.mhd.wms.domain.materialCommon.repository.todo.MaterialCommonDO;
import com.mhd.wms.domain.materialCommon.service.MaterialCommonDomainService; import com.mhd.wms.domain.materialCommon.service.MaterialCommonDomainService;
import com.mhd.wms.domain.materialGoodsRule.entity.MaterialGoodsRule;
import com.mhd.wms.domain.materialGoodsRule.repository.mapper.MaterialGoodsRuleMapper;
import com.mhd.wms.domain.materialGoodsRule.repository.po.MaterialGoodsRulePO;
import com.mhd.wms.domain.materialGoodsRule.repository.todo.MaterialGoodsRuleDO; import com.mhd.wms.domain.materialGoodsRule.repository.todo.MaterialGoodsRuleDO;
import com.mhd.wms.domain.materialGoodsRule.service.MaterialGoodsRuleDomainService; import com.mhd.wms.domain.materialGoodsRule.service.MaterialGoodsRuleDomainService;
import com.mhd.wms.domain.materialInventoryWarning.service.MaterialInventoryWarningDomainService; import com.mhd.wms.domain.materialInventoryWarning.service.MaterialInventoryWarningDomainService;
import com.mhd.wms.domain.materialWarehouseControl.repository.todo.MaterialWarehouseControlDO; import com.mhd.wms.domain.materialWarehouseControl.repository.todo.MaterialWarehouseControlDO;
import com.mhd.wms.domain.materialWarehouseControl.service.MaterialWarehouseControlDomainService; import com.mhd.wms.domain.materialWarehouseControl.service.MaterialWarehouseControlDomainService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 物料基础信息ApplicationService * 物料基础信息ApplicationService
@@ -42,6 +50,8 @@ public class MaterialBaseInfoApplicationService {
@Autowired @Autowired
private MaterialBarCodeDomainService materialBarCodeDomainService; private MaterialBarCodeDomainService materialBarCodeDomainService;
@Autowired
private MaterialGoodsRuleMapper materialGoodsRuleMapper;
/** /**
* 分页查询物料基础信息列表 * 分页查询物料基础信息列表
@@ -55,7 +65,34 @@ public class MaterialBaseInfoApplicationService {
materialBaseInfoDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); materialBaseInfoDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
} }
} }
return materialBaseInfoDomainService.queryList(materialBaseInfoDO); List<MaterialBaseInfoPO> materialBaseInfoPOS = materialBaseInfoDomainService.queryList(materialBaseInfoDO);
for (MaterialBaseInfoPO materialBaseInfoPO : materialBaseInfoPOS) {
//物料商品规则
MaterialGoodsRule materialGoodsRules = materialGoodsRuleMapper.selectOne(new LambdaQueryWrapper<MaterialGoodsRule>()
.eq(MaterialGoodsRule::getMaterialBaseInfoId, materialBaseInfoPO.getMaterialBaseInfoId())
.eq(MaterialGoodsRule::getDelFlag, 1));
if (materialGoodsRules != null){
MaterialGoodsRulePO materialGoodsRulePO = new MaterialGoodsRulePO();
BeanUtils.copyProperties(materialGoodsRules,materialGoodsRulePO);
materialBaseInfoPO.setMaterialGoodsRule(materialGoodsRulePO);
}
// 将物料分类的List转换为逗号分隔的字符串用于导出
if (!CollectionUtils.isEmpty(materialBaseInfoPO.getMaterialClassifyCode())) {
materialBaseInfoPO.setMaterialClassifyCodeStr(
materialBaseInfoPO.getMaterialClassifyCode().stream()
.filter(code -> !StringUtils.isEmpty(code))
.collect(Collectors.joining(","))
);
}
if (!CollectionUtils.isEmpty(materialBaseInfoPO.getMaterialClassifyName())) {
materialBaseInfoPO.setMaterialClassifyNameStr(
materialBaseInfoPO.getMaterialClassifyName().stream()
.filter(name -> !StringUtils.isEmpty(name))
.collect(Collectors.joining(","))
);
}
}
return materialBaseInfoPOS;
} }
@@ -1,21 +1,32 @@
package com.mhd.wms.application.service.materialInventory; package com.mhd.wms.application.service.materialInventory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.nacos.common.utils.CollectionUtils; import com.alibaba.nacos.common.utils.CollectionUtils;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.domain.BatchDetailFeignPO;
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO; import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil; import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO; import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO; import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO;
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO; import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO;
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryQueryListDO; import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryQueryListDO;
import com.mhd.wms.domain.materialInventory.service.MaterialInventoryDomainService; import com.mhd.wms.domain.materialInventory.service.MaterialInventoryDomainService;
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* 物料库存ApplicationService * 物料库存ApplicationService
@@ -28,6 +39,10 @@ import java.util.List;
public class MaterialInventoryApplicationService { public class MaterialInventoryApplicationService {
@Autowired @Autowired
private MaterialInventoryDomainService materialInventoryDomainService; private MaterialInventoryDomainService materialInventoryDomainService;
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private MaterialInventoryMapper materialInventoryMapper;
/** /**
@@ -47,6 +62,274 @@ public class MaterialInventoryApplicationService {
return materialInventoryDomainService.queryList(materialInventoryDO); return materialInventoryDomainService.queryList(materialInventoryDO);
} }
/**
* 查询物料库存列表带批次属性
* 批次属性值从库存表中获取
*/
public List<MaterialInventoryPO> queryListWithBatchAttributes(MaterialInventoryDO materialInventoryDO) {
List<MaterialInventoryPO> list = queryList(materialInventoryDO);
if (CollectionUtils.isEmpty(list)) {
return list;
}
// 性能优化批量获取批次属性避免N+1查询问题
// 1. 收集所有唯一的materialBaseInfoId
Set<Long> materialBaseInfoIdSet = list.stream()
.map(MaterialInventoryPO::getMaterialBaseInfoId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 2. 批量查询批次属性使用Map缓存避免重复查询相同的materialBaseInfoId
Map<Long, List<BatchDetailFeignPO>> batchDetailMap = new HashMap<>();
for (Long materialBaseInfoId : materialBaseInfoIdSet) {
try {
AjaxResult ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(materialBaseInfoId);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<BatchDetailFeignPO> batchDetailFeignPOList = JSON.parseArray(
JSONObject.toJSONString(ajaxResult.get("data")), BatchDetailFeignPO.class);
if (!CollectionUtils.isEmpty(batchDetailFeignPOList)) {
// 过滤isDisplay=1的属性
List<BatchDetailFeignPO> filteredList = batchDetailFeignPOList.stream()
.filter(batchDetail -> batchDetail.getIsDisplay() != null && batchDetail.getIsDisplay() == 1)
.collect(Collectors.toList());
batchDetailMap.put(materialBaseInfoId, filteredList);
}
}
} catch (Exception e) {
log.warn("获取物料批次属性失败,物料基础信息ID:{},错误:{}", materialBaseInfoId, e.getMessage());
}
}
// 3. 为每个物料库存设置更多属性从库存表中获取值
setMaterialMoreDetailListFromInventory(list, batchDetailMap);
return list;
}
/**
* 为物料库存设置更多属性从库存表中获取值
* @param materialInventoryPOList 物料库存列表
* @param batchDetailMap 批次属性Map
*/
private void setMaterialMoreDetailListFromInventory(List<MaterialInventoryPO> materialInventoryPOList,
Map<Long, List<BatchDetailFeignPO>> batchDetailMap) {
if (CollectionUtils.isEmpty(materialInventoryPOList)) {
return;
}
materialInventoryPOList.forEach(materialInventoryPO -> {
Long materialBaseInfoId = materialInventoryPO.getMaterialBaseInfoId();
Long materialInventoryId = materialInventoryPO.getMaterialInventoryId();
// 创建新的materialMoreDetailList只包含isDisplay=1的属性
List<MaterialMoreDetailPO> materialMoreDetailList = new ArrayList<>();
// 从库存表获取数据包含批次属性字段
MaterialInventoryPO inventoryPO = null;
if (materialInventoryId != null) {
inventoryPO = materialInventoryMapper.selectByIdWithBatchAttributes(materialInventoryId);
}
if (materialBaseInfoId != null && batchDetailMap.containsKey(materialBaseInfoId)) {
List<BatchDetailFeignPO> batchDetailFeignPOList = batchDetailMap.get(materialBaseInfoId);
// 用于跟踪已添加到列表中的batchDetailId
Set<Long> addedBatchDetailIds = new HashSet<>();
for (BatchDetailFeignPO batchDetailFeignPO : batchDetailFeignPOList) {
MaterialMoreDetailPO materialMoreDetailPO = new MaterialMoreDetailPO();
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchDetailId(batchDetailFeignPO.getBatchDetailId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
// 确保添加到列表中使用batchDetailId来避免重复
Long batchDetailId = batchDetailFeignPO.getBatchDetailId();
if (batchDetailId != null && !addedBatchDetailIds.contains(batchDetailId)) {
materialMoreDetailList.add(materialMoreDetailPO);
addedBatchDetailIds.add(batchDetailId);
}
// 根据fieldName或batchLabels从库存表中获取对应的字段值
if (inventoryPO != null) {
String fieldValue = null;
String usedFieldName = null;
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(inventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, fieldName={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射到字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(inventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
}
}
// 只有当获取到值时才更新attributeValue
if (fieldValue != null) {
materialMoreDetailPO.setAttributeValue(fieldValue);
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
materialMoreDetailPO.getAttributeValue());
}
}
}
}
materialInventoryPO.setMaterialMoreDetailList(materialMoreDetailList);
log.info("物料库存 materialInventoryId={}, materialBaseInfoId={}, materialMoreDetailList大小={}",
materialInventoryPO.getMaterialInventoryId(), materialInventoryPO.getMaterialBaseInfoId(),
materialMoreDetailList != null ? materialMoreDetailList.size() : 0);
});
}
/**
* 根据批次标签batchLabels映射到字段名
* @param batchLabel 批次标签
* @return 字段名如果找不到映射则返回null
*/
private String getFieldNameByBatchLabel(String batchLabel) {
if (StringUtils.isBlank(batchLabel)) {
return null;
}
// 批次标签到字段名的映射关系
Map<String, String> labelToFieldNameMap = new HashMap<>();
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("Invoice No", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
labelToFieldNameMap.put("Batch Ref NO's", "batchRefNo");
labelToFieldNameMap.put("Batch Ref NO", "batchRefNo");
labelToFieldNameMap.put("批次参考号", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("Sheet Ref NO", "sheetRefNo");
labelToFieldNameMap.put("单据参考号", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("箱号", "boxPalletNo");
labelToFieldNameMap.put("卡板号", "boxPalletNo");
labelToFieldNameMap.put("生产日期", "productionDate");
labelToFieldNameMap.put("过期日期", "expiryDate");
labelToFieldNameMap.put("存货日期", "inventoryDate");
labelToFieldNameMap.put("扩展字段1", "extAttr1");
labelToFieldNameMap.put("扩展字段2", "extAttr2");
labelToFieldNameMap.put("扩展字段3", "extAttr3");
labelToFieldNameMap.put("扩展字段4", "extAttr4");
// 精确匹配
String fieldName = labelToFieldNameMap.get(batchLabel.trim());
if (StringUtils.isNotBlank(fieldName)) {
return fieldName;
}
// 模糊匹配包含关系
for (Map.Entry<String, String> entry : labelToFieldNameMap.entrySet()) {
if (batchLabel.contains(entry.getKey()) || entry.getKey().contains(batchLabel)) {
return entry.getValue();
}
}
return null;
}
/**
* 根据字段名从对象中获取字段值使用反射
* @param obj 对象
* @param fieldName 字段名
* @return 字段值转换为字符串
*/
private String getFieldValueByFieldName(Object obj, String fieldName) {
if (obj == null || StringUtils.isBlank(fieldName)) {
return null;
}
try {
// 兼容如果传的是下划线命名数据库列名风格先转成驼峰字段名再取
String normalizedFieldName = fieldName;
if (normalizedFieldName.contains("_")) {
normalizedFieldName = snakeToCamel(normalizedFieldName);
}
// 获取对象的Class
Class<?> clazz = obj.getClass();
// 尝试获取字段包括父类字段
Field field = null;
Class<?> currentClass = clazz;
while (currentClass != null && field == null) {
try {
field = currentClass.getDeclaredField(normalizedFieldName);
} catch (NoSuchFieldException e) {
currentClass = currentClass.getSuperclass();
}
}
if (field == null) {
log.warn("字段不存在:{}(normalized{}),对象类型:{}", fieldName, normalizedFieldName, clazz.getName());
return null;
}
// 设置可访问
field.setAccessible(true);
// 获取字段值
Object value = field.get(obj);
// 转换为字符串
if (value == null) {
log.info("字段 {} 的值为 null,对象类型:{}", normalizedFieldName, clazz.getName());
return null;
}
String result;
// 处理日期类型字段
if (value instanceof Date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
result = sdf.format((Date) value);
} else {
result = value.toString();
}
log.info("通过反射获取字段值成功,字段名:{}(原始:{}),值:{},对象类型:{}",
normalizedFieldName, fieldName, result, clazz.getName());
return result;
} catch (Exception e) {
log.warn("通过反射获取字段值失败,字段名:{},对象类型:{},错误:{}", fieldName, obj.getClass().getName(), e.getMessage());
return null;
}
}
private String snakeToCamel(String snake) {
if (StringUtils.isBlank(snake)) {
return null;
}
String s = snake.trim().toLowerCase();
StringBuilder sb = new StringBuilder();
boolean upperNext = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '_') {
upperNext = true;
continue;
}
if (upperNext) {
sb.append(Character.toUpperCase(c));
upperNext = false;
} else {
sb.append(c);
}
}
return sb.toString();
}
public BigDecimal sumInventoryQuantity(MaterialInventoryDO materialInventoryDO) { public BigDecimal sumInventoryQuantity(MaterialInventoryDO materialInventoryDO) {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){ if (loginUser != null){
@@ -139,6 +139,9 @@ public class NoticeOrderApplicationService {
* @param noticeOrderDO * @param noticeOrderDO
*/ */
private void setWarehouseInfo(NoticeOrderDO noticeOrderDO) { private void setWarehouseInfo(NoticeOrderDO noticeOrderDO) {
if (noticeOrderDO.getWarehouseId() == null) {
throw new ServiceException("仓库ID不能为空");
}
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(noticeOrderDO.getWarehouseId()); AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(noticeOrderDO.getWarehouseId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){ if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取仓库信息失败"); throw new ServiceException("获取仓库信息失败");
@@ -6,15 +6,18 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.mhd.common.core.domain.po.UserPo; import com.mhd.common.core.domain.po.UserPo;
import com.mhd.common.core.exception.ServiceException; import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.utils.bean.BeanUtils; import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign; import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.UserServiceFeign; import com.mhd.system.api.UserServiceFeign;
import com.mhd.system.api.domain.BatchDetailFeignPO;
import com.mhd.system.api.domain.StorageLocationFeignPO; import com.mhd.system.api.domain.StorageLocationFeignPO;
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO; import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil; import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
import com.mhd.wms.domain.pickingMaterialDetail.repository.po.PickingMaterialDetailPO; import com.mhd.wms.domain.pickingMaterialDetail.repository.po.PickingMaterialDetailPO;
import com.mhd.wms.domain.pickingMaterialDetail.repository.todo.PickingMaterialDetailDO; import com.mhd.wms.domain.pickingMaterialDetail.repository.todo.PickingMaterialDetailDO;
import com.mhd.wms.domain.pickingMaterialDetail.service.PickingMaterialDetailDomainService; import com.mhd.wms.domain.pickingMaterialDetail.service.PickingMaterialDetailDomainService;
@@ -26,10 +29,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -66,7 +69,52 @@ public class PickingOrderApplicationService {
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
pickingOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); pickingOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
} }
return pickingOrderDomainService.queryList(pickingOrderDO); List<PickingOrderPO> pickingOrderPOList = pickingOrderDomainService.queryList(pickingOrderDO);
// 重新计算物料种类数按料号去重一个料号算一种物料
if (!CollectionUtils.isEmpty(pickingOrderPOList)) {
// 收集所有拣货单号
List<String> pickingOrderNumbers = pickingOrderPOList.stream()
.map(PickingOrderPO::getPickingOrderNumber)
.filter(Objects::nonNull)
.filter(number -> !number.trim().isEmpty())
.collect(Collectors.toList());
if (!pickingOrderNumbers.isEmpty()) {
// 批量查询所有拣货单的物料明细循环查询每个拣货单的物料明细
Map<String, List<PickingMaterialDetailPO>> materialDetailsByOrderNumber = new HashMap<>();
for (String pickingOrderNumber : pickingOrderNumbers) {
PickingMaterialDetailDO pickingMaterialDetailDO = new PickingMaterialDetailDO();
pickingMaterialDetailDO.setPickingOrderNumber(pickingOrderNumber);
List<PickingMaterialDetailPO> materialDetails = pickingMaterialDetailDomainService.queryList(pickingMaterialDetailDO);
if (!CollectionUtils.isEmpty(materialDetails)) {
materialDetailsByOrderNumber.put(pickingOrderNumber, materialDetails);
}
}
// 为每个拣货单计算物料种类数按料号去重
for (PickingOrderPO pickingOrderPO : pickingOrderPOList) {
String pickingOrderNumber = pickingOrderPO.getPickingOrderNumber();
if (pickingOrderNumber != null && materialDetailsByOrderNumber.containsKey(pickingOrderNumber)) {
List<PickingMaterialDetailPO> materialDetails = materialDetailsByOrderNumber.get(pickingOrderNumber);
// 按料号去重计算物料种类数
long materialQuantity = materialDetails.stream()
.map(PickingMaterialDetailPO::getMaterialCode)
.filter(Objects::nonNull)
.filter(code -> !code.trim().isEmpty())
.distinct()
.count();
pickingOrderPO.setMaterialQuantity((int) materialQuantity);
log.debug("重新计算物料种类数 - 拣货单号: {}, 物料种类数: {}", pickingOrderNumber, materialQuantity);
} else {
// 如果没有物料明细物料种类数为0
pickingOrderPO.setMaterialQuantity(0);
}
}
}
}
return pickingOrderPOList;
} }
@@ -96,7 +144,295 @@ public class PickingOrderApplicationService {
* 获取拣货单详细信息 * 获取拣货单详细信息
*/ */
public PickingOrderPO getInfoByIdAndType(Long pickingOrderId, Integer type) { public PickingOrderPO getInfoByIdAndType(Long pickingOrderId, Integer type) {
return pickingOrderDomainService.getInfoByIdAndType(pickingOrderId, type); PickingOrderPO pickingOrderPO = pickingOrderDomainService.getInfoByIdAndType(pickingOrderId, type);
List<PickingMaterialDetailPO> pickingMaterialDetailPOList = pickingOrderPO.getMaterialDetailList();
if (CollectionUtils.isEmpty(pickingMaterialDetailPOList)) {
return pickingOrderPO;
}
// 性能优化批量获取批次属性避免N+1查询问题
// 1. 收集所有唯一的materialBaseInfoId
Set<Long> materialBaseInfoIdSet = pickingMaterialDetailPOList.stream()
.map(PickingMaterialDetailPO::getMaterialBaseInfoId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 2. 批量查询批次属性使用Map缓存避免重复查询相同的materialBaseInfoId
Map<Long, List<BatchDetailFeignPO>> batchDetailMap = new HashMap<>();
for (Long materialBaseInfoId : materialBaseInfoIdSet) {
try {
AjaxResult ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(materialBaseInfoId);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<BatchDetailFeignPO> batchDetailFeignPOList = JSON.parseArray(
JSONObject.toJSONString(ajaxResult.get("data")), BatchDetailFeignPO.class);
if (!CollectionUtils.isEmpty(batchDetailFeignPOList)) {
// 过滤isDisplay=1的属性
List<BatchDetailFeignPO> filteredList = batchDetailFeignPOList.stream()
.filter(batchDetail -> batchDetail.getIsDisplay() != null && batchDetail.getIsDisplay() == 1)
.collect(Collectors.toList());
batchDetailMap.put(materialBaseInfoId, filteredList);
}
}
} catch (Exception e) {
log.warn("获取物料批次属性失败,物料基础信息ID:{},错误:{}", materialBaseInfoId, e.getMessage());
}
}
// 3. 为每个物料明细设置更多属性从物料明细中获取值递归处理所有层级
setMaterialMoreDetailListRecursively(pickingMaterialDetailPOList, batchDetailMap);
pickingOrderPO.setMaterialDetailList(pickingMaterialDetailPOList);
log.info("返回拣货单信息,pickingOrderId={}, materialDetailList大小={}",
pickingOrderPO.getPickingOrderId(),
pickingMaterialDetailPOList != null ? pickingMaterialDetailPOList.size() : 0);
return pickingOrderPO;
}
/**
* 递归为物料明细设置更多属性
* @param pickingMaterialDetailPOList 物料明细列表
* @param batchDetailMap 批次属性Map
*/
private void setMaterialMoreDetailListRecursively(List<PickingMaterialDetailPO> pickingMaterialDetailPOList,
Map<Long, List<BatchDetailFeignPO>> batchDetailMap) {
if (CollectionUtils.isEmpty(pickingMaterialDetailPOList)) {
return;
}
pickingMaterialDetailPOList.forEach(pickingMaterialDetailPO -> {
Long materialBaseInfoId = pickingMaterialDetailPO.getMaterialBaseInfoId();
// 只保留isDisplay=1的批次属性从batchDetailMap中获取已经过滤过了
// 创建新的materialMoreDetailList只包含isDisplay=1的属性
List<MaterialMoreDetailPO> materialMoreDetailList = new ArrayList<>();
// 创建batchDetailId到MaterialMoreDetailPO的映射用于快速查找已有的属性值
Map<Long, MaterialMoreDetailPO> batchDetailIdToMaterialMoreDetailMap = new HashMap<>();
List<MaterialMoreDetailPO> existingList = pickingMaterialDetailPO.getMaterialMoreDetailList();
if (!CollectionUtils.isEmpty(existingList)) {
for (MaterialMoreDetailPO existing : existingList) {
if (existing.getBatchDetailId() != null) {
batchDetailIdToMaterialMoreDetailMap.put(existing.getBatchDetailId(), existing);
}
}
}
if (materialBaseInfoId != null && batchDetailMap.containsKey(materialBaseInfoId)) {
List<BatchDetailFeignPO> batchDetailFeignPOList = batchDetailMap.get(materialBaseInfoId);
// 用于跟踪已添加到列表中的batchDetailId
Set<Long> addedBatchDetailIds = new HashSet<>();
for (BatchDetailFeignPO batchDetailFeignPO : batchDetailFeignPOList) {
MaterialMoreDetailPO materialMoreDetailPO = batchDetailIdToMaterialMoreDetailMap.get(batchDetailFeignPO.getBatchDetailId());
// 如果不存在创建新的
if (materialMoreDetailPO == null) {
materialMoreDetailPO = new MaterialMoreDetailPO();
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchDetailId(batchDetailFeignPO.getBatchDetailId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
} else {
// 如果已存在更新属性保留已有的attributeValue
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
}
// 确保添加到列表中使用batchDetailId来避免重复
Long batchDetailId = batchDetailFeignPO.getBatchDetailId();
if (batchDetailId != null && !addedBatchDetailIds.contains(batchDetailId)) {
materialMoreDetailList.add(materialMoreDetailPO);
addedBatchDetailIds.add(batchDetailId);
}
// 根据fieldName或batchLabels从物料明细中获取对应的字段值
if (pickingMaterialDetailPO != null) {
String fieldValue = null;
String usedFieldName = null;
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(pickingMaterialDetailPO, usedFieldName);
log.info("批次属性 batchDetailId={}, fieldName={}, 获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射到字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(pickingMaterialDetailPO, usedFieldName);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
}
}
// 只有当获取到值时才更新attributeValue避免覆盖已有的值
if (fieldValue != null) {
materialMoreDetailPO.setAttributeValue(fieldValue);
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
materialMoreDetailPO.getAttributeValue());
}
}
}
}
pickingMaterialDetailPO.setMaterialMoreDetailList(materialMoreDetailList);
log.info("物料明细 uniqueId={}, materialBaseInfoId={}, materialMoreDetailList大小={}",
pickingMaterialDetailPO.getUniqueId(), pickingMaterialDetailPO.getMaterialBaseInfoId(),
materialMoreDetailList != null ? materialMoreDetailList.size() : 0);
// 递归处理子级
if (!CollectionUtils.isEmpty(pickingMaterialDetailPO.getChildren())) {
setMaterialMoreDetailListRecursively(pickingMaterialDetailPO.getChildren(), batchDetailMap);
}
});
}
/**
* 根据批次标签batchLabels映射到字段名
* @param batchLabel 批次标签
* @return 字段名如果找不到映射则返回null
*/
private String getFieldNameByBatchLabel(String batchLabel) {
if (StringUtils.isBlank(batchLabel)) {
return null;
}
// 批次标签到字段名的映射关系
Map<String, String> labelToFieldNameMap = new HashMap<>();
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("Invoice No", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
labelToFieldNameMap.put("Batch Ref NO's", "batchRefNo");
labelToFieldNameMap.put("Batch Ref NO", "batchRefNo");
labelToFieldNameMap.put("批次参考号", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("Sheet Ref NO", "sheetRefNo");
labelToFieldNameMap.put("单据参考号", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("箱号", "boxPalletNo");
labelToFieldNameMap.put("卡板号", "boxPalletNo");
labelToFieldNameMap.put("生产日期", "productionDate");
labelToFieldNameMap.put("过期日期", "expiryDate");
labelToFieldNameMap.put("存货日期", "inventoryDate");
labelToFieldNameMap.put("扩展字段1", "extAttr1");
labelToFieldNameMap.put("扩展字段2", "extAttr2");
labelToFieldNameMap.put("扩展字段3", "extAttr3");
labelToFieldNameMap.put("扩展字段4", "extAttr4");
// 精确匹配
String fieldName = labelToFieldNameMap.get(batchLabel.trim());
if (StringUtils.isNotBlank(fieldName)) {
return fieldName;
}
// 模糊匹配包含关系
for (Map.Entry<String, String> entry : labelToFieldNameMap.entrySet()) {
if (batchLabel.contains(entry.getKey()) || entry.getKey().contains(batchLabel)) {
return entry.getValue();
}
}
return null;
}
/**
* 根据字段名从对象中获取字段值使用反射
* @param obj 对象
* @param fieldName 字段名
* @return 字段值转换为字符串
*/
private String getFieldValueByFieldName(Object obj, String fieldName) {
if (obj == null || StringUtils.isBlank(fieldName)) {
return null;
}
try {
// 兼容如果传的是下划线命名数据库列名风格先转成驼峰字段名再取
String normalizedFieldName = fieldName;
if (normalizedFieldName.contains("_")) {
normalizedFieldName = snakeToCamel(normalizedFieldName);
}
// 获取对象的Class
Class<?> clazz = obj.getClass();
// 尝试获取字段包括父类字段
Field field = null;
Class<?> currentClass = clazz;
while (currentClass != null && field == null) {
try {
field = currentClass.getDeclaredField(normalizedFieldName);
} catch (NoSuchFieldException e) {
currentClass = currentClass.getSuperclass();
}
}
if (field == null) {
log.warn("字段不存在:{}(normalized{}),对象类型:{}", fieldName, normalizedFieldName, clazz.getName());
return null;
}
// 设置可访问
field.setAccessible(true);
// 获取字段值
Object value = field.get(obj);
// 转换为字符串
if (value == null) {
log.info("字段 {} 的值为 null,对象类型:{}", normalizedFieldName, clazz.getName());
return null;
}
String result;
// 处理日期类型字段
if (value instanceof Date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
result = sdf.format((Date) value);
} else {
result = value.toString();
}
log.info("通过反射获取字段值成功,字段名:{}(原始:{}),值:{},对象类型:{}",
normalizedFieldName, fieldName, result, clazz.getName());
return result;
} catch (Exception e) {
log.warn("通过反射获取字段值失败,字段名:{},对象类型:{},错误:{}", fieldName, obj.getClass().getName(), e.getMessage());
return null;
}
}
private String snakeToCamel(String snake) {
if (StringUtils.isBlank(snake)) {
return null;
}
String s = snake.trim().toLowerCase();
StringBuilder sb = new StringBuilder();
boolean upperNext = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '_') {
upperNext = true;
continue;
}
if (upperNext) {
sb.append(Character.toUpperCase(c));
upperNext = false;
} else {
sb.append(c);
}
}
return sb.toString();
} }
/** /**
@@ -242,6 +242,8 @@ public class ShiftManageApplicationService {
if (shiftMaterialDetailPO == null){ if (shiftMaterialDetailPO == null){
throw new ServiceException("物料明细不存在"); throw new ServiceException("物料明细不存在");
} }
//ShiftQuantity前端传过来是0 他那边不好赋值 和Quantity参数统一
shiftMaterialDetailDO.setShiftQuantity(shiftMaterialDetailDO.getQuantity());
if (shiftMaterialDetailDO.getShiftQuantity().compareTo(BigDecimal.ZERO) == 0){ if (shiftMaterialDetailDO.getShiftQuantity().compareTo(BigDecimal.ZERO) == 0){
//未进行移位直接跳过 //未进行移位直接跳过
continue; continue;
@@ -339,6 +341,9 @@ public class ShiftManageApplicationService {
* @param shiftManageDO * @param shiftManageDO
*/ */
private void setWarehouseInfo(ShiftManageDO shiftManageDO) { private void setWarehouseInfo(ShiftManageDO shiftManageDO) {
if (shiftManageDO.getWarehouseId() == null) {
throw new ServiceException("仓库ID不能为空");
}
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(shiftManageDO.getWarehouseId()); AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(shiftManageDO.getWarehouseId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){ if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取仓库信息失败"); throw new ServiceException("获取仓库信息失败");
@@ -368,14 +373,14 @@ public class ShiftManageApplicationService {
shiftMaterialDetailDO.setNewStorageLocationName(storageLocationFeignPO.getStorageLocationName()); shiftMaterialDetailDO.setNewStorageLocationName(storageLocationFeignPO.getStorageLocationName());
//获取容器详情 //获取容器详情
AjaxResult ajaxResult = systemServiceFeign.getContainerInfoByContainerId(shiftMaterialDetailDO.getContainerId()); // AjaxResult ajaxResult = systemServiceFeign.getContainerInfoByContainerId(shiftMaterialDetailDO.getContainerId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){ // if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取容器信息失败"); // throw new ServiceException("获取容器信息失败");
} // }
ContainerFeignPO containerFeignPO = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContainerFeignPO.class); // ContainerFeignPO containerFeignPO = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContainerFeignPO.class);
shiftMaterialDetailDO.setContainerCode(containerFeignPO.getContainerCode()); // shiftMaterialDetailDO.setContainerCode(containerFeignPO.getContainerCode());
shiftMaterialDetailDO.setContainerType(containerFeignPO.getContainerType()); // shiftMaterialDetailDO.setContainerType(containerFeignPO.getContainerType());
shiftMaterialDetailDO.setContainerTypeName(containerFeignPO.getContainerTypeName()); // shiftMaterialDetailDO.setContainerTypeName(containerFeignPO.getContainerTypeName());
} }
/** /**
@@ -1,16 +1,29 @@
package com.mhd.wms.application.service.shiftMaterialDetail; package com.mhd.wms.application.service.shiftMaterialDetail;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign; import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.domain.BatchDetailFeignPO;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
import com.mhd.wms.domain.shiftMaterialDetail.repository.po.ShiftMaterialDetailPO; import com.mhd.wms.domain.shiftMaterialDetail.repository.po.ShiftMaterialDetailPO;
import com.mhd.wms.domain.shiftMaterialDetail.repository.todo.ShiftMaterialDetailDO; import com.mhd.wms.domain.shiftMaterialDetail.repository.todo.ShiftMaterialDetailDO;
import com.mhd.wms.domain.shiftMaterialDetail.service.ShiftMaterialDetailDomainService; import com.mhd.wms.domain.shiftMaterialDetail.service.ShiftMaterialDetailDomainService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List; import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* 移位物料明细ApplicationService * 移位物料明细ApplicationService
@@ -25,6 +38,8 @@ public class ShiftMaterialDetailApplicationService {
private ShiftMaterialDetailDomainService shiftMaterialDetailDomainService; private ShiftMaterialDetailDomainService shiftMaterialDetailDomainService;
@Autowired @Autowired
private SystemServiceFeign systemServiceFeign; private SystemServiceFeign systemServiceFeign;
@Autowired
private MaterialInventoryMapper materialInventoryMapper;
/** /**
* 分页查询移位物料明细列表 * 分页查询移位物料明细列表
@@ -92,4 +107,273 @@ public class ShiftMaterialDetailApplicationService {
return shiftMaterialDetailDomainService.getShiftMaterialDetail(shiftMaterialDetailDO); return shiftMaterialDetailDomainService.getShiftMaterialDetail(shiftMaterialDetailDO);
} }
/**
* 查询移位物料明细列表带批次属性
* 批次属性值从库存表中获取
*/
public List<ShiftMaterialDetailPO> queryListWithBatchAttributes(ShiftMaterialDetailDO shiftMaterialDetailDO) {
List<ShiftMaterialDetailPO> list = queryList(shiftMaterialDetailDO);
if (CollectionUtils.isEmpty(list)) {
return list;
}
// 性能优化批量获取批次属性避免N+1查询问题
// 1. 收集所有唯一的materialBaseInfoId
Set<Long> materialBaseInfoIdSet = list.stream()
.map(ShiftMaterialDetailPO::getMaterialBaseInfoId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 2. 批量查询批次属性使用Map缓存避免重复查询相同的materialBaseInfoId
Map<Long, List<BatchDetailFeignPO>> batchDetailMap = new HashMap<>();
for (Long materialBaseInfoId : materialBaseInfoIdSet) {
try {
AjaxResult ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(materialBaseInfoId);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<BatchDetailFeignPO> batchDetailFeignPOList = JSON.parseArray(
JSONObject.toJSONString(ajaxResult.get("data")), BatchDetailFeignPO.class);
if (!CollectionUtils.isEmpty(batchDetailFeignPOList)) {
// 过滤isDisplay=1的属性
List<BatchDetailFeignPO> filteredList = batchDetailFeignPOList.stream()
.filter(batchDetail -> batchDetail.getIsDisplay() != null && batchDetail.getIsDisplay() == 1)
.collect(Collectors.toList());
batchDetailMap.put(materialBaseInfoId, filteredList);
}
}
} catch (Exception e) {
log.warn("获取物料批次属性失败,物料基础信息ID:{},错误:{}", materialBaseInfoId, e.getMessage());
}
}
// 3. 为每个物料明细设置更多属性从库存表中获取值
setMaterialMoreDetailListFromInventory(list, batchDetailMap);
return list;
}
/**
* 为移位物料明细设置更多属性从库存表中获取值
* @param shiftMaterialDetailPOList 移位物料明细列表
* @param batchDetailMap 批次属性Map
*/
private void setMaterialMoreDetailListFromInventory(List<ShiftMaterialDetailPO> shiftMaterialDetailPOList,
Map<Long, List<BatchDetailFeignPO>> batchDetailMap) {
if (CollectionUtils.isEmpty(shiftMaterialDetailPOList)) {
return;
}
shiftMaterialDetailPOList.forEach(shiftMaterialDetailPO -> {
Long materialBaseInfoId = shiftMaterialDetailPO.getMaterialBaseInfoId();
Long materialInventoryId = shiftMaterialDetailPO.getMaterialInventoryId();
// 创建新的materialMoreDetailList只包含isDisplay=1的属性
List<MaterialMoreDetailPO> materialMoreDetailList = new ArrayList<>();
// 从库存表获取数据包含批次属性字段
MaterialInventoryPO materialInventoryPO = null;
if (materialInventoryId != null) {
materialInventoryPO = materialInventoryMapper.selectByIdWithBatchAttributes(materialInventoryId);
}
if (materialBaseInfoId != null && batchDetailMap.containsKey(materialBaseInfoId)) {
List<BatchDetailFeignPO> batchDetailFeignPOList = batchDetailMap.get(materialBaseInfoId);
// 用于跟踪已添加到列表中的batchDetailId
Set<Long> addedBatchDetailIds = new HashSet<>();
for (BatchDetailFeignPO batchDetailFeignPO : batchDetailFeignPOList) {
MaterialMoreDetailPO materialMoreDetailPO = new MaterialMoreDetailPO();
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchDetailId(batchDetailFeignPO.getBatchDetailId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
// 确保添加到列表中使用batchDetailId来避免重复
Long batchDetailId = batchDetailFeignPO.getBatchDetailId();
if (batchDetailId != null && !addedBatchDetailIds.contains(batchDetailId)) {
materialMoreDetailList.add(materialMoreDetailPO);
addedBatchDetailIds.add(batchDetailId);
}
// 根据fieldName或batchLabels从库存表中获取对应的字段值
if (materialInventoryPO != null) {
String fieldValue = null;
String usedFieldName = null;
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(materialInventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, fieldName={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射到字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(materialInventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
}
}
// 只有当获取到值时才更新attributeValue
if (fieldValue != null) {
materialMoreDetailPO.setAttributeValue(fieldValue);
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
materialMoreDetailPO.getAttributeValue());
}
}
}
}
shiftMaterialDetailPO.setMaterialMoreDetailList(materialMoreDetailList);
log.info("移位物料明细 uniqueId={}, materialBaseInfoId={}, materialInventoryId={}, materialMoreDetailList大小={}",
shiftMaterialDetailPO.getUniqueId(), shiftMaterialDetailPO.getMaterialBaseInfoId(),
shiftMaterialDetailPO.getMaterialInventoryId(),
materialMoreDetailList != null ? materialMoreDetailList.size() : 0);
});
}
/**
* 根据批次标签batchLabels映射到字段名
* @param batchLabel 批次标签
* @return 字段名如果找不到映射则返回null
*/
private String getFieldNameByBatchLabel(String batchLabel) {
if (StringUtils.isBlank(batchLabel)) {
return null;
}
// 批次标签到字段名的映射关系
Map<String, String> labelToFieldNameMap = new HashMap<>();
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("Invoice No", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
labelToFieldNameMap.put("Batch Ref NO's", "batchRefNo");
labelToFieldNameMap.put("Batch Ref NO", "batchRefNo");
labelToFieldNameMap.put("批次参考号", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("Sheet Ref NO", "sheetRefNo");
labelToFieldNameMap.put("单据参考号", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("箱号", "boxPalletNo");
labelToFieldNameMap.put("卡板号", "boxPalletNo");
labelToFieldNameMap.put("生产日期", "productionDate");
labelToFieldNameMap.put("过期日期", "expiryDate");
labelToFieldNameMap.put("存货日期", "inventoryDate");
labelToFieldNameMap.put("扩展字段1", "extAttr1");
labelToFieldNameMap.put("扩展字段2", "extAttr2");
labelToFieldNameMap.put("扩展字段3", "extAttr3");
labelToFieldNameMap.put("扩展字段4", "extAttr4");
// 精确匹配
String fieldName = labelToFieldNameMap.get(batchLabel.trim());
if (StringUtils.isNotBlank(fieldName)) {
return fieldName;
}
// 模糊匹配包含关系
for (Map.Entry<String, String> entry : labelToFieldNameMap.entrySet()) {
if (batchLabel.contains(entry.getKey()) || entry.getKey().contains(batchLabel)) {
return entry.getValue();
}
}
return null;
}
/**
* 根据字段名从对象中获取字段值使用反射
* @param obj 对象
* @param fieldName 字段名
* @return 字段值转换为字符串
*/
private String getFieldValueByFieldName(Object obj, String fieldName) {
if (obj == null || StringUtils.isBlank(fieldName)) {
return null;
}
try {
// 兼容如果传的是下划线命名数据库列名风格先转成驼峰字段名再取
String normalizedFieldName = fieldName;
if (normalizedFieldName.contains("_")) {
normalizedFieldName = snakeToCamel(normalizedFieldName);
}
// 获取对象的Class
Class<?> clazz = obj.getClass();
// 尝试获取字段包括父类字段
Field field = null;
Class<?> currentClass = clazz;
while (currentClass != null && field == null) {
try {
field = currentClass.getDeclaredField(normalizedFieldName);
} catch (NoSuchFieldException e) {
currentClass = currentClass.getSuperclass();
}
}
if (field == null) {
log.warn("字段不存在:{}(normalized{}),对象类型:{}", fieldName, normalizedFieldName, clazz.getName());
return null;
}
// 设置可访问
field.setAccessible(true);
// 获取字段值
Object value = field.get(obj);
// 转换为字符串
if (value == null) {
log.info("字段 {} 的值为 null,对象类型:{}", normalizedFieldName, clazz.getName());
return null;
}
String result;
// 处理日期类型字段
if (value instanceof Date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
result = sdf.format((Date) value);
} else {
result = value.toString();
}
log.info("通过反射获取字段值成功,字段名:{}(原始:{}),值:{},对象类型:{}",
normalizedFieldName, fieldName, result, clazz.getName());
return result;
} catch (Exception e) {
log.warn("通过反射获取字段值失败,字段名:{},对象类型:{},错误:{}", fieldName, obj.getClass().getName(), e.getMessage());
return null;
}
}
private String snakeToCamel(String snake) {
if (StringUtils.isBlank(snake)) {
return null;
}
String s = snake.trim().toLowerCase();
StringBuilder sb = new StringBuilder();
boolean upperNext = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '_') {
upperNext = true;
continue;
}
if (upperNext) {
sb.append(Character.toUpperCase(c));
upperNext = false;
} else {
sb.append(c);
}
}
return sb.toString();
}
} }
@@ -1,11 +1,20 @@
package com.mhd.wms.application.service.statementStatistics; package com.mhd.wms.application.service.statementStatistics;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.domain.BatchDetailFeignPO;
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO; import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil; import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.inventoryStandingDetail.service.InventoryStandingDetailDomainService; import com.mhd.wms.domain.inventoryStandingDetail.service.InventoryStandingDetailDomainService;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
import com.mhd.wms.domain.materialInventory.service.MaterialInventoryDomainService; import com.mhd.wms.domain.materialInventory.service.MaterialInventoryDomainService;
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
import com.mhd.wms.domain.statementStatistics.po.ImmediateInventoryPO; import com.mhd.wms.domain.statementStatistics.po.ImmediateInventoryPO;
import com.mhd.wms.domain.statementStatistics.po.WarehousingReportPO; import com.mhd.wms.domain.statementStatistics.po.WarehousingReportPO;
import com.mhd.wms.domain.statementStatistics.todo.ImmediateInventoryDO; import com.mhd.wms.domain.statementStatistics.todo.ImmediateInventoryDO;
@@ -13,8 +22,12 @@ import com.mhd.wms.domain.statementStatistics.todo.WarehousingReportDO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List; import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* 报表管理ApplicationService * 报表管理ApplicationService
@@ -29,6 +42,10 @@ public class StatementStatisticsService {
private MaterialInventoryDomainService materialInventoryDomainService; private MaterialInventoryDomainService materialInventoryDomainService;
@Autowired @Autowired
private InventoryStandingDetailDomainService inventoryStandingDetailDomainService; private InventoryStandingDetailDomainService inventoryStandingDetailDomainService;
@Autowired
private MaterialInventoryMapper materialInventoryMapper;
@Autowired
private SystemServiceFeign systemServiceFeign;
/** /**
* 分页查询即时库存列表 * 分页查询即时库存列表
@@ -41,10 +58,288 @@ public class StatementStatisticsService {
if (topOrganizationId != null && topOrganizationId != 1){ if (topOrganizationId != null && topOrganizationId != 1){
immediateInventoryDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); immediateInventoryDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
} }
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); // 只有在用户没有明确指定仓库参数时才使用缓存中的仓库信息
immediateInventoryDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); // 如果用户已经传递了 warehouseIdwarehouseCode warehouseName优先使用这些值
boolean hasWarehouseFilter = (immediateInventoryDO.getWarehouseId() != null)
|| (immediateInventoryDO.getWarehouseCode() != null && !immediateInventoryDO.getWarehouseCode().trim().isEmpty())
|| (immediateInventoryDO.getWarehouseName() != null && !immediateInventoryDO.getWarehouseName().trim().isEmpty());
if (!hasWarehouseFilter) {
try {
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
if (associationWarehouseCacheDO != null) {
if (associationWarehouseCacheDO.getWarehouseId() != null) {
immediateInventoryDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
}
if (associationWarehouseCacheDO.getWarehouseCode() != null && !associationWarehouseCacheDO.getWarehouseCode().trim().isEmpty()) {
immediateInventoryDO.setWarehouseCode(associationWarehouseCacheDO.getWarehouseCode());
}
if (associationWarehouseCacheDO.getWarehouseName() != null && !associationWarehouseCacheDO.getWarehouseName().trim().isEmpty()) {
immediateInventoryDO.setWarehouseName(associationWarehouseCacheDO.getWarehouseName());
}
}
} catch (Exception e) {
// 如果获取仓库信息失败记录日志但不影响查询允许查询所有仓库
log.warn("获取用户关联仓库信息失败,将查询所有仓库数据,用户ID:{},错误:{}", loginUser.getUserid(), e.getMessage());
}
}
} }
return materialInventoryDomainService.queryImmediateInventoryList(immediateInventoryDO); List<ImmediateInventoryPO> immediateInventoryPOS = materialInventoryDomainService.queryImmediateInventoryList(immediateInventoryDO);
// 性能优化批量获取批次属性避免N+1查询问题
// 1. 收集所有唯一的materialBaseInfoId
Set<Long> materialBaseInfoIdSet = immediateInventoryPOS.stream()
.map(ImmediateInventoryPO::getMaterialBaseInfoId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 2. 批量查询批次属性使用Map缓存避免重复查询相同的materialBaseInfoId
Map<Long, List<BatchDetailFeignPO>> batchDetailMap = new HashMap<>();
for (Long materialBaseInfoId : materialBaseInfoIdSet) {
try {
AjaxResult ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(materialBaseInfoId);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<BatchDetailFeignPO> batchDetailFeignPOList = JSON.parseArray(
JSONObject.toJSONString(ajaxResult.get("data")), BatchDetailFeignPO.class);
if (!CollectionUtils.isEmpty(batchDetailFeignPOList)) {
// 过滤isDisplay=1的属性
List<BatchDetailFeignPO> filteredList = batchDetailFeignPOList.stream()
.filter(batchDetail -> batchDetail.getIsDisplay() != null && batchDetail.getIsDisplay() == 1)
.collect(Collectors.toList());
batchDetailMap.put(materialBaseInfoId, filteredList);
}
}
} catch (Exception e) {
log.warn("获取物料批次属性失败,物料基础信息ID:{},错误:{}", materialBaseInfoId, e.getMessage());
}
}
// 3. 为每个物料明细设置更多属性从库存表中获取值
setMaterialMoreDetailListFromInventory(immediateInventoryPOS, batchDetailMap);
return immediateInventoryPOS;
}
/**
* 为物料库存设置更多属性从库存表中获取值
* @param materialInventoryPOList 物料库存列表
* @param batchDetailMap 批次属性Map
*/
private void setMaterialMoreDetailListFromInventory(List<ImmediateInventoryPO> materialInventoryPOList,
Map<Long, List<BatchDetailFeignPO>> batchDetailMap) {
if (CollectionUtils.isEmpty(materialInventoryPOList)) {
return;
}
materialInventoryPOList.forEach(materialInventoryPO -> {
Long materialBaseInfoId = materialInventoryPO.getMaterialBaseInfoId();
Long materialInventoryId = materialInventoryPO.getMaterialInventoryId();
// 创建新的materialMoreDetailList只包含isDisplay=1的属性
List<MaterialMoreDetailPO> materialMoreDetailList = new ArrayList<>();
// 从库存表获取数据包含批次属性字段
MaterialInventoryPO inventoryPO = null;
if (materialInventoryId != null) {
inventoryPO = materialInventoryMapper.selectByIdWithBatchAttributes(materialInventoryId);
}
if (materialBaseInfoId != null && batchDetailMap.containsKey(materialBaseInfoId)) {
List<BatchDetailFeignPO> batchDetailFeignPOList = batchDetailMap.get(materialBaseInfoId);
// 用于跟踪已添加到列表中的batchDetailId
Set<Long> addedBatchDetailIds = new HashSet<>();
for (BatchDetailFeignPO batchDetailFeignPO : batchDetailFeignPOList) {
MaterialMoreDetailPO materialMoreDetailPO = new MaterialMoreDetailPO();
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchDetailId(batchDetailFeignPO.getBatchDetailId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
// 确保添加到列表中使用batchDetailId来避免重复
Long batchDetailId = batchDetailFeignPO.getBatchDetailId();
if (batchDetailId != null && !addedBatchDetailIds.contains(batchDetailId)) {
materialMoreDetailList.add(materialMoreDetailPO);
addedBatchDetailIds.add(batchDetailId);
}
// 根据fieldName或batchLabels从库存表中获取对应的字段值
if (inventoryPO != null) {
String fieldValue = null;
String usedFieldName = null;
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(inventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, fieldName={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射到字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(inventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
}
}
// 只有当获取到值时才更新attributeValue
if (fieldValue != null) {
materialMoreDetailPO.setAttributeValue(fieldValue);
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
materialMoreDetailPO.getAttributeValue());
}
}
}
}
materialInventoryPO.setMaterialMoreDetailList(materialMoreDetailList);
log.info("物料库存 materialInventoryId={}, materialBaseInfoId={}, materialMoreDetailList大小={}",
materialInventoryPO.getMaterialInventoryId(), materialInventoryPO.getMaterialBaseInfoId(),
materialMoreDetailList != null ? materialMoreDetailList.size() : 0);
});
}
/**
* 根据字段名从对象中获取字段值使用反射
* @param obj 对象
* @param fieldName 字段名
* @return 字段值转换为字符串
*/
private String getFieldValueByFieldName(Object obj, String fieldName) {
if (obj == null || StringUtils.isBlank(fieldName)) {
return null;
}
try {
// 兼容如果传的是下划线命名数据库列名风格先转成驼峰字段名再取
String normalizedFieldName = fieldName;
if (normalizedFieldName.contains("_")) {
normalizedFieldName = snakeToCamel(normalizedFieldName);
}
// 获取对象的Class
Class<?> clazz = obj.getClass();
// 尝试获取字段包括父类字段
Field field = null;
Class<?> currentClass = clazz;
while (currentClass != null && field == null) {
try {
field = currentClass.getDeclaredField(normalizedFieldName);
} catch (NoSuchFieldException e) {
currentClass = currentClass.getSuperclass();
}
}
if (field == null) {
log.warn("字段不存在:{}(normalized{}),对象类型:{}", fieldName, normalizedFieldName, clazz.getName());
return null;
}
// 设置可访问
field.setAccessible(true);
// 获取字段值
Object value = field.get(obj);
// 转换为字符串
if (value == null) {
log.info("字段 {} 的值为 null,对象类型:{}", normalizedFieldName, clazz.getName());
return null;
}
String result;
// 处理日期类型字段
if (value instanceof Date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
result = sdf.format((Date) value);
} else {
result = value.toString();
}
log.info("通过反射获取字段值成功,字段名:{}(原始:{}),值:{},对象类型:{}",
normalizedFieldName, fieldName, result, clazz.getName());
return result;
} catch (Exception e) {
log.warn("通过反射获取字段值失败,字段名:{},对象类型:{},错误:{}", fieldName, obj.getClass().getName(), e.getMessage());
return null;
}
}
private String snakeToCamel(String snake) {
if (StringUtils.isBlank(snake)) {
return null;
}
String s = snake.trim().toLowerCase();
StringBuilder sb = new StringBuilder();
boolean upperNext = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '_') {
upperNext = true;
continue;
}
if (upperNext) {
sb.append(Character.toUpperCase(c));
upperNext = false;
} else {
sb.append(c);
}
}
return sb.toString();
}
/**
* 根据批次标签batchLabels映射到字段名
* @param batchLabel 批次标签
* @return 字段名如果找不到映射则返回null
*/
private String getFieldNameByBatchLabel(String batchLabel) {
if (StringUtils.isBlank(batchLabel)) {
return null;
}
// 批次标签到字段名的映射关系
Map<String, String> labelToFieldNameMap = new HashMap<>();
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("Invoice No", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
labelToFieldNameMap.put("Batch Ref NO's", "batchRefNo");
labelToFieldNameMap.put("Batch Ref NO", "batchRefNo");
labelToFieldNameMap.put("批次参考号", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("Sheet Ref NO", "sheetRefNo");
labelToFieldNameMap.put("单据参考号", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("箱号", "boxPalletNo");
labelToFieldNameMap.put("卡板号", "boxPalletNo");
labelToFieldNameMap.put("生产日期", "productionDate");
labelToFieldNameMap.put("过期日期", "expiryDate");
labelToFieldNameMap.put("存货日期", "inventoryDate");
labelToFieldNameMap.put("扩展字段1", "extAttr1");
labelToFieldNameMap.put("扩展字段2", "extAttr2");
labelToFieldNameMap.put("扩展字段3", "extAttr3");
labelToFieldNameMap.put("扩展字段4", "extAttr4");
// 精确匹配
String fieldName = labelToFieldNameMap.get(batchLabel.trim());
if (StringUtils.isNotBlank(fieldName)) {
return fieldName;
}
// 模糊匹配包含关系
for (Map.Entry<String, String> entry : labelToFieldNameMap.entrySet()) {
if (batchLabel.contains(entry.getKey()) || entry.getKey().contains(batchLabel)) {
return entry.getValue();
}
}
return null;
} }
/** /**
@@ -16,14 +16,17 @@ import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign; import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.UserServiceFeign; import com.mhd.system.api.UserServiceFeign;
import com.mhd.system.api.domain.BatchDetailFeignPO;
import com.mhd.system.api.domain.StorageLocationFeignPO; import com.mhd.system.api.domain.StorageLocationFeignPO;
import com.mhd.system.api.domain.SysDictData; import com.mhd.system.api.domain.SysDictData;
import com.mhd.system.api.domain.WarehouseFeignPO; import com.mhd.system.api.domain.WarehouseFeignPO;
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO; import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil; import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO; import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
import com.mhd.wms.domain.materialInventory.service.MaterialInventoryDomainService; import com.mhd.wms.domain.materialInventory.service.MaterialInventoryDomainService;
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
import com.mhd.wms.domain.outMaterialDetail.repository.po.OutMaterialCheckPO; import com.mhd.wms.domain.outMaterialDetail.repository.po.OutMaterialCheckPO;
import com.mhd.wms.domain.outMaterialDetail.repository.po.OutMaterialDetailPO; import com.mhd.wms.domain.outMaterialDetail.repository.po.OutMaterialDetailPO;
import com.mhd.wms.domain.outMaterialDetail.repository.todo.OutMaterialDetailDO; import com.mhd.wms.domain.outMaterialDetail.repository.todo.OutMaterialDetailDO;
@@ -36,10 +39,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -59,6 +62,8 @@ public class StockOutOrderApplicationService {
@Autowired @Autowired
private MaterialInventoryDomainService materialInventoryDomainService; private MaterialInventoryDomainService materialInventoryDomainService;
@Autowired @Autowired
private MaterialInventoryMapper materialInventoryMapper;
@Autowired
private UserServiceFeign userServiceFeign; private UserServiceFeign userServiceFeign;
@Autowired @Autowired
private SystemServiceFeign systemServiceFeign; private SystemServiceFeign systemServiceFeign;
@@ -72,14 +77,14 @@ public class StockOutOrderApplicationService {
public List<StockOutOrderPO> queryList(StockOutOrderDO stockOutOrderDO) { public List<StockOutOrderPO> queryList(StockOutOrderDO stockOutOrderDO) {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){ /*if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId(); Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){ if (topOrganizationId != null && topOrganizationId != 1){
stockOutOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); stockOutOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
} }
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
stockOutOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); stockOutOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
} }*/
return stockOutOrderDomainService.queryList(stockOutOrderDO); return stockOutOrderDomainService.queryList(stockOutOrderDO);
} }
@@ -89,13 +94,15 @@ public class StockOutOrderApplicationService {
*/ */
public Boolean insert(StockOutOrderDO stockOutOrderDO) { public Boolean insert(StockOutOrderDO stockOutOrderDO) {
//设置仓库 //设置仓库
setWarehouseInfo(stockOutOrderDO); //setWarehouseInfo(stockOutOrderDO);
//设置货主信息 //设置货主信息
shipperParam(stockOutOrderDO); shipperParam(stockOutOrderDO);
//设置客户信息 //设置客户信息
customerParam(stockOutOrderDO); customerParam(stockOutOrderDO);
stockOutOrderDO.setOrderTypeCode("pu_tong_chu_ku");
stockOutOrderDO.setOrderTypeName("普通出库");
//设置数据字典键值 //设置数据字典键值
setDataDict(stockOutOrderDO); //setDataDict(stockOutOrderDO);
return stockOutOrderDomainService.insert(stockOutOrderDO); return stockOutOrderDomainService.insert(stockOutOrderDO);
} }
@@ -121,11 +128,367 @@ public class StockOutOrderApplicationService {
} }
/** /**
* 获取出库单详细信息 * 获取出库单详细信息带批次属性
*/ */
public StockOutOrderPO getInfoChildren(Long outOrderId) public StockOutOrderPO getInfoChildren(Long outOrderId)
{ {
return stockOutOrderDomainService.getInfoChildren(outOrderId); StockOutOrderPO stockOutOrderPO = stockOutOrderDomainService.getInfoChildren(outOrderId);
if (stockOutOrderPO == null || CollectionUtils.isEmpty(stockOutOrderPO.getMaterialDetailList())) {
return stockOutOrderPO;
}
List<OutMaterialDetailPO> detailList = stockOutOrderPO.getMaterialDetailList();
// 性能优化批量获取批次属性避免N+1查询问题
// 1. 收集所有唯一的materialBaseInfoId
Set<Long> materialBaseInfoIdSet = detailList.stream()
.map(OutMaterialDetailPO::getMaterialBaseInfoId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 2. 批量查询批次属性使用Map缓存避免重复查询相同的materialBaseInfoId
Map<Long, List<BatchDetailFeignPO>> batchDetailMap = new HashMap<>();
for (Long materialBaseInfoId : materialBaseInfoIdSet) {
try {
AjaxResult ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(materialBaseInfoId);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<BatchDetailFeignPO> batchDetailFeignPOList = JSON.parseArray(
JSONObject.toJSONString(ajaxResult.get("data")), BatchDetailFeignPO.class);
if (!CollectionUtils.isEmpty(batchDetailFeignPOList)) {
// 过滤isDisplay=1的属性
List<BatchDetailFeignPO> filteredList = batchDetailFeignPOList.stream()
.filter(batchDetail -> batchDetail.getIsDisplay() != null && batchDetail.getIsDisplay() == 1)
.collect(Collectors.toList());
batchDetailMap.put(materialBaseInfoId, filteredList);
}
}
} catch (Exception e) {
log.warn("获取物料批次属性失败,物料基础信息ID:{},错误:{}", materialBaseInfoId, e.getMessage());
}
}
// 3. 为每个物料明细设置更多属性从物料明细表中获取值递归处理所有层级
setMaterialMoreDetailListRecursively(detailList, batchDetailMap);
// 4. 为每个物料明细设置分配按钮显示类型递归处理所有层级
setAllocationButtonTypeRecursively(detailList);
return stockOutOrderPO;
}
/**
* 递归为出库物料明细设置更多属性
* 如果已分配库存materialInventoryId不为空则从库存表中获取批次属性值
* 否则从物料明细表中获取值
* @param outMaterialDetailPOList 出库物料明细列表
* @param batchDetailMap 批次属性Map
*/
private void setMaterialMoreDetailListRecursively(List<OutMaterialDetailPO> outMaterialDetailPOList,
Map<Long, List<BatchDetailFeignPO>> batchDetailMap) {
if (CollectionUtils.isEmpty(outMaterialDetailPOList)) {
return;
}
outMaterialDetailPOList.forEach(outMaterialDetailPO -> {
Long materialBaseInfoId = outMaterialDetailPO.getMaterialBaseInfoId();
Long materialInventoryId = outMaterialDetailPO.getMaterialInventoryId();
// 创建新的materialMoreDetailList只包含isDisplay=1的属性
List<MaterialMoreDetailPO> materialMoreDetailList = new ArrayList<>();
// 创建batchDetailId到MaterialMoreDetailPO的映射用于快速查找已有的属性值
Map<Long, MaterialMoreDetailPO> batchDetailIdToMaterialMoreDetailMap = new HashMap<>();
List<MaterialMoreDetailPO> existingList = outMaterialDetailPO.getMaterialMoreDetailList();
if (!CollectionUtils.isEmpty(existingList)) {
for (MaterialMoreDetailPO existing : existingList) {
if (existing.getBatchDetailId() != null) {
batchDetailIdToMaterialMoreDetailMap.put(existing.getBatchDetailId(), existing);
}
}
}
// 如果已分配库存从库存表中获取批次属性值
MaterialInventoryPO inventoryPO = null;
if (materialInventoryId != null && materialInventoryId > 0) {
try {
inventoryPO = materialInventoryMapper.selectByIdWithBatchAttributes(materialInventoryId);
log.info("从库存表获取批次属性,materialInventoryId={}", materialInventoryId);
} catch (Exception e) {
log.warn("从库存表获取批次属性失败,materialInventoryId={},错误:{}", materialInventoryId, e.getMessage());
}
}
// 只保留isDisplay=1的批次属性从batchDetailMap中获取已经过滤过了
if (materialBaseInfoId != null && batchDetailMap.containsKey(materialBaseInfoId)) {
List<BatchDetailFeignPO> batchDetailFeignPOList = batchDetailMap.get(materialBaseInfoId);
// 用于跟踪已添加到列表中的batchDetailId
Set<Long> addedBatchDetailIds = new HashSet<>();
for (BatchDetailFeignPO batchDetailFeignPO : batchDetailFeignPOList) {
MaterialMoreDetailPO materialMoreDetailPO = batchDetailIdToMaterialMoreDetailMap.get(batchDetailFeignPO.getBatchDetailId());
// 如果不存在创建新的
if (materialMoreDetailPO == null) {
materialMoreDetailPO = new MaterialMoreDetailPO();
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchDetailId(batchDetailFeignPO.getBatchDetailId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
} else {
// 如果已存在更新属性保留已有的attributeValue
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
}
// 确保添加到列表中使用batchDetailId来避免重复
Long batchDetailId = batchDetailFeignPO.getBatchDetailId();
if (batchDetailId != null && !addedBatchDetailIds.contains(batchDetailId)) {
materialMoreDetailList.add(materialMoreDetailPO);
addedBatchDetailIds.add(batchDetailId);
}
// 根据fieldName或batchLabels获取对应的字段值
String fieldValue = null;
String usedFieldName = null;
// 只有在已分配库存时才从库存表获取值并设置到attributeValue
if (inventoryPO != null) {
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(inventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, fieldName={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射到字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(inventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
}
}
// 只有当获取到值时才更新attributeValue已分配库存时
if (fieldValue != null) {
materialMoreDetailPO.setAttributeValue(fieldValue);
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
materialMoreDetailPO.getAttributeValue());
}
} else {
// 未分配库存时attributeValue保持为空不设置值
log.info("批次属性未分配库存,batchDetailId={}, batchLabels={}, attributeValue为空",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels());
}
}
}
outMaterialDetailPO.setMaterialMoreDetailList(materialMoreDetailList);
log.info("出库物料明细 uniqueId={}, materialBaseInfoId={}, materialInventoryId={}, materialMoreDetailList大小={}",
outMaterialDetailPO.getUniqueId(), outMaterialDetailPO.getMaterialBaseInfoId(),
outMaterialDetailPO.getMaterialInventoryId(),
materialMoreDetailList != null ? materialMoreDetailList.size() : 0);
// 递归处理子集
if (!CollectionUtils.isEmpty(outMaterialDetailPO.getChildren())) {
setMaterialMoreDetailListRecursively(outMaterialDetailPO.getChildren(), batchDetailMap);
}
});
}
/**
* 根据批次标签batchLabels映射到字段名
* @param batchLabel 批次标签
* @return 字段名如果找不到映射则返回null
*/
private String getFieldNameByBatchLabel(String batchLabel) {
if (StringUtils.isBlank(batchLabel)) {
return null;
}
// 批次标签到字段名的映射关系
Map<String, String> labelToFieldNameMap = new HashMap<>();
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("Invoice No", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
labelToFieldNameMap.put("Batch Ref NO's", "batchRefNo");
labelToFieldNameMap.put("Batch Ref NO", "batchRefNo");
labelToFieldNameMap.put("批次参考号", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("Sheet Ref NO", "sheetRefNo");
labelToFieldNameMap.put("单据参考号", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("箱号", "boxPalletNo");
labelToFieldNameMap.put("卡板号", "boxPalletNo");
labelToFieldNameMap.put("申报数量", "declareQuantity");
labelToFieldNameMap.put("申报单位", "declareUnit");
labelToFieldNameMap.put("原产国", "countryOfOrigin");
labelToFieldNameMap.put("币制", "currency");
labelToFieldNameMap.put("单位", "unit");
labelToFieldNameMap.put("", "liter");
labelToFieldNameMap.put("尺寸", "size");
labelToFieldNameMap.put("箱数", "caseCount");
labelToFieldNameMap.put("件数", "pieceCount");
labelToFieldNameMap.put("出库数量", "outboundQuantity");
labelToFieldNameMap.put("总净重", "totalNetWeight");
labelToFieldNameMap.put("总毛重", "totalGrossWeight");
labelToFieldNameMap.put("总体积", "totalVolume");
labelToFieldNameMap.put("总面积", "totalArea");
labelToFieldNameMap.put("总价", "totalAmount");
// 精确匹配
String fieldName = labelToFieldNameMap.get(batchLabel.trim());
if (StringUtils.isNotBlank(fieldName)) {
return fieldName;
}
// 模糊匹配包含关系
for (Map.Entry<String, String> entry : labelToFieldNameMap.entrySet()) {
if (batchLabel.contains(entry.getKey()) || entry.getKey().contains(batchLabel)) {
return entry.getValue();
}
}
// 如果找不到映射尝试将批次标签转换为驼峰命名简单处理
return convertLabelToFieldName(batchLabel);
}
/**
* 将批次标签转换为字段名驼峰命名
* @param label 批次标签
* @return 字段名
*/
private String convertLabelToFieldName(String label) {
if (StringUtils.isBlank(label)) {
return null;
}
// 移除特殊字符转换为小写用空格或特殊字符分割
String cleaned = label.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5\\s]", " ")
.trim()
.toLowerCase();
// 如果是中文无法自动转换返回null
if (cleaned.matches(".*[\\u4e00-\\u9fa5].*")) {
return null;
}
// 将空格分割的单词转换为驼峰命名
String[] words = cleaned.split("\\s+");
if (words.length == 0) {
return null;
}
StringBuilder fieldName = new StringBuilder(words[0]);
for (int i = 1; i < words.length; i++) {
if (words[i].length() > 0) {
fieldName.append(words[i].substring(0, 1).toUpperCase())
.append(words[i].substring(1));
}
}
return fieldName.toString();
}
/**
* 根据字段名从对象中获取字段值使用反射
* @param obj 对象
* @param fieldName 字段名
* @return 字段值转换为字符串
*/
private String getFieldValueByFieldName(Object obj, String fieldName) {
if (obj == null || StringUtils.isBlank(fieldName)) {
return null;
}
try {
// 兼容如果传的是下划线命名数据库列名风格先转成驼峰字段名再取
String normalizedFieldName = fieldName;
if (normalizedFieldName.contains("_")) {
normalizedFieldName = snakeToCamel(normalizedFieldName);
}
// 获取对象的Class
Class<?> clazz = obj.getClass();
// 尝试获取字段包括父类字段
Field field = null;
Class<?> currentClass = clazz;
while (currentClass != null && field == null) {
try {
field = currentClass.getDeclaredField(normalizedFieldName);
} catch (NoSuchFieldException e) {
currentClass = currentClass.getSuperclass();
}
}
if (field == null) {
log.warn("字段不存在:{}(normalized{}),对象类型:{}", fieldName, normalizedFieldName, clazz.getName());
return null;
}
// 设置可访问
field.setAccessible(true);
// 获取字段值
Object value = field.get(obj);
// 转换为字符串
if (value == null) {
log.info("字段 {} 的值为 null,对象类型:{}", normalizedFieldName, clazz.getName());
return null;
}
String result;
// 处理日期类型字段
if (value instanceof Date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
result = sdf.format((Date) value);
} else {
result = value.toString();
}
log.info("通过反射获取字段值成功,字段名:{}(原始:{}),值:{},对象类型:{}",
normalizedFieldName, fieldName, result, clazz.getName());
return result;
} catch (Exception e) {
log.warn("通过反射获取字段值失败,字段名:{},对象类型:{},错误:{}", fieldName, obj.getClass().getName(), e.getMessage());
return null;
}
}
private String snakeToCamel(String snake) {
if (StringUtils.isBlank(snake)) {
return null;
}
String s = snake.trim().toLowerCase();
StringBuilder sb = new StringBuilder();
boolean upperNext = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '_') {
upperNext = true;
continue;
}
if (upperNext) {
sb.append(Character.toUpperCase(c));
upperNext = false;
} else {
sb.append(c);
}
}
return sb.toString();
} }
/** /**
@@ -175,6 +538,19 @@ public class StockOutOrderApplicationService {
return stockOutOrderDomainService.cancelAssign(stockOutOrderDO); return stockOutOrderDomainService.cancelAssign(stockOutOrderDO);
} }
/**
* @description 手动取消分配点击确认后直接取消分配
* @author ZhouGY
* @date 2024/5/28 13:47
* @param stockOutOrderDO
* @return Boolean
*/
public Boolean manualCancelAssign(StockOutOrderDO stockOutOrderDO){
// 取消分配不需要经过assembleParamByOutOrder因为该方法是为分配设计的会过滤掉allocationQuantity为0的明细
// 直接调用领域服务传递原始参数
return stockOutOrderDomainService.manualCancelAssign(stockOutOrderDO);
}
/** /**
* @description 复核下发 * @description 复核下发
@@ -384,6 +760,9 @@ public class StockOutOrderApplicationService {
* @param stockOutOrderDO * @param stockOutOrderDO
*/ */
private void setWarehouseInfo(StockOutOrderDO stockOutOrderDO) { private void setWarehouseInfo(StockOutOrderDO stockOutOrderDO) {
if (stockOutOrderDO.getWarehouseId() == null) {
throw new ServiceException("仓库ID不能为空");
}
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(stockOutOrderDO.getWarehouseId()); AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(stockOutOrderDO.getWarehouseId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){ if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取仓库信息失败"); throw new ServiceException("获取仓库信息失败");
@@ -400,13 +779,26 @@ public class StockOutOrderApplicationService {
* @param stockOutOrderDO * @param stockOutOrderDO
*/ */
private void shipperParam(StockOutOrderDO stockOutOrderDO){ private void shipperParam(StockOutOrderDO stockOutOrderDO){
AjaxResult ajaxResult = userServiceFeign.getInfo(stockOutOrderDO.getShipperId()); String customerName = stockOutOrderDO.getCustomerName();
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){ if (customerName == null || !customerName.matches("\\d+")) {
throw new ServiceException("获取货主信息失败"); AjaxResult ajaxResult = userServiceFeign.getInfoByName(customerName);
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取客户信息失败");
}
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
stockOutOrderDO.setShipperId(userPo.getUserId());
stockOutOrderDO.setShipperCode(userPo.getUserMemberCode());
stockOutOrderDO.setShipperName(userPo.getUserName());
} else {
AjaxResult ajaxResult = userServiceFeign.getInfo(Long.valueOf(customerName));
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取货主信息失败");
}
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
stockOutOrderDO.setShipperId(userPo.getUserId());
stockOutOrderDO.setShipperCode(userPo.getUserMemberCode());
stockOutOrderDO.setShipperName(userPo.getUserName());
} }
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
stockOutOrderDO.setShipperCode(userPo.getUserMemberCode());
stockOutOrderDO.setShipperName(userPo.getUserName());
} }
/** /**
@@ -416,13 +808,26 @@ public class StockOutOrderApplicationService {
* @param stockOutOrderDO * @param stockOutOrderDO
*/ */
private void customerParam(StockOutOrderDO stockOutOrderDO){ private void customerParam(StockOutOrderDO stockOutOrderDO){
AjaxResult ajaxResult = userServiceFeign.getInfo(stockOutOrderDO.getCustomerId()); String customerName = stockOutOrderDO.getCustomerName();
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){ if (customerName == null || !customerName.matches("\\d+")) {
throw new ServiceException("获取客户信息失败"); AjaxResult ajaxResult = userServiceFeign.getInfoByName(customerName);
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取客户信息失败");
}
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
stockOutOrderDO.setCustomerId(userPo.getUserId());
stockOutOrderDO.setCustomerCode(userPo.getUserMemberCode());
stockOutOrderDO.setCustomerName(userPo.getUserName());
} else {
AjaxResult ajaxResult = userServiceFeign.getInfo(Long.valueOf(customerName));
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取客户信息失败");
}
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
stockOutOrderDO.setCustomerId(userPo.getUserId());
stockOutOrderDO.setCustomerCode(userPo.getUserMemberCode());
stockOutOrderDO.setCustomerName(userPo.getUserName());
} }
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
stockOutOrderDO.setCustomerCode(userPo.getUserMemberCode());
stockOutOrderDO.setCustomerName(userPo.getUserName());
} }
/** /**
@@ -520,5 +925,43 @@ public class StockOutOrderApplicationService {
outMaterialDetailDO.setContainerCode(materialInventoryPO.getContainerCode()); outMaterialDetailDO.setContainerCode(materialInventoryPO.getContainerCode());
outMaterialDetailDO.setContainerType(materialInventoryPO.getContainerType()); outMaterialDetailDO.setContainerType(materialInventoryPO.getContainerType());
outMaterialDetailDO.setContainerTypeName(materialInventoryPO.getContainerTypeName()); outMaterialDetailDO.setContainerTypeName(materialInventoryPO.getContainerTypeName());
// 库存数量仅用于前端展示
outMaterialDetailDO.setInventoryQuantity(materialInventoryPO.getInventoryQuantity());
} }
/**
* 递归为出库物料明细设置分配按钮显示类型
* @param outMaterialDetailPOList 出库物料明细列表
*/
private void setAllocationButtonTypeRecursively(List<OutMaterialDetailPO> outMaterialDetailPOList) {
if (CollectionUtils.isEmpty(outMaterialDetailPOList)) {
return;
}
outMaterialDetailPOList.forEach(outMaterialDetailPO -> {
BigDecimal quantity = outMaterialDetailPO.getQuantity(); // 计划数量
BigDecimal alreadyAllocationQuantity = outMaterialDetailPO.getAlreadyAllocationQuantity(); // 已分配数量
// 判断按钮显示类型
// 已分配数量 = 0显示"库存分配"按钮类型1
// 已分配数量 = 计划数量显示"取消分配"按钮类型2
if (alreadyAllocationQuantity == null || alreadyAllocationQuantity.compareTo(BigDecimal.ZERO) == 0) {
// 已分配数量为0或null显示"库存分配"按钮
outMaterialDetailPO.setAllocationButtonType(1);
} else if (quantity != null && alreadyAllocationQuantity.compareTo(quantity) == 0) {
// 已分配数量等于计划数量显示"取消分配"按钮
outMaterialDetailPO.setAllocationButtonType(2);
} else {
// 其他情况已分配数量 > 0 < 计划数量不显示按钮或显示其他状态
outMaterialDetailPO.setAllocationButtonType(0);
}
// 递归处理子级
List<OutMaterialDetailPO> children = outMaterialDetailPO.getChildren();
if (!CollectionUtils.isEmpty(children)) {
setAllocationButtonTypeRecursively(children);
}
});
}
} }
@@ -28,6 +28,7 @@ import com.mhd.wms.domain.materialGoodsRule.repository.facade.IMaterialGoodsRule
import com.mhd.wms.domain.materialGoodsRule.repository.po.MaterialGoodsRulePO; import com.mhd.wms.domain.materialGoodsRule.repository.po.MaterialGoodsRulePO;
import com.mhd.wms.domain.materialWarehouseControl.repository.facade.IMaterialWarehouseControlService; import com.mhd.wms.domain.materialWarehouseControl.repository.facade.IMaterialWarehouseControlService;
import com.mhd.wms.domain.materialWarehouseControl.repository.po.MaterialWarehouseControlPO; import com.mhd.wms.domain.materialWarehouseControl.repository.po.MaterialWarehouseControlPO;
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
import com.mhd.wms.domain.receiptMaterialDetail.repository.po.ReceiptMaterialDetailPO; import com.mhd.wms.domain.receiptMaterialDetail.repository.po.ReceiptMaterialDetailPO;
import com.mhd.wms.domain.receiptMaterialDetail.repository.todo.ReceiptMaterialDetailDO; import com.mhd.wms.domain.receiptMaterialDetail.repository.todo.ReceiptMaterialDetailDO;
import com.mhd.wms.domain.receiptMaterialDetail.service.ReceiptMaterialDetailDomainService; import com.mhd.wms.domain.receiptMaterialDetail.service.ReceiptMaterialDetailDomainService;
@@ -39,14 +40,20 @@ import com.mhd.wms.domain.stockReceiptOrder.service.StockReceiptOrderDomainServi
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mhd.common.core.utils.StringUtils;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -84,11 +91,28 @@ public class StockReceiptOrderApplicationService {
public List<StockReceiptOrderPO> queryList(StockReceiptOrderDO stockReceiptOrderDO) { public List<StockReceiptOrderPO> queryList(StockReceiptOrderDO stockReceiptOrderDO) {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId(); if (loginUser != null){
if (topOrganizationId != null && topOrganizationId != 1){ Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
stockReceiptOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); if (topOrganizationId != null && topOrganizationId != 1){
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); stockReceiptOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
stockReceiptOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); }
try {
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
if (associationWarehouseCacheDO != null) {
if (associationWarehouseCacheDO.getWarehouseId() != null) {
stockReceiptOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
}
if (StringUtils.isNotBlank(associationWarehouseCacheDO.getWarehouseCode())) {
stockReceiptOrderDO.setWarehouseCode(associationWarehouseCacheDO.getWarehouseCode());
}
if (StringUtils.isNotBlank(associationWarehouseCacheDO.getWarehouseName())) {
stockReceiptOrderDO.setWarehouseName(associationWarehouseCacheDO.getWarehouseName());
}
}
} catch (Exception e) {
// 如果获取仓库信息失败记录日志但不影响查询允许查询所有仓库
log.warn("获取用户关联仓库信息失败,将查询所有仓库数据,用户ID:{},错误:{}", loginUser.getUserid(), e.getMessage());
}
} }
return stockReceiptOrderDomainService.queryList(stockReceiptOrderDO); return stockReceiptOrderDomainService.queryList(stockReceiptOrderDO);
} }
@@ -116,10 +140,409 @@ public class StockReceiptOrderApplicationService {
ReceiptMaterialDetailDO receiptMaterialDetailDO = new ReceiptMaterialDetailDO(); ReceiptMaterialDetailDO receiptMaterialDetailDO = new ReceiptMaterialDetailDO();
receiptMaterialDetailDO.setReceiptOrderNumber(stockReceiptOrderPO.getReceiptOrderNumber()); receiptMaterialDetailDO.setReceiptOrderNumber(stockReceiptOrderPO.getReceiptOrderNumber());
List<ReceiptMaterialDetailPO> receiptMaterialDetailPOList = receiptMaterialDetailDomainService.queryListChildren(receiptMaterialDetailDO); List<ReceiptMaterialDetailPO> receiptMaterialDetailPOList = receiptMaterialDetailDomainService.queryListChildren(receiptMaterialDetailDO);
// 性能优化批量获取批次属性避免N+1查询问题
// 1. 收集所有唯一的materialBaseInfoId
Set<Long> materialBaseInfoIdSet = receiptMaterialDetailPOList.stream()
.map(ReceiptMaterialDetailPO::getMaterialBaseInfoId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 2. 批量查询批次属性使用Map缓存避免重复查询相同的materialBaseInfoId
Map<Long, List<BatchDetailFeignPO>> batchDetailMap = new HashMap<>();
for (Long materialBaseInfoId : materialBaseInfoIdSet) {
try {
AjaxResult ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(materialBaseInfoId);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<BatchDetailFeignPO> batchDetailFeignPOList = JSON.parseArray(
JSONObject.toJSONString(ajaxResult.get("data")), BatchDetailFeignPO.class);
if (!CollectionUtils.isEmpty(batchDetailFeignPOList)) {
// 过滤isDisplay=1的属性
List<BatchDetailFeignPO> filteredList = batchDetailFeignPOList.stream()
.filter(batchDetail -> batchDetail.getIsDisplay() != null && batchDetail.getIsDisplay() == 1)
.collect(Collectors.toList());
batchDetailMap.put(materialBaseInfoId, filteredList);
}
}
} catch (Exception e) {
log.warn("获取物料批次属性失败,物料基础信息ID:{},错误:{}", materialBaseInfoId, e.getMessage());
}
}
// 3. 为每个物料明细设置更多属性从缓存中获取递归处理所有层级
setMaterialMoreDetailListRecursively(receiptMaterialDetailPOList, batchDetailMap);
stockReceiptOrderPO.setMaterialDetailList(receiptMaterialDetailPOList); stockReceiptOrderPO.setMaterialDetailList(receiptMaterialDetailPOList);
log.info("返回收货单信息,receiptOrderId={}, materialDetailList大小={}",
stockReceiptOrderPO.getReceiptOrderId(),
receiptMaterialDetailPOList != null ? receiptMaterialDetailPOList.size() : 0);
return stockReceiptOrderPO; return stockReceiptOrderPO;
} }
/**
* 根据物料基础信息ID获取批次属性更多属性只返回isDisplay=1的属性
* 并根据fieldName从物料明细中获取对应的字段值
* @param materialBaseInfoId 物料基础信息ID
* @param receiptMaterialDetailPO 收货物料明细对象用于根据fieldName获取字段值
* @return 更多属性列表
*/
private List<MaterialMoreDetailPO> getMaterialMoreDetailByBatch(Long materialBaseInfoId, ReceiptMaterialDetailPO receiptMaterialDetailPO) {
List<MaterialMoreDetailPO> materialMoreDetailPOList = new ArrayList<>();
if (materialBaseInfoId == null) {
return materialMoreDetailPOList;
}
try {
// 根据物料基础信息ID获取批次属性列表
AjaxResult ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(materialBaseInfoId);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<BatchDetailFeignPO> batchDetailFeignPOList = JSON.parseArray(
JSONObject.toJSONString(ajaxResult.get("data")), BatchDetailFeignPO.class);
if (!CollectionUtils.isEmpty(batchDetailFeignPOList)) {
// 过滤isDisplay=1的属性
batchDetailFeignPOList.stream()
.filter(batchDetail -> batchDetail.getIsDisplay() != null && batchDetail.getIsDisplay() == 1)
.forEach(batchDetailFeignPO -> {
MaterialMoreDetailPO materialMoreDetailPO = new MaterialMoreDetailPO();
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchDetailId(batchDetailFeignPO.getBatchDetailId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
// 根据fieldName或batchLabels从物料明细中获取对应的字段值
if (receiptMaterialDetailPO != null) {
String fieldValue = null;
String usedFieldName = null;
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(receiptMaterialDetailPO, usedFieldName);
log.debug("批次属性 batchDetailId={}, fieldName={}, 获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射到字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(receiptMaterialDetailPO, usedFieldName);
log.debug("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
}
}
materialMoreDetailPO.setAttributeValue(fieldValue);
}
materialMoreDetailPOList.add(materialMoreDetailPO);
});
}
}
} catch (Exception e) {
log.warn("获取物料批次属性失败,物料基础信息ID:{},错误:{}", materialBaseInfoId, e.getMessage());
}
return materialMoreDetailPOList;
}
/**
* 递归为物料明细设置更多属性
* @param receiptMaterialDetailPOList 物料明细列表
* @param batchDetailMap 批次属性Map
*/
private void setMaterialMoreDetailListRecursively(List<ReceiptMaterialDetailPO> receiptMaterialDetailPOList,
Map<Long, List<BatchDetailFeignPO>> batchDetailMap) {
if (CollectionUtils.isEmpty(receiptMaterialDetailPOList)) {
return;
}
receiptMaterialDetailPOList.forEach(receiptMaterialDetailPO -> {
Long materialBaseInfoId = receiptMaterialDetailPO.getMaterialBaseInfoId();
// 只保留isDisplay=1的批次属性从batchDetailMap中获取已经过滤过了
// 创建新的materialMoreDetailList只包含isDisplay=1的属性
List<MaterialMoreDetailPO> materialMoreDetailList = new ArrayList<>();
// 创建batchDetailId到MaterialMoreDetailPO的映射用于快速查找已有的属性值
Map<Long, MaterialMoreDetailPO> batchDetailIdToMaterialMoreDetailMap = new HashMap<>();
List<MaterialMoreDetailPO> existingList = receiptMaterialDetailPO.getMaterialMoreDetailList();
if (!CollectionUtils.isEmpty(existingList)) {
for (MaterialMoreDetailPO existing : existingList) {
if (existing.getBatchDetailId() != null) {
batchDetailIdToMaterialMoreDetailMap.put(existing.getBatchDetailId(), existing);
}
}
}
if (materialBaseInfoId != null && batchDetailMap.containsKey(materialBaseInfoId)) {
List<BatchDetailFeignPO> batchDetailFeignPOList = batchDetailMap.get(materialBaseInfoId);
// 用于跟踪已添加到列表中的batchDetailId
Set<Long> addedBatchDetailIds = new HashSet<>();
for (BatchDetailFeignPO batchDetailFeignPO : batchDetailFeignPOList) {
MaterialMoreDetailPO materialMoreDetailPO = batchDetailIdToMaterialMoreDetailMap.get(batchDetailFeignPO.getBatchDetailId());
// 如果不存在创建新的
if (materialMoreDetailPO == null) {
materialMoreDetailPO = new MaterialMoreDetailPO();
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchDetailId(batchDetailFeignPO.getBatchDetailId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
} else {
// 如果已存在更新属性保留已有的attributeValue
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
}
// 确保添加到列表中使用batchDetailId来避免重复
Long batchDetailId = batchDetailFeignPO.getBatchDetailId();
if (batchDetailId != null && !addedBatchDetailIds.contains(batchDetailId)) {
materialMoreDetailList.add(materialMoreDetailPO);
addedBatchDetailIds.add(batchDetailId);
}
// 根据fieldName或batchLabels从物料明细中获取对应的字段值
if (receiptMaterialDetailPO != null) {
String fieldValue = null;
String usedFieldName = null;
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(receiptMaterialDetailPO, usedFieldName);
log.info("批次属性 batchDetailId={}, fieldName={}, 获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射到字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(receiptMaterialDetailPO, usedFieldName);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
}
}
// 只有当获取到值时才更新attributeValue避免覆盖已有的值
if (fieldValue != null) {
materialMoreDetailPO.setAttributeValue(fieldValue);
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
materialMoreDetailPO.getAttributeValue());
}
}
}
}
receiptMaterialDetailPO.setMaterialMoreDetailList(materialMoreDetailList);
log.info("物料明细 uniqueId={}, materialBaseInfoId={}, materialMoreDetailList大小={}",
receiptMaterialDetailPO.getUniqueId(), receiptMaterialDetailPO.getMaterialBaseInfoId(),
materialMoreDetailList != null ? materialMoreDetailList.size() : 0);
// 递归处理子集
if (!CollectionUtils.isEmpty(receiptMaterialDetailPO.getChildren())) {
setMaterialMoreDetailListRecursively(receiptMaterialDetailPO.getChildren(), batchDetailMap);
}
});
}
/**
* 根据批次标签batchLabels映射到字段名
* @param batchLabel 批次标签
* @return 字段名如果找不到映射则返回null
*/
private String getFieldNameByBatchLabel(String batchLabel) {
if (StringUtils.isBlank(batchLabel)) {
return null;
}
// 批次标签到字段名的映射关系
// 可以根据实际业务需求扩展这个映射表
Map<String, String> labelToFieldNameMap = new HashMap<>();
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("Invoice No", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
labelToFieldNameMap.put("Batch Ref NO's", "batchRefNo");
labelToFieldNameMap.put("Batch Ref NO", "batchRefNo");
labelToFieldNameMap.put("批次参考号", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("Sheet Ref NO", "sheetRefNo");
labelToFieldNameMap.put("单据参考号", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("箱号", "boxPalletNo");
labelToFieldNameMap.put("卡板号", "boxPalletNo");
labelToFieldNameMap.put("申报数量", "declaredQuantity");
labelToFieldNameMap.put("申报单位", "declarationUnit");
labelToFieldNameMap.put("原产国", "originCountry");
labelToFieldNameMap.put("币制", "currency");
labelToFieldNameMap.put("单位", "unit");
labelToFieldNameMap.put("", "liter");
labelToFieldNameMap.put("尺寸", "dimensions");
labelToFieldNameMap.put("箱数", "boxCount");
labelToFieldNameMap.put("件数", "pieceCount");
labelToFieldNameMap.put("入库数量", "inboundQuantity");
labelToFieldNameMap.put("总净重", "totalNetWeight");
labelToFieldNameMap.put("总毛重", "totalGrossWeight");
labelToFieldNameMap.put("总体积", "totalVolume");
labelToFieldNameMap.put("总面积", "totalArea");
labelToFieldNameMap.put("总价", "totalPrice");
// 精确匹配
String fieldName = labelToFieldNameMap.get(batchLabel.trim());
if (StringUtils.isNotBlank(fieldName)) {
return fieldName;
}
// 模糊匹配包含关系
for (Map.Entry<String, String> entry : labelToFieldNameMap.entrySet()) {
if (batchLabel.contains(entry.getKey()) || entry.getKey().contains(batchLabel)) {
return entry.getValue();
}
}
// 如果找不到映射尝试将批次标签转换为驼峰命名简单处理
// 例如"Invoice No." -> "invoiceNo"
return convertLabelToFieldName(batchLabel);
}
/**
* 将批次标签转换为字段名驼峰命名
* @param label 批次标签
* @return 字段名
*/
private String convertLabelToFieldName(String label) {
if (StringUtils.isBlank(label)) {
return null;
}
// 移除特殊字符转换为小写用空格或特殊字符分割
String cleaned = label.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5\\s]", " ")
.trim()
.toLowerCase();
// 如果是中文无法自动转换返回null
if (cleaned.matches(".*[\\u4e00-\\u9fa5].*")) {
return null;
}
// 将空格分割的单词转换为驼峰命名
String[] words = cleaned.split("\\s+");
if (words.length == 0) {
return null;
}
StringBuilder fieldName = new StringBuilder(words[0]);
for (int i = 1; i < words.length; i++) {
if (words[i].length() > 0) {
fieldName.append(words[i].substring(0, 1).toUpperCase())
.append(words[i].substring(1));
}
}
return fieldName.toString();
}
/**
* 根据字段名从对象中获取字段值使用反射
* @param obj 对象
* @param fieldName 字段名
* @return 字段值转换为字符串
*/
private String getFieldValueByFieldName(Object obj, String fieldName) {
if (obj == null || StringUtils.isBlank(fieldName)) {
return null;
}
try {
// 兼容如果传的是下划线命名数据库列名风格先转成驼峰字段名再取
// 例如box_pallet_no -> boxPalletNo
String normalizedFieldName = fieldName;
if (normalizedFieldName.contains("_")) {
normalizedFieldName = snakeToCamel(normalizedFieldName);
}
// 获取对象的Class
Class<?> clazz = obj.getClass();
// 尝试获取字段包括父类字段
Field field = null;
Class<?> currentClass = clazz;
while (currentClass != null && field == null) {
try {
field = currentClass.getDeclaredField(normalizedFieldName);
} catch (NoSuchFieldException e) {
currentClass = currentClass.getSuperclass();
}
}
if (field == null) {
log.warn("字段不存在:{}(normalized{}),对象类型:{}", fieldName, normalizedFieldName, clazz.getName());
return null;
}
// 设置可访问
field.setAccessible(true);
// 获取字段值
Object value = field.get(obj);
// 转换为字符串
if (value == null) {
log.info("字段 {} 的值为 null,对象类型:{}", normalizedFieldName, clazz.getName());
return null;
}
String result;
// 处理日期类型字段
if (value instanceof Date) {
result = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, (Date) value);
} else {
result = value.toString();
}
log.info("通过反射获取字段值成功,字段名:{}(原始:{}),值:{},对象类型:{}",
normalizedFieldName, fieldName, result, clazz.getName());
return result;
} catch (Exception e) {
log.warn("通过反射获取字段值失败,字段名:{},对象类型:{},错误:{}", fieldName, obj.getClass().getName(), e.getMessage());
return null;
}
}
private String snakeToCamel(String snake) {
if (StringUtils.isBlank(snake)) {
return null;
}
String s = snake.trim().toLowerCase();
StringBuilder sb = new StringBuilder();
boolean upperNext = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '_') {
upperNext = true;
continue;
}
if (upperNext) {
sb.append(Character.toUpperCase(c));
upperNext = false;
} else {
sb.append(c);
}
}
return sb.toString();
}
/** /**
* 获取收货单详细信息 * 获取收货单详细信息
*/ */
@@ -162,7 +585,21 @@ public class StockReceiptOrderApplicationService {
* @return Boolean * @return Boolean
*/ */
public Boolean taskDistribution(StockReceiptOrderDO stockReceiptOrderDO){ public Boolean taskDistribution(StockReceiptOrderDO stockReceiptOrderDO){
//设置作业人员信息 //获取收货单信息用于获取仓库ID
if (stockReceiptOrderDO.getReceiptOrderIds() != null && stockReceiptOrderDO.getReceiptOrderIds().size() > 0) {
StockReceiptOrderDO queryDO = new StockReceiptOrderDO();
queryDO.setReceiptOrderId(stockReceiptOrderDO.getReceiptOrderIds().get(0));
StockReceiptOrderPO stockReceiptOrderPO = stockReceiptOrderDomainService.getInfo(queryDO.getReceiptOrderId());
if (stockReceiptOrderPO != null && stockReceiptOrderPO.getWarehouseId() != null) {
//查询该仓库绑定的用户ID列表
AjaxResult ajaxResult = systemServiceFeign.queryListCorrelationId(stockReceiptOrderPO.getWarehouseId());
if ("200".equals(String.valueOf(ajaxResult.get("code")))) {
List<Long> warehouseUserIds = JSON.parseArray(JSONUtil.toJsonStr(ajaxResult.get("data")), Long.class);
stockReceiptOrderDO.setWarehouseUserIds(warehouseUserIds);
}
}
}
//设置作业人员信息会验证操作人员是否属于该仓库绑定的用户
operatorsParam(stockReceiptOrderDO); operatorsParam(stockReceiptOrderDO);
return stockReceiptOrderDomainService.taskDistribution(stockReceiptOrderDO); return stockReceiptOrderDomainService.taskDistribution(stockReceiptOrderDO);
} }
@@ -313,6 +750,15 @@ public class StockReceiptOrderApplicationService {
* @param stockReceiptOrderDO * @param stockReceiptOrderDO
*/ */
private void operatorsParam(StockReceiptOrderDO stockReceiptOrderDO){ private void operatorsParam(StockReceiptOrderDO stockReceiptOrderDO){
if (stockReceiptOrderDO.getOperatorsBy() == null) {
throw new ServiceException("操作人员不能为空");
}
//如果指定了仓库绑定的用户列表验证操作人员是否在该列表中
if (stockReceiptOrderDO.getWarehouseUserIds() != null && !stockReceiptOrderDO.getWarehouseUserIds().isEmpty()) {
if (!stockReceiptOrderDO.getWarehouseUserIds().contains(stockReceiptOrderDO.getOperatorsBy())) {
throw new ServiceException("操作人员必须属于当前收货单对应仓库绑定的用户");
}
}
AjaxResult ajaxResult = userServiceFeign.getInfo(stockReceiptOrderDO.getOperatorsBy()); AjaxResult ajaxResult = userServiceFeign.getInfo(stockReceiptOrderDO.getOperatorsBy());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){ if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取作业人员信息失败"); throw new ServiceException("获取作业人员信息失败");
@@ -591,7 +1037,7 @@ public class StockReceiptOrderApplicationService {
*/ */
private void setMaterialMoreDetailInfo(ReceiptMaterialDetailDO receiptMaterialDetailDO){ private void setMaterialMoreDetailInfo(ReceiptMaterialDetailDO receiptMaterialDetailDO){
if(ObjectUtil.isNotNull(receiptMaterialDetailDO.getMaterialStatusCode())){ if(ObjectUtil.isNotNull(receiptMaterialDetailDO.getMaterialStatusCode()) && StringUtils.isNotBlank(receiptMaterialDetailDO.getMaterialStatusCode())){
//翻译物料状态 //翻译物料状态
AjaxResult materialsStatusResult = systemServiceFeign.selectListByDictType(DictCode.MATERIALS_STATUS.getCode()); AjaxResult materialsStatusResult = systemServiceFeign.selectListByDictType(DictCode.MATERIALS_STATUS.getCode());
if (!"200".equals(String.valueOf(materialsStatusResult.get("code")))) { if (!"200".equals(String.valueOf(materialsStatusResult.get("code")))) {
@@ -645,6 +1091,9 @@ public class StockReceiptOrderApplicationService {
* @param stockReceiptOrderDO * @param stockReceiptOrderDO
*/ */
private void setWarehouseInfo(StockReceiptOrderDO stockReceiptOrderDO) { private void setWarehouseInfo(StockReceiptOrderDO stockReceiptOrderDO) {
if (stockReceiptOrderDO.getWarehouseId() == null) {
throw new ServiceException("仓库ID不能为空");
}
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(stockReceiptOrderDO.getWarehouseId()); AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(stockReceiptOrderDO.getWarehouseId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){ if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取仓库信息失败"); throw new ServiceException("获取仓库信息失败");
@@ -741,3 +1190,4 @@ public class StockReceiptOrderApplicationService {
receiptMaterialDetailDO.setDistributeRuleName(materialGoodsRulePO.getRuleName()); receiptMaterialDetailDO.setDistributeRuleName(materialGoodsRulePO.getRuleName());
} }
} }
@@ -3,9 +3,11 @@ package com.mhd.wms.application.service.stockShelfOrder;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.mhd.common.core.constant.SnowFlakeConstants; import com.mhd.common.core.constant.SnowFlakeConstants;
import com.mhd.common.core.domain.po.UserConfigSwitchPo;
import com.mhd.common.core.domain.po.UserPo; import com.mhd.common.core.domain.po.UserPo;
import com.mhd.common.core.exception.ServiceException; import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.utils.IgnoreNullUtil; import com.mhd.common.core.utils.IgnoreNullUtil;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.utils.bean.BeanUtils; import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.core.utils.uuid.IdGenerator; import com.mhd.common.core.utils.uuid.IdGenerator;
import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.core.web.domain.AjaxResult;
@@ -17,6 +19,18 @@ import com.mhd.system.api.domain.StorageLocationFeignPO;
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO; import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil; import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.materialBaseInfo.entity.MaterialBaseInfo;
import com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper;
import com.mhd.wms.domain.materialBaseInfo.repository.po.MaterialBaseInfoPO;
import com.mhd.wms.domain.materialGoodsRule.repository.facade.IMaterialGoodsRuleService;
import com.mhd.wms.domain.materialGoodsRule.repository.po.BatchDetailPO;
import com.mhd.wms.domain.materialGoodsRule.repository.po.BatchPO;
import com.mhd.wms.domain.materialGoodsRule.repository.po.MaterialGoodsRulePO;
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
import com.mhd.system.api.domain.BatchDetailFeignPO;
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
import com.mhd.wms.domain.shelfMaterialDetail.repository.po.ShelfMaterialDetailPO; import com.mhd.wms.domain.shelfMaterialDetail.repository.po.ShelfMaterialDetailPO;
import com.mhd.wms.domain.shelfMaterialDetail.repository.todo.ShelfMaterialDetailDO; import com.mhd.wms.domain.shelfMaterialDetail.repository.todo.ShelfMaterialDetailDO;
import com.mhd.wms.domain.shelfMaterialDetail.service.ShelfMaterialDetailDomainService; import com.mhd.wms.domain.shelfMaterialDetail.service.ShelfMaterialDetailDomainService;
@@ -28,10 +42,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -54,6 +74,13 @@ public class StockShelfOrderApplicationService {
private SystemServiceFeign systemServiceFeign; private SystemServiceFeign systemServiceFeign;
@Autowired @Autowired
private IdGenerator idGenerator; private IdGenerator idGenerator;
@Autowired
private MaterialBaseInfoMapper materialBaseInfoMapper;
@Autowired
private MaterialInventoryMapper materialInventoryMapper;
@Autowired
private IMaterialGoodsRuleService materialGoodsRuleService;
/** /**
@@ -67,8 +94,23 @@ public class StockShelfOrderApplicationService {
if (topOrganizationId != null && topOrganizationId != 1){ if (topOrganizationId != null && topOrganizationId != 1){
stockShelfOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); stockShelfOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
} }
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); try {
stockShelfOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
if (associationWarehouseCacheDO != null) {
if (associationWarehouseCacheDO.getWarehouseId() != null) {
stockShelfOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
}
if (StringUtils.isNotBlank(associationWarehouseCacheDO.getWarehouseCode())) {
stockShelfOrderDO.setWarehouseCode(associationWarehouseCacheDO.getWarehouseCode());
}
if (StringUtils.isNotBlank(associationWarehouseCacheDO.getWarehouseName())) {
stockShelfOrderDO.setWarehouseName(associationWarehouseCacheDO.getWarehouseName());
}
}
} catch (Exception e) {
// 如果获取仓库信息失败记录日志但不影响查询允许查询所有仓库
log.warn("获取用户关联仓库信息失败,将查询所有仓库数据,用户ID:{},错误:{}", loginUser.getUserid(), e.getMessage());
}
} }
return stockShelfOrderDomainService.queryList(stockShelfOrderDO); return stockShelfOrderDomainService.queryList(stockShelfOrderDO);
} }
@@ -101,7 +143,47 @@ public class StockShelfOrderApplicationService {
*/ */
public StockShelfOrderPO getInfo(Long shelfOrderId) public StockShelfOrderPO getInfo(Long shelfOrderId)
{ {
return stockShelfOrderDomainService.getInfo(shelfOrderId); StockShelfOrderPO stockShelfOrderPO = stockShelfOrderDomainService.getInfo(shelfOrderId);
ShelfMaterialDetailDO shelfMaterialDetailDO = new ShelfMaterialDetailDO();
shelfMaterialDetailDO.setShelfOrderNumber(stockShelfOrderPO.getShelfOrderNumber());
List<ShelfMaterialDetailPO> shelfMaterialDetailPOList = shelfMaterialDetailDomainService.queryListChildren(shelfMaterialDetailDO);
// 性能优化批量获取批次属性避免N+1查询问题
// 1. 收集所有唯一的materialBaseInfoId
Set<Long> materialBaseInfoIdSet = shelfMaterialDetailPOList.stream()
.map(ShelfMaterialDetailPO::getMaterialBaseInfoId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 2. 批量查询批次属性使用Map缓存避免重复查询相同的materialBaseInfoId
Map<Long, List<BatchDetailFeignPO>> batchDetailMap = new HashMap<>();
for (Long materialBaseInfoId : materialBaseInfoIdSet) {
try {
AjaxResult ajaxResult = systemServiceFeign.getBatchDetailListByMaterialBaseInfoId(materialBaseInfoId);
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code")))) {
List<BatchDetailFeignPO> batchDetailFeignPOList = JSON.parseArray(
JSONObject.toJSONString(ajaxResult.get("data")), BatchDetailFeignPO.class);
if (!CollectionUtils.isEmpty(batchDetailFeignPOList)) {
// 过滤isDisplay=1的属性
List<BatchDetailFeignPO> filteredList = batchDetailFeignPOList.stream()
.filter(batchDetail -> batchDetail.getIsDisplay() != null && batchDetail.getIsDisplay() == 1)
.collect(Collectors.toList());
batchDetailMap.put(materialBaseInfoId, filteredList);
}
}
} catch (Exception e) {
log.warn("获取物料批次属性失败,物料基础信息ID:{},错误:{}", materialBaseInfoId, e.getMessage());
}
}
// 3. 为每个物料明细设置更多属性从缓存中获取递归处理所有层级
setMaterialMoreDetailListRecursively(shelfMaterialDetailPOList, batchDetailMap);
stockShelfOrderPO.setMaterialDetailList(shelfMaterialDetailPOList);
log.info("返回上架单信息,shelfOrderId={}, materialDetailList大小={}",
stockShelfOrderPO.getShelfOrderId(),
shelfMaterialDetailPOList != null ? shelfMaterialDetailPOList.size() : 0);
return stockShelfOrderPO;
} }
/** /**
@@ -132,6 +214,7 @@ public class StockShelfOrderApplicationService {
* @param stockReceiptOrderDO * @param stockReceiptOrderDO
* @return Boolean * @return Boolean
*/ */
public Boolean upShelf(StockShelfOrderDO stockReceiptOrderDO){ public Boolean upShelf(StockShelfOrderDO stockReceiptOrderDO){
//上架装配参数 //上架装配参数
StockShelfOrderDO assembleStockShelfOrderDO = assembleParamByShelf(stockReceiptOrderDO); StockShelfOrderDO assembleStockShelfOrderDO = assembleParamByShelf(stockReceiptOrderDO);
@@ -168,6 +251,52 @@ public class StockShelfOrderApplicationService {
} }
private MaterialInventory getParam(ShelfMaterialDetailDO shelfMaterialDetailDO, List<String> fieldNames,Long shipperId){
MaterialInventory param = new MaterialInventory();
param.setShipperId(shipperId);
param.setWarehouseId(shelfMaterialDetailDO.getWarehouseId());
param.setMaterialBaseInfoId(shelfMaterialDetailDO.getMaterialBaseInfoId());
param.setStorageSectionId(shelfMaterialDetailDO.getStorageSectionId());
param.setStorageLocationId(shelfMaterialDetailDO.getStorageLocationId());
param.setOrganizationId(shelfMaterialDetailDO.getOrganizationId());
for (String fieldName : fieldNames) {
switch (fieldName) {
case "ext_attr_4":
param.setExtAttr4(shelfMaterialDetailDO.getExtAttr4());
break;
case "ext_attr_3":
param.setExtAttr3(shelfMaterialDetailDO.getExtAttr3());
break;
case "ext_attr_2":
param.setExtAttr2(shelfMaterialDetailDO.getExtAttr2());
break;
case "ext_attr_1":
param.setExtAttr1(shelfMaterialDetailDO.getExtAttr1());
break;
case "box_pallet_no":
param.setBoxPalletNo(shelfMaterialDetailDO.getBoxPalletNo());
break;
case "sheet_ref_no":
param.setSheetRefNo(shelfMaterialDetailDO.getSheetRefNo());
break;
case "batch_ref_no":
param.setBatchRefNo(shelfMaterialDetailDO.getBatchRefNo());
break;
case "inventory_date":
param.setInventoryDate(shelfMaterialDetailDO.getInventoryDate());
break;
case "expiry_date":
param.setExpiryDate(shelfMaterialDetailDO.getExpiryDate());
break;
case "production_date":
param.setProductionDate(shelfMaterialDetailDO.getProductionDate());
break;
}
}
return param;
}
/** /**
* @description 完成上架 * @description 完成上架
* @author ZhouGY * @author ZhouGY
@@ -245,7 +374,7 @@ public class StockShelfOrderApplicationService {
//设置上架信息 //设置上架信息
setStorageLocationInfo(shelfMaterialDetailDO); setStorageLocationInfo(shelfMaterialDetailDO);
//设置容器信息 //设置容器信息
setContainerInfo(shelfMaterialDetailDO); // setContainerInfo(shelfMaterialDetailDO);
//上架后 设置该记录不允许被修改 //上架后 设置该记录不允许被修改
shelfMaterialDetailDO.setAllowModify(2); shelfMaterialDetailDO.setAllowModify(2);
//未上过架 统计到当前收货单作业收货数 //未上过架 统计到当前收货单作业收货数
@@ -267,9 +396,9 @@ public class StockShelfOrderApplicationService {
//设置上架信息 //设置上架信息
setStorageLocationInfo(shelfMaterialDetailDOChild); setStorageLocationInfo(shelfMaterialDetailDOChild);
//设置容器信息 //设置容器信息
setContainerInfo(returnShelfMaterialDetailDOChild); // setContainerInfo(returnShelfMaterialDetailDOChild);
//上架后 设置该记录不允许被修改 //上架后 设置该记录不允许被修改
shelfMaterialDetailDO.setAllowModify(2); returnShelfMaterialDetailDOChild.setAllowModify(2);
returnShelfMaterialDetailDOChild.setMaterialDetailSerialNumberList(shelfMaterialDetailDOChild.getMaterialDetailSerialNumberList()); returnShelfMaterialDetailDOChild.setMaterialDetailSerialNumberList(shelfMaterialDetailDOChild.getMaterialDetailSerialNumberList());
returnShelfMaterialDetailDOChild.setUniqueId(idGenerator.snowflakeId(SnowFlakeConstants.wmsId)); returnShelfMaterialDetailDOChild.setUniqueId(idGenerator.snowflakeId(SnowFlakeConstants.wmsId));
returnShelfMaterialDetailDOChild.setLevel(2); returnShelfMaterialDetailDOChild.setLevel(2);
@@ -281,6 +410,8 @@ public class StockShelfOrderApplicationService {
} }
} }
returnShelfMaterialDetailDOChild.setMaterialDetailSerialNumberList(shelfMaterialDetailDO.getMaterialDetailSerialNumberList()); returnShelfMaterialDetailDOChild.setMaterialDetailSerialNumberList(shelfMaterialDetailDO.getMaterialDetailSerialNumberList());
//设置子项的实际数量等于上架数量
returnShelfMaterialDetailDOChild.setActualQuantity(returnShelfMaterialDetailDOChild.getShelvesQuantity());
returnShelfMaterialDetailDOChildList.add(returnShelfMaterialDetailDOChild); returnShelfMaterialDetailDOChildList.add(returnShelfMaterialDetailDOChild);
actualQuantity = actualQuantity.add(returnShelfMaterialDetailDOChild.getShelvesQuantity()); actualQuantity = actualQuantity.add(returnShelfMaterialDetailDOChild.getShelvesQuantity());
} }
@@ -326,20 +457,47 @@ public class StockShelfOrderApplicationService {
* @param shelfMaterialDetailDO * @param shelfMaterialDetailDO
*/ */
private void setStorageLocationInfo(ShelfMaterialDetailDO shelfMaterialDetailDO){ private void setStorageLocationInfo(ShelfMaterialDetailDO shelfMaterialDetailDO){
if (shelfMaterialDetailDO.getStorageLocationId() == null || shelfMaterialDetailDO.getStorageLocationId() == 0) {
throw new ServiceException("库位ID不能为空或0");
}
AjaxResult storageLocationResult = systemServiceFeign.getStorageLocationInfoByStorageLocationId(shelfMaterialDetailDO.getStorageLocationId()); AjaxResult storageLocationResult = systemServiceFeign.getStorageLocationInfoByStorageLocationId(shelfMaterialDetailDO.getStorageLocationId());
if(!"200".equals(String.valueOf(storageLocationResult.get("code")))){ if (storageLocationResult == null) {
throw new ServiceException("获取上架库位信息失败"); throw new ServiceException("获取上架库位信息失败:返回结果为空");
}
Object codeObj = storageLocationResult.get("code");
if (codeObj == null || !"200".equals(String.valueOf(codeObj))) {
String errorMsg = storageLocationResult.get("msg") != null ? String.valueOf(storageLocationResult.get("msg")) : "未知错误";
throw new ServiceException("获取上架库位信息失败,库位ID" + shelfMaterialDetailDO.getStorageLocationId() + ",错误信息:" + errorMsg);
}
Object dataObj = storageLocationResult.get("data");
if (dataObj == null) {
throw new ServiceException("获取上架库位信息失败:返回数据为空,库位ID:" + shelfMaterialDetailDO.getStorageLocationId());
}
try {
String jsonString = JSONObject.toJSONString(dataObj);
if (jsonString == null || jsonString.trim().isEmpty() || "null".equals(jsonString)) {
throw new ServiceException("获取上架库位信息失败:数据序列化失败,库位ID:" + shelfMaterialDetailDO.getStorageLocationId());
}
StorageLocationFeignPO storageLocationFeignPO = JSON.parseObject(jsonString, StorageLocationFeignPO.class);
if (storageLocationFeignPO == null) {
throw new ServiceException("获取上架库位信息失败:数据解析失败,库位ID:" + shelfMaterialDetailDO.getStorageLocationId());
}
shelfMaterialDetailDO.setWarehouseId(storageLocationFeignPO.getWarehouseId());
shelfMaterialDetailDO.setWarehouseCode(storageLocationFeignPO.getWarehouseCode());
shelfMaterialDetailDO.setWarehouseName(storageLocationFeignPO.getWarehouseName());
shelfMaterialDetailDO.setStorageSectionId(storageLocationFeignPO.getStorageSectionId());
shelfMaterialDetailDO.setStorageCode(storageLocationFeignPO.getStorageCode());
shelfMaterialDetailDO.setStorageName(storageLocationFeignPO.getStorageName());
shelfMaterialDetailDO.setStorageLocationId(storageLocationFeignPO.getStorageLocationId());
shelfMaterialDetailDO.setStorageLocationCode(storageLocationFeignPO.getStorageLocationCode());
shelfMaterialDetailDO.setStorageLocationName(storageLocationFeignPO.getStorageLocationName());
} catch (Exception e) {
log.error("解析库位信息失败,库位ID:{},错误:{}", shelfMaterialDetailDO.getStorageLocationId(), e.getMessage(), e);
if (e instanceof ServiceException) {
throw e;
}
throw new ServiceException("获取上架库位信息失败:数据解析异常,库位ID:" + shelfMaterialDetailDO.getStorageLocationId() + ",错误信息:" + e.getMessage());
} }
StorageLocationFeignPO storageLocationFeignPO = JSON.parseObject(JSONObject.toJSONString(storageLocationResult.get("data")), StorageLocationFeignPO.class);
shelfMaterialDetailDO.setWarehouseId(storageLocationFeignPO.getWarehouseId());
shelfMaterialDetailDO.setWarehouseCode(storageLocationFeignPO.getWarehouseCode());
shelfMaterialDetailDO.setWarehouseName(storageLocationFeignPO.getWarehouseName());
shelfMaterialDetailDO.setStorageSectionId(storageLocationFeignPO.getStorageSectionId());
shelfMaterialDetailDO.setStorageCode(storageLocationFeignPO.getStorageCode());
shelfMaterialDetailDO.setStorageName(storageLocationFeignPO.getStorageName());
shelfMaterialDetailDO.setStorageLocationId(storageLocationFeignPO.getStorageLocationId());
shelfMaterialDetailDO.setStorageLocationCode(storageLocationFeignPO.getStorageLocationCode());
shelfMaterialDetailDO.setStorageLocationName(storageLocationFeignPO.getStorageLocationName());
} }
/** /**
@@ -348,18 +506,18 @@ public class StockShelfOrderApplicationService {
* @date 2024/5/23 14:03 * @date 2024/5/23 14:03
* @param shelfMaterialDetailDO * @param shelfMaterialDetailDO
*/ */
private void setContainerInfo(ShelfMaterialDetailDO shelfMaterialDetailDO){ // private void setContainerInfo(ShelfMaterialDetailDO shelfMaterialDetailDO){
//
//获取容器详情 // //获取容器详情
AjaxResult ajaxResult = systemServiceFeign.getContainerInfoByContainerId(shelfMaterialDetailDO.getContainerId()); // AjaxResult ajaxResult = systemServiceFeign.getContainerInfoByContainerId(shelfMaterialDetailDO.getContainerId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){ // if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取容器信息失败"); // throw new ServiceException("获取容器信息失败");
} // }
ContainerFeignPO containerFeignPO = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContainerFeignPO.class); // ContainerFeignPO containerFeignPO = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContainerFeignPO.class);
shelfMaterialDetailDO.setContainerCode(containerFeignPO.getContainerCode()); // shelfMaterialDetailDO.setContainerCode(containerFeignPO.getContainerCode());
shelfMaterialDetailDO.setContainerType(containerFeignPO.getContainerType()); // shelfMaterialDetailDO.setContainerType(containerFeignPO.getContainerType());
shelfMaterialDetailDO.setContainerTypeName(containerFeignPO.getContainerTypeName()); // shelfMaterialDetailDO.setContainerTypeName(containerFeignPO.getContainerTypeName());
} // }
/** /**
* @description 判断上架数量是否存在超收 * @description 判断上架数量是否存在超收
@@ -378,4 +536,299 @@ public class StockShelfOrderApplicationService {
return 2; return 2;
} }
} }
/**
* 递归为物料明细设置更多属性
* @param shelfMaterialDetailPOList 物料明细列表
* @param batchDetailMap 批次属性Map
*/
private void setMaterialMoreDetailListRecursively(List<ShelfMaterialDetailPO> shelfMaterialDetailPOList,
Map<Long, List<BatchDetailFeignPO>> batchDetailMap) {
if (CollectionUtils.isEmpty(shelfMaterialDetailPOList)) {
return;
}
shelfMaterialDetailPOList.forEach(shelfMaterialDetailPO -> {
Long materialBaseInfoId = shelfMaterialDetailPO.getMaterialBaseInfoId();
// 只保留isDisplay=1的批次属性从batchDetailMap中获取已经过滤过了
// 创建新的materialMoreDetailList只包含isDisplay=1的属性
List<MaterialMoreDetailPO> materialMoreDetailList = new ArrayList<>();
// 创建batchDetailId到MaterialMoreDetailPO的映射用于快速查找已有的属性值
Map<Long, MaterialMoreDetailPO> batchDetailIdToMaterialMoreDetailMap = new HashMap<>();
List<MaterialMoreDetailPO> existingList = shelfMaterialDetailPO.getMaterialMoreDetailList();
if (!CollectionUtils.isEmpty(existingList)) {
for (MaterialMoreDetailPO existing : existingList) {
if (existing.getBatchDetailId() != null) {
batchDetailIdToMaterialMoreDetailMap.put(existing.getBatchDetailId(), existing);
}
}
}
if (materialBaseInfoId != null && batchDetailMap.containsKey(materialBaseInfoId)) {
List<BatchDetailFeignPO> batchDetailFeignPOList = batchDetailMap.get(materialBaseInfoId);
// 用于跟踪已添加到列表中的batchDetailId
Set<Long> addedBatchDetailIds = new HashSet<>();
for (BatchDetailFeignPO batchDetailFeignPO : batchDetailFeignPOList) {
MaterialMoreDetailPO materialMoreDetailPO = batchDetailIdToMaterialMoreDetailMap.get(batchDetailFeignPO.getBatchDetailId());
// 如果不存在创建新的
if (materialMoreDetailPO == null) {
materialMoreDetailPO = new MaterialMoreDetailPO();
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchDetailId(batchDetailFeignPO.getBatchDetailId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
} else {
// 如果已存在更新属性保留已有的attributeValue
materialMoreDetailPO.setBatchId(batchDetailFeignPO.getBatchId());
materialMoreDetailPO.setBatchLabels(batchDetailFeignPO.getBatchLabels());
materialMoreDetailPO.setInputControl(batchDetailFeignPO.getInputControl());
materialMoreDetailPO.setAttributeFormat(batchDetailFeignPO.getAttributeFormat());
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
}
// 确保添加到列表中使用batchDetailId来避免重复
Long batchDetailId = batchDetailFeignPO.getBatchDetailId();
if (batchDetailId != null && !addedBatchDetailIds.contains(batchDetailId)) {
materialMoreDetailList.add(materialMoreDetailPO);
addedBatchDetailIds.add(batchDetailId);
}
// 根据fieldName或batchLabels从物料明细中获取对应的字段值
if (shelfMaterialDetailPO != null) {
String fieldValue = null;
String usedFieldName = null;
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(shelfMaterialDetailPO, usedFieldName);
log.info("批次属性 batchDetailId={}, fieldName={}, 获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射到字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(shelfMaterialDetailPO, usedFieldName);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
}
}
// 只有当获取到值时才更新attributeValue避免覆盖已有的值
if (fieldValue != null) {
materialMoreDetailPO.setAttributeValue(fieldValue);
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
materialMoreDetailPO.getAttributeValue());
}
}
}
}
shelfMaterialDetailPO.setMaterialMoreDetailList(materialMoreDetailList);
log.info("物料明细 uniqueId={}, materialBaseInfoId={}, materialMoreDetailList大小={}",
shelfMaterialDetailPO.getUniqueId(), shelfMaterialDetailPO.getMaterialBaseInfoId(),
materialMoreDetailList != null ? materialMoreDetailList.size() : 0);
// 递归处理子集
if (!CollectionUtils.isEmpty(shelfMaterialDetailPO.getChildren())) {
setMaterialMoreDetailListRecursively(shelfMaterialDetailPO.getChildren(), batchDetailMap);
}
});
}
/**
* 根据批次标签batchLabels映射到字段名
* @param batchLabel 批次标签
* @return 字段名如果找不到映射则返回null
*/
private String getFieldNameByBatchLabel(String batchLabel) {
if (StringUtils.isBlank(batchLabel)) {
return null;
}
// 批次标签到字段名的映射关系
// 可以根据实际业务需求扩展这个映射表
Map<String, String> labelToFieldNameMap = new HashMap<>();
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("Invoice No", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
labelToFieldNameMap.put("Batch Ref NO's", "batchRefNo");
labelToFieldNameMap.put("Batch Ref NO", "batchRefNo");
labelToFieldNameMap.put("批次参考号", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("Sheet Ref NO", "sheetRefNo");
labelToFieldNameMap.put("单据参考号", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("箱号", "boxPalletNo");
labelToFieldNameMap.put("卡板号", "boxPalletNo");
labelToFieldNameMap.put("申报数量", "declaredQuantity");
labelToFieldNameMap.put("申报单位", "declarationUnit");
labelToFieldNameMap.put("原产国", "originCountry");
labelToFieldNameMap.put("币制", "currency");
labelToFieldNameMap.put("单位", "unit");
labelToFieldNameMap.put("", "liter");
labelToFieldNameMap.put("尺寸", "dimensions");
labelToFieldNameMap.put("箱数", "boxCount");
labelToFieldNameMap.put("件数", "pieceCount");
labelToFieldNameMap.put("入库数量", "inboundQuantity");
labelToFieldNameMap.put("总净重", "totalNetWeight");
labelToFieldNameMap.put("总毛重", "totalGrossWeight");
labelToFieldNameMap.put("总体积", "totalVolume");
labelToFieldNameMap.put("总面积", "totalArea");
labelToFieldNameMap.put("总价", "totalPrice");
// 精确匹配
String fieldName = labelToFieldNameMap.get(batchLabel.trim());
if (StringUtils.isNotBlank(fieldName)) {
return fieldName;
}
// 模糊匹配包含关系
for (Map.Entry<String, String> entry : labelToFieldNameMap.entrySet()) {
if (batchLabel.contains(entry.getKey()) || entry.getKey().contains(batchLabel)) {
return entry.getValue();
}
}
// 如果找不到映射尝试将批次标签转换为驼峰命名简单处理
// 例如"Invoice No." -> "invoiceNo"
return convertLabelToFieldName(batchLabel);
}
/**
* 将批次标签转换为字段名驼峰命名
* @param label 批次标签
* @return 字段名
*/
private String convertLabelToFieldName(String label) {
if (StringUtils.isBlank(label)) {
return null;
}
// 移除特殊字符转换为小写用空格或特殊字符分割
String cleaned = label.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5\\s]", " ")
.trim()
.toLowerCase();
// 如果是中文无法自动转换返回null
if (cleaned.matches(".*[\\u4e00-\\u9fa5].*")) {
return null;
}
// 将空格分割的单词转换为驼峰命名
String[] words = cleaned.split("\\s+");
if (words.length == 0) {
return null;
}
StringBuilder fieldName = new StringBuilder(words[0]);
for (int i = 1; i < words.length; i++) {
if (words[i].length() > 0) {
fieldName.append(words[i].substring(0, 1).toUpperCase())
.append(words[i].substring(1));
}
}
return fieldName.toString();
}
/**
* 根据字段名从对象中获取字段值使用反射
* @param obj 对象
* @param fieldName 字段名
* @return 字段值转换为字符串
*/
private String getFieldValueByFieldName(Object obj, String fieldName) {
if (obj == null || StringUtils.isBlank(fieldName)) {
return null;
}
try {
// 兼容如果传的是下划线命名数据库列名风格先转成驼峰字段名再取
// 例如box_pallet_no -> boxPalletNo
String normalizedFieldName = fieldName;
if (normalizedFieldName.contains("_")) {
normalizedFieldName = snakeToCamel(normalizedFieldName);
}
// 获取对象的Class
Class<?> clazz = obj.getClass();
// 尝试获取字段包括父类字段
Field field = null;
Class<?> currentClass = clazz;
while (currentClass != null && field == null) {
try {
field = currentClass.getDeclaredField(normalizedFieldName);
} catch (NoSuchFieldException e) {
currentClass = currentClass.getSuperclass();
}
}
if (field == null) {
log.warn("字段不存在:{}(normalized{}),对象类型:{}", fieldName, normalizedFieldName, clazz.getName());
return null;
}
// 设置可访问
field.setAccessible(true);
// 获取字段值
Object value = field.get(obj);
// 转换为字符串
if (value == null) {
log.info("字段 {} 的值为 null,对象类型:{}", normalizedFieldName, clazz.getName());
return null;
}
String result;
// 处理日期类型字段
if (value instanceof Date) {
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
result = sdf.format((Date) value);
} else {
result = value.toString();
}
log.info("通过反射获取字段值成功,字段名:{}(原始:{}),值:{},对象类型:{}",
normalizedFieldName, fieldName, result, clazz.getName());
return result;
} catch (Exception e) {
log.warn("通过反射获取字段值失败,字段名:{},对象类型:{},错误:{}", fieldName, obj.getClass().getName(), e.getMessage());
return null;
}
}
private String snakeToCamel(String snake) {
if (StringUtils.isBlank(snake)) {
return null;
}
String s = snake.trim().toLowerCase();
StringBuilder sb = new StringBuilder();
boolean upperNext = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '_') {
upperNext = true;
continue;
}
if (upperNext) {
sb.append(Character.toUpperCase(c));
upperNext = false;
} else {
sb.append(c);
}
}
return sb.toString();
}
} }
@@ -1,5 +1,6 @@
package com.mhd.wms.domain.deliveTask.repository.persistence; package com.mhd.wms.domain.deliveTask.repository.persistence;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.common.core.domain.dto.NoticeMessageLoggingDto; import com.mhd.common.core.domain.dto.NoticeMessageLoggingDto;
import com.mhd.common.core.enums.MessageTypeEnum; import com.mhd.common.core.enums.MessageTypeEnum;
@@ -8,17 +9,35 @@ import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils; import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign; import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.application.service.pickingOrder.PickingOrderApplicationService;
import com.mhd.wms.application.service.stockOutOrder.StockOutOrderApplicationService;
import com.mhd.wms.domain.deliveTask.entity.DeliveTask; import com.mhd.wms.domain.deliveTask.entity.DeliveTask;
import com.mhd.wms.domain.deliveTask.repository.facade.IDeliveTaskService; import com.mhd.wms.domain.deliveTask.repository.facade.IDeliveTaskService;
import com.mhd.wms.domain.deliveTask.repository.mapper.DeliveTaskMapper; import com.mhd.wms.domain.deliveTask.repository.mapper.DeliveTaskMapper;
import com.mhd.wms.domain.deliveTask.repository.po.DeliveTaskPO; import com.mhd.wms.domain.deliveTask.repository.po.DeliveTaskPO;
import com.mhd.wms.domain.deliveTask.repository.po.DeliveTaskSumPO; import com.mhd.wms.domain.deliveTask.repository.po.DeliveTaskSumPO;
import com.mhd.wms.domain.deliveTask.repository.todo.DeliveTaskDO; import com.mhd.wms.domain.deliveTask.repository.todo.DeliveTaskDO;
import com.mhd.wms.domain.handoverTaskOrder.entity.HandoverTaskOrder;
import com.mhd.wms.domain.handoverTaskOrder.repository.facade.IHandoverTaskOrderService;
import com.mhd.wms.domain.pickingOrder.repository.facade.IPickingOrderService;
import com.mhd.wms.domain.pickingOrder.repository.po.PickingOrderPO;
import com.mhd.wms.domain.pickingOrder.repository.todo.PickingOrderDO;
import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder;
import com.mhd.wms.domain.stockOutOrder.repository.facade.IStockOutOrderService;
import com.mhd.wms.domain.stockOutOrder.repository.po.StockOutOrderPO;
import com.mhd.wms.domain.stockOutOrder.repository.todo.StockOutOrderDO;
import com.mhd.wms.interfaces.assember.pickingOrder.PickingOrderAssembler;
import com.mhd.wms.interfaces.assember.stockOutOrder.StockOutOrderAssembler;
import com.mhd.wms.interfaces.dto.pickingOrder.PickingOrderDTO;
import com.mhd.wms.interfaces.dto.stockOutOrder.StockOutOrderDTO;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -35,6 +54,26 @@ public class DeliveTaskImpl extends ServiceImpl<DeliveTaskMapper, DeliveTask> im
private DeliveTaskMapper deliveTaskMapper; private DeliveTaskMapper deliveTaskMapper;
@Autowired @Autowired
private SystemServiceFeign systemServiceFeign; private SystemServiceFeign systemServiceFeign;
@Autowired
private IHandoverTaskOrderService handoverTaskOrderService;
@Autowired
private IPickingOrderService pickingOrderService;
@Resource
private PickingOrderAssembler pickingOrderAssembler;
@Lazy
@Autowired
private StockOutOrderApplicationService stockOutOrderApplicationService;
@Resource
private StockOutOrderAssembler stockOutOrderAssembler;
@Autowired
private IStockOutOrderService stockOutOrderService;
/** /**
* 查询下发任务列表 * 查询下发任务列表
*/ */
@@ -55,8 +94,51 @@ public class DeliveTaskImpl extends ServiceImpl<DeliveTaskMapper, DeliveTask> im
}else{ }else{
} }
return deliveTaskMapper.queryListApp(deliveTaskDO); List<DeliveTaskPO> deliveTaskPOS = deliveTaskMapper.queryListApp(deliveTaskDO);
if (deliveTaskDO.getTaskType() == 7){
statistics(deliveTaskPOS);
}
return deliveTaskPOS;
} }
//关联查询物料种类
private void statistics(List<DeliveTaskPO> deliveTaskPOS) {
for (DeliveTaskPO deliveTaskPO : deliveTaskPOS) {
String trackingNumber = deliveTaskPO.getTrackingNumber();
HandoverTaskOrder handoverTaskOrder = handoverTaskOrderService.getOne(new LambdaQueryWrapper<HandoverTaskOrder>()
.eq(HandoverTaskOrder::getTaskNumber, trackingNumber));
String orderNumber = handoverTaskOrder.getOrderNumber();//出库单号
PickingOrderDTO pickingOrderDTO = new PickingOrderDTO();
pickingOrderDTO.setOrderNumber(orderNumber);
PickingOrderDO pickingOrderDO = pickingOrderAssembler.toDO(pickingOrderDTO);
PickingOrderPO pickingOrderPOS = pickingOrderService.queryList(pickingOrderDO).get(0);
if (pickingOrderPOS != null){
Integer materialQuantity = pickingOrderPOS.getMaterialQuantity();//物料种类数
BigDecimal pickingQuantity = pickingOrderPOS.getPickingQuantity();//已拣货数量
deliveTaskPO.setMaterialQuantity(materialQuantity);
deliveTaskPO.setPickingQuantity(pickingQuantity);
}
StockOutOrderDTO stockOutOrderDTO = new StockOutOrderDTO();
stockOutOrderDTO.setOutOrderNumber(orderNumber);
StockOutOrderDO stockOutOrderDO = stockOutOrderAssembler.toDO(stockOutOrderDTO);
StockOutOrderPO checkInfo = null;
try {
checkInfo = stockOutOrderApplicationService.getCheckInfo(stockOutOrderDO);
BigDecimal checkQuantity = checkInfo.getCheckQuantity();//复核数量
deliveTaskPO.setCheckQuantity(checkQuantity);
} catch (Exception e) {
}
StockOutOrder stockOutOrder = stockOutOrderService.getOne(new LambdaQueryWrapper<StockOutOrder>()
.eq(StockOutOrder::getOutOrderNumber, orderNumber));
if (stockOutOrder != null){
deliveTaskPO.setOutOrderNumber(stockOutOrder.getOutOrderNumber());
deliveTaskPO.setOutOrderStatus(stockOutOrder.getStatus());
deliveTaskPO.setShipperName(stockOutOrder.getShipperName());
deliveTaskPO.setCarrier(stockOutOrder.getCarrier());
}
}
}
/** /**
* 新增下发任务 * 新增下发任务
*/ */

Some files were not shown because too many files have changed in this diff Show More