master
guochaojie 4 months ago
parent 314dd86db7
commit e8c1da2c03

@ -7,7 +7,6 @@ import cc.yunxi.common.utils.CommonUtil;
import cc.yunxi.domain.dto.UserDTO; import cc.yunxi.domain.dto.UserDTO;
import cc.yunxi.domain.po.*; import cc.yunxi.domain.po.*;
import cc.yunxi.domain.vo.device.*; import cc.yunxi.domain.vo.device.*;
import cc.yunxi.domain.vo.file.FileUploadReqVO;
import cc.yunxi.domain.vo.file.FileUploadRespVO; import cc.yunxi.domain.vo.file.FileUploadRespVO;
import cc.yunxi.enums.BusinessCodeEnum; import cc.yunxi.enums.BusinessCodeEnum;
import cc.yunxi.service.*; import cc.yunxi.service.*;
@ -17,12 +16,14 @@ import cc.yunxi.utils.UserContext;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
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;
@ -108,7 +109,7 @@ public class DeviceController {
_bucket.put("productCode", bucket.getProductCode());//产品大类 _bucket.put("productCode", bucket.getProductCode());//产品大类
_bucket.put("productSubCode", bucket.getProductSubCode());//产品子类 _bucket.put("productSubCode", bucket.getProductSubCode());//产品子类
_bucket.put("isShow", bucket.getIsShow());//是否显示 _bucket.put("isShow", bucket.getIsShow());//是否显示
_bucket.put("status", bucket.getStatus());// _bucket.put("status", bucket.getStatus());//是否启用
_bucket.put("showName", bucket.getShowName());//显示名称 _bucket.put("showName", bucket.getShowName());//显示名称
_bucket.put("bucketImg", JSONUtil.parseArray(bucket.getBucketImg()));//桶身图片 _bucket.put("bucketImg", JSONUtil.parseArray(bucket.getBucketImg()));//桶身图片
BigDecimal price = calculatePrice(bucket, config);//综合计算价格 BigDecimal price = calculatePrice(bucket, config);//综合计算价格
@ -124,6 +125,17 @@ public class DeviceController {
} }
_bucket.put("closeDelay", bucket.getCloseDelay());//关门时延 _bucket.put("closeDelay", bucket.getCloseDelay());//关门时延
_bucket.put("bagNo", bucket.getBagNo());//垃圾袋编号 _bucket.put("bagNo", bucket.getBagNo());//垃圾袋编号
/********************************配置继承自机构************************************/
Integer smogSet = bucket.getSmogSet();
Integer fullSet = bucket.getFullSet();
Integer delay = bucket.getCloseDelay();
BigDecimal weight1 = bucket.getWarningWeight();
if (smogSet < 0) _bucket.put("smogSet", Integer.valueOf(config.getSmogSet()));
if (fullSet < 0) _bucket.put("fullSet", Integer.valueOf(config.getFullSet()));
if (delay < 0) _bucket.put("closeDelay", config.getCloseDelay());
if (weight1.compareTo(BigDecimal.ZERO) < 0) _bucket.put("warningWeight", config.getWarningWeight());
/***********************************************************************/
list.add(_bucket); list.add(_bucket);
} }
result.put("bucketList", list); result.put("bucketList", list);
@ -134,7 +146,7 @@ public class DeviceController {
//获取设备配置 //获取设备配置
@PostMapping("/conf") @PostMapping("/conf")
@ApiOperation("机柜获取设备配置") @ApiOperation("机柜获取设备配置")
public CommonResult<DeviceRespVO> conf(@RequestBody DeviceVO deviceVO, HttpServletRequest request) { public CommonResult<DeviceRespVO> conf(@RequestBody DeviceVO deviceVO) {
CommonResult<DeviceRespVO> result = new CommonResult<>(); CommonResult<DeviceRespVO> result = new CommonResult<>();
DeviceRespVO respVO = new DeviceRespVO(); DeviceRespVO respVO = new DeviceRespVO();
@ -166,6 +178,7 @@ public class DeviceController {
//宣传配置 //宣传配置
respVO.setPromotionSet(config.getPromotionSet()); respVO.setPromotionSet(config.getPromotionSet());
respVO.setSlogan(config.getPromotionSlogans()); respVO.setSlogan(config.getPromotionSlogans());
respVO.setCompanyId(device.getBeLongCompanyId());
String pics = config.getPromotionPic1(); String pics = config.getPromotionPic1();
fillPoster(pics, respVO); fillPoster(pics, respVO);
result.setData(respVO); result.setData(respVO);
@ -191,6 +204,19 @@ public class DeviceController {
_bucket.setTotalWeightLimit(bucket.getWarningWeight()); _bucket.setTotalWeightLimit(bucket.getWarningWeight());
_bucket.setSmokeAlarm(bucket.getSmogSet()); _bucket.setSmokeAlarm(bucket.getSmogSet());
_bucket.setFullAlarm(bucket.getFullSet()); _bucket.setFullAlarm(bucket.getFullSet());
_bucket.setBagNo(bucket.getBagNo());
_bucket.setCloseDelay(bucket.getCloseDelay());
/********************************配置继承自机构************************************/
Integer smogSet = bucket.getSmogSet();
Integer fullSet = bucket.getFullSet();
Integer delay = bucket.getCloseDelay();
BigDecimal weight = bucket.getWarningWeight();
if (smogSet < 0) _bucket.setSmokeAlarm(Integer.valueOf(config.getSmogSet()));
if (fullSet < 0) _bucket.setFullAlarm(Integer.valueOf(config.getFullSet()));
if (delay < 0) _bucket.setCloseDelay(config.getCloseDelay());
if (weight.compareTo(BigDecimal.ZERO) < 0) _bucket.setTotalWeightLimit(config.getWarningWeight());
/***********************************************************************/
String bucketImg = bucket.getBucketImg(); String bucketImg = bucket.getBucketImg();
List<FileUploadRespVO> img = JSONUtil.toList(bucketImg, FileUploadRespVO.class); List<FileUploadRespVO> img = JSONUtil.toList(bucketImg, FileUploadRespVO.class);
if (img.size() > 0) { if (img.size() > 0) {
@ -293,6 +319,10 @@ public class DeviceController {
private String uploadImages(List<Snap> snaps) { private String uploadImages(List<Snap> snaps) {
List<FileUploadRespVO> list = new ArrayList<>(); List<FileUploadRespVO> list = new ArrayList<>();
if(null==list||list.size()==0){
log.error("上传图片失败,图片列表为空!!!");
return "";
}
for (Snap snap : snaps) { for (Snap snap : snaps) {
FileUploadRespVO uploadRespVO = fileService.uploadImage(snap.getImage(), snap.getFileName()); FileUploadRespVO uploadRespVO = fileService.uploadImage(snap.getImage(), snap.getFileName());
list.add(uploadRespVO); list.add(uploadRespVO);
@ -389,7 +419,6 @@ public class DeviceController {
order.setAdjustPrice(BigDecimal.ZERO); order.setAdjustPrice(BigDecimal.ZERO);
order.setAdjustComm(""); order.setAdjustComm("");
} }
order.setBagNo(orderVO.getBagNo());
order.setDeliverId(orderVO.getUserId()); order.setDeliverId(orderVO.getUserId());
order.setPhone(orderVO.getPhone()); order.setPhone(orderVO.getPhone());
// 上传照片 // 上传照片
@ -398,6 +427,13 @@ public class DeviceController {
order.setPhoto(photos); order.setPhoto(photos);
order.setCompanyId(companyId);//绑定订单对应商户 order.setCompanyId(companyId);//绑定订单对应商户
order.setLoginType(orderVO.getLoginType()); order.setLoginType(orderVO.getLoginType());
if(StrUtil.isEmpty(orderVO.getLoginType()))order.setLoginType("2");//手机号登录
order.setCleanNo("");//清运单
order.setCleanerPhone("");//清运员手机
order.setCreatorUserId("");//清运员用户
order.setCleanStatus(0);//未清运
order.setCreatorUserId(orderVO.getUserId());
order.setCreatorTime(new Date());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try { try {
if (StrUtil.isNotEmpty(orderVO.getStarTime())) { if (StrUtil.isNotEmpty(orderVO.getStarTime())) {
@ -415,13 +451,7 @@ public class DeviceController {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
boolean save = deliveryOrderService.save(order);
// 结算
if (save) {
deliveryOrderService.settlement(order); deliveryOrderService.settlement(order);
} else {
throw new BizIllegalException("上传失败:订单上传失败!!");
}
return CommonResult.success(orderVO.getDeviceOrderNo()); return CommonResult.success(orderVO.getDeviceOrderNo());
} }
@ -429,7 +459,6 @@ public class DeviceController {
@PostMapping("/clean") @PostMapping("/clean")
@ApiOperation("清运订单上传") @ApiOperation("清运订单上传")
public CommonResult<String> clean(@RequestBody CleanOrderVO orderVO) { public CommonResult<String> clean(@RequestBody CleanOrderVO orderVO) {
UserDTO user = UserContext.getUser();
RecycleDevice device = deviceService.getByDeviceCode(orderVO.getDeviceCode()); RecycleDevice device = deviceService.getByDeviceCode(orderVO.getDeviceCode());
if (null == device) { if (null == device) {
throw new BizIllegalException("上传失败:根据设备编号,未查询到设备信息!!"); throw new BizIllegalException("上传失败:根据设备编号,未查询到设备信息!!");
@ -507,7 +536,7 @@ public class DeviceController {
RecycleDeviceEvent event = new RecycleDeviceEvent(); RecycleDeviceEvent event = new RecycleDeviceEvent();
event.setDeviceCode(eventVO.getDeviceCode()); event.setDeviceCode(eventVO.getDeviceCode());
event.setPhone(eventVO.getPhone()); event.setPhone(eventVO.getPhone());
event.setIsLocal("0"); event.setIsLocal("1");//本地调用
event.setEventType(eventVO.getEventType()); event.setEventType(eventVO.getEventType());
String eventTime = eventVO.getEventTime(); String eventTime = eventVO.getEventTime();
if (StrUtil.isNotEmpty(eventTime)) { if (StrUtil.isNotEmpty(eventTime)) {
@ -520,8 +549,8 @@ public class DeviceController {
event.setBucketCode(eventVO.getBucketCode()); event.setBucketCode(eventVO.getBucketCode());
event.setOrderNo(eventVO.getOrderNum()); event.setOrderNo(eventVO.getOrderNum());
event.setOrderType(eventVO.getOrderType()); event.setOrderType(eventVO.getOrderType());
event.setCompanyId(device.getCompanyId()); event.setCompanyId(device.getBeLongCompanyId());//公司
event.setCreateUserId(eventVO.getUserId());//公司 event.setCreateUserId(eventVO.getUserId());
event.setCreateTime(new Date()); event.setCreateTime(new Date());
eventService.save(event); eventService.save(event);
return CommonResult.success("事件上报成功"); return CommonResult.success("事件上报成功");
@ -563,7 +592,7 @@ public class DeviceController {
event.setEventType(cmd.getCmd().getValue()); event.setEventType(cmd.getCmd().getValue());
event.setEventDesc("设备命令下发"); event.setEventDesc("设备命令下发");
event.setEventTime(new Date()); event.setEventTime(new Date());
event.setIsLocal("0");//远程调用 event.setIsLocal("2");//远程调用
event.setCreateUserId(null != user ? user.getId() : null); event.setCreateUserId(null != user ? user.getId() : null);
event.setCreateTime(new Date()); event.setCreateTime(new Date());
event.setCompanyId(device.getBeLongCompanyId()); event.setCompanyId(device.getBeLongCompanyId());

@ -82,6 +82,13 @@ public class DeviceRespVO {
@ApiModelProperty(value = "总限重", required = true, example = "1.00") @ApiModelProperty(value = "总限重", required = true, example = "1.00")
@NotNull(message = "总限重不能为空") @NotNull(message = "总限重不能为空")
private BigDecimal totalWeightLimit; private BigDecimal totalWeightLimit;
@ApiModelProperty(value = "关门时延", required = true, example = "30")
@NotNull(message = "关门时延")
private Integer closeDelay;
@ApiModelProperty(value = "垃圾袋编号", required = true, example = "B123321")
@NotBlank(message = "垃圾袋编号不能为空")
private String bagNo;
@ApiModelProperty(value = "桶身图片", required = true) @ApiModelProperty(value = "桶身图片", required = true)
@NotNull(message = "桶身图片不能为空") @NotNull(message = "桶身图片不能为空")
private String image; private String image;

@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -44,12 +45,14 @@ public class RecycleDeliveryOrderServiceImpl extends ServiceImpl<RecycleDelivery
} }
@Override @Override
@Transactional
public void settlement(RecycleDeliveryOrder order) { public void settlement(RecycleDeliveryOrder order) {
save(order);//保存订单
String client = order.getDeliverId(); String client = order.getDeliverId();
String orderNo = order.getOrderNo(); String orderNo = order.getOrderNo();
BigDecimal amount = order.getAdjustPrice(); BigDecimal amount = order.getAdjustPrice();
String companyId = order.getCompanyId(); String companyId = order.getCompanyId();
clientService.addBalance(client, amount, orderNo, companyId); clientService.addBalance(client, amount, orderNo, companyId);//结算
} }
@Override @Override

Loading…
Cancel
Save