tcp服务启动
This commit is contained in:
@@ -56,7 +56,6 @@ public interface MaterialInfoService extends BaseService<MaterialInfoResp, Mater
|
||||
* */
|
||||
void uploadMaterialPhotos(MultipartFile file);
|
||||
|
||||
|
||||
/*
|
||||
* 称重时照片抓取
|
||||
* */
|
||||
|
||||
@@ -413,12 +413,11 @@ public class MaterialInfoServiceImpl extends BaseServiceImpl<MaterialInfoMapper,
|
||||
.forEach(code -> log.warn("物料编码 [{}] 不存在,照片更新失败", code));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String catchPhoto(MultipartFile file){
|
||||
public String catchPhoto(MultipartFile file) {
|
||||
String photoStoragePath = "catch" + DateUtil.today() + "/";
|
||||
FileInfo fileInfo = fileService.upload(file, photoStoragePath, null, true, true);
|
||||
CheckUtils.throwIfNull(fileInfo,"照片上传失败");
|
||||
CheckUtils.throwIfNull(fileInfo, "照片上传失败");
|
||||
return fileInfo.getUrl();
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInfo upload(MultipartFile file, String path, String storageCode, Boolean createMin, Boolean store) {
|
||||
public FileInfo upload(MultipartFile file, String path, String storageCode, Boolean createMin, Boolean store) {
|
||||
StorageDO storage;
|
||||
if (StrUtil.isBlank(storageCode)) {
|
||||
storage = storageService.getDefaultStorage();
|
||||
|
||||
@@ -44,13 +44,11 @@ public class WorkOrderReq implements Serializable {
|
||||
@NotEmpty(message = "称重列表不能为空")
|
||||
private List<WorkOrderInfoReq> workOrderInfos;
|
||||
|
||||
|
||||
/**
|
||||
* 手动填写的物料数量
|
||||
*/
|
||||
private String inputQuantity;
|
||||
|
||||
|
||||
/**
|
||||
* 电子秤重量
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,7 @@ public interface WorkOrderService extends BaseService<WorkOrderResp, WorkOrderRe
|
||||
*/
|
||||
WorkOrderResp getDetail(Long id);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 创建任务工单
|
||||
*
|
||||
* @param req 创建任务工单参数
|
||||
@@ -41,7 +41,8 @@ public interface WorkOrderService extends BaseService<WorkOrderResp, WorkOrderRe
|
||||
List<WorkOrderInfoResp> getWorkOrderInfos(Long id);
|
||||
|
||||
/**
|
||||
* 校验物料数量和重量是否匹配
|
||||
* 校验物料数量和重量是否匹配
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -45,12 +44,11 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkOrderDO, WorkOrderResp, WorkOrderResp, WorkOrderQuery, WorkOrderReq> implements WorkOrderService {
|
||||
|
||||
private final WorkOrderInfoMapper workOrderInfoMapper;
|
||||
private final WorkOrderInfoMapper workOrderInfoMapper;
|
||||
|
||||
private final MaterialInfoMapper materialInfoMapper;
|
||||
|
||||
private final ConfigService configService;
|
||||
private final MaterialInfoMapper materialInfoMapper;
|
||||
|
||||
private final ConfigService configService;
|
||||
|
||||
@Override
|
||||
public PageResp<WorkOrderResp> page(WorkOrderQuery query, PageQuery pageQuery) {
|
||||
@@ -75,7 +73,8 @@ private final ConfigService configService;
|
||||
workOrderResp.setEncoding(materialInfoDO.getEncoding());
|
||||
}
|
||||
|
||||
List<WorkOrderInfoDO> workOrderInfos = workOrderInfoMapper.selectList(new QueryWrapper<WorkOrderInfoDO>().eq("work_order_id", id));
|
||||
List<WorkOrderInfoDO> workOrderInfos = workOrderInfoMapper.selectList(new QueryWrapper<WorkOrderInfoDO>()
|
||||
.eq("work_order_id", id));
|
||||
if (CollUtil.isNotEmpty(workOrderInfos)) {
|
||||
BigDecimal bigDecimal = new BigDecimal("0");
|
||||
for (WorkOrderInfoDO workOrderInfoDO : workOrderInfos) {
|
||||
@@ -92,13 +91,11 @@ private final ConfigService configService;
|
||||
return baseMapper.getDetail(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterDelete(List<Long> ids) {
|
||||
workOrderInfoMapper.delete(new QueryWrapper<WorkOrderInfoDO>().in("work_order_id", ids));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WorkOrderResp addWorKerOrder(WorkOrderReq req) {
|
||||
if (CollUtil.isEmpty(req.getWorkOrderInfos())) {
|
||||
@@ -117,8 +114,8 @@ private final ConfigService configService;
|
||||
String timestamp = DateUtil.format(new Date(), "yyyyMMddHHmmss");
|
||||
String randomNum = String.format("%06d", (int)(Math.random() * 1000000));
|
||||
workOrder.setOrderNo(timestamp + randomNum);
|
||||
String title = DateUtil.format(new Date(), DatePattern.CHINESE_DATE_PATTERN) + "-"
|
||||
+ UserContextHolder.getUsername() + "-" + req.getMaterialName();
|
||||
String title = DateUtil.format(new Date(), DatePattern.CHINESE_DATE_PATTERN) + "-" + UserContextHolder
|
||||
.getUsername() + "-" + req.getMaterialName();
|
||||
workOrder.setTitle(title);
|
||||
workOrder.setMaterialId(req.getMaterialId());
|
||||
workOrder.setTotalWeight(totalWeight);
|
||||
@@ -144,19 +141,19 @@ private final ConfigService configService;
|
||||
|
||||
//计算标准重量
|
||||
MaterialInfoDO materialInfoDO = materialInfoMapper.selectById(req.getMaterialId());
|
||||
BigDecimal standardWeight = materialInfoDO.getUnitWeight().subtract(new BigDecimal(req.getInputQuantity()));
|
||||
BigDecimal standardWeight = materialInfoDO.getUnitWeight().subtract(new BigDecimal(req.getInputQuantity()));
|
||||
BigDecimal electronicWeight = new BigDecimal(req.getAhDeviceWeight());
|
||||
|
||||
|
||||
// 检查 electronicWeight 是否大于 standardWeight
|
||||
if (electronicWeight.compareTo(standardWeight) <= 0) {
|
||||
log.error("电子秤重量必须大于标准重量");
|
||||
return 500; // 电子秤重量必须大于标准重量
|
||||
}
|
||||
|
||||
|
||||
// 计算比值:(electronicWeight - standardWeight) / standardWeight
|
||||
BigDecimal weightDifference = electronicWeight.subtract(standardWeight);
|
||||
BigDecimal ratio = weightDifference.divide(standardWeight, 4, BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
|
||||
// 检查比值是否超过 6%
|
||||
if (ratio.compareTo(weightFloat) > 0) {
|
||||
log.error("比值超过 6%,当前比值: {}", ratio);
|
||||
|
||||
Reference in New Issue
Block a user