Browse Source

库存事务

master
songguoqiang 7 months ago
parent
commit
2002b971d9
  1. 3
      win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java
  2. 10
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/ItemInLocationController.java
  3. 2
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationCreateReqVO.java
  4. 3
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationRespVO.java
  5. 2
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/ItemOutLocationController.java
  6. 1
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationCreateReqVO.java
  7. 3
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationRespVO.java
  8. 5
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/transaction/vo/TransactionBaseVO.java
  9. 5
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/iteminlocation/ItemInLocationDO.java
  10. 5
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemoutlocation/ItemOutLocationDO.java
  11. 5
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/transaction/TransactionDO.java
  12. 164
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java
  13. 4
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/enums/transaction/TransactionEnum.java
  14. 142
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java
  15. 28
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/iteminlocation/ItemInLocationServiceImpl.java
  16. 28
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemoutlocation/ItemOutLocationServiceImpl.java
  17. 5
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/transaction/TransactionService.java
  18. 220
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/transaction/TransactionServiceImpl.java

3
win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java

@ -160,5 +160,8 @@ public interface ErrorCodeConstants {
ErrorCode ITEM_TYPE_LOCATION_EXIST = new ErrorCode(1_000_020_063, "备件编码库位类型库位编码已存在,不能重复添加"); ErrorCode ITEM_TYPE_LOCATION_EXIST = new ErrorCode(1_000_020_063, "备件编码库位类型库位编码已存在,不能重复添加");
ErrorCode ITEM_NEW_TURN_IN_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_000_020_063, "数据不能为空"); ErrorCode ITEM_NEW_TURN_IN_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_000_020_063, "数据不能为空");
//备件入库记录
ErrorCode LOCATION_EXISTS = new ErrorCode(1_000_020_021, "该库位已与备件绑定不可重复绑定");
} }

10
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/ItemInLocationController.java

@ -51,6 +51,8 @@ public class ItemInLocationController {
@Operation(summary = "创建备件入库记录") @Operation(summary = "创建备件入库记录")
@PreAuthorize("@ss.hasPermission('item:itemInLocation:create')") @PreAuthorize("@ss.hasPermission('item:itemInLocation:create')")
public CommonResult<Long> createItemInLocation(@Valid @RequestBody ItemInLocationCreateReqVO createReqVO) { public CommonResult<Long> createItemInLocation(@Valid @RequestBody ItemInLocationCreateReqVO createReqVO) {
LocationDO byNumber = locationService.getByNumber(createReqVO.getLocationNumber());
createReqVO.setAreaNumber(byNumber.getAreaNumber());
return success(itemInLocationService.createItemInLocation(createReqVO)); return success(itemInLocationService.createItemInLocation(createReqVO));
} }
@ -96,8 +98,8 @@ public class ItemInLocationController {
PageResult<ItemInLocationDO> pageResult = itemInLocationService.getItemInLocationPage(pageVO); PageResult<ItemInLocationDO> pageResult = itemInLocationService.getItemInLocationPage(pageVO);
PageResult<ItemInLocationRespVO> result = ItemInLocationConvert.INSTANCE.convertPage(pageResult); PageResult<ItemInLocationRespVO> result = ItemInLocationConvert.INSTANCE.convertPage(pageResult);
for(ItemInLocationRespVO vo:result.getList()){ for(ItemInLocationRespVO vo:result.getList()){
// ItemDO itemDO = itemService.getByNumber(vo.getItemNumber()); ItemDO itemDO = itemService.getByNumber(vo.getItemNumber());
// vo.setItemName(itemDO.getName()); vo.setItemName(itemDO.getName());
LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber()); LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber());
vo.setLocationName(locationDO.getName()); vo.setLocationName(locationDO.getName());
} }
@ -131,8 +133,8 @@ public class ItemInLocationController {
PageResult<ItemInLocationDO> pageResult = itemInLocationService.getItemInLocationSenior(conditions); PageResult<ItemInLocationDO> pageResult = itemInLocationService.getItemInLocationSenior(conditions);
PageResult<ItemInLocationRespVO> result = ItemInLocationConvert.INSTANCE.convertPage(pageResult); PageResult<ItemInLocationRespVO> result = ItemInLocationConvert.INSTANCE.convertPage(pageResult);
for(ItemInLocationRespVO vo:result.getList()){ for(ItemInLocationRespVO vo:result.getList()){
// ItemDO itemDO = itemService.getByNumber(vo.getItemNumber()); ItemDO itemDO = itemService.getByNumber(vo.getItemNumber());
// vo.setItemName(itemDO.getName()); vo.setItemName(itemDO.getName());
LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber()); LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber());
vo.setLocationName(locationDO.getName()); vo.setLocationName(locationDO.getName());
} }

2
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationCreateReqVO.java

@ -10,5 +10,5 @@ import javax.validation.constraints.*;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class ItemInLocationCreateReqVO extends ItemInLocationBaseVO { public class ItemInLocationCreateReqVO extends ItemInLocationBaseVO {
private String areaNumber;
} }

3
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationRespVO.java

@ -1,5 +1,6 @@
package com.win.module.eam.controller.iteminlocation.vo; package com.win.module.eam.controller.iteminlocation.vo;
import cn.hutool.core.date.DateTime;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -9,6 +10,8 @@ import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class ItemInLocationRespVO extends ItemInLocationBaseVO { public class ItemInLocationRespVO extends ItemInLocationBaseVO {
@Schema(description = "创建时间")
private LocalDateTime createTime;
private String itemName; private String itemName;
private String locationName; private String locationName;

2
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/ItemOutLocationController.java

@ -52,6 +52,8 @@ public class ItemOutLocationController {
@Operation(summary = "创建备件出库记录") @Operation(summary = "创建备件出库记录")
@PreAuthorize("@ss.hasPermission('item:itemOutLocation:create')") @PreAuthorize("@ss.hasPermission('item:itemOutLocation:create')")
public CommonResult<Long> createItemOutLocation(@Valid @RequestBody ItemOutLocationCreateReqVO createReqVO) { public CommonResult<Long> createItemOutLocation(@Valid @RequestBody ItemOutLocationCreateReqVO createReqVO) {
LocationDO byNumber = locationService.getByNumber(createReqVO.getLocationNumber());
createReqVO.setAreaNumber(byNumber.getAreaNumber());
return success(itemOutLocationService.createItemOutLocation(createReqVO)); return success(itemOutLocationService.createItemOutLocation(createReqVO));
} }

1
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationCreateReqVO.java

@ -10,5 +10,6 @@ import javax.validation.constraints.*;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class ItemOutLocationCreateReqVO extends ItemOutLocationBaseVO { public class ItemOutLocationCreateReqVO extends ItemOutLocationBaseVO {
private String areaNumber;
} }

3
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationRespVO.java

@ -11,4 +11,7 @@ import java.time.LocalDateTime;
public class ItemOutLocationRespVO extends ItemOutLocationBaseVO { public class ItemOutLocationRespVO extends ItemOutLocationBaseVO {
private String itemName; private String itemName;
private String locationName; private String locationName;
@Schema(description = "创建时间")
private LocalDateTime createTime;
} }

5
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/transaction/vo/TransactionBaseVO.java

@ -52,7 +52,7 @@ public class TransactionBaseVO {
private String associatedNumber; private String associatedNumber;
@Schema(description = "是否账内账外") @Schema(description = "是否账内账外")
@NotNull(message = "是否账内账外不能为空") //@NotNull(message = "是否账内账外不能为空")
private String isInAccount; private String isInAccount;
/** /**
@ -65,4 +65,7 @@ public class TransactionBaseVO {
@Schema(description = "备注原因") @Schema(description = "备注原因")
private String describes; private String describes;
@Schema(description = "备件类型")
private String type;
} }

5
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/iteminlocation/ItemInLocationDO.java

@ -37,6 +37,11 @@ public class ItemInLocationDO extends BaseDO {
*/ */
private String itemNumber; private String itemNumber;
/**
* 库区
*/
private String areaNumber;
/** /**
* 库位编号 * 库位编号
*/ */

5
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemoutlocation/ItemOutLocationDO.java

@ -36,6 +36,11 @@ public class ItemOutLocationDO extends BaseDO {
*/ */
private String itemNumber; private String itemNumber;
/**
* 库区
*/
private String areaNumber;
/** /**
* 库位编号 * 库位编号
*/ */

5
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/transaction/TransactionDO.java

@ -91,4 +91,9 @@ public class TransactionDO extends BaseDO {
*/ */
private String describes; private String describes;
/**
* 库位类型
*/
private String type;
} }

164
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java

@ -13,6 +13,7 @@ import com.win.module.eam.controller.itemaccounts.vo.ItemAccountsExportReqVO;
import com.win.module.eam.controller.itemaccounts.vo.ItemAccountsPageReqVO; import com.win.module.eam.controller.itemaccounts.vo.ItemAccountsPageReqVO;
import com.win.module.eam.convert.itemaccounts.ItemAccountsConvert; import com.win.module.eam.convert.itemaccounts.ItemAccountsConvert;
import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO;
import com.win.module.eam.enums.itemAccount.ItemAccountStatusEnum;
import com.win.module.eam.enums.transaction.TransactionEnum; import com.win.module.eam.enums.transaction.TransactionEnum;
import com.win.module.eam.enums.transactionType.TransactionTypeEnum; import com.win.module.eam.enums.transactionType.TransactionTypeEnum;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -38,31 +39,127 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
* 更新库存余额数量出库qty是负数 * 更新库存余额数量出库qty是负数
*/ */
default Boolean updateItemAccountsQty(ItemAccountsCreateReqVO param, String transactionType, String InventoryAction) { default Boolean updateItemAccountsQty(ItemAccountsCreateReqVO param, String transactionType, String InventoryAction) {
int result = 0;
BigDecimal qtyNew = param.getQty();//增减数量
if (TransactionTypeEnum.TransactionType_OUT.getCode().equals(transactionType)) {//出库操作
if (TransactionEnum.REQUISITION_OUT.getCode().equals(InventoryAction)) {//领用出库优先账外 账内 新到货
BigDecimal outQty = BigDecimal.ZERO;
BigDecimal inQty = BigDecimal.ZERO;
BigDecimal newQty = BigDecimal.ZERO;
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>(); QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("item_number", param.getItemNumber()); queryWrapper.eq("item_number", param.getItemNumber());
queryWrapper.eq("location_number", param.getLocationNumber()); queryWrapper.eq("location_number", param.getLocationNumber());
queryWrapper.eq("is_in_account", param.getIsInAccount()); List<ItemAccountsDO> itemAccountsDOS = selectList(queryWrapper);//出库
ItemAccountsDO itemAccountsDO = selectOne(queryWrapper); //如果是出库类型库存 例如:+(-2)领用出库优先级账外 账内 新到货
int result;
if (itemAccountsDO == null) {//不存在新增 BigDecimal allByLocation = this.getAllByLocation(param.getLocationNumber());//查询当前所有库存
itemAccountsDO = ItemAccountsConvert.INSTANCE.convert(param); if (allByLocation.compareTo(param.getQty()) < 0) {//所有库存都不足
result = this.insert(itemAccountsDO); //库存不足
throw exception(COUNT_IS_HAVA);
}
//判断账外库存是否足够
ItemAccountsDO outLocation = getByLocationAndType(param.getLocationNumber(), ItemAccountStatusEnum.OUT.getCode());//账外库库存
outQty = outLocation == null ? BigDecimal.ZERO : outLocation.getQty();
if (outQty.compareTo(param.getQty()) < 0) {//账外库不足
ItemAccountsDO inLocation = getByLocationAndType(param.getLocationNumber(), ItemAccountStatusEnum.IN.getCode());//账内库库存
inQty = inLocation == null ? BigDecimal.ZERO : inLocation.getQty();
ItemAccountsDO newLocation = getByLocationAndType(param.getLocationNumber(), ItemAccountStatusEnum.NEW.getCode());//账内库库存
newQty = newLocation == null ? BigDecimal.ZERO : newLocation.getQty();
if (outQty.compareTo(BigDecimal.ZERO) > 0) {//说明账外库存在且数据不为0 需要先把账外库清空
outLocation.setQty(outQty);
result = this.updateById(outLocation);
BigDecimal subtractOutQty = qtyNew.subtract(outQty);//差几个零件
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractOutQty) >= 0) {//账内库存在且大于0足够差额
BigDecimal subtractInQty = inQty.subtract(subtractOutQty);//减去之后的数量
inLocation.setQty(subtractInQty);
result = this.updateById(inLocation);
}
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractOutQty) < 0) {//账内库存在且不足差额
inLocation.setQty(inQty);
result = this.updateById(inLocation);
BigDecimal subtractInQty = subtractOutQty.subtract(inQty);//减去之后的数量
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractInQty) >= 0) {//新到货存在且足够差额
BigDecimal subtractNewQty = newQty.subtract(subtractInQty);//减去之后的数量
newLocation.setQty(subtractNewQty);
result = this.updateById(newLocation);
} else { } else {
//存在只更新数量,获取差异的数量 throw exception(COUNT_IS_HAVA);
BigDecimal qtyNew = param.getQty(); }
//如果是出库类型库存 例如:+(-2) }
if (TransactionTypeEnum.TransactionType_OUT.getCode().equals(transactionType)&& TransactionEnum.REQUISITION_OUT.getCode().equals(InventoryAction)) { if (inQty.compareTo(BigDecimal.ZERO) == 0) {//账内库存不存在
//判断库存是否足够 if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractOutQty) >= 0) {//新到货存在且足够差额
if (itemAccountsDO.getQty().compareTo(param.getQty()) >=0) { BigDecimal subtractNewQty = newQty.subtract(subtractOutQty);//减去之后的数量
qtyNew = BigDecimal.ZERO.subtract(qtyNew); newLocation.setQty(subtractNewQty);
result = this.updateById(newLocation);
} else {
throw exception(COUNT_IS_HAVA);
}
}
} else {//账外库不存在
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(qtyNew) >= 0) {//账内库存在且大于0足够差额
BigDecimal subtractInQty = inQty.subtract(qtyNew);//减去之后的数量
inLocation.setQty(subtractInQty);
result = this.updateById(inLocation);
}
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(qtyNew) < 0) {//账内库存在且不足差额
inLocation.setQty(inQty);
result = this.updateById(inLocation);
BigDecimal subtractInQty = qtyNew.subtract(inQty);//减去之后的数量
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractInQty) >= 0) {//新到货存在且足够差额
BigDecimal subtractNewQty = newQty.subtract(subtractInQty);//减去之后的数量
newLocation.setQty(subtractNewQty);
result = this.updateById(newLocation);
} else {
throw exception(COUNT_IS_HAVA);
}
}
if (inQty.compareTo(BigDecimal.ZERO) == 0) {//账内库存不存在
if (newQty.compareTo(BigDecimal.ZERO) > 0 && newQty.compareTo(qtyNew) >= 0) {//新到货存在且足够差额
BigDecimal subtractNewQty = newQty.subtract(qtyNew);//减去之后的数量
newLocation.setQty(subtractNewQty);
result = this.updateById(newLocation);
} else { } else {
//库存不足
throw exception(COUNT_IS_HAVA); throw exception(COUNT_IS_HAVA);
} }
} }
itemAccountsDO.setQty(itemAccountsDO.getQty().add(qtyNew)); }
} else {//账外库存在且足够
BigDecimal subtractOutQty = outQty.subtract(qtyNew);//减去之后的数量
outLocation.setQty(subtractOutQty);
result = this.updateById(outLocation);
}
} else {//非领用出库
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("item_number", param.getItemNumber());
queryWrapper.eq("location_number", param.getLocationNumber());
queryWrapper.eq("type", param.getType());
ItemAccountsDO itemAccountsDO = selectOne(queryWrapper);
if (itemAccountsDO == null) {
throw exception(COUNT_IS_HAVA);
}
BigDecimal subtractNewQty = itemAccountsDO.getQty().subtract(qtyNew);//减去之后的数量
itemAccountsDO.setQty(subtractNewQty);
result = this.updateById(itemAccountsDO); result = this.updateById(itemAccountsDO);
} }
}
if (TransactionTypeEnum.TransactionType_IN.getCode().equals(transactionType)) {//入库操作
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("item_number", param.getItemNumber());
queryWrapper.eq("location_number", param.getLocationNumber());
queryWrapper.eq("type", param.getType());
ItemAccountsDO itemAccountsDO = selectOne(queryWrapper);//
if (itemAccountsDO == null) {//不存在新增
itemAccountsDO = ItemAccountsConvert.INSTANCE.convert(param);
result = this.insert(itemAccountsDO);
} else {//更新
BigDecimal qty = itemAccountsDO.getQty();
BigDecimal add = qty.add(param.getQty());
itemAccountsDO.setQty(add);
result = updateById(itemAccountsDO);
}
}
return result > 0; return result > 0;
} }
@ -82,7 +179,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
default Long selectCountByItemNumber(String itemNumber) { default Long selectCountByItemNumber(String itemNumber) {
return selectCount(new LambdaQueryWrapperX<ItemAccountsDO>() return selectCount(new LambdaQueryWrapperX<ItemAccountsDO>()
.eqIfPresent(ItemAccountsDO::getItemNumber, itemNumber) .eqIfPresent(ItemAccountsDO::getItemNumber, itemNumber)
.eqIfPresent(ItemAccountsDO::getAvailable,"TRUE")); .eqIfPresent(ItemAccountsDO::getAvailable, "TRUE"));
} }
/** /**
@ -155,4 +252,39 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
.eqIfPresent(ItemAccountsDO::getId, reqVO.getId()) .eqIfPresent(ItemAccountsDO::getId, reqVO.getId())
.orderByDesc(ItemAccountsDO::getId)); .orderByDesc(ItemAccountsDO::getId));
} }
/**
* 根据库位号查询所有库存 新到货 账内 账外
*
* @param locationNumber
* @return
*/
default BigDecimal getAllByLocation(String locationNumber) {
BigDecimal qty = BigDecimal.ZERO;
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("location_number", locationNumber);
queryWrapper.eq("available", "TRUE");
List<ItemAccountsDO> itemDOS = selectList(queryWrapper);
for (ItemAccountsDO en : itemDOS) {
qty = qty.add(en.getQty());
}
return qty;
}
/**
* 根据库位编号以及库位类型查询台账
*
* @param locationNumber
* @param type
* @return
*/
default ItemAccountsDO getByLocationAndType(String locationNumber, String type) {
BigDecimal qty = BigDecimal.ZERO;
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("location_number", locationNumber);
queryWrapper.eq("available", "TRUE");
queryWrapper.eq("type", type);
ItemAccountsDO itemDO = selectOne(queryWrapper);
return itemDO;
}
} }

4
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/enums/transaction/TransactionEnum.java

@ -7,6 +7,10 @@ public enum TransactionEnum {
RETURN_IN("RETURNIN", "归还入库"), RETURN_IN("RETURNIN", "归还入库"),
SERVICE_IN("SERVICEIN", "维修入库"), SERVICE_IN("SERVICEIN", "维修入库"),
ADJUST("ADJUST", "盘点调整"), ADJUST("ADJUST", "盘点调整"),
NEW_IN("NEWIN", "新到货入库"),
IN_IN("ININ", "账内入库"),
NEW_TURN_IN("NEWTURNIN", "新到货转账内入库"),
NEW_TURN_OUT("NEWTURNOUT", "新到货转账内出库"),
; ;
private String code; private String code;

142
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java

@ -8,10 +8,12 @@ import com.win.framework.common.exception.util.ServiceExceptionUtil;
import com.win.framework.common.pojo.CustomConditions; import com.win.framework.common.pojo.CustomConditions;
import com.win.framework.common.pojo.PageResult; import com.win.framework.common.pojo.PageResult;
import com.win.module.eam.controller.itemaccounts.vo.*; import com.win.module.eam.controller.itemaccounts.vo.*;
import com.win.module.eam.controller.transaction.vo.TransactionCreateReqVO;
import com.win.module.eam.convert.itemaccounts.ItemAccountsConvert; import com.win.module.eam.convert.itemaccounts.ItemAccountsConvert;
import com.win.module.eam.dal.dataobject.devicemaintenancejob.DeviceMaintenanceJobMainDO; import com.win.module.eam.dal.dataobject.devicemaintenancejob.DeviceMaintenanceJobMainDO;
import com.win.module.eam.dal.dataobject.item.ItemDO; import com.win.module.eam.dal.dataobject.item.ItemDO;
import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO;
import com.win.module.eam.dal.dataobject.iteminlocation.ItemInLocationDO;
import com.win.module.eam.dal.dataobject.itemlocationreplace.ItemLocationReplaceDO; import com.win.module.eam.dal.dataobject.itemlocationreplace.ItemLocationReplaceDO;
import com.win.module.eam.dal.dataobject.itemnewturnin.ItemNewTurnInDO; import com.win.module.eam.dal.dataobject.itemnewturnin.ItemNewTurnInDO;
import com.win.module.eam.dal.dataobject.location.LocationDO; import com.win.module.eam.dal.dataobject.location.LocationDO;
@ -22,6 +24,8 @@ import com.win.module.eam.dal.mysql.itemnewturnin.ItemNewTurnInMapper;
import com.win.module.eam.dal.mysql.location.LocationMapper; import com.win.module.eam.dal.mysql.location.LocationMapper;
import com.win.module.eam.enums.basic.BooleanTypeEnum; import com.win.module.eam.enums.basic.BooleanTypeEnum;
import com.win.module.eam.enums.itemAccount.ItemAccountStatusEnum; import com.win.module.eam.enums.itemAccount.ItemAccountStatusEnum;
import com.win.module.eam.enums.transaction.TransactionEnum;
import com.win.module.eam.service.transaction.TransactionService;
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.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -35,6 +39,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.win.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static com.win.module.eam.enums.ErrorCodeConstants.*; import static com.win.module.eam.enums.ErrorCodeConstants.*;
import static com.win.module.eam.enums.ErrorCodeConstants.CLASSTYPR_NO_NOMAL; import static com.win.module.eam.enums.ErrorCodeConstants.CLASSTYPR_NO_NOMAL;
@ -62,31 +67,60 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
@Resource @Resource
private ItemNewTurnInMapper itemNewTurnInMapper; private ItemNewTurnInMapper itemNewTurnInMapper;
@Resource
private TransactionService transactionService;
@Override @Override
@Transactional
public Long createItemAccounts(ItemAccountsCreateReqVO createReqVO) { public Long createItemAccounts(ItemAccountsCreateReqVO createReqVO) {
validate(createReqVO.getItemNumber(),createReqVO.getLocationNumber());//校验库位是否被使用
long id = 0; long id = 0;
//校验 List<TransactionCreateReqVO> list = new ArrayList<>();
//账内校验
ItemAccountsDO itemAccountsDO = validateItemAndTypeAndLocation(createReqVO.getItemNumber(), createReqVO.getType(), createReqVO.getLocationNumber()); ItemAccountsDO itemAccountsDO = validateItemAndTypeAndLocation(createReqVO.getItemNumber(), createReqVO.getType(), createReqVO.getLocationNumber());
if(itemAccountsDO!=null){//存在则更新库存 if(itemAccountsDO!=null){//存在则更新库存
ItemAccountsDO updateObj = ItemAccountsConvert.INSTANCE.convert(createReqVO); ItemAccountsDO updateObj = ItemAccountsConvert.INSTANCE.convert(createReqVO);
BigDecimal qty = itemAccountsDO.getQty(); BigDecimal qty = itemAccountsDO.getQty();
BigDecimal add = updateObj.getQty().add(qty); BigDecimal add = updateObj.getQty().add(qty);
updateObj.setQty(add); updateObj.setQty(add);
updateObj.setId(itemAccountsDO.getId()); // updateObj.setId(itemAccountsDO.getId());
itemAccountsMapper.updateById(updateObj); // itemAccountsMapper.updateById(updateObj);
id = updateObj.getId(); // id = updateObj.getId();
}else{ }else{
// 插入 // 插入
ItemAccountsDO itemAccounts = ItemAccountsConvert.INSTANCE.convert(createReqVO); //ItemAccountsDO itemAccounts = ItemAccountsConvert.INSTANCE.convert(createReqVO);
itemAccountsMapper.insert(itemAccounts); //itemAccountsMapper.insert(itemAccounts);
id = itemAccounts.getId(); //id = itemAccounts.getId();
} }
//添加库存事务
TransactionCreateReqVO transactionCreateReqVO = new TransactionCreateReqVO();
transactionCreateReqVO.setItemNumber(createReqVO.getItemNumber());
transactionCreateReqVO.setLocationNumber(createReqVO.getLocationNumber());
transactionCreateReqVO.setAreaNumber(createReqVO.getAreaNumber());
transactionCreateReqVO.setTransactionType("IN");
transactionCreateReqVO.setQty(createReqVO.getQty());
transactionCreateReqVO.setOperator(null);
transactionCreateReqVO.setCreator(getLoginUserId().toString());
transactionCreateReqVO.setAssociatedNumber(String.valueOf(id));
if(createReqVO.getType().equals(ItemAccountStatusEnum.NEW.getCode())){//新到货
transactionCreateReqVO.setInventoryAction(TransactionEnum.NEW_IN.getCode());
transactionCreateReqVO.setDescribes("备件新到货入库");//描述
}
if(createReqVO.getType().equals(ItemAccountStatusEnum.IN.getCode())){//账内
transactionCreateReqVO.setInventoryAction(TransactionEnum.IN_IN.getCode());
transactionCreateReqVO.setDescribes("备件账内入库");//描述
}
transactionCreateReqVO.setType(createReqVO.getType());
list.add(transactionCreateReqVO);
transactionService.create(list);
return id; return id;
} }
@Override @Override
@Transactional
public Long createIn(ItemAccountsCreateReqVO createReqVO) { public Long createIn(ItemAccountsCreateReqVO createReqVO) {
long id = 0; long id = 0;
//校验 //校验
@ -117,6 +151,7 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
if(itemAccountsDO==null){// if(itemAccountsDO==null){//
throw exception(ITEM_TYPE_LOCATION_EXIST);//新到货数据不存在 throw exception(ITEM_TYPE_LOCATION_EXIST);//新到货数据不存在
} }
List<TransactionCreateReqVO> list = new ArrayList<>();
ItemNewTurnInDO itemNewTurnInDO = new ItemNewTurnInDO();//变更记录 ItemNewTurnInDO itemNewTurnInDO = new ItemNewTurnInDO();//变更记录
newqty = createReqVO.getQty(); newqty = createReqVO.getQty();
//查询有无账内库存 //查询有无账内库存
@ -127,16 +162,15 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
queryWrapper.eq("available","TRUE"); queryWrapper.eq("available","TRUE");
List<ItemAccountsDO> itemAccountsDOS = itemAccountsMapper.selectList(queryWrapper); List<ItemAccountsDO> itemAccountsDOS = itemAccountsMapper.selectList(queryWrapper);
if(!itemAccountsDOS.isEmpty()){//有数据更新 if(!itemAccountsDOS.isEmpty()){//有数据更新
//往账内添加库存 //往账内添加库存
BigDecimal qty = itemAccountsDOS.get(0).getQty(); BigDecimal qty = itemAccountsDOS.get(0).getQty();
BigDecimal add = newqty.add(qty); BigDecimal add = newqty.add(qty);
ItemAccountsDO itemAccountsDO1 = new ItemAccountsDO(); //ItemAccountsDO itemAccountsDO1 = new ItemAccountsDO();
itemAccountsDO1.setId(itemAccountsDOS.get(0).getId()); //itemAccountsDO1.setId(itemAccountsDOS.get(0).getId());
itemAccountsDO1.setQty(add); //itemAccountsDO1.setQty(add);
int i = itemAccountsMapper.updateById(itemAccountsDO1); //int i = itemAccountsMapper.updateById(itemAccountsDO1);
//记录新到货转账内 //记录新到货转账内
id = itemAccountsDO1.getId(); //id = itemAccountsDO1.getId();
itemNewTurnInDO.setType("3"); itemNewTurnInDO.setType("3");
itemNewTurnInDO.setItemNumber(createReqVO.getItemNumber()); itemNewTurnInDO.setItemNumber(createReqVO.getItemNumber());
itemNewTurnInDO.setAreaNumber(createReqVO.getAreaNumber()); itemNewTurnInDO.setAreaNumber(createReqVO.getAreaNumber());
@ -144,12 +178,27 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
itemNewTurnInDO.setNewQty(newqty); itemNewTurnInDO.setNewQty(newqty);
itemNewTurnInDO.setInQty(itemAccountsDOS.get(0).getQty()); itemNewTurnInDO.setInQty(itemAccountsDOS.get(0).getQty());
itemNewTurnInDO.setQty(add); itemNewTurnInDO.setQty(add);
//添加库存事务
TransactionCreateReqVO transactionCreateReqVO = new TransactionCreateReqVO();
transactionCreateReqVO.setItemNumber(createReqVO.getItemNumber());
transactionCreateReqVO.setLocationNumber(createReqVO.getLocationNumber());
transactionCreateReqVO.setAreaNumber(createReqVO.getAreaNumber());
transactionCreateReqVO.setTransactionType("IN");
transactionCreateReqVO.setQty(createReqVO.getQty());
transactionCreateReqVO.setDescribes("新到货转账内往账内添加数据");//描述
transactionCreateReqVO.setOperator(null);
transactionCreateReqVO.setCreator(getLoginUserId().toString());
transactionCreateReqVO.setAssociatedNumber(String.valueOf(id));
transactionCreateReqVO.setInventoryAction(TransactionEnum.NEW_TURN_IN.getCode());
transactionCreateReqVO.setType(ItemAccountStatusEnum.IN.getCode());
list.add(transactionCreateReqVO);
}else{//无数据插入 }else{//无数据插入
ItemAccountsDO itemAccounts = ItemAccountsConvert.INSTANCE.convert(createReqVO); ItemAccountsDO itemAccounts = ItemAccountsConvert.INSTANCE.convert(createReqVO);
itemAccounts.setType(ItemAccountStatusEnum.IN.getCode()); itemAccounts.setType(ItemAccountStatusEnum.IN.getCode());
itemAccounts.setId(null); itemAccounts.setId(null);
itemAccountsMapper.insert(itemAccounts); //itemAccountsMapper.insert(itemAccounts);
id = itemAccounts.getId(); //id = itemAccounts.getId();
itemNewTurnInDO.setType("2"); itemNewTurnInDO.setType("2");
itemNewTurnInDO.setItemNumber(itemAccounts.getItemNumber()); itemNewTurnInDO.setItemNumber(itemAccounts.getItemNumber());
itemNewTurnInDO.setAreaNumber(itemAccounts.getAreaNumber()); itemNewTurnInDO.setAreaNumber(itemAccounts.getAreaNumber());
@ -159,19 +208,27 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
} }
//记录表 //记录表
itemNewTurnInMapper.insert(itemNewTurnInDO); itemNewTurnInMapper.insert(itemNewTurnInDO);
//BigDecimal qty = itemAccountsDO.getQty();
//BigDecimal difference = qty.subtract(newqty);
//itemAccountsDO.setQty(difference);
//itemAccountsMapper.updateById(itemAccountsDO);
//更新新到货数量 //更新新到货数量
BigDecimal qty = itemAccountsDO.getQty(); //添加库存事务
// if(qty.compareTo(newqty) == 0){//等于删除 TransactionCreateReqVO transactionCreateReqVO = new TransactionCreateReqVO();
// itemAccountsMapper.deleteById(createReqVO.getId()); transactionCreateReqVO.setItemNumber(createReqVO.getItemNumber());
// }else{//更新数量 transactionCreateReqVO.setLocationNumber(createReqVO.getLocationNumber());
// BigDecimal difference = qty.subtract(newqty); transactionCreateReqVO.setAreaNumber(createReqVO.getAreaNumber());
// itemAccountsDO.setQty(difference); transactionCreateReqVO.setTransactionType("OUT");
// itemAccountsMapper.updateById(itemAccountsDO); transactionCreateReqVO.setQty(createReqVO.getQty());
// } transactionCreateReqVO.setDescribes("新到货转账内出库数量");//描述
BigDecimal difference = qty.subtract(newqty); transactionCreateReqVO.setOperator(null);
itemAccountsDO.setQty(difference); transactionCreateReqVO.setType(ItemAccountStatusEnum.NEW.getCode());
itemAccountsMapper.updateById(itemAccountsDO); transactionCreateReqVO.setCreator(getLoginUserId().toString());
//itemAccountsMapper.deleteById(createReqVO.getId()); transactionCreateReqVO.setAssociatedNumber(String.valueOf(itemAccountsDO.getId()));
transactionCreateReqVO.setInventoryAction(TransactionEnum.NEW_TURN_OUT.getCode());
list.add(transactionCreateReqVO);
transactionService.create(list);
return id; return id;
} }
@ -393,19 +450,11 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
@Override @Override
public BigDecimal getAllByLocation(String locationNumber) { public BigDecimal getAllByLocation(String locationNumber) {
BigDecimal qty = BigDecimal.ZERO; return itemAccountsMapper.getAllByLocation(locationNumber);
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("location_number",locationNumber);
queryWrapper.eq("available","TRUE");
List<ItemAccountsDO> itemDOS = itemAccountsMapper.selectList(queryWrapper);
for(ItemAccountsDO en:itemDOS){
qty = qty.add(en.getQty());
}
return qty;
} }
/** /**
* 新增校验备件编号+类型+库位编码唯一 * 账内校验备件编号+类型+库位编码唯一
*/ */
private ItemAccountsDO validateItemAndTypeAndLocation(String itemNumber,String type,String locationNumber) { private ItemAccountsDO validateItemAndTypeAndLocation(String itemNumber,String type,String locationNumber) {
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>(); QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
@ -416,4 +465,19 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
return itemAccountsMapper.selectOne(queryWrapper); return itemAccountsMapper.selectOne(queryWrapper);
} }
/**
* 备件号和库位号是否存在
*/
private void validate(String itemNumber,String locationNumber) {
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
queryWrapper.ne("item_number",itemNumber);
queryWrapper.eq("location_number",locationNumber);
queryWrapper.eq("available","TRUE");
List<ItemAccountsDO> itemAccountsDOS = itemAccountsMapper.selectList(queryWrapper);
if(!itemAccountsDOS.isEmpty()){
throw exception(LOCATION_EXISTS);
}
}
} }

28
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/iteminlocation/ItemInLocationServiceImpl.java

@ -6,18 +6,25 @@ import com.win.module.eam.controller.iteminlocation.vo.ItemInLocationCreateReqVO
import com.win.module.eam.controller.iteminlocation.vo.ItemInLocationExportReqVO; import com.win.module.eam.controller.iteminlocation.vo.ItemInLocationExportReqVO;
import com.win.module.eam.controller.iteminlocation.vo.ItemInLocationPageReqVO; import com.win.module.eam.controller.iteminlocation.vo.ItemInLocationPageReqVO;
import com.win.module.eam.controller.iteminlocation.vo.ItemInLocationUpdateReqVO; import com.win.module.eam.controller.iteminlocation.vo.ItemInLocationUpdateReqVO;
import com.win.module.eam.controller.transaction.vo.TransactionCreateReqVO;
import com.win.module.eam.convert.iteminlocation.ItemInLocationConvert; import com.win.module.eam.convert.iteminlocation.ItemInLocationConvert;
import com.win.module.eam.dal.dataobject.iteminlocation.ItemInLocationDO; import com.win.module.eam.dal.dataobject.iteminlocation.ItemInLocationDO;
import com.win.module.eam.dal.dataobject.location.LocationDO; import com.win.module.eam.dal.dataobject.location.LocationDO;
import com.win.module.eam.dal.mysql.iteminlocation.ItemInLocationMapper; import com.win.module.eam.dal.mysql.iteminlocation.ItemInLocationMapper;
import com.win.module.eam.enums.itemAccount.ItemAccountStatusEnum;
import com.win.module.eam.enums.transaction.TransactionEnum;
import com.win.module.eam.service.transaction.TransactionService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.win.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static com.win.module.eam.enums.ErrorCodeConstants.ITEM_IN_LOCATION_NOT_EXISTS; import static com.win.module.eam.enums.ErrorCodeConstants.ITEM_IN_LOCATION_NOT_EXISTS;
/** /**
@ -32,11 +39,32 @@ public class ItemInLocationServiceImpl implements ItemInLocationService {
@Resource @Resource
private ItemInLocationMapper itemInLocationMapper; private ItemInLocationMapper itemInLocationMapper;
@Resource
private TransactionService transactionService;
@Override @Override
@Transactional
public Long createItemInLocation(ItemInLocationCreateReqVO createReqVO) { public Long createItemInLocation(ItemInLocationCreateReqVO createReqVO) {
// 插入 // 插入
ItemInLocationDO itemInLocation = ItemInLocationConvert.INSTANCE.convert(createReqVO); ItemInLocationDO itemInLocation = ItemInLocationConvert.INSTANCE.convert(createReqVO);
itemInLocation.setType(TransactionEnum.RETURN_IN.getCode());
itemInLocationMapper.insert(itemInLocation); itemInLocationMapper.insert(itemInLocation);
List<TransactionCreateReqVO> list = new ArrayList<>();
//添加库存事务
TransactionCreateReqVO transactionCreateReqVO = new TransactionCreateReqVO();
transactionCreateReqVO.setItemNumber(createReqVO.getItemNumber());
transactionCreateReqVO.setLocationNumber(createReqVO.getLocationNumber());
transactionCreateReqVO.setAreaNumber(createReqVO.getAreaNumber());
transactionCreateReqVO.setTransactionType("IN");
transactionCreateReqVO.setQty(createReqVO.getQty());
transactionCreateReqVO.setDescribes("备件归还");//描述
transactionCreateReqVO.setOperator(createReqVO.getReturner());
transactionCreateReqVO.setCreator(getLoginUserId().toString());
transactionCreateReqVO.setAssociatedNumber(null);
transactionCreateReqVO.setInventoryAction(TransactionEnum.RETURN_IN.getCode());
transactionCreateReqVO.setType(ItemAccountStatusEnum.OUT.getCode());
list.add(transactionCreateReqVO);
transactionService.create(list);
// 返回 // 返回
return itemInLocation.getId(); return itemInLocation.getId();
} }

28
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemoutlocation/ItemOutLocationServiceImpl.java

@ -6,18 +6,25 @@ import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationCreateReq
import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationExportReqVO; import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationExportReqVO;
import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationPageReqVO; import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationPageReqVO;
import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationUpdateReqVO; import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationUpdateReqVO;
import com.win.module.eam.controller.transaction.vo.TransactionCreateReqVO;
import com.win.module.eam.convert.itemoutlocation.ItemOutLocationConvert; import com.win.module.eam.convert.itemoutlocation.ItemOutLocationConvert;
import com.win.module.eam.dal.dataobject.itemoutlocation.ItemOutLocationDO; import com.win.module.eam.dal.dataobject.itemoutlocation.ItemOutLocationDO;
import com.win.module.eam.dal.dataobject.location.LocationDO; import com.win.module.eam.dal.dataobject.location.LocationDO;
import com.win.module.eam.dal.mysql.itemoutlocation.ItemOutLocationMapper; import com.win.module.eam.dal.mysql.itemoutlocation.ItemOutLocationMapper;
import com.win.module.eam.enums.itemAccount.ItemAccountStatusEnum;
import com.win.module.eam.enums.transaction.TransactionEnum;
import com.win.module.eam.service.transaction.TransactionService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.win.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static com.win.module.eam.enums.ErrorCodeConstants.ITEM_OUT_LOCATION_NOT_EXISTS; import static com.win.module.eam.enums.ErrorCodeConstants.ITEM_OUT_LOCATION_NOT_EXISTS;
/** /**
@ -32,11 +39,32 @@ public class ItemOutLocationServiceImpl implements ItemOutLocationService {
@Resource @Resource
private ItemOutLocationMapper itemOutLocationMapper; private ItemOutLocationMapper itemOutLocationMapper;
@Resource
private TransactionService transactionService;
@Override @Override
@Transactional
public Long createItemOutLocation(ItemOutLocationCreateReqVO createReqVO) { public Long createItemOutLocation(ItemOutLocationCreateReqVO createReqVO) {
// 插入 // 插入
ItemOutLocationDO itemOutLocation = ItemOutLocationConvert.INSTANCE.convert(createReqVO); ItemOutLocationDO itemOutLocation = ItemOutLocationConvert.INSTANCE.convert(createReqVO);
itemOutLocation.setType(TransactionEnum.REQUISITION_OUT.getCode());
itemOutLocationMapper.insert(itemOutLocation); itemOutLocationMapper.insert(itemOutLocation);
List<TransactionCreateReqVO> list = new ArrayList<>();
//添加库存事务
TransactionCreateReqVO transactionCreateReqVO = new TransactionCreateReqVO();
transactionCreateReqVO.setItemNumber(createReqVO.getItemNumber());
transactionCreateReqVO.setLocationNumber(createReqVO.getLocationNumber());
transactionCreateReqVO.setAreaNumber(createReqVO.getAreaNumber());
transactionCreateReqVO.setTransactionType("OUT");
transactionCreateReqVO.setQty(createReqVO.getQty());
transactionCreateReqVO.setDescribes("备件出库");//描述
transactionCreateReqVO.setOperator(createReqVO.getReceiver());
transactionCreateReqVO.setCreator(getLoginUserId().toString());
transactionCreateReqVO.setAssociatedNumber(null);
transactionCreateReqVO.setInventoryAction(TransactionEnum.REQUISITION_OUT.getCode());
transactionCreateReqVO.setType(ItemAccountStatusEnum.IN.getCode());
list.add(transactionCreateReqVO);
transactionService.create(list);
// 返回 // 返回
return itemOutLocation.getId(); return itemOutLocation.getId();
} }

5
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/transaction/TransactionService.java

@ -81,10 +81,5 @@ public interface TransactionService {
*/ */
PageResult<TransactionDO> getTransactionSenior(CustomConditions conditions); PageResult<TransactionDO> getTransactionSenior(CustomConditions conditions);
/**
* 备件出库操作时需要判断重采购点是否需要给oa发消息低于重采购点发消息
* @param number
*/
void SendOa(String number);
} }

220
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/transaction/TransactionServiceImpl.java

@ -61,86 +61,6 @@ public class TransactionServiceImpl implements TransactionService {
@Transactional @Transactional
public Integer create(List<TransactionCreateReqVO> createReqVOList) { public Integer create(List<TransactionCreateReqVO> createReqVOList) {
int result = 0; int result = 0;
int line = 0;
//如果是采购入库,领用出库,盘点调整,需要调用QAD更新数据
//领用出库
List<TedIssunpMstr> issunpMstr = new ArrayList<>();
List<TedIssunpDet> issunpDet = new ArrayList<>();
//盘点调整
List<TedRctunpMstr> rctunpMstr = new ArrayList<>();
List<TedRctunpDet> rctunpDet = new ArrayList<>();
//采购入库
List<TedReceiptMstr> receiptMstr = new ArrayList<>();
List<TedReceiptDet> receiptDet = new ArrayList<>();
JsonTask jsonTask = new JsonTask();
//填充QAD所需的主表数据以及其他数据
//每次调用接口都是相同库存动作
//TransactionEnum.REQUISITION_OUT 领用出库·
if (TransactionEnum.REQUISITION_OUT.getCode().equals(createReqVOList.get(0).getInventoryAction())) {//任务
jsonTask = this.sendJsonTask("TED_RECEIPT_MSTR", createReqVOList.size());
TedIssunpMstr tedIssunpMstr = new TedIssunpMstr();
tedIssunpMstr.setGUID(UUID.randomUUID());
tedIssunpMstr.setUser("");
tedIssunpMstr.setUnplanedBillNum(null);
tedIssunpMstr.setDate(jsonTask.getCreateTime());
tedIssunpMstr.setTime(jsonTask.getCreateTime());
tedIssunpMstr.setUID(0);
tedIssunpMstr.setCreateUser(jsonTask.getCreateUser());
tedIssunpMstr.setCreateTime(jsonTask.getCreateTime());
tedIssunpMstr.setRemark(null);
tedIssunpMstr.setTaskID(jsonTask.getTaskID());
tedIssunpMstr.setCommandType("A");
tedIssunpMstr.setDomain(jsonTask.getDomain());
tedIssunpMstr.setSite(jsonTask.getSite());
issunpMstr.add(tedIssunpMstr);
}
//TransactionEnum.PURCHASE_IN 采购入库
if (TransactionEnum.PURCHASE_IN.getCode().equals(createReqVOList.get(0).getInventoryAction())) {
jsonTask = this.sendJsonTask("TED_ISSUNP_MSTR", createReqVOList.size());
TedReceiptMstr tedReceiptMstr = new TedReceiptMstr();
tedReceiptMstr.setUser(jsonTask.getCreateUser());// 操作员
tedReceiptMstr.setASN("");// 货运单
tedReceiptMstr.setPurchaseOrder("");// 采购订单
tedReceiptMstr.setSupplier("");// 供应商
tedReceiptMstr.setReceiveNbr("");// 收货单号
tedReceiptMstr.setReceiptDate(jsonTask.getCreateTime());// 收货日期
tedReceiptMstr.setTime(jsonTask.getCreateTime());// 时间
tedReceiptMstr.setGUID(UUID.randomUUID());// UUID(一个新的,不重复行)
tedReceiptMstr.setID(UUID.randomUUID());// UUID(一个新的,不重复行)
tedReceiptMstr.setCreateUser(jsonTask.getCreateUser());// 创建人
tedReceiptMstr.setCreateTime(jsonTask.getCreateTime());// 创建时间
tedReceiptMstr.setRemark(null);// 备注
tedReceiptMstr.setTaskID(jsonTask.getTaskID());// 任务编号
tedReceiptMstr.setCommandType("A");// 命令类型
tedReceiptMstr.setDataID(UUID.randomUUID());//
tedReceiptMstr.setDomain(jsonTask.getDomain());
tedReceiptMstr.setSite(jsonTask.getSite());
receiptMstr.add(tedReceiptMstr);
}
//TransactionEnum.ADJUST 盘点调整
if (TransactionEnum.ADJUST.getCode().equals(createReqVOList.get(0).getInventoryAction())) {
jsonTask = this.sendJsonTask("TED_RCTUNP_MSTR", createReqVOList.size());
TedRctunpMstr tedRctunpMstr = new TedRctunpMstr();
tedRctunpMstr.setUser(jsonTask.getCreateUser());
tedRctunpMstr.setReceiveBillNum(null);
tedRctunpMstr.setDate(jsonTask.getCreateTime());
tedRctunpMstr.setTime(jsonTask.getCreateTime());
tedRctunpMstr.setGUID(UUID.randomUUID());
tedRctunpMstr.setUID(0);
tedRctunpMstr.setCreateUser(jsonTask.getCreateUser());
tedRctunpMstr.setCreateTime(jsonTask.getCreateTime());
tedRctunpMstr.setRemark(null);
tedRctunpMstr.setTaskID(jsonTask.getTaskID());// 任务编号
tedRctunpMstr.setCommandType("A");// 命令类型
tedRctunpMstr.setDataID(UUID.randomUUID());//
tedRctunpMstr.setDomain(jsonTask.getDomain());
tedRctunpMstr.setSite(jsonTask.getSite());
rctunpMstr.add(tedRctunpMstr);
}
for (TransactionCreateReqVO createReqVO : createReqVOList) { for (TransactionCreateReqVO createReqVO : createReqVOList) {
TransactionDO transactionDO = TransactionConvert.INSTANCE.convert(createReqVO); TransactionDO transactionDO = TransactionConvert.INSTANCE.convert(createReqVO);
//生成单据号 //生成单据号
@ -152,137 +72,10 @@ public class TransactionServiceImpl implements TransactionService {
ItemAccountsCreateReqVO itemAccountsCreateReqVO = new ItemAccountsCreateReqVO(); ItemAccountsCreateReqVO itemAccountsCreateReqVO = new ItemAccountsCreateReqVO();
BeanUtils.copyProperties(transactionDO, itemAccountsCreateReqVO); BeanUtils.copyProperties(transactionDO, itemAccountsCreateReqVO);
Boolean b = itemAccountsMapper.updateItemAccountsQty(itemAccountsCreateReqVO, transactionDO.getTransactionType(), transactionDO.getInventoryAction()); Boolean b = itemAccountsMapper.updateItemAccountsQty(itemAccountsCreateReqVO, transactionDO.getTransactionType(), transactionDO.getInventoryAction());
//查询备件的库存是否小于等与重采购点,如果满足条件则给oa推送消息
String inventoryAction = createReqVO.getInventoryAction();
if (b && TransactionEnum.REQUISITION_OUT.getCode().equals(inventoryAction)) {//领用出库需要判断重采购点与安全库存以便于给oa发通知
SendOa(createReqVO.getItemNumber());
}
//填充QAD所需的子表数据
if (BooleanTypeEnum.Y.getCode().equals(createReqVO.getIsInAccount())) {
//TransactionEnum.REQUISITION_OUT 领用出库·
if (TransactionEnum.REQUISITION_OUT.getCode().equals(createReqVO.getInventoryAction())) {
TedIssunpDet tedIssunpDet = new TedIssunpDet();
tedIssunpDet.setDataID(UUID.randomUUID());//(一个新的,不重复行)
tedIssunpDet.setCommandType("A");//命令类型--赋值A
tedIssunpDet.setTaskID(jsonTask.getTaskID());//任务编号
tedIssunpDet.setRemark("");//备注
tedIssunpDet.setCreateTime(jsonTask.getCreateTime());//创建时间
tedIssunpDet.setCreateUser(jsonTask.getCreateUser());// 创建人
tedIssunpDet.setUID(0);//
tedIssunpDet.setGUID(UUID.randomUUID());//UUID(一个新的,不重复行)
tedIssunpDet.setProject("");// 项目
tedIssunpDet.setCcAccount("");// 成本中心
tedIssunpDet.setSubAccount("");// 分账户
tedIssunpDet.setDomain(jsonTask.getDomain());// 域
tedIssunpDet.setCreditAccount("");// 科目
tedIssunpDet.setAddress("");// 地址
tedIssunpDet.setCustomerNbr("");// 客户单
tedIssunpDet.setLine(line++);// 行号
tedIssunpDet.setReference(null);// 参考号
tedIssunpDet.setLot("");// 批号 批次
tedIssunpDet.setLocation(createReqVO.getLocationNumber());// 库位 erp库位
tedIssunpDet.setConversion("");// 转换量
tedIssunpDet.setQuantity(createReqVO.getQty());// 数量
tedIssunpDet.setUm(itemDO.getUom());// 单位
tedIssunpDet.setPartCode(itemDO.getItemNumber());// 物料号
//通过事务的ID 来判断是哪个事务出现问题
tedIssunpDet.setUnplanedBillNum(transactionDO.getAssociatedNumber());// 单号
tedIssunpDet.setRemarks("");// 备注
tedIssunpDet.setSite(jsonTask.getSite());
issunpDet.add(tedIssunpDet);
}
//TransactionEnum.PURCHASE_IN 采购入库
if (TransactionEnum.PURCHASE_IN.getCode().equals(createReqVO.getInventoryAction())) {
TedReceiptDet tedReceiptDet = new TedReceiptDet();
tedReceiptDet.setGUID(UUID.randomUUID());// UUID(一个新的,不重复行)
tedReceiptDet.setASN("");// ASN单号
tedReceiptDet.setPurchaseOrder(transactionDO.getId().toString());// 采购订单
tedReceiptDet.setLine(line++);// 行号
tedReceiptDet.setPartCode(itemDO.getItemNumber());// 物料号
tedReceiptDet.setReceiveNbr(transactionDO.getId().toString());// 收货单号
tedReceiptDet.setReceiveQuantity(createReqVO.getQty());// 收货数量
tedReceiptDet.setLocation(createReqVO.getLocationNumber());// 库位
tedReceiptDet.setUm(itemDO.getUom());// 采购单位
tedReceiptDet.setLogisticsUm("");// 物流单位
tedReceiptDet.setLot("");// 批号
tedReceiptDet.setReference("");// 参考号
tedReceiptDet.setUID(0);//
tedReceiptDet.setSupplierLot("");// 供应商批次
tedReceiptDet.setCreateUser(jsonTask.getCreateUser());// 创建人
tedReceiptDet.setCreateTime(jsonTask.getCreateTime());// 创建时间
tedReceiptDet.setRemark("");// 备注
tedReceiptDet.setTaskID(jsonTask.getTaskID());// 任务编号
tedReceiptDet.setCommandType("A");// 命令类型--赋值A
tedReceiptDet.setDataID(UUID.randomUUID());//
tedReceiptDet.setDomain(jsonTask.getDomain());// 域
tedReceiptDet.setSite(jsonTask.getSite());// 地点
receiptDet.add(tedReceiptDet);
}
//TransactionEnum.ADJUST 盘点调整
if (TransactionEnum.ADJUST.getCode().equals(createReqVO.getInventoryAction())) {
TedRctunpDet tedRctunpDet = new TedRctunpDet();
tedRctunpDet.setDataID(UUID.randomUUID());//
tedRctunpDet.setCommandType("A");// 命令类型
tedRctunpDet.setTaskID(jsonTask.getTaskID());// 任务编号
tedRctunpDet.setRemark("");// 备注
tedRctunpDet.setCreateTime(jsonTask.getCreateTime());// 创建时间
tedRctunpDet.setCreateUser(jsonTask.getCreateUser());// 创建人
tedRctunpDet.setUID(0);//
tedRctunpDet.setGUID(UUID.randomUUID());// UUID(一个新的,不重复行)
tedRctunpDet.setProject("");// 项目
tedRctunpDet.setCcAccount("");// 成本中心
tedRctunpDet.setSubAccount("");// 分账户
tedRctunpDet.setDomain(jsonTask.getDomain());// 域
tedRctunpDet.setCreditAccount("");// 科目
tedRctunpDet.setAddress("");// 地址
tedRctunpDet.setCustomerNbr("");// 客户单
tedRctunpDet.setLine(line++);// 行号
tedRctunpDet.setReference("");// 参考号
tedRctunpDet.setLot("");// 批号
tedRctunpDet.setLocation(createReqVO.getLocationNumber());// 库位
tedRctunpDet.setConversion("");// 转换量
tedRctunpDet.setQuantity(createReqVO.getQty());// 数量
tedRctunpDet.setUm(itemDO.getUom());// 单位
tedRctunpDet.setPartCode(itemDO.getItemNumber());// 物料号
tedRctunpDet.setReceiveBillNum(transactionDO.getAssociatedNumber());// 单号
tedRctunpDet.setRemarks("");// 备注
tedRctunpDet.setSite("");// 地点
rctunpDet.add(tedRctunpDet);
}
}
}
//用事务的关联number来对应qad的主子表单号
if (issunpDet.size() > 0) {
issunpMstr.get(0).setUnplanedBillNum(issunpDet.get(0).getUnplanedBillNum());
// SoapUtil.addJob(issunpMstr, issunpDet, jsonTask);
}
if (rctunpDet.size() > 0) {
rctunpMstr.get(0).setReceiveBillNum(rctunpDet.get(0).getReceiveBillNum());
SoapUtil.addJob(rctunpMstr, rctunpDet, jsonTask);
}
if (receiptDet.size() > 0) {
receiptMstr.get(0).setReceiveNbr(receiptDet.get(0).getReceiveNbr());
// SoapUtil.addJob(receiptMstr, receiptDet, jsonTask);
} }
return result; return result;
} }
public JsonTask sendJsonTask(String tableName, int size) {
JsonTask jsonTask = new JsonTask();
jsonTask.setTaskID(UUID.randomUUID());
jsonTask.setTableName(tableName);
jsonTask.setDataCount(size);
jsonTask.setCreator("EAM");
AdminUserRespDTO user = userApi.getUser(getLoginUserId());
jsonTask.setCreateUser(user.getNickname());
jsonTask.setDomain("FAWAYQCJ"); //--QAD域
jsonTask.setSite("1120"); //-- QAD地点
jsonTask.setCreateTime(LocalDateTime.now());
return jsonTask;
}
@Override @Override
public Integer update(TransactionUpdateReqVO updateReqVO) { public Integer update(TransactionUpdateReqVO updateReqVO) {
// 校验存在 // 校验存在
@ -330,17 +123,4 @@ public class TransactionServiceImpl implements TransactionService {
public PageResult<TransactionDO> getTransactionSenior(CustomConditions conditions) { public PageResult<TransactionDO> getTransactionSenior(CustomConditions conditions) {
return Mapper.selectSenior(conditions); return Mapper.selectSenior(conditions);
} }
@Override
public void SendOa(String number) {
long l = itemAccountsMapper.selectCountByItemNumber(number);
QueryWrapper<ItemDO> query = new QueryWrapper<>();
query.eq("number", number);
query.eq("deleted", 0);
query.eq("available", "TRUE");
List<ItemDO> itemDOS = itemMapper.selectList(query);
if (!itemDOS.isEmpty()) {
ItemDO itemDO = itemDOS.get(0);
}
}
} }

Loading…
Cancel
Save