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