成品订单修改:更新范围>=20230921

highway
zhaoxiaolin 1 year ago
parent 0da428ce6f
commit d4446de5fc

@ -2,10 +2,7 @@ package com.op.system.api;
import com.op.common.core.constant.ServiceNameConstants;
import com.op.common.core.domain.R;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.op.system.api.domain.sap.SapRFW;
import com.op.system.api.domain.sap.SapWorkCenter;
import com.op.system.api.domain.sap.*;
import com.op.system.api.factory.RemoteSapFallbackFactory;
import com.op.system.api.model.SapProOrder;
import org.springframework.cloud.openfeign.FeignClient;
@ -23,7 +20,7 @@ import java.util.List;
public interface RemoteSapService {
@PostMapping("/sap/shopOrderSync")
public R<List<SapProOrder>> shopOrderSync(@RequestBody SapProOrder sapProOrder);
public R<List<SapProOrder>> shopOrderSync(@RequestBody SapShopOrderQuery sapProOrder);
@PostMapping("/bomSync")
public R<Boolean> bomSync();
@ -48,9 +45,13 @@ public interface RemoteSapService {
/**工作中心**/
@PostMapping("/sap/sapWorkCenterSync")
public R sapWorkCenterSync(@RequestBody SapWorkCenter sapWorkCenter);
public R sapWorkCenterSync();
/**供应商**/
@PostMapping("/sap/sapSupplierSync")
public R sapSupplierSync(@RequestBody SapWorkCenter sapWorkCenter);
public R sapSupplierSync();
/**客户**/
@PostMapping("/sap/sapCustomSync")
public R sapCustomSync();
}

@ -0,0 +1,33 @@
package com.op.system.api.domain.sap;
public class SapShopOrderQuery {
// S_AUFNR订单号 S_MATNR物料号 S_ERDAT(创建日期)
private String aufnr;
private String matnr;
private String erdat;
public String getAufnr() {
return aufnr;
}
public void setAufnr(String aufnr) {
this.aufnr = aufnr;
}
public String getMatnr() {
return matnr;
}
public void setMatnr(String matnr) {
this.matnr = matnr;
}
public String getErdat() {
return erdat;
}
public void setErdat(String erdat) {
this.erdat = erdat;
}
}

@ -6,13 +6,13 @@ import javax.xml.crypto.Data;
import java.util.Date;
public class SapWorkCenter {
private String weeks;
private String name1;
private String arbpl;
private String ktext;
private String weeks;//工厂
private String name1;//工厂描述
private String arbpl;//工作中心
private String ktext;//工作中心描述
private String parentId;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date aedat_grnd;
private Date aedat_grnd;//更新日期
public String getWeeks() {
return weeks;
@ -38,6 +38,14 @@ public class SapWorkCenter {
this.arbpl = arbpl;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getKtext() {
return ktext;
}

@ -2,10 +2,7 @@ package com.op.system.api.factory;
import com.op.common.core.domain.R;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.op.system.api.domain.sap.SapRFW;
import com.op.system.api.domain.sap.SapWorkCenter;
import com.op.system.api.domain.sap.*;
import com.op.system.api.model.SapProOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -21,7 +18,7 @@ public class RemoteSapFallbackFactory implements FallbackFactory<RemoteSapServic
log.error("SAP服务调用失败:{}", throwable.getMessage());
return new RemoteSapService() {
@Override
public R<List<SapProOrder>> shopOrderSync(SapProOrder sapProOrder) {
public R<List<SapProOrder>> shopOrderSync(SapShopOrderQuery sapProOrder) {
return R.fail("SAP服务获取SAP订单失败:" + throwable.getMessage());
}
@ -56,14 +53,20 @@ public class RemoteSapFallbackFactory implements FallbackFactory<RemoteSapServic
}
@Override
public R sapWorkCenterSync(SapWorkCenter sapWorkCenter) {
return null;
public R sapWorkCenterSync() {
return R.fail("sap工作中心同步失败" + throwable.getMessage());
}
@Override
public R sapSupplierSync(SapWorkCenter sapWorkCenter) {
return null;
public R sapSupplierSync() {
return R.fail("sap供应商同步失败" + throwable.getMessage());
}
@Override
public R sapCustomSync() {
return R.fail("sap客户同步失败" + throwable.getMessage());
}
};
}
}

@ -55,6 +55,7 @@ public class SapProOrder extends TreeEntity {
private String workerOrder;
private Date createTime;
private String createTimeStr;
public Long getQuantitySplit() {
return quantitySplit;
@ -106,6 +107,14 @@ public class SapProOrder extends TreeEntity {
@Excel(name = "产品类型")
private String prodType;
public String getCreateTimeStr() {
return createTimeStr;
}
public void setCreateTimeStr(String createTimeStr) {
this.createTimeStr = createTimeStr;
}
@Override
public Date getCreateTime() {
return createTime;

@ -1,12 +1,9 @@
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.RemotePlanService;
import com.op.system.api.RemoteSapService;
import com.op.system.api.model.SapProOrder;
import com.op.system.api.domain.sap.SapShopOrderQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -43,8 +40,8 @@ public class RyTask {
}
public void shopOrderSync(){
SapProOrder sapProOrder=new SapProOrder();
sapProOrder.setCreateTime(DateUtils.getNowDate());
SapShopOrderQuery sapProOrder = new SapShopOrderQuery();
//sapProOrder.setCreateTime(DateUtils.getNowDate());//TODO;
remoteSapService.shopOrderSync(sapProOrder);
}
@ -76,4 +73,21 @@ public class RyTask {
logger.info("++报工接口+开始++reportWorkTask+++++");
remoteMesService.reportWorkTask();
}
/**每天执行010一次**/
public void sapWorkCenterTask(){
logger.info("++工作中心接口+开始++sapWorkCenterTask+++++");
remoteSapService.sapWorkCenterSync();
}
/**每天执行020一次**/
public void sapSupplierTask(){
logger.info("++供应商接口+开始++sapSupplierTask+++++");
remoteSapService.sapSupplierSync();
}
/**每天执行030一次**/
public void sapCustomTask(){
logger.info("++客户接口+开始++sapCustomTask+++++");
remoteSapService.sapCustomSync();
}
}

@ -151,6 +151,15 @@ public class MesReportWork extends BaseEntity {
private String sac4;
private String sac5;
private String sac6;
private String prodType;
public String getProdType() {
return prodType;
}
public void setProdType(String prodType) {
this.prodType = prodType;
}
public String getWorkorderCodeSap() {
return workorderCodeSap;

@ -252,6 +252,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
MesReportWork mesReportWork = new MesReportWork();
mesReportWork.setUploadStatus("1");//除了1报工成功的都需要报工
mesReportWork.setProdType("prod");
List<MesReportWork> reportWorks = mesReportWorkMapper.getReportWorkList(mesReportWork);
for(MesReportWork work:reportWorks){
SapRFW sapRFW = new SapRFW();

@ -180,7 +180,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from mes_report_work mrw
left join pro_order_workorder ow on mrw.workorder_code = ow.workorder_code
left join pro_route rte on rte.route_code = ow.route_code
where mrw.upload_status != #{uploadStatus}
where mrw.upload_status != #{uploadStatus} and mrw.prod_type = #{prodType}
order by mrw.create_time
</select>
<select id="getDailyReport" resultType="com.op.mes.domain.MesDailyReport">

@ -28,7 +28,9 @@ import com.op.plan.mapper.*;
import com.op.system.api.RemoteSapService;
import com.op.system.api.RemoteUserService;
import com.op.system.api.domain.SysUser;
import com.op.system.api.domain.sap.SapShopOrderQuery;
import com.op.system.api.model.SapProOrder;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
@ -416,17 +418,23 @@ public class ProOrderServiceImpl implements IProOrderService {
@Override
@DS("#header.poolName")
public AjaxResult syncSAP() {
SapProOrder sapqo = new SapProOrder();
sapqo.setCreateTime(DateUtils.addDays(DateUtils.getNowDate(),-4));
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
sapqo.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
SapShopOrderQuery sapqo = new SapShopOrderQuery();
// sapqo.setCreateTime(DateUtils.addDays(DateUtils.getNowDate(),-4));
// //获取当前所选工厂
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// String key = "#header.poolName";
// sapqo.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
SapProOrder maxCreateTime = proOrderMapper.getMaxCreatetime();
if(maxCreateTime == null ){
sapqo.setErdat(DateFormatUtils.format(new Date(), "yyyyMMdd"));//S_ERDAT(创建日期) 例如20230923
}else{
sapqo.setErdat(maxCreateTime.getCreateTimeStr());//S_ERDAT(创建日期) 例如20230923
}
//取>=20230923的sap数据
R<List<SapProOrder>> rSapProOrder = remoteSapService.shopOrderSync(sapqo);//sap只能同步指定日期的数据
if(rSapProOrder == null){
return AjaxResult.error("无"+sapqo.getCreateTime()+"之后的最新订单");
return AjaxResult.error("无"+sapqo.getErdat()+"之后的最新订单");
}
List<SapProOrder> newOrders = rSapProOrder.getData();
@ -676,17 +684,24 @@ public class ProOrderServiceImpl implements IProOrderService {
public void getSAPOrderByFactory(String poolName) {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
SapProOrder sapqo = new SapProOrder();//proOrderMapper.getMaxCreatetime();
Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_MONTH,1);//明天
sapqo.setCreateTime(calendar.getTime());
sapqo.setFactoryCode(poolName.replace("ds_",""));
// SapProOrder sapqo = new SapProOrder();//proOrderMapper.getMaxCreatetime();
// Calendar calendar = Calendar.getInstance();
//// calendar.add(Calendar.DAY_OF_MONTH,1);//明天
// sapqo.setCreateTime(calendar.getTime());
//
// sapqo.setFactoryCode(poolName.replace("ds_",""));
SapShopOrderQuery sapqo = new SapShopOrderQuery();
SapProOrder maxCreateTime = proOrderMapper.getMaxCreatetime();
if(maxCreateTime == null ){
sapqo.setErdat(DateFormatUtils.format(new Date(), "yyyyMMdd"));//S_ERDAT(创建日期) 例如20230923
}else{
sapqo.setErdat(maxCreateTime.getCreateTimeStr());//S_ERDAT(创建日期) 例如20230923
}
R<List<SapProOrder>> rSapProOrder = remoteSapService.shopOrderSync(sapqo);
List<SapProOrder> newOrders = rSapProOrder.getData();
if(CollectionUtils.isEmpty(newOrders)){
logger.error("无"+sapqo.getCreateTime()+"之后的最新订单");
logger.error("无"+sapqo.getErdat()+"之后的最新订单");
}
syncSAPFunc(newOrders);
}

@ -135,7 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE bst.Shift_Id = #{shiftId}
</select>
<select id="getMaxCreatetime" resultType="com.op.system.api.model.SapProOrder">
select CONVERT(varchar(100),max(create_time), 20) createTime
select CONVERT(varchar(112),max(create_time), 112) createTimeStr
from pro_order
where order_type != 'white'
and del_flag = '0'

@ -1,21 +1,28 @@
package com.op.sap.controller;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.web.controller.BaseController;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.sap.domain.vo.SapBomQuery;
import com.op.sap.domain.vo.SapRouterQuery;
import com.op.sap.domain.vo.*;
import com.op.sap.mapper.SapBomMapper;
import com.op.sap.service.*;
import com.op.system.api.RemoteUserService;
import com.op.system.api.domain.SysUser;
import com.op.system.api.domain.sap.*;
import com.op.system.api.domain.sap.SapCustom;
import com.op.system.api.domain.sap.SapSupplier;
import com.op.system.api.model.SapProOrder;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/sap")
@ -39,25 +46,30 @@ public class SapController extends BaseController {
@Autowired
private SapWorkCenterService sapWorkCenterService;
@Autowired
private RemoteUserService remoteUserService;
@Autowired
private SapBomMapper sapBomMapper;
/**
*
* @return
*/
@PostMapping("/shopOrderSync")
@Log(title = "同步SAP订单", businessType = BusinessType.SAP)
public R<List<SapProOrder>> shopOrderSync(@RequestBody SapProOrder sapProOrder){
public R<List<SapProOrder>> shopOrderSync(@RequestBody SapShopOrderQuery sapProOrder){
return sapOrderService.shopOrderSync(sapProOrder);
}
/**
*
* @param sapBaseProduct
* @param sapItemQuery
* @return
*/
@PostMapping("/itemSync")
@Log(title = "同步SAP物料清单", businessType = BusinessType.SAP)
public R itemSync(@RequestBody SapBaseProduct sapBaseProduct){
return sapItemSyncService.itemSync(sapBaseProduct);
public R itemSync(@RequestBody SapItemQuery sapItemQuery){
return sapItemSyncService.itemSync(sapItemQuery);
}
/**
@ -70,6 +82,18 @@ public class SapController extends BaseController {
return sapBomService.bomSync(sapBomQuery);
}
/**
* 线
* @param sapRouterQuery
* @return
*/
@PostMapping("/sapRouterSync")
@Log(title = "工艺路线同步接口", businessType = BusinessType.SAP)
public R sapRouerSync(@RequestBody SapRouterQuery sapRouterQuery) {
return sapRouterService.sapRouterSync(sapRouterQuery);
}
/**
*
* @param shopOrder
@ -117,31 +141,49 @@ public class SapController extends BaseController {
}
/**
* 线
* @return
*/
@PostMapping("/sapRouterSync")
@Log(title = "工艺路线同步接口", businessType = BusinessType.SAP)
public R sapRouerSync(@RequestBody SapRouterQuery sapRouterQuery) {
return sapRouterService.sapRouterSync(sapRouterQuery);
}
/**
*
* @return
*/
@PostMapping("/sapWorkCenterSync")
@Log(title = "工作中心接口", businessType = BusinessType.SAP)
public R sapWorkCenterSync(){
return sapWorkCenterService.sapWorkCenterSync();
SapWorkCenterQuery qo = new SapWorkCenterQuery();
// 加载sf-cloud库的sys_datasource
SysUser sysUser = new SysUser();
sysUser.setUserId(1L);
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
List<Map<String, String>> dateSources = dateSources0.getData();
dateSources.forEach(dateSource -> {
logger.info("++++++++++++" + dateSource.get("poolName") + "++++工作中心开始++++++++++");
DynamicDataSourceContextHolder.push(dateSource.get("poolName"));// 这是数据源的key
qo.setWerks(dateSource.get("poolName").replace("ds_",""));//工厂
Date maxTime = sapBomMapper.getMaxTime();
if(maxTime != null){
qo.setAedat(DateFormatUtils.format(maxTime, "yyyyMMdd"));//修改日期20230923
}
R r = sapWorkCenterService.sapWorkCenterSync(qo);
if(r.getCode()==200){
List<SapWorkCenter> dtos = (List<SapWorkCenter>) r.getData();
sapWorkCenterService.syncWorkCenter(dtos);
}else{
logger.error("++++++++++++" + dateSource.get("poolName")+"错误信息:"+ r.getMsg());
}
logger.error("++++++++++++" + dateSource.get("poolName") + "++++工作中心结束++++++++++");
});
return R.ok();
}
/**
*
* @return
*/
@PostMapping("/sapSupplierSync")
@Log(title = "供应商主数据", businessType = BusinessType.SAP)
public R sapSupplierSync(@RequestBody SapSupplier sapSupplier){
return sapWorkCenterService.sapSupplierSync(sapSupplier);
public R sapSupplierSync(){
SapSupplierQuery sapSupplierQuery = new SapSupplierQuery();
return sapWorkCenterService.sapSupplierSync(sapSupplierQuery);
}
/**
@ -151,7 +193,8 @@ public class SapController extends BaseController {
@PostMapping("/sapCustomSync")
@Log(title = "客户主数据", businessType = BusinessType.SAP)
public R sapCustomSync(@RequestBody SapCustom sapCustom){
public R sapCustomSync(){
SapCustom sapCustom = new SapCustom();
return sapWorkCenterService.sapCustomSync(sapCustom);
}

@ -1,125 +0,0 @@
package com.op.sap.domain;
public class SapMaterialPreparation {
//订单号
private String AUFNR;
//预留/相关需求的项目编号
private String RSPOS;
//物料号
private String MATNR;
//物料描述(短文本)
private String MAKTX;
//工厂
private String WERKS;
//库存地点
private String LGORT;
//组件的需求日期
private String BDTER;
//需求量
private String BDMNG;
//欠料数量
private String ZQLSL;
//基本计量单位
private String MEINS;
//标识:反冲
private String RGEKZ;
//直接采购标识
private String DBSKZ;
public String getAUFNR() {
return AUFNR;
}
public void setAUFNR(String AUFNR) {
this.AUFNR = AUFNR;
}
public String getRSPOS() {
return RSPOS;
}
public void setRSPOS(String RSPOS) {
this.RSPOS = RSPOS;
}
public String getMATNR() {
return MATNR;
}
public void setMATNR(String MATNR) {
this.MATNR = MATNR;
}
public String getMAKTX() {
return MAKTX;
}
public void setMAKTX(String MAKTX) {
this.MAKTX = MAKTX;
}
public String getWERKS() {
return WERKS;
}
public void setWERKS(String WERKS) {
this.WERKS = WERKS;
}
public String getLGORT() {
return LGORT;
}
public void setLGORT(String LGORT) {
this.LGORT = LGORT;
}
public String getBDTER() {
return BDTER;
}
public void setBDTER(String BDTER) {
this.BDTER = BDTER;
}
public String getBDMNG() {
return BDMNG;
}
public void setBDMNG(String BDMNG) {
this.BDMNG = BDMNG;
}
public String getZQLSL() {
return ZQLSL;
}
public void setZQLSL(String ZQLSL) {
this.ZQLSL = ZQLSL;
}
public String getMEINS() {
return MEINS;
}
public void setMEINS(String MEINS) {
this.MEINS = MEINS;
}
public String getRGEKZ() {
return RGEKZ;
}
public void setRGEKZ(String RGEKZ) {
this.RGEKZ = RGEKZ;
}
public String getDBSKZ() {
return DBSKZ;
}
public void setDBSKZ(String DBSKZ) {
this.DBSKZ = DBSKZ;
}
}

@ -0,0 +1,56 @@
package com.op.sap.domain.vo;
public class SapItemQuery {
/* S_MATNR
S_MTART
S_MATKL
S_ERSDA
S_LAEDA
*/
private String matnr;
private String mtart;
private String matkl;
private String ersda;
private String laeda;
public String getMatnr() {
return matnr;
}
public void setMatnr(String matnr) {
this.matnr = matnr;
}
public String getMtart() {
return mtart;
}
public void setMtart(String mtart) {
this.mtart = mtart;
}
public String getMatkl() {
return matkl;
}
public void setMatkl(String matkl) {
this.matkl = matkl;
}
public String getErsda() {
return ersda;
}
public void setErsda(String ersda) {
this.ersda = ersda;
}
public String getLaeda() {
return laeda;
}
public void setLaeda(String laeda) {
this.laeda = laeda;
}
}

@ -0,0 +1,36 @@
package com.op.sap.domain.vo;
public class SapSupplierQuery {
/* S_BUKRS
S_LIFNR
S_ERDAT */
private String bukrs;
private String lifnr;
private String erdat;
public String getBukrs() {
return bukrs;
}
public void setBukrs(String bukrs) {
this.bukrs = bukrs;
}
public String getLifnr() {
return lifnr;
}
public void setLifnr(String lifnr) {
this.lifnr = lifnr;
}
public String getErdat() {
return erdat;
}
public void setErdat(String erdat) {
this.erdat = erdat;
}
}

@ -0,0 +1,36 @@
package com.op.sap.domain.vo;
public class SapWorkCenterQuery {
/*
werks
arbpl
aedat
*/
private String werks;
private String arbpl;
private String aedat;
public String getWerks() {
return werks;
}
public void setWerks(String werks) {
this.werks = werks;
}
public String getArbpl() {
return arbpl;
}
public void setArbpl(String arbpl) {
this.arbpl = arbpl;
}
public String getAedat() {
return aedat;
}
public void setAedat(String aedat) {
this.aedat = aedat;
}
}

@ -2,8 +2,11 @@ package com.op.sap.mapper;
import com.op.system.api.domain.sap.SapBom;
import com.op.system.api.domain.sap.SapBomComponent;
import com.op.system.api.domain.sap.SapWorkCenter;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
@Mapper
@ -19,5 +22,15 @@ public interface SapBomMapper {
void insertBaseBomBatch(List<SapBom> sapBomList);
public int insertBasetBomComponent(SapBomComponent sapBomComponent);
//public int insertBasetBomComponent(SapBomComponent sapBomComponent);
public Date getMaxTime();
public List<String> getExsitCodes(@Param("list") List<String> codes);
int updateFactoryBatchs(@Param("list")List<SapWorkCenter> updates);
int addFactoryBatchs(@Param("list")List<SapWorkCenter> adds);
String getParentId(String factoryCode);
}

@ -1,6 +1,7 @@
package com.op.sap.service;
import com.op.common.core.domain.R;
import com.op.sap.domain.vo.SapItemQuery;
import com.op.system.api.domain.sap.SapBaseProduct;
import java.util.List;
@ -14,5 +15,5 @@ public interface SapItemSyncService {
*
* @return
*/
R itemSync(SapBaseProduct sapBaseProduct);
R itemSync(SapItemQuery sapItemQuery);
}

@ -2,8 +2,10 @@ package com.op.sap.service;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapRFW;
import com.op.system.api.domain.sap.SapShopOrderQuery;
import com.op.system.api.model.SapProOrder;
import java.util.List;
@ -18,7 +20,7 @@ public interface SapOrderService {
* @param sapProOrder
* @return
*/
R<List<SapProOrder>> shopOrderSync(SapProOrder sapProOrder);
R<List<SapProOrder>> shopOrderSync(SapShopOrderQuery sapProOrder);
/**
*

@ -1,14 +1,22 @@
package com.op.sap.service;
import com.op.common.core.domain.R;
import com.op.sap.domain.vo.SapSupplierQuery;
import com.op.sap.domain.vo.SapWorkCenterQuery;
import com.op.system.api.domain.sap.SapCustom;
import com.op.system.api.domain.sap.SapSupplier;
import com.op.system.api.domain.sap.SapWorkCenter;
import java.util.Date;
import java.util.List;
public interface SapWorkCenterService {
R sapWorkCenterSync();
R sapWorkCenterSync(SapWorkCenterQuery sapWorkCenterQuery);
R sapSupplierSync(SapSupplier sapSupplier);
R sapSupplierSync(SapSupplierQuery sapSupplierQuery);
R sapCustomSync(SapCustom sapCustom);
void syncWorkCenter(List<SapWorkCenter> dtos);
}

@ -31,7 +31,7 @@ import java.util.stream.Collectors;
@Service
public class SapBomServiceImpl implements SapBomService {
private static final String END_DATE="99991231";
@Autowired
private SapBomMapper sapBomMapper;
@ -63,49 +63,65 @@ public class SapBomServiceImpl implements SapBomService {
S_ANDAT
S_AEDAT
*/
if (!StringUtils.isNull(sapBomQuery.getWerks())){
JCoTable S_WERKS = func.getTableParameterList().getTable("S_WERKS");
S_WERKS.appendRow();
S_WERKS.setValue(Constants.SIGN, "I");
S_WERKS.setValue(Constants.OPTION, "EQ");
S_WERKS.setValue(Constants.LOW, sapBomQuery.getWerks());
}
if (!StringUtils.isNull(sapBomQuery.getMatnr())){
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow();
S_MATNR.setValue(Constants.SIGN, "I");
S_MATNR.setValue(Constants.OPTION, "EQ");
S_MATNR.setValue(Constants.LOW, sapBomQuery.getMatnr());
}
if (!StringUtils.isNull(sapBomQuery.getMatnr())){
JCoTable S_MATKL = func.getTableParameterList().getTable("S_MATKL");
S_MATKL.appendRow();
S_MATKL.setValue(Constants.SIGN, "I");
S_MATKL.setValue(Constants.OPTION, "EQ");
S_MATKL.setValue(Constants.LOW, sapBomQuery.getMatkl());
}
if (!StringUtils.isNull(sapBomQuery.getMatnr())){
JCoTable S_VERID = func.getTableParameterList().getTable("S_VERID");
S_VERID.appendRow();
S_VERID.setValue(Constants.SIGN, "I");
S_VERID.setValue(Constants.OPTION, "EQ");
S_VERID.setValue(Constants.LOW, sapBomQuery.getVerid());
}
if (!StringUtils.isNull(sapBomQuery.getMatnr())){
JCoTable S_STLNR = func.getTableParameterList().getTable("S_STLNR");
S_STLNR.appendRow();
S_STLNR.setValue(Constants.SIGN, "I");
S_STLNR.setValue(Constants.OPTION, "EQ");
S_STLNR.setValue(Constants.LOW, sapBomQuery.getStlnr());
}
if (!StringUtils.isNull(sapBomQuery.getMatnr())){
JCoTable S_ANDAT = func.getTableParameterList().getTable("S_ANDAT");
S_ANDAT.appendRow();
S_ANDAT.setValue(Constants.SIGN, "I");
S_ANDAT.setValue(Constants.OPTION, "EQ");
S_ANDAT.setValue(Constants.OPTION, "BT");
S_ANDAT.setValue(Constants.LOW, sapBomQuery.getAndat());
S_ANDAT.setValue("HIGH", END_DATE);
}
if (!StringUtils.isNull(sapBomQuery.getMatnr())){
JCoTable S_AEDAT = func.getTableParameterList().getTable("S_AEDAT");
S_AEDAT.appendRow();
S_AEDAT.setValue(Constants.SIGN, "I");
S_AEDAT.setValue(Constants.OPTION, "EQ");
S_AEDAT.setValue(Constants.OPTION, "BT");
S_AEDAT.setValue(Constants.LOW, sapBomQuery.getAedat());
S_AEDAT.setValue("HIGH", END_DATE);
}
// 获取调用 RFC 函数对象
func.execute(dest);

@ -8,6 +8,7 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.bean.BeanValidators;
import com.op.common.security.utils.SecurityUtils;
import com.op.sap.domain.vo.SapItemQuery;
import com.op.sap.mapper.SapBaseProductMapper;
import com.op.sap.service.SapItemSyncService;
import com.op.sap.util.SAPConnUtils;
@ -28,6 +29,8 @@ import java.util.Map;
@Service
public class SapItemSyncImpl implements SapItemSyncService {
private static final String END_DATE="99991231";
@Autowired
private SapBaseProductMapper sapBaseProductMapper;
@ -39,7 +42,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
private static final Logger log = LoggerFactory.getLogger(SapItemSyncImpl.class);
@Override
public R itemSync(SapBaseProduct sapBaseProduct) {
public R itemSync(SapItemQuery sapItemQuery) {
try {
// 获取调用 RFC 函数对象
//获取连接
@ -54,39 +57,47 @@ public class SapItemSyncImpl implements SapItemSyncService {
S_MATKL
S_ERSDA
S_LAEDA */
if (!StringUtils.isNull(sapBaseProduct.getProductCode())){
JCoTable jCoTables = func.getTableParameterList().getTable("S_MATNR");
System.out.println(jCoTables);
jCoTables.appendRow();
jCoTables.setValue(Constants.SIGN, "I");
jCoTables.setValue(Constants.OPTION, "EQ");
jCoTables.setValue(Constants.LOW, sapBaseProduct.getProductCode());
}
if (!StringUtils.isNull(sapBaseProduct.getProductGroup())){
JCoTable jCoTables = func.getTableParameterList().getTable("S_MATKL");
System.out.println(jCoTables);
jCoTables.appendRow();
jCoTables.setValue(Constants.SIGN, "I");
jCoTables.setValue(Constants.OPTION, "EQ");
jCoTables.setValue(Constants.LOW, sapBaseProduct.getProductGroup());
}
if (!StringUtils.isNull(sapBaseProduct.getCreateTime())){
JCoTable jCoTables = func.getTableParameterList().getTable("S_ERSDA");
System.out.println(jCoTables);
jCoTables.appendRow();
jCoTables.setValue(Constants.SIGN, "I");
jCoTables.setValue(Constants.OPTION, "EQ");
jCoTables.setValue(Constants.LOW, DateUtils.parseDateToStr("yyyyMMdd", sapBaseProduct.getCreateTime()));
}
if (!StringUtils.isNull(sapBaseProduct.getUpdateTime())){
JCoTable jCoTables = func.getTableParameterList().getTable("S_LAEDA");
System.out.println(jCoTables);
jCoTables.appendRow();
jCoTables.setValue(Constants.SIGN, "I");
jCoTables.setValue(Constants.OPTION, "EQ");
jCoTables.setValue(Constants.LOW, DateUtils.parseDateToStr("yyyyMMdd", sapBaseProduct.getUpdateTime()));
if (!StringUtils.isNull(sapItemQuery.getMatnr())){
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow();
S_MATNR.setValue(Constants.SIGN, "I");
S_MATNR.setValue(Constants.OPTION, "EQ");
S_MATNR.setValue(Constants.LOW, sapItemQuery.getMatnr());
}
if (!StringUtils.isNull(sapItemQuery.getMatkl())){
JCoTable S_MATKL = func.getTableParameterList().getTable("S_MATKL");
S_MATKL.appendRow();
S_MATKL.setValue(Constants.SIGN, "I");
S_MATKL.setValue(Constants.OPTION, "EQ");
S_MATKL.setValue(Constants.LOW, sapItemQuery.getMatkl());
}
if (!StringUtils.isNull(sapItemQuery.getErsda())){
JCoTable S_ERSDA = func.getTableParameterList().getTable("S_ERSDA");
S_ERSDA.appendRow();
S_ERSDA.setValue(Constants.SIGN, "I");
S_ERSDA.setValue(Constants.OPTION, "BT");
S_ERSDA.setValue(Constants.LOW, sapItemQuery.getErsda());
S_ERSDA.setValue("HIGH", END_DATE);
}
if (!StringUtils.isNull(sapItemQuery.getLaeda())){
JCoTable S_LAEDA = func.getTableParameterList().getTable("S_LAEDA");
S_LAEDA.appendRow();
S_LAEDA.setValue(Constants.SIGN, "I");
S_LAEDA.setValue(Constants.OPTION, "BT");
S_LAEDA.setValue(Constants.LOW, sapItemQuery.getLaeda());
S_LAEDA.setValue("HIGH", END_DATE);
}
// 获取调用 RFC 函数对象
func.execute(dest);
// 获取 内表 - ZMES_PRO

@ -4,13 +4,13 @@ import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.sap.service.SapOrderService;
import com.op.sap.util.SAPConnUtils;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapRFW;
import com.op.system.api.domain.sap.SapShopOrderQuery;
import com.op.system.api.model.SapProOrder;
import com.sap.conn.jco.*;
@ -26,7 +26,7 @@ public class SapOrderServiceImpl implements SapOrderService {
private static final String END_DATE="99991231";
@Override
public R<List<SapProOrder>> shopOrderSync(SapProOrder sapProOrder) {
public R<List<SapProOrder>> shopOrderSync(SapShopOrderQuery sapShopOrderQuery) {
try {
// 获取调用 RFC 函数对象
@ -37,13 +37,36 @@ public class SapOrderServiceImpl implements SapOrderService {
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
// 配置传入参数
JCoTable jCoTable = func.getTableParameterList().getTable("S_ERDAT");
jCoTable.appendRow();
jCoTable.setValue("SIGN", "I");
jCoTable.setValue("OPTION", "BT");
jCoTable.setValue("LOW", DateUtils.parseDateToStr("yyyyMMdd", sapProOrder.getCreateTime()));
jCoTable.setValue("HIGH", END_DATE);
// S_AUFNR订单号 S_MATNR物料号 S_ERDAT(创建日期) 例如20230923
if (!StringUtils.isNull(sapShopOrderQuery.getAufnr())){
JCoTable S_AUFNR = func.getTableParameterList().getTable("S_AUFNR");
S_AUFNR.appendRow();
S_AUFNR.setValue("SIGN", "I");
S_AUFNR.setValue("OPTION", "EQ");
S_AUFNR.setValue("LOW", sapShopOrderQuery.getAufnr());
}
if (!StringUtils.isNull(sapShopOrderQuery.getMatnr())){
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow();
S_MATNR.setValue("SIGN", "I");
S_MATNR.setValue("OPTION", "EQ");
S_MATNR.setValue("LOW",sapShopOrderQuery.getMatnr());
}
if (!StringUtils.isNull(sapShopOrderQuery.getErdat())){
JCoTable S_ERDAT = func.getTableParameterList().getTable("S_ERDAT");
S_ERDAT.appendRow();
S_ERDAT.setValue("SIGN", "I");
S_ERDAT.setValue("OPTION", "BT");
S_ERDAT.setValue("LOW", sapShopOrderQuery.getErdat());
S_ERDAT.setValue("HIGH", END_DATE);
}
func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO

@ -30,6 +30,7 @@ import java.util.stream.Collectors;
@Service
public class SapRouterServiceImpl implements SapRouterService {
private static final String END_DATE="99991231";
@Autowired
private SapProProcessMapper sapProProcessMapper;
@Autowired
@ -69,35 +70,48 @@ public class SapRouterServiceImpl implements SapRouterService {
S_AEDAT
*/
if (!StringUtils.isNull(sapRouterQuery.getMatnr())){
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow();
S_MATNR.setValue("SIGN", "I");
S_MATNR.setValue("OPTION", "EQ");
S_MATNR.setValue("LOW", sapRouterQuery.getMatnr());
}
if (!StringUtils.isNull(sapRouterQuery.getMatnr())){
JCoTable S_WERKS = func.getTableParameterList().getTable("S_WERKS");
S_WERKS.appendRow();
S_WERKS.setValue("SIGN", "I");
S_WERKS.setValue("OPTION", "EQ");
S_WERKS.setValue("LOW", sapRouterQuery.getWerks());
}
if (!StringUtils.isNull(sapRouterQuery.getMatnr())){
JCoTable S_ARBPL = func.getTableParameterList().getTable("S_ARBPL");
S_ARBPL.appendRow();
S_ARBPL.setValue("SIGN", "I");
S_ARBPL.setValue("OPTION", "EQ");
S_ARBPL.setValue("LOW", sapRouterQuery.getArbpl());
}
if (!StringUtils.isNull(sapRouterQuery.getMatnr())){
JCoTable S_ANDAT = func.getTableParameterList().getTable("S_ANDAT");
S_ANDAT.appendRow();
S_ANDAT.setValue("SIGN", "I");
S_ANDAT.setValue("OPTION", "EQ");
S_ANDAT.setValue("OPTION", "BT");
S_ANDAT.setValue("LOW", sapRouterQuery.getAndat());
S_ANDAT.setValue("HIGH", END_DATE);
}
if (!StringUtils.isNull(sapRouterQuery.getMatnr())){
JCoTable S_AEDAT = func.getTableParameterList().getTable("S_AEDAT");
S_AEDAT.appendRow();
S_AEDAT.setValue("SIGN", "I");
S_AEDAT.setValue("OPTION", "EQ");
S_AEDAT.setValue("OPTION", "BT");
S_AEDAT.setValue("LOW", sapRouterQuery.getAedat());
S_AEDAT.setValue("HIGH", END_DATE);
}
func.execute(dest);//执行调用函数
@ -107,7 +121,6 @@ public class SapRouterServiceImpl implements SapRouterService {
System.out.println("###" + metaData.toString());
List<SapProRoute> sapProRouteList=new ArrayList<>();
DynamicDataSourceContextHolder.push("ds_1000");
for (int i = 0; i <maraTable.getNumRows(); i++) {
SapProProcess sapProProcess=new SapProProcess();
maraTable.setRow(i);
@ -251,6 +264,7 @@ public class SapRouterServiceImpl implements SapRouterService {
successNum++;
}
}
else{
//验证是否存在工序
sapProProcess.setProcessName(LTXA1);

@ -3,22 +3,33 @@ 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.StringUtils;
import com.op.sap.domain.vo.SapSupplierQuery;
import com.op.sap.domain.vo.SapWorkCenterQuery;
import com.op.sap.mapper.SapBomMapper;
import com.op.sap.service.SapWorkCenterService;
import com.op.sap.util.SAPConnUtils;
import com.op.system.api.domain.sap.SapCustom;
import com.op.system.api.domain.sap.SapSupplier;
import com.op.system.api.domain.sap.SapWorkCenter;
import com.sap.conn.jco.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class SapWorkCenterServiceImpl implements SapWorkCenterService {
private static final String END_DATE="99991231";
@Autowired
private SapBomMapper sapBomMapper;
@Override
public R sapWorkCenterSync() {
public R sapWorkCenterSync(SapWorkCenterQuery sapWorkCenterQuery) {
try {
// 获取调用 RFC 函数对象
//获取连接
@ -28,12 +39,38 @@ public class SapWorkCenterServiceImpl implements SapWorkCenterService {
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
// 配置传入参数
JCoTable jCoTable = func.getTableParameterList().getTable("S_WERKS");
// jCoTable.appendRow();
// jCoTable.setValue("SIGN", "I");
// jCoTable.setValue("OPTION", "EQ");
// jCoTable.setValue("LOW", "1000");
/*
S_WERKS
S_ARBPL
S_AEDAT 20230923
*/
if (!StringUtils.isNull(sapWorkCenterQuery.getWerks())){
JCoTable S_WERKS = func.getTableParameterList().getTable("S_WERKS");
S_WERKS.appendRow();
S_WERKS.setValue("SIGN", "I");
S_WERKS.setValue("OPTION", "EQ");
S_WERKS.setValue("LOW", sapWorkCenterQuery.getWerks());
}
if (!StringUtils.isNull(sapWorkCenterQuery.getArbpl())){
JCoTable S_ARBPL = func.getTableParameterList().getTable("S_ARBPL");
S_ARBPL.appendRow();
S_ARBPL.setValue("SIGN", "I");
S_ARBPL.setValue("OPTION", "EQ");
S_ARBPL.setValue("LOW", sapWorkCenterQuery.getArbpl());
}
if (!StringUtils.isNull(sapWorkCenterQuery.getAedat())){
JCoTable S_AEDAT = func.getTableParameterList().getTable("S_AEDAT");
S_AEDAT.appendRow();
S_AEDAT.setValue("SIGN", "I");
S_AEDAT.setValue("OPTION", "BT");
S_AEDAT.setValue("LOW", sapWorkCenterQuery.getAedat());
S_AEDAT.setValue("HIGH", END_DATE);
}
func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_ARBPL");
@ -69,7 +106,7 @@ public class SapWorkCenterServiceImpl implements SapWorkCenterService {
}
@Override
public R sapSupplierSync(SapSupplier sapSupplier) {
public R sapSupplierSync(SapSupplierQuery sapSupplierQuery) {
try {
// 获取调用 RFC 函数对象
//获取连接
@ -83,35 +120,32 @@ public class SapWorkCenterServiceImpl implements SapWorkCenterService {
/*
S_BUKRS 1000/1001/1002
S_LIFNR
S_ERDAT
S_ERDAT 20230807
*/
if (!StringUtils.isNull(sapSupplier.getBukrs())){
if (!StringUtils.isNull(sapSupplierQuery.getBukrs())){
JCoTable S_BUKRS = func.getTableParameterList().getTable("S_BUKRS");
S_BUKRS.appendRow();
S_BUKRS.setValue("SIGN", "I");
S_BUKRS.setValue("OPTION", "EQ");
S_BUKRS.setValue("LOW", sapSupplier.getBukrs());
S_BUKRS.setValue("LOW", sapSupplierQuery.getBukrs());
}
if (!StringUtils.isNull(sapSupplier.getLifnr())){
if (!StringUtils.isNull(sapSupplierQuery.getLifnr())){
JCoTable S_LIFNR = func.getTableParameterList().getTable("S_LIFNR");
S_LIFNR.appendRow();
S_LIFNR.setValue("SIGN", "I");
S_LIFNR.setValue("OPTION", "EQ");
S_LIFNR.setValue("LOW", sapSupplier.getLifnr());
S_LIFNR.setValue("LOW", sapSupplierQuery.getLifnr());
}
///日期参数示例
if (!StringUtils.isNull(sapSupplier.getErdat())){
if (!StringUtils.isNull(sapSupplierQuery.getErdat())){
JCoTable S_ERDAT = func.getTableParameterList().getTable("S_ERDAT");
S_ERDAT.appendRow();
S_ERDAT.setValue("SIGN", "I");
S_ERDAT.setValue("OPTION", "EQ");
S_ERDAT.setValue("LOW", sapSupplier.getErdat() );
S_ERDAT.setValue("OPTION", "BT");
S_ERDAT.setValue("LOW", sapSupplierQuery.getErdat());
S_ERDAT.setValue("HIGH", END_DATE);
}
func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_LIFNR");
@ -164,7 +198,6 @@ public class SapWorkCenterServiceImpl implements SapWorkCenterService {
S_KUNNR
S_ERDAT
*/
if (!StringUtils.isNull(sapCustom.getBukrs())){
JCoTable S_BUKRS = func.getTableParameterList().getTable("S_BUKRS");
S_BUKRS.appendRow();
@ -173,19 +206,21 @@ public class SapWorkCenterServiceImpl implements SapWorkCenterService {
S_BUKRS.setValue("LOW", sapCustom.getBukrs());
}
if (!StringUtils.isNull(sapCustom.getKunnr())){
JCoTable S_KUNNR = func.getTableParameterList().getTable("S_KUNNR");
S_KUNNR.appendRow();
S_KUNNR.setValue("SIGN", "I");
S_KUNNR.setValue("OPTION", "EQ");
S_KUNNR.setValue("LOW", sapCustom.getKunnr());
}
///日期参数示例 20230921
if (!StringUtils.isNull(sapCustom.getErdat())){
///日期参数示例 20230921
JCoTable S_ERDAT = func.getTableParameterList().getTable("S_ERDAT");
S_ERDAT.appendRow();
S_ERDAT.setValue("SIGN", "I");
S_ERDAT.setValue("OPTION", "EQ");
S_ERDAT.setValue("OPTION", "BT");
S_ERDAT.setValue("LOW", sapCustom.getErdat() );
S_ERDAT.setValue("HIGH", END_DATE);
}
func.execute(dest);//执行调用函数
@ -222,4 +257,37 @@ public class SapWorkCenterServiceImpl implements SapWorkCenterService {
return R.fail(e.getMessage());
}
}
/**sys_factory**/
@Override
public void syncWorkCenter(List<SapWorkCenter> dtos) {
//sap返回的工作中心编码
List<String> codes = dtos.stream().map(SapWorkCenter::getArbpl).collect(Collectors.toList());
//sap返回的工作中心编码-本地已存在
List<String> exsitCodes = sapBomMapper.getExsitCodes(codes);
//sap返回的工作中心编码-本地不存在// 差集 (list2 - list1)
List<String> noExsitCodes = codes.stream().filter(item -> !exsitCodes.contains(item)).collect(Collectors.toList());
List<SapWorkCenter> updates = new ArrayList<>();
for(String exsitCode:exsitCodes){
updates = dtos.stream().filter(dto -> dto.getArbpl().equals(exsitCode)).collect(Collectors.toList());
}
if(CollectionUtils.isEmpty(updates)){
int m = sapBomMapper.updateFactoryBatchs(updates);
System.out.println("工作中心更新成功条数:"+m);
}
List<SapWorkCenter> adds = new ArrayList<>();
for(String noExsitCode:noExsitCodes){
adds = dtos.stream().filter(dto -> dto.getArbpl().equals(noExsitCode)).collect(Collectors.toList());
}
if(CollectionUtils.isEmpty(adds)){
//工厂parentId
String parentId = sapBomMapper.getParentId(adds.get(0).getWeeks());
adds.stream().forEach(e->{
e.setParentId(parentId);
});
int n = sapBomMapper.addFactoryBatchs(adds);
System.out.println("工作中心新增成功条数:"+ n);
}
}
}

@ -65,6 +65,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where bom_code = #{bomCode}
order by production_version desc
</select>
<select id="getMaxTime" resultType="java.util.Date">
select max(create_time) from sys_factory
</select>
<select id="getExsitCodes" resultType="java.lang.String">
select factory_code from sys_factory where factory_code in
<foreach collection="code" item="list" open="(" separator="," close=")">
#{code}
</foreach>
</select>
<select id="getParentId" resultType="java.lang.String">
select factory_id from sys_factory where factory_code = #{factoryCode}
</select>
<insert id="insertBaseBom" parameterType="com.op.system.api.domain.sap.SapBom">
insert into base_bom
@ -211,7 +223,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where factory_code = #{factoryCode}
</update>
<!--批量更新工厂建模表-->
<update id="updateFactoryBatchs">
<foreach collection="list" item="item" separator=";">
update sys_factory
set factory_name = #{item.factoryName}
where
factoryCode = #{item.factoryCode}
</foreach>
</update>
<!--批量添加工厂建模表-->
<insert id="addFactoryBatchs">
insert into sys_factory
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="item.parentId != null">parent_id,</if>
<if test="item.factoryName != null">factory_name,</if>
<if test="item.factoryCode != null">factory_code,</if>
create_by,
<if test="item.createTime != null">create_time,</if>
<if test="item.updateTime != null">update_time,</if>
</trim>
VALUES
<foreach collection="list" index="index" item="item" separator=",">
<if test="item.parentId != null">#{item.parentId},</if>
<if test="item.factoryName != null">#{item.factoryName},</if>
<if test="item.factoryCode != null">#{item.factoryCode},</if>
'job',
<if test="item.createTime != null">#{item.aedat_grnd},</if>
<if test="item.updateTime != null">#{item.aedat_grnd},</if>
</foreach>
</insert>
<delete id="deleteBaseBomByFactoryCode" parameterType="String">
delete from base_bom where factory_code = #{factoryCode}
</delete>

Loading…
Cancel
Save