湿料计划集成到白胚订单拆分

highway
zhaoxiaolin 1 year ago
parent ab51cb0827
commit 0da428ce6f

@ -136,6 +136,9 @@ public class ProOrder extends TreeEntity {
@Excel(name = "更新日期", width = 20, dateFormat = "yyyy-MM-dd")
private Date updateTime;
private String materialCode;
private String materialName;
// 车数
private Integer carNum;
@ -191,6 +194,21 @@ public class ProOrder extends TreeEntity {
this.prodSpc = prodSpc;
}
public String getMaterialCode() {
return materialCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public String getMaterialName() {
return materialName;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
public void setId(String id) {
this.id = id;

@ -27,6 +27,25 @@ public class SplitOrderDTO {
private ProOrderWorkorder proOrderWorkorder;
private Integer carNum;
private String materialCode;
private String materialName;
public String getMaterialCode() {
return materialCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public String getMaterialName() {
return materialName;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
public Integer getCarNum() {
return carNum;
}

@ -5,6 +5,7 @@ import com.op.plan.domain.ProOrderWorkorder;
import com.op.plan.domain.ProWetMaterialPlan;
import com.op.plan.domain.ProWetMaterialPlanDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -115,11 +116,15 @@ public interface ProWetMaterialPlanDetailMapper {
* @param orderCode
* @return
*/
ProWetMaterialPlanDetail selectProWetMaterialPlanDetailByOrderCode(String orderCode);
//ProWetMaterialPlanDetail selectProWetMaterialPlanDetailByOrderCode(String orderCode);
/**
* 湿id湿
* @param id
*/
void deleteProWetMaterialPlanDetailByPlanId(String id);
void batchAddWetDetails(@Param("list") List<ProWetMaterialPlanDetail> wetDetails);
ProWetMaterialPlanDetail getWetInfoByWorkId(String workorderId);
}

@ -200,6 +200,35 @@ public class ProOrderServiceImpl implements IProOrderService {
setBatch(proOrderWorkorderBatch,splitOrderDTO.getFormFields(),proOrderWorkorder.getWorkorderId(),1L);
//生成湿料计划------------------------------开始
List<ProWetMaterialPlanDetail> wetDetails = new ArrayList<>();
//设备-根据工单获取实际规划设备路线
String[][] lineCodes = splitOrderDTO.getProdLineCodeArray();//proRfidProcessDetailMapper.getActuaEquips(rfidInfo);
ProWetMaterialPlanDetail wetDetail = null;
for(int c1= 0;c1<lineCodes.length;c1++){
if(lineCodes[c1][1].startsWith("L")){//L1-8湿料罐
wetDetail = new ProWetMaterialPlanDetail();
wetDetail.setId(IdUtils.fastSimpleUUID());
wetDetail.setWorkorderId(proOrderWorkorder.getWorkorderId());
wetDetail.setBucketCode(lineCodes[c1][1]);
wetDetail.setMaterialCode(splitOrderDTO.getMaterialCode());
wetDetail.setMaterialName(splitOrderDTO.getMaterialName());
wetDetail.setShiftId(Long.parseLong(splitOrderDTO.getShiftId()));
wetDetail.setPlanTime(splitOrderDTO.getProductDate());
wetDetail.setCreateBy(SecurityUtils.getUsername());
wetDetail.setCreateTime(DateUtils.getNowDate());
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
wetDetail.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
wetDetails.add(wetDetail);
}
}
if(!CollectionUtils.isEmpty(wetDetails)){
proWetMaterialPlanDetailMapper.batchAddWetDetails(wetDetails);
}
//生成湿料计划------------------------------结束
return success();
}else {
@ -598,7 +627,7 @@ public class ProOrderServiceImpl implements IProOrderService {
level1.setChildren(children);
}
}
System.out.println(JSONArray.toJSONString(level));
//System.out.println(JSONArray.toJSONString(level));
return level;
}

@ -28,7 +28,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;
@ -411,6 +414,10 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
ProOrderWorkorder workOrder = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(proOrderWorkorder.getWorkorderId());
formatProOrderWorkorder(workOrder);
//查湿料计划,看看用的什么料
ProWetMaterialPlanDetail wetInfo = proWetMaterialPlanDetailMapper.getWetInfoByWorkId(proOrderWorkorder.getWorkorderId());
workOrder.setMaterialCode(wetInfo.getMaterialCode());
workOrder.setMaterialName(wetInfo.getMaterialName());
Map orderAndWork = new HashMap();
orderAndWork.put("order", proOrder);
@ -650,6 +657,35 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
// System.out.println("这里是拆分数量----------->"+workBatch.getBatchQuantity());
}
//生成湿料计划------------------------------开始
List<ProWetMaterialPlanDetail> wetDetails = new ArrayList<>();
//设备-根据工单获取实际规划设备路线
String[][] lineCodes = splitOrderDTO.getProdLineCodeArray();//proRfidProcessDetailMapper.getActuaEquips(rfidInfo);
ProWetMaterialPlanDetail wetDetail = null;
for(int c1= 0;c1<lineCodes.length;c1++){
if(lineCodes[c1][1].startsWith("L")){//L1-8湿料罐
wetDetail = new ProWetMaterialPlanDetail();
wetDetail.setId(IdUtils.fastSimpleUUID());
wetDetail.setWorkorderId(proOrderWorkorder.getWorkorderId());
wetDetail.setBucketCode(lineCodes[c1][1]);
wetDetail.setMaterialCode(splitOrderDTO.getMaterialCode());
wetDetail.setMaterialName(splitOrderDTO.getMaterialName());
wetDetail.setShiftId(Long.parseLong(proWorkOrder.getShiftId()));
wetDetail.setPlanTime(splitOrderDTO.getProductDate());
wetDetail.setCreateBy(SecurityUtils.getUsername());
wetDetail.setCreateTime(DateUtils.getNowDate());
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
wetDetail.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
wetDetails.add(wetDetail);
}
}
if(!CollectionUtils.isEmpty(wetDetails)){
proWetMaterialPlanDetailMapper.batchAddWetDetails(wetDetails);
}
//生成湿料计划------------------------------结束
return success("变更成功");
} else {
// 删除所有工单s下的批次信息
@ -767,13 +803,13 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
if (!(proOrderWorkorder.getStatus().equals("w0") || proOrderWorkorder.getStatus().equals("w1"))) {
return error("工单已生产,不可变更!");
}
// 白坯工单所在湿料计划下发不允许变更
if (proOrderWorkorder.getProdType().equals("white")) {
ProWetMaterialPlan plan = proWetMaterialPlanMapper.selectProWetMaterialPlanByWorkId(proOrderWorkorder.getWorkorderId());
if (plan != null) {
return error("工单所在湿料计划已下发,不允许变更!");
}
}
// // 白坯工单所在湿料计划下发不允许变更
// if (proOrderWorkorder.getProdType().equals("white")) {
// ProWetMaterialPlan plan = proWetMaterialPlanMapper.selectProWetMaterialPlanByWorkId(proOrderWorkorder.getWorkorderId());
// if (plan != null) {
// return error("工单所在湿料计划已下发,不允许变更!");
// }
// }
return success();
}
@ -845,7 +881,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
ProWetMaterialPlan plan = proWetMaterialPlanMapper.selectProWetMaterialPlanByWorkId(data.getWorkorderId());
if (plan != null) {
if (plan.getSyncFlag().equals("Y")) {
throw new RuntimeException("工单下湿料计划已下发,不允许删除!");
throw new RuntimeException("白坯工单湿料计划已同步wcs,不允许删除!");
}
}
}

@ -123,17 +123,22 @@
prod_type, plan_code, shift_id, shift_desc from pro_wet_material_plan
where wet_material_plan_id = #{wetMaterialPlanId} and del_flag = '0'
</select>
<select id="selectProWetMaterialPlanDetailByOrderCode"
resultType="com.op.plan.domain.ProWetMaterialPlanDetail">
select id, factory_code, plan_time, sync_flag, create_by, create_time, update_by, update_time,
order_type, prod_code, prod_desc, prod_source, quantity, unit, atrr1, atrr2, atrr3, status,
prod_type, plan_code, shift_id, shift_desc from pro_wet_material_plan
where workorder_id in (select workorder_id from pro_order_workorder where order_code = #{orderCode}
)
and del_flag = '0'
<select id="getWetInfoByWorkId" resultType="com.op.plan.domain.ProWetMaterialPlanDetail">
select top 1 material_code materialCode,
material_name materialName
from pro_wet_material_plan_detail where workorder_id = #{workorderId}
</select>
<!-- <select id="selectProWetMaterialPlanDetailByOrderCode"-->
<!-- resultType="com.op.plan.domain.ProWetMaterialPlanDetail">-->
<!-- select id, factory_code, plan_time, sync_flag, create_by, create_time, update_by, update_time,-->
<!-- order_type, prod_code, prod_desc, prod_source, quantity, unit, atrr1, atrr2, atrr3, status,-->
<!-- prod_type, plan_code, shift_id, shift_desc from pro_wet_material_plan-->
<!-- where workorder_id in (select workorder_id from pro_order_workorder where order_code = #{orderCode}-->
<!-- )-->
<!-- and del_flag = '0'-->
<!-- </select>-->
<insert id="insertProWetMaterialPlanDetail" parameterType="ProWetMaterialPlanDetail">
insert into pro_wet_material_plan_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -185,6 +190,23 @@
<if test="planTime != null">#{planTime},</if>
</trim>
</insert>
<insert id="batchAddWetDetails">
insert into pro_wet_material_plan_detail
(
id, factory_code, workorder_id,
create_by, create_time, bucket_code,
material_code,material_name, shift_id,
plan_time,sync_flag
)values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.id},#{item.factoryCode},#{item.workorderId},
#{item.createBy},#{item.createTime},#{item.bucketCode},
#{item.materialCode},#{item.materialName},#{item.shiftId},
#{item.planTime}, 'N'
)
</foreach>
</insert>
<update id="updateProWetMaterialPlanDetail" parameterType="ProWetMaterialPlanDetail">
update pro_wet_material_plan_detail

@ -23,6 +23,8 @@ import java.util.List;
@Service
public class SapOrderServiceImpl implements SapOrderService {
private static final String END_DATE="99991231";
@Override
public R<List<SapProOrder>> shopOrderSync(SapProOrder sapProOrder) {
@ -39,9 +41,9 @@ public class SapOrderServiceImpl implements SapOrderService {
JCoTable jCoTable = func.getTableParameterList().getTable("S_ERDAT");
jCoTable.appendRow();
jCoTable.setValue("SIGN", "I");
jCoTable.setValue("OPTION", "EQ");
jCoTable.setValue("OPTION", "BT");
jCoTable.setValue("LOW", DateUtils.parseDateToStr("yyyyMMdd", sapProOrder.getCreateTime()));
jCoTable.setValue("HIGH", END_DATE);
func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO

Loading…
Cancel
Save