物料主数据同步接口更改,计件薪酬基础信息修改,SAP报工接口增加备注

master
Yangwl 10 months ago
parent e156d92645
commit af833e891a

@ -9,9 +9,18 @@ public class SapRFW {
private String aufnr; private String aufnr;
private String gamng; private String gamng;
private String anzma; private String anzma;
private String remark;
private lt_gs lt_gs; private lt_gs lt_gs;
private List<lt_hw> lt_hwList; private List<lt_hw> lt_hwList;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getAnzma() { public String getAnzma() {
return anzma; return anzma;
} }

@ -40,7 +40,7 @@ public class MesUnitPrice extends BaseEntity {
/** /**
* 线 * 线
*/ */
@Excel(name = "产线编码") @Excel(name = "SAP产线编码")
private String lineCode; private String lineCode;
/** /**
@ -76,7 +76,7 @@ public class MesUnitPrice extends BaseEntity {
/** /**
* 2 * 2
*/ */
// @Excel(name = "预留字段2") @Excel(name = "标准用人")
private String attr2; private String attr2;
/** /**

@ -47,6 +47,8 @@ public class MesUnitpriceReport extends BaseEntity {
@Excel(name = "产线编码") @Excel(name = "产线编码")
private String lineCode; private String lineCode;
@Excel(name = "SAP产线编码")
private String sapCode;
@Excel(name = "产线名称") @Excel(name = "产线名称")
private String equipmentName; private String equipmentName;
/** /**
@ -100,6 +102,14 @@ public class MesUnitpriceReport extends BaseEntity {
// @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") // @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String attr2; private String attr2;
public String getSapCode() {
return sapCode;
}
public void setSapCode(String sapCode) {
this.sapCode = sapCode;
}
public String getRealWages() { public String getRealWages() {
return realWages; return realWages;
} }

@ -11,6 +11,7 @@
<result property="productName" column="product_name"/> <result property="productName" column="product_name"/>
<result property="productCode" column="product_code"/> <result property="productCode" column="product_code"/>
<result property="lineCode" column="line_code"/> <result property="lineCode" column="line_code"/>
<result property="sapCode" column="sap_code,"/>
<result property="equipmentName" column="equipment_name"/> <result property="equipmentName" column="equipment_name"/>
<result property="userName" column="user_name"/> <result property="userName" column="user_name"/>
<result property="nickName" column="nick_name"/> <result property="nickName" column="nick_name"/>
@ -45,7 +46,7 @@
mur.line_code, mur.line_code,
mur.attr1 AS real_wages, mur.attr1 AS real_wages,
mur.remark, mur.remark,
be.equipment_name, be.sap_name as equipment_name,
mur.nick_name, mur.nick_name,
mur.childprocess_code, mur.childprocess_code,
mup.childprocess_name, mup.childprocess_name,
@ -63,7 +64,7 @@
mes_unitprice_report mur mes_unitprice_report mur
LEFT JOIN LEFT JOIN
mes_unit_price mup ON RIGHT(mur.product_code, 11) = mup.product_code AND mur.childprocess_code = mup.childprocess_code mes_unit_price mup ON RIGHT(mur.product_code, 11) = mup.product_code AND mur.childprocess_code = mup.childprocess_code
LEFT JOIN base_equipment be ON be.equipment_code=mur.line_code LEFT JOIN base_equipment be ON be.sap_code=mur.line_code
LEFT JOIN ( SELECT parent_order, SUM ( quantity ) AS total_quantity FROM mes_report_work GROUP BY parent_order ) mrw ON mur.workorder_code = mrw.parent_order LEFT JOIN ( SELECT parent_order, SUM ( quantity ) AS total_quantity FROM mes_report_work GROUP BY parent_order ) mrw ON mur.workorder_code = mrw.parent_order
<where> <where>
<if test="workorderCode != null and workorderCode != ''">and workorder_code = #{workorderCode}</if> <if test="workorderCode != null and workorderCode != ''">and workorder_code = #{workorderCode}</if>
@ -103,7 +104,7 @@
mur.attr1, mur.attr1,
mur.line_code, mur.line_code,
mur.remark, mur.remark,
be.equipment_name, be.sap_name,
mur.nick_name, mur.nick_name,
mur.childprocess_code, mur.childprocess_code,
mup.childprocess_name, mup.childprocess_name,

@ -65,36 +65,9 @@ public class SapController extends BaseController {
*/ */
@PostMapping("/itemSync") @PostMapping("/itemSync")
@Log(title = "同步SAP物料清单", businessType = BusinessType.SAP) @Log(title = "同步SAP物料清单", businessType = BusinessType.SAP)
public R itemSync() { public R itemSync(@RequestBody SapItemQuery qo) {
SapItemQuery qo = new SapItemQuery();
// 加载sf-cloud库的sys_datasource // 加载sf-cloud库的sys_datasource
SysUser sysUser = new SysUser(); return sapItemSyncService.itemSync(qo);
sysUser.setUserId(1L);
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
List<Map<String, String>> dateSources = dateSources0.getData();
dateSources.forEach(dateSource -> {
if (!"ds_999".equals(dateSource.get("poolName"))) {
logger.info("++++++++++++" + dateSource.get("poolName") + "++++product同步开始++++++++++");
DynamicDataSourceContextHolder.push(dateSource.get("poolName"));// 这是数据源的key
/**base_product**/
Date maxTime0 = sapBomMapper.getProductMaxTime();
if (maxTime0 != null) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(maxTime0);
calendar.add(Calendar.DAY_OF_YEAR, 1);
Date maxTime = calendar.getTime();
qo.setLaeda(DateFormatUtils.format(maxTime, "yyyyMMdd"));//修改日期20230923
}
R r = sapItemSyncService.itemSync(qo);
if (r.getCode() != 200) {
logger.error("++++++++++++" + dateSource.get("poolName") + "同步product失败错误信息" + r.getMsg());
}
logger.error("++++++++++++" + dateSource.get("poolName") + "++++product同步结束++++++++++");
}
});
return R.ok();
} }
/** /**
@ -106,7 +79,6 @@ public class SapController extends BaseController {
@Log(title = "同步SAP物料组件清单", businessType = BusinessType.SAP) @Log(title = "同步SAP物料组件清单", businessType = BusinessType.SAP)
public R bomSync() { public R bomSync() {
SapBomQuery qo = new SapBomQuery(); SapBomQuery qo = new SapBomQuery();
// 加载sf-cloud库的sys_datasource // 加载sf-cloud库的sys_datasource
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
sysUser.setUserId(1L); sysUser.setUserId(1L);

@ -8,12 +8,21 @@ public class SapItemQuery {
S_ERSDA S_ERSDA
S_LAEDA S_LAEDA
*/ */
private String werks;
private String matnr; private String matnr;
private String mtart; private String mtart;
private String matkl; private String matkl;
private String ersda; private String ersda;
private String laeda; private String laeda;
public String getWerks() {
return werks;
}
public void setWerks(String werks) {
this.werks = werks;
}
public String getMatnr() { public String getMatnr() {
return matnr; return matnr;
} }

@ -55,20 +55,30 @@ public class SapItemSyncImpl implements SapItemSyncService {
try { try {
// 获取调用 RFC 函数对象 // 获取调用 RFC 函数对象
//获取连接 //获取连接
// JCoDestination dest = SAPConnUtils.connect();
log.info("物料基础数据同步输入参数---------" + JSONObject.toJSONString(sapItemQuery)); log.info("物料基础数据同步输入参数---------" + JSONObject.toJSONString(sapItemQuery));
JCoRepository repository = dest.getRepository(); JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMMR_MES_MAT_GET"); JCoFunction func = repository.getFunction("ZMMR_MES_MAT_GET");
if (func == null) { if (func == null) {
throw new RuntimeException("Function does not exist in SAP"); throw new RuntimeException("Function does not exist in SAP");
} }
/* /*
P_WERKS
S_MATNR S_MATNR
S_MATKL S_MATKL
S_ERSDA S_ERSDA
S_LAEDA */ S_LAEDA */
sapItemQuery.setMatnr("000000040000005209"); if (!StringUtils.isNull(sapItemQuery.getWerks())){
JCoParameterList jCoParameterList = func.getImportParameterList();
jCoParameterList.setValue("P_WERKS", sapItemQuery.getWerks());
}
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.getMatnr())) { if (!StringUtils.isNull(sapItemQuery.getMatnr())) {
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR"); JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow(); S_MATNR.appendRow();
@ -93,27 +103,24 @@ public class SapItemSyncImpl implements SapItemSyncService {
S_ERSDA.setValue(Constants.LOW, sapItemQuery.getErsda()); S_ERSDA.setValue(Constants.LOW, sapItemQuery.getErsda());
S_ERSDA.setValue("HIGH", END_DATE); S_ERSDA.setValue("HIGH", END_DATE);
} }
// if (!StringUtils.isNull(sapItemQuery.getLaeda())) { if (!StringUtils.isNull(sapItemQuery.getLaeda())) {
// JCoTable S_LAEDA = func.getTableParameterList().getTable("S_LAEDA"); JCoTable S_LAEDA = func.getTableParameterList().getTable("S_LAEDA");
// S_LAEDA.appendRow(); S_LAEDA.appendRow();
// S_LAEDA.setValue(Constants.SIGN, "I"); S_LAEDA.setValue(Constants.SIGN, "I");
// S_LAEDA.setValue(Constants.OPTION, "BT"); S_LAEDA.setValue(Constants.OPTION, "BT");
// S_LAEDA.setValue(Constants.LOW, sapItemQuery.getLaeda()); S_LAEDA.setValue(Constants.LOW, sapItemQuery.getLaeda());
// S_LAEDA.setValue("HIGH", END_DATE); S_LAEDA.setValue("HIGH", END_DATE);
// } }
// 获取调用 RFC 函数对象 // 获取调用 RFC 函数对象
func.execute(dest); func.execute(dest);
// 获取 内表 - ZMES_PRO // 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_MARA"); JCoTable maraTable = func.getTableParameterList().getTable("LT_MARA");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
// System.out.println("###" + metaData.toString());
// 加载数据源 // 加载数据源
DynamicDataSourceContextHolder.push("ds_1000");
List<SapBaseProduct> sapBaseProductList = new ArrayList<>(); List<SapBaseProduct> sapBaseProductList = new ArrayList<>();
for (int i = 0; i < maraTable.getNumRows(); i++) { for (int i = 0; i < maraTable.getNumRows(); i++) {
SapBaseProduct baseProduct = new SapBaseProduct(); SapBaseProduct baseProduct = new SapBaseProduct();
maraTable.setRow(i); maraTable.setRow(i);
String WERKS = maraTable.getString("WERKS");
String MATNR = maraTable.getString("MATNR"); String MATNR = maraTable.getString("MATNR");
String MAKTX = maraTable.getString("MAKTX"); String MAKTX = maraTable.getString("MAKTX");
String EAN11 = maraTable.getString("EAN11"); String EAN11 = maraTable.getString("EAN11");
@ -146,7 +153,8 @@ public class SapItemSyncImpl implements SapItemSyncService {
String MVGR5_NM = maraTable.getString("MVGR5_NM"); String MVGR5_NM = maraTable.getString("MVGR5_NM");
String LAEDA = maraTable.getString("LAEDA"); String LAEDA = maraTable.getString("LAEDA");
String ERSDA = maraTable.getString("LAEDA"); String ERSDA = maraTable.getString("LAEDA");
log.info("物料基础数据同步数据输出----" + log.info(i+"物料基础数据同步数据输出----" +
"工厂:" +WERKS+
"物料号:" + MATNR + "物料号:" + MATNR +
"物料描述(短文本):" + MAKTX + "物料描述(短文本):" + MAKTX +
"国际文件号(EAN/UPC)" + EAN11 + "国际文件号(EAN/UPC)" + EAN11 +
@ -175,35 +183,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
" 物料组描述 " + MVGR3_NM + " 物料组描述 " + MVGR3_NM +
"创建日期:" + ERSDA + "创建日期:" + ERSDA +
"上次更改日期:" + LAEDA); "上次更改日期:" + LAEDA);
// System.out.println( baseProduct.setFactoryCode(WERKS);
// "物料号:" + MATNR+
// "物料描述(短文本):" + MAKTX+
// "国际文件号(EAN/UPC)" + EAN11+
// "物料类型:" + MTART+
// "物料类型描述:" + MTBEZ+
// "物料组:" + MATKL+
// "物料组描述:" + WGBEZ+
// "毛重:" + BRGEW+
// "净重:" + NTGEW+
// "体积:" + VOLUM+
// "体积单位:" + VOLEH+
// "基本计量单位:" + MEINS+
// "帐面库存单位的可选计量单位 " + MEINH+
// "基本计量单位转换分子:" + UMREZ+
// "转换为基本计量单位的分母:" + UMREN+
// "在客户级标记要删除的物料:" + LVORM+
// "数量:" + MENGE+
// "总货架寿命 " + MHDHB+
// "产品组:" + SPART+
// "产品组描述:" + SPART_NM+
// "物料组1" + MVGR1+
// "物料组1描述" + MVGR1_NM+
// "物料组2" + MVGR2+
// "物料组2描述" + MVGR2_NM+
// " 物料组3" + MVGR3+
// " 物料组描述 " + MVGR3_NM+
// "创建日期:"+ERSDA+
// "上次更改日期:"+LAEDA);
baseProduct.setProductCode(MATNR); baseProduct.setProductCode(MATNR);
baseProduct.setProductDescZh(MAKTX); baseProduct.setProductDescZh(MAKTX);
baseProduct.setProductGroup(MATKL); baseProduct.setProductGroup(MATKL);
@ -221,7 +201,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
sapBaseProductList.add(baseProduct); sapBaseProductList.add(baseProduct);
} }
//this.importProducts(sapBaseProductList) //this.importProducts(sapBaseProductList)
return R.ok(this.importProducts(sapBaseProductList)); return R.ok(this.importProducts(sapBaseProductList,sapItemQuery.getWerks()));
} catch (Exception e) { } catch (Exception e) {
return R.fail(e.getMessage()); return R.fail(e.getMessage());
} }
@ -355,7 +335,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
public String importProducts(List<SapBaseProduct> sapBaseProductList) { public String importProducts(List<SapBaseProduct> sapBaseProductList,String factoryCode) {
if (StringUtils.isNull(sapBaseProductList) || sapBaseProductList.size() == 0) { if (StringUtils.isNull(sapBaseProductList) || sapBaseProductList.size() == 0) {
throw new ServiceException("同步物料数据为空!"); throw new ServiceException("同步物料数据为空!");
} }
@ -363,7 +343,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
int failureNum = 0; int failureNum = 0;
StringBuilder successMsg = new StringBuilder(); StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder();
DynamicDataSourceContextHolder.push("ds_"+factoryCode);
for (SapBaseProduct sapBaseProduct : sapBaseProductList) { for (SapBaseProduct sapBaseProduct : sapBaseProductList) {
try { try {
// 验证是否存在这个物料 // 验证是否存在这个物料
@ -371,12 +351,14 @@ public class SapItemSyncImpl implements SapItemSyncService {
if (StringUtils.isNull(u)) { if (StringUtils.isNull(u)) {
BeanValidators.validateWithException(validator, sapBaseProduct); BeanValidators.validateWithException(validator, sapBaseProduct);
sapBaseProduct.setCreateBy("job"); sapBaseProduct.setCreateBy("job");
sapBaseProduct.setCreateTime(DateUtils.getNowDate());
sapBaseProductMapper.insertBaseProduct(sapBaseProduct); sapBaseProductMapper.insertBaseProduct(sapBaseProduct);
successNum++; successNum++;
successMsg.append("<br/>" + successNum + "、物料 " + sapBaseProduct.getProductCode() + " 同步成功"); successMsg.append("<br/>" + successNum + "、物料 " + sapBaseProduct.getProductCode() + " 同步成功");
} else if (!StringUtils.isNull(u)) { } else if (!StringUtils.isNull(u)) {
sapBaseProduct.setProductId(u.getProductId()); sapBaseProduct.setProductId(u.getProductId());
sapBaseProduct.setCreateBy("job"); sapBaseProduct.setUpdateBy("job");
sapBaseProduct.setUpdateTime(DateUtils.getNowDate());
sapBaseProductMapper.updateBaseProduct(sapBaseProduct); sapBaseProductMapper.updateBaseProduct(sapBaseProduct);
successNum++; successNum++;
successMsg.append("<br/>" + successNum + "、物料 " + sapBaseProduct.getProductCode() + " 更新成功"); successMsg.append("<br/>" + successNum + "、物料 " + sapBaseProduct.getProductCode() + " 更新成功");
@ -431,8 +413,8 @@ public class SapItemSyncImpl implements SapItemSyncService {
qcCheckTaskIncomeDTO.setMaterialName(maraTable.getString("MAKTX"));//物料描述 qcCheckTaskIncomeDTO.setMaterialName(maraTable.getString("MAKTX"));//物料描述
qcCheckTaskIncomeDTO.setQuality(new BigDecimal(maraTable.getString("MENGE")));//数量 qcCheckTaskIncomeDTO.setQuality(new BigDecimal(maraTable.getString("MENGE")));//数量
qcCheckTaskIncomeDTO.setUnit(maraTable.getString("MEINS"));//单位 qcCheckTaskIncomeDTO.setUnit(maraTable.getString("MEINS"));//单位
String inputDateTime = maraTable.getString("CPUDT")+maraTable.getString("CPUTM"); String inputDateTime = maraTable.getString("CPUDT")+" "+maraTable.getString("CPUTM");
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMddHHmmss"); SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 将原始日期时间字符串解析为Date对象 // 将原始日期时间字符串解析为Date对象
Date date = inputFormat.parse(inputDateTime); Date date = inputFormat.parse(inputDateTime);
qcCheckTaskIncomeDTO.setIncomeTime(date); qcCheckTaskIncomeDTO.setIncomeTime(date);

@ -284,6 +284,8 @@ public class SapOrderServiceImpl implements SapOrderService {
jCoParameterList.setValue("P_GAMNG", sapRFW.getGamng()); jCoParameterList.setValue("P_GAMNG", sapRFW.getGamng());
//产线编号 //产线编号
jCoParameterList.setValue("P_ANZMA", sapRFW.getAnzma()); jCoParameterList.setValue("P_ANZMA", sapRFW.getAnzma());
//备注
jCoParameterList.setValue("P_TEXT", sapRFW.getRemark());
if (sapRFW.getLt_gs() == null) { if (sapRFW.getLt_gs() == null) {
return R.fail("生产订单报工工时为空"); return R.fail("生产订单报工工时为空");
} }
@ -624,7 +626,7 @@ public class SapOrderServiceImpl implements SapOrderService {
//获取结果 //获取结果
String L_MSG = func.getExportParameterList().getString("MSG"); String L_MSG = func.getExportParameterList().getString("MSG");
String RETCODE = func.getExportParameterList().getString("RETCODE"); String RETCODE = func.getExportParameterList().getString("RETCODE");
System.out.println(RETCODE+L_MSG);
if (Constants.SUCCESS.equals(Integer.parseInt(RETCODE))){ if (Constants.SUCCESS.equals(Integer.parseInt(RETCODE))){
successNum++; successNum++;
successMsg.append("<br/>" + successNum + "、物料:"+m.get("P_MATNR")+L_MSG); successMsg.append("<br/>" + successNum + "、物料:"+m.get("P_MATNR")+L_MSG);

@ -175,7 +175,7 @@
<if test="netWeight != null">#{netWeight},</if> <if test="netWeight != null">#{netWeight},</if>
<if test="tareWeight != null">#{tareWeight},</if> <if test="tareWeight != null">#{tareWeight},</if>
<if test="volume != null">#{volume},</if> <if test="volume != null">#{volume},</if>
<if test="meins != null">meins,</if> <if test="meins != null">#{meins},</if>
<if test="unitPrice != null">#{unitPrice},</if> <if test="unitPrice != null">#{unitPrice},</if>
<if test="productGroup != null">#{productGroup},</if> <if test="productGroup != null">#{productGroup},</if>
<if test="productGroupName != null">#{productGroupName},</if> <if test="productGroupName != null">#{productGroupName},</if>

Loading…
Cancel
Save