|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
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.qmth.sop.business.bean.dto.CustomImportDto;
|
|
import com.qmth.sop.business.bean.dto.CustomImportDto;
|
|
|
|
+import com.qmth.sop.business.bean.dto.DeviceImportDto;
|
|
import com.qmth.sop.business.bean.dto.SysMessageExportDto;
|
|
import com.qmth.sop.business.bean.dto.SysMessageExportDto;
|
|
import com.qmth.sop.business.bean.dto.UserArchivesImportDto;
|
|
import com.qmth.sop.business.bean.dto.UserArchivesImportDto;
|
|
import com.qmth.sop.business.bean.params.UserArchivesParam;
|
|
import com.qmth.sop.business.bean.params.UserArchivesParam;
|
|
@@ -31,6 +32,7 @@ import org.springframework.util.LinkedMultiValueMap;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
|
|
+import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -76,6 +78,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
@Resource
|
|
@Resource
|
|
private SequenceService sequenceService;
|
|
private SequenceService sequenceService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private SysDeviceService sysDeviceService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 处理导入人员档案数据
|
|
* 处理导入人员档案数据
|
|
*
|
|
*
|
|
@@ -353,6 +358,67 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, Object> executeImportDeviceLogic(Map<String, Object> map) throws Exception {
|
|
|
|
+ InputStream inputStream = null;
|
|
|
|
+ try {
|
|
|
|
+ TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
|
+ inputStream = importExportUtil.getUploadFileInputStream(tbTask);
|
|
|
|
+ LinkedMultiValueMap<String, DeviceImportDto> customImportDtoLinkedMultiValueMap = new LinkedMultiValueMap<>();
|
|
|
|
+ StringJoiner errorData = new StringJoiner("");
|
|
|
|
+ EasyExcel.read(inputStream, DeviceImportDto.class, new BasicExcelListener<DeviceImportDto>() {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void handle(LinkedMultiValueMap<String, DeviceImportDto> dataList, StringJoiner errorDataSj) {
|
|
|
|
+ customImportDtoLinkedMultiValueMap.addAll(dataList);
|
|
|
|
+ errorData.add(errorDataSj.toString());
|
|
|
|
+ }
|
|
|
|
+ }).headRowNumber(2).sheet(0).doRead();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ map.computeIfAbsent(SystemConstant.EXCEL_DATA, v -> customImportDtoLinkedMultiValueMap);
|
|
|
|
+ map.computeIfAbsent(SystemConstant.EXCEL_DATA_ERROR, v -> errorData.toString());
|
|
|
|
+ int errorSize = Objects.nonNull(customImportDtoLinkedMultiValueMap.get(BasicExcelListener.ERROR)) ? Objects.requireNonNull(customImportDtoLinkedMultiValueMap.get(BasicExcelListener.ERROR)).size() : 0;
|
|
|
|
+
|
|
|
|
+ if (errorSize == 0) {
|
|
|
|
+ List<SysDevice> sysDevices=new ArrayList<>();
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+ List<SysSupplier> supplierList = sysSupplierService.list(new QueryWrapper<SysSupplier>().lambda().eq(SysSupplier::getType,SupplierTypeEnum.DEVICE));
|
|
|
|
+ Objects.requireNonNull(customImportDtoLinkedMultiValueMap.get(BasicExcelListener.SUCCESS)).forEach(e -> {
|
|
|
|
+ SysDevice device=new SysDevice();
|
|
|
|
+ device.setDeviceCode(e.getDeviceCode());
|
|
|
|
+ InOutTypeEnum bound = InOutTypeEnum.IN.getTitle().equals(e.getBound()) ? InOutTypeEnum.IN : InOutTypeEnum.OUT;
|
|
|
|
+ device.setBound(bound);
|
|
|
|
+ device.setBrand(e.getBrand());
|
|
|
|
+ device.setLocation(e.getLocation());
|
|
|
|
+ device.setEnable(true);
|
|
|
|
+ //日期字符串转换时间戳
|
|
|
|
+ try {
|
|
|
|
+ device.setBuyTime(new SimpleDateFormat("yyyy/MM/dd").parse(e.getBuyTime()).getTime());
|
|
|
|
+ } catch (ParseException ex) {
|
|
|
|
+ throw new RuntimeException(ex);
|
|
|
|
+ }
|
|
|
|
+ device.setScanCount(e.getScanCount());
|
|
|
|
+ device.setSupplierId(supplierList.stream().filter(s -> s.getName().equals(e.getSupplier())).findFirst().get().getId());
|
|
|
|
+ device.setSerialNo(e.getSerialNo());
|
|
|
|
+ DeviceStatusEnum status = DeviceStatusEnum.NORMAL.getTitle().equals(e.getStatus()) ? DeviceStatusEnum.NORMAL : DeviceStatusEnum.BREAK_DOWN;
|
|
|
|
+ device.setStatus(status);
|
|
|
|
+ device.setSync(false);
|
|
|
|
+ device.insertInfo(sysUser.getId());
|
|
|
|
+ sysDevices.add(device);
|
|
|
|
+ });
|
|
|
|
+ sysDeviceService.saveSysDevice(sysDevices);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } finally {
|
|
|
|
+ if (Objects.nonNull(inputStream)) {
|
|
|
|
+ inputStream.close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 处理导出人员档案数据
|
|
* 处理导出人员档案数据
|
|
*
|
|
*
|