计件工资优化、能源模块增加数据源

master
Yangwl 8 months ago
parent 4b0ba99444
commit 45a5f33fe8

@ -0,0 +1,21 @@
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.DataSourcePropertyDTO;
import com.op.system.api.factory.RemoteEnergyFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/** auth YangWl
*
*/
@FeignClient(contextId = "remoteEnergyService", value = ServiceNameConstants.ENERGY_SERVICE, fallbackFactory = RemoteEnergyFallbackFactory.class)
public interface RemoteEnergyService {
@PostMapping("/energy/addDatasource")
public R addDatasource(@RequestBody DataSourcePropertyDTO dataSourceProperty);
@PostMapping("/energy/removeDatasource")
public R removeDatasource(@RequestBody DataSourcePropertyDTO dataSourceProperty);
}

@ -170,6 +170,28 @@ public class SapBaseProduct extends BaseEntity {
@Excel(name = "基本计量单位")
private String meins;
@Excel(name = "基本计量单位转换分子")
private BigDecimal umrez;
@Excel(name = "基本计量单位转换分母")
private BigDecimal umren;
public BigDecimal getUmrez() {
return umrez;
}
public void setUmrez(BigDecimal umrez) {
this.umrez = umrez;
}
public BigDecimal getUmren() {
return umren;
}
public void setUmren(BigDecimal umren) {
this.umren = umren;
}
public String getMeins() {
return meins;

@ -159,4 +159,25 @@ public class SapPurchaseOrderQuery {
public void setPwerk(String pwerk) {
this.pwerk = pwerk;
}
@Override
public String toString() {
return "SapPurchaseOrderQuery{" +
"ebeln='" + ebeln + '\'' +
", ebelp='" + ebelp + '\'' +
", matnr='" + matnr + '\'' +
", pwerk='" + pwerk + '\'' +
", maktx='" + maktx + '\'' +
", menge='" + menge + '\'' +
", meins='" + meins + '\'' +
", zmenge='" + zmenge + '\'' +
", zmeins='" + zmeins + '\'' +
", lifnr='" + lifnr + '\'' +
", werks='" + werks + '\'' +
", lgort='" + lgort + '\'' +
", eindt='" + eindt + '\'' +
", elikz='" + elikz + '\'' +
", beizhu='" + beizhu + '\'' +
'}';
}
}

@ -0,0 +1,31 @@
package com.op.system.api.factory;
import com.op.common.core.domain.R;
import com.op.system.api.RemoteEnergyService;
import com.op.system.api.RemoteWmsService;
import com.op.system.api.domain.DataSourcePropertyDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
@Component
public class RemoteEnergyFallbackFactory implements FallbackFactory<RemoteEnergyService> {
private static final Logger log = LoggerFactory.getLogger(RemoteEnergyFallbackFactory.class);
@Override
public RemoteEnergyService create(Throwable throwable) {
log.error("能源服务调用失败:{}", throwable.getMessage());
return new RemoteEnergyService() {
@Override
public R addDatasource(DataSourcePropertyDTO dataSourceProperty) {
return R.fail("mes数据源创建失败:" + throwable.getMessage());
}
@Override
public R removeDatasource(DataSourcePropertyDTO dataSourceProperty) {
return R.fail("mes数据源删除失败:" + throwable.getMessage());
}
};
}
}

@ -51,6 +51,10 @@ public class ServiceNameConstants {
/**质量模块**/
public static final String QMS_SERVICE = "op-quality";
/**能源模块**/
public static final String ENERGY_SERVICE = "op-energy";
/**
* serviceid
*/

@ -4,6 +4,9 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.poi.hpsf.Decimal;
import java.math.BigDecimal;
/**
* ${subTable.functionName} mes_unit_price
@ -71,7 +74,7 @@ public class MesUnitPrice extends BaseEntity {
* 1
*/
@Excel(name = "工序单价(元/pc")
private String attr1;
private BigDecimal attr1;
/**
* 2
@ -163,12 +166,12 @@ public class MesUnitPrice extends BaseEntity {
return childprocessName;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
public BigDecimal getAttr1() {
return attr1;
}
public String getAttr1() {
return attr1;
public void setAttr1(BigDecimal attr1) {
this.attr1 = attr1;
}
public void setAttr2(String attr2) {

@ -61,5 +61,5 @@ public interface IMesUnitPriceService {
public int deleteMesUnitPriceByPicId(String picId);
public String importMesUnitPrice(List<MesUnitPrice> UnitPriceList, Boolean updateSupport, String operName);
public String importMesUnitPrice(List<MesUnitPrice> UnitPriceList, Boolean isUpdateSupport, String operName);
}

@ -114,7 +114,7 @@ public class MesUnitPriceServiceImpl implements IMesUnitPriceService {
@Override
@DS("#header.poolName")
public String importMesUnitPrice(List<MesUnitPrice> UnitPriceList, Boolean updateSupport, String operName) {
public String importMesUnitPrice(List<MesUnitPrice> UnitPriceList, Boolean isUpdateSupport, String operName) {
if (StringUtils.isNull(UnitPriceList) || UnitPriceList.size() == 0) {
throw new ServiceException("导入计件薪酬基础数据不能为空!");
}
@ -130,9 +130,18 @@ public class MesUnitPriceServiceImpl implements IMesUnitPriceService {
BeanValidators.validateWithException(validator, mesUnitPrice);
mesUnitPrice.setPicId(IdUtils.simpleUUID());
mesUnitPrice.setCreateBy(SecurityUtils.getUsername());
mesUnitPrice.setCreateTime(DateUtils.getNowDate());
mesUnitPriceMapper.insertMesUnitPrice(mesUnitPrice);
successNum++;
successMsg.append("<br/>" + successNum + mesUnitPrice.getProductName() + "-" + mesUnitPrice.getChildprocessName() + " 导入成功");
} else if (isUpdateSupport) {
BeanValidators.validateWithException(validator, mesUnitPrice);
if (!u.getAttr1().equals(mesUnitPrice.getAttr1())){
mesUnitPrice.setPicId(u.getPicId());
mesUnitPrice.setUpdateBy(operName);
mesUnitPrice.setUpdateTime(DateUtils.getNowDate());
mesUnitPriceMapper.updateMesUnitPrice(mesUnitPrice);
successNum++;
}
} else {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、产品 " + mesUnitPrice.getProductName() + " 已存在");
@ -144,11 +153,12 @@ public class MesUnitPriceServiceImpl implements IMesUnitPriceService {
log.error(msg, e);
}
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
}
return successMsg.toString();
}

@ -7,6 +7,7 @@ import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.utils.DateUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.mes.domain.MesUnitpriceReport;
import com.op.mes.domain.ProOrderWorkorder;
import com.op.mes.mapper.MesUnitpriceReportMapper;
import com.op.mes.service.IMesUnitpriceReportService;
import org.springframework.beans.factory.annotation.Autowired;

@ -29,9 +29,9 @@
</sql>
<select id="selectMesUnitPriceList" parameterType="MesUnitPrice" resultMap="MesUnitPriceResult">
select A.pic_id, A.factory_id, A.product_code, A.product_name, A.line_code,
A.line_name, A.childprocess_id, A.childprocess_code, A.childprocess_name, A.attr1,
A.attr2, A.attr3, A.attr4, A.create_by, A.create_time, A.update_by, A.update_time from mes_unit_price A
select pic_id, factory_id, product_code, product_name, line_code,
line_name, childprocess_id, childprocess_code, childprocess_name, attr1,
attr2, attr3, attr4, create_by, create_time, update_by, update_time from mes_unit_price
<where>
<if test="factoryId != null ">and factory_id = #{factoryId}</if>
<if test="productCode != null and productCode != ''">and product_code = #{productCode}</if>
@ -51,9 +51,9 @@
<if test="attr2 != null and attr2 != ''">and attr2 = #{attr2}</if>
<if test="attr3 != null ">and attr3 = #{attr3}</if>
<if test="attr4 != null ">and attr4 = #{attr4}</if>
<if test="createBy != null">create_by = #{createBy}</if>
<if test="createBy != null">and create_by = #{createBy}</if>
</where>
ORDER BY A.childprocess_code ASC
ORDER BY childprocess_code ASC
</select>
<select id="selectMesUnitPriceByPicId" parameterType="String" resultMap="MesUnitPriceResult">

@ -44,22 +44,16 @@
mur.product_code,
mur.product_name,
mur.line_code,
mur.attr1 AS real_wages,
mur.attr2 AS real_wages,
mur.remark,
be.sap_name as equipment_name,
mur.nick_name,
mur.childprocess_code,
mup.childprocess_name,
mrw.total_quantity,
mur.attr1 AS total_quantity,
mup.attr1,
CAST(CAST(mrw.total_quantity AS DECIMAL(18,2)) * CAST(mup.attr1 AS DECIMAL(18,5)) AS DECIMAL(18, 6)) AS result,
COUNT(*) OVER (PARTITION BY mur.workorder_code_sap, mur.childprocess_code) AS head_count,
ROUND(
CAST (
CAST(CAST(mrw.total_quantity AS DECIMAL(18,2)) * CAST(mup.attr1 AS DECIMAL(18,5)) AS DECIMAL(18, 6)) / NULLIF ( COUNT ( * ) OVER ( PARTITION BY mur.workorder_code_sap, mur.childprocess_code ), 0 ) AS DECIMAL ( 18, 4 )
),
4
) AS avg_result
mup.attr1*mur.attr1 AS result,
COUNT(*) OVER (PARTITION BY mur.workorder_code_sap, mur.childprocess_code) AS head_count
FROM
mes_unitprice_report mur
LEFT JOIN
@ -102,6 +96,7 @@
mur.product_code,
mur.product_name,
mur.attr1,
mur.attr2,
mur.line_code,
mur.remark,
be.sap_name,

@ -140,8 +140,8 @@ public class SapItemSyncImpl implements SapItemSyncService {
String VOLEH = maraTable.getString("VOLEH");
String MEINS = maraTable.getString("MEINS");
String MEINH = maraTable.getString("MEINH");
String UMREZ = maraTable.getString("UMREZ");
String UMREN = maraTable.getString("UMREN");
BigDecimal UMREZ = maraTable.getBigDecimal("UMREZ");
BigDecimal UMREN = maraTable.getBigDecimal("UMREN");
String LVORM = maraTable.getString("LVORM");
String MENGE = maraTable.getString("MENGE");
String MHDHB = maraTable.getString("MHDHB");
@ -194,6 +194,8 @@ public class SapItemSyncImpl implements SapItemSyncService {
baseProduct.setProductDescZh(MAKTX);
baseProduct.setProductGroup(MATKL);
baseProduct.setProductGroupName(WGBEZ);
baseProduct.setUmrez(UMREZ);
baseProduct.setUmren(UMREN);
baseProduct.setGrossWeight(BRGEW);
baseProduct.setNetWeight(NTGEW);
baseProduct.setVolume(VOLUM);
@ -260,7 +262,6 @@ public class SapItemSyncImpl implements SapItemSyncService {
Resmap.put("MATDOCUMENTYEAR", MATDOCUMENTYEAR);
return R.ok(Resmap, MESSAGE);
}
} catch (Exception e) {
return R.fail(e.getMessage());
}

@ -61,7 +61,6 @@ public class SapOrderServiceImpl implements SapOrderService {
// 配置传入参数
// S_WERKS(工厂) S_AUFNR订单号 S_MATNR物料号 S_ERDAT(创建日期) 例如20230923
if (!StringUtils.isNull(sapShopOrderQuery.getWerk())) {
JCoTable S_WERKS = func.getTableParameterList().getTable("S_PWERK");
S_WERKS.appendRow();
@ -337,10 +336,9 @@ public class SapOrderServiceImpl implements SapOrderService {
// 获取调用 RFC 函数对象
//获取连接
//JCoDestination dest = SAPConnUtils.connect();
log.info(DateUtils.getTime()+"采购订单抽取开始入参------" + sapPurchaseOrderQuery.toString());
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_GET_PROCURE");
JCoParameterList jCoParameterList = func.getTableParameterList();
System.out.println(jCoParameterList);
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
@ -349,6 +347,7 @@ public class SapOrderServiceImpl implements SapOrderService {
* S_MATNR
* S_PWERK
*/
System.out.println(func.getTableParameterList());
if (!StringUtils.isNull(sapPurchaseOrderQuery.getEbeln())) {
JCoTable S_EBELN = func.getTableParameterList().getTable("S_EBELN");
S_EBELN.appendRow();
@ -372,7 +371,7 @@ public class SapOrderServiceImpl implements SapOrderService {
}
if (!StringUtils.isNull(sapPurchaseOrderQuery.getPwerk())) {
JCoTable S_PWERK = func.getTableParameterList().getTable("S_PWERK");
JCoTable S_PWERK = func.getTableParameterList().getTable("P_WERK");
S_PWERK.appendRow();
S_PWERK.setValue(Constants.SIGN, "I");
S_PWERK.setValue(Constants.OPTION, "EQ");
@ -381,8 +380,7 @@ public class SapOrderServiceImpl implements SapOrderService {
func.execute(dest);//执行调用函数
// 获取 内表 - LT_PROCURE
JCoTable maraTable = func.getTableParameterList().getTable("LT_PROCURE");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
log.info(DateUtils.getTime()+"获取采购订单数据结束");
List<SapPurchaseOrderQuery> sapPurchaseOrderQueryList = new ArrayList<>();
for (int i = 0; i < maraTable.getNumRows(); i++) {
maraTable.setRow(i);
@ -649,6 +647,7 @@ public class SapOrderServiceImpl implements SapOrderService {
}
return R.ok(successMsg);
}
}

@ -22,6 +22,8 @@
<result property="tareWeight" column="tare_weight"/>
<result property="volume" column="volume"/>
<result property="meins" column="meins"/>
<result property="umrez" column="umrez"/>
<result property="umren" column="umren"/>
<result property="unitPrice" column="unit_price"/>
<result property="productGroup" column="product_group"/>
<result property="productGroupName" column="product_group_name"/>
@ -131,6 +133,8 @@
<if test="tareWeight != null">tare_weight,</if>
<if test="volume != null">volume,</if>
<if test="meins != null">meins,</if>
<if test="umrez != null">umrez,</if>
<if test="umren != null">umren,</if>
<if test="unitPrice != null">unit_price,</if>
<if test="productGroup != null">product_group,</if>
<if test="productGroupName != null">product_group_name,</if>
@ -176,6 +180,8 @@
<if test="tareWeight != null">#{tareWeight},</if>
<if test="volume != null">#{volume},</if>
<if test="meins != null">#{meins},</if>
<if test="umrez != null">#{umrez},</if>
<if test="umren != null">#{umren},</if>
<if test="unitPrice != null">#{unitPrice},</if>
<if test="productGroup != null">#{productGroup},</if>
<if test="productGroupName != null">#{productGroupName},</if>
@ -224,6 +230,8 @@
<if test="tareWeight != null">tare_weight = #{tareWeight},</if>
<if test="volume != null">volume = #{volume},</if>
<if test="meins != null">meins = #{meins},</if>
<if test="umrez != null">umrez = #{umrez},</if>
<if test="umren != null">umren = #{umren},</if>
<if test="unitPrice != null">unit_price = #{unitPrice},</if>
<if test="productGroup != null">product_group = #{productGroup},</if>
<if test="productGroupName != null">product_group_name = #{productGroupName},</if>

@ -63,6 +63,8 @@ public class SysDatasourceServiceImpl implements ISysDatasourceService {
private RemoteSapService remoteSapService;
@Autowired
private RemoteTechnologyService remoteTechnologyService;
@Autowired
private RemoteEnergyService remoteEnergyService;
@Resource
private DynamicRoutingDataSource dynamicRoutingDataSource;
@ -162,6 +164,8 @@ public class SysDatasourceServiceImpl implements ISysDatasourceService {
remoteSapService.removeDatasource(dataSourceProperty);
//工艺删除数据源
remoteTechnologyService.removeDatasource(dataSourceProperty);
//能源删除数据源
remoteEnergyService.removeDatasource(dataSourceProperty);
}
sysDatasourceMapper.deleteSysDatasourceByIds(ids);
sysDatasourceMapper.deleteUserByIds(ids);
@ -282,6 +286,8 @@ public class SysDatasourceServiceImpl implements ISysDatasourceService {
remoteSapService.addDatasource(dto);
//工艺加入数据源
remoteTechnologyService.addDatasource(dto);
//能源加入数据源
remoteEnergyService.addDatasource(dto);
return "数据库链接测试成功,数据库链接状态正常";
} catch (ClassNotFoundException | SQLException classNotFoundException) {

Loading…
Cancel
Save