领料单获取

highway
zhaoxiaolin 1 year ago
parent d70b27e01f
commit ae4d615aff

1
.gitignore vendored

@ -5,3 +5,4 @@
/**/.settings/* /**/.settings/*
/**/.node_modules/* /**/.node_modules/*
/**/*.idea /**/*.idea
/**/*.iml

@ -7,6 +7,8 @@ import com.op.system.api.factory.RemoteSapFallbackFactory;
import com.op.system.api.model.SapProOrder; import com.op.system.api.model.SapProOrder;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
/** /**
@ -18,12 +20,12 @@ import java.util.List;
public interface RemoteSapService { public interface RemoteSapService {
@PostMapping("/sap/shopOrderSync") @PostMapping("/sap/shopOrderSync")
public R<List<SapProOrder>> shopOrderSync(SapProOrder sapProOrder); public R<List<SapProOrder>> shopOrderSync(@RequestBody SapProOrder sapProOrder);
@PostMapping("/bomSync") @PostMapping("/bomSync")
public R<Boolean> bomSync(); public R<Boolean> bomSync();
@PostMapping("/sap/sapProRouteProcess") @PostMapping("/sap/sapProRouteProcess")
public R<Boolean> sapProRouteProcess(); public R<Boolean> sapProRouteProcess();
@PostMapping("/sap/materialPreparation") @PostMapping("/sap/materialPreparation")
public R<List<SapMaterialPreparation>>materialPreparation(SapMaterialPreparation sapMaterialPreparation); public R<List<SapMaterialPreparation>>materialPreparation(@RequestParam("shopOrder") String shopOrder);
} }

@ -7,6 +7,7 @@ import com.op.system.api.model.SapProOrder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
@ -32,7 +33,7 @@ public class RemoteSapFallbackFactory implements FallbackFactory<RemoteSapServic
} }
@Override @Override
public R<List<SapMaterialPreparation>> materialPreparation(SapMaterialPreparation sapMaterialPreparation) { public R<List<SapMaterialPreparation>> materialPreparation(String shopOrder) {
return R.fail("SAP服务获取SAP领料单失败:" + throwable.getMessage()); return R.fail("SAP服务获取SAP领料单失败:" + throwable.getMessage());
} }
}; };

@ -1,6 +1,11 @@
package com.op.job.task; package com.op.job.task;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.system.api.RemoteMesService; import com.op.system.api.RemoteMesService;
import com.op.system.api.RemoteSapService;
import com.op.system.api.model.SapProOrder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.StringUtils;
@ -16,6 +21,9 @@ public class RyTask {
@Autowired @Autowired
private RemoteMesService remoteMesService; private RemoteMesService remoteMesService;
@Autowired
private RemoteSapService remoteSapService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
} }
@ -28,6 +36,16 @@ public class RyTask {
System.out.println("执行无参方法"); System.out.println("执行无参方法");
} }
public void shopOrderSync(){
SapProOrder sapProOrder=new SapProOrder();
sapProOrder.setCreateTime(DateUtils.getNowDate());
remoteSapService.shopOrderSync(sapProOrder);
}
/**23
* 16
* 0 0 23 * * ?
*/
public void getMesPrepareTask(){ public void getMesPrepareTask(){
System.out.println("++同步领料单+开始++getMesPrepareTask+++++"); System.out.println("++同步领料单+开始++getMesPrepareTask+++++");
remoteMesService.getMesPrepare(); remoteMesService.getMesPrepare();

@ -119,6 +119,17 @@ public class MesPrepare extends BaseEntity {
/** 工厂编码 */ /** 工厂编码 */
@Excel(name = "工厂编码") @Excel(name = "工厂编码")
private String factoryCode; private String factoryCode;
private String dayStr;
public String getDayStr() {
return dayStr;
}
public void setDayStr(String dayStr) {
this.dayStr = dayStr;
}
public String getMaterialCode() { public String getMaterialCode() {
return materialCode; return materialCode;
} }

@ -58,4 +58,6 @@ public interface MesPrepareMapper {
* @return * @return
*/ */
public int deleteMesPrepareByPrepareIds(String[] prepareIds); public int deleteMesPrepareByPrepareIds(String[] prepareIds);
public List<MesPrepare> getParentWorkOrderT1(MesPrepare qo);
} }

@ -1,5 +1,6 @@
package com.op.mes.service.impl; package com.op.mes.service.impl;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -25,6 +26,8 @@ import org.springframework.stereotype.Service;
import com.op.mes.mapper.MesPrepareMapper; import com.op.mes.mapper.MesPrepareMapper;
import com.op.mes.domain.MesPrepare; import com.op.mes.domain.MesPrepare;
import com.op.mes.service.IMesPrepareService; import com.op.mes.service.IMesPrepareService;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestParam;
/** /**
* Service * Service
@ -43,6 +46,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
private RemoteUserService remoteUserService; private RemoteUserService remoteUserService;
@Autowired @Autowired
private MesPrepareDetailMapper mesPrepareDetailMapper; private MesPrepareDetailMapper mesPrepareDetailMapper;
/** /**
* *
* *
@ -119,9 +123,6 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
@Override @Override
public R getMesPrepare() { public R getMesPrepare() {
SapMaterialPreparation qo = new SapMaterialPreparation();
List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(qo).getData();
// 加载sf-cloud库的sys_datasource // 加载sf-cloud库的sys_datasource
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
sysUser.setUserId(1L); sysUser.setUserId(1L);
@ -135,7 +136,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
try { try {
dateSources.forEach(dateSource -> { dateSources.forEach(dateSource -> {
logger.info("++++++++++++" + dateSource.get("poolName") + "++++开始++++++++++"); logger.info("++++++++++++" + dateSource.get("poolName") + "++++开始++++++++++");
Runnable run = () -> getMesPrepareByFactory(dateSource.get("poolName"),sapMaterialPreparationList); Runnable run = () -> getMesPrepareByFactory(dateSource.get("poolName"));
executorService.execute(run); executorService.execute(run);
}); });
} catch (Exception e) { } catch (Exception e) {
@ -144,34 +145,52 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
} finally { } finally {
executorService.shutdown(); executorService.shutdown();
} }
return R.ok(true); return R.ok(true);
} }
public void getMesPrepareByFactory(String poolName, List<SapMaterialPreparation> sapMaterialPreparationList) {
public void getMesPrepareByFactory(String poolName) {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
List<SapMaterialPreparation> list = sapMaterialPreparationList.stream() // List<SapMaterialPreparation> list = sapMaterialPreparationList.stream()
.filter(a->a.getWERKS().equals(poolName)) // .filter(a->a.getWERKS().equals(poolName))
.collect(Collectors.toList()); // .collect(Collectors.toList());
//取出各单位集合中所有单位名称 //获取T+1天的所有母工单
Set<String> orderCodes = list.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet()); MesPrepare qo = new MesPrepare();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1);//这里改为1
Date time = cal.getTime();
qo.setDayStr(new SimpleDateFormat("yyyy-MM-dd").format(time));
List<MesPrepare> parents = mesPrepareMapper.getParentWorkOrderT1(qo);
if (CollectionUtils.isEmpty(parents)) {
System.out.println("T+1无母工单数据");
}
for (MesPrepare mesPrepare : parents) {
List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(mesPrepare.getWorkorderCode()).getData();
if (CollectionUtils.isEmpty(sapMaterialPreparationList)) {
System.out.println("sap无领料单数据");
}
//取出各领料单
Set<String> orderCodes = sapMaterialPreparationList.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet());
for (String orderCode : orderCodes) { for (String orderCode : orderCodes) {
/**mes_prepare**/ /**mes_prepare**/
String mesPrepareId = IdUtils.fastSimpleUUID(); String mesPrepareId = IdUtils.fastSimpleUUID();
MesPrepare mesPrepare = new MesPrepare(); MesPrepare mesPrepare0 = new MesPrepare();
mesPrepare.setPrepareId(mesPrepareId); mesPrepare0.setPrepareId(mesPrepareId);
mesPrepare.setWorkorderCode(orderCode);//工单(子) mesPrepare0.setWorkorderCode(orderCode);//工单(子)
mesPrepare.setCreateTime(DateUtils.getNowDate()); mesPrepare0.setCreateTime(DateUtils.getNowDate());
mesPrepare.setCreateBy(SecurityUtils.getUsername()); mesPrepare0.setCreateBy(SecurityUtils.getUsername());
mesPrepare.setStatus("L0");//默认待确认 mesPrepare0.setStatus("L0");//默认待确认
mesPrepareMapper.insertMesPrepare(mesPrepare); mesPrepareMapper.insertMesPrepare(mesPrepare0);
/**mes_prepare_detail**/ /**mes_prepare_detail**/
List<MesPrepareDetail> details = new ArrayList<>(); List<MesPrepareDetail> details = new ArrayList<>();
List<SapMaterialPreparation> listdetails = list.stream() // List<SapMaterialPreparation> listdetails = list.stream()
.filter(a->a.getAUFNR().equals(orderCode)) // .filter(a->a.getAUFNR().equals(orderCode))
.collect(Collectors.toList()); // .collect(Collectors.toList());
MesPrepareDetail detail = null; MesPrepareDetail detail = null;
Date createDate = DateUtils.getNowDate(); Date createDate = DateUtils.getNowDate();
for(SapMaterialPreparation sap:listdetails){ for (SapMaterialPreparation sap : sapMaterialPreparationList) {
detail = new MesPrepareDetail(); detail = new MesPrepareDetail();
detail.setPrepareId(mesPrepareId); detail.setPrepareId(mesPrepareId);
detail.setRecordId(IdUtils.fastSimpleUUID()); detail.setRecordId(IdUtils.fastSimpleUUID());
@ -192,6 +211,8 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
} }
mesPrepareDetailMapper.insertMesPrepareDetails(details); mesPrepareDetailMapper.insertMesPrepareDetails(details);
} }
}
} }

@ -118,9 +118,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)VALUES )VALUES
<foreach collection="list" item="d" index="index" separator=","> <foreach collection="list" item="d" index="index" separator=",">
( (
#{list.recordId},#{list.prepareId},#{list.materialCode},#{list.materialName},#{list.unit}, #{d.recordId},#{d.prepareId},#{d.materialCode},#{d.materailName},#{d.unit},
#{list.quantity},#{list.createBy},#{list.createTime},#{list.factoryCode},#{list.status}, #{d.quantity},#{d.createBy},#{d.createTime},#{d.factoryCode},#{d.status},
#{list.locator},#{list.needDate},#{list.recoil},#{list.fundQuanlity},#{list.buyFlag}, #{d.locator},#{d.needDate},#{d.recoil},#{d.fundQuanlity},#{d.buyFlag}
) )
</foreach> </foreach>

@ -101,117 +101,124 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectMesPrepareVo"/> <include refid="selectMesPrepareVo"/>
where prepare_id = #{prepareId} where prepare_id = #{prepareId}
</select> </select>
<!--T+1天的母单-->
<select id="getParentWorkOrderT1" resultType="com.op.mes.domain.MesPrepare">
select workorder_code workorderCode
from pro_order_workorder
where parent_order = '0' and prod_type = 'prod'
and CONVERT(varchar(100), product_date, 23) = #{dayStr}
</select>
<!-- <insert id="insertMesPrepare" parameterType="MesPrepare">--> <insert id="insertMesPrepare" parameterType="MesPrepare">
<!-- insert into mes_prepare--> insert into mes_prepare
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">--> <trim prefix="(" suffix=")" suffixOverrides=",">
<!-- <if test="prepareId != null">prepare_id,</if>--> <if test="prepareId != null">prepare_id,</if>
<!-- <if test="workorderCode != null and workorderCode != ''">workorder_code,</if>--> <if test="workorderCode != null and workorderCode != ''">workorder_code,</if>
<!-- <if test="workorderName != null">workorder_name,</if>--> <if test="workorderName != null">workorder_name,</if>
<!-- <if test="parentOrder != null and parentOrder != ''">parent_order,</if>--> <if test="parentOrder != null and parentOrder != ''">parent_order,</if>
<!-- <if test="orderId != null and orderId != ''">order_id,</if>--> <if test="orderId != null and orderId != ''">order_id,</if>
<!-- <if test="orderCode != null">order_code,</if>--> <if test="orderCode != null">order_code,</if>
<!-- <if test="productId != null">product_id,</if>--> <if test="productId != null">product_id,</if>
<!-- <if test="productCode != null and productCode != ''">product_code,</if>--> <if test="productCode != null and productCode != ''">product_code,</if>
<!-- <if test="prodType != null">prod_type,</if>--> <if test="prodType != null">prod_type,</if>
<!-- <if test="productName != null and productName != ''">product_name,</if>--> <if test="productName != null and productName != ''">product_name,</if>
<!-- <if test="productSpc != null">product_spc,</if>--> <if test="productSpc != null">product_spc,</if>
<!-- <if test="wetDetailPlanId != null">wet_detail_plan_id,</if>--> <if test="wetDetailPlanId != null">wet_detail_plan_id,</if>
<!-- <if test="productDate != null">product_date,</if>--> <if test="productDate != null">product_date,</if>
<!-- <if test="shiftId != null">shift_id,</if>--> <if test="shiftId != null">shift_id,</if>
<!-- <if test="ancestors != null">ancestors,</if>--> <if test="ancestors != null">ancestors,</if>
<!-- <if test="status != null">status,</if>--> <if test="status != null">status,</if>
<!-- <if test="remark != null">remark,</if>--> <if test="remark != null">remark,</if>
<!-- <if test="attr1 != null">attr1,</if>--> <if test="attr1 != null">attr1,</if>
<!-- <if test="attr2 != null">attr2,</if>--> <if test="attr2 != null">attr2,</if>
<!-- <if test="attr3 != null">attr3,</if>--> <if test="attr3 != null">attr3,</if>
<!-- <if test="attr4 != null">attr4,</if>--> <if test="attr4 != null">attr4,</if>
<!-- <if test="createBy != null">create_by,</if>--> <if test="createBy != null">create_by,</if>
<!-- <if test="createTime != null">create_time,</if>--> <if test="createTime != null">create_time,</if>
<!-- <if test="updateBy != null">update_by,</if>--> <if test="updateBy != null">update_by,</if>
<!-- <if test="updateTime != null">update_time,</if>--> <if test="updateTime != null">update_time,</if>
<!-- <if test="factoryCode != null">factory_code,</if>--> <if test="factoryCode != null">factory_code,</if>
<!-- <if test="materialCode != null and materialCode != ''">material_code,</if>--> <if test="materialCode != null and materialCode != ''">material_code,</if>
<!-- <if test="materialName != null and materialName != ''">material_name,</if>--> <if test="materialName != null and materialName != ''">material_name,</if>
<!-- <if test="materialSpc != null">material_spc,</if>--> <if test="materialSpc != null">material_spc,</if>
<!-- <if test="unit != null and unit != ''">unit,</if>--> <if test="unit != null and unit != ''">unit,</if>
<!-- <if test="quantity != null">quantity,</if>--> <if test="quantity != null">quantity,</if>
<!-- </trim>--> </trim>
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">--> <trim prefix="values (" suffix=")" suffixOverrides=",">
<!-- <if test="prepareId != null">#{prepareId},</if>--> <if test="prepareId != null">#{prepareId},</if>
<!-- <if test="workorderCode != null and workorderCode != ''">#{workorderCode},</if>--> <if test="workorderCode != null and workorderCode != ''">#{workorderCode},</if>
<!-- <if test="workorderName != null">#{workorderName},</if>--> <if test="workorderName != null">#{workorderName},</if>
<!-- <if test="parentOrder != null and parentOrder != ''">#{parentOrder},</if>--> <if test="parentOrder != null and parentOrder != ''">#{parentOrder},</if>
<!-- <if test="orderId != null and orderId != ''">#{orderId},</if>--> <if test="orderId != null and orderId != ''">#{orderId},</if>
<!-- <if test="orderCode != null">#{orderCode},</if>--> <if test="orderCode != null">#{orderCode},</if>
<!-- <if test="productId != null">#{productId},</if>--> <if test="productId != null">#{productId},</if>
<!-- <if test="productCode != null and productCode != ''">#{productCode},</if>--> <if test="productCode != null and productCode != ''">#{productCode},</if>
<!-- <if test="prodType != null">#{prodType},</if>--> <if test="prodType != null">#{prodType},</if>
<!-- <if test="productName != null and productName != ''">#{productName},</if>--> <if test="productName != null and productName != ''">#{productName},</if>
<!-- <if test="productSpc != null">#{productSpc},</if>--> <if test="productSpc != null">#{productSpc},</if>
<!-- <if test="wetDetailPlanId != null">#{wetDetailPlanId},</if>--> <if test="wetDetailPlanId != null">#{wetDetailPlanId},</if>
<!-- <if test="productDate != null">#{productDate},</if>--> <if test="productDate != null">#{productDate},</if>
<!-- <if test="shiftId != null">#{shiftId},</if>--> <if test="shiftId != null">#{shiftId},</if>
<!-- <if test="ancestors != null">#{ancestors},</if>--> <if test="ancestors != null">#{ancestors},</if>
<!-- <if test="status != null">#{status},</if>--> <if test="status != null">#{status},</if>
<!-- <if test="remark != null">#{remark},</if>--> <if test="remark != null">#{remark},</if>
<!-- <if test="attr1 != null">#{attr1},</if>--> <if test="attr1 != null">#{attr1},</if>
<!-- <if test="attr2 != null">#{attr2},</if>--> <if test="attr2 != null">#{attr2},</if>
<!-- <if test="attr3 != null">#{attr3},</if>--> <if test="attr3 != null">#{attr3},</if>
<!-- <if test="attr4 != null">#{attr4},</if>--> <if test="attr4 != null">#{attr4},</if>
<!-- <if test="createBy != null">#{createBy},</if>--> <if test="createBy != null">#{createBy},</if>
<!-- <if test="createTime != null">#{createTime},</if>--> <if test="createTime != null">#{createTime},</if>
<!-- <if test="updateBy != null">#{updateBy},</if>--> <if test="updateBy != null">#{updateBy},</if>
<!-- <if test="updateTime != null">#{updateTime},</if>--> <if test="updateTime != null">#{updateTime},</if>
<!-- <if test="factoryCode != null">#{factoryCode},</if>--> <if test="factoryCode != null">#{factoryCode},</if>
<!-- <if test="materialCode != null and materialCode != ''">#{materialCode},</if>--> <if test="materialCode != null and materialCode != ''">#{materialCode},</if>
<!-- <if test="materialName != null and materialName != ''">#{materialName},</if>--> <if test="materialName != null and materialName != ''">#{materialName},</if>
<!-- <if test="materialSpc != null">#{materialSpc},</if>--> <if test="materialSpc != null">#{materialSpc},</if>
<!-- <if test="unit != null and unit != ''">#{unit},</if>--> <if test="unit != null and unit != ''">#{unit},</if>
<!-- <if test="quantity != null">#{quantity},</if>--> <if test="quantity != null">#{quantity},</if>
<!-- </trim>--> </trim>
<!-- </insert>--> </insert>
<!-- <update id="updateMesPrepare" parameterType="MesPrepare">--> <update id="updateMesPrepare" parameterType="MesPrepare">
<!-- update mes_prepare--> update mes_prepare
<!-- <trim prefix="SET" suffixOverrides=",">--> <trim prefix="SET" suffixOverrides=",">
<!-- <if test="workorderCode != null and workorderCode != ''">workorder_code = #{workorderCode},</if>--> <if test="workorderCode != null and workorderCode != ''">workorder_code = #{workorderCode},</if>
<!-- <if test="workorderName != null">workorder_name = #{workorderName},</if>--> <if test="workorderName != null">workorder_name = #{workorderName},</if>
<!-- <if test="parentOrder != null and parentOrder != ''">parent_order = #{parentOrder},</if>--> <if test="parentOrder != null and parentOrder != ''">parent_order = #{parentOrder},</if>
<!-- <if test="orderId != null and orderId != ''">order_id = #{orderId},</if>--> <if test="orderId != null and orderId != ''">order_id = #{orderId},</if>
<!-- <if test="orderCode != null">order_code = #{orderCode},</if>--> <if test="orderCode != null">order_code = #{orderCode},</if>
<!-- <if test="productId != null">product_id = #{productId},</if>--> <if test="productId != null">product_id = #{productId},</if>
<!-- <if test="productCode != null and productCode != ''">product_code = #{productCode},</if>--> <if test="productCode != null and productCode != ''">product_code = #{productCode},</if>
<!-- <if test="prodType != null">prod_type = #{prodType},</if>--> <if test="prodType != null">prod_type = #{prodType},</if>
<!-- <if test="productName != null and productName != ''">product_name = #{productName},</if>--> <if test="productName != null and productName != ''">product_name = #{productName},</if>
<!-- <if test="productSpc != null">product_spc = #{productSpc},</if>--> <if test="productSpc != null">product_spc = #{productSpc},</if>
<!-- <if test="wetDetailPlanId != null">wet_detail_plan_id = #{wetDetailPlanId},</if>--> <if test="wetDetailPlanId != null">wet_detail_plan_id = #{wetDetailPlanId},</if>
<!-- <if test="productDate != null">product_date = #{productDate},</if>--> <if test="productDate != null">product_date = #{productDate},</if>
<!-- <if test="shiftId != null">shift_id = #{shiftId},</if>--> <if test="shiftId != null">shift_id = #{shiftId},</if>
<!-- <if test="ancestors != null">ancestors = #{ancestors},</if>--> <if test="ancestors != null">ancestors = #{ancestors},</if>
<!-- <if test="status != null">status = #{status},</if>--> <if test="status != null">status = #{status},</if>
<!-- <if test="remark != null">remark = #{remark},</if>--> <if test="remark != null">remark = #{remark},</if>
<!-- <if test="attr1 != null">attr1 = #{attr1},</if>--> <if test="attr1 != null">attr1 = #{attr1},</if>
<!-- <if test="attr2 != null">attr2 = #{attr2},</if>--> <if test="attr2 != null">attr2 = #{attr2},</if>
<!-- <if test="attr3 != null">attr3 = #{attr3},</if>--> <if test="attr3 != null">attr3 = #{attr3},</if>
<!-- <if test="attr4 != null">attr4 = #{attr4},</if>--> <if test="attr4 != null">attr4 = #{attr4},</if>
<!-- <if test="createBy != null">create_by = #{createBy},</if>--> <if test="createBy != null">create_by = #{createBy},</if>
<!-- <if test="createTime != null">create_time = #{createTime},</if>--> <if test="createTime != null">create_time = #{createTime},</if>
<!-- <if test="updateBy != null">update_by = #{updateBy},</if>--> <if test="updateBy != null">update_by = #{updateBy},</if>
<!-- <if test="updateTime != null">update_time = #{updateTime},</if>--> <if test="updateTime != null">update_time = #{updateTime},</if>
<!-- <if test="factoryCode != null">factory_code = #{factoryCode},</if>--> <if test="factoryCode != null">factory_code = #{factoryCode},</if>
<!-- </trim>--> </trim>
<!-- where prepare_id = #{prepareId}--> where prepare_id = #{prepareId}
<!-- </update>--> </update>
<!-- <delete id="deleteMesPrepareByPrepareId" parameterType="String">--> <delete id="deleteMesPrepareByPrepareId" parameterType="String">
<!-- delete from mes_prepare where prepare_id = #{prepareId}--> delete from mes_prepare where prepare_id = #{prepareId}
<!-- </delete>--> </delete>
<!-- <delete id="deleteMesPrepareByPrepareIds" parameterType="String">--> <delete id="deleteMesPrepareByPrepareIds" parameterType="String">
<!-- delete from mes_prepare where prepare_id in --> delete from mes_prepare where prepare_id in
<!-- <foreach item="prepareId" collection="array" open="(" separator="," close=")">--> <foreach item="prepareId" collection="array" open="(" separator="," close=")">
<!-- #{prepareId}--> #{prepareId}
<!-- </foreach>--> </foreach>
<!-- </delete>--> </delete>
</mapper> </mapper>

@ -1,5 +1,6 @@
package com.op.sap.controller; package com.op.sap.controller;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.DateUtils;
import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
@ -10,6 +11,7 @@ import com.op.sap.service.SapBomService;
import com.op.sap.domain.SapBom; import com.op.sap.domain.SapBom;
import com.op.sap.service.SapMaterialPreparationService; import com.op.sap.service.SapMaterialPreparationService;
import com.op.sap.service.SapOrderService; import com.op.sap.service.SapOrderService;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.op.system.api.model.SapProOrder; import com.op.system.api.model.SapProOrder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -35,7 +37,7 @@ public class SapController extends BaseController {
*/ */
@PostMapping("/shopOrderSync") @PostMapping("/shopOrderSync")
@Log(title = "同步SAP订单", businessType = BusinessType.SAP) @Log(title = "同步SAP订单", businessType = BusinessType.SAP)
public AjaxResult shopOrderSync(@RequestBody SapProOrder sapProOrder){ public R<List<SapProOrder>> shopOrderSync(@RequestBody SapProOrder sapProOrder){
return sapOrderService.shopOrderSync(sapProOrder); return sapOrderService.shopOrderSync(sapProOrder);
} }
@ -66,7 +68,7 @@ public class SapController extends BaseController {
@PostMapping("/materialPreparation") @PostMapping("/materialPreparation")
@Log(title = "生产订单备料单接口", businessType = BusinessType.SAP) @Log(title = "生产订单备料单接口", businessType = BusinessType.SAP)
public AjaxResult materialPreparation(@RequestParam("shopOrder") String shopOrder){ public R<List<SapMaterialPreparation>> materialPreparation(@RequestParam("shopOrder") String shopOrder){
return sapMaterialPreparationService.MaterialPreparation(shopOrder); return sapMaterialPreparationService.MaterialPreparation(shopOrder);
} }

@ -1,8 +1,12 @@
package com.op.sap.service; package com.op.sap.service;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import java.util.List;
public interface SapMaterialPreparationService { public interface SapMaterialPreparationService {
AjaxResult MaterialPreparation(String shopOrder); R<List<SapMaterialPreparation>> MaterialPreparation(String shopOrder);
} }

@ -1,5 +1,6 @@
package com.op.sap.service; package com.op.sap.service;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
import com.op.sap.domain.SapBom; import com.op.sap.domain.SapBom;
import com.op.system.api.model.SapProOrder; import com.op.system.api.model.SapProOrder;
@ -8,5 +9,5 @@ import java.util.List;
public interface SapOrderService { public interface SapOrderService {
AjaxResult shopOrderSync(SapProOrder sapProOrder); R<List<SapProOrder>> shopOrderSync(SapProOrder sapProOrder);
} }

@ -1,10 +1,12 @@
package com.op.sap.service.impl; package com.op.sap.service.impl;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
import com.op.sap.domain.SapMaterialPreparation;
import com.op.sap.mapper.SapMaterialPreparationMapper; import com.op.sap.mapper.SapMaterialPreparationMapper;
import com.op.sap.service.SapMaterialPreparationService; import com.op.sap.service.SapMaterialPreparationService;
import com.op.sap.util.SAPConnUtils; import com.op.sap.util.SAPConnUtils;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.sap.conn.jco.*; import com.sap.conn.jco.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -19,7 +21,7 @@ public class SapMaterialPreparationServiceImpl implements SapMaterialPreparation
SapMaterialPreparationMapper sapMaterialPreparationMapper; SapMaterialPreparationMapper sapMaterialPreparationMapper;
@Override @Override
public AjaxResult MaterialPreparation(String shopOrder) { public R<List<SapMaterialPreparation>> MaterialPreparation(String shopOrder) {
// 连接 // 连接
try { try {
@ -86,9 +88,9 @@ public class SapMaterialPreparationServiceImpl implements SapMaterialPreparation
sapMaterialPreparation.setZQLSL(ZQLSL); sapMaterialPreparation.setZQLSL(ZQLSL);
sapMaterialPreparationList.add(sapMaterialPreparation); sapMaterialPreparationList.add(sapMaterialPreparation);
} }
return AjaxResult.success(sapMaterialPreparationList); return R.ok(sapMaterialPreparationList);
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error(e.getMessage()); return R.fail(e.getMessage());
} }
} }
} }

@ -1,5 +1,6 @@
package com.op.sap.service.impl; package com.op.sap.service.impl;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
@ -27,12 +28,8 @@ import java.util.List;
@Service @Service
public class SapOrderServiceImpl implements SapOrderService { public class SapOrderServiceImpl implements SapOrderService {
@Autowired
private RemotePlanService remotePlanService;
@Override @Override
public AjaxResult shopOrderSync(SapProOrder sapProOrder) { public R<List<SapProOrder>> shopOrderSync(SapProOrder sapProOrder) {
try { try {
// 获取调用 RFC 函数对象 // 获取调用 RFC 函数对象
@ -98,7 +95,7 @@ public class SapOrderServiceImpl implements SapOrderService {
// remoteMesService.sapAddOrder(proOrder); // remoteMesService.sapAddOrder(proOrder);
} }
return AjaxResult.success(proOrderList); return R.ok(proOrderList);
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }

Loading…
Cancel
Save