|
|
@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
@ -380,15 +381,20 @@ public class DeviceController {
|
|
|
|
@PostMapping("/delivery")
|
|
|
|
@PostMapping("/delivery")
|
|
|
|
@ApiOperation("投递订单上传")
|
|
|
|
@ApiOperation("投递订单上传")
|
|
|
|
public CommonResult<String> delivery(@RequestBody DeliveryOrderVO orderVO) {
|
|
|
|
public CommonResult<String> delivery(@RequestBody DeliveryOrderVO orderVO) {
|
|
|
|
RecycleDevice device = deviceService.getByDeviceCode(orderVO.getDeviceCode());
|
|
|
|
RecycleDeliveryOrder exist = deliveryOrderService.getByDeviceOrderNo(orderVO.getDeviceOrderNo());
|
|
|
|
|
|
|
|
if (null != exist) {
|
|
|
|
|
|
|
|
return CommonResult.success(orderVO.getDeviceOrderNo(), "success,订单已上传!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RecycleDevice device = deviceService.getByDeviceCode(orderVO.getDeviceCode());
|
|
|
|
if (null == device || StrUtil.isEmpty(device.getBeLongCompanyId())) {
|
|
|
|
if (null == device || StrUtil.isEmpty(device.getBeLongCompanyId())) {
|
|
|
|
throw new BizIllegalException("上传失败:根据设备编号,未查询到设备信息!!");
|
|
|
|
throw new BizIllegalException("上传失败:根据设备编号,未查询到设备信息!!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RecycleDeliveryOrder exist = deliveryOrderService.getByDeviceOrderNo(orderVO.getDeviceOrderNo());
|
|
|
|
RecycleBucket bucket = bucketService.getByBucketCode(orderVO.getBucketCode());
|
|
|
|
if (null != exist) {
|
|
|
|
if (null == bucket) {
|
|
|
|
return CommonResult.success(orderVO.getDeviceOrderNo(), "success,订单已上传!");
|
|
|
|
throw new BizIllegalException("上传失败:根据桶编号,未查询到桶信息!!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String companyId = device.getBeLongCompanyId();
|
|
|
|
String companyId = device.getBeLongCompanyId();
|
|
|
|
//查询配置
|
|
|
|
//查询配置
|
|
|
|
RecycleDeviceConfig config = configService.getByCompanyId(companyId);
|
|
|
|
RecycleDeviceConfig config = configService.getByCompanyId(companyId);
|
|
|
@ -451,7 +457,19 @@ public class DeviceController {
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RecycleBucket entity = new RecycleBucket();
|
|
|
|
|
|
|
|
entity.setId(bucket.getId());
|
|
|
|
|
|
|
|
entity.setCurrentWeight(BigDecimal.ZERO);
|
|
|
|
|
|
|
|
BigDecimal currentWeight = bucket.getCurrentWeight();
|
|
|
|
|
|
|
|
if (currentWeight == null || currentWeight.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
|
|
|
entity.setCurrentWeight(orderVO.getWeight());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
entity.setCurrentWeight(currentWeight.add(orderVO.getWeight()).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
deliveryOrderService.settlement(order);
|
|
|
|
deliveryOrderService.settlement(order);
|
|
|
|
|
|
|
|
bucketService.updateById(entity);//更新桶内当前重量
|
|
|
|
return CommonResult.success(orderVO.getDeviceOrderNo());
|
|
|
|
return CommonResult.success(orderVO.getDeviceOrderNo());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -459,19 +477,24 @@ public class DeviceController {
|
|
|
|
@PostMapping("/clean")
|
|
|
|
@PostMapping("/clean")
|
|
|
|
@ApiOperation("清运订单上传")
|
|
|
|
@ApiOperation("清运订单上传")
|
|
|
|
public CommonResult<String> clean(@RequestBody CleanOrderVO orderVO) {
|
|
|
|
public CommonResult<String> clean(@RequestBody CleanOrderVO orderVO) {
|
|
|
|
RecycleDevice device = deviceService.getByDeviceCode(orderVO.getDeviceCode());
|
|
|
|
|
|
|
|
if (null == device) {
|
|
|
|
|
|
|
|
throw new BizIllegalException("上传失败:根据设备编号,未查询到设备信息!!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//判断是否重复上传
|
|
|
|
//判断是否重复上传
|
|
|
|
RecycleCleanOrder exist = cleanOrderService.getByDeviceOrderNo(orderVO.getDeviceOrderNo());
|
|
|
|
RecycleCleanOrder exist = cleanOrderService.getByDeviceOrderNo(orderVO.getDeviceOrderNo());
|
|
|
|
if (exist != null) {
|
|
|
|
if (exist != null) {
|
|
|
|
return CommonResult.success(orderVO.getDeviceOrderNo(), "success,订单已上传!");
|
|
|
|
return CommonResult.success(orderVO.getDeviceOrderNo(), "success,订单已上传!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RecycleDevice device = deviceService.getByDeviceCode(orderVO.getDeviceCode());
|
|
|
|
|
|
|
|
if (null == device) {
|
|
|
|
|
|
|
|
throw new BizIllegalException("上传失败:根据设备编号,未查询到设备信息!!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//查询桶
|
|
|
|
|
|
|
|
RecycleBucket bucket = bucketService.getByBucketCode(orderVO.getBucketCode());
|
|
|
|
|
|
|
|
if (null == bucket) {
|
|
|
|
|
|
|
|
throw new BizIllegalException("上传失败:根据桶编号,未查询到桶信息!!");
|
|
|
|
|
|
|
|
}
|
|
|
|
//查询配置
|
|
|
|
//查询配置
|
|
|
|
RecycleDeviceConfig config = configService.getByCompanyId(device.getBeLongCompanyId());
|
|
|
|
RecycleDeviceConfig config = configService.getByCompanyId(device.getBeLongCompanyId());
|
|
|
|
String adjustSet = config.getCleanAdjustSet();//审核配置
|
|
|
|
String adjustSet = config.getCleanAdjustSet();//审核配置
|
|
|
|
//查询桶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RecycleCleanOrder order = new RecycleCleanOrder();
|
|
|
|
RecycleCleanOrder order = new RecycleCleanOrder();
|
|
|
|
order.setOrderNo(CommonUtil.getIdNumber(BusinessCodeEnum.CLEAN.getCode()));
|
|
|
|
order.setOrderNo(CommonUtil.getIdNumber(BusinessCodeEnum.CLEAN.getCode()));
|
|
|
@ -524,6 +547,12 @@ public class DeviceController {
|
|
|
|
order.setPhone(orderVO.getPhone());
|
|
|
|
order.setPhone(orderVO.getPhone());
|
|
|
|
order.setCompanyId(device.getBeLongCompanyId());
|
|
|
|
order.setCompanyId(device.getBeLongCompanyId());
|
|
|
|
cleanOrderService.save(order);
|
|
|
|
cleanOrderService.save(order);
|
|
|
|
|
|
|
|
//桶内重量清零
|
|
|
|
|
|
|
|
RecycleBucket entity = new RecycleBucket();
|
|
|
|
|
|
|
|
entity.setId(bucket.getId());
|
|
|
|
|
|
|
|
entity.setCurrentWeight(BigDecimal.ZERO);
|
|
|
|
|
|
|
|
bucketService.updateById(entity);
|
|
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(orderVO.getDeviceOrderNo());
|
|
|
|
return CommonResult.success(orderVO.getDeviceOrderNo());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|