tags/yfai-mes-ext-v1.0
gsz 1 year ago
commit a881b3ec49

@ -25,11 +25,11 @@ class mesWorkOrderToSap {
@Autowired
private MesWorkOrderToSapRepository mesWorkOrderToSapRDao;
//@Resource(name = "yfasDataSource")
@Resource(name = "yfasDataSource")
private DynamicDataSourceProxy yfasDataSource;
//@Resource(name = "mesDataSource")
//private DynamicDataSourceProxy mesDataSource;
@Resource(name = "mesDataSource")
private DynamicDataSourceProxy mesDataSource;
@Getter
@Setter

@ -0,0 +1,73 @@
package cn.estsh.i3plus.ext.mes.apiservice.cus_suit;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.platform.plugin.datasource.DynamicDataSourceProxy;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.TimeUnit;
/**
* @Description :
* @Reference :
* @Author : alwaysfrin
* @CreateDate : 2019-06-11 14:26
* @Modify:
**/
@Configuration
//@PropertySource(value="classpath:/cus_config/cus-datasource.properties",encoding = "UTF-8")
public class CusProperties {
public static final Logger LOGGER = LoggerFactory.getLogger(CommonConstWords.SYSTEM_LOG);
/***********************
*
*/
@Value("${impp.yfas.datasource.isopen}")
@Getter
private boolean yfasIsOpen;
@Value("${impp.yfas.datasource.driver-class-name}")
@Getter
private String yfasDriverClassName;
@Value("${impp.yfas.datasource.alias}")
@Getter
private String yfasDsAlias;
@Value("${impp.yfas.datasource.jdbc-url}")
@Getter
private String yfasDsJdbcUrl;
@Value("${impp.yfas.datasource.username}")
@Getter
private String yfasDsUsername;
@Value("${impp.yfas.datasource.password}")
@Getter
private String yfasDsPassword;
@ConditionalOnExpression("'${impp.yfas.datasource.isopen:false}' == 'true'")
@Bean(name = "yfasDataSource")
public DynamicDataSourceProxy initYfasCustomerSet(){
LOGGER.info("【初始化客户定制化...】");
/**
*
*/
LOGGER.info("【客户定制化:安道拓数据源加载...】");
//安道拓定制业务
DynamicDataSourceProxy yfasDataSource = DynamicDataSourceProxy.initDataSourceFactory(this.getYfasDriverClassName(),
this.getYfasDsJdbcUrl(),this.getYfasDsUsername(),this.getYfasDsPassword(),TimeUnit.MINUTES.toMillis(30));
//手动注册DataSource到spring中
//SpringContextsUtil.registBean(this.getYfasDsAlias(),yfasDataSource);
return yfasDataSource;
}
}

@ -0,0 +1,70 @@
package cn.estsh.i3plus.ext.mes.apiservice.cus_suit;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.platform.plugin.datasource.DynamicDataSourceProxy;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.TimeUnit;
/**
* @Description : mes
* @Reference :
* @Author : Rock.Yu
* @CreateDate : 2019-06-13 20:40
* @Modify:
**/
@Configuration
//@PropertySource(value="classpath:/cus_config/cus-datasource.properties",encoding = "UTF-8")
public class MesProperties {
public static final Logger LOGGER = LoggerFactory.getLogger(CommonConstWords.SYSTEM_LOG);
/***********************
* mes
*/
@Value("${impp.mes.datasource.isopen}")
@Getter
private boolean mesIsOpen;
@Value("${impp.mes.datasource.driver-class-name}")
@Getter
private String mesDriverClassName;
@Value("${impp.mes.datasource.alias}")
@Getter
private String mesDsAlias;
@Value("${impp.mes.datasource.jdbc-url}")
@Getter
private String mesDsJdbcUrl;
@Value("${impp.mes.datasource.username}")
@Getter
private String mesDsUsername;
@Value("${impp.mes.datasource.password}")
@Getter
private String mesDsPassword;
@ConditionalOnExpression("'${impp.mes.datasource.isopen:false}' == 'true'")
@Bean(name = "mesDataSource")
public DynamicDataSourceProxy initmesCustomerSet(){
LOGGER.info("【初始化客户定制化-mes直连...】");
/**
*
*/
LOGGER.info("【客户定制化mes直连数据源加载...】");
//安道拓定制业务
DynamicDataSourceProxy mesDataSource = DynamicDataSourceProxy.initDataSourceFactory(this.getMesDriverClassName(),
this.getMesDsJdbcUrl(),this.getMesDsUsername(),this.getMesDsPassword(),TimeUnit.MINUTES.toMillis(30));
return mesDataSource;
}
}

@ -0,0 +1,65 @@
package cn.estsh.i3plus.ext.mes.apiservice.cus_suit.yfas;
import cn.estsh.i3plus.platform.plugin.datasource.DynamicDataSourceProxy;
import cn.estsh.i3plus.pojo.mes.bean.BasVendor;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description :
* @Reference : Service使service
* @Author : alwaysfrin
* @CreateDate : 2019-06-11 14:35
* @Modify:
**/
@Component
public class YfasBusiTool {
@Resource(name="yfasDataSource")
private DynamicDataSourceProxy dataSourceProxy;
public void execute(String sql) throws SQLException {
dataSourceProxy.execute(sql);
}
public void insert(String tableName,HashMap<String,Object> objMap) throws SQLException {
dataSourceProxy.insert(tableName,objMap);
}
public void update(String tableName,HashMap<String,Object> conditionMap,HashMap<String,Object> setValueMap) throws SQLException {
dataSourceProxy.update(tableName,conditionMap,setValueMap);
}
public void detelte(String tableName,HashMap<String,Object> conditionMap) throws SQLException {
dataSourceProxy.delete(tableName,conditionMap);
}
public List<Map<String,Object>> listMap(String sql) throws SQLException {
return dataSourceProxy.queryMapList(sql);
}
public BasVendor get(String sql) throws SQLException, IllegalAccessException, InstantiationException {
return dataSourceProxy.queryObject(sql,BasVendor.class);
}
public List<BasVendor> listObject(String sql) throws SQLException, IllegalAccessException, InstantiationException {
return dataSourceProxy.queryObjectList(sql,BasVendor.class);
}
public BasVendor get(String tableName,HashMap<String,Object> conditionMap) throws SQLException, IllegalAccessException, InstantiationException {
return dataSourceProxy.queryObject(tableName,conditionMap,BasVendor.class);
}
public List<BasVendor> listObject(String tableName,HashMap<String,Object> conditionMap) throws SQLException, IllegalAccessException, InstantiationException {
return dataSourceProxy.queryObjectList(tableName,conditionMap,BasVendor.class);
}
public int[] executeAsBatch(String[] sqlArr) throws SQLException {
return dataSourceProxy.executeAsBatch(sqlArr);
}
}

@ -41,10 +41,10 @@ public class MesSAPDbAdapter {
public static final Logger LOGGER = LoggerFactory.getLogger(WmsSAPDbWriter.class);
//@Resource(name = "yfasDataSource")
@Resource(name = "yfasDataSource")
private DynamicDataSourceProxy sapDataSourceProxy;
//@Resource(name = "mesDataSource")
@Resource(name = "mesDataSource")
private DynamicDataSourceProxy mesDataSourceProxy;
@Value("${sync.redis.time:1800}")

@ -26,10 +26,10 @@ import java.sql.Connection;
public class WmsSAPDbQuery {
public static final Logger LOGGER = LoggerFactory.getLogger(WmsSAPDbQuery.class);
public static boolean needI18N = true;
// @Resource(name = "wmsDataSource")
// private DynamicDataSourceProxy wmsDataSourceProxy;
/*@Resource(name = "wmsDataSource")
private DynamicDataSourceProxy wmsDataSourceProxy;*/
//@Resource(name = "mesDataSource")
@Resource(name = "mesDataSource")
private DynamicDataSourceProxy mesDataSourceProxy;
@Autowired

@ -1,8 +1,8 @@
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base;
import cn.estsh.i3plus.ext.mes.api.base.IMesConfigService;
import cn.estsh.i3plus.ext.mes.api.base.IMesPartService;
import cn.estsh.i3plus.ext.mes.api.base.IMesShippingOrderManagementService;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
@ -13,6 +13,7 @@ import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.repository.MesJisShippingRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPartRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPartShippingGroupRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
@ -25,6 +26,8 @@ import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
@ -47,6 +50,9 @@ public class MesShippingOrderManagementService extends BaseMesService<MesShippin
@Autowired
private MesPartRepository partRepository;
@Autowired
private IMesPartService partService;
protected void setPackQueryBean(MesShippingOrderManagement bean, DdlPackBean packBean) {
DdlPreparedPack.getStringEqualPack(bean.getShippingGroupNo(), "shippingGroupNo", packBean);
@ -120,11 +126,16 @@ public class MesShippingOrderManagementService extends BaseMesService<MesShippin
groupDetailList.forEach(k -> {
MesShippingOrderManagementDetail detail = new MesShippingOrderManagementDetail();
MesPart part = partService.getPartByPartNo(k.getPartNo(), k.getOrganizeCode());
detail.setPartName(part.getPartName());
detail.setCustPartNo(k.getCustomerPartNo());
detail.setPlanQty(1D);
detail.setActualQty(1);
detail.setShippingOrderNo(finalBean.getShippingOrderNo());
detail.setOrganizeCode(k.getOrganizeCode());
detail.setStatus(MesExtEnumUtil.SHIPPING_ORDER_STATUS.CREATE.getValue());
ConvertBean.serviceModelInitialize(detail, AuthUtil.getSessionUser().getUserName());
BeanUtils.copyProperties(k, detail, "id");
ConvertBean.serviceModelInitialize(detail, AuthUtil.getSessionUser().getUserName());
detailInsertList.add(detail);
});
@ -259,12 +270,13 @@ public class MesShippingOrderManagementService extends BaseMesService<MesShippin
DdlPreparedPack.getStringEqualPack(originBean.getShippingOrderNo(), "shippingOrderNo", detailPackBean);
List<MesShippingOrderManagementDetail> detailDeleteList = detailService.findAll(detailPackBean);
;
Map<String, List<MesShippingOrderManagementDetail>> detailMap = detailDeleteList.stream().collect(Collectors.groupingBy(k -> k.getPartNo()));
List<MesJisShipping> jisShippingList = new ArrayList<>();
detailDeleteList.forEach(k -> {
detailMap.forEach((k, v) -> {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(k.getPartNo(), "partNo", packBean);
DdlPreparedPack.getStringEqualPack(v.get(0).getPartNo(), "partNo", packBean);
MesPart part = partRepository.getByProperty(packBean);
MesJisShipping jisShipping = new MesJisShipping();
@ -277,13 +289,13 @@ public class MesShippingOrderManagementService extends BaseMesService<MesShippin
jisShipping.setErpWarerhouse(configService.getCfgValue(bean.getOrganizeCode(), "ERP_WARERHOUSE"));
jisShipping.setErpWarehous(configService.getCfgValue(bean.getOrganizeCode(), "ERP_WAREHOUS"));
jisShipping.setCusDock(originBean.getCustDockCode());
jisShipping.setCustOrderNo(k.getCustOrderNo());
jisShipping.setSerialNumber(k.getBarcode());
jisShipping.setQuantityPerCar(detailDeleteList.size());
jisShipping.setCustOrderNo(v.get(0).getCustOrderNo());
jisShipping.setSerialNumber(v.get(0).getBarcode());
jisShipping.setQuantityPerCar(v.size());
jisShipping.setShippingOrderCode(originBean.getShippingOrderNo());
jisShipping.setVin(k.getVin());
jisShipping.setCarNo(k.getVin());
if(!StringUtils.isEmpty(part)){
jisShipping.setVin(v.get(0).getVin());
jisShipping.setCarNo(v.get(0).getVin());
if (!StringUtils.isEmpty(part)) {
jisShipping.setUnit(part.getUnit());
}
jisShipping.setOffTime(TimeTool.getNowTime(true));

@ -212,7 +212,7 @@ spring.shardingsphere.datasource.names=master,slave
##??
spring.shardingsphere.datasource.master.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.master.driver-class-name= com.mysql.jdbc.Driver
spring.shardingsphere.datasource.master.JdbcUrl=jdbc:mysql://10.195.88.71:3306/impp_i3_mes?autoReconnect=true&useSSL=false&characterEncoding=utf-8
spring.shardingsphere.datasource.master.JdbcUrl=jdbc:mysql://10.195.88.71:3316/impp_i3_mes?autoReconnect=true&useSSL=false&characterEncoding=utf-8
spring.shardingsphere.datasource.master.username=root
spring.shardingsphere.datasource.master.password=estsh123
@ -228,7 +228,7 @@ spring.shardingsphere.datasource.master.keep-alive-time=3500000
##??
spring.shardingsphere.datasource.slave.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.slave.driver-class-name= com.mysql.jdbc.Driver
spring.shardingsphere.datasource.slave.JdbcUrl=jdbc:mysql://10.195.88.71:3306/impp_i3_mes?autoReconnect=true&useSSL=false&characterEncoding=utf-8
spring.shardingsphere.datasource.slave.JdbcUrl=jdbc:mysql://10.195.88.71:3336/impp_i3_mes?autoReconnect=true&useSSL=false&characterEncoding=utf-8
spring.shardingsphere.datasource.slave.username=root
spring.shardingsphere.datasource.slave.password=estsh123

Loading…
Cancel
Save