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.
udi-wms-java/src/main/java/com/glxp/api/service/collect/IoCollectLedGroupService.java

123 lines
5.0 KiB
Java

6 months ago
package com.glxp.api.service.collect;
import cn.hutool.core.thread.ThreadUtil;
6 months ago
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;
6 months ago
import com.glxp.api.entity.basic.SysWorkplaceQueue;
6 months ago
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;
6 months ago
import com.glxp.api.res.collect.IoCollectLedGroupResponse;
6 months ago
import com.glxp.api.service.basic.SysWorkplaceQueueService;
import com.glxp.api.util.IntUtil;
6 months ago
import com.glxp.api.util.OkHttpCli;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
6 months ago
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);
}
6 months ago
@Resource
SysWorkplaceQueueService sysWorkplaceQueueService;
6 months ago
public BaseResponse<String> openLed(List<IoCollectOrderBiz> collectOrderBizs) {
LedGroupRequest ledGroupRequest = new LedGroupRequest();
6 months ago
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());
6 months ago
collectLedGroupRequest.setLedmode(1);
collectLedGroupRequest.setLednum(setLedNum(one));
6 months ago
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());
}
6 months ago
collectOrderBiz.setQueueCode(sysWorkplaceQueue.getCode());
collectOrderBiz.setLedNum(collectLedGroupRequest.getLednum());
ledGroupRequest.getData().add(collectLedGroupRequest);
6 months ago
updateById(one);
6 months ago
}
6 months ago
// http://192.168.0.166:9099/wms/associate/lighttagsled
String json = JSONUtil.toJsonStr(ledGroupRequest);
6 months ago
log.error("json:{}" + json);
String result = okHttpCli.doPostJson("http://192.168.0.166:9099/wms/associate/lighttagsled", json);
6 months ago
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
return response;
}
private Integer setLedNum(IoCollectLedGroup ioCollectLedGroup) {
6 months ago
if (IntUtil.value(ioCollectLedGroup.getRed()) == 0) {
6 months ago
return LedColorStatusEnum.RED_FALSE.getReturnValue();
}
6 months ago
if (IntUtil.value(ioCollectLedGroup.getOrange()) == 0) {
6 months ago
return LedColorStatusEnum.ORANGE_FALSE.getReturnValue();
}
6 months ago
if (IntUtil.value(ioCollectLedGroup.getBlue()) == 0) {
6 months ago
return LedColorStatusEnum.BLUE_FALSE.getReturnValue();
}
6 months ago
if (IntUtil.value(ioCollectLedGroup.getBlue()) == 0) {
return LedColorStatusEnum.DEFAULT.getReturnValue();
}
return LedColorStatusEnum.DEFAULT.getReturnValue();
6 months ago
}
}