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

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 com.op.mes.domain.ProOrderWorkorder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
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 com.op.common.log.annotation.Log; import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType; import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions; import com.op.common.security.annotation.RequiresPermissions;

@ -1,10 +1,13 @@
package com.op.mes.domain; package com.op.mes.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.op.common.core.annotation.Excel; import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity; import com.op.common.core.web.domain.BaseEntity;
import java.util.Date;
/** /**
* pro_wet_material_plan_detail * pro_wet_material_plan_detail
* *
@ -81,6 +84,19 @@ public class ProWetMaterialPlanDetail extends BaseEntity {
@Excel(name = "班次简称") @Excel(name = "班次简称")
private String shiftDesc; 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) { public void setId(String id) {
this.id = id; this.id = id;
} }
@ -225,6 +241,7 @@ public class ProWetMaterialPlanDetail extends BaseEntity {
.append("shiftId", getShiftId()) .append("shiftId", getShiftId())
.append("shiftCode", getShiftCode()) .append("shiftCode", getShiftCode())
.append("shiftDesc", getShiftDesc()) .append("shiftDesc", getShiftDesc())
.append("planTime",getPlanTime())
.toString(); .toString();
} }
} }

@ -105,10 +105,19 @@ public interface ProWetMaterialPlanMapper {
/** /**
* --id * --id
*
* @param planTime * @param planTime
* @param bucketCode * @param bucketCode
* @param shiftId * @param shiftId
* @return * @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 @Autowired
private ProOrderWorkorderMapper proOrderWorkorderMapper; private ProOrderWorkorderMapper proOrderWorkorderMapper;
@Autowired @Autowired
private ProOrderMapper proOrderMapper;
@Autowired
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper; private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
/** /**
@ -189,133 +187,99 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
@DS("#header.poolName") @DS("#header.poolName")
@Transactional @Transactional
public AjaxResult addWetPlan(List<ProOrderWorkorder> proOrderWorkorderList) { public AjaxResult addWetPlan(List<ProOrderWorkorder> proOrderWorkorderList) {
// 获取料罐信息list // 判断在该计划日期下是否存在计划-存在计划则获取主计划id-不存在新建计划
List<Bucket> bucketList = proWetMaterialPlanMapper.selectBucketList(); String planId = proWetMaterialPlanMapper.selectWetMaterialPlanByPlanTime(proOrderWorkorderList.get(0).getPlanTime());
// 获取班次信息list if (planId == null) {
List<ProShift> shiftList = proOrderMapper.selectProShift(); // 创建主计划
ProWetMaterialPlan proWetMaterialPlan = createProWetMaterialPlan(proOrderWorkorderList.get(0));
// 湿料计划分类 // 将主计划更新至数据库
// 在该班次下 proWetMaterialPlanMapper.insertProWetMaterialPlan(proWetMaterialPlan);
for (int shift = 0; shift < shiftList.size(); shift++){ // 循环创建湿料计划详情
// 在该料罐下 for (int i = 0; i < proOrderWorkorderList.size(); i++) {
for (int bucket = 0; bucket < bucketList.size(); bucket++){ // 将湿料计划详情更新至数据库
int onlyOne = 0; proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(proOrderWorkorderList.get(i), proWetMaterialPlan.getId()));
// 循环传入的工单信息 }
for (int order = 0; order < proOrderWorkorderList.size(); order++){ }else {
// 如果该工单在该班次并且在该料罐下 // 循环创建湿料计划详情
if (proOrderWorkorderList.get(order).getShiftId().equals(shiftList.get(shift).getShiftId().toString()) && (proOrderWorkorderList.get(order).getBucketId() == bucketList.get(bucket).getBucketId())){ for (int i = 0; i < proOrderWorkorderList.size(); i++) {
// 同班次同料罐下所有工单进行相同操作 // 将湿料计划详情更新至数据库
// 如果首次创建主计划 proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(proOrderWorkorderList.get(i), planId));
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;
}
}
} }
} }
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="shiftId" column="shift_id" />
<result property="shiftCode" column="shift_code" /> <result property="shiftCode" column="shift_code" />
<result property="shiftDesc" column="shift_desc" /> <result property="shiftDesc" column="shift_desc" />
<result property="planTime" column="plan_time" />
</resultMap> </resultMap>
<sql id="selectProWetMaterialPlanDetailVo"> <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> </sql>
<select id="selectProWetMaterialPlanDetailList" parameterType="ProWetMaterialPlanDetail" resultMap="ProWetMaterialPlanDetailResult"> <select id="selectProWetMaterialPlanDetailList" parameterType="ProWetMaterialPlanDetail" resultMap="ProWetMaterialPlanDetailResult">
@ -51,6 +52,7 @@
<if test="shiftId != null "> and shift_id = #{shiftId}</if> <if test="shiftId != null "> and shift_id = #{shiftId}</if>
<if test="shiftCode != null and shiftCode != ''"> and shift_code = #{shiftCode}</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="shiftDesc != null and shiftDesc != ''"> and shift_desc = #{shiftDesc}</if>
<if test="planTime != null and planTime != ''"> and plan_time = #{planTime}</if>
</where> </where>
</select> </select>
@ -83,6 +85,7 @@
<if test="shiftId != null">shift_id,</if> <if test="shiftId != null">shift_id,</if>
<if test="shiftCode != null">shift_code,</if> <if test="shiftCode != null">shift_code,</if>
<if test="shiftDesc != null">shift_desc,</if> <if test="shiftDesc != null">shift_desc,</if>
<if test="planTime != null">plan_time,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
@ -106,6 +109,7 @@
<if test="shiftId != null">#{shiftId},</if> <if test="shiftId != null">#{shiftId},</if>
<if test="shiftCode != null">#{shiftCode},</if> <if test="shiftCode != null">#{shiftCode},</if>
<if test="shiftDesc != null">#{shiftDesc},</if> <if test="shiftDesc != null">#{shiftDesc},</if>
<if test="planTime != null">#{planTime},</if>
</trim> </trim>
</insert> </insert>
@ -132,6 +136,7 @@
<if test="shiftId != null">shift_id = #{shiftId},</if> <if test="shiftId != null">shift_id = #{shiftId},</if>
<if test="shiftCode != null">shift_code = #{shiftCode},</if> <if test="shiftCode != null">shift_code = #{shiftCode},</if>
<if test="shiftDesc != null">shift_desc = #{shiftDesc},</if> <if test="shiftDesc != null">shift_desc = #{shiftDesc},</if>
<if test="planTime != null">plan_time = #{planTime},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBMSList" resultType="com.op.mes.domain.BMS"> <select id="selectBMSList" resultType="com.op.mes.domain.BMS">
SELECT bucket_id AS 'bucketId', material_id AS 'materialId',shift_id AS 'shiftId' SELECT bucket_id AS 'bucketId', material_id AS 'materialId',shift_id AS 'shiftId'
FROM pro_wet_material_plan_detail 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 GROUP BY bucket_id,material_id,shift_id
</select> </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} where prod_source = #{bucketCode} and plan_time = #{planTime} and shift_id = #{shiftId}
</select> </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 insert into pro_wet_material_plan
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if> <if test="id != null">id,</if>

Loading…
Cancel
Save