Browse Source

测试提交

master
songguoqiang 6 months ago
parent
commit
b545e94f0c
  1. 4
      win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java
  2. 2
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java
  3. 2
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/ItemInLocationController.java
  4. 4
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationExcelVO.java
  5. 40
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java
  6. 78
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java
  7. 11
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/transaction/TransactionServiceImpl.java

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

@ -130,6 +130,8 @@ public interface ErrorCodeConstants {
ErrorCode ITEM_IS_HAVE= new ErrorCode(1_000_020_045, "该备件已存在!");
ErrorCode ProducePlan_NOT_EXISTS= new ErrorCode(1_000_020_046, "生产计划不存在!");
ErrorCode ITEM_CAN_NOT_DELETE= new ErrorCode(1_000_020_045, "该备件已存在于备件台账,不允许删除!");
ErrorCode LOCATION_COUNTS_EXISTS= new ErrorCode(1_000_020_045, "该库存数不为0,不能更换库位!");
ErrorCode MOLD_ACCOUNT_EXISTS = new ErrorCode(1_000_020_050, "该编号模具已存在!");
ErrorCode FALSE_LOCATION_ACCOUNT_EXISTS = new ErrorCode(1_000_020_051, "该备件有账外库且库存大于0,应该优先出账外库");
ErrorCode OUT_BIG_APPLY = new ErrorCode(1_000_020_052, "出库数量大于申领数量");
@ -163,5 +165,7 @@ public interface ErrorCodeConstants {
//备件入库记录
ErrorCode LOCATION_EXISTS = new ErrorCode(1_000_020_021, "该库位已与备件绑定不可重复绑定");
ErrorCode ITEM_EXISTS = new ErrorCode(1_000_020_021, "该备件已绑定不可重复绑定");
}

2
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java

@ -271,7 +271,7 @@ public class ItemAccountsController {
@GetMapping("/getByItemNumber")
@Operation(summary = "根据备件编码查询库位信息")
// @PreAuthorize("@ss.hasPermission('basic:item:query')")
public CommonResult<ItemAccountsRespVO> scanCodeByNumber(@RequestParam("itemNumber") String itemNumber) {
public CommonResult<ItemAccountsRespVO> getByItemNumber(@RequestParam("itemNumber") String itemNumber) {
ItemAccountsRespVO convert = ItemAccountsConvert.INSTANCE.convert(itemAccountsService.getByItemNumber(itemNumber));
if(convert!=null){
ItemDO itemDO = itemService.getByNumber(itemNumber);

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

@ -121,7 +121,7 @@ public class ItemInLocationController {
LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber());
vo.setLocationName(locationDO.getName());
}
ExcelUtils.write(response, "备件入库记录.xls", "数据", ItemInLocationExcelVO.class, datas);
ExcelUtils.write(response, "备件归还记录.xls", "数据", ItemInLocationExcelVO.class, datas);
}
@GetMapping("/get-import-template")

4
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationExcelVO.java

@ -42,8 +42,8 @@ public class ItemInLocationExcelVO {
@ExcelProperty("数量")
private BigDecimal qty;
@ExcelProperty("领用人")
private String receiver;
@ExcelProperty("归还人")
private String returner;
@ExcelProperty("创建时间")
private LocalDateTime createTime;

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

@ -69,11 +69,11 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
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);
outLocation.setQty(BigDecimal.ZERO);
result = this.updateById(outLocation);
//添加库存事务
TransactionDO transactionDO = new TransactionDO();
transactionDO.setQty(outLocation.getQty());
transactionDO.setQty(outQty);
transactionDO.setType(outLocation.getType());
list.add(transactionDO);
BigDecimal subtractOutQty = qtyNew.subtract(outQty);//差几个零件
@ -83,21 +83,26 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
result = this.updateById(inLocation);
//添加库存事务
TransactionDO transactionDO1 = new TransactionDO();
transactionDO1.setQty(inLocation.getQty());
transactionDO1.setQty(subtractOutQty);
transactionDO1.setType(inLocation.getType());
list.add(transactionDO1);
}
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractOutQty) < 0) {//账内库存在且不足差额
inLocation.setQty(inQty);
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractOutQty) < 0) {//账内库存在且不足差额需要清空账内
inLocation.setQty(BigDecimal.ZERO);
result = this.updateById(inLocation);
//添加库存事务
TransactionDO transactionDO0 = new TransactionDO();
transactionDO0.setQty(inQty);
transactionDO0.setType(inLocation.getType());
list.add(transactionDO0);
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);
//添加库存事务
TransactionDO transactionDO2 = new TransactionDO();
transactionDO2.setQty(newLocation.getQty());
transactionDO2.setQty(subtractInQty);
transactionDO2.setType(newLocation.getType());
list.add(transactionDO2);
} else {
@ -111,7 +116,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
result = this.updateById(newLocation);
//添加库存事务
TransactionDO transactionDO3 = new TransactionDO();
transactionDO3.setQty(newLocation.getQty());
transactionDO3.setQty(subtractOutQty);
transactionDO3.setType(newLocation.getType());
list.add(transactionDO3);
} else {
@ -126,16 +131,16 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
result = this.updateById(inLocation);
//添加库存事务
TransactionDO transactionDO4 = new TransactionDO();
transactionDO4.setQty(inLocation.getQty());
transactionDO4.setQty(qtyNew);
transactionDO4.setType(inLocation.getType());
list.add(transactionDO4);
}
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(qtyNew) < 0) {//账内库存在且不足差额
inLocation.setQty(inQty);
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(qtyNew) < 0) {//账内库存在且不足差额清空
inLocation.setQty(BigDecimal.ZERO);
result = this.updateById(inLocation);
//添加库存事务
TransactionDO transactionDO5 = new TransactionDO();
transactionDO5.setQty(inLocation.getQty());
transactionDO5.setQty(inQty);
transactionDO5.setType(inLocation.getType());
list.add(transactionDO5);
BigDecimal subtractInQty = qtyNew.subtract(inQty);//减去之后的数量
@ -145,7 +150,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
result = this.updateById(newLocation);
//添加库存事务
TransactionDO transactionDO6 = new TransactionDO();
transactionDO6.setQty(newLocation.getQty());
transactionDO6.setQty(subtractInQty);
transactionDO6.setType(newLocation.getType());
list.add(transactionDO6);
} else {
@ -159,7 +164,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
result = this.updateById(newLocation);
//添加库存事务
TransactionDO transactionDO7 = new TransactionDO();
transactionDO7.setQty(newLocation.getQty());
transactionDO7.setQty(qtyNew);
transactionDO7.setType(newLocation.getType());
list.add(transactionDO7);
} else {
@ -173,7 +178,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
result = this.updateById(outLocation);
//添加库存事务
TransactionDO transactionDO8 = new TransactionDO();
transactionDO8.setQty(outLocation.getQty());
transactionDO8.setQty(qtyNew);
transactionDO8.setType(outLocation.getType());
list.add(transactionDO8);
}
@ -189,8 +194,9 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
BigDecimal subtractNewQty = itemAccountsDO.getQty().subtract(qtyNew);//减去之后的数量
itemAccountsDO.setQty(subtractNewQty);
result = this.updateById(itemAccountsDO);
//事务记录
TransactionDO transactionDO = new TransactionDO();
transactionDO.setQty(subtractNewQty);
transactionDO.setQty(qtyNew);
transactionDO.setType(itemAccountsDO.getType());
list.add(transactionDO);
}
@ -204,6 +210,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
if (itemAccountsDO == null) {//不存在新增
itemAccountsDO = ItemAccountsConvert.INSTANCE.convert(param);
result = this.insert(itemAccountsDO);
//库存事务
TransactionDO transactionDO = new TransactionDO();
transactionDO.setQty(itemAccountsDO.getQty());
transactionDO.setType(itemAccountsDO.getType());
@ -212,6 +219,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> {
BigDecimal qty = itemAccountsDO.getQty();
BigDecimal add = qty.add(param.getQty());
itemAccountsDO.setQty(add);
//库存事务
result = updateById(itemAccountsDO);
TransactionDO transactionDO = new TransactionDO();
transactionDO.setQty(itemAccountsDO.getQty());

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

@ -77,6 +77,8 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
validate(createReqVO.getItemNumber(),createReqVO.getLocationNumber());//校验库位是否被使用
long id = 0;
List<TransactionCreateReqVO> list = new ArrayList<>();
validate(createReqVO.getItemNumber(), createReqVO.getLocationNumber());//校验非当前备件,库位相同是否存在存在即提醒
validate1(createReqVO.getItemNumber(), createReqVO.getLocationNumber());//校验当前备件,非库位是否存在存在即提醒
//账内校验
ItemAccountsDO itemAccountsDO = validateItemAndTypeAndLocation(createReqVO.getItemNumber(), createReqVO.getType(), createReqVO.getLocationNumber());
@ -172,7 +174,7 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
//int i = itemAccountsMapper.updateById(itemAccountsDO1);
//记录新到货转账内
//id = itemAccountsDO1.getId();
itemNewTurnInDO.setType("3");
itemNewTurnInDO.setType("2");
itemNewTurnInDO.setItemNumber(createReqVO.getItemNumber());
itemNewTurnInDO.setAreaNumber(createReqVO.getAreaNumber());
itemNewTurnInDO.setLocationNumber(createReqVO.getLocationNumber());
@ -206,6 +208,20 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
itemNewTurnInDO.setLocationNumber(itemAccounts.getLocationNumber());
itemNewTurnInDO.setNewQty(newqty);
itemNewTurnInDO.setQty(newqty);
//添加库存事务
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(null);
transactionCreateReqVO.setInventoryAction(TransactionEnum.NEW_TURN_IN.getCode());
transactionCreateReqVO.setType(ItemAccountStatusEnum.IN.getCode());
list.add(transactionCreateReqVO);
}
//记录表
itemNewTurnInMapper.insert(itemNewTurnInDO);
@ -480,18 +496,26 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
@Transactional
public Integer replaceLocation(ItemAccountsDO accountsDO) {
ItemAccountsDO itemAccountsDO = itemAccountsMapper.selectById(accountsDO.getId());
if(accountsDO.getItemNumber().equals(itemAccountsDO.getItemNumber())){
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("available", BooleanTypeEnum.Y.getCode());
queryWrapper.eq("item_number", accountsDO.getItemNumber());
List<ItemAccountsDO> lists = itemAccountsMapper.selectList(queryWrapper);
if(!lists.isEmpty()){
throw ServiceExceptionUtil.exception(ITEM_IS_HAVE);
}
if(accountsDO.getItemNumber().equals(itemAccountsDO.getItemNumber())){//判断是否更换的为同一个备件
throw ServiceExceptionUtil.exception(LOCATION_CAN_NOT_REPLACE2);
}
//查询新备件在备件台账中是否存在
BigDecimal allByLocation = getAllByLocation(accountsDO.getLocationNumber());
if(allByLocation.compareTo(BigDecimal.ZERO)!=0){//该库位下有库存不能更换
throw ServiceExceptionUtil.exception(LOCATION_COUNTS_EXISTS);
}
//查询该库位下所有数据
QueryWrapper<ItemAccountsDO> itemAccountsDOQueryWrapper = new QueryWrapper<>();
itemAccountsDOQueryWrapper.eq("available", BooleanTypeEnum.Y.getCode());
if (itemAccountsDO.getIsInAccount() != null) {
itemAccountsDOQueryWrapper.eq("is_in_account", itemAccountsDO.getIsInAccount());
}
itemAccountsDOQueryWrapper.eq("item_number", accountsDO.getItemNumber());
itemAccountsDOQueryWrapper.eq("location_number", itemAccountsDO.getLocationNumber());
List<ItemAccountsDO> itemAccountsDOList = itemAccountsMapper.selectList(itemAccountsDOQueryWrapper);
if (itemAccountsDOList.size() == 0) {
for (ItemAccountsDO en:itemAccountsDOList) {
//新增备件库位变更记录
ItemLocationReplaceDO itemLocationReplaceDO = new ItemLocationReplaceDO();
itemLocationReplaceDO.setItemNumber(accountsDO.getItemNumber());
@ -499,26 +523,10 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
itemLocationReplaceDO.setLocationNumber(accountsDO.getLocationNumber());
itemLocationReplaceDO.setCreateTime(LocalDateTime.now());
itemLocationReplaceMapper.insert(itemLocationReplaceDO);
//删除备件台账的数据
itemAccountsMapper.deleteById(itemAccountsDO);
//新增一条备件台账(该库位下的)
ItemAccountsDO newItemAccountsDO = new ItemAccountsDO();
newItemAccountsDO.setIsInAccount(itemAccountsDO.getIsInAccount());
newItemAccountsDO.setItemNumber(accountsDO.getItemNumber());
newItemAccountsDO.setLocationNumber(accountsDO.getLocationNumber());
//根据库位查询库区
QueryWrapper<LocationDO> locationDOQueryWrapper = new QueryWrapper<>();
locationDOQueryWrapper.eq("available", BooleanTypeEnum.Y.getCode());
locationDOQueryWrapper.eq("number", accountsDO.getLocationNumber());
LocationDO locationDO = locationMapper.selectOne(locationDOQueryWrapper);
newItemAccountsDO.setAreaNumber(locationDO.getAreaNumber());
en.setItemNumber(accountsDO.getItemNumber());
//库位中新的备件数量是0
newItemAccountsDO.setQty(BigDecimal.ZERO);
newItemAccountsDO.setCreateTime(LocalDateTime.now());
newItemAccountsDO.setAvailable(BooleanTypeEnum.Y.getCode());
itemAccountsMapper.insert(newItemAccountsDO);
} else {
throw ServiceExceptionUtil.exception(LOCATION_CAN_NOT_REPLACE);
en.setQty(BigDecimal.ZERO);
itemAccountsMapper.updateById(en);
}
return 1;
}
@ -564,7 +572,7 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
}
/**
* 备件号和库位号是否存在
* 非当前备件号和库位号是否存在
*/
private void validate(String itemNumber,String locationNumber) {
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
@ -577,5 +585,19 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
}
}
/**
* 备件号和非库位号是否存在
*/
private void validate1(String itemNumber,String locationNumber) {
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("item_number",itemNumber);
queryWrapper.ne("location_number",locationNumber);
queryWrapper.eq("available","TRUE");
List<ItemAccountsDO> itemAccountsDOS = itemAccountsMapper.selectList(queryWrapper);
if(!itemAccountsDOS.isEmpty()){
throw exception(ITEM_EXISTS);
}
}
}

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

@ -62,17 +62,18 @@ public class TransactionServiceImpl implements TransactionService {
public Integer create(List<TransactionCreateReqVO> createReqVOList) {
int result = 0;
for (TransactionCreateReqVO createReqVO : createReqVOList) {
TransactionDO transactionDO = TransactionConvert.INSTANCE.convert(createReqVO);
//生成单据号
QueryWrapper<ItemDO> itemDOQueryWrapper = new QueryWrapper<>();
itemDOQueryWrapper.eq("number", transactionDO.getItemNumber());
itemDOQueryWrapper.eq("number", createReqVO.getItemNumber());
ItemDO itemDO = itemMapper.selectOne(itemDOQueryWrapper);
transactionDO.setUom(itemDO.getUom());
createReqVO.setUom(itemDO.getUom());
//result += Mapper.insert(transactionDO);
ItemAccountsCreateReqVO itemAccountsCreateReqVO = new ItemAccountsCreateReqVO();
BeanUtils.copyProperties(transactionDO, itemAccountsCreateReqVO);
List<TransactionDO> transactionDOS = itemAccountsMapper.updateItemAccountsQty(itemAccountsCreateReqVO, transactionDO.getTransactionType(), transactionDO.getInventoryAction());
BeanUtils.copyProperties(createReqVO, itemAccountsCreateReqVO);
List<TransactionDO> transactionDOS = itemAccountsMapper.updateItemAccountsQty(itemAccountsCreateReqVO, createReqVO.getTransactionType(), createReqVO.getInventoryAction());
for(TransactionDO en:transactionDOS){//循环出库存记录
TransactionDO transactionDO = TransactionConvert.INSTANCE.convert(createReqVO);
transactionDO.setType(en.getType());
transactionDO.setQty(en.getQty());
result += Mapper.insert(transactionDO);

Loading…
Cancel
Save