任务BUG修改
This commit is contained in:
+5
@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -66,6 +67,10 @@ public class MaterialBarCodeFeign extends BaseVOEntity{
|
||||
@Excel(name = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
@Excel(name = "数量")
|
||||
private BigDecimal number;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
+76
-31
@@ -1,5 +1,6 @@
|
||||
package com.mhd.basic.application.service.Lease;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -188,56 +189,98 @@ public class LeaseApplicationService {
|
||||
|
||||
/**
|
||||
* 货主租赁明细
|
||||
* 定时任务:每天凌晨1点执行,计算前一天的货主租赁明细
|
||||
*/
|
||||
@Scheduled(cron = "0 0 1 * * ?")
|
||||
public void shipperLeaseDetails() {
|
||||
log.info("开始执行货主租赁明细定时任务");
|
||||
// 计算前一天的日期,将时间设置为当天的0点0分0秒,只保留日期部分
|
||||
final Date yesterday = DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1));
|
||||
|
||||
LeaseDO leaseDO = new LeaseDO();
|
||||
leaseDO.setTime(new Date());
|
||||
//查询租赁
|
||||
leaseDO.setTime(yesterday);
|
||||
//查询有效期内的租赁
|
||||
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) {//整租
|
||||
|
||||
List<ShipperLeaseDetails> shipperLeaseDetailsList = new ArrayList<>(); //需要保存或更新的数据
|
||||
List<ShipperLeaseDetails> shipperLeaseDetailsToUpdate = new ArrayList<>(); //需要更新的数据
|
||||
|
||||
// 查询已存在的货主租赁明细数据(用于判断是新增还是更新)
|
||||
ShipperLeaseDetailsDO queryDO = new ShipperLeaseDetailsDO();
|
||||
queryDO.setBusinessDate(yesterday);
|
||||
List<ShipperLeaseDetailsPO> existingList = shipperLeaseDetailsService.queryList(queryDO);
|
||||
// 构建已存在数据的Map,key为:业务日期+货主ID+仓库ID+租赁类型
|
||||
Map<String, ShipperLeaseDetailsPO> existingMap = existingList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
item -> buildKey(yesterday, item.getShipperId(), item.getWarehouseId(), item.getLeaseType()),
|
||||
item -> item,
|
||||
(existing, replacement) -> existing // 如果有重复key,保留第一个
|
||||
));
|
||||
|
||||
// 处理整租
|
||||
for (LeasePO en : entireUnit) {
|
||||
String key = buildKey(yesterday, en.getShipperId(), en.getWarehouseId(), en.getLeaseType());
|
||||
ShipperLeaseDetails shipperLeaseDetails = new ShipperLeaseDetails();
|
||||
BeanUtils.copyProperties(en, shipperLeaseDetails);
|
||||
shipperLeaseDetails.setBusinessDate(new Date());
|
||||
shipperLeaseDetailsList.add(shipperLeaseDetails);
|
||||
shipperLeaseDetails.setBusinessDate(yesterday);
|
||||
|
||||
// 如果已存在,则更新;否则新增
|
||||
if (existingMap.containsKey(key)) {
|
||||
ShipperLeaseDetailsPO existing = existingMap.get(key);
|
||||
shipperLeaseDetails.setId(existing.getId());
|
||||
shipperLeaseDetailsToUpdate.add(shipperLeaseDetails);
|
||||
} else {
|
||||
shipperLeaseDetailsList.add(shipperLeaseDetails);
|
||||
}
|
||||
}
|
||||
//当前货主当前仓库,库存查询页面所有面积加起来就是散租面积
|
||||
for (LeasePO ca : casualRental) {//散租
|
||||
|
||||
// 处理散租:从租赁管理页面维护的面积,效期内的散租客户面积之和
|
||||
for (LeasePO ca : casualRental) {
|
||||
String key = buildKey(yesterday, ca.getShipperId(), ca.getWarehouseId(), ca.getLeaseType());
|
||||
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.setBusinessDate(yesterday);
|
||||
// 散租面积直接使用租赁管理页面维护的面积
|
||||
shipperLeaseDetails.setLeaseArea(ca.getLeaseArea());
|
||||
log.info("货主:{},仓库:{},散租面积:{}(来自租赁管理)", ca.getCargoOwnerName(), ca.getWarehouseName(), ca.getLeaseArea());
|
||||
|
||||
// 如果已存在,则更新;否则新增
|
||||
if (existingMap.containsKey(key)) {
|
||||
ShipperLeaseDetailsPO existing = existingMap.get(key);
|
||||
shipperLeaseDetails.setId(existing.getId());
|
||||
shipperLeaseDetailsToUpdate.add(shipperLeaseDetails);
|
||||
} else {
|
||||
shipperLeaseDetailsList.add(shipperLeaseDetails);
|
||||
}
|
||||
shipperLeaseDetails.setLeaseArea(area);
|
||||
shipperLeaseDetailsList.add(shipperLeaseDetails);
|
||||
}
|
||||
// 保存货主租赁明细(新建表)
|
||||
|
||||
// 批量新增货主租赁明细
|
||||
if (shipperLeaseDetailsList.size() > 0) {
|
||||
shipperLeaseDetailsService.saveBatch(shipperLeaseDetailsList);
|
||||
log.info("新增货主租赁明细{}条", shipperLeaseDetailsList.size());
|
||||
}
|
||||
|
||||
// 批量更新货主租赁明细
|
||||
if (shipperLeaseDetailsToUpdate.size() > 0) {
|
||||
shipperLeaseDetailsService.updateBatchById(shipperLeaseDetailsToUpdate);
|
||||
log.info("更新货主租赁明细{}条", shipperLeaseDetailsToUpdate.size());
|
||||
}
|
||||
|
||||
log.info("货主租赁明细定时任务执行完成,业务日期:{}", DateUtil.formatDate(yesterday));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建唯一key:业务日期+货主ID+仓库ID+租赁类型
|
||||
*/
|
||||
private String buildKey(Date businessDate, Long shipperId, Long warehouseId, String leaseType) {
|
||||
String dateStr = DateUtil.formatDate(businessDate);
|
||||
return dateStr + "_" + shipperId + "_" + warehouseId + "_" + leaseType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,9 +290,11 @@ public class LeaseApplicationService {
|
||||
* businessDateEnd 业务结束时间
|
||||
*/
|
||||
public List<WarehouseOccupancyRate> warehouseOccupancyRate(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
|
||||
//仓库id 和 开始结束时间作为查询条件 查数据库 差出来当前仓库所有的
|
||||
//仓库id 和 开始结束时间作为查询条件 查数据库 查出来当前仓库所有的
|
||||
List<ShipperLeaseDetailsPO> shipperLeaseDetailsList = shipperLeaseDetailsService.queryList(shipperLeaseDetailsDO);
|
||||
ShipperLeaseDetailsPO shipperLeaseDetailsPO = shipperLeaseDetailsList.get(0);
|
||||
if (shipperLeaseDetailsList == null || shipperLeaseDetailsList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//按业务日期分组,并按日期排序
|
||||
TreeMap<Date, List<ShipperLeaseDetailsPO>> groupedByDate = shipperLeaseDetailsList.stream().collect(
|
||||
Collectors.groupingBy(
|
||||
|
||||
@@ -10,6 +10,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<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" />
|
||||
|
||||
+8
-2
@@ -2022,6 +2022,10 @@ public class UserApplicationService {
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteByIds(List<Long> ids) {
|
||||
// 检查ids是否为空
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
throw new ServiceException("删除的用户ID列表不能为空");
|
||||
}
|
||||
//获取登录人信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
@@ -2042,8 +2046,10 @@ public class UserApplicationService {
|
||||
userDomainService.updateUser(userDO);
|
||||
}
|
||||
}
|
||||
//同步删除网货的员工信息
|
||||
wlhyDomainService.deleteBatchPlatformUser(ids);
|
||||
//同步删除网货的员工信息(只有当ids不为空时才调用)
|
||||
if (!ids.isEmpty()) {
|
||||
wlhyDomainService.deleteBatchPlatformUser(ids);
|
||||
}
|
||||
return ids.size();
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -609,6 +609,10 @@ public class UserWlhyDomainService {
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean deleteBatchPlatformUser(List<Long> szwlUserIds){
|
||||
// 检查ids是否为空
|
||||
if (szwlUserIds == null || szwlUserIds.isEmpty()) {
|
||||
return true; // 如果列表为空,直接返回成功,避免SQL语法错误
|
||||
}
|
||||
//检查是否开启网货
|
||||
boolean flag = checkSwitch();
|
||||
if(!flag){
|
||||
|
||||
@@ -366,6 +366,10 @@ public class UserAPI extends BaseController {
|
||||
@Log(title = "用户中台管理-删除", description ="批量删除用户",businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/removeByIds/{ids}")
|
||||
public AjaxResult removeByIds(@PathVariable List<Long> ids) {
|
||||
// 检查ids是否为空
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return error("删除的用户ID列表不能为空");
|
||||
}
|
||||
return toAjax(userApplicationService.deleteByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 物料条码信息对象 material_bar_code
|
||||
@@ -66,6 +68,10 @@ public class MaterialBarCodePO extends BaseVOEntity {
|
||||
@Excel(name = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
@Excel(name = "数量")
|
||||
private BigDecimal number;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
+5
@@ -5,6 +5,7 @@ import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -66,6 +67,10 @@ public class MaterialBarCodeDO extends BaseVOEntity {
|
||||
@Excel(name = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
@Excel(name = "数量")
|
||||
private BigDecimal number;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
+72
-1
@@ -116,9 +116,80 @@ public class MaterialBaseInfoDomainService {
|
||||
//获取库存预警
|
||||
List<MaterialInventoryWarningPO> materialInventoryWarningPOList = materialInventoryWarningService.getInfoByMaterialBaseInfoIds(materialBaseInfoId);
|
||||
materialBaseInfoPO.setMaterialInventoryWarningList(materialInventoryWarningPOList);
|
||||
//获取条码信息
|
||||
|
||||
// 条码信息:
|
||||
// 1)优先读取已维护的物料条码表 material_bar_code;
|
||||
// 2)如果没有维护条码,则根据当前物料绑定的包装规格(packId),
|
||||
// 按包装明细的单位(EA/IP/CS/PL/OT 等)生成一份默认的条码信息列表,
|
||||
// 其中条码字段留空,前端可编辑。
|
||||
List<MaterialBarCodePO> materialBarCodePOList = materialBarCodeService.getInfoByMaterialBaseInfoIds(materialBaseInfoId);
|
||||
if ((materialBarCodePOList == null || materialBarCodePOList.isEmpty()) && materialBaseInfoPO.getPackId() != null) {
|
||||
try {
|
||||
materialBarCodePOList = new ArrayList<>();
|
||||
// 常见单位代码;只生成在包装规格中实际存在的单位
|
||||
String[] unitCodes = {"EA", "IP", "CS", "PL", "OT"};
|
||||
for (String unitCode : unitCodes) {
|
||||
AjaxResult packDetailResult = systemServiceFeign.getInfoByPackIdAndUnitCode(materialBaseInfoPO.getPackId(), unitCode);
|
||||
if (!"200".equals(String.valueOf(packDetailResult.get("code")))
|
||||
|| packDetailResult.get("data") == null) {
|
||||
continue;
|
||||
}
|
||||
PackDetailFeignPO packDetailFeignPO = JSON.parseObject(
|
||||
JSONObject.toJSONString(packDetailResult.get("data")),
|
||||
PackDetailFeignPO.class);
|
||||
// 如果包装明细没有维护名称或数量,则不生成对应的条码行
|
||||
if (packDetailFeignPO == null
|
||||
|| packDetailFeignPO.getName() == null
|
||||
|| packDetailFeignPO.getNumber() == null) {
|
||||
continue;
|
||||
}
|
||||
MaterialBarCodePO barCodePO = new MaterialBarCodePO();
|
||||
// 物料、组织信息
|
||||
barCodePO.setMaterialBaseInfoId(materialBaseInfoId);
|
||||
barCodePO.setPackId(materialBaseInfoPO.getPackId());
|
||||
barCodePO.setPackCode(materialBaseInfoPO.getPackCode());
|
||||
barCodePO.setPackName(materialBaseInfoPO.getPackName());
|
||||
// 绑定包装明细(单位代码、名称、数量来自包装规格明细)
|
||||
barCodePO.setPackDetailId(packDetailFeignPO.getPackDetailId());
|
||||
barCodePO.setUnitCode(packDetailFeignPO.getUnitCode());
|
||||
barCodePO.setName(packDetailFeignPO.getName());
|
||||
barCodePO.setNumber(packDetailFeignPO.getNumber());
|
||||
// 条码本身留空,前端允许编辑
|
||||
barCodePO.setBarCode(null);
|
||||
materialBarCodePOList.add(barCodePO);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("根据包装规格生成条码信息失败,物料ID:{},包装ID:{},错误:{}",
|
||||
materialBaseInfoId, materialBaseInfoPO.getPackId(), e.getMessage());
|
||||
}
|
||||
}
|
||||
materialBaseInfoPO.setMaterialBarCodeList(materialBarCodePOList);
|
||||
|
||||
// 从包装规格获取默认显示的包装单位(取第一条包装详情的单位名称),前端只读展示
|
||||
if (materialBaseInfoPO.getPackId() != null) {
|
||||
try {
|
||||
String[] unitCodes = {"EA", "IP", "CS", "PL", "OT"};
|
||||
for (String unitCode : unitCodes) {
|
||||
AjaxResult packDetailResult = systemServiceFeign.getInfoByPackIdAndUnitCode(materialBaseInfoPO.getPackId(), unitCode);
|
||||
if (!"200".equals(String.valueOf(packDetailResult.get("code")))
|
||||
|| packDetailResult.get("data") == null) {
|
||||
continue;
|
||||
}
|
||||
PackDetailFeignPO packDetailFeignPO = JSON.parseObject(
|
||||
JSONObject.toJSONString(packDetailResult.get("data")),
|
||||
PackDetailFeignPO.class);
|
||||
if (packDetailFeignPO != null && packDetailFeignPO.getName() != null) {
|
||||
materialBaseInfoPO.setUnitName(packDetailFeignPO.getName());
|
||||
materialBaseInfoPO.setUnitCode(packDetailFeignPO.getUnitCode());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("获取包装规格单位名称失败,物料ID:{},包装ID:{},错误:{}",
|
||||
materialBaseInfoId, materialBaseInfoPO.getPackId(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return materialBaseInfoPO;
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -5,6 +5,7 @@ import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -65,6 +66,10 @@ public class MaterialBarCodeDTO extends BaseVOEntity {
|
||||
@Excel(name = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
@Excel(name = "数量")
|
||||
private BigDecimal number;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
Reference in New Issue
Block a user