From 4f4ee3f59de09f774a4b97de42758ada3e8fb329 Mon Sep 17 00:00:00 2001 From: psh Date: Fri, 17 May 2024 17:32:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=BA=E6=96=B0=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MaterialDataController.java | 38 ++++++++++ .../sch/data/service/MaterialDataService.java | 28 ++++++++ .../dao/mapper/MaterialDataMapper.java | 13 ++++ .../sch/data/service/dto/MaterialDataDto.java | 48 +++++++++++++ .../data/service/dto/MaterialDataQuery.java | 70 +++++++++++++++++++ .../service/impl/MaterialDataServiceImpl.java | 44 ++++++++++++ .../sch/material/service/dao/Material.java | 3 + .../sch/task_manage/task/tasks/YCLCKTask.java | 50 ++++++++++--- .../sch/task_manage/task/tasks/YCLRKTask.java | 46 ++++++++++-- 9 files changed, 327 insertions(+), 13 deletions(-) create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/controller/MaterialDataController.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/MaterialDataService.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dao/mapper/MaterialDataMapper.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dto/MaterialDataDto.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dto/MaterialDataQuery.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/impl/MaterialDataServiceImpl.java diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/controller/MaterialDataController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/controller/MaterialDataController.java new file mode 100644 index 0000000..f1fd2e3 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/controller/MaterialDataController.java @@ -0,0 +1,38 @@ +package org.nl.wms.sch.data.controller; + + +import org.nl.wms.sch.data.service.MaterialDataService; +import org.nl.wms.sch.data.service.dto.MaterialDataDto; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; +import lombok.extern.slf4j.Slf4j; + +/** + * @author psh + * @date 2024-05-17 + **/ +@RestController +@RequiredArgsConstructor +@Api(tags = "data管理") +@RequestMapping("/api/materialData") +@Slf4j +public class MaterialDataController { + + private final MaterialDataService materialDataService; + + @GetMapping + @ApiOperation("查询data") + //@PreAuthorize("@el.check('materialData:list')") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page){ + return new ResponseEntity<>(materialDataService.queryAll(whereJson,page),HttpStatus.OK); + } + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/MaterialDataService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/MaterialDataService.java new file mode 100644 index 0000000..af27618 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/MaterialDataService.java @@ -0,0 +1,28 @@ +package org.nl.wms.sch.data.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.nl.wms.sch.data.service.dto.MaterialDataDto; +import org.nl.wms.sch.material.service.dao.Material; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** + * @description 服务接口 + * @author psh + * @date 2024-05-17 + **/ +public interface MaterialDataService extends IService { + + /** + * 查询数据分页 + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map queryAll(Map whereJson, Pageable page); + + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dao/mapper/MaterialDataMapper.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dao/mapper/MaterialDataMapper.java new file mode 100644 index 0000000..2929032 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dao/mapper/MaterialDataMapper.java @@ -0,0 +1,13 @@ +package org.nl.wms.sch.data.service.dao.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.nl.wms.sch.data.service.dto.MaterialDataDto; +import org.nl.wms.sch.material.service.dao.Material; + +/** +* @author lyd +* @date 2023-05-16 +**/ +public interface MaterialDataMapper extends BaseMapper { + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dto/MaterialDataDto.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dto/MaterialDataDto.java new file mode 100644 index 0000000..9a15b9c --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dto/MaterialDataDto.java @@ -0,0 +1,48 @@ +package org.nl.wms.sch.data.service.dto; + +import lombok.Data; +import java.sql.Timestamp; +import java.math.BigDecimal; +import java.io.Serializable; + +/** + * @description / + * @author psh + * @date 2024-05-17 + **/ +@Data +public class MaterialDataDto implements Serializable { + + /** 客户编码 */ + private String supplierCode; + + /** 客户名称 */ + private String supplierName; + + /** 物料编码 */ + private String productName; + + /** 规格 */ + private String specification; + + /** 来料批次 */ + private String batch; + + /** 棒源等级 */ + private String barLevel; + + /** 领料批次 */ + private String pickingBatch; + + /** 长度 */ + private BigDecimal length; + + /** 重量 */ + private BigDecimal weight; + + /** 日期 */ + private Timestamp createTime; + + /** 操作类型,1-来料,2-领料 */ + private Integer type; +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dto/MaterialDataQuery.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dto/MaterialDataQuery.java new file mode 100644 index 0000000..db0681b --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/dto/MaterialDataQuery.java @@ -0,0 +1,70 @@ +package org.nl.wms.sch.data.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.Timestamp; + +/** + * @description / + * @author psh + * @date 2024-05-17 + **/ +@Data +public class MaterialDataQuery implements Serializable { + + /** 客户编码 */ + private String supplierCode; + + /** 客户名称 */ + private String supplierName; + + /** 物料编码 */ + private String productName; + + /** 规格 */ + private String specification; + + /** 来料批次 */ + private String batch; + + /** 棒源等级 */ + private String barLevel; + + /** 领料批次 */ + private String pickingBatch; + + /** 长度 */ + private BigDecimal length; + + /** 重量 */ + private BigDecimal weight; + + /** 日期 */ + private Timestamp createTime; + + /** 上月长度 */ + private BigDecimal sy_length; + + /** 上月重量 */ + private BigDecimal sy_weight; + + /** 来料长度 */ + private BigDecimal ll_length; + + /** 来料重量 */ + private BigDecimal ll_weight; + + /** 生产长度 */ + private BigDecimal sc_length; + + /** 生产重量 */ + private BigDecimal sc_weight; + + /** 结存长度 */ + private BigDecimal jc_length; + + /** 结存重量 */ + private BigDecimal jc_weight; +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/impl/MaterialDataServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/impl/MaterialDataServiceImpl.java new file mode 100644 index 0000000..bd48c94 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/impl/MaterialDataServiceImpl.java @@ -0,0 +1,44 @@ +package org.nl.wms.sch.data.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import org.nl.common.exception.BadRequestException; +import org.nl.wms.sch.data.service.MaterialDataService; +import org.nl.wms.sch.data.service.dao.mapper.MaterialDataMapper; +import org.nl.wms.sch.data.service.dto.MaterialDataDto; +import org.nl.wms.sch.material.service.dao.Material; +import org.nl.wms.sch.material.service.dao.mapper.MaterialMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.springframework.data.domain.Pageable; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import cn.hutool.core.util.ObjectUtil; + +/** + * @description 服务实现 + * @author psh + * @date 2024-05-17 + **/ +@Service +@RequiredArgsConstructor +@Slf4j +public class MaterialDataServiceImpl extends ServiceImpl implements MaterialDataService { + + @Override + public Map queryAll(Map whereJson, Pageable page){ + //todo + return new HashMap<>(); + } + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/material/service/dao/Material.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/material/service/dao/Material.java index e3127d6..8e34b9e 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/material/service/dao/Material.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/material/service/dao/Material.java @@ -56,6 +56,9 @@ public class Material implements Serializable { private String incomingchipping; @ApiModelProperty(value = "绑定状态") private String group_bind_material_status; + @ApiModelProperty(value = "棒源等级") + private String barLevel; + public void copyFrom(QPMES060RequestBody source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java index 64f1639..ea765a4 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java @@ -1,5 +1,6 @@ package org.nl.wms.sch.task_manage.task.tasks; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; @@ -17,6 +18,8 @@ import org.nl.wms.mes.domain.QPMES065Request; import org.nl.wms.mes.domain.QPMES065RequestBody; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; +import org.nl.wms.sch.data.service.dao.mapper.MaterialDataMapper; +import org.nl.wms.sch.data.service.dto.MaterialDataDto; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; import org.nl.wms.sch.material.service.dao.Material; @@ -40,9 +43,7 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -74,6 +75,8 @@ public class YCLCKTask extends AbstractTask { private PointMapper pointMapper; @Autowired private MaterialMapper materialMapper; + @Autowired + private MaterialDataMapper materialDataMapper; @Override @@ -228,11 +231,10 @@ public class YCLCKTask extends AbstractTask { taskObj.setTask_status(TaskStatus.FINISHED.getCode()); taskObj.setGroup_id(ObjectUtil.isNotEmpty(one)?one.getGroup_id():null); taskObj.setRemark("任务完成"); + List materialList = materialMapper.selectList(new LambdaQueryWrapper() + .eq(Material::getPalletSN, taskObj.getVehicle_code2()) + .eq(Material::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue())); try { - //todo 待确认具体传值 - List materialList = materialMapper.selectList(new LambdaQueryWrapper() - .eq(Material::getPalletSN, taskObj.getVehicle_code2()) - .eq(Material::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue())); if (ObjectUtil.isNotEmpty(materialList)) { String url = "http://192.168.9.124/sitAppWebApi/PDSToWMS/Api/QPMES065"; QPMES065Request qpmes065Request = new QPMES065Request(); @@ -246,7 +248,6 @@ public class YCLCKTask extends AbstractTask { QPMES065RequestBody qpmes065RequestBody=new QPMES065RequestBody(); double qty=0; for(Material material:materialList) { - qpmes065RequestBody.setMoname(extGroupData.getString("workorder_code")); qpmes065RequestBody.setLotSN(material.getPalletSN()); qty+=Double.parseDouble(material.getQty()); @@ -268,6 +269,39 @@ public class YCLCKTask extends AbstractTask { } catch (Exception e) { log.error("原材料出库上报MES失败{}", e.getMessage(), e); } + try{ + Map> groupedBy = materialList.stream() + .collect(Collectors.groupingBy(Material::getProductName)); + + if(ObjectUtil.isNotEmpty(groupedBy)) { + Iterator>> iterator = groupedBy.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry> next = iterator.next(); + List tempList = next.getValue(); + Material material = tempList.get(0); + double length = 0.0; + double weight = 0.0; + for (Material temp : tempList) { + length += Double.parseDouble(temp.getIncomingLength()); + weight += Double.parseDouble(temp.getIncomingWeight()); + } + MaterialDataDto materialDataDto = new MaterialDataDto(); + materialDataDto.setSupplierCode(material.getSupplierCode()); + materialDataDto.setSupplierName(material.getSupplierName()); + materialDataDto.setProductName(material.getProductName()); + materialDataDto.setSpecification(material.getSpecification()); + materialDataDto.setPickingBatch(extGroupData.getString("batch")); + materialDataDto.setBarLevel(material.getBarLevel()); + materialDataDto.setLength(BigDecimal.valueOf(length)); + materialDataDto.setWeight(BigDecimal.valueOf(weight)); + materialDataDto.setCreateTime(new DateTime().toTimestamp()); + materialDataDto.setType(2); + materialDataMapper.insert(materialDataDto); + } + } + }catch (Exception e){ + log.error("原材料入库暂存入库数据失败{}",e.getMessage(),e); + } } if (status.equals(TaskStatus.CANCELED)) { // 取消 // 终点解锁 diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java index 5955475..1ec61fa 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java @@ -1,5 +1,6 @@ package org.nl.wms.sch.task_manage.task.tasks; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; @@ -15,6 +16,8 @@ import org.nl.wms.mes.domain.QPMES062Request; import org.nl.wms.mes.domain.QPMES062RequestBody; import org.nl.wms.pdm.service.IPdmBdWorkorderService; import org.nl.wms.pdm.service.dao.PdmBdWorkorder; +import org.nl.wms.sch.data.service.dao.mapper.MaterialDataMapper; +import org.nl.wms.sch.data.service.dto.MaterialDataDto; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; import org.nl.wms.sch.material.service.dao.Material; @@ -38,11 +41,9 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.sql.Timestamp; +import java.util.*; +import java.util.stream.Collectors; /** * @Author: psh @@ -73,6 +74,8 @@ public class YCLRKTask extends AbstractTask { private PointMapper pointMapper; @Autowired private MaterialMapper materialMapper; + @Autowired + private MaterialDataMapper materialDataMapper; @Override // @Transactional(rollbackFor = Exception.class) @@ -239,6 +242,39 @@ public class YCLRKTask extends AbstractTask { }catch (Exception e){ log.error("原材料入库上报MES失败{}",e.getMessage(),e); } + try{ + Map> groupedBy = materialList.stream() + .collect(Collectors.groupingBy(Material::getProductName)); + + if(ObjectUtil.isNotEmpty(groupedBy)) { + Iterator>> iterator = groupedBy.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry> next = iterator.next(); + List tempList=next.getValue(); + Material material = tempList.get(0); + double length = 0.0; + double weight = 0.0; + for (Material temp : tempList) { + length += Double.parseDouble(temp.getIncomingLength()); + weight += Double.parseDouble(temp.getIncomingWeight()); + } + MaterialDataDto materialDataDto = new MaterialDataDto(); + materialDataDto.setSupplierCode(material.getSupplierCode()); + materialDataDto.setSupplierName(material.getSupplierName()); + materialDataDto.setProductName(material.getProductName()); + materialDataDto.setSpecification(material.getSpecification()); + materialDataDto.setBatch(material.getBatch()); + materialDataDto.setBarLevel(material.getBarLevel()); + materialDataDto.setLength(BigDecimal.valueOf(length)); + materialDataDto.setWeight(BigDecimal.valueOf(weight)); + materialDataDto.setCreateTime(new DateTime().toTimestamp()); + materialDataDto.setType(1); + materialDataMapper.insert(materialDataDto); + } + } + }catch (Exception e){ + log.error("原材料入库暂存入库数据失败{}",e.getMessage(),e); + } } if (status.equals(TaskStatus.CANCELED)) { // 取消 // 终点解锁