From d6e17541a90d593865d9964c798528882813118d Mon Sep 17 00:00:00 2001 From: wws <18630710203@163.com> Date: Thu, 27 Jul 2023 15:16:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B9=BF=E6=96=99=E8=AE=A1=E5=88=92=E7=AE=A1?= =?UTF-8?q?=E7=90=86(=E6=B9=BF=E6=96=99=E8=AE=A1=E5=88=92=E6=96=B0?= =?UTF-8?q?=E5=A2=9Einit)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/domain/ProWetMaterialPlanDetail.java | 230 ++++++++++++++++++ .../ProWetMaterialPlanDetailMapper.java | 62 +++++ .../mes/mapper/ProWetMaterialPlanMapper.java | 13 +- .../impl/ProWetMaterialPlanServiceImpl.java | 148 +++++++++-- .../mes/ProWetMaterialPlanDetailMapper.xml | 149 ++++++++++++ .../mapper/mes/ProWetMaterialPlanMapper.xml | 26 +- 6 files changed, 598 insertions(+), 30 deletions(-) create mode 100644 op-modules/op-mes/src/main/java/com/op/mes/domain/ProWetMaterialPlanDetail.java create mode 100644 op-modules/op-mes/src/main/java/com/op/mes/mapper/ProWetMaterialPlanDetailMapper.java create mode 100644 op-modules/op-mes/src/main/resources/mapper/mes/ProWetMaterialPlanDetailMapper.xml diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/ProWetMaterialPlanDetail.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/ProWetMaterialPlanDetail.java new file mode 100644 index 00000000..a4b66fdf --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/ProWetMaterialPlanDetail.java @@ -0,0 +1,230 @@ +package com.op.mes.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; + +/** + * 配料计划明细对象 pro_wet_material_plan_detail + * + * @author Open Platform + * @date 2023-07-27 + */ +public class ProWetMaterialPlanDetail extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** ID */ + private String id; + + /** 计划工厂编码 */ + @Excel(name = "计划工厂编码") + private String factoryCode; + + /** 配料计划id */ + @Excel(name = "配料计划id") + private String wetMaterialPlanId; + + /** 工单id */ + @Excel(name = "工单id") + private String workorderId; + + /** */ + @Excel(name = "") + private String atrr1; + + /** */ + @Excel(name = "") + private String atrr2; + + /** */ + @Excel(name = "") + private String atrr3; + + /** 1接料完成0未接料 */ + @Excel(name = "1接料完成0未接料") + private String status; + + /** 料罐id */ + @Excel(name = "料罐id") + private String bucketId; + + /** 料罐编码 */ + @Excel(name = "料罐编码") + private String bucketCode; + + /** 物料编码 */ + @Excel(name = "物料编码") + private String materialCode; + + /** 物料id */ + @Excel(name = "物料id") + private String materialId; + + /** 物料名称 */ + @Excel(name = "物料名称") + private String materialName; + + /** 产品名称 */ + @Excel(name = "产品名称") + private String productName; + + /** 班次id */ + @Excel(name = "班次id") + private Long shiftId; + + /** 班次编码 */ + @Excel(name = "班次编码") + private String shiftCode; + + /** 班次简称 */ + @Excel(name = "班次简称") + private String shiftDesc; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + public void setFactoryCode(String factoryCode) { + this.factoryCode = factoryCode; + } + + public String getFactoryCode() { + return factoryCode; + } + public void setWetMaterialPlanId(String wetMaterialPlanId) { + this.wetMaterialPlanId = wetMaterialPlanId; + } + + public String getWetMaterialPlanId() { + return wetMaterialPlanId; + } + public void setWorkorderId(String workorderId) { + this.workorderId = workorderId; + } + + public String getWorkorderId() { + return workorderId; + } + public void setAtrr1(String atrr1) { + this.atrr1 = atrr1; + } + + public String getAtrr1() { + return atrr1; + } + public void setAtrr2(String atrr2) { + this.atrr2 = atrr2; + } + + public String getAtrr2() { + return atrr2; + } + public void setAtrr3(String atrr3) { + this.atrr3 = atrr3; + } + + public String getAtrr3() { + return atrr3; + } + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return status; + } + public void setBucketId(String bucketId) { + this.bucketId = bucketId; + } + + public String getBucketId() { + return bucketId; + } + public void setBucketCode(String bucketCode) { + this.bucketCode = bucketCode; + } + + public String getBucketCode() { + return bucketCode; + } + public void setMaterialCode(String materialCode) { + this.materialCode = materialCode; + } + + public String getMaterialCode() { + return materialCode; + } + public void setMaterialId(String materialId) { + this.materialId = materialId; + } + + public String getMaterialId() { + return materialId; + } + public void setMaterialName(String materialName) { + this.materialName = materialName; + } + + public String getMaterialName() { + return materialName; + } + public void setProductName(String productName) { + this.productName = productName; + } + + public String getProductName() { + return productName; + } + public void setShiftId(Long shiftId) { + this.shiftId = shiftId; + } + + public Long getShiftId() { + return shiftId; + } + public void setShiftCode(String shiftCode) { + this.shiftCode = shiftCode; + } + + public String getShiftCode() { + return shiftCode; + } + public void setShiftDesc(String shiftDesc) { + this.shiftDesc = shiftDesc; + } + + public String getShiftDesc() { + return shiftDesc; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("factoryCode", getFactoryCode()) + .append("wetMaterialPlanId", getWetMaterialPlanId()) + .append("workorderId", getWorkorderId()) + .append("atrr1", getAtrr1()) + .append("atrr2", getAtrr2()) + .append("atrr3", getAtrr3()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("bucketId", getBucketId()) + .append("bucketCode", getBucketCode()) + .append("materialCode", getMaterialCode()) + .append("materialId", getMaterialId()) + .append("materialName", getMaterialName()) + .append("productName", getProductName()) + .append("shiftId", getShiftId()) + .append("shiftCode", getShiftCode()) + .append("shiftDesc", getShiftDesc()) + .toString(); + } +} \ No newline at end of file diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProWetMaterialPlanDetailMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProWetMaterialPlanDetailMapper.java new file mode 100644 index 00000000..d580953e --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProWetMaterialPlanDetailMapper.java @@ -0,0 +1,62 @@ +package com.op.mes.mapper; + + +import com.op.mes.domain.ProWetMaterialPlanDetail; + +import java.util.List; + +/** + * 配料计划明细Mapper接口 + * + * @author Open Platform + * @date 2023-07-27 + */ +public interface ProWetMaterialPlanDetailMapper { + /** + * 查询配料计划明细 + * + * @param id 配料计划明细主键 + * @return 配料计划明细 + */ + public ProWetMaterialPlanDetail selectProWetMaterialPlanDetailById(String id); + + /** + * 查询配料计划明细列表 + * + * @param proWetMaterialPlanDetail 配料计划明细 + * @return 配料计划明细集合 + */ + public List selectProWetMaterialPlanDetailList(ProWetMaterialPlanDetail proWetMaterialPlanDetail); + + /** + * 新增配料计划明细 + * + * @param proWetMaterialPlanDetail 配料计划明细 + * @return 结果 + */ + public int insertProWetMaterialPlanDetail(ProWetMaterialPlanDetail proWetMaterialPlanDetail); + + /** + * 修改配料计划明细 + * + * @param proWetMaterialPlanDetail 配料计划明细 + * @return 结果 + */ + public int updateProWetMaterialPlanDetail(ProWetMaterialPlanDetail proWetMaterialPlanDetail); + + /** + * 删除配料计划明细 + * + * @param id 配料计划明细主键 + * @return 结果 + */ + public int deleteProWetMaterialPlanDetailById(String id); + + /** + * 批量删除配料计划明细 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteProWetMaterialPlanDetailByIds(String[] ids); +} \ No newline at end of file diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProWetMaterialPlanMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProWetMaterialPlanMapper.java index 19adf54f..557796d2 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProWetMaterialPlanMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProWetMaterialPlanMapper.java @@ -8,7 +8,6 @@ import com.op.mes.domain.Bucket; import com.op.mes.domain.ProWetMaterialPlan; import com.op.mes.domain.Product; import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; /** * 湿料计划管理Mapper接口 @@ -80,7 +79,6 @@ public interface ProWetMaterialPlanMapper { * @param shiftId * @return */ - @Select("SELECT bst.Shift_Desc_Global shiftName FROM base_shifts_t bst WHERE bst.Shift_Id = #{shiftId}") String selectShiftById(String shiftId); /** @@ -88,7 +86,6 @@ public interface ProWetMaterialPlanMapper { * * @return */ - @Select("SELECT equipment_id AS 'bucketId',equipment_code AS 'bucketCode',equipment_name AS 'bucketName' FROM base_equipment WHERE equipment_type_code = 'equ_type_lg'") List selectBucketList(); /** @@ -96,7 +93,6 @@ public interface ProWetMaterialPlanMapper { * * @return */ - @Select("SELECT product_id AS 'productId', product_code AS 'productCode',product_desc_zh AS 'productDesc' FROM base_product WHERE active_flag = '1'") List selectProductList(); /** @@ -106,4 +102,13 @@ public interface ProWetMaterialPlanMapper { * @return */ List selectBMSList(Date planTime); + + /** + * 查询该天-该班次-该料罐下的主计划id + * @param planTime + * @param bucketCode + * @param shiftId + * @return + */ + String selectProWetMaterialPlanByPlanTime(@Param("planTime") Date planTime,@Param("bucketCode") String bucketCode,@Param("shiftId") String shiftId); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProWetMaterialPlanServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProWetMaterialPlanServiceImpl.java index e64d6ec0..6af7e332 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProWetMaterialPlanServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProWetMaterialPlanServiceImpl.java @@ -3,15 +3,20 @@ package com.op.mes.service.impl; import java.util.*; import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.context.SecurityContextHolder; import com.op.common.core.utils.DateUtils; +import com.op.common.core.utils.uuid.IdUtils; +import com.op.common.core.utils.uuid.UUID; import com.op.common.core.web.domain.AjaxResult; import com.op.mes.domain.*; import com.op.mes.mapper.ProOrderMapper; import com.op.mes.mapper.ProOrderWorkorderMapper; +import com.op.mes.mapper.ProWetMaterialPlanDetailMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.op.mes.mapper.ProWetMaterialPlanMapper; import com.op.mes.service.IProWetMaterialPlanService; +import org.springframework.transaction.annotation.Transactional; import static com.op.common.core.web.domain.AjaxResult.error; import static com.op.common.core.web.domain.AjaxResult.success; @@ -30,6 +35,8 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService private ProOrderWorkorderMapper proOrderWorkorderMapper; @Autowired private ProOrderMapper proOrderMapper; + @Autowired + private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper; /** * 查询湿料计划管理 @@ -167,7 +174,7 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService public AjaxResult getBMSList(Date planTime) { // 参数判空 if (planTime == null) { - return error("参数为空!"); + return null; } return success(proWetMaterialPlanMapper.selectBMSList(planTime)); } @@ -179,6 +186,8 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService * @return */ @Override + @DS("#header.poolName") + @Transactional public AjaxResult addWetPlan(List proOrderWorkorderList) { // 获取料罐信息list List bucketList = proWetMaterialPlanMapper.selectBucketList(); @@ -186,38 +195,127 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService List shiftList = proOrderMapper.selectProShift(); // 湿料计划分类 + // 在该班次下 for (int shift = 0; shift < shiftList.size(); shift++){ + // 在该料罐下 + for (int bucket = 0; bucket < bucketList.size(); bucket++){ + int onlyOne = 0; + // 循环传入的工单信息 + for (int order = 0; order < proOrderWorkorderList.size(); order++){ + // 如果该工单在该班次并且在该料罐下 + if (proOrderWorkorderList.get(order).getShiftId().equals(shiftList.get(shift).getShiftId().toString()) && (proOrderWorkorderList.get(order).getBucketId() == bucketList.get(bucket).getBucketId())){ + // 同班次同料罐下所有工单进行相同操作 + // 如果首次创建主计划 + if (onlyOne==0){ + // 创建主湿料计划 + ProWetMaterialPlan proWetMaterialPlan = new ProWetMaterialPlan(); + // 设置主键id + proWetMaterialPlan.setId(IdUtils.fastSimpleUUID()); + // TODO 计划工厂编码 + // 订单类型 + proWetMaterialPlan.setProdType(proOrderWorkorderList.get(order).getProdType()); + // 物料号 + proWetMaterialPlan.setProdCode(proOrderWorkorderList.get(order).getProductCode()); + // 物料名称 + proWetMaterialPlan.setProdDesc(proOrderWorkorderList.get(order).getProductName()); + // 存放大罐Code + proWetMaterialPlan.setProdSource(proOrderWorkorderList.get(order).getBucketCode()); + // 计划状态(1正常0停用) + proWetMaterialPlan.setStatus("1"); + // 创建者 + proWetMaterialPlan.setCreateBy(SecurityContextHolder.getUserName()); + // 创建时间 + proWetMaterialPlan.setCreateTime(new Date()); + // 更新者 + proWetMaterialPlan.setUpdateBy(SecurityContextHolder.getUserName()); + // 更新时间 + proWetMaterialPlan.setUpdateTime(new Date()); + // 同步状态(1已同步0未同步) + proWetMaterialPlan.setSyncFlag("0"); + // 计划编码 + proWetMaterialPlan.setProdCode("SL"+ DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, new Date())); + // 计划日期 + proWetMaterialPlan.setPlanTime(proOrderWorkorderList.get(order).getPlanTime()); + // 班次id + proWetMaterialPlan.setShiftId(Integer.valueOf(proOrderWorkorderList.get(order).getShiftId())); + // 班次名称 + proWetMaterialPlan.setShiftDesc(proOrderWorkorderList.get(order).getShiftDesc()); + // 将主湿料计划加入到数据库 + proWetMaterialPlanMapper.insertProWetMaterialPlan(proWetMaterialPlan); - } - - return null; - } - - public static Map>> classifyWorkOrders(List shifts, List tanks, List workOrders) { - Map>> classifiedWorkOrders = new HashMap<>(); + // 创建湿料计划详情 + ProWetMaterialPlanDetail proWetMaterialPlanDetail = new ProWetMaterialPlanDetail(); + // 主键id + proWetMaterialPlanDetail.setId(IdUtils.fastSimpleUUID()); + // TODO 计划工厂编码 + // 配料计划id + proWetMaterialPlanDetail.setWetMaterialPlanId(proWetMaterialPlan.getId()); + // 工单id + proWetMaterialPlanDetail.setWorkorderId(proOrderWorkorderList.get(order).getWorkorderId()); + // 接料状态(1接料完成0未接料) + proWetMaterialPlanDetail.setStatus("0"); + // 料罐id + proWetMaterialPlanDetail.setBucketId(String.valueOf(proOrderWorkorderList.get(order).getBucketId())); + // 料罐编码 + proWetMaterialPlanDetail.setBucketCode(proOrderWorkorderList.get(order).getBucketCode()); + // 物料编码 + proWetMaterialPlanDetail.setMaterialCode(proOrderWorkorderList.get(order).getMaterialCode()); + // 物料id + proWetMaterialPlanDetail.setMaterialId(String.valueOf(proOrderWorkorderList.get(order).getMaterialId())); + // 物料名称 + proWetMaterialPlanDetail.setMaterialName(proOrderWorkorderList.get(order).getMaterialName()); + // 产品名称 + proWetMaterialPlanDetail.setProductName(proOrderWorkorderList.get(order).getProductName()); + // 班次id + proWetMaterialPlanDetail.setShiftId(Long.valueOf(proOrderWorkorderList.get(order).getShiftId())); + // TODO 班次编码 + // 班次简称 + proWetMaterialPlanDetail.setShiftDesc(proOrderWorkorderList.get(order).getShiftDesc()); - for (int i = 0; i < shifts.size(); i++) { - String shift = shifts.get(i); - String tank = tanks.get(i); - String workOrder = workOrders.get(i); + proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(proWetMaterialPlanDetail); - // 获取当前班次的工单分类 - Map> shiftMap = classifiedWorkOrders.getOrDefault(shift, new HashMap<>()); + }else { + // 查询当天下-该班次-该料罐下的主湿料计划的id + String id = proWetMaterialPlanMapper.selectProWetMaterialPlanByPlanTime(proOrderWorkorderList.get(order).getPlanTime(),proOrderWorkorderList.get(order).getBucketCode(),proOrderWorkorderList.get(order).getShiftId()); - // 获取当前料罐的工单列表 - List tankOrders = shiftMap.getOrDefault(tank, new ArrayList<>()); + // 创建湿料计划详情 + ProWetMaterialPlanDetail proWetMaterialPlanDetail = new ProWetMaterialPlanDetail(); + // 主键id + proWetMaterialPlanDetail.setId(IdUtils.fastSimpleUUID()); + // TODO 计划工厂编码 + // 配料计划id + proWetMaterialPlanDetail.setWetMaterialPlanId(id); + // 工单id + proWetMaterialPlanDetail.setWorkorderId(proOrderWorkorderList.get(order).getWorkorderId()); + // 接料状态(1接料完成0未接料) + proWetMaterialPlanDetail.setStatus("0"); + // 料罐id + proWetMaterialPlanDetail.setBucketId(String.valueOf(proOrderWorkorderList.get(order).getBucketId())); + // 料罐编码 + proWetMaterialPlanDetail.setBucketCode(proOrderWorkorderList.get(order).getBucketCode()); + // 物料编码 + proWetMaterialPlanDetail.setMaterialCode(proOrderWorkorderList.get(order).getMaterialCode()); + // 物料id + proWetMaterialPlanDetail.setMaterialId(String.valueOf(proOrderWorkorderList.get(order).getMaterialId())); + // 物料名称 + proWetMaterialPlanDetail.setMaterialName(proOrderWorkorderList.get(order).getMaterialName()); + // 产品名称 + proWetMaterialPlanDetail.setProductName(proOrderWorkorderList.get(order).getProductName()); + // 班次id + proWetMaterialPlanDetail.setShiftId(Long.valueOf(proOrderWorkorderList.get(order).getShiftId())); + // TODO 班次编码 + // 班次简称 + proWetMaterialPlanDetail.setShiftDesc(proOrderWorkorderList.get(order).getShiftDesc()); - // 添加工单到料罐列表 - tankOrders.add(workOrder); - - // 更新料罐的工单列表 - shiftMap.put(tank, tankOrders); - - // 更新班次的工单分类 - classifiedWorkOrders.put(shift, shiftMap); + proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(proWetMaterialPlanDetail); + } + onlyOne+=1; + } + } + } } - return classifiedWorkOrders; + return null; } } diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/ProWetMaterialPlanDetailMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/ProWetMaterialPlanDetailMapper.xml new file mode 100644 index 00000000..01701db9 --- /dev/null +++ b/op-modules/op-mes/src/main/resources/mapper/mes/ProWetMaterialPlanDetailMapper.xml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, factory_code, wet_material_plan_id, workorder_id, atrr1, atrr2, atrr3, status, create_by, create_time, update_by, update_time, bucket_id, bucket_code, material_code, material_id, material_name, product_name, shift_id, shift_code, shift_desc from pro_wet_material_plan_detail + + + + + + + + insert into pro_wet_material_plan_detail + + id, + factory_code, + wet_material_plan_id, + workorder_id, + atrr1, + atrr2, + atrr3, + status, + create_by, + create_time, + update_by, + update_time, + bucket_id, + bucket_code, + material_code, + material_id, + material_name, + product_name, + shift_id, + shift_code, + shift_desc, + + + #{id}, + #{factoryCode}, + #{wetMaterialPlanId}, + #{workorderId}, + #{atrr1}, + #{atrr2}, + #{atrr3}, + #{status}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{bucketId}, + #{bucketCode}, + #{materialCode}, + #{materialId}, + #{materialName}, + #{productName}, + #{shiftId}, + #{shiftCode}, + #{shiftDesc}, + + + + + update pro_wet_material_plan_detail + + factory_code = #{factoryCode}, + wet_material_plan_id = #{wetMaterialPlanId}, + workorder_id = #{workorderId}, + atrr1 = #{atrr1}, + atrr2 = #{atrr2}, + atrr3 = #{atrr3}, + status = #{status}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + bucket_id = #{bucketId}, + bucket_code = #{bucketCode}, + material_code = #{materialCode}, + material_id = #{materialId}, + material_name = #{materialName}, + product_name = #{productName}, + shift_id = #{shiftId}, + shift_code = #{shiftCode}, + shift_desc = #{shiftDesc}, + + where id = #{id} + + + + delete from pro_wet_material_plan_detail where id = #{id} + + + + delete from pro_wet_material_plan_detail where id in + + #{id} + + + \ No newline at end of file diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/ProWetMaterialPlanMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/ProWetMaterialPlanMapper.xml index 7323b857..58ba19db 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/ProWetMaterialPlanMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/ProWetMaterialPlanMapper.xml @@ -56,7 +56,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" GROUP BY bucket_id,material_id,shift_id - + + + + + + + + + insert into pro_wet_material_plan id,