更新桶内重量

master
guochaojie 4 months ago
parent ab3c130665
commit 14d46cf01d

@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -319,7 +320,7 @@ public class DeviceController {
private String uploadImages(List<Snap> snaps) {
List<FileUploadRespVO> list = new ArrayList<>();
if(null==list||list.size()==0){
if (null == list || list.size() == 0) {
log.error("上传图片失败,图片列表为空!!!");
return "";
}
@ -380,15 +381,20 @@ public class DeviceController {
@PostMapping("/delivery")
@ApiOperation("投递订单上传")
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())) {
throw new BizIllegalException("上传失败:根据设备编号,未查询到设备信息!!");
}
RecycleDeliveryOrder exist = deliveryOrderService.getByDeviceOrderNo(orderVO.getDeviceOrderNo());
if (null != exist) {
return CommonResult.success(orderVO.getDeviceOrderNo(), "success,订单已上传!");
RecycleBucket bucket = bucketService.getByBucketCode(orderVO.getBucketCode());
if (null == bucket) {
throw new BizIllegalException("上传失败:根据桶编号,未查询到桶信息!!");
}
String companyId = device.getBeLongCompanyId();
//查询配置
RecycleDeviceConfig config = configService.getByCompanyId(companyId);
@ -427,7 +433,7 @@ public class DeviceController {
order.setPhoto(photos);
order.setCompanyId(companyId);//绑定订单对应商户
order.setLoginType(orderVO.getLoginType());
if(StrUtil.isEmpty(orderVO.getLoginType()))order.setLoginType("2");//手机号登录
if (StrUtil.isEmpty(orderVO.getLoginType())) order.setLoginType("2");//手机号登录
order.setCleanNo("");//清运单
order.setCleanerPhone("");//清运员手机
order.setCreatorUserId("");//清运员用户
@ -451,7 +457,19 @@ public class DeviceController {
} catch (Exception e) {
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);
bucketService.updateById(entity);//更新桶内当前重量
return CommonResult.success(orderVO.getDeviceOrderNo());
}
@ -459,19 +477,24 @@ public class DeviceController {
@PostMapping("/clean")
@ApiOperation("清运订单上传")
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());
if (exist != null) {
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());
String adjustSet = config.getCleanAdjustSet();//审核配置
//查询桶
RecycleCleanOrder order = new RecycleCleanOrder();
order.setOrderNo(CommonUtil.getIdNumber(BusinessCodeEnum.CLEAN.getCode()));
@ -524,6 +547,12 @@ public class DeviceController {
order.setPhone(orderVO.getPhone());
order.setCompanyId(device.getBeLongCompanyId());
cleanOrderService.save(order);
//桶内重量清零
RecycleBucket entity = new RecycleBucket();
entity.setId(bucket.getId());
entity.setCurrentWeight(BigDecimal.ZERO);
bucketService.updateById(entity);
return CommonResult.success(orderVO.getDeviceOrderNo());
}

Loading…
Cancel
Save