工单下发sap接口联调

highway
zhaoxiaolin 1 year ago
parent 48496ffa9a
commit dee2982dbd

@ -46,9 +46,9 @@ public class RyTask {
remoteSapService.shopOrderSync(sapProOrder); remoteSapService.shopOrderSync(sapProOrder);
} }
/**23 /**22
* 16 * 16
* 0 0 23 * * ? * 0 00 22 * * ?
*/ */
public void getMesPrepareTask(){ public void getMesPrepareTask(){
System.out.println("++同步领料单+开始++getMesPrepareTask+++++"); System.out.println("++同步领料单+开始++getMesPrepareTask+++++");
@ -62,8 +62,8 @@ public class RyTask {
remoteSapService.sapProRouteProcess(); remoteSapService.sapProRouteProcess();
} }
/**3023 /**2100
* 0 30 23 * * ? * 0 00 21 * * ?
*/ */
public void getTOrderTask(){ public void getTOrderTask(){
System.out.println("++同步今日订单+开始++getTOrderTask+++++"); System.out.println("++同步今日订单+开始++getTOrderTask+++++");

@ -159,7 +159,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
//获取T+1天的所有母工单 //获取T+1天的所有母工单
MesPrepare qo = new MesPrepare(); MesPrepare qo = new MesPrepare();
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);//这里改为1 cal.add(Calendar.DATE, 1);//这里改为1
Date time = cal.getTime(); Date time = cal.getTime();
qo.setDayStr(new SimpleDateFormat("yyyy-MM-dd").format(time)); qo.setDayStr(new SimpleDateFormat("yyyy-MM-dd").format(time));
List<MesPrepare> parents = mesPrepareMapper.getParentWorkOrderT1(qo); List<MesPrepare> parents = mesPrepareMapper.getParentWorkOrderT1(qo);
@ -167,7 +167,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
System.out.println("T+1无母工单数据"); System.out.println("T+1无母工单数据");
} }
for (MesPrepare mesPrepare : parents) { for (MesPrepare mesPrepare : parents) {
List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(mesPrepare.getWorkorderCode()).getData(); List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(mesPrepare.getWorkorderCodeSap()).getData();
if (CollectionUtils.isEmpty(sapMaterialPreparationList)) { if (CollectionUtils.isEmpty(sapMaterialPreparationList)) {
System.out.println("sap无领料单数据"); System.out.println("sap无领料单数据");
} }

@ -132,5 +132,7 @@ public interface ProOrderWorkorderMapper {
void createPrepareDetails(@Param("list") List<MesPrepareDetailDTO> list); void createPrepareDetails(@Param("list") List<MesPrepareDetailDTO> list);
List<ProOrderWorkorder> selectProOrderWorkerderByWorkerIds(String[] ids); List<ProOrderWorkorder> selectProOrderWorkerderByWorkerIds(String[] ids);
public void updateWorkOrderCodeSap(ProOrderWorkorder oworkSap);
} }

@ -486,7 +486,7 @@ public class ProOrderServiceImpl implements IProOrderService {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
SapProOrder sapqo = new SapProOrder();//proOrderMapper.getMaxCreatetime(); SapProOrder sapqo = new SapProOrder();//proOrderMapper.getMaxCreatetime();
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-1); calendar.add(Calendar.DAY_OF_MONTH,1);
sapqo.setCreateTime(calendar.getTime()); sapqo.setCreateTime(calendar.getTime());
sapqo.setFactoryCode(poolName.replace("ds_","")); sapqo.setFactoryCode(poolName.replace("ds_",""));

@ -201,7 +201,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
} }
} }
} }
List<SapCreateOrder> sapList = new ArrayList<>();//回传给sap的工单 List<SapCreateOrder> sapList = null;//回传给sap的工单
//如果是白坯生成备料单 //如果是白坯生成备料单
for(String workorderId:workorderIds){ for(String workorderId:workorderIds){
ProOrderWorkorder whiteOrder = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId); ProOrderWorkorder whiteOrder = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId);
@ -233,6 +233,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
details.add(detail); details.add(detail);
proOrderWorkorderMapper.createPrepareDetails(details); proOrderWorkorderMapper.createPrepareDetails(details);
}else if(whiteOrder!=null){//成品的母工单回传sap }else if(whiteOrder!=null){//成品的母工单回传sap
sapList = new ArrayList<>();
SapCreateOrder sap = new SapCreateOrder(); SapCreateOrder sap = new SapCreateOrder();
sap.setWerks(whiteOrder.getFactoryCode());//工厂编码 sap.setWerks(whiteOrder.getFactoryCode());//工厂编码
sap.setAufpar(whiteOrder.getProdType());//订单类型 sap.setAufpar(whiteOrder.getProdType());//订单类型
@ -241,16 +242,41 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
sap.setDates(DateUtils.parseDateToStr("yyyy-MM-dd",whiteOrder.getProductDate()));//开始时间 sap.setDates(DateUtils.parseDateToStr("yyyy-MM-dd",whiteOrder.getProductDate()));//开始时间
sap.setDatee(DateUtils.parseDateToStr("yyyy-MM-dd",whiteOrder.getProductDate()));//完成时间 sap.setDatee(DateUtils.parseDateToStr("yyyy-MM-dd",whiteOrder.getProductDate()));//完成时间
sapList.add(sap); sapList.add(sap);
R<List<String>> r = remoteSapService.SapCreateOrder(sapList);
logger.info("sap工单回传"+r.getMsg());
if(500==r.getCode()){
logger.error("sap工单回传"+r.getMsg());
return 0;
}
List<String> returnCodes = r.getData();
if(!CollectionUtils.isEmpty(returnCodes)){
for(String sapCode:returnCodes){
ProOrderWorkorder oworkSap = new ProOrderWorkorder();
oworkSap.setWorkorderCodeSap(sapCode);
oworkSap.setWorkorderId(workorderId);//工单编码
oworkSap.setUpdateTime(DateUtils.getNowDate());
/**pro_order_workorder**/
proOrderWorkorderMapper.updateWorkOrderCodeSap(oworkSap);
ProOrder order = this.getTopOrder(workorderId);
ProOrderWorkorder oworkSapParent = new ProOrderWorkorder();
oworkSapParent.setWorkorderCodeSap(sapCode);
oworkSapParent.setWorkorderId(order.getOrderCode());//母工单编码
oworkSapParent.setUpdateTime(DateUtils.getNowDate());
proOrderWorkorderMapper.updateWorkOrderCodeSap(oworkSapParent);
logger.info("sap工单回传sap虚拟工单号"+sapCode);
}
}
} }
} }
if(!CollectionUtils.isEmpty(sapList)){
R r = remoteSapService.SapCreateOrder(sapList);
logger.info("sap工单回传"+r.getMsg());
}
//下达工单 //下达工单
return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(workorderIds); //return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(workorderIds);
return 1;
} }
// //获取最低级材料 // //获取最低级材料
// private void getLastChildren(List<BaseBomComponentDTO> all, List<BaseBomComponentDTO> allChildren , BaseBomComponentDTO bc) { // private void getLastChildren(List<BaseBomComponentDTO> all, List<BaseBomComponentDTO> allChildren , BaseBomComponentDTO bc) {
// List<BaseBomComponentDTO> cList = all.stream().filter(item -> item.getCumc().equals(bc.getComponent())) // List<BaseBomComponentDTO> cList = all.stream().filter(item -> item.getCumc().equals(bc.getComponent()))
@ -290,14 +316,16 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
// //
// return bomdtos; // return bomdtos;
// } // }
// //根据工单子单获取最顶级订单的母单 //根据工单子单编码获取最顶级订单的母单
// private ProOrder getTopOrder(String workorderId){ private ProOrder getTopOrder(String workorderId){
// ProOrder topOrder = proOrderWorkorderMapper.getOrderCodeById(workorderId); //pro_order_workorder
// while(!"0".equals(topOrder.getParentOrder())&& com.op.common.core.utils.StringUtils.isNotEmpty(topOrder.getParentOrder())){ ProOrder topOrder = proOrderWorkorderMapper.getOrderCodeById(workorderId);
// topOrder = proOrderWorkorderMapper.getOrderCodeBySonCode(topOrder.getParentOrder()); while(!"0".equals(topOrder.getParentOrder())&& StringUtils.isNotEmpty(topOrder.getParentOrder())){
// } //pro_order_workorder
// return topOrder; topOrder = proOrderWorkorderMapper.getOrderCodeById(topOrder.getParentOrder());
// } }
return topOrder;
}
/** /**

@ -81,10 +81,7 @@
<select id="selectProOrderWorkorderByWorkorderId" parameterType="String" resultMap="ProOrderWorkorderResult"> <select id="selectProOrderWorkorderByWorkorderId" parameterType="String" resultMap="ProOrderWorkorderResult">
<include refid="selectProOrderWorkorderVo"/> <include refid="selectProOrderWorkorderVo"/>
where workorder_id = #{workorderId} where workorder_code = #{workorderId}
<if test="prodType != null and prodType != ''">
and prod_type = #{prodType}
</if>
</select> </select>
<select id="selectFirWorkOrder" parameterType="String" resultMap="ProOrderWorkorderResult"> <select id="selectFirWorkOrder" parameterType="String" resultMap="ProOrderWorkorderResult">
<include refid="selectProOrderWorkorderVo"/> <include refid="selectProOrderWorkorderVo"/>
@ -142,9 +139,9 @@
</foreach> </foreach>
</select> </select>
<select id="getOrderCodeById" resultType="com.op.plan.domain.ProOrder"> <select id="getOrderCodeById" resultType="com.op.plan.domain.ProOrder">
select order_code orderCode, select workorder_code orderCode,
bom_bo bomBo parent_order parentOrder
from pro_order_workorder where workorder_id = #{workorderId} from pro_order_workorder where workorder_code = #{workorderId}
</select> </select>
<select id="getOrderCodeBySonCode" resultType="com.op.plan.domain.ProOrder"> <select id="getOrderCodeBySonCode" resultType="com.op.plan.domain.ProOrder">
select parent_order parentOrder, select parent_order parentOrder,
@ -378,6 +375,12 @@
#{workorderCode} #{workorderCode}
</foreach> </foreach>
</update> </update>
<update id="updateWorkOrderCodeSap">
update pro_order_workorder
set workorder_code_sap = #{workorderCodeSap},
status = 'w1'
where workorder_code = #{workorderId}
</update>
<delete id="deleteProOrderWorkorderByWorkorderId" parameterType="String"> <delete id="deleteProOrderWorkorderByWorkorderId" parameterType="String">
delete from pro_order_workorder where workorder_id = #{workorderId} delete from pro_order_workorder where workorder_id = #{workorderId}

@ -1,4 +1,4 @@
package com.op.quality.Controller; package com.op.quality.controller;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.domain.R; import com.op.common.core.domain.R;

Loading…
Cancel
Save