|
@@ -1,18 +1,31 @@
|
|
package com.qmth.sop.business.service.impl;
|
|
package com.qmth.sop.business.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.qmth.sop.business.bean.params.DeviceInOutForm;
|
|
|
|
+import com.qmth.sop.business.bean.params.DeviceInOutSubmitParam;
|
|
import com.qmth.sop.business.bean.result.DeviceInOutResult;
|
|
import com.qmth.sop.business.bean.result.DeviceInOutResult;
|
|
|
|
+import com.qmth.sop.business.entity.SysDevice;
|
|
|
|
+import com.qmth.sop.business.entity.SysUser;
|
|
import com.qmth.sop.business.entity.TBDeviceInOut;
|
|
import com.qmth.sop.business.entity.TBDeviceInOut;
|
|
import com.qmth.sop.business.mapper.TBDeviceInOutMapper;
|
|
import com.qmth.sop.business.mapper.TBDeviceInOutMapper;
|
|
|
|
+import com.qmth.sop.business.service.SysDeviceService;
|
|
import com.qmth.sop.business.service.TBDeviceInOutService;
|
|
import com.qmth.sop.business.service.TBDeviceInOutService;
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
import com.qmth.sop.common.enums.DeviceStatusEnum;
|
|
import com.qmth.sop.common.enums.DeviceStatusEnum;
|
|
import com.qmth.sop.common.enums.DeviceUsageTypeEnum;
|
|
import com.qmth.sop.common.enums.DeviceUsageTypeEnum;
|
|
|
|
+import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
import com.qmth.sop.common.enums.InOutTypeEnum;
|
|
import com.qmth.sop.common.enums.InOutTypeEnum;
|
|
|
|
+import com.qmth.sop.common.util.ServletUtil;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 设备出入库登记 服务实现类
|
|
* 设备出入库登记 服务实现类
|
|
@@ -23,6 +36,8 @@ import org.springframework.stereotype.Service;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, TBDeviceInOut> implements TBDeviceInOutService {
|
|
public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, TBDeviceInOut> implements TBDeviceInOutService {
|
|
|
|
+ @Resource
|
|
|
|
+ private SysDeviceService sysDeviceService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public IPage<DeviceInOutResult> findDeviceInOutPageBySop(Long serviceUnitId, DeviceUsageTypeEnum usageType, Long userId, DeviceStatusEnum deviceStatus, Long inOutTimeStart, Long inOutTimeEnd, String deviceNo, String customName, String location, String address, Integer pageNumber, Integer pageSize) {
|
|
public IPage<DeviceInOutResult> findDeviceInOutPageBySop(Long serviceUnitId, DeviceUsageTypeEnum usageType, Long userId, DeviceStatusEnum deviceStatus, Long inOutTimeStart, Long inOutTimeEnd, String deviceNo, String customName, String location, String address, Integer pageNumber, Integer pageSize) {
|
|
@@ -36,18 +51,65 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Object findDeviceInInfo() {
|
|
|
|
- return null;
|
|
|
|
|
|
+ public List<DeviceInOutResult> findDeviceCanOutInfo(Long supplierId) {
|
|
|
|
+ return this.baseMapper.findDeviceCanOutInfo(supplierId, DeviceStatusEnum.NORMAL, InOutTypeEnum.IN);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Object findDeviceOutInfo() {
|
|
|
|
- return null;
|
|
|
|
|
|
+ public List<DeviceInOutResult> findDeviceCanInInfo(Long supplierId, String crmNo) {
|
|
|
|
+ return this.baseMapper.findDeviceCanInInfo(supplierId, InOutTypeEnum.OUT, crmNo);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public void deviceInOutSubmit() {
|
|
|
|
|
|
+ public void deviceInOutSubmit(DeviceInOutSubmitParam deviceInOutSubmitParam) {
|
|
|
|
+ SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+
|
|
|
|
+ Long inOutTime = deviceInOutSubmitParam.getInOutTime();
|
|
|
|
+ InOutTypeEnum inOutType = deviceInOutSubmitParam.getInOutType();
|
|
|
|
+
|
|
|
|
+ Long serviceUnitId = deviceInOutSubmitParam.getServiceUnitId();
|
|
|
|
+ String crmNo = deviceInOutSubmitParam.getCrmNo();
|
|
|
|
+ String sopNo = deviceInOutSubmitParam.getSopNo();
|
|
|
|
+
|
|
|
|
+ DeviceUsageTypeEnum usageType;
|
|
|
|
+ if (sopNo != null && sopNo.length() > 0) {
|
|
|
|
+ usageType = DeviceUsageTypeEnum.PROJECT;
|
|
|
|
+ } else {
|
|
|
|
+ usageType = DeviceUsageTypeEnum.OTHER;
|
|
|
|
+ }
|
|
|
|
+ if (deviceInOutSubmitParam.getDeviceInOutFormList().size() > deviceInOutSubmitParam.getDeviceInOutFormList().stream().map(DeviceInOutForm::getDeviceNo).distinct().count()) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("出入库登记表中设备编号有重复");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<DeviceInOutForm> deviceInOutFormList = deviceInOutSubmitParam.getDeviceInOutFormList();
|
|
|
|
+ List<TBDeviceInOut> tbDeviceInOutList = deviceInOutFormList.stream().flatMap(e -> {
|
|
|
|
+ TBDeviceInOut tbDeviceInOut = new TBDeviceInOut();
|
|
|
|
+ tbDeviceInOut.setServiceId(serviceUnitId);
|
|
|
|
+ tbDeviceInOut.setCrmNo(crmNo);
|
|
|
|
+ tbDeviceInOut.setSopNo(sopNo);
|
|
|
|
+ tbDeviceInOut.setUserId(requestUser.getId());
|
|
|
|
+ tbDeviceInOut.setType(inOutType);
|
|
|
|
+ tbDeviceInOut.setDeviceNo(e.getDeviceNo());
|
|
|
|
+ tbDeviceInOut.setSupplierName(e.getSupplierName());
|
|
|
|
+ tbDeviceInOut.setLocation(e.getLocation());
|
|
|
|
+ tbDeviceInOut.setAddress(e.getAddress());
|
|
|
|
+ tbDeviceInOut.setStatus(e.getDeviceStatus());
|
|
|
|
+ tbDeviceInOut.setUsageType(usageType);
|
|
|
|
+ tbDeviceInOut.setBasePhotoPath(e.getBasePhotoPath());
|
|
|
|
+ tbDeviceInOut.setInOutTime(inOutTime);
|
|
|
|
+
|
|
|
|
+ UpdateWrapper<SysDevice> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.lambda()
|
|
|
|
+ .set(SysDevice::getLocation, e.getAddress())
|
|
|
|
+ .set(SysDevice::getScanCount, e.getScanCount())
|
|
|
|
+ .set(SysDevice::getStatus, e.getDeviceStatus())
|
|
|
|
+ .eq(SysDevice::getSerialNo, e.getDeviceNo());
|
|
|
|
+ sysDeviceService.update(updateWrapper);
|
|
|
|
|
|
|
|
+ return Stream.of(tbDeviceInOut);
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ this.saveBatch(tbDeviceInOutList);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -58,4 +120,4 @@ public class TBDeviceInOutServiceImpl extends ServiceImpl<TBDeviceInOutMapper, T
|
|
return this.baseMapper.findDeviceInOutPageBySource(new Page<>(pageNumber, pageSize), serviceUnitId, inOutType,
|
|
return this.baseMapper.findDeviceInOutPageBySource(new Page<>(pageNumber, pageSize), serviceUnitId, inOutType,
|
|
deviceNo, inOutTimeStart, inOutTimeEnd, supplierId, customName);
|
|
deviceNo, inOutTimeStart, inOutTimeEnd, supplierId, customName);
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|