部门id改为字符串;修改库存推送oms;

This commit is contained in:
王奎兴
2026-04-22 14:41:20 +08:00
parent 3062adeca9
commit 775dfecf9f
43 changed files with 7072 additions and 6 deletions
@@ -0,0 +1,120 @@
package com.mhd.oms.interfaces.facade.inventoryAdjustmentRecord;
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 com.mhd.oms.domain.reservationInventoryAdjustmentRecord.repository.po.ReservationInventoryAdjustmentRecordPO;
import com.mhd.oms.domain.reservationInventoryAdjustmentRecord.repository.todo.ReservationInventoryAdjustmentRecordDO;
import com.mhd.oms.domain.reservationInventoryAdjustmentRecord.repository.todo.ReservationInventoryAdjustmentRecordDTO;
import com.mhd.oms.domain.reservationInventoryAdjustmentRecord.service.ReservationInventoryAdjustmentRecordApplicationService;
import com.mhd.oms.domain.reservationInventoryAdjustmentRecord.service.ReservationInventoryAdjustmentRecordAssembler;
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;
/**
* 库存调整记录
*
* @author gen
* @date 2024-07-17
*/
@RestController
@RequestMapping("/reservationInventoryAdjustmentRecordApi")
public class ReservationInventoryAdjustmentRecordApi extends BaseController {
@Autowired
private ReservationInventoryAdjustmentRecordApplicationService inventoryAdjustmentRecordApplicationService;
@Resource
private ReservationInventoryAdjustmentRecordAssembler inventoryAdjustmentRecordAssembler;
/**
* 分页查询库存调整记录列表
*/
@ApiOperation("查询库存调整记录列表")
@GetMapping("/list")
public TableDataInfo list(ReservationInventoryAdjustmentRecordDTO inventoryAdjustmentRecordDTO)
{
//转换实体
ReservationInventoryAdjustmentRecordDO inventoryAdjustmentRecordDO = inventoryAdjustmentRecordAssembler.toDO(inventoryAdjustmentRecordDTO);
startPage();
List<ReservationInventoryAdjustmentRecordPO> list = inventoryAdjustmentRecordApplicationService.queryList(inventoryAdjustmentRecordDO);
return getDataTable(list);
}
/**
* 编辑库存调整记录
*/
@ApiOperation("编辑库存调整记录")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody ReservationInventoryAdjustmentRecordDTO inventoryAdjustmentRecordDTO)
{
//转换实体
ReservationInventoryAdjustmentRecordDO inventoryAdjustmentRecordDO = inventoryAdjustmentRecordAssembler.toDO(inventoryAdjustmentRecordDTO);
if(inventoryAdjustmentRecordDTO.getInventoryAdjustmentId() != null){
return toAjax(inventoryAdjustmentRecordApplicationService.update(inventoryAdjustmentRecordDO));
} else {
return toAjax(inventoryAdjustmentRecordApplicationService.insert(inventoryAdjustmentRecordDO));
}
}
/**
* 批量删除库存调整记录
*/
@ApiOperation("批量删除库存调整记录")
@DeleteMapping("/deleteByIds/{inventoryAdjustmentIds}")
public AjaxResult delete(@PathVariable Long[] inventoryAdjustmentIds)
{
return toAjax(inventoryAdjustmentRecordApplicationService.delete(inventoryAdjustmentIds));
}
/**
* 获取库存调整记录详细信息
*/
@ApiOperation("获取库存调整记录")
@GetMapping(value = "/getInfo/{inventoryAdjustmentId}")
public AjaxResult getInfo(@PathVariable("inventoryAdjustmentId") Long inventoryAdjustmentId)
{
return AjaxResult.success(inventoryAdjustmentRecordApplicationService.getInfo(inventoryAdjustmentId));
}
/**
* @description:库存调整
* @param inventoryAdjustmentRecordDTO
* @return: com.mhd.common.core.web.domain.AjaxResult
* @author: lianzj
* @time: 2024-07-18 9:28:47
*/
// @ApiOperation("库存调整")
// @PostMapping("/inventoryAdjust")
// public AjaxResult inventoryAdjust(@RequestBody ReservationInventoryAdjustmentRecordDTO inventoryAdjustmentRecordDTO)
// {
// //转换实体
// ReservationInventoryAdjustmentRecordDO inventoryAdjustmentRecordDO = inventoryAdjustmentRecordAssembler.toDO(inventoryAdjustmentRecordDTO);
// return AjaxResult.success(inventoryAdjustmentRecordApplicationService.inventoryAdjust(inventoryAdjustmentRecordDO));
// }
/**
* @description:库存冻结
* @param inventoryAdjustmentRecordDTO
* @return: com.mhd.common.core.web.domain.AjaxResult
* @author: lianzj
* @time: 2024-07-18 14:57:51
*/
// @ApiOperation("库存冻结")
// @PostMapping("/inventoryFrozen")
// public AjaxResult inventoryFrozen(@RequestBody ReservationInventoryAdjustmentRecordDTO inventoryAdjustmentRecordDTO)
// {
// //转换实体
// ReservationInventoryAdjustmentRecordDO inventoryAdjustmentRecordDO = inventoryAdjustmentRecordAssembler.toDO(inventoryAdjustmentRecordDTO);
// return AjaxResult.success(inventoryAdjustmentRecordApplicationService.inventoryFrozenForAll(inventoryAdjustmentRecordDO));
// }
}
@@ -0,0 +1,194 @@
package com.mhd.oms.interfaces.facade.reservationMaterialInventory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mhd.common.core.domain.po.UserPo;
import com.mhd.common.core.utils.StringUtils;
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 com.mhd.oms.domain.reservationMaterialInventory.repository.po.ReservationMaterialInventoryPO;
import com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO;
import com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDTO;
import com.mhd.oms.domain.reservationMaterialInventory.service.ReservationMaterialInventoryApplicationService;
import com.mhd.oms.domain.reservationMaterialInventory.service.ReservationMaterialInventoryAssembler;
import com.mhd.system.api.UserServiceFeign;
import com.mhd.system.api.domain.MaterialInventoryDTO;
import com.mhd.system.api.domain.MaterialInventoryOmsParamDO;
import com.mhd.system.api.domain.MaterialInventoryPO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* 物料库存Api
*
* @author gen
* @date 2024-05-29
*/
@RestController
@RequestMapping("/materialInventoryApi")
@Slf4j
public class ReservationMaterialInventoryApi extends BaseController {
@Autowired
private ReservationMaterialInventoryApplicationService materialInventoryApplicationService;
@Resource
private ReservationMaterialInventoryAssembler materialInventoryAssembler;
@Autowired
private UserServiceFeign userServiceFeign;
/**
* 分页查询物料库存列表
*/
@ApiOperation("查询物料库存列表")
@GetMapping("/list")
public TableDataInfo list(ReservationMaterialInventoryDTO materialInventoryDTO,
@RequestParam(value = "customerName", required = false) String customerName)
{
// 出库分配前端传的是客户名称 customerName,这里通过名称查询货主ID,使用精确匹配(不模糊匹配)
String shipperName = null; // 保存查询到的货主名称
if (StringUtils.isNotBlank(customerName) && materialInventoryDTO.getShipperId() == null) {
try {
AjaxResult ajaxResult = userServiceFeign.getInfoByName(customerName);
if ("200".equals(String.valueOf(ajaxResult.get("code"))) && ajaxResult.get("data") != null) {
UserPo userPo = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
if (userPo != null && userPo.getUserId() != null) {
materialInventoryDTO.setShipperId(userPo.getUserId());
// 获取货主名称:优先使用企业名称,如果没有则使用用户名称
shipperName = StringUtils.isNotBlank(userPo.getShipperEnterpriseName())
? userPo.getShipperEnterpriseName()
: userPo.getUserName();
log.info("根据客户名称查询到货主信息,客户名称:{},货主ID:{},货主名称:{}",
customerName, userPo.getUserId(), shipperName);
}
}
} catch (Exception e) {
log.warn("根据客户名称查询货主ID失败,客户名称:{},错误:{}", customerName, e.getMessage());
}
}
//转换实体
ReservationMaterialInventoryDO materialInventoryDO = materialInventoryAssembler.toDO(materialInventoryDTO);
startPage();
// 使用带批次属性的查询方法,批次属性值从库存表中获取
List<ReservationMaterialInventoryPO> list = materialInventoryApplicationService.queryListWithBatchAttributes(materialInventoryDO);
// 按更新时间倒序排序;update_time 为空的数据放最后
list.sort((o1, o2) -> {
Date t1 = o1.getUpdateTime();
Date t2 = o2.getUpdateTime();
if (t1 == null && t2 == null) return 0;
if (t1 == null) return 1;
if (t2 == null) return -1;
return t2.compareTo(t1); // desc
});
TableDataInfo tableDataInfo = getDataTable(list);
return tableDataInfo;
}
@ApiOperation("查询物料库存列表不分页")
@GetMapping("/listAll")
public TableDataInfo listAll(ReservationMaterialInventoryDTO materialInventoryDTO)
{
//转换实体
ReservationMaterialInventoryDO materialInventoryDO = materialInventoryAssembler.toDO(materialInventoryDTO);
List<ReservationMaterialInventoryPO> list = materialInventoryApplicationService.queryList(materialInventoryDO);
return getDataTable(list);
}
/**
* 编辑物料库存
*/
@ApiOperation("编辑物料库存")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody ReservationMaterialInventoryDTO materialInventoryDTO)
{
//转换实体
ReservationMaterialInventoryDO materialInventoryDO = materialInventoryAssembler.toDOByEdit(materialInventoryDTO);
if(materialInventoryDTO.getMaterialInventoryId() != null){
return toAjax(materialInventoryApplicationService.update(materialInventoryDO));
}else {
// 新增时补齐更新时间(update_time),避免新增数据 update_time 为空
materialInventoryDO.setUpdateTime(new Date());
// update_by/update_by_name 与 create_by/create_by_name 保持一致
materialInventoryDO.setUpdateBy(materialInventoryDO.getCreateBy());
materialInventoryDO.setUpdateByName(materialInventoryDO.getCreateByName());
return toAjax(materialInventoryApplicationService.insert(materialInventoryDO));
}
}
/**
* 批量删除物料库存
*/
@ApiOperation("批量删除物料库存")
@DeleteMapping("/deleteByIds/{materialInventoryIds}")
public AjaxResult delete(@PathVariable Long[] materialInventoryIds)
{
return toAjax(materialInventoryApplicationService.delete(materialInventoryIds));
}
/**
* 获取物料库存详细信息
*/
@ApiOperation("获取物料库存")
@GetMapping(value = "/getInfo/{materialInventoryId}")
public AjaxResult getInfo(@PathVariable("materialInventoryId") Long materialInventoryId)
{
return AjaxResult.success(materialInventoryApplicationService.getInfo(materialInventoryId));
}
/**
* 根据库位Id和物料基础信息Id 获取物料库存详细信息
*/
@ApiOperation("根据库位Id和物料基础信息Id 获取物料库存详细信息")
@GetMapping(value = "/getInventory/{storageLocationId}/{materialBaseInfoId}")
public AjaxResult getInventoryByStorageLocationIdAndMaterialBaseInfoId(@PathVariable("storageLocationId") Long storageLocationId, @PathVariable("materialBaseInfoId") Long materialBaseInfoId)
{
return AjaxResult.success(materialInventoryApplicationService.getInventoryByStorageLocationIdAndMaterialBaseInfoId(storageLocationId, materialBaseInfoId));
}
/**
* 分页库存列表
*/
// @ApiOperation("查询库存列表")
// @GetMapping("/queryList")
// public TableDataInfo queryList(MaterialInventoryQueryListDTO materialInventoryQueryListDTO)
// {
// //转换实体
// MaterialInventoryQueryListDO materialInventoryQueryListDO = materialInventoryAssembler.toDOByQueryList(materialInventoryQueryListDTO);
// startPage();
// List<ReservationMaterialInventoryQueryListPO> list = materialInventoryApplicationService.materialQueryList(materialInventoryQueryListDO);
// return getDataTable(list);
// }
@ApiOperation("查询物料库存数量")
@GetMapping("/sumInventoryQuantity")
public AjaxResult sumInventoryQuantity(ReservationMaterialInventoryDTO materialInventoryDTO)
{
//转换实体
ReservationMaterialInventoryDO materialInventoryDO = materialInventoryAssembler.toDO(materialInventoryDTO);
return AjaxResult.success(materialInventoryApplicationService.sumInventoryQuantity(materialInventoryDO));
}
/**
* 编辑物料库存
*/
@ApiOperation("编辑物料库存")
@PostMapping("/omsEdit")
public AjaxResult omsEdit(@RequestBody MaterialInventoryOmsParamDO materialInventoryOmsParamDO)
{
materialInventoryApplicationService.omsEdit(materialInventoryOmsParamDO);
return AjaxResult.success();
}
}