You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-wms-java/src/main/java/com/glxp/api/controller/inv/DeviceInspectTakeController...

186 lines
8.2 KiB
Java

package com.glxp.api.controller.inv;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.thread.ThreadUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BasicExportTypeEnum;
import com.glxp.api.constant.Constant;
import com.glxp.api.constant.DeviceStatus;
import com.glxp.api.entity.inv.DeviceInspectTaskDetailEntity;
import com.glxp.api.entity.inv.DeviceInspectTaskEntity;
import com.glxp.api.entity.system.SyncDataSetEntity;
import com.glxp.api.http.sync.SpGetHttpClient;
import com.glxp.api.req.inv.FilterDeviceInspectTakeRequest;
import com.glxp.api.res.inv.DeviceInspectTakeResponse;
import com.glxp.api.res.sync.SpsSyncDeviceTakeResponse;
import com.glxp.api.service.inv.DeviceInspectTaskDetailService;
import com.glxp.api.service.inv.DeviceInspectTaskService;
import com.glxp.api.service.sync.HeartService;
import com.glxp.api.service.sync.SyncDataSetService;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.OkHttpCli;
import com.glxp.api.util.OrderNoTypeBean;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.web.bind.annotation.GetMapping;
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.util.Date;
import java.util.List;
/**
*
*/
@Slf4j
@RestController
public class DeviceInspectTakeController {
@Resource
DeviceInspectTaskService deviceInspectTaskService;
@Resource
DeviceInspectTaskDetailService deviceInspectTaskDetailService;
@Resource
private GennerOrderUtils gennerOrderUtils;
@Resource
SpGetHttpClient spGetHttpClient;
/**
*
*
* @param filterDeviceInspectTakeRequest
* @return
*/
@GetMapping("/udiwms/inv/device/inspect/take/filter")
public BaseResponse filterList(FilterDeviceInspectTakeRequest filterDeviceInspectTakeRequest) {
List<DeviceInspectTakeResponse> list = deviceInspectTaskService.filterList(filterDeviceInspectTakeRequest);
PageInfo<DeviceInspectTakeResponse> pageInfo = new PageInfo<>(list);
return ResultVOUtils.page(pageInfo);
}
@PostMapping("/udiwms/inv/device/inspect/take/uploadDeviceInspecTake")
public BaseResponse uploadDeviceInspecTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) {
deviceInspectTaskEntity.setUpdateTime(new Date());
if (deviceInspectTaskEntity.getStatus() == DeviceStatus.DEVICE_STATUS_TEMP_DURINGINSPECTTION) {
deviceInspectTaskEntity.setStrartTime(new Date());
} else if (deviceInspectTaskEntity.getStatus() == DeviceStatus.DEVICE_STATUS_TEMP_INSPECTED) {
deviceInspectTaskEntity.setEndTime(new Date());
}
boolean falg = deviceInspectTaskService.updateById(deviceInspectTaskEntity);
UploadDeviceTake(deviceInspectTaskEntity.getId(), 2);
if (!falg) {
return ResultVOUtils.error(999, "更新失败");
}
return ResultVOUtils.success();
}
@PostMapping("/udiwms/inv/device/inspect/take/uploadDeviceTake")
public BaseResponse uploadDeviceTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) {
deviceInspectTaskEntity.setUpdateTime(new Date());
boolean falg = deviceInspectTaskService.updateById(deviceInspectTaskEntity);
if (deviceInspectTaskEntity.getStatus() == 2) {
UploadDeviceTake(deviceInspectTaskEntity.getId(), 1);
}
if (!falg) {
return ResultVOUtils.error(999, "更新失败");
}
return ResultVOUtils.success();
}
@PostMapping("/udiwms/inv/device/inspect/take/addDeviceInspecTake")
public BaseResponse addDeviceInspecTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) {
String orderId = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.DEVICE_INSPECT_PLAN_ORDER, "yyyyMMdd"));
deviceInspectTaskEntity.setOrderId(orderId);
deviceInspectTaskEntity.setCreateTime(new Date());
deviceInspectTaskService.addDeviceInspectTask(deviceInspectTaskEntity);
return ResultVOUtils.success(deviceInspectTaskEntity);
}
@PostMapping("/udiwms/inv/device/inspect/take/delectDeviceInspecTake")
public BaseResponse delectDeviceInspecTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) {
deviceInspectTaskService.delectDeviceInspectTask(deviceInspectTaskEntity);
deviceInspectTaskDetailService.remove(new QueryWrapper<DeviceInspectTaskDetailEntity>().eq("taskOrderIdFk", deviceInspectTaskEntity.getOrderId()));
UploadDeviceTake(deviceInspectTaskEntity.getId(), 3);
return ResultVOUtils.success(deviceInspectTaskEntity);
}
@Resource
HeartService heartService;
@Resource
SyncDataSetService syncDataSetService;
void UploadDeviceTake(Long id, Integer type) {
//提交上传到自助
//查询任务表
// DeviceInspectTaskEntity deviceInspectTaskEntity = deviceInspectTaskService.getById(id);
// List<DeviceInspectTaskDetailEntity> deviceInspectTaskDetailEntityList = deviceInspectTaskDetailService
// .list(new QueryWrapper<DeviceInspectTaskDetailEntity>().eq("taskOrderIdFk", deviceInspectTaskEntity.getOrderId()));
// SpsSyncDeviceTakeResponse spsSyncDeviceTakeResponse = new SpsSyncDeviceTakeResponse();
// spsSyncDeviceTakeResponse.setDeviceInspectTaskEntity(deviceInspectTaskEntity);
// spsSyncDeviceTakeResponse.setDeviceInspectTaskDetailEntityList(deviceInspectTaskDetailEntityList);
// spsSyncDeviceTakeResponse.setType(type);
// spGetHttpClient.postAllDeviceTake(spsSyncDeviceTakeResponse);
SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet();
ThreadUtil.execAsync(() -> {
try {
heartService.pushData(syncDataSetEntity, null, BasicExportTypeEnum.DEVICE_TASK);
} catch (Exception e) {
log.error(ExceptionUtils.getStackTrace(e));
e.printStackTrace();
}
});
}
//------------------------------------------ 详情方法--------------------------------------------------------------//
@GetMapping("/udiwms/inv/device/inspect/take/detail/selectDeviceInspecTakeDetail")
public BaseResponse selectDeviceInspecTakeDetail(DeviceInspectTaskDetailEntity deviceInspectTaskDetailEntity) {
List<DeviceInspectTaskDetailEntity> deviceInspectPlanDelectEntityList = deviceInspectTaskDetailService.selectDeviceInspectTakeDetail(deviceInspectTaskDetailEntity);
return ResultVOUtils.success(deviceInspectPlanDelectEntityList);
}
@PostMapping("/udiwms/inv/device/inspect/take/detail/uploadDeviceInspecTakeDetail")
public BaseResponse uploadDeviceInspecTakeDetail(@RequestBody DeviceInspectTaskDetailEntity deviceInspectTaskDetailEntity) {
deviceInspectTaskDetailEntity.setUpdateTime(new Date());
boolean falg = deviceInspectTaskDetailService.uploadDeviceInspecTakeDetail(deviceInspectTaskDetailEntity);
if (!falg) {
return ResultVOUtils.error(999, "更新失败");
}
return ResultVOUtils.success();
}
@PostMapping("/udiwms/inv/device/inspect/take/detail/addDeviceInspecTakeDetail")
public BaseResponse addDeviceInspecTakeDetail(@RequestBody DeviceInspectTaskDetailEntity deviceInspectTaskDetailEntity) {
boolean falg = deviceInspectTaskDetailService.addDeviceInspectTaskDelect(deviceInspectTaskDetailEntity);
if (!falg) {
return ResultVOUtils.error(999, "更新失败");
}
return ResultVOUtils.success();
}
@GetMapping("/udiwms/inv/device/inspect/take/detail/delectDeviceInspecTakeDetail")
public BaseResponse delecttDeviceInspecTakeDetail(String id) {
boolean falg = deviceInspectTaskDetailService.removeById(id);
if (!falg) {
return ResultVOUtils.error(999, "删除失败");
}
return ResultVOUtils.success();
}
}