|
|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.kxs.common.core.constant.CommonConstants;
|
|
|
import com.kxs.common.core.constant.SecurityConstants;
|
|
|
import com.kxs.common.core.constant.enums.ErrorTypeEnum;
|
|
|
import com.kxs.common.core.constant.enums.MachineTypeEnum;
|
|
|
@@ -114,7 +115,7 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
//修改机具
|
|
|
machine.setWarehouseId(machineRecycle.getWarehouseId());
|
|
|
machine.setUserId(0);
|
|
|
-// machine.setStatus(MachineTypeEnum.RECYCLE_CONFIRM.getType());
|
|
|
+ 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()){
|
|
|
@@ -146,18 +147,6 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
recycleInfo.setStatus(RecycleOrderEnum.INFO_CANCEL.getType());
|
|
|
recycleInfo.setCancelTime(LocalDateTime.now());
|
|
|
kxsMachineRecycleInfoMapper.updateById(recycleInfo);
|
|
|
-
|
|
|
- //修改机具状态未可回收
|
|
|
- R<KxsMachine> kxsMachineR = remoteKxsProductService.loadMachineBySn(recycleInfo.getPosSn(), SecurityConstants.FROM_IN);
|
|
|
- KxsMachine machine = RetOps.of(kxsMachineR)
|
|
|
- .getData()
|
|
|
- .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.SN_FIND_NULL.getDescription()));
|
|
|
- machine.setStatus(MachineTypeEnum.RECYCLE_STATUS.getType());
|
|
|
-
|
|
|
- R<Boolean> booleanR = remoteKxsProductService.updateByMachine(machine, SecurityConstants.FROM_IN);
|
|
|
- if(!booleanR.getData()){
|
|
|
- throw new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription());
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -207,7 +196,7 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
BeanUtils.copyProperties(param, machineRecycle);
|
|
|
//订单号
|
|
|
String orderSn = IdUtil.getSnowflakeNextIdStr();
|
|
|
- machineRecycle.setOrderSn("JJHS" + orderSn);
|
|
|
+ machineRecycle.setOrderSn(CommonConstants.KXS_MACHINE_RE_PREFIX + orderSn);
|
|
|
|
|
|
machineRecycle.setUserId(userId.intValue());
|
|
|
machineRecycle.setUsername(user.getUsername());
|
|
|
@@ -223,10 +212,16 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
KxsMachine machine = RetOps.of(kxsMachineR)
|
|
|
.getData()
|
|
|
.orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription()));
|
|
|
- if(!Objects.equals(machine.getStatus(), MachineTypeEnum.RECYCLE_STATUS.getType())){
|
|
|
- throw new GlobalCustomerException("机具号" + machine.getPosSn() + "不可回收");
|
|
|
+ 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){
|
|
|
+ throw new GlobalCustomerException("机具号" + machine.getPosSn() + "重复提交/已回收");
|
|
|
}
|
|
|
-
|
|
|
KxsMachineRecycleInfo kxsMachineRecycleInfo = new KxsMachineRecycleInfo();
|
|
|
kxsMachineRecycleInfo.setPosSn(sn);
|
|
|
kxsMachineRecycleInfo.setOrderId(machineRecycle.getId());
|
|
|
@@ -234,11 +229,6 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
kxsMachineRecycleInfo.setRecycleEndTime(machine.getRecycleEndTime());
|
|
|
kxsMachineRecycleInfoMapper.insert(kxsMachineRecycleInfo);
|
|
|
|
|
|
-// machine.setStatus(MachineTypeEnum.RECYCLE_UN_CONFIRM.getType());
|
|
|
-// R<Boolean> booleanR = remoteKxsProductService.updateByMachine(machine, SecurityConstants.FROM_IN);
|
|
|
-// if (!booleanR.getData()) {
|
|
|
-// throw new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription());
|
|
|
-// }
|
|
|
}
|
|
|
KxsUserMsg kxsUserMsg = MsgTemplateUtil.machineRecycleNote(param.getSnList(), brand.getName(), kxsWarehouse.getUserId(), user.getUserCode());
|
|
|
remoteUserMsgService.pushUserMsg(kxsUserMsg, SecurityConstants.FROM_IN);
|
|
|
@@ -304,26 +294,16 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
|
|
|
if (recycleInfo == null) {
|
|
|
throw new GlobalCustomerException(sn + "机具已处理");
|
|
|
}
|
|
|
- //删除回收机具
|
|
|
- kxsMachineRecycleInfoMapper.deleteById(recycleInfo.getId());
|
|
|
- //修改机具状态未可回收
|
|
|
-// R<KxsMachine> kxsMachineR = remoteKxsProductService.loadMachineBySn(sn, SecurityConstants.FROM_IN);
|
|
|
-// KxsMachine machine = RetOps.of(kxsMachineR)
|
|
|
-// .getData()
|
|
|
-// .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.SN_FIND_NULL.getDescription()));
|
|
|
-// machine.setStatus(MachineTypeEnum.RECYCLE_CANCEL.getType());
|
|
|
-//
|
|
|
-// R<Boolean> booleanR = remoteKxsProductService.updateByMachine(machine, SecurityConstants.FROM_IN);
|
|
|
-// if(!booleanR.getData()){
|
|
|
-// throw new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription());
|
|
|
+ //回收机具
|
|
|
+ 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());
|
|
|
// }
|
|
|
-
|
|
|
- //删除主订单
|
|
|
- Long count = kxsMachineRecycleInfoMapper.selectCount(Wrappers.lambdaQuery(KxsMachineRecycleInfo.class)
|
|
|
- .eq(KxsMachineRecycleInfo::getOrderId, recycleInfo.getOrderId()));
|
|
|
- if(count == 0){
|
|
|
- baseMapper.deleteById(recycleInfo.getOrderId());
|
|
|
- }
|
|
|
});
|
|
|
|
|
|
return R.ok();
|