|
|
@@ -25,8 +25,10 @@ import com.kxs.store.api.dto.kxsapp.storeRecycle.UserReturnRecycleDTO;
|
|
|
import com.kxs.store.api.model.KxsMachineRecycleInfo;
|
|
|
import com.kxs.store.api.model.KxsWarehouse;
|
|
|
import com.kxs.store.api.vo.kxsapp.storeRecycle.*;
|
|
|
+import com.kxs.store.biz.constant.enums.MachineRecycleStatusEnum;
|
|
|
import com.kxs.store.biz.constant.enums.RecycleOrderEnum;
|
|
|
import com.kxs.store.biz.constant.enums.StoreErrorTypeEnum;
|
|
|
+import com.kxs.store.biz.constant.enums.StoreStatusEnum;
|
|
|
import com.kxs.store.biz.mapper.KxsMachineRecycleInfoMapper;
|
|
|
import com.kxs.store.biz.mapper.KxsMachineRecycleMapper;
|
|
|
import com.kxs.store.api.model.KxsMachineRecycle;
|
|
|
@@ -89,23 +91,23 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
public R confirm(RecycleConfirmDTO param) {
|
|
|
|
|
|
KxsMachineRecycle machineRecycle = baseMapper.selectById(param.getId());
|
|
|
- if(machineRecycle == null){
|
|
|
+ if (machineRecycle == null) {
|
|
|
return R.failed(StoreErrorTypeEnum.DATA_ERROR.getDescription());
|
|
|
}
|
|
|
List<KxsMachineRecycleInfo> recycleInfos = kxsMachineRecycleInfoMapper.selectList(Wrappers.<KxsMachineRecycleInfo>lambdaQuery()
|
|
|
.eq(KxsMachineRecycleInfo::getStatus, RecycleOrderEnum.INFO_UNCONFIRM.getType())
|
|
|
.eq(KxsMachineRecycleInfo::getOrderId, machineRecycle.getId()));
|
|
|
- if(recycleInfos.isEmpty()){
|
|
|
+ if (recycleInfos.isEmpty()) {
|
|
|
return R.failed(StoreErrorTypeEnum.DATA_ERROR.getDescription());
|
|
|
}
|
|
|
for (KxsMachineRecycleInfo recycleInfo : recycleInfos) {
|
|
|
- if(param.getSnList().contains(recycleInfo.getPosSn())){
|
|
|
+ if (param.getSnList().contains(recycleInfo.getPosSn())) {
|
|
|
//远程查询机具号
|
|
|
R<KxsMachine> kxsMachineR = remoteKxsProductService.loadMachineBySn(recycleInfo.getPosSn(), SecurityConstants.FROM_IN);
|
|
|
KxsMachine machine = RetOps.of(kxsMachineR)
|
|
|
.getData()
|
|
|
.orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.SN_FIND_NULL.getDescription()));
|
|
|
- if(Objects.equals(machine.getBindStatus(), MachineTypeEnum.BIND.getType())){
|
|
|
+ if (Objects.equals(machine.getBindStatus(), MachineTypeEnum.BIND.getType())) {
|
|
|
throw new GlobalCustomerException("机具" + machine.getPosSn() + "已被绑定,请驳回该机具");
|
|
|
}
|
|
|
|
|
|
@@ -118,11 +120,19 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
machine.setStatus(MachineTypeEnum.STATUS_IS.getType());
|
|
|
machine.setMachineType(MachineTypeEnum.M_TYPE_SN.getType());
|
|
|
R<Boolean> booleanR = remoteKxsProductService.updateByMachine(machine, SecurityConstants.FROM_IN);
|
|
|
- if(!booleanR.getData()){
|
|
|
+ if (!booleanR.getData()) {
|
|
|
throw new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //都处理完成后主订单状态字段修改为完成
|
|
|
+ Long count = kxsMachineRecycleInfoMapper.selectCount(Wrappers.lambdaQuery(KxsMachineRecycleInfo.class)
|
|
|
+ .eq(KxsMachineRecycleInfo::getStatus, RecycleOrderEnum.INFO_UNCONFIRM.getType())
|
|
|
+ .eq(KxsMachineRecycleInfo::getOrderId, param.getId()));
|
|
|
+ if (count == 0) {
|
|
|
+ machineRecycle.setStatus(CommonConstants.SUCCESS);
|
|
|
+ baseMapper.updateById(machineRecycle);
|
|
|
+ }
|
|
|
|
|
|
return R.ok();
|
|
|
}
|
|
|
@@ -133,27 +143,35 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R cancel(RecycleConfirmDTO param) {
|
|
|
|
|
|
- KxsMachineRecycle recycleOrder = baseMapper.selectById(param.getId());
|
|
|
+ KxsMachineRecycle machineRecycle = baseMapper.selectById(param.getId());
|
|
|
|
|
|
- if(recycleOrder == null){
|
|
|
+ if (machineRecycle == null) {
|
|
|
return R.failed(StoreErrorTypeEnum.DATA_ERROR.getDescription());
|
|
|
}
|
|
|
List<KxsMachineRecycleInfo> recycleInfos = kxsMachineRecycleInfoMapper.selectList(Wrappers.<KxsMachineRecycleInfo>lambdaQuery()
|
|
|
.eq(KxsMachineRecycleInfo::getStatus, RecycleOrderEnum.INFO_UNCONFIRM.getType())
|
|
|
- .eq(KxsMachineRecycleInfo::getOrderId, recycleOrder.getId()));
|
|
|
+ .eq(KxsMachineRecycleInfo::getOrderId, machineRecycle.getId()));
|
|
|
|
|
|
for (KxsMachineRecycleInfo recycleInfo : recycleInfos) {
|
|
|
- if(param.getSnList().contains(recycleInfo.getPosSn())){
|
|
|
+ if (param.getSnList().contains(recycleInfo.getPosSn())) {
|
|
|
recycleInfo.setStatus(RecycleOrderEnum.INFO_CANCEL.getType());
|
|
|
recycleInfo.setCancelTime(LocalDateTime.now());
|
|
|
kxsMachineRecycleInfoMapper.updateById(recycleInfo);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ //都处理完成后主订单状态字段修改为完成
|
|
|
+ Long count = kxsMachineRecycleInfoMapper.selectCount(Wrappers.lambdaQuery(KxsMachineRecycleInfo.class)
|
|
|
+ .eq(KxsMachineRecycleInfo::getStatus, RecycleOrderEnum.INFO_UNCONFIRM.getType())
|
|
|
+ .eq(KxsMachineRecycleInfo::getOrderId, param.getId()));
|
|
|
+ if (count == 0) {
|
|
|
+ machineRecycle.setStatus(CommonConstants.SUCCESS);
|
|
|
+ baseMapper.updateById(machineRecycle);
|
|
|
+ }
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public StoreRecycleDataVO recycleCount() {
|
|
|
|
|
|
@@ -162,10 +180,14 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
StoreRecycleDataVO storeRecycleDataVO = new StoreRecycleDataVO();
|
|
|
|
|
|
//待确认机具数量
|
|
|
- Integer recycleCount = baseMapper.storeRecoverableData(userId.intValue(), 0);
|
|
|
+ Long recycleCount = baseMapper.selectCount(Wrappers.<KxsMachineRecycle>lambdaQuery()
|
|
|
+ .eq(KxsMachineRecycle::getUserId, userId)
|
|
|
+ .eq(KxsMachineRecycle::getStatus, CommonConstants.FAIL));
|
|
|
storeRecycleDataVO.setRecycleCount(recycleCount);
|
|
|
//已完成
|
|
|
- Integer recyclableCount = baseMapper.storeRecoverableData(userId.intValue(), 1);
|
|
|
+ Long recyclableCount = baseMapper.selectCount(Wrappers.<KxsMachineRecycle>lambdaQuery()
|
|
|
+ .eq(KxsMachineRecycle::getUserId, userId)
|
|
|
+ .eq(KxsMachineRecycle::getStatus, CommonConstants.SUCCESS));
|
|
|
storeRecycleDataVO.setRecyclableCount(recyclableCount);
|
|
|
|
|
|
return storeRecycleDataVO;
|
|
|
@@ -190,7 +212,7 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
.orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription()));
|
|
|
//查询仓库
|
|
|
KxsWarehouse kxsWarehouse = kxsWarehouseMapper.selectById(param.getWarehouseId());
|
|
|
- if(kxsWarehouse == null){
|
|
|
+ if (kxsWarehouse == null) {
|
|
|
return R.failed(StoreErrorTypeEnum.STORE_NOT_FIND.getDescription());
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, machineRecycle);
|
|
|
@@ -212,14 +234,14 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
KxsMachine machine = RetOps.of(kxsMachineR)
|
|
|
.getData()
|
|
|
.orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription()));
|
|
|
- if(Objects.equals(machine.getIsAct(), MachineTypeEnum.ACT.getType()) || Objects.equals(machine.getBindStatus(), MachineTypeEnum.BIND.getType())){
|
|
|
+ if (Objects.equals(machine.getIsAct(), MachineTypeEnum.ACT.getType()) || Objects.equals(machine.getBindStatus(), MachineTypeEnum.BIND.getType())) {
|
|
|
throw new GlobalCustomerException("机具号" + machine.getPosSn() + "已绑定/已激活");
|
|
|
}
|
|
|
//查询是否已提交
|
|
|
KxsMachineRecycleInfo recycleInfo = kxsMachineRecycleInfoMapper.selectOne(Wrappers.<KxsMachineRecycleInfo>lambdaQuery()
|
|
|
.in(KxsMachineRecycleInfo::getStatus, 0, 1)
|
|
|
.eq(KxsMachineRecycleInfo::getPosSn, sn));
|
|
|
- if(recycleInfo != null){
|
|
|
+ if (recycleInfo != null) {
|
|
|
throw new GlobalCustomerException("机具号" + machine.getPosSn() + "重复提交/已回收");
|
|
|
}
|
|
|
KxsMachineRecycleInfo kxsMachineRecycleInfo = new KxsMachineRecycleInfo();
|
|
|
@@ -298,22 +320,18 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
recycleInfo.setStatus(RecycleOrderEnum.INFO_RETURN.getType());
|
|
|
kxsMachineRecycleInfoMapper.updateById(recycleInfo);
|
|
|
|
|
|
- //主订单
|
|
|
-// Long count = kxsMachineRecycleInfoMapper.selectCount(Wrappers.lambdaQuery(KxsMachineRecycleInfo.class)
|
|
|
-// .eq(KxsMachineRecycleInfo::getOrderId, recycleInfo.getOrderId()));
|
|
|
-// if(count == 0){
|
|
|
-// baseMapper.deleteById(recycleInfo.getOrderId());
|
|
|
-// }
|
|
|
+
|
|
|
});
|
|
|
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<String> recycleSnList() {
|
|
|
+ public List<String> loadByRecycleSnList() {
|
|
|
+
|
|
|
Long userId = SecurityUtils.getUser().getId();
|
|
|
|
|
|
- return baseMapper.recycleUserSnList(userId);
|
|
|
+ return baseMapper.loadByRecycleSnList(userId);
|
|
|
}
|
|
|
|
|
|
|