You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
3.3 KiB
Java
88 lines
3.3 KiB
Java
6 months ago
|
package com.glxp.api.service.collect;
|
||
|
|
||
|
import cn.hutool.json.JSONUtil;
|
||
|
import com.alibaba.fastjson.JSONObject;
|
||
|
import com.alibaba.fastjson.TypeReference;
|
||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||
|
import com.github.pagehelper.PageHelper;
|
||
|
import com.glxp.api.common.res.BaseResponse;
|
||
|
import com.glxp.api.dao.collect.IoCollectLedGroupMapper;
|
||
|
import com.glxp.api.entity.collect.IoCollectLedGroup;
|
||
|
import com.glxp.api.entity.collect.IoCollectOrderBiz;
|
||
|
import com.glxp.api.entity.thrsys.CodeRel;
|
||
|
import com.glxp.api.enums.led.LedColorStatusEnum;
|
||
|
import com.glxp.api.exception.JsonException;
|
||
|
import com.glxp.api.req.collect.CollectLedGroupRequest;
|
||
|
import com.glxp.api.res.collect.IoCollectLedGroupResponse;
|
||
|
import com.glxp.api.util.OkHttpCli;
|
||
|
import org.springframework.stereotype.Service;
|
||
|
|
||
|
import javax.annotation.Resource;
|
||
|
import java.util.Collections;
|
||
|
import java.util.List;
|
||
|
|
||
|
/**
|
||
|
* @author : zhuzhu
|
||
|
* @date : 2024/12/30 10:47
|
||
|
* @modyified By :
|
||
|
*/
|
||
|
|
||
|
@Service
|
||
|
public class IoCollectLedGroupService extends ServiceImpl<IoCollectLedGroupMapper, IoCollectLedGroup> {
|
||
|
|
||
|
@Resource
|
||
|
IoCollectLedGroupMapper ioCollectLedGroupMapper;
|
||
|
|
||
|
@Resource
|
||
|
private OkHttpCli okHttpCli;
|
||
|
|
||
|
|
||
|
public List<IoCollectLedGroupResponse> filterList(CollectLedGroupRequest collectLedGroupRequest) {
|
||
|
if (collectLedGroupRequest == null) {
|
||
|
return Collections.emptyList();
|
||
|
}
|
||
|
if (collectLedGroupRequest.getPage() != null) {
|
||
|
int offset = (collectLedGroupRequest.getPage() - 1) * collectLedGroupRequest.getLimit();
|
||
|
PageHelper.offsetPage(offset, collectLedGroupRequest.getLimit());
|
||
|
}
|
||
|
return ioCollectLedGroupMapper.filterList(collectLedGroupRequest);
|
||
|
}
|
||
|
|
||
|
|
||
|
public BaseResponse<String> openLed(IoCollectOrderBiz collectOrderBiz) {
|
||
|
IoCollectLedGroup one = getOne(new LambdaQueryWrapper<IoCollectLedGroup>().eq(IoCollectLedGroup::getRelId, collectOrderBiz.getRelId()));
|
||
|
if (one == null){
|
||
|
throw new JsonException(500,"当前产品未绑定灯组");
|
||
|
}
|
||
|
CollectLedGroupRequest collectLedGroupRequest = new CollectLedGroupRequest();
|
||
|
collectLedGroupRequest.setMac(one.getMac());
|
||
|
collectLedGroupRequest.setTimeout(one.getTimeout());
|
||
|
if (one.getLedMode()){
|
||
|
collectLedGroupRequest.setLedmode(1);
|
||
|
}else {
|
||
|
collectLedGroupRequest.setLedmode(0);
|
||
|
}
|
||
|
collectLedGroupRequest.setLednum(setLedNum(one));
|
||
|
String json = JSONUtil.toJsonStr(collectLedGroupRequest);
|
||
|
String result = okHttpCli.doPostJson( "http://192.168.0.166:9099/wms/associate/lighttagsled", json);
|
||
|
BaseResponse<String> response =
|
||
|
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
|
||
|
});
|
||
|
return response;
|
||
|
}
|
||
|
|
||
|
private Integer setLedNum(IoCollectLedGroup ioCollectLedGroup) {
|
||
|
if (!ioCollectLedGroup.getRed()) {
|
||
|
return LedColorStatusEnum.RED_FALSE.getReturnValue();
|
||
|
}
|
||
|
if (!ioCollectLedGroup.getOrange()) {
|
||
|
return LedColorStatusEnum.ORANGE_FALSE.getReturnValue();
|
||
|
}
|
||
|
if (!ioCollectLedGroup.getBlue()) {
|
||
|
return LedColorStatusEnum.BLUE_FALSE.getReturnValue();
|
||
|
}
|
||
|
return LedColorStatusEnum.DEFAULT.getReturnValue();
|
||
|
}
|
||
|
}
|