小程序 生成投递|清运单优化

master
guochaojie 4 months ago
parent 54d1638601
commit 57ab494336

@ -317,7 +317,7 @@ public class DeviceController {
private String uploadImages(List<Snap> snaps) {
List<FileUploadRespVO> list = new ArrayList<>();
if (null == list || list.size() == 0) {
if (null == snaps || snaps.size() == 0) {
log.error("上传图片失败,图片列表为空!!!");
return "";
}
@ -782,11 +782,26 @@ public class DeviceController {
return CommonResult.success(bucketCode, "success");
}
@ApiOperation("控制柜接口 实时重量上传")
@ApiOperation("控制柜接口 重量上传")
@PostMapping("/weight")
public CommonResult<String> weight(@RequestBody WeightVO weight) {
String deviceCode = weight.getDeviceCode();
String bucketCode = weight.getBucketCode();
// String orderNo = weight.getOrderNo();
// BigDecimal _weight = weight.getWeight();
// if (StrUtil.isEmpty(orderNo)) {
// RecycleBucket bucket = bucketService.getByBucketCode(bucketCode);
// if (bucket != null) {
// BigDecimal currentWeight = bucket.getCurrentWeight();
// if (null != currentWeight && currentWeight.compareTo(_weight) < 0) {
// bucket.setCurrentWeight(_weight);
// bucketService.updateById(bucket);
// log.info("更新桶重量:{},更新前:{},更新后:{}", bucketCode, currentWeight, _weight);
// }
// }
// } else {
//
// }
StringBuilder key = new StringBuilder();
key.append("weight_").append(deviceCode).append("_").append(bucketCode);
redisTool.setValue(key.toString(), JSONUtil.toJsonStr(weight), 1000 * 60L);//一分钟过期
@ -902,22 +917,38 @@ public class DeviceController {
String adjustSet = config.getDeliveryAdjustSet();
RecycleDeliveryOrder order = BeanUtils.copyBean(delivery, RecycleDeliveryOrder.class);
// 投递完成 更新桶状态
BigDecimal currentWeight = bucket.getCurrentWeight();
BigDecimal price = calculatePrice(bucket, config);
BigDecimal weight = delivery.getReportWeight();
BigDecimal money = weight.multiply(price).setScale(2, BigDecimal.ROUND_HALF_UP);
//桶身信息
order.setOriginalWeight(currentWeight);
order.setPrice(price);
order.setTotalPrice(money);
order.setProductCode(bucket.getProductCode());
order.setProductSubCode(bucket.getProductSubCode());
order.setDoorNum(bucket.getDoorNum());
order.setBagNo(bucket.getBagNo());
order.setDeliverId(user.getId());
order.setPhone(user.getPhone());
order.setCleanStatus(0);//清运状态
order.setCreatorUserId(user.getId());
order.setCreatorTime(new Date());
//抓拍信息
Object value = redisTool.getValue(orderNo);
if (null != value) {
order.setPhoto(value.toString());
}
//用户信息
order.setCreatorTime(new Date());
order.setCreatorUserId(user.getId());
order.setLoginType("2");//扫码登录
order.setCleanStatus(0);//清运状态
//审核信息
order.setAdjustSet(Integer.valueOf(adjustSet));
if ("1".equals(adjustSet)) {//自动审核
order.setAdjustStatus(1);
order.setAdjustWeight(delivery.getReportWeight());
order.setAdjustPrice(delivery.getTotalPrice());
order.setAdjustPrice(money);
order.setAdjustComm("自动审核");
} else {//手动审核
order.setAdjustSet(Integer.valueOf(adjustSet));
@ -926,16 +957,19 @@ public class DeviceController {
order.setAdjustPrice(BigDecimal.ZERO);
order.setAdjustComm("");
}
boolean save = deliveryOrderService.save(order);
if (save) {
// 投递完成 更新桶状态
BigDecimal currentWeight = bucket.getCurrentWeight();
if (null != currentWeight) {
currentWeight = currentWeight.add(delivery.getReportWeight());
currentWeight = currentWeight.add(weight);
bucket.setCurrentWeight(currentWeight);
bucketService.updateById(bucket);
log.info("投递成功更新桶重量,桶编号:{},当前重量:{}", bucketCode, currentWeight);
if (null != value) {
redisTool.deleteKey(orderNo);//删除缓存的图片
log.info("删除缓存的图片,单号:{},图片信息:{}", orderNo, value);
}
}
} else {
return CommonResult.error(400, "投递单保存失败!");
@ -959,6 +993,21 @@ public class DeviceController {
if (null != value) {
order.setPhoto(value.toString());
}
BigDecimal price = calculatePrice(bucket, config);
BigDecimal weight = clean.getWeight();
BigDecimal money = price.multiply(weight).setScale(2, BigDecimal.ROUND_HALF_UP);
//回收类目信息
UserDTO user = UserContext.getUser();
order.setProductCode(bucket.getProductCode());
order.setProductSubCode(bucket.getProductSubCode());
order.setDoorNum(null != bucket.getDoorNum() ? "" + bucket.getDoorNum() : "");
order.setPrice(price);
order.setTotalPrice(money);
order.setBagNo(bucket.getBagNo());
order.setCleanUserId(user.getId());
order.setPhone(user.getPhone());
order.setCreatorUserId(user.getId());
order.setCreatorTime(new Date());
//审核信息
order.setAdjustSet(Integer.valueOf(adjustSet));
if ("1".equals(adjustSet)) {
@ -966,7 +1015,7 @@ public class DeviceController {
order.setAdjustComm("自动审核");
order.setEntryStatus(1);//已入库
order.setAdjustWeight(clean.getWeight());
order.setAdjustPrice(clean.getTotalPrice());
order.setAdjustPrice(money);
} else {
order.setAdjustStatus(0);
order.setAdjustComm("");
@ -978,9 +1027,11 @@ public class DeviceController {
if (save) {
bucket.setCurrentWeight(BigDecimal.ZERO);
bucketService.updateById(bucket);
if (null != value)
if (null != value) {
redisTool.deleteKey(orderNo);//删除缓存的图片
}else {
log.info("删除缓存的图片,单号:{},图片信息:{}", orderNo, value);
}
} else {
return CommonResult.error(400, "清运单保存失败!");
}
return CommonResult.success("清运单保存成功!", "success");

@ -14,28 +14,10 @@ public class CleanOrder {
private String deviceCode;
@ApiModelProperty("桶编码")
private String bucketCode;
@ApiModelProperty("门号")
private String doorNum;
@ApiModelProperty("回收大类")
private String productCode;
@ApiModelProperty("回收子类")
private String productSubCode;
@ApiModelProperty("单价")
private BigDecimal price;
@ApiModelProperty("所属公司")
private String companyId;
@ApiModelProperty("重量")
private BigDecimal weight;
@ApiModelProperty("本单金额")
private BigDecimal totalPrice;
@ApiModelProperty("清运员用户id")
private String cleanUserId;
@ApiModelProperty("清运员手机号")
private String phone;
@ApiModelProperty("垃圾袋编号")
private String bagNo;
@ApiModelProperty("抓拍照片")
private String photo;
@ApiModelProperty("公司id")
private String companyId;
@ApiModelProperty("开始时间")
private Date startTime;
@ApiModelProperty("完成时间")

@ -16,26 +16,8 @@ public class DeliveryOrder {
private String deviceCode;
@ApiModelProperty("桶编号")
private String bucketCode;
@ApiModelProperty("门号")
private Integer doorNum;
@ApiModelProperty("垃圾袋编号")
private String bagNo;
@ApiModelProperty("桶内原重")
private BigDecimal originalWeight;
@ApiModelProperty("上报重量")
private BigDecimal reportWeight;
@ApiModelProperty("回收大类")
private String productCode;
@ApiModelProperty("回收子类")
private String productSubCode;
@ApiModelProperty("单价")
private BigDecimal price;
@ApiModelProperty("总价")
private BigDecimal totalPrice;
@ApiModelProperty("投递员id")
private String deliverId;
@ApiModelProperty("投递员手机")
private String phone;
@ApiModelProperty("公司id")
private String companyId;
@ApiModelProperty("开始时间")

Loading…
Cancel
Save