湿料计划管理(计划新增完成)

highway
wws 1 year ago
parent 0425f44ef9
commit 97b1ddbc4b

@ -6,14 +6,7 @@ import javax.servlet.http.HttpServletResponse;
import com.op.mes.domain.ProOrderWorkorder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;

@ -1,10 +1,13 @@
package com.op.mes.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
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;
import java.util.Date;
/**
* pro_wet_material_plan_detail
*
@ -81,6 +84,19 @@ public class ProWetMaterialPlanDetail extends BaseEntity {
@Excel(name = "班次简称")
private String shiftDesc;
/** 计划日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "计划日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date planTime;
public Date getPlanTime() {
return planTime;
}
public void setPlanTime(Date planTime) {
this.planTime = planTime;
}
public void setId(String id) {
this.id = id;
}
@ -225,6 +241,7 @@ public class ProWetMaterialPlanDetail extends BaseEntity {
.append("shiftId", getShiftId())
.append("shiftCode", getShiftCode())
.append("shiftDesc", getShiftDesc())
.append("planTime",getPlanTime())
.toString();
}
}

@ -105,10 +105,19 @@ public interface ProWetMaterialPlanMapper {
/**
* --id
*
* @param planTime
* @param bucketCode
* @param shiftId
* @return
*/
String selectProWetMaterialPlanByPlanTime(@Param("planTime") Date planTime,@Param("bucketCode") String bucketCode,@Param("shiftId") String shiftId);
String selectProWetMaterialPlanByPlanTime(@Param("planTime") Date planTime, @Param("bucketCode") String bucketCode, @Param("shiftId") String shiftId);
/**
* 湿id
*
* @param planTime
* @return
*/
String selectWetMaterialPlanByPlanTime(Date planTime);
}

@ -34,8 +34,6 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
@Autowired
private ProOrderWorkorderMapper proOrderWorkorderMapper;
@Autowired
private ProOrderMapper proOrderMapper;
@Autowired
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
/**
@ -189,133 +187,99 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
@DS("#header.poolName")
@Transactional
public AjaxResult addWetPlan(List<ProOrderWorkorder> proOrderWorkorderList) {
// 获取料罐信息list
List<Bucket> bucketList = proWetMaterialPlanMapper.selectBucketList();
// 获取班次信息list
List<ProShift> 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);
// 创建湿料计划详情
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());
proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(proWetMaterialPlanDetail);
}else {
// 查询当天下-该班次-该料罐下的主湿料计划的id
String id = proWetMaterialPlanMapper.selectProWetMaterialPlanByPlanTime(proOrderWorkorderList.get(order).getPlanTime(),proOrderWorkorderList.get(order).getBucketCode(),proOrderWorkorderList.get(order).getShiftId());
// 创建湿料计划详情
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());
proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(proWetMaterialPlanDetail);
}
onlyOne+=1;
}
}
// 判断在该计划日期下是否存在计划-存在计划则获取主计划id-不存在新建计划
String planId = proWetMaterialPlanMapper.selectWetMaterialPlanByPlanTime(proOrderWorkorderList.get(0).getPlanTime());
if (planId == null) {
// 创建主计划
ProWetMaterialPlan proWetMaterialPlan = createProWetMaterialPlan(proOrderWorkorderList.get(0));
// 将主计划更新至数据库
proWetMaterialPlanMapper.insertProWetMaterialPlan(proWetMaterialPlan);
// 循环创建湿料计划详情
for (int i = 0; i < proOrderWorkorderList.size(); i++) {
// 将湿料计划详情更新至数据库
proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(proOrderWorkorderList.get(i), proWetMaterialPlan.getId()));
}
}else {
// 循环创建湿料计划详情
for (int i = 0; i < proOrderWorkorderList.size(); i++) {
// 将湿料计划详情更新至数据库
proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(proOrderWorkorderList.get(i), planId));
}
}
return success();
}
return null;
/**
* 湿
*
* @param proOrderWorkorder
* @return
*/
private ProWetMaterialPlan createProWetMaterialPlan(ProOrderWorkorder proOrderWorkorder) {
ProWetMaterialPlan proWetMaterialPlan = new ProWetMaterialPlan();
// 创建者
proWetMaterialPlan.setCreateBy(SecurityContextHolder.getUserName());
// 创建时间
proWetMaterialPlan.setCreateTime(DateUtils.getNowDate());
// 更新者
proWetMaterialPlan.setUpdateBy(SecurityContextHolder.getUserName());
// 更新时间
proWetMaterialPlan.setUpdateTime(DateUtils.getNowDate());
// 计划状态(1正常0停用)
proWetMaterialPlan.setStatus("1");
// TODO 订单类型
//proWetMaterialPlan.setOrderType();
// TODO 计划工厂编码
//proWetMaterialPlan.setFactoryCode();
// 计划日期
proWetMaterialPlan.setPlanTime(proOrderWorkorder.getPlanTime());
// 同步状态(1已同步0未同步)
proWetMaterialPlan.setSyncFlag("0");
// 计划编码
proWetMaterialPlan.setProdCode("PC" + DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, DateUtils.getNowDate()));
// 创建主键id
proWetMaterialPlan.setId(IdUtils.fastSimpleUUID());
return proWetMaterialPlan;
}
/**
* 湿
*
* @param workorder
* @param id
* @return
*/
private ProWetMaterialPlanDetail createProWetMaterialPlanDetail(ProOrderWorkorder workorder, String id) {
ProWetMaterialPlanDetail detail = new ProWetMaterialPlanDetail();
// 设置主键id
detail.setId(IdUtils.fastSimpleUUID());
// TODO 计划工厂编码
//detail.setFactoryCode();
// 主计划id
detail.setWetMaterialPlanId(id);
// 工单id
detail.setWorkorderId(workorder.getWorkorderId());
// 接料状态1已接料0未接料
detail.setStatus("0");
// 料罐id
detail.setBucketId(String.valueOf(workorder.getBucketId()));
// 料罐编码
detail.setBucketCode(workorder.getBucketCode());
// 物料编码
detail.setMaterialCode(workorder.getMaterialCode());
// 物料id
detail.setMaterialId(String.valueOf(workorder.getMaterialId()));
// 物料名称
detail.setMaterialName(workorder.getMaterialName());
// 班次id
detail.setShiftId(Long.valueOf(workorder.getShiftId()));
// TODO 班次编码
//detail.setShiftCode();
// 班次简称
detail.setShiftDesc(workorder.getShiftDesc());
// 湿料计划时间
detail.setPlanTime(workorder.getPlanTime());
return detail;
}
}

@ -26,10 +26,11 @@
<result property="shiftId" column="shift_id" />
<result property="shiftCode" column="shift_code" />
<result property="shiftDesc" column="shift_desc" />
<result property="planTime" column="plan_time" />
</resultMap>
<sql id="selectProWetMaterialPlanDetailVo">
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
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, plan_time from pro_wet_material_plan_detail
</sql>
<select id="selectProWetMaterialPlanDetailList" parameterType="ProWetMaterialPlanDetail" resultMap="ProWetMaterialPlanDetailResult">
@ -51,6 +52,7 @@
<if test="shiftId != null "> and shift_id = #{shiftId}</if>
<if test="shiftCode != null and shiftCode != ''"> and shift_code = #{shiftCode}</if>
<if test="shiftDesc != null and shiftDesc != ''"> and shift_desc = #{shiftDesc}</if>
<if test="planTime != null and planTime != ''"> and plan_time = #{planTime}</if>
</where>
</select>
@ -83,6 +85,7 @@
<if test="shiftId != null">shift_id,</if>
<if test="shiftCode != null">shift_code,</if>
<if test="shiftDesc != null">shift_desc,</if>
<if test="planTime != null">plan_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -106,6 +109,7 @@
<if test="shiftId != null">#{shiftId},</if>
<if test="shiftCode != null">#{shiftCode},</if>
<if test="shiftDesc != null">#{shiftDesc},</if>
<if test="planTime != null">#{planTime},</if>
</trim>
</insert>
@ -132,6 +136,7 @@
<if test="shiftId != null">shift_id = #{shiftId},</if>
<if test="shiftCode != null">shift_code = #{shiftCode},</if>
<if test="shiftDesc != null">shift_desc = #{shiftDesc},</if>
<if test="planTime != null">plan_time = #{planTime},</if>
</trim>
where id = #{id}
</update>

@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBMSList" resultType="com.op.mes.domain.BMS">
SELECT bucket_id AS 'bucketId', material_id AS 'materialId',shift_id AS 'shiftId'
FROM pro_wet_material_plan_detail
WHERE status = '1' AND CONVERT(date, create_time) = #{planTime}
WHERE status = '0' AND CONVERT(date, plan_time) = #{planTime}
GROUP BY bucket_id,material_id,shift_id
</select>
@ -80,7 +80,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where prod_source = #{bucketCode} and plan_time = #{planTime} and shift_id = #{shiftId}
</select>
<insert id="insertProWetMaterialPlan" parameterType="ProWetMaterialPlan">
<select id="selectWetMaterialPlanByPlanTime" resultType="java.lang.String">
select id
from pro_wet_material_plan
where CONVERT(date, plan_time) = CONVERT(date, #{planTime})
</select>
<insert id="insertProWetMaterialPlan" parameterType="ProWetMaterialPlan">
insert into pro_wet_material_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>

Loading…
Cancel
Save