|
|
|
package com.glxp.api.service.collect;
|
|
|
|
|
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
|
|
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.basic.SysWorkplaceQueue;
|
|
|
|
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.req.collect.LedGroupRequest;
|
|
|
|
import com.glxp.api.res.collect.IoCollectLedGroupResponse;
|
|
|
|
import com.glxp.api.service.basic.SysWorkplaceQueueService;
|
|
|
|
import com.glxp.api.util.IntUtil;
|
|
|
|
import com.glxp.api.util.OkHttpCli;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
SysWorkplaceQueueService sysWorkplaceQueueService;
|
|
|
|
|
|
|
|
public BaseResponse<String> openLed(List<IoCollectOrderBiz> collectOrderBizs) {
|
|
|
|
LedGroupRequest ledGroupRequest = new LedGroupRequest();
|
|
|
|
for (IoCollectOrderBiz collectOrderBiz : collectOrderBizs) {
|
|
|
|
|
|
|
|
SysWorkplaceQueue sysWorkplaceQueue = sysWorkplaceQueueService.getOne(new LambdaQueryWrapper<SysWorkplaceQueue>().eq(SysWorkplaceQueue::getRelId, collectOrderBiz.getRelId()).last("limit 1"));
|
|
|
|
if (sysWorkplaceQueue == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
IoCollectLedGroup
|
|
|
|
one = getOne(new LambdaQueryWrapper<IoCollectLedGroup>().eq(IoCollectLedGroup::getMac, sysWorkplaceQueue.getMac()));
|
|
|
|
if (one == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
CollectLedGroupRequest collectLedGroupRequest = new CollectLedGroupRequest();
|
|
|
|
collectLedGroupRequest.setMac(one.getMac());
|
|
|
|
collectLedGroupRequest.setTimeout(one.getTimeout());
|
|
|
|
collectLedGroupRequest.setLedmode(1);
|
|
|
|
collectLedGroupRequest.setLednum(setLedNum(one));
|
|
|
|
if (collectLedGroupRequest.getLednum() == 1) {
|
|
|
|
one.setRed(collectOrderBiz.getId());
|
|
|
|
} else if (collectLedGroupRequest.getLednum() == 2) {
|
|
|
|
one.setOrange(collectOrderBiz.getId());
|
|
|
|
} else if (collectLedGroupRequest.getLednum() == 3) {
|
|
|
|
one.setBlue(collectOrderBiz.getId());
|
|
|
|
} else if (collectLedGroupRequest.getLednum() == 4) {
|
|
|
|
one.setGreen(collectOrderBiz.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
collectOrderBiz.setQueueCode(sysWorkplaceQueue.getCode());
|
|
|
|
collectOrderBiz.setLedNum(collectLedGroupRequest.getLednum());
|
|
|
|
ledGroupRequest.getData().add(collectLedGroupRequest);
|
|
|
|
updateById(one);
|
|
|
|
}
|
|
|
|
|
|
|
|
// http://192.168.0.166:9099/wms/associate/lighttagsled
|
|
|
|
|
|
|
|
String json = JSONUtil.toJsonStr(ledGroupRequest);
|
|
|
|
log.error("json:{}" + json);
|
|
|
|
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 (IntUtil.value(ioCollectLedGroup.getRed()) == 0) {
|
|
|
|
return LedColorStatusEnum.RED_FALSE.getReturnValue();
|
|
|
|
}
|
|
|
|
if (IntUtil.value(ioCollectLedGroup.getOrange()) == 0) {
|
|
|
|
return LedColorStatusEnum.ORANGE_FALSE.getReturnValue();
|
|
|
|
}
|
|
|
|
if (IntUtil.value(ioCollectLedGroup.getBlue()) == 0) {
|
|
|
|
return LedColorStatusEnum.BLUE_FALSE.getReturnValue();
|
|
|
|
}
|
|
|
|
if (IntUtil.value(ioCollectLedGroup.getBlue()) == 0) {
|
|
|
|
return LedColorStatusEnum.DEFAULT.getReturnValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
return LedColorStatusEnum.DEFAULT.getReturnValue();
|
|
|
|
}
|
|
|
|
}
|