feat: 设备

dev_ksck
chenhc 2 days ago
parent 981380d94e
commit dafefc2f5d

@ -10,4 +10,6 @@ public class FileConstant {
public static String COMMON_FILE_PATH = "register/image2/";
public static String DEV_COMMON_FILE_PATH = "register/device/";
}

@ -20,6 +20,7 @@ public interface SocketMsgType {
String BASIC_CORP_MAINTAIN_DELETE = "BASIC_CORP_MAINTAIN_DELETE"; //供应商字典
String BASIC_BUSINESS_TYPE_DELETE = "BASIC_BUSINESS_TYPE_DELETE"; //单据类型
String DEVICE_CERT_TYPE_DELETE = "DEVICE_CERT_TYPE_DELETE"; //资质资料
String STAT_DATA_REQUEST = "STAT_DATA_REQUEST"; //
String STAT_DATA = "STAT_DATA"; //

@ -19,5 +19,6 @@ public interface SyncDelType {
String DEV_TASK = "DEV_TASK";
String DEVICE_INFO_DATA = "DEVICE_INFO_DATA";
String DEVICE_CERT_TYPE = "DEVICE_CERT_TYPE";
}

@ -8,8 +8,12 @@ import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.constant.FileConstant;
import com.glxp.api.constant.SocketMsgType;
import com.glxp.api.controller.BaseController;
import com.glxp.api.controller.sync.SpsSyncWebSocket;
import com.glxp.api.entity.dev.DeviceAssetCertEntity;
import com.glxp.api.entity.sync.SocketMsgEntity;
import com.glxp.api.req.basic.BasicDataRequest;
import com.glxp.api.req.dev.PostDeviceCertRequest;
import com.glxp.api.req.inv.FilterInvCertRequest;
import com.glxp.api.req.system.DeleteDeviceFileRequest;
@ -17,6 +21,7 @@ import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.dev.DeviceAssetCertService;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.server.WebSocketServer;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
@ -30,6 +35,7 @@ import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
import java.util.List;
/**
@ -44,6 +50,9 @@ public class DeviceAssetCertController extends BaseController {
private DeviceAssetCertService deviceAssetCertService;
@Resource
private CustomerService customerService;
@Resource
SpsSyncWebSocket webSocketServer;
@AuthRuleAnnotation("")
@GetMapping("/inv/device/cert/filter")
@ -63,7 +72,7 @@ public class DeviceAssetCertController extends BaseController {
@Log(title = "资质证书", businessType = BusinessType.INSERT)
public BaseResponse insertDeviceCert(@RequestBody DeviceAssetCertEntity deviceAssetCertEntity) {
String userId = customerService.getUserId()+ "";
LocalDate now = LocalDate.now();
Date now = new Date();
deviceAssetCertEntity.setCreateTime(now);
deviceAssetCertEntity.setUpdateTime(now);
deviceAssetCertEntity.setCreateUser(userId);
@ -78,11 +87,21 @@ public class DeviceAssetCertController extends BaseController {
@PostMapping("/inv/info/deleteDeviceCert")
public BaseResponse deleteDeviceCert(@RequestBody DeleteDeviceFileRequest deleteDeviceFileRequest) {
boolean b = deviceAssetCertService.deleteById(deleteDeviceFileRequest.getId());
String URL = filePath + FileConstant.COMMON_FILE_PATH + deleteDeviceFileRequest.getFilePath();
String URL = filePath + FileConstant.DEV_COMMON_FILE_PATH + deleteDeviceFileRequest.getFilePath();
File file = new File(URL);
if (file.exists() && file.isFile()) {
file.delete();
}
BasicDataRequest basicDataRequest = new BasicDataRequest();
basicDataRequest.setDeleteDeviceFileRequest(deleteDeviceFileRequest);
Long userId = getUserId();
basicDataRequest.setKey("DEVICE_CERT_TYPE");
//推送
BasicDataRequest request = webSocketServer.insert(basicDataRequest, userId + "");
request.setDeleteDeviceFileRequest(deleteDeviceFileRequest);
webSocketServer.sendMessage(SocketMsgEntity.builder().type(SocketMsgType.DEVICE_CERT_TYPE_DELETE).content(request).remark("设备资质材料").build(), null);
return ResultVOUtils.success("成功");
}
@ -105,7 +124,7 @@ public class DeviceAssetCertController extends BaseController {
}
}
String userId = customerService.getUserId()+ "";
LocalDate now = LocalDate.now();
Date now = new Date();
deviceAssetCertEntity.setUpdateTime(now);
deviceAssetCertEntity.setUpdateUser(userId);
boolean b = deviceAssetCertService.updateDeviceCert(deviceAssetCertEntity);

@ -159,6 +159,12 @@ public class SpsSyncWebSocket {
deleteBasicDataRequest.setName("汇总日报");
basicDataRequest.setDeleteBasicDataRequest(deleteBasicDataRequest);
break;
case "DEVICE_CERT_TYPE":
deleteBasicDataRequest.setDataType(basicDataRequest.getKey());
deleteBasicDataRequest.setParam(JSONUtil.toJsonStr(basicDataRequest.getDeleteDeviceFileRequest()) + basicDataRequest.getKey());
deleteBasicDataRequest.setName("设备资质材料");
basicDataRequest.setDeleteBasicDataRequest(deleteBasicDataRequest);
break;
default:
break;
}

@ -9,6 +9,7 @@ import com.glxp.api.annotation.Log;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.constant.FileConstant;
import com.glxp.api.constant.SyncDelType;
import com.glxp.api.controller.BaseController;
import com.glxp.api.dao.dev.DeviceInfoMapper;
@ -22,21 +23,25 @@ import com.glxp.api.entity.sync.SyncEditLogEntity;
import com.glxp.api.entity.sync.SyncEditTypeEntity;
import com.glxp.api.req.basic.*;
import com.glxp.api.req.system.DeleteCompanyFileRequest;
import com.glxp.api.req.system.DeleteDeviceFileRequest;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.service.auth.InvBusUserService;
import com.glxp.api.service.auth.WarehouseBussinessTypeService;
import com.glxp.api.service.basic.*;
import com.glxp.api.service.dev.DeviceAssetCertService;
import com.glxp.api.service.inout.*;
import com.glxp.api.service.inout.impl.IoCodeService;
import com.glxp.api.service.inv.DeviceInspectTaskDetailService;
import com.glxp.api.service.inv.DeviceInspectTaskService;
import com.glxp.api.service.sync.SyncEditLogService;
import com.glxp.api.service.sync.SyncEditTypeService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -123,6 +128,14 @@ public class SyncDelController extends BaseController {
//插入操作数据类型记录表
insertType(basicDataRequest.getDeleteBasicDataRequest());
break;
case SyncDelType.DEVICE_CERT_TYPE:
baseResponse = deleteDevCertData(basicDataRequest.getDeleteDeviceFileRequest());
//插入日志
insertLog(basicDataRequest.getDeleteBasicDataRequest(), baseResponse);
//插入操作数据类型记录表
insertType(basicDataRequest.getDeleteBasicDataRequest());
break;
default:
break;
}
@ -234,12 +247,27 @@ public class SyncDelController extends BaseController {
@Resource
DeviceInfoMapper deviceInfoMapper;
@Resource
DeviceAssetCertService deviceAssetCertService;
public BaseResponse deleteDevInfoData(DeviceInfoEntity deviceInfoEntity) {
deviceInfoMapper.delete(new QueryWrapper<DeviceInfoEntity>().eq("deviceCode", deviceInfoEntity.getDeviceCode()));
return ResultVOUtils.success("删除成功");
}
@Value("${file_path}")
private String filePath;
public BaseResponse deleteDevCertData(DeleteDeviceFileRequest deleteDeviceFileRequest) {
String URL = filePath + FileConstant.DEV_COMMON_FILE_PATH + deleteDeviceFileRequest.getFilePath();
File file = new File(URL);
if (file.exists() && file.isFile()) {
file.delete();
}
return deviceAssetCertService.deleteById(deleteDeviceFileRequest.getId()) ? ResultVOUtils.success("删除成功") : ResultVOUtils.error(500, "删除失败,系统繁忙");
}
@Resource
private IoCodeTempService codeTempService;
@Resource

@ -9,6 +9,7 @@ import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;
@Data
@TableName(value = "device_asset_cert")
@ -86,7 +87,7 @@ public class DeviceAssetCertEntity implements Serializable {
*/
@TableField(value = "createTime")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate createTime;
private Date createTime;
/**
*
@ -99,7 +100,7 @@ public class DeviceAssetCertEntity implements Serializable {
*/
@TableField(value = "updateTime")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate updateTime;
private Date updateTime;
private static final long serialVersionUID = 1L;
}

@ -5,6 +5,7 @@ import com.glxp.api.entity.inv.DeviceInspectTaskEntity;
import com.glxp.api.req.inout.FilterOrderDetailResultRequest;
import com.glxp.api.req.inout.FilterStatDataRequest;
import com.glxp.api.req.system.DeleteCompanyFileRequest;
import com.glxp.api.req.system.DeleteDeviceFileRequest;
import com.glxp.api.req.system.DeleteRequest;
import lombok.Data;
@ -37,4 +38,9 @@ public class BasicDataRequest {
private String key;
/**
*
*/
private DeleteDeviceFileRequest deleteDeviceFileRequest;
}

@ -104,6 +104,8 @@ public class SpsSyncDownloadService {
private PurApplyDao purApplyDao;
@Autowired
private PurContractMapper purContractMapper;
@Autowired
private DeviceAssetCertService deviceAssetCertService;
// 创建单据同步任务
@ -1140,6 +1142,26 @@ public class SpsSyncDownloadService {
jsonMap.put("syncFiles", syncFiles);
}
List<DeviceAssetCertEntity> deviceAssetCertEntities = deviceAssetCertService.list(Wrappers.lambdaQuery(DeviceAssetCertEntity.class)
.le(!ge && (boolean) map.get("isNew"), DeviceAssetCertEntity::getUpdateTime, now)
.between(ge, DeviceAssetCertEntity::getUpdateTime, syncTime, now)
.between(!ge && !(boolean) map.get("isNew"), DeviceAssetCertEntity::getUpdateTime
, map.get("oldDate"), now)
);
if (CollectionUtil.isNotEmpty(deviceAssetCertEntities)) {
remark.append("设备资质材料信息:").append(deviceAssetCertEntities.size()).append("条\n");
jsonMap.put(DeviceAssetCertEntity.class.getSimpleName(), deviceAssetCertEntities);
for (DeviceAssetCertEntity entity : deviceAssetCertEntities) {
if (StrUtil.isNotEmpty(entity.getFilePath())) {
syncFiles.add(entity.getFilePath());
}
}
}
log.error("接收到的各种文件集合{}",syncFiles);
if (CollUtil.isNotEmpty(syncFiles)) {
jsonMap.put("syncFiles", syncFiles);
}
}
if (jsonMap.size() > 0) {
jsonMap.put(SYNC_REMARK, remark.toString());

Loading…
Cancel
Save