From 994ccf66286f76dd82526ed3e08bd85e0186b6c1 Mon Sep 17 00:00:00 2001 From: Leon Date: Fri, 4 Jun 2021 17:58:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=AF=E5=8A=A8=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=8A=A0=E8=BD=BD=E6=89=80=E6=9C=89Mapper?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mesnac/common/aspect/HttpLogAspect.java | 2 +- .../GeneralMybatisPlusSqlInjector.java | 53 +++ .../console/mybatis/MybatisPlusConfig.java | 23 + .../ExtMybatisPlusAutoConfiguration.java | 137 ++++++ .../ExtMybatisPlusProperties.java | 32 ++ .../mybatis/core/ExtMybatisConfiguration.java | 130 ++++++ .../core/ExtMybatisMapperRegistry.java | 84 ++++ .../override/ExtMybatisMapperMethod.java | 420 ++++++++++++++++++ .../override/ExtMybatisMapperProxy.java | 91 ++++ .../ExtMybatisMapperProxyFactory.java | 43 ++ .../mybatis/override/MethodFactory.java | 53 +++ console/src/main/resources/application.yml | 1 + .../controller/SfcDispatchController.java | 29 +- .../dispatch/mapper/SfcDispatchMapper.java | 3 + .../mesnac/dispatch/model/SfcDispatch.java | 146 +++--- .../dispatch/model/ShopOrderRelease.java | 27 ++ .../dispatch/service/SfcDispatchService.java | 9 + .../service/impl/SfcDispatchServiceImpl.java | 6 + .../impl/ShopOrderReleaseServiceImpl.java | 10 +- .../resources/mapper/SfcDispatchMapper.xml | 170 +++++-- .../meapi/controller/ResrceController.java | 13 + .../meapi/controller/SfcController.java | 45 +- .../mesnac/meapi/mapper/ResrceMapper.java | 4 + .../mesnac/meapi/service/ResrceService.java | 9 + .../meapi/service/impl/ResrceServiceImpl.java | 5 + .../main/resources/mapper/ResrceMapper.xml | 8 + meapi/src/main/resources/mapper/SfcMapper.xml | 4 +- 27 files changed, 1422 insertions(+), 135 deletions(-) create mode 100644 console/src/main/java/com/foreverwin/mesnac/console/mybatis/GeneralMybatisPlusSqlInjector.java create mode 100644 console/src/main/java/com/foreverwin/mesnac/console/mybatis/MybatisPlusConfig.java create mode 100644 console/src/main/java/com/foreverwin/mesnac/console/mybatis/autoconfigure/ExtMybatisPlusAutoConfiguration.java create mode 100644 console/src/main/java/com/foreverwin/mesnac/console/mybatis/autoconfigure/ExtMybatisPlusProperties.java create mode 100644 console/src/main/java/com/foreverwin/mesnac/console/mybatis/core/ExtMybatisConfiguration.java create mode 100644 console/src/main/java/com/foreverwin/mesnac/console/mybatis/core/ExtMybatisMapperRegistry.java create mode 100644 console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperMethod.java create mode 100644 console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperProxy.java create mode 100644 console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperProxyFactory.java create mode 100644 console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/MethodFactory.java diff --git a/common/src/main/java/com/foreverwin/mesnac/common/aspect/HttpLogAspect.java b/common/src/main/java/com/foreverwin/mesnac/common/aspect/HttpLogAspect.java index 211cec77..fe954a1a 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/aspect/HttpLogAspect.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/aspect/HttpLogAspect.java @@ -33,7 +33,7 @@ import java.util.UUID; * @author Syngna * @since 2020-01-13 */ -@Aspect +//@Aspect @Component public class HttpLogAspect { diff --git a/console/src/main/java/com/foreverwin/mesnac/console/mybatis/GeneralMybatisPlusSqlInjector.java b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/GeneralMybatisPlusSqlInjector.java new file mode 100644 index 00000000..f5cc4f7c --- /dev/null +++ b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/GeneralMybatisPlusSqlInjector.java @@ -0,0 +1,53 @@ +package com.foreverwin.mesnac.console.mybatis; + +import com.baomidou.mybatisplus.core.injector.AbstractMethod; +import com.baomidou.mybatisplus.core.metadata.TableInfo; +import com.baomidou.mybatisplus.core.parser.SqlParserHelper; +import com.baomidou.mybatisplus.core.toolkit.Assert; +import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils; +import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper; +import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector; +import org.apache.ibatis.builder.MapperBuilderAssistant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; + +import java.util.List; +import java.util.Set; + +/** + * 自定义sql注入器,增加通用方法 + */ +public class GeneralMybatisPlusSqlInjector extends LogicSqlInjector { + + @Autowired + private Environment env; + + @Override + public void inspectInject(MapperBuilderAssistant builderAssistant, Class mapperClass) { + + String statementLazyLoad = env.getProperty("mybatis-plus.statement-lazy-load"); + + String className = mapperClass.toString(); + Set mapperRegistryCache = GlobalConfigUtils.getMapperRegistryCache(builderAssistant.getConfiguration()); + if (!mapperRegistryCache.contains(className)) { + List methodList = this.getMethodList(); + Assert.notEmpty(methodList, "No effective injection method was found."); + // 循环注入自定义方法 + Class modelClass = extractModelClass(mapperClass); + if (modelClass != null) { + TableInfo tableInfo = TableInfoHelper.initTableInfo(builderAssistant, modelClass); + if(!"true".equals(statementLazyLoad)) { + methodList.forEach(m -> m.inject(builderAssistant, mapperClass, modelClass, tableInfo)); + } + } + + mapperRegistryCache.add(className); + /* + * 初始化 SQL 解析 + */ + if (GlobalConfigUtils.getGlobalConfig(builderAssistant.getConfiguration()).isSqlParserCache()) { + SqlParserHelper.initSqlParserInfoCache(mapperClass); + } + } + } +} diff --git a/console/src/main/java/com/foreverwin/mesnac/console/mybatis/MybatisPlusConfig.java b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/MybatisPlusConfig.java new file mode 100644 index 00000000..0fe947af --- /dev/null +++ b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/MybatisPlusConfig.java @@ -0,0 +1,23 @@ +package com.foreverwin.mesnac.console.mybatis; + +import com.baomidou.mybatisplus.core.injector.ISqlInjector; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * + * @description: + * @author: syngna + * @create: 2020-11-23 21:11 + */ +@Configuration +public class MybatisPlusConfig { + /** + * 自定义sql注入器 + * @return + */ + @Bean + public ISqlInjector sqlInjector() { + return new GeneralMybatisPlusSqlInjector(); + } +} \ No newline at end of file diff --git a/console/src/main/java/com/foreverwin/mesnac/console/mybatis/autoconfigure/ExtMybatisPlusAutoConfiguration.java b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/autoconfigure/ExtMybatisPlusAutoConfiguration.java new file mode 100644 index 00000000..5a384a8b --- /dev/null +++ b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/autoconfigure/ExtMybatisPlusAutoConfiguration.java @@ -0,0 +1,137 @@ +package com.foreverwin.mesnac.console.mybatis.autoconfigure; + +import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; +import com.baomidou.mybatisplus.autoconfigure.SpringBootVFS; +import com.baomidou.mybatisplus.core.config.GlobalConfig; +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator; +import com.baomidou.mybatisplus.core.injector.ISqlInjector; +import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; +import com.foreverwin.mesnac.console.mybatis.core.ExtMybatisConfiguration; +import org.apache.ibatis.mapping.DatabaseIdProvider; +import org.apache.ibatis.plugin.Interceptor; +import org.apache.ibatis.session.SqlSessionFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ResourceLoader; +import org.springframework.util.CollectionUtils; +import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; + +import javax.sql.DataSource; +import java.util.List; + +/** + * + * @description: + * @author: syngna + * @create: 2021-04-16 16:58 + */ +@ConditionalOnProperty(prefix = "mybatis-plus",name = "statement-lazy-load",havingValue = "true") +@Configuration +public class ExtMybatisPlusAutoConfiguration { + + + private final ExtMybatisPlusProperties properties; + + private final Interceptor[] interceptors; + + private final ResourceLoader resourceLoader; + + private final DatabaseIdProvider databaseIdProvider; + + private final List configurationCustomizers; + + private final ApplicationContext applicationContext; + + + public ExtMybatisPlusAutoConfiguration(ExtMybatisPlusProperties properties, + ObjectProvider interceptorsProvider, + ResourceLoader resourceLoader, + ObjectProvider databaseIdProvider, + ObjectProvider> configurationCustomizersProvider, + ApplicationContext applicationContext) { + this.properties = properties; + this.interceptors = interceptorsProvider.getIfAvailable(); + this.resourceLoader = resourceLoader; + this.databaseIdProvider = databaseIdProvider.getIfAvailable(); + this.configurationCustomizers = configurationCustomizersProvider.getIfAvailable(); + this.applicationContext = applicationContext; + } + + @Bean + public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { + MybatisSqlSessionFactoryBean factory = new MybatisSqlSessionFactoryBean(); + factory.setDataSource(dataSource); + factory.setVfs(SpringBootVFS.class); + if (StringUtils.hasText(this.properties.getConfigLocation())) { + factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation())); + } + applyConfiguration(factory); + if (this.properties.getConfigurationProperties() != null) { + factory.setConfigurationProperties(this.properties.getConfigurationProperties()); + } + if (!ObjectUtils.isEmpty(this.interceptors)) { + factory.setPlugins(this.interceptors); + } + if (this.databaseIdProvider != null) { + factory.setDatabaseIdProvider(this.databaseIdProvider); + } + if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) { + factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage()); + } + // TODO 自定义枚举包 + if (StringUtils.hasLength(this.properties.getTypeEnumsPackage())) { + factory.setTypeEnumsPackage(this.properties.getTypeEnumsPackage()); + } + if (this.properties.getTypeAliasesSuperType() != null) { + factory.setTypeAliasesSuperType(this.properties.getTypeAliasesSuperType()); + } + if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) { + factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage()); + } + if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) { + factory.setMapperLocations(this.properties.resolveMapperLocations()); + } + // TODO 此处必为非 NULL + GlobalConfig globalConfig = this.properties.getGlobalConfig(); + //注入填充器 + if (this.applicationContext.getBeanNamesForType(MetaObjectHandler.class, + false, false).length > 0) { + MetaObjectHandler metaObjectHandler = this.applicationContext.getBean(MetaObjectHandler.class); + globalConfig.setMetaObjectHandler(metaObjectHandler); + } + //注入主键生成器 + if (this.applicationContext.getBeanNamesForType(IKeyGenerator.class, false, + false).length > 0) { + IKeyGenerator keyGenerator = this.applicationContext.getBean(IKeyGenerator.class); + globalConfig.getDbConfig().setKeyGenerator(keyGenerator); + } + //注入sql注入器 + if (this.applicationContext.getBeanNamesForType(ISqlInjector.class, false, + false).length > 0) { + ISqlInjector iSqlInjector = this.applicationContext.getBean(ISqlInjector.class); + globalConfig.setSqlInjector(iSqlInjector); + } + factory.setGlobalConfig(globalConfig); + return factory.getObject(); + } + + private void applyConfiguration(MybatisSqlSessionFactoryBean factory) { + ExtMybatisConfiguration configuration = this.properties.getConfiguration(); + if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) { + configuration = new ExtMybatisConfiguration(); + } + if (configuration != null && !CollectionUtils.isEmpty(this.configurationCustomizers)) { + for (ConfigurationCustomizer customizer : this.configurationCustomizers) { + customizer.customize(configuration); + } + } + factory.setConfiguration(configuration); + } +} \ No newline at end of file diff --git a/console/src/main/java/com/foreverwin/mesnac/console/mybatis/autoconfigure/ExtMybatisPlusProperties.java b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/autoconfigure/ExtMybatisPlusProperties.java new file mode 100644 index 00000000..36a419c6 --- /dev/null +++ b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/autoconfigure/ExtMybatisPlusProperties.java @@ -0,0 +1,32 @@ +package com.foreverwin.mesnac.console.mybatis.autoconfigure; + +import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties; +import com.foreverwin.mesnac.console.mybatis.core.ExtMybatisConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.NestedConfigurationProperty; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +/** + * + * @description: + * @author: syngna + * @create: 2021-04-18 10:08 + */ +@Primary +@ConditionalOnProperty(prefix = "mybatis-plus",name = "statement-lazy-load",havingValue = "true") +@Component +public class ExtMybatisPlusProperties extends MybatisPlusProperties { + + @NestedConfigurationProperty + private ExtMybatisConfiguration configuration; + + @Override + public ExtMybatisConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration(ExtMybatisConfiguration configuration) { + this.configuration = configuration; + } +} \ No newline at end of file diff --git a/console/src/main/java/com/foreverwin/mesnac/console/mybatis/core/ExtMybatisConfiguration.java b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/core/ExtMybatisConfiguration.java new file mode 100644 index 00000000..5ca1b808 --- /dev/null +++ b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/core/ExtMybatisConfiguration.java @@ -0,0 +1,130 @@ +package com.foreverwin.mesnac.console.mybatis.core; + +import com.baomidou.mybatisplus.core.MybatisConfiguration; +import com.baomidou.mybatisplus.core.metadata.TableInfo; +import com.baomidou.mybatisplus.core.toolkit.ArrayUtils; +import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper; +import com.foreverwin.mesnac.console.mybatis.override.MethodFactory; +import com.foreverwin.modular.core.exception.BusinessException; +import org.apache.ibatis.binding.MapperRegistry; +import org.apache.ibatis.builder.MapperBuilderAssistant; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.session.SqlSession; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.lang.reflect.WildcardType; + +/** + * @program: modular-aps + * @description: override mybatis configuration + * @author: syngna + * @create: 2021-04-16 17:15 + */ +public class ExtMybatisConfiguration extends MybatisConfiguration { + + protected final ExtMybatisMapperRegistry mybatisMapperRegistry = new ExtMybatisMapperRegistry(this); + + /** + * 使用自己的 MybatisMapperRegistry + */ + @Override + public MapperRegistry getMapperRegistry() { + return mybatisMapperRegistry; + } + + /** + * 使用自己的 MybatisMapperRegistry + */ + @Override + public void addMapper(Class type) { + mybatisMapperRegistry.addMapper(type); + } + + /** + * 使用自己的 MybatisMapperRegistry + */ + @Override + public void addMappers(String packageName, Class superType) { + mybatisMapperRegistry.addMappers(packageName, superType); + } + + /** + * 使用自己的 MybatisMapperRegistry + */ + @Override + public void addMappers(String packageName) { + mybatisMapperRegistry.addMappers(packageName); + } + + /** + * 使用自己的 MybatisMapperRegistry + */ + @Override + public T getMapper(Class type, SqlSession sqlSession) { + return mybatisMapperRegistry.getMapper(type, sqlSession); + } + + /** + * 使用自己的 MybatisMapperRegistry + */ + @Override + public boolean hasMapper(Class type) { + return mybatisMapperRegistry.hasMapper(type); + } + + @Override + public MappedStatement getMappedStatement(String id, boolean validateIncompleteStatements) { + if (validateIncompleteStatements) { + buildAllStatements(); + } + if(!this.hasStatement(id)) { + // 新增逻辑,没找到注入的statement则先注入---------------------------------------------------------------------------------------------------------- + String mapperName = id.substring(0, id.lastIndexOf(".")); + String methodName = id.substring(id.lastIndexOf(".") + 1); + Class mapperInterface; + try { + mapperInterface = Class.forName(mapperName); + } catch (ClassNotFoundException e) { + throw BusinessException.build("get mapper class [" + mapperName + "] failed " + e); + } + String resource = mapperName.replace('.', '/') + ".java (best guess)"; + MapperBuilderAssistant assistant = new MapperBuilderAssistant(this, resource); + assistant.setCurrentNamespace(mapperName); + Class modelClass = extractModelClass(mapperInterface); + TableInfo tableInfo = TableInfoHelper.initTableInfo(assistant, modelClass); + MethodFactory.getInstance(methodName).inject(assistant,mapperInterface, modelClass, tableInfo); + // ----------------------------------------------------------------------------------------------------------------------------------------------- + } + return mappedStatements.get(id); + } + + /** + * 提取泛型模型,多泛型的时候请将泛型T放在第一位 + * + * @param mapperClass mapper 接口 + * @return mapper 泛型 + */ + protected Class extractModelClass(Class mapperClass) { + Type[] types = mapperClass.getGenericInterfaces(); + ParameterizedType target = null; + for (Type type : types) { + if (type instanceof ParameterizedType) { + Type[] typeArray = ((ParameterizedType) type).getActualTypeArguments(); + if (ArrayUtils.isNotEmpty(typeArray)) { + for (Type t : typeArray) { + if (t instanceof TypeVariable || t instanceof WildcardType) { + break; + } else { + target = (ParameterizedType) type; + break; + } + } + } + break; + } + } + return target == null ? null : (Class) target.getActualTypeArguments()[0]; + } +} \ No newline at end of file diff --git a/console/src/main/java/com/foreverwin/mesnac/console/mybatis/core/ExtMybatisMapperRegistry.java b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/core/ExtMybatisMapperRegistry.java new file mode 100644 index 00000000..45d31c34 --- /dev/null +++ b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/core/ExtMybatisMapperRegistry.java @@ -0,0 +1,84 @@ +package com.foreverwin.mesnac.console.mybatis.core; + +import com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder; +import com.baomidou.mybatisplus.core.MybatisMapperRegistry; +import com.foreverwin.mesnac.console.mybatis.override.ExtMybatisMapperProxyFactory; +import org.apache.ibatis.binding.BindingException; +import org.apache.ibatis.session.Configuration; +import org.apache.ibatis.session.SqlSession; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * @program: modular-aps + * @description: + * @author: syngna + * @create: 2021-04-16 17:25 + */ +public class ExtMybatisMapperRegistry extends MybatisMapperRegistry { + + private final Map, ExtMybatisMapperProxyFactory> knownMappers = new HashMap<>(); + private final Configuration config; + + public ExtMybatisMapperRegistry(Configuration config) { + super(config); + this.config = config; + } + + @SuppressWarnings("unchecked") + @Override + public T getMapper(Class type, SqlSession sqlSession) { + final ExtMybatisMapperProxyFactory mapperProxyFactory = (ExtMybatisMapperProxyFactory) knownMappers.get(type); + if (mapperProxyFactory == null) { + throw new BindingException("Type " + type + " is not known to the MybatisPlusMapperRegistry."); + } + try { + return mapperProxyFactory.newInstance(sqlSession); + } catch (Exception e) { + throw new BindingException("Error getting mapper instance. Cause: " + e, e); + } + } + + @Override + public boolean hasMapper(Class type) { + return knownMappers.containsKey(type); + } + + @Override + public void addMapper(Class type) { + if (type.isInterface()) { + if (hasMapper(type)) { + // TODO 如果之前注入 直接返回 + return; + // throw new BindingException("Type " + type + + // " is already known to the MybatisPlusMapperRegistry."); + } + boolean loadCompleted = false; + try { + knownMappers.put(type, new ExtMybatisMapperProxyFactory<>(type)); + // It's important that the type is added before the parser is run + // otherwise the binding may automatically be attempted by the + // mapper parser. If the type is already known, it won't try. + // TODO 自定义无 XML 注入 + MybatisMapperAnnotationBuilder parser = new MybatisMapperAnnotationBuilder(config, type); + parser.parse(); + loadCompleted = true; + } finally { + if (!loadCompleted) { + knownMappers.remove(type); + } + } + } + } + + /** + * 使用自己的 knownMappers + */ + @Override + public Collection> getMappers() { + return Collections.unmodifiableCollection(knownMappers.keySet()); + } +} \ No newline at end of file diff --git a/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperMethod.java b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperMethod.java new file mode 100644 index 00000000..a3f94b99 --- /dev/null +++ b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperMethod.java @@ -0,0 +1,420 @@ +package com.foreverwin.mesnac.console.mybatis.override; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.metadata.TableInfo; +import com.baomidou.mybatisplus.core.toolkit.ArrayUtils; +import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper; +import org.apache.ibatis.annotations.Flush; +import org.apache.ibatis.annotations.MapKey; +import org.apache.ibatis.binding.BindingException; +import org.apache.ibatis.builder.MapperBuilderAssistant; +import org.apache.ibatis.cursor.Cursor; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.SqlCommandType; +import org.apache.ibatis.mapping.StatementType; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.reflection.ParamNameResolver; +import org.apache.ibatis.reflection.TypeParameterResolver; +import org.apache.ibatis.session.Configuration; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; +import org.apache.ibatis.session.SqlSession; + +import java.lang.reflect.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * 重写类: org.apache.ibatis.binding.MapperMethod
+ *

不要 ParamMap 该内部类

+ * + * @author miemie + * @since 2018-06-09 + */ +public class ExtMybatisMapperMethod { + + private final SqlCommand command; + private final MethodSignature method; + + public ExtMybatisMapperMethod(Class mapperInterface, Method method, Configuration config) { + this.command = new SqlCommand(config, mapperInterface, method); + this.method = new MethodSignature(config, mapperInterface, method); + } + + @SuppressWarnings("unchecked") + public Object execute(SqlSession sqlSession, Object[] args) { + Object result; + switch (command.getType()) { + case INSERT: { + Object param = method.convertArgsToSqlCommandParam(args); + result = rowCountResult(sqlSession.insert(command.getName(), param)); + break; + } + case UPDATE: { + Object param = method.convertArgsToSqlCommandParam(args); + result = rowCountResult(sqlSession.update(command.getName(), param)); + break; + } + case DELETE: { + Object param = method.convertArgsToSqlCommandParam(args); + result = rowCountResult(sqlSession.delete(command.getName(), param)); + break; + } + case SELECT: + if (method.returnsVoid() && method.hasResultHandler()) { + executeWithResultHandler(sqlSession, args); + result = null; + } else if (method.returnsMany()) { + result = executeForMany(sqlSession, args); + } else if (method.returnsMap()) { + result = executeForMap(sqlSession, args); + } else if (method.returnsCursor()) { + result = executeForCursor(sqlSession, args); + } else { + Object param = method.convertArgsToSqlCommandParam(args); + /* + * 这下面 + */ + if (IPage.class.isAssignableFrom(method.getReturnType()) && args != null + && IPage.class.isAssignableFrom(args[0].getClass())) { + result = ((IPage) args[0]).setRecords(executeForIPage(sqlSession, args)); + /* + * 这上面 + */ + } else { + result = sqlSession.selectOne(command.getName(), param); + if (method.returnsOptional() && + (result == null || !method.getReturnType().equals(result.getClass()))) { + result = Optional.ofNullable(result); + } + } + } + break; + case FLUSH: + result = sqlSession.flushStatements(); + break; + default: + throw new BindingException("Unknown execution method for: " + command.getName()); + } + if (result == null && method.getReturnType().isPrimitive() && !method.returnsVoid()) { + throw new BindingException("Mapper method '" + command.getName() + + " attempted to return null from a method with a primitive return type (" + method.getReturnType() + ")."); + } + return result; + } + + /** + * IPage 专用 + */ + private List executeForIPage(SqlSession sqlSession, Object[] args) { + Object param = method.convertArgsToSqlCommandParam(args); + return sqlSession.selectList(command.getName(), param); + } + + private Object rowCountResult(int rowCount) { + final Object result; + if (method.returnsVoid()) { + result = null; + } else if (Integer.class.equals(method.getReturnType()) || Integer.TYPE.equals(method.getReturnType())) { + result = rowCount; + } else if (Long.class.equals(method.getReturnType()) || Long.TYPE.equals(method.getReturnType())) { + result = (long) rowCount; + } else if (Boolean.class.equals(method.getReturnType()) || Boolean.TYPE.equals(method.getReturnType())) { + result = rowCount > 0; + } else { + throw new BindingException("Mapper method '" + command.getName() + "' has an unsupported return type: " + method.getReturnType()); + } + return result; + } + + private void executeWithResultHandler(SqlSession sqlSession, Object[] args) { + MappedStatement ms = sqlSession.getConfiguration().getMappedStatement(command.getName()); + if (!StatementType.CALLABLE.equals(ms.getStatementType()) + && void.class.equals(ms.getResultMaps().get(0).getType())) { + throw new BindingException("method " + command.getName() + + " needs either a @ResultMap annotation, a @ResultType annotation," + + " or a resultType attribute in XML so a ResultHandler can be used as a parameter."); + } + Object param = method.convertArgsToSqlCommandParam(args); + if (method.hasRowBounds()) { + RowBounds rowBounds = method.extractRowBounds(args); + sqlSession.select(command.getName(), param, rowBounds, method.extractResultHandler(args)); + } else { + sqlSession.select(command.getName(), param, method.extractResultHandler(args)); + } + } + + private Object executeForMany(SqlSession sqlSession, Object[] args) { + List result; + Object param = method.convertArgsToSqlCommandParam(args); + if (method.hasRowBounds()) { + RowBounds rowBounds = method.extractRowBounds(args); + result = sqlSession.selectList(command.getName(), param, rowBounds); + } else { + result = sqlSession.selectList(command.getName(), param); + } + // issue #510 Collections & arrays support + if (!method.getReturnType().isAssignableFrom(result.getClass())) { + if (method.getReturnType().isArray()) { + return convertToArray(result); + } else { + return convertToDeclaredCollection(sqlSession.getConfiguration(), result); + } + } + return result; + } + + private Cursor executeForCursor(SqlSession sqlSession, Object[] args) { + Cursor result; + Object param = method.convertArgsToSqlCommandParam(args); + if (method.hasRowBounds()) { + RowBounds rowBounds = method.extractRowBounds(args); + result = sqlSession.selectCursor(command.getName(), param, rowBounds); + } else { + result = sqlSession.selectCursor(command.getName(), param); + } + return result; + } + + private Object convertToDeclaredCollection(Configuration config, List list) { + Object collection = config.getObjectFactory().create(method.getReturnType()); + MetaObject metaObject = config.newMetaObject(collection); + metaObject.addAll(list); + return collection; + } + + @SuppressWarnings("unchecked") + private Object convertToArray(List list) { + Class arrayComponentType = method.getReturnType().getComponentType(); + Object array = Array.newInstance(arrayComponentType, list.size()); + if (arrayComponentType.isPrimitive()) { + for (int i = 0; i < list.size(); i++) { + Array.set(array, i, list.get(i)); + } + return array; + } else { + return list.toArray((E[]) array); + } + } + + private Map executeForMap(SqlSession sqlSession, Object[] args) { + Map result; + Object param = method.convertArgsToSqlCommandParam(args); + if (method.hasRowBounds()) { + RowBounds rowBounds = method.extractRowBounds(args); + result = sqlSession.selectMap(command.getName(), param, method.getMapKey(), rowBounds); + } else { + result = sqlSession.selectMap(command.getName(), param, method.getMapKey()); + } + return result; + } + + public static class SqlCommand { + + private final String name; + private final SqlCommandType type; + + public SqlCommand(Configuration configuration, Class mapperInterface, Method method) { + final String methodName = method.getName(); + final Class declaringClass = method.getDeclaringClass(); + MappedStatement ms = resolveMappedStatement(mapperInterface, methodName, declaringClass, + configuration); + if (ms == null) { + if (method.getAnnotation(Flush.class) != null) { + name = null; + type = SqlCommandType.FLUSH; + } else { + throw new BindingException("Invalid bound statement (not found): " + + mapperInterface.getName() + "." + methodName); + } + } else { + name = ms.getId(); + type = ms.getSqlCommandType(); + if (type == SqlCommandType.UNKNOWN) { + throw new BindingException("Unknown execution method for: " + name); + } + } + } + + public String getName() { + return name; + } + + public SqlCommandType getType() { + return type; + } + + private MappedStatement resolveMappedStatement(Class mapperInterface, String methodName, + Class declaringClass, Configuration configuration) { + String statementId = mapperInterface.getName() + "." + methodName; + // 新增逻辑,没找到注入的statement则先注入---------------------------------------------------------------------------------------------------------- + if(!configuration.hasStatement(statementId)) { + String resource = mapperInterface.getName().replace('.', '/') + ".java (best guess)"; + MapperBuilderAssistant assistant = new MapperBuilderAssistant(configuration, resource); + assistant.setCurrentNamespace(mapperInterface.getName()); + Class modelClass = extractModelClass(mapperInterface); + TableInfo tableInfo = TableInfoHelper.initTableInfo(assistant, modelClass); + MethodFactory.getInstance(methodName).inject(assistant,mapperInterface, modelClass,tableInfo); + } + // ----------------------------------------------------------------------------------------------------------------------------------------------- + if (configuration.hasStatement(statementId)) { + return configuration.getMappedStatement(statementId); + } else if (mapperInterface.equals(declaringClass)) { + return null; + } + for (Class superInterface : mapperInterface.getInterfaces()) { + if (declaringClass.isAssignableFrom(superInterface)) { + MappedStatement ms = resolveMappedStatement(superInterface, methodName, + declaringClass, configuration); + if (ms != null) { + return ms; + } + } + } + return null; + } + + /** + * 提取泛型模型,多泛型的时候请将泛型T放在第一位 + * + * @param mapperClass mapper 接口 + * @return mapper 泛型 + */ + protected Class extractModelClass(Class mapperClass) { + Type[] types = mapperClass.getGenericInterfaces(); + ParameterizedType target = null; + for (Type type : types) { + if (type instanceof ParameterizedType) { + Type[] typeArray = ((ParameterizedType) type).getActualTypeArguments(); + if (ArrayUtils.isNotEmpty(typeArray)) { + for (Type t : typeArray) { + if (t instanceof TypeVariable || t instanceof WildcardType) { + break; + } else { + target = (ParameterizedType) type; + break; + } + } + } + break; + } + } + return target == null ? null : (Class) target.getActualTypeArguments()[0]; + } + } + + public static class MethodSignature { + + private final boolean returnsMany; + private final boolean returnsMap; + private final boolean returnsVoid; + private final boolean returnsCursor; + private final boolean returnsOptional; + private final Class returnType; + private final String mapKey; + private final Integer resultHandlerIndex; + private final Integer rowBoundsIndex; + private final ParamNameResolver paramNameResolver; + + public MethodSignature(Configuration configuration, Class mapperInterface, Method method) { + Type resolvedReturnType = TypeParameterResolver.resolveReturnType(method, mapperInterface); + if (resolvedReturnType instanceof Class) { + this.returnType = (Class) resolvedReturnType; + } else if (resolvedReturnType instanceof ParameterizedType) { + this.returnType = (Class) ((ParameterizedType) resolvedReturnType).getRawType(); + } else { + this.returnType = method.getReturnType(); + } + this.returnsVoid = void.class.equals(this.returnType); + this.returnsMany = configuration.getObjectFactory().isCollection(this.returnType) || this.returnType.isArray(); + this.returnsCursor = Cursor.class.equals(this.returnType); + this.returnsOptional = Optional.class.equals(this.returnType); + this.mapKey = getMapKey(method); + this.returnsMap = this.mapKey != null; + this.rowBoundsIndex = getUniqueParamIndex(method, RowBounds.class); + this.resultHandlerIndex = getUniqueParamIndex(method, ResultHandler.class); + this.paramNameResolver = new ParamNameResolver(configuration, method); + } + + public Object convertArgsToSqlCommandParam(Object[] args) { + return paramNameResolver.getNamedParams(args); + } + + public boolean hasRowBounds() { + return rowBoundsIndex != null; + } + + public RowBounds extractRowBounds(Object[] args) { + return hasRowBounds() ? (RowBounds) args[rowBoundsIndex] : null; + } + + public boolean hasResultHandler() { + return resultHandlerIndex != null; + } + + public ResultHandler extractResultHandler(Object[] args) { + return hasResultHandler() ? (ResultHandler) args[resultHandlerIndex] : null; + } + + public String getMapKey() { + return mapKey; + } + + public Class getReturnType() { + return returnType; + } + + public boolean returnsMany() { + return returnsMany; + } + + public boolean returnsMap() { + return returnsMap; + } + + public boolean returnsVoid() { + return returnsVoid; + } + + public boolean returnsCursor() { + return returnsCursor; + } + + /** + * return whether return type is {@code java.util.Optional} + * + * @return return {@code true}, if return type is {@code java.util.Optional} + * @since 3.5.0 + */ + public boolean returnsOptional() { + return returnsOptional; + } + + private Integer getUniqueParamIndex(Method method, Class paramType) { + Integer index = null; + final Class[] argTypes = method.getParameterTypes(); + for (int i = 0; i < argTypes.length; i++) { + if (paramType.isAssignableFrom(argTypes[i])) { + if (index == null) { + index = i; + } else { + throw new BindingException(method.getName() + " cannot have multiple " + paramType.getSimpleName() + " parameters"); + } + } + } + return index; + } + + private String getMapKey(Method method) { + String mapKey = null; + if (Map.class.isAssignableFrom(method.getReturnType())) { + final MapKey mapKeyAnnotation = method.getAnnotation(MapKey.class); + if (mapKeyAnnotation != null) { + mapKey = mapKeyAnnotation.value(); + } + } + return mapKey; + } + } +} diff --git a/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperProxy.java b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperProxy.java new file mode 100644 index 00000000..61075f40 --- /dev/null +++ b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperProxy.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2011-2020, hubin (jobob@qq.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.foreverwin.mesnac.console.mybatis.override; + +import org.apache.ibatis.reflection.ExceptionUtil; +import org.apache.ibatis.session.SqlSession; + +import java.io.Serializable; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Map; + +/** + * 替换掉引用 + *

重写类: org.apache.ibatis.binding.MapperProxy

+ * + * @author miemie + * @since 2018-06-09 + */ +public class ExtMybatisMapperProxy implements InvocationHandler, Serializable { + + private static final long serialVersionUID = -6424540398559729838L; + private final SqlSession sqlSession; + private final Class mapperInterface; + private final Map methodCache; + + public ExtMybatisMapperProxy(SqlSession sqlSession, Class mapperInterface, Map methodCache) { + this.sqlSession = sqlSession; + this.mapperInterface = mapperInterface; + this.methodCache = methodCache; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + try { + if (Object.class.equals(method.getDeclaringClass())) { + return method.invoke(this, args); + } else if (isDefaultMethod(method)) { + return invokeDefaultMethod(proxy, method, args); + } + } catch (Throwable t) { + throw ExceptionUtil.unwrapThrowable(t); + } + final ExtMybatisMapperMethod mapperMethod = cachedMapperMethod(method); + return mapperMethod.execute(sqlSession, args); + } + + private ExtMybatisMapperMethod cachedMapperMethod(Method method) { + return methodCache.computeIfAbsent(method, k -> new ExtMybatisMapperMethod(mapperInterface, method, sqlSession.getConfiguration())); + } + + private Object invokeDefaultMethod(Object proxy, Method method, Object[] args) + throws Throwable { + final Constructor constructor = MethodHandles.Lookup.class + .getDeclaredConstructor(Class.class, int.class); + if (!constructor.isAccessible()) { + constructor.setAccessible(true); + } + final Class declaringClass = method.getDeclaringClass(); + return constructor + .newInstance(declaringClass, + MethodHandles.Lookup.PRIVATE | MethodHandles.Lookup.PROTECTED + | MethodHandles.Lookup.PACKAGE | MethodHandles.Lookup.PUBLIC) + .unreflectSpecial(method, declaringClass).bindTo(proxy).invokeWithArguments(args); + } + + /** + * Backport of java.lang.reflect.Method#isDefault() + */ + private boolean isDefaultMethod(Method method) { + return (method.getModifiers() + & (Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC)) == Modifier.PUBLIC + && method.getDeclaringClass().isInterface(); + } +} diff --git a/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperProxyFactory.java b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperProxyFactory.java new file mode 100644 index 00000000..f0e2a586 --- /dev/null +++ b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/ExtMybatisMapperProxyFactory.java @@ -0,0 +1,43 @@ +package com.foreverwin.mesnac.console.mybatis.override; + +import com.baomidou.mybatisplus.core.override.MybatisMapperMethod; +import org.apache.ibatis.session.SqlSession; + +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * + * @description: + * @author: syngna + * @create: 2021-04-16 17:34 + */ +public class ExtMybatisMapperProxyFactory { + + private final Class mapperInterface; + + private final Map methodCache = new ConcurrentHashMap<>(); + + public ExtMybatisMapperProxyFactory(Class mapperInterface) { + this.mapperInterface = mapperInterface; + } + + public Class getMapperInterface() { + return mapperInterface; + } + + public Map getMethodCache() { + return methodCache; + } + + protected T newInstance(ExtMybatisMapperProxy mapperProxy) { + return (T) Proxy.newProxyInstance(mapperInterface.getClassLoader(), new Class[]{mapperInterface}, mapperProxy); + } + + public T newInstance(SqlSession sqlSession) { + final ExtMybatisMapperProxy mapperProxy = new ExtMybatisMapperProxy(sqlSession, mapperInterface, methodCache); + return newInstance(mapperProxy); + } +} \ No newline at end of file diff --git a/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/MethodFactory.java b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/MethodFactory.java new file mode 100644 index 00000000..179769bd --- /dev/null +++ b/console/src/main/java/com/foreverwin/mesnac/console/mybatis/override/MethodFactory.java @@ -0,0 +1,53 @@ +package com.foreverwin.mesnac.console.mybatis.override; + +import com.baomidou.mybatisplus.core.injector.AbstractMethod; +import com.baomidou.mybatisplus.core.injector.methods.Insert; +import com.baomidou.mybatisplus.extension.injector.methods.*; + +/** + * + * @description: + * @author: syngna + * @create: 2021-04-18 17:14 + */ +public class MethodFactory { + + public static AbstractMethod getInstance(String methodName) { + if("insert".equals(methodName)) { + return new Insert(); + } else if("delete".equals(methodName)) { + return new LogicDelete(); + } else if("deleteByMap".equals(methodName)) { + return new LogicDeleteByMap(); + } else if("deleteById".equals(methodName)) { + return new LogicDeleteById(); + } else if("deleteBatchByIds".equals(methodName)) { + return new LogicDeleteBatchByIds(); + } else if("update".equals(methodName)) { + return new LogicUpdate(); + } else if("updateById".equals(methodName)) { + return new LogicUpdateById(); + } else if("selectById".equals(methodName)) { + return new LogicSelectById(); + } else if("selectBatchByIds".equals(methodName)) { + return new LogicSelectBatchByIds(); + } else if("selectByMap".equals(methodName)) { + return new LogicSelectByMap(); + } else if("selectOne".equals(methodName)) { + return new LogicSelectOne(); + } else if("selectCount".equals(methodName)) { + return new LogicSelectCount(); + } else if("selectMaps".equals(methodName)) { + return new LogicSelectMaps(); + } else if("selectMapsPage".equals(methodName)) { + return new LogicSelectMapsPage(); + } else if("selectObjs".equals(methodName)) { + return new LogicSelectObjs(); + } else if("selectList".equals(methodName)) { + return new LogicSelectList(); + } else if("selectPage".equals(methodName)) { + return new LogicSelectPage(); + } + return null; + } +} \ No newline at end of file diff --git a/console/src/main/resources/application.yml b/console/src/main/resources/application.yml index 0df95698..43014bd5 100644 --- a/console/src/main/resources/application.yml +++ b/console/src/main/resources/application.yml @@ -54,6 +54,7 @@ mybatis-plus: typeAliasesPackage: com.foreverwin.**.model # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath*:mapper/**/*Mapper.xml + statement-lazy-load: false #dialectClass: com.foreverwin.modular.core.mybatisplus.plugins.pagination.dialects.HanaDialect # 加载全局的配置文件 # configuration: diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SfcDispatchController.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SfcDispatchController.java index 4e65163d..d19f6da2 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SfcDispatchController.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SfcDispatchController.java @@ -1,5 +1,6 @@ package com.foreverwin.mesnac.dispatch.controller; +import com.foreverwin.mesnac.dispatch.model.ShopOrderRelease; import com.foreverwin.modular.core.util.R; import com.foreverwin.modular.core.util.FrontPage; import com.foreverwin.modular.core.util.CommonMethods; @@ -26,15 +27,31 @@ public class SfcDispatchController { public SfcDispatchService sfcDispatchService; + @ResponseBody + @GetMapping("getSfcDispatch") + public R getSfcDispatch() { + List list; + try { + ShopOrderRelease shopOrderRelease = new ShopOrderRelease(); + shopOrderRelease.setSite(CommonMethods.getSite()); + + list = sfcDispatchService.findSfcDispatchList(shopOrderRelease); + } catch (Exception e) { + return R.failed(e.getMessage()); + } + + return R.ok(list); + } + @ResponseBody @PostMapping("querySfcDispatch") - public R querySfcDispatch(@RequestBody SfcDispatch sfcDispatch) { - List list = null; + public R querySfcDispatch(@RequestBody ShopOrderRelease shopOrderRelease) { + List list; try { - sfcDispatch.setSite(CommonMethods.getSite()); + shopOrderRelease.setSite(CommonMethods.getSite()); - list = sfcDispatchService.selectList(sfcDispatch); + list = sfcDispatchService.findSfcDispatchList(shopOrderRelease); } catch (Exception e) { return R.failed(e.getMessage()); } @@ -91,8 +108,8 @@ public class SfcDispatchController { .or().like(SfcDispatch::getWorkCenter, frontPage.getGlobalQuery()) .or().like(SfcDispatch::getResrce, frontPage.getGlobalQuery()) .or().like(SfcDispatch::getEmployee, frontPage.getGlobalQuery()) - .or().like(SfcDispatch::getTurnOrder, frontPage.getGlobalQuery()) - .or().like(SfcDispatch::getIsAllot, frontPage.getGlobalQuery()) + .or().like(SfcDispatch::getTurnOperation, frontPage.getGlobalQuery()) + .or().like(SfcDispatch::getIsDispatch, frontPage.getGlobalQuery()) .or().like(SfcDispatch::getIsImport, frontPage.getGlobalQuery()) .or().like(SfcDispatch::getRemark, frontPage.getGlobalQuery()) .or().like(SfcDispatch::getCreateUser, frontPage.getGlobalQuery()) diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/mapper/SfcDispatchMapper.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/mapper/SfcDispatchMapper.java index a6ec0e1c..bb18d8bd 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/mapper/SfcDispatchMapper.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/mapper/SfcDispatchMapper.java @@ -2,6 +2,7 @@ package com.foreverwin.mesnac.dispatch.mapper; import com.foreverwin.mesnac.dispatch.model.SfcDispatch; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.foreverwin.mesnac.dispatch.model.ShopOrderRelease; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -19,4 +20,6 @@ import java.util.List; public interface SfcDispatchMapper extends BaseMapper { List findSfcDispatch(@Param("site") String site, @Param("sfc") String sfc, @Param("operation") String operation, @Param("stepId") String stepId); + + List findSfcDispatchList(ShopOrderRelease shopOrderRelease); } \ No newline at end of file diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/SfcDispatch.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/SfcDispatch.java index 2ad287f9..dbaac69a 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/SfcDispatch.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/SfcDispatch.java @@ -16,10 +16,11 @@ import com.baomidou.mybatisplus.annotation.IdType; *

* * @author Leon.L - * @since 2021-06-02 + * @since 2021-06-04 */ @TableName("Z_SFC_DISPATCH") + public class SfcDispatch extends Model { private static final long serialVersionUID = 1L; @@ -58,7 +59,7 @@ public class SfcDispatch extends Model { * 派工序号 */ @TableField("DISPATCH_SEQ") - private Double dispatchSeq; + private String dispatchSeq; /** * 派工单号 */ @@ -122,8 +123,8 @@ public class SfcDispatch extends Model { /** * 是否已经转序 */ - @TableField("TURN_ORDER") - private String turnOrder; + @TableField("TURN_OPERATION") + private String turnOperation; /** * 派工数量 */ @@ -169,6 +170,11 @@ public class SfcDispatch extends Model { */ @TableField("RELEASED_COMPLETE_DATE") private LocalDateTime releasedCompleteDate; + /** + * 实际开始时间 + */ + @TableField("ACTUAL_START_DATE") + private LocalDateTime actualStartDate; /** * 实际完成时间 */ @@ -177,8 +183,8 @@ public class SfcDispatch extends Model { /** * 是否已经分配资源 */ - @TableField("IS_ALLOT") - private String isAllot; + @TableField("IS_DISPATCH") + private String isDispatch; /** * 是否导入 */ @@ -189,9 +195,9 @@ public class SfcDispatch extends Model { */ @TableField("REMARK") private String remark; - /** - * 备注 - */ + /** + * 是否首工序 + */ @TableField("IS_FIRST_OPERATION") private String isFirstOperation; /** @@ -274,11 +280,11 @@ public class SfcDispatch extends Model { this.isMajor = isMajor; } - public Double getDispatchSeq() { + public String getDispatchSeq() { return dispatchSeq; } - public void setDispatchSeq(Double dispatchSeq) { + public void setDispatchSeq(String dispatchSeq) { this.dispatchSeq = dispatchSeq; } @@ -378,12 +384,12 @@ public class SfcDispatch extends Model { this.employee = employee; } - public String getTurnOrder() { - return turnOrder; + public String getTurnOperation() { + return turnOperation; } - public void setTurnOrder(String turnOrder) { - this.turnOrder = turnOrder; + public void setTurnOperation(String turnOperation) { + this.turnOperation = turnOperation; } public Double getDispatchQty() { @@ -458,6 +464,14 @@ public class SfcDispatch extends Model { this.releasedCompleteDate = releasedCompleteDate; } + public LocalDateTime getActualStartDate() { + return actualStartDate; + } + + public void setActualStartDate(LocalDateTime actualStartDate) { + this.actualStartDate = actualStartDate; + } + public LocalDateTime getActualCompleteDate() { return actualCompleteDate; } @@ -466,12 +480,12 @@ public class SfcDispatch extends Model { this.actualCompleteDate = actualCompleteDate; } - public String getIsAllot() { - return isAllot; + public String getIsDispatch() { + return isDispatch; } - public void setIsAllot(String isAllot) { - this.isAllot = isAllot; + public void setIsDispatch(String isDispatch) { + this.isDispatch = isDispatch; } public String getIsImport() { @@ -570,89 +584,93 @@ public class SfcDispatch extends Model { this.other5 = other5; } -public static final String HANDLE = "HANDLE"; + public static final String HANDLE = "HANDLE"; + + public static final String SITE = "SITE"; + + public static final String SHOP_ORDER = "SHOP_ORDER"; -public static final String SITE = "SITE"; + public static final String WORK_ORDER = "WORK_ORDER"; -public static final String SHOP_ORDER = "SHOP_ORDER"; + public static final String SFC = "SFC"; -public static final String WORK_ORDER = "WORK_ORDER"; + public static final String IS_MAJOR = "IS_MAJOR"; -public static final String SFC = "SFC"; + public static final String DISPATCH_SEQ = "DISPATCH_SEQ"; -public static final String IS_MAJOR = "IS_MAJOR"; + public static final String DISPATCH_NO = "DISPATCH_NO"; -public static final String DISPATCH_SEQ = "DISPATCH_SEQ"; + public static final String DISPATCH_STATUS = "DISPATCH_STATUS"; -public static final String DISPATCH_NO = "DISPATCH_NO"; + public static final String DRAWINGS_NO = "DRAWINGS_NO"; -public static final String DISPATCH_STATUS = "DISPATCH_STATUS"; + public static final String DRAWINGS_REVISION = "DRAWINGS_REVISION"; -public static final String DRAWINGS_NO = "DRAWINGS_NO"; + public static final String IS_LOCK = "IS_LOCK"; -public static final String DRAWINGS_REVISION = "DRAWINGS_REVISION"; + public static final String ROUTER_BO = "ROUTER_BO"; -public static final String IS_LOCK = "IS_LOCK"; + public static final String STEP_ID = "STEP_ID"; -public static final String ROUTER_BO = "ROUTER_BO"; + public static final String OPERATION = "OPERATION"; -public static final String STEP_ID = "STEP_ID"; + public static final String RESOURCE_TYPE = "RESOURCE_TYPE"; -public static final String OPERATION = "OPERATION"; + public static final String WORK_CENTER = "WORK_CENTER"; -public static final String RESOURCE_TYPE = "RESOURCE_TYPE"; + public static final String RESRCE = "RESRCE"; -public static final String WORK_CENTER = "WORK_CENTER"; + public static final String EMPLOYEE = "EMPLOYEE"; -public static final String RESRCE = "RESRCE"; + public static final String TURN_OPERATION = "TURN_OPERATION"; -public static final String EMPLOYEE = "EMPLOYEE"; + public static final String DISPATCH_QTY = "DISPATCH_QTY"; -public static final String TURN_ORDER = "TURN_ORDER"; + public static final String PROD_HOURS = "PROD_HOURS"; -public static final String DISPATCH_QTY = "DISPATCH_QTY"; + public static final String PLANNED_START_DATE = "PLANNED_START_DATE"; -public static final String PROD_HOURS = "PROD_HOURS"; + public static final String PLANNED_COMPLETE_DATE = "PLANNED_COMPLETE_DATE"; -public static final String PLANNED_START_DATE = "PLANNED_START_DATE"; + public static final String EARLIEST_START_DATE = "EARLIEST_START_DATE"; -public static final String PLANNED_COMPLETE_DATE = "PLANNED_COMPLETE_DATE"; + public static final String LATEST_END_DATE = "LATEST_END_DATE"; -public static final String EARLIEST_START_DATE = "EARLIEST_START_DATE"; + public static final String SO_RELEASED_DATE = "SO_RELEASED_DATE"; -public static final String LATEST_END_DATE = "LATEST_END_DATE"; + public static final String SFC_RELEASED_DATE = "SFC_RELEASED_DATE"; -public static final String SO_RELEASED_DATE = "SO_RELEASED_DATE"; + public static final String RELEASED_COMPLETE_DATE = "RELEASED_COMPLETE_DATE"; -public static final String SFC_RELEASED_DATE = "SFC_RELEASED_DATE"; + public static final String ACTUAL_START_DATE = "ACTUAL_START_DATE"; -public static final String RELEASED_COMPLETE_DATE = "RELEASED_COMPLETE_DATE"; + public static final String ACTUAL_COMPLETE_DATE = "ACTUAL_COMPLETE_DATE"; -public static final String ACTUAL_COMPLETE_DATE = "ACTUAL_COMPLETE_DATE"; + public static final String IS_DISPATCH = "IS_DISPATCH"; -public static final String IS_ALLOT = "IS_ALLOT"; + public static final String IS_IMPORT = "IS_IMPORT"; -public static final String IS_IMPORT = "IS_IMPORT"; + public static final String REMARK = "REMARK"; -public static final String REMARK = "REMARK"; + public static final String IS_FIRST_OPERATION = "IS_FIRST_OPERATION"; -public static final String CREATE_USER = "CREATE_USER"; + public static final String CREATE_USER = "CREATE_USER"; -public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME"; + public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME"; -public static final String MODIFY_USER = "MODIFY_USER"; + public static final String MODIFY_USER = "MODIFY_USER"; -public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME"; + public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME"; -public static final String OTHER_1 = "OTHER_1"; + public static final String OTHER_1 = "OTHER_1"; -public static final String OTHER_2 = "OTHER_2"; + public static final String OTHER_2 = "OTHER_2"; -public static final String OTHER_3 = "OTHER_3"; + public static final String OTHER_3 = "OTHER_3"; -public static final String OTHER_4 = "OTHER_4"; + public static final String OTHER_4 = "OTHER_4"; -public static final String OTHER_5 = "OTHER_5"; + public static final String OTHER_5 = "OTHER_5"; @Override @@ -682,7 +700,7 @@ public static final String OTHER_5 = "OTHER_5"; ", workCenter = " + workCenter + ", resrce = " + resrce + ", employee = " + employee + - ", turnOrder = " + turnOrder + + ", turnOperation = " + turnOperation + ", dispatchQty = " + dispatchQty + ", prodHours = " + prodHours + ", plannedStartDate = " + plannedStartDate + @@ -692,10 +710,12 @@ public static final String OTHER_5 = "OTHER_5"; ", soReleasedDate = " + soReleasedDate + ", sfcReleasedDate = " + sfcReleasedDate + ", releasedCompleteDate = " + releasedCompleteDate + + ", actualStartDate = " + actualStartDate + ", actualCompleteDate = " + actualCompleteDate + - ", isAllot = " + isAllot + + ", isDispatch = " + isDispatch + ", isImport = " + isImport + ", remark = " + remark + + ", isFirstOperation = " + isFirstOperation + ", createUser = " + createUser + ", createdDateTime = " + createdDateTime + ", modifyUser = " + modifyUser + diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/ShopOrderRelease.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/ShopOrderRelease.java index 47705bc9..bb3b65b9 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/ShopOrderRelease.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/ShopOrderRelease.java @@ -31,6 +31,9 @@ public class ShopOrderRelease extends SfcDispatch { private String category; private String status; private String comments; + private String component; + private String componentDescription; + private String isCompleted; private LocalDateTime plannedStartDate; private LocalDateTime plannedCompDate; @@ -136,6 +139,30 @@ public class ShopOrderRelease extends SfcDispatch { this.dispatchCompleteDate = dispatchCompleteDate; } + public String getComponent() { + return component; + } + + public void setComponent(String component) { + this.component = component; + } + + public String getComponentDescription() { + return componentDescription; + } + + public void setComponentDescription(String componentDescription) { + this.componentDescription = componentDescription; + } + + public String getIsCompleted() { + return isCompleted; + } + + public void setIsCompleted(String isCompleted) { + this.isCompleted = isCompleted; + } + public Date getStartFromDate() { return startFromDate; } diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/SfcDispatchService.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/SfcDispatchService.java index 57de6579..351d8739 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/SfcDispatchService.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/SfcDispatchService.java @@ -3,6 +3,7 @@ package com.foreverwin.mesnac.dispatch.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.foreverwin.mesnac.dispatch.model.SfcDispatch; import com.baomidou.mybatisplus.extension.service.IService; +import com.foreverwin.mesnac.dispatch.model.ShopOrderRelease; import com.foreverwin.modular.core.util.FrontPage; import java.util.List; @@ -36,4 +37,12 @@ public interface SfcDispatchService extends IService { * @return */ List findSfcDispatch(String site, String sfc, String operation, String stepId); + + /** + * 查询派工清单 + * + * @param shopOrderRelease + * @return + */ + List findSfcDispatchList(ShopOrderRelease shopOrderRelease); } \ No newline at end of file diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SfcDispatchServiceImpl.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SfcDispatchServiceImpl.java index 5a708760..19992e15 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SfcDispatchServiceImpl.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SfcDispatchServiceImpl.java @@ -1,5 +1,6 @@ package com.foreverwin.mesnac.dispatch.service.impl; +import com.foreverwin.mesnac.dispatch.model.ShopOrderRelease; import com.foreverwin.modular.core.util.FrontPage; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -47,5 +48,10 @@ public class SfcDispatchServiceImpl extends ServiceImpl findSfcDispatchList(ShopOrderRelease shopOrderRelease) { + return sfcDispatchMapper.findSfcDispatchList(shopOrderRelease); + } + } \ No newline at end of file diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/ShopOrderReleaseServiceImpl.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/ShopOrderReleaseServiceImpl.java index 325d8a52..0b5ff244 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/ShopOrderReleaseServiceImpl.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/ShopOrderReleaseServiceImpl.java @@ -227,7 +227,7 @@ public class ShopOrderReleaseServiceImpl implements ShopOrderReleaseService { sfcDispatchModel.setSfc(sfc); sfcDispatchModel.setWorkOrder(""); sfcDispatchModel.setIsMajor(""); - sfcDispatchModel.setDispatchSeq(new Double(m+1)); + sfcDispatchModel.setDispatchSeq((m + 1)+""); sfcDispatchModel.setDispatchNo(dispatchNo); sfcDispatchModel.setDispatchStatus(Constants.STATUS_NEW); sfcDispatchModel.setDrawingsNo(""); @@ -243,7 +243,7 @@ public class ShopOrderReleaseServiceImpl implements ShopOrderReleaseService { //sfcDispatchModel.setPlannedStartDate(plannedStartDate); //sfcDispatchModel.setPlannedCompleteDate(plannedCompleteDate); sfcDispatchModel.setSoReleasedDate(nowDate); - sfcDispatchModel.setIsAllot(Constants.BOOL_FALSE); + sfcDispatchModel.setIsDispatch(Constants.BOOL_FALSE); sfcDispatchModel.setIsImport(Constants.BOOL_FALSE); sfcDispatchModel.setIsFirstOperation(isFirstOperation); sfcDispatchModel.setCreateUser(user); @@ -410,7 +410,7 @@ public class ShopOrderReleaseServiceImpl implements ShopOrderReleaseService { sfcDispatchModel.setSfc(sfc); sfcDispatchModel.setWorkOrder(""); sfcDispatchModel.setIsMajor(""); - sfcDispatchModel.setDispatchSeq(new Double(m + 1)); + sfcDispatchModel.setDispatchSeq((m + 1)+""); sfcDispatchModel.setDispatchNo(dispatchNo); sfcDispatchModel.setDispatchStatus(Constants.STATUS_NEW); sfcDispatchModel.setDrawingsNo(""); @@ -426,7 +426,7 @@ public class ShopOrderReleaseServiceImpl implements ShopOrderReleaseService { //sfcDispatchModel.setPlannedStartDate(plannedStartDate); //sfcDispatchModel.setPlannedCompleteDate(plannedCompleteDate); sfcDispatchModel.setSoReleasedDate(nowDate); - sfcDispatchModel.setIsAllot(Constants.BOOL_FALSE); + sfcDispatchModel.setIsDispatch(Constants.BOOL_FALSE); sfcDispatchModel.setIsImport(Constants.BOOL_FALSE); sfcDispatchModel.setCreateUser(user); sfcDispatchModel.setCreatedDateTime(nowDate); @@ -436,7 +436,7 @@ public class ShopOrderReleaseServiceImpl implements ShopOrderReleaseService { } else { //已经存在的更新 SfcDispatch sfcDispatchModel = list.get(0); - sfcDispatchModel.setDispatchSeq(new Double(m + 1)); + sfcDispatchModel.setDispatchSeq((m + 1)+""); sfcDispatchModel.setModifyUser(user); sfcDispatchModel.setModifiedDateTime(nowDate); updateSfcDispatchList.add(sfcDispatchModel); diff --git a/dispatch/src/main/resources/mapper/SfcDispatchMapper.xml b/dispatch/src/main/resources/mapper/SfcDispatchMapper.xml index bbed1921..c631f005 100644 --- a/dispatch/src/main/resources/mapper/SfcDispatchMapper.xml +++ b/dispatch/src/main/resources/mapper/SfcDispatchMapper.xml @@ -23,7 +23,7 @@ - + @@ -33,8 +33,9 @@ + - + @@ -49,9 +50,17 @@ + + + + + + + + - HANDLE, SITE, SHOP_ORDER, WORK_ORDER, SFC, IS_MAJOR, DISPATCH_SEQ, DISPATCH_NO, DISPATCH_STATUS, DRAWINGS_NO, DRAWINGS_REVISION, IS_LOCK, ROUTER_BO, STEP_ID, OPERATION, RESOURCE_TYPE, WORK_CENTER, RESRCE, EMPLOYEE, TURN_ORDER, DISPATCH_QTY, PROD_HOURS, PLANNED_START_DATE, PLANNED_COMPLETE_DATE, EARLIEST_START_DATE, LATEST_END_DATE, SO_RELEASED_DATE, SFC_RELEASED_DATE, RELEASED_COMPLETE_DATE, ACTUAL_COMPLETE_DATE, IS_ALLOT, IS_IMPORT, REMARK, IS_FIRST_OPERATION, CREATE_USER, CREATED_DATE_TIME, MODIFY_USER, MODIFIED_DATE_TIME, OTHER_1, OTHER_2, OTHER_3, OTHER_4, OTHER_5 + HANDLE, SITE, SHOP_ORDER, WORK_ORDER, SFC, IS_MAJOR, DISPATCH_SEQ, DISPATCH_NO, DISPATCH_STATUS, DRAWINGS_NO, DRAWINGS_REVISION, IS_LOCK, ROUTER_BO, STEP_ID, OPERATION, RESOURCE_TYPE, WORK_CENTER, RESRCE, EMPLOYEE, TURN_OPERATION, DISPATCH_QTY, PROD_HOURS, PLANNED_START_DATE, PLANNED_COMPLETE_DATE, EARLIEST_START_DATE, LATEST_END_DATE, SO_RELEASED_DATE, SFC_RELEASED_DATE, RELEASED_COMPLETE_DATE, ACTUAL_START_DATE, ACTUAL_COMPLETE_DATE, IS_DISPATCH, IS_IMPORT, REMARK, IS_FIRST_OPERATION, CREATE_USER, CREATED_DATE_TIME, MODIFY_USER, MODIFIED_DATE_TIME, OTHER_1, OTHER_2, OTHER_3, OTHER_4, OTHER_5 @@ -104,7 +113,7 @@ AND WORK_CENTER=#{ew.entity.workCenter} AND RESRCE=#{ew.entity.resrce} AND EMPLOYEE=#{ew.entity.employee} - AND TURN_ORDER=#{ew.entity.turnOrder} + AND TURN_OPERATION=#{ew.entity.turnOperation} AND DISPATCH_QTY=#{ew.entity.dispatchQty} AND PROD_HOURS=#{ew.entity.prodHours} AND PLANNED_START_DATE=#{ew.entity.plannedStartDate} @@ -114,8 +123,9 @@ AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate} AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate} AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate} + AND ACTUAL_START_DATE=#{ew.entity.actualStartDate} AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate} - AND IS_ALLOT=#{ew.entity.isAllot} + AND IS_DISPATCH=#{ew.entity.isDispatch} AND IS_IMPORT=#{ew.entity.isImport} AND REMARK=#{ew.entity.remark} AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation} @@ -157,7 +167,7 @@ AND WORK_CENTER=#{ew.entity.workCenter} AND RESRCE=#{ew.entity.resrce} AND EMPLOYEE=#{ew.entity.employee} - AND TURN_ORDER=#{ew.entity.turnOrder} + AND TURN_OPERATION=#{ew.entity.turnOperation} AND DISPATCH_QTY=#{ew.entity.dispatchQty} AND PROD_HOURS=#{ew.entity.prodHours} AND PLANNED_START_DATE=#{ew.entity.plannedStartDate} @@ -167,8 +177,9 @@ AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate} AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate} AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate} + AND ACTUAL_START_DATE=#{ew.entity.actualStartDate} AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate} - AND IS_ALLOT=#{ew.entity.isAllot} + AND IS_DISPATCH=#{ew.entity.isDispatch} AND IS_IMPORT=#{ew.entity.isImport} AND REMARK=#{ew.entity.remark} AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation} @@ -218,7 +229,7 @@ AND WORK_CENTER=#{ew.entity.workCenter} AND RESRCE=#{ew.entity.resrce} AND EMPLOYEE=#{ew.entity.employee} - AND TURN_ORDER=#{ew.entity.turnOrder} + AND TURN_OPERATION=#{ew.entity.turnOperation} AND DISPATCH_QTY=#{ew.entity.dispatchQty} AND PROD_HOURS=#{ew.entity.prodHours} AND PLANNED_START_DATE=#{ew.entity.plannedStartDate} @@ -228,8 +239,9 @@ AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate} AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate} AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate} + AND ACTUAL_START_DATE=#{ew.entity.actualStartDate} AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate} - AND IS_ALLOT=#{ew.entity.isAllot} + AND IS_DISPATCH=#{ew.entity.isDispatch} AND IS_IMPORT=#{ew.entity.isImport} AND REMARK=#{ew.entity.remark} AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation} @@ -279,7 +291,7 @@ AND WORK_CENTER=#{ew.entity.workCenter} AND RESRCE=#{ew.entity.resrce} AND EMPLOYEE=#{ew.entity.employee} - AND TURN_ORDER=#{ew.entity.turnOrder} + AND TURN_OPERATION=#{ew.entity.turnOperation} AND DISPATCH_QTY=#{ew.entity.dispatchQty} AND PROD_HOURS=#{ew.entity.prodHours} AND PLANNED_START_DATE=#{ew.entity.plannedStartDate} @@ -289,8 +301,9 @@ AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate} AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate} AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate} + AND ACTUAL_START_DATE=#{ew.entity.actualStartDate} AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate} - AND IS_ALLOT=#{ew.entity.isAllot} + AND IS_DISPATCH=#{ew.entity.isDispatch} AND IS_IMPORT=#{ew.entity.isImport} AND REMARK=#{ew.entity.remark} AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation} @@ -340,7 +353,7 @@ AND WORK_CENTER=#{ew.entity.workCenter} AND RESRCE=#{ew.entity.resrce} AND EMPLOYEE=#{ew.entity.employee} - AND TURN_ORDER=#{ew.entity.turnOrder} + AND TURN_OPERATION=#{ew.entity.turnOperation} AND DISPATCH_QTY=#{ew.entity.dispatchQty} AND PROD_HOURS=#{ew.entity.prodHours} AND PLANNED_START_DATE=#{ew.entity.plannedStartDate} @@ -350,8 +363,9 @@ AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate} AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate} AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate} + AND ACTUAL_START_DATE=#{ew.entity.actualStartDate} AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate} - AND IS_ALLOT=#{ew.entity.isAllot} + AND IS_DISPATCH=#{ew.entity.isDispatch} AND IS_IMPORT=#{ew.entity.isImport} AND REMARK=#{ew.entity.remark} AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation} @@ -401,7 +415,7 @@ AND WORK_CENTER=#{ew.entity.workCenter} AND RESRCE=#{ew.entity.resrce} AND EMPLOYEE=#{ew.entity.employee} - AND TURN_ORDER=#{ew.entity.turnOrder} + AND TURN_OPERATION=#{ew.entity.turnOperation} AND DISPATCH_QTY=#{ew.entity.dispatchQty} AND PROD_HOURS=#{ew.entity.prodHours} AND PLANNED_START_DATE=#{ew.entity.plannedStartDate} @@ -411,8 +425,9 @@ AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate} AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate} AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate} + AND ACTUAL_START_DATE=#{ew.entity.actualStartDate} AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate} - AND IS_ALLOT=#{ew.entity.isAllot} + AND IS_DISPATCH=#{ew.entity.isDispatch} AND IS_IMPORT=#{ew.entity.isImport} AND REMARK=#{ew.entity.remark} AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation} @@ -462,7 +477,7 @@ AND WORK_CENTER=#{ew.entity.workCenter} AND RESRCE=#{ew.entity.resrce} AND EMPLOYEE=#{ew.entity.employee} - AND TURN_ORDER=#{ew.entity.turnOrder} + AND TURN_OPERATION=#{ew.entity.turnOperation} AND DISPATCH_QTY=#{ew.entity.dispatchQty} AND PROD_HOURS=#{ew.entity.prodHours} AND PLANNED_START_DATE=#{ew.entity.plannedStartDate} @@ -472,8 +487,9 @@ AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate} AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate} AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate} + AND ACTUAL_START_DATE=#{ew.entity.actualStartDate} AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate} - AND IS_ALLOT=#{ew.entity.isAllot} + AND IS_DISPATCH=#{ew.entity.isDispatch} AND IS_IMPORT=#{ew.entity.isImport} AND REMARK=#{ew.entity.remark} AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation} @@ -519,7 +535,7 @@ WORK_CENTER, RESRCE, EMPLOYEE, - TURN_ORDER, + TURN_OPERATION, DISPATCH_QTY, PROD_HOURS, PLANNED_START_DATE, @@ -529,8 +545,9 @@ SO_RELEASED_DATE, SFC_RELEASED_DATE, RELEASED_COMPLETE_DATE, + ACTUAL_START_DATE, ACTUAL_COMPLETE_DATE, - IS_ALLOT, + IS_DISPATCH, IS_IMPORT, REMARK, IS_FIRST_OPERATION, @@ -564,7 +581,7 @@ #{workCenter}, #{resrce}, #{employee}, - #{turnOrder}, + #{turnOperation}, #{dispatchQty}, #{prodHours}, #{plannedStartDate}, @@ -574,8 +591,9 @@ #{soReleasedDate}, #{sfcReleasedDate}, #{releasedCompleteDate}, + #{actualStartDate}, #{actualCompleteDate}, - #{isAllot}, + #{isDispatch}, #{isImport}, #{remark}, #{isFirstOperation}, @@ -616,7 +634,7 @@ #{workCenter}, #{resrce}, #{employee}, - #{turnOrder}, + #{turnOperation}, #{dispatchQty}, #{prodHours}, #{plannedStartDate}, @@ -626,8 +644,9 @@ #{soReleasedDate}, #{sfcReleasedDate}, #{releasedCompleteDate}, + #{actualStartDate}, #{actualCompleteDate}, - #{isAllot}, + #{isDispatch}, #{isImport}, #{remark}, #{isFirstOperation}, @@ -664,7 +683,7 @@ WORK_CENTER=#{et.workCenter}, RESRCE=#{et.resrce}, EMPLOYEE=#{et.employee}, - TURN_ORDER=#{et.turnOrder}, + TURN_OPERATION=#{et.turnOperation}, DISPATCH_QTY=#{et.dispatchQty}, PROD_HOURS=#{et.prodHours}, PLANNED_START_DATE=#{et.plannedStartDate}, @@ -674,8 +693,9 @@ SO_RELEASED_DATE=#{et.soReleasedDate}, SFC_RELEASED_DATE=#{et.sfcReleasedDate}, RELEASED_COMPLETE_DATE=#{et.releasedCompleteDate}, + ACTUAL_START_DATE=#{et.actualStartDate}, ACTUAL_COMPLETE_DATE=#{et.actualCompleteDate}, - IS_ALLOT=#{et.isAllot}, + IS_DISPATCH=#{et.isDispatch}, IS_IMPORT=#{et.isImport}, REMARK=#{et.remark}, IS_FIRST_OPERATION=#{et.isFirstOperation}, @@ -712,7 +732,7 @@ WORK_CENTER=#{et.workCenter}, RESRCE=#{et.resrce}, EMPLOYEE=#{et.employee}, - TURN_ORDER=#{et.turnOrder}, + TURN_OPERATION=#{et.turnOperation}, DISPATCH_QTY=#{et.dispatchQty}, PROD_HOURS=#{et.prodHours}, PLANNED_START_DATE=#{et.plannedStartDate}, @@ -722,8 +742,9 @@ SO_RELEASED_DATE=#{et.soReleasedDate}, SFC_RELEASED_DATE=#{et.sfcReleasedDate}, RELEASED_COMPLETE_DATE=#{et.releasedCompleteDate}, + ACTUAL_START_DATE=#{et.actualStartDate}, ACTUAL_COMPLETE_DATE=#{et.actualCompleteDate}, - IS_ALLOT=#{et.isAllot}, + IS_DISPATCH=#{et.isDispatch}, IS_IMPORT=#{et.isImport}, REMARK=#{et.remark}, IS_FIRST_OPERATION=#{et.isFirstOperation}, @@ -760,7 +781,7 @@ WORK_CENTER=#{et.workCenter}, RESRCE=#{et.resrce}, EMPLOYEE=#{et.employee}, - TURN_ORDER=#{et.turnOrder}, + TURN_OPERATION=#{et.turnOperation}, DISPATCH_QTY=#{et.dispatchQty}, PROD_HOURS=#{et.prodHours}, PLANNED_START_DATE=#{et.plannedStartDate}, @@ -770,8 +791,9 @@ SO_RELEASED_DATE=#{et.soReleasedDate}, SFC_RELEASED_DATE=#{et.sfcReleasedDate}, RELEASED_COMPLETE_DATE=#{et.releasedCompleteDate}, + ACTUAL_START_DATE=#{et.actualStartDate}, ACTUAL_COMPLETE_DATE=#{et.actualCompleteDate}, - IS_ALLOT=#{et.isAllot}, + IS_DISPATCH=#{et.isDispatch}, IS_IMPORT=#{et.isImport}, REMARK=#{et.remark}, IS_FIRST_OPERATION=#{et.isFirstOperation}, @@ -807,7 +829,7 @@ AND WORK_CENTER=#{ew.entity.workCenter} AND RESRCE=#{ew.entity.resrce} AND EMPLOYEE=#{ew.entity.employee} - AND TURN_ORDER=#{ew.entity.turnOrder} + AND TURN_OPERATION=#{ew.entity.turnOperation} AND DISPATCH_QTY=#{ew.entity.dispatchQty} AND PROD_HOURS=#{ew.entity.prodHours} AND PLANNED_START_DATE=#{ew.entity.plannedStartDate} @@ -817,8 +839,9 @@ AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate} AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate} AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate} + AND ACTUAL_START_DATE=#{ew.entity.actualStartDate} AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate} - AND IS_ALLOT=#{ew.entity.isAllot} + AND IS_DISPATCH=#{ew.entity.isDispatch} AND IS_IMPORT=#{ew.entity.isImport} AND REMARK=#{ew.entity.remark} AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation} @@ -885,7 +908,7 @@ AND WORK_CENTER=#{ew.entity.workCenter} AND RESRCE=#{ew.entity.resrce} AND EMPLOYEE=#{ew.entity.employee} - AND TURN_ORDER=#{ew.entity.turnOrder} + AND TURN_OPERATION=#{ew.entity.turnOperation} AND DISPATCH_QTY=#{ew.entity.dispatchQty} AND PROD_HOURS=#{ew.entity.prodHours} AND PLANNED_START_DATE=#{ew.entity.plannedStartDate} @@ -895,8 +918,9 @@ AND SO_RELEASED_DATE=#{ew.entity.soReleasedDate} AND SFC_RELEASED_DATE=#{ew.entity.sfcReleasedDate} AND RELEASED_COMPLETE_DATE=#{ew.entity.releasedCompleteDate} + AND ACTUAL_START_DATE=#{ew.entity.actualStartDate} AND ACTUAL_COMPLETE_DATE=#{ew.entity.actualCompleteDate} - AND IS_ALLOT=#{ew.entity.isAllot} + AND IS_DISPATCH=#{ew.entity.isDispatch} AND IS_IMPORT=#{ew.entity.isImport} AND REMARK=#{ew.entity.remark} AND IS_FIRST_OPERATION=#{ew.entity.isFirstOperation} @@ -911,12 +935,12 @@ AND OTHER_5=#{ew.entity.other5} - AND ${ew.sqlSegment} + ${ew.sqlSegment} - AND ${ew.sqlSegment} + ${ew.sqlSegment} @@ -938,4 +962,80 @@ AND STEP_ID = #{stepId} + + + diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/ResrceController.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/ResrceController.java index f397621a..c63dcceb 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/ResrceController.java +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/ResrceController.java @@ -41,6 +41,19 @@ public class ResrceController { return R.ok(result); } + @GetMapping("/getResourceListByType") + public R getResourceListByType(String resourceType) { + List result; + try { + String site = CommonMethods.getSite(); + result = resrceService.getResourceListByType(site, resourceType); + } catch (Exception e) { + return R.failed(e.getMessage()); + } + + return R.ok(result); + } + /** * 分页查询数据 * diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/SfcController.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/SfcController.java index fd2b2f74..58799f31 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/SfcController.java +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/SfcController.java @@ -51,30 +51,29 @@ public class SfcController { @GetMapping("/page") public R page(FrontPage frontPage, Sfc sfc){ IPage result; - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.setEntity(sfc); - if (frontPage.getGlobalQuery() != null && !"".equals(frontPage.getGlobalQuery().trim())) { - //TODO modify global query - queryWrapper.lambda().and(wrapper -> wrapper - .like(Sfc::getHandle, frontPage.getGlobalQuery()) - .or().like(Sfc::getSite, frontPage.getGlobalQuery()) - .or().like(Sfc::getSfc, frontPage.getGlobalQuery()) - .or().like(Sfc::getStatusBo, frontPage.getGlobalQuery()) - .or().like(Sfc::getShopOrderBo, frontPage.getGlobalQuery()) - .or().like(Sfc::getItemBo, frontPage.getGlobalQuery()) - .or().like(Sfc::getLocation, frontPage.getGlobalQuery()) - .or().like(Sfc::getLccBo, frontPage.getGlobalQuery()) - .or().like(Sfc::getOriginalStatusBo, frontPage.getGlobalQuery()) - .or().like(Sfc::getQtyMultPerformed, frontPage.getGlobalQuery()) - .or().like(Sfc::getPrevSite, frontPage.getGlobalQuery()) - .or().like(Sfc::getOriginalTransferKey, frontPage.getGlobalQuery()) - .or().like(Sfc::getImmediateArchive, frontPage.getGlobalQuery()) - .or().like(Sfc::getTransferUser, frontPage.getGlobalQuery()) - .or().like(Sfc::getSnDone, frontPage.getGlobalQuery()) - .or().like(Sfc::getAinEquipmentId, frontPage.getGlobalQuery()) - ); + + try { + String site = CommonMethods.getSite(); + sfc.setSite(site); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(sfc); + if (frontPage.getGlobalQuery() != null && !"".equals(frontPage.getGlobalQuery().trim())) { + queryWrapper + .like(Sfc.HANDLE, frontPage.getGlobalQuery()) + .or().like(Sfc.SITE, frontPage.getGlobalQuery()) + .or().like(Sfc.SFC, frontPage.getGlobalQuery()) + .or().like(Sfc.STATUS_BO, frontPage.getGlobalQuery()) + .or().like(Sfc.SHOP_ORDER_BO, frontPage.getGlobalQuery()) + .or().like(Sfc.ITEM_BO, frontPage.getGlobalQuery()) + .or().like(Sfc.ORIGINAL_STATUS_BO, frontPage.getGlobalQuery()) + .or().like(Sfc.SN_DONE, frontPage.getGlobalQuery()); + } + result = sfcService.page(frontPage.getPagePlus(), queryWrapper); + } catch (Exception e) { + return R.failed(e.getMessage()); } - result = sfcService.page(frontPage.getPagePlus(), queryWrapper); + return R.ok(result); } diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/mapper/ResrceMapper.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/mapper/ResrceMapper.java index 95e60383..d439fc40 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/mapper/ResrceMapper.java +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/mapper/ResrceMapper.java @@ -2,8 +2,11 @@ package com.foreverwin.mesnac.meapi.mapper; import com.foreverwin.mesnac.meapi.model.Resrce; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; +import java.util.List; + /** *

* Mapper 接口 @@ -15,4 +18,5 @@ import org.springframework.stereotype.Repository; @Repository public interface ResrceMapper extends BaseMapper { + List selectResourceListByType(@Param("site") String site, @Param("resourceType") String resourceType); } \ No newline at end of file diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/ResrceService.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/ResrceService.java index 0c1c8910..deae55cf 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/ResrceService.java +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/ResrceService.java @@ -25,4 +25,13 @@ public interface ResrceService extends IService { IPage selectPage(FrontPage frontPage, Resrce resrce); List selectList(Resrce resrce); + + /** + * 根据资源类型查询资源清单 + * + * @param site + * @param resourceType + * @return + */ + List getResourceListByType(String site, String resourceType); } \ No newline at end of file diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/ResrceServiceImpl.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/ResrceServiceImpl.java index 6244f4e5..9159c3a2 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/ResrceServiceImpl.java +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/ResrceServiceImpl.java @@ -42,5 +42,10 @@ public class ResrceServiceImpl extends ServiceImpl impleme return super.list(queryWrapper); } + @Override + public List getResourceListByType(String site, String resourceType) { + return resrceMapper.selectResourceListByType(site, resourceType); + } + } \ No newline at end of file diff --git a/meapi/src/main/resources/mapper/ResrceMapper.xml b/meapi/src/main/resources/mapper/ResrceMapper.xml index c6881b60..fb6664e5 100644 --- a/meapi/src/main/resources/mapper/ResrceMapper.xml +++ b/meapi/src/main/resources/mapper/ResrceMapper.xml @@ -540,4 +540,12 @@ + + diff --git a/meapi/src/main/resources/mapper/SfcMapper.xml b/meapi/src/main/resources/mapper/SfcMapper.xml index a665108c..6549f53c 100644 --- a/meapi/src/main/resources/mapper/SfcMapper.xml +++ b/meapi/src/main/resources/mapper/SfcMapper.xml @@ -320,12 +320,12 @@ AND PARTITION_DATE=#{ew.entity.partitionDate} - ${ew.sqlSegment} + AND ${ew.sqlSegment} - ${ew.sqlSegment} + AND ${ew.sqlSegment}