Browse Source

修复进销存合并

zyh
Loki 3 years ago
parent
commit
e01f90088f
  1. 19
      yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
  2. 1
      yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/authentication/MultiUserDetailsAuthenticationProvider.java
  3. 35
      yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java
  4. 5
      yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java
  5. 9
      yudao-server/src/main/resources/application-local.yaml
  6. 2
      zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java
  7. 2
      zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponIssueUserServiceImpl.java
  8. 3
      zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/impl/StoreCanvasServiceImpl.java
  9. 3
      zsw-bxg/src/main/java/co/yixiang/modules/customer/service/impl/YxStoreCustomerServiceImpl.java
  10. 1
      zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxArticleServiceImpl.java
  11. 2
      zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatLiveGoodsServiceImpl.java
  12. 4
      zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatLiveServiceImpl.java
  13. 1
      zsw-bxg/src/main/java/co/yixiang/modules/order/rest/StoreOrderController.java
  14. 1
      zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductRuleController.java
  15. 1
      zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRuleServiceImpl.java
  16. 2
      zsw-bxg/src/main/java/co/yixiang/modules/sales/StoreAfterSalesController.java
  17. 3
      zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxAppVersionServiceImpl.java
  18. 4
      zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxMaterialServiceImpl.java
  19. 2
      zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/YxMaterialMapper.java
  20. 1
      zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserAddressServiceImpl.java
  21. 1
      zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserBillServiceImpl.java
  22. 1
      zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiNiuServiceImpl.java
  23. 40
      zsw-erp/pom.xml
  24. 15
      zsw-erp/src/main/java/com/zsw/erp/config/MvcConfigurer.java
  25. 152
      zsw-erp/src/main/java/com/zsw/erp/controller/AccountController.java
  26. 14
      zsw-erp/src/main/java/com/zsw/erp/controller/BomController.java
  27. 4
      zsw-erp/src/main/java/com/zsw/erp/controller/BxgProductController.java
  28. 10
      zsw-erp/src/main/java/com/zsw/erp/controller/DepotController.java
  29. 13
      zsw-erp/src/main/java/com/zsw/erp/controller/DepotHeadController.java
  30. 2
      zsw-erp/src/main/java/com/zsw/erp/controller/ErpController.java
  31. 25
      zsw-erp/src/main/java/com/zsw/erp/controller/ErpSystemConfigController.java
  32. 241
      zsw-erp/src/main/java/com/zsw/erp/controller/FunctionController.java
  33. 14
      zsw-erp/src/main/java/com/zsw/erp/controller/IndexController.java
  34. 116
      zsw-erp/src/main/java/com/zsw/erp/controller/PlatformConfigController.java
  35. 71
      zsw-erp/src/main/java/com/zsw/erp/controller/RoleController.java
  36. 30
      zsw-erp/src/main/java/com/zsw/erp/controller/SupplierController.java
  37. 57
      zsw-erp/src/main/java/com/zsw/erp/controller/TenantController.java
  38. 35
      zsw-erp/src/main/java/com/zsw/erp/controller/TestController.java
  39. 104
      zsw-erp/src/main/java/com/zsw/erp/controller/UserBusinessController.java
  40. 483
      zsw-erp/src/main/java/com/zsw/erp/controller/UserController.java
  41. 20
      zsw-erp/src/main/java/com/zsw/erp/datasource/dto/UserLoginDto.java
  42. 178
      zsw-erp/src/main/java/com/zsw/erp/datasource/entities/DepotItemVo4WithInfoEx.java
  43. 3
      zsw-erp/src/main/java/com/zsw/erp/datasource/entities/InventorySeason.java
  44. 76
      zsw-erp/src/main/java/com/zsw/erp/datasource/entities/Role.java
  45. 669
      zsw-erp/src/main/java/com/zsw/erp/datasource/entities/RoleExample.java
  46. 38
      zsw-erp/src/main/java/com/zsw/erp/datasource/entities/User.java
  47. 33
      zsw-erp/src/main/java/com/zsw/erp/datasource/entities/UserBusiness.java
  48. 669
      zsw-erp/src/main/java/com/zsw/erp/datasource/entities/UserBusinessExample.java
  49. 36
      zsw-erp/src/main/java/com/zsw/erp/datasource/entities/UserEx.java
  50. 1129
      zsw-erp/src/main/java/com/zsw/erp/datasource/entities/UserExample.java
  51. 2
      zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/ErpLogMapper.java
  52. 2
      zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/ErpSystemConfigMapper.java
  53. 32
      zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/RoleMapper.java
  54. 20
      zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/RoleMapperEx.java
  55. 32
      zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/TenantMapper.java
  56. 21
      zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/TenantMapperEx.java
  57. 13
      zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/UserBusinessMapper.java
  58. 17
      zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/UserBusinessMapperEx.java
  59. 30
      zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/UserMapper.java
  60. 30
      zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/UserMapperEx.java
  61. 19
      zsw-erp/src/main/java/com/zsw/erp/dto/bom/BomConvert.java
  62. 18
      zsw-erp/src/main/java/com/zsw/erp/dto/depot/DepotConvert.java
  63. 75
      zsw-erp/src/main/java/com/zsw/erp/service/account/AccountComponent.java
  64. 13
      zsw-erp/src/main/java/com/zsw/erp/service/account/AccountResource.java
  65. 575
      zsw-erp/src/main/java/com/zsw/erp/service/account/AccountService.java
  66. 15
      zsw-erp/src/main/java/com/zsw/erp/service/accountHead/AccountHeadService.java
  67. 13
      zsw-erp/src/main/java/com/zsw/erp/service/accountItem/AccountItemService.java
  68. 30
      zsw-erp/src/main/java/com/zsw/erp/service/depot/DepotService.java
  69. 50
      zsw-erp/src/main/java/com/zsw/erp/service/depotHead/DepotHeadService.java
  70. 8
      zsw-erp/src/main/java/com/zsw/erp/service/depotItem/DepotItemService.java
  71. 73
      zsw-erp/src/main/java/com/zsw/erp/service/functions/FunctionComponent.java
  72. 13
      zsw-erp/src/main/java/com/zsw/erp/service/functions/FunctionResource.java
  73. 211
      zsw-erp/src/main/java/com/zsw/erp/service/functions/FunctionService.java
  74. 9
      zsw-erp/src/main/java/com/zsw/erp/service/inOutItem/InOutItemService.java
  75. 9
      zsw-erp/src/main/java/com/zsw/erp/service/inventorySeason/InventorySeasonService.java
  76. 33
      zsw-erp/src/main/java/com/zsw/erp/service/log/LogService.java
  77. 13
      zsw-erp/src/main/java/com/zsw/erp/service/material/MaterialService.java
  78. 13
      zsw-erp/src/main/java/com/zsw/erp/service/materialCategory/MaterialCategoryService.java
  79. 22
      zsw-erp/src/main/java/com/zsw/erp/service/materialExtend/MaterialExtendService.java
  80. 10
      zsw-erp/src/main/java/com/zsw/erp/service/materialProperty/MaterialPropertyService.java
  81. 36
      zsw-erp/src/main/java/com/zsw/erp/service/msg/MsgService.java
  82. 12
      zsw-erp/src/main/java/com/zsw/erp/service/orgaUserRel/OrgaUserRelService.java
  83. 14
      zsw-erp/src/main/java/com/zsw/erp/service/organization/OrganizationService.java
  84. 6
      zsw-erp/src/main/java/com/zsw/erp/service/person/PersonService.java
  85. 70
      zsw-erp/src/main/java/com/zsw/erp/service/role/RoleComponent.java
  86. 13
      zsw-erp/src/main/java/com/zsw/erp/service/role/RoleResource.java
  87. 184
      zsw-erp/src/main/java/com/zsw/erp/service/role/RoleService.java
  88. 21
      zsw-erp/src/main/java/com/zsw/erp/service/serialNumber/SerialNumberService.java
  89. 28
      zsw-erp/src/main/java/com/zsw/erp/service/supplier/SupplierService.java
  90. 50
      zsw-erp/src/main/java/com/zsw/erp/service/systemConfig/SystemConfigService.java
  91. 78
      zsw-erp/src/main/java/com/zsw/erp/service/tenant/TenantComponent.java
  92. 13
      zsw-erp/src/main/java/com/zsw/erp/service/tenant/TenantResource.java
  93. 182
      zsw-erp/src/main/java/com/zsw/erp/service/tenant/TenantService.java
  94. 10
      zsw-erp/src/main/java/com/zsw/erp/service/unit/UnitService.java
  95. 73
      zsw-erp/src/main/java/com/zsw/erp/service/user/UserComponent.java
  96. 13
      zsw-erp/src/main/java/com/zsw/erp/service/user/UserResource.java
  97. 815
      zsw-erp/src/main/java/com/zsw/erp/service/user/UserService.java
  98. 67
      zsw-erp/src/main/java/com/zsw/erp/service/userBusiness/UserBusinessComponent.java
  99. 13
      zsw-erp/src/main/java/com/zsw/erp/service/userBusiness/UserBusinessResource.java
  100. 163
      zsw-erp/src/main/java/com/zsw/erp/service/userBusiness/UserBusinessService.java
  101. Some files were not shown because too many files have changed in this diff Show More

19
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java

@ -20,8 +20,11 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.sql.DataSource;
import java.util.Arrays;
import java.util.Map;
/**
@ -32,6 +35,7 @@ import java.util.Map;
@MapperScans({
@MapperScan(basePackages ={"co.yixiang.**.service.mapper", "co.yixiang.config"},sqlSessionFactoryRef = "shangcheng"),
@MapperScan(basePackages = {"com.zsw.erp.datasource.mappers"},sqlSessionFactoryRef = "erp"),
@MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class,
lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试
})
@ -69,6 +73,21 @@ public class YudaoMybatisAutoConfiguration {
return getSqlSessionFactory(factory);
}
@Bean("erp")
public SqlSessionFactory erpSqlSessionFactory(DynamicDataSourceProvider dynamicDataSourceProvider) throws Exception {
MybatisSqlSessionFactoryBean factory = new MybatisSqlSessionFactoryBean();
Resource[] resources = new PathMatchingResourcePatternResolver().getResources("classpath*:/erp_mapper/*.xml");
Arrays.stream(resources).forEach(resource -> {
log.info("erp mapper:{}",resource.getFilename());
});
factory.setMapperLocations(resources);
Map<String, DataSource> map = dynamicDataSourceProvider.loadDataSources();
DataSource dataSource = map.get("erp");
factory.setDataSource(map.get("erp"));
return getSqlSessionFactory(factory);
}
private SqlSessionFactory getSqlSessionFactory(MybatisSqlSessionFactoryBean factory) throws Exception {
GlobalConfig globalConfig = new GlobalConfig();
GlobalConfig.DbConfig dbConfig = new GlobalConfig.DbConfig();

1
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/authentication/MultiUserDetailsAuthenticationProvider.java

@ -143,6 +143,7 @@ public class MultiUserDetailsAuthenticationProvider extends AbstractUserDetailsA
if (request.getRequestURI().startsWith(properties.getAdminApi().getPrefix())
|| request.getRequestURI().startsWith("/common/")
|| request.getRequestURI().startsWith("/bxg")
|| request.getRequestURI().startsWith("/erp")
|| request.getRequestURI().startsWith("/api/upload")
) {
return UserTypeEnum.ADMIN;

35
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java

@ -49,6 +49,7 @@ public class YudaoSwaggerAutoConfiguration {
return new Docket(DocumentationType.SWAGGER_2)
// 用来创建该 API 的基本信息,展示在文档的页面中(自定义展示的信息)
.apiInfo(apiInfo(properties))
.groupName("管理系统")
// 设置扫描指定 package 包下的
.select()
.apis(basePackage(properties.getBasePackage()))
@ -75,7 +76,7 @@ public class YudaoSwaggerAutoConfiguration {
.build();
pars.add(ticketPar.build());
return new Docket(DocumentationType.SWAGGER_2)
.groupName("ADMIN")
.groupName("商城后台")
.enable(true)
.apiInfo(apiInfo(properties))
.select()
@ -103,7 +104,7 @@ public class YudaoSwaggerAutoConfiguration {
.build();
pars.add(ticketPar.build());
return new Docket(DocumentationType.SWAGGER_2)
.groupName("APP")
.groupName("商城前台")
.enable(true)
.apiInfo(apiInfo(properties))
.select()
@ -132,7 +133,7 @@ public class YudaoSwaggerAutoConfiguration {
.build();
pars.add(ticketPar.build());
return new Docket(DocumentationType.SWAGGER_2)
.groupName("TOOL")
.groupName("电商工具")
.enable(true)
.apiInfo(apiInfo(properties))
.select()
@ -146,6 +147,34 @@ public class YudaoSwaggerAutoConfiguration {
.securityContexts(securityContexts());
}
@Bean("ERP")
@SuppressWarnings("all")
public Docket createErpApi() {
SwaggerProperties properties = swaggerProperties();
ParameterBuilder ticketPar = new ParameterBuilder();
List<Parameter> pars = new ArrayList<>();
ticketPar.name("token").description("token")
.modelRef(new ModelRef("string"))
.parameterType("header")
.defaultValue("token" + " ")
.required(true)
.build();
pars.add(ticketPar.build());
return new Docket(DocumentationType.SWAGGER_2)
.groupName("进销存")
.enable(true)
.apiInfo(apiInfo(properties))
.select()
.apis(RequestHandlerSelectors.basePackage("com.zsw.erp"))
.paths(PathSelectors.regex("/error.*").negate())
.build()
.globalOperationParameters(pars)
//添加登陆认证
.securitySchemes(securitySchemes())
.globalRequestParameters(globalRequestParameters())
.securityContexts(securityContexts());
}
// ========== apiInfo ==========
/**

5
yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java

@ -4,7 +4,10 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package}
@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module","co.yixiang"})
@SpringBootApplication(scanBasePackages = {
"${yudao.info.base-package}.server", "${yudao.info.base-package}.module",
"co.yixiang", "com.zsw.erp"
})
public class YudaoServerApplication {
public static void main(String[] args) {

9
yudao-server/src/main/resources/application-local.yaml

@ -60,6 +60,12 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
erp: # 进销存
name: erp
url: jdbc:mysql://192.168.10.250:3306/${spring.datasource.dynamic.datasource.erp.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
# farm: # 农场数据源
# name: zsw-farm
# url: jdbc:mysql://192.168.10.129:3306/${spring.datasource.dynamic.datasource.farm.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
@ -225,4 +231,5 @@ justauth:
cache:
type: REDIS
prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE::
timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟
timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟

2
zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/IndexController.java → zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java

@ -63,7 +63,7 @@ import java.util.Map;
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(value = "首页模块", tags = "商城:首页模块")
public class IndexController {
public class BxgIndexController {
private final YxAppVersionService appVersionService;
private final YxSystemGroupDataService systemGroupDataService;
private final YxStoreProductService storeProductService;

2
zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponIssueUserServiceImpl.java

@ -17,8 +17,6 @@ import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueUserDto;
import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueUserQueryCriteria;
import co.yixiang.modules.activity.service.mapper.YxStoreCouponIssueUserMapper;
import co.yixiang.utils.FileUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Pageable;

3
zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/impl/StoreCanvasServiceImpl.java

@ -12,10 +12,8 @@ import co.yixiang.modules.canvas.domain.StoreCanvas;
import co.yixiang.common.service.impl.BaseServiceImpl;
import lombok.AllArgsConstructor;
import co.yixiang.dozer.service.IGenerator;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.utils.ValidationUtil;
import co.yixiang.utils.FileUtil;
import co.yixiang.modules.canvas.service.StoreCanvasService;
import co.yixiang.modules.canvas.service.dto.StoreCanvasDto;
@ -28,7 +26,6 @@ import org.springframework.transaction.annotation.Transactional;
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;

3
zsw-bxg/src/main/java/co/yixiang/modules/customer/service/impl/YxStoreCustomerServiceImpl.java

@ -12,10 +12,8 @@ import co.yixiang.modules.customer.domain.YxStoreCustomer;
import co.yixiang.common.service.impl.BaseServiceImpl;
import lombok.AllArgsConstructor;
import co.yixiang.dozer.service.IGenerator;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.utils.ValidationUtil;
import co.yixiang.utils.FileUtil;
import co.yixiang.modules.customer.service.YxStoreCustomerService;
import co.yixiang.modules.customer.service.dto.YxStoreCustomerDto;
@ -28,7 +26,6 @@ import org.springframework.transaction.annotation.Transactional;
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;

1
zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxArticleServiceImpl.java

@ -23,7 +23,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;

2
zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatLiveGoodsServiceImpl.java

@ -19,7 +19,6 @@ import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.enums.LiveGoodsEnum;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.mp.service.dto.WxMaLiveInfo;
import co.yixiang.modules.mp.service.mapper.YxWechatLiveGoodsMapper;
import co.yixiang.modules.mp.domain.YxWechatLiveGoods;
import co.yixiang.modules.mp.service.YxWechatLiveGoodsService;
@ -32,7 +31,6 @@ import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;

4
zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatLiveServiceImpl.java

@ -16,7 +16,6 @@ import cn.hutool.json.JSONUtil;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.enums.ShopCommonEnum;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.mp.domain.YxWechatLiveGoods;
import co.yixiang.modules.mp.service.YxWechatLiveGoodsService;
@ -26,8 +25,6 @@ import co.yixiang.modules.mp.service.mapper.YxWechatLiveMapper;
import co.yixiang.modules.mp.vo.WechatLiveVo;
import co.yixiang.modules.mp.domain.YxWechatLive;
import co.yixiang.modules.mp.config.WxMaConfiguration;
import co.yixiang.modules.product.domain.YxStoreProduct;
import co.yixiang.modules.product.vo.YxStoreProductQueryVo;
import co.yixiang.utils.FileUtil;
import co.yixiang.utils.OrderUtil;
import co.yixiang.utils.StringUtils;
@ -44,7 +41,6 @@ import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.json.GsonParser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;

1
zsw-bxg/src/main/java/co/yixiang/modules/order/rest/StoreOrderController.java

@ -36,7 +36,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

1
zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductRuleController.java

@ -13,7 +13,6 @@ import co.yixiang.logging.aop.log.Log;
import co.yixiang.modules.aop.ForbidSubmit;
import co.yixiang.modules.product.domain.YxStoreProductRule;
import co.yixiang.modules.product.service.YxStoreProductRuleService;
import co.yixiang.modules.product.service.dto.YxStoreProductRuleDto;
import co.yixiang.modules.product.service.dto.YxStoreProductRuleQueryCriteria;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

1
zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRuleServiceImpl.java

@ -13,7 +13,6 @@ import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.modules.product.domain.YxStoreProductRule;
import co.yixiang.modules.product.service.YxStoreProductRuleService;
import co.yixiang.modules.product.service.dto.YxStoreProductRuleDto;
import co.yixiang.modules.product.service.dto.YxStoreProductRuleQueryCriteria;
import co.yixiang.modules.product.service.mapper.YxStoreProductRuleMapper;
import co.yixiang.utils.FileUtil;

2
zsw-bxg/src/main/java/co/yixiang/modules/sales/StoreAfterSalesController.java

@ -1,7 +1,5 @@
package co.yixiang.modules.sales;
import co.yixiang.annotation.AnonymousAccess;
import co.yixiang.domain.PageResult;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.logging.aop.log.Log;
import co.yixiang.modules.mp.service.WeixinPayService;

3
zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxAppVersionServiceImpl.java

@ -12,10 +12,8 @@ import co.yixiang.modules.shop.domain.YxAppVersion;
import co.yixiang.common.service.impl.BaseServiceImpl;
import lombok.AllArgsConstructor;
import co.yixiang.dozer.service.IGenerator;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.utils.ValidationUtil;
import co.yixiang.utils.FileUtil;
import co.yixiang.modules.shop.service.YxAppVersionService;
import co.yixiang.modules.shop.service.dto.YxAppVersionDto;
@ -28,7 +26,6 @@ import org.springframework.transaction.annotation.Transactional;
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;

4
zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxMaterialServiceImpl.java

@ -15,7 +15,7 @@ import co.yixiang.modules.shop.domain.YxMaterial;
import co.yixiang.modules.shop.service.YxMaterialService;
import co.yixiang.modules.shop.service.dto.YxMaterialDto;
import co.yixiang.modules.shop.service.dto.YxMaterialQueryCriteria;
import co.yixiang.modules.shop.service.mapper.MaterialMapper;
import co.yixiang.modules.shop.service.mapper.YxMaterialMapper;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Pageable;
@ -35,7 +35,7 @@ import java.util.Map;
@Service
@AllArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class YxMaterialServiceImpl extends BaseServiceImpl<MaterialMapper, YxMaterial> implements YxMaterialService {
public class YxMaterialServiceImpl extends BaseServiceImpl<YxMaterialMapper, YxMaterial> implements YxMaterialService {
private final IGenerator generator;

2
zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/MaterialMapper.java → zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/YxMaterialMapper.java

@ -17,6 +17,6 @@ import org.springframework.stereotype.Repository;
* @date 2020-05-12
*/
@Repository
public interface MaterialMapper extends CoreMapper<YxMaterial> {
public interface YxMaterialMapper extends CoreMapper<YxMaterial> {
}

1
zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserAddressServiceImpl.java

@ -9,7 +9,6 @@
package co.yixiang.modules.user.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.dozer.service.IGenerator;

1
zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserBillServiceImpl.java

@ -41,7 +41,6 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**

1
zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiNiuServiceImpl.java

@ -25,7 +25,6 @@ import com.qiniu.storage.UploadManager;
import com.qiniu.storage.model.DefaultPutRet;
import com.qiniu.storage.model.FileInfo;
import com.qiniu.util.Auth;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;

40
zsw-erp/pom.xml

@ -23,9 +23,9 @@
<dependencies>
<dependency>
<groupId>com.zsw</groupId>
<artifactId>pos-spi</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>cn.iocoder.boot</groupId>
<artifactId>zsw-spi</artifactId>
<version>1.6.2-snapshot</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.qiniu/qiniu-java-sdk -->
@ -40,46 +40,55 @@
<artifactId>yudao-module-system-impl</artifactId>
<version>1.6.2-snapshot</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-weixin</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-common</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-pay</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-web</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-redis</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-security</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-extension</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
@ -97,6 +106,31 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer-spring</artifactId>
<version>5.5.1</version>
</dependency>
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.5.1</version>
</dependency>
</dependencies>

15
zsw-erp/src/main/java/com/zsw/erp/config/MvcConfigurer.java

@ -0,0 +1,15 @@
package com.zsw.erp.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MvcConfigurer implements WebMvcConfigurer {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.addPathPrefix("/admin-api/erp",aClass -> aClass.getPackage().getName().startsWith("com.zsw.erp"));
}
}

152
zsw-erp/src/main/java/com/zsw/erp/controller/AccountController.java

@ -1,152 +0,0 @@
package com.zsw.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.datasource.entities.Account;
import com.zsw.erp.datasource.vo.AccountVo4InOutList;
import com.zsw.erp.service.account.AccountService;
import com.zsw.base.R;
import com.zsw.erp.utils.ErpInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.zsw.erp.utils.ResponseJsonUtil.returnJson;
@RestController
@RequestMapping(value = "/account")
@Api(tags = {"账户管理"})
public class AccountController {
private Logger logger = LoggerFactory.getLogger(AccountController.class);
@Resource
private AccountService accountService;
/**
* 查找结算账户信息-下拉框
* @param request
* @return
*/
@GetMapping(value = "/findBySelect")
@ApiOperation(value = "查找结算账户信息-下拉框")
public String findBySelect(HttpServletRequest request) throws Exception {
String res = null;
try {
List<Account> dataList = accountService.findBySelect();
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (Account account : dataList) {
JSONObject item = new JSONObject();
item.put("Id", account.getId());
//结算账户名称
item.put("AccountName", account.getName());
dataArray.add(item);
}
}
res = dataArray.toJSONString();
} catch(Exception e){
e.printStackTrace();
res = "获取数据失败";
}
return res;
}
/**
* 获取所有结算账户
* @param request
* @return
*/
@GetMapping(value = "/getAccount")
@ApiOperation(value = "获取所有结算账户")
public R getAccount(HttpServletRequest request) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
List<Account> accountList = accountService.getAccount();
map.put("accountList", accountList);
return R.success(map);
}
/**
* 账户流水信息
* @param currentPage
* @param pageSize
* @param accountId
* @param initialAmount
* @param request
* @return
*/
@GetMapping(value = "/findAccountInOutList")
@ApiOperation(value = "账户流水信息")
public R findAccountInOutList(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("accountId") Long accountId,
@RequestParam("initialAmount") BigDecimal initialAmount,
HttpServletRequest request) throws Exception{
Map<String, Object> map = new HashMap<String, Object>();
List<AccountVo4InOutList> dataList = accountService.findAccountInOutList(accountId, (currentPage-1)*pageSize, pageSize);
int total = accountService.findAccountInOutListCount(accountId);
map.put("total", total);
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (AccountVo4InOutList aEx : dataList) {
String timeStr = aEx.getOperTime().toString();
BigDecimal balance = accountService.getAccountSum(accountId, timeStr, "date").add(accountService.getAccountSumByHead(accountId, timeStr, "date"))
.add(accountService.getAccountSumByDetail(accountId, timeStr, "date")).add(accountService.getManyAccountSum(accountId, timeStr, "date")).add(initialAmount);
aEx.setBalance(balance);
aEx.setAccountId(accountId);
dataArray.add(aEx);
}
}
map.put("rows", dataArray);
return R.success(map);
}
/**
* 更新默认账户
* @param object
* @param request
* @return
* @throws Exception
*/
@PostMapping(value = "/updateIsDefault")
@ApiOperation(value = "更新默认账户")
public String updateIsDefault(@RequestBody JSONObject object,
HttpServletRequest request) throws Exception{
Long accountId = object.getLong("id");
Map<String, Object> objectMap = new HashMap<>();
int res = accountService.updateIsDefault(accountId);
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
/**
* 结算账户的统计
* @param request
* @return
*/
@GetMapping(value = "/getStatistics")
@ApiOperation(value = "结算账户的统计")
public R getStatistics(@RequestParam("name") String name,
@RequestParam("serialNo") String serialNo,
HttpServletRequest request) throws Exception {
Map<String, Object> map = accountService.getStatistics(name, serialNo);
return R.success(map);
}
}

14
zsw-erp/src/main/java/com/zsw/erp/controller/BomController.java

@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.zsw.base.R;
import com.zsw.erp.datasource.dto.BomDto;
import com.zsw.erp.dto.bom.BomConvert;
import com.zsw.erp.service.zyh.BomService;
import com.zsw.erp.utils.DozerUtils;
import com.zsw.pos.product.dto.AdminStoreProductDTO;
import com.zsw.pos.product.entity.Product;
import com.zsw.pos.product.entity.ProductSku;
@ -29,17 +29,13 @@ import java.util.List;
@RequestMapping("/bom")
@Slf4j
public class BomController {
@Resource
private DozerUtils dozerUtils;
@DubboReference
// @DubboReference
private ProductService productService;
@DubboReference
// @DubboReference
private ProductSkuService productSkuService;
@DubboReference
// @DubboReference
private StoreService storeService;
@Resource
@ -60,7 +56,7 @@ public class BomController {
@GetMapping("/list")
@ApiOperation("列举全部BOM")
public R<List<BomDto>> list(){
List<BomDto> rs = dozerUtils.convertList(bomService.list(), BomDto.class);
List<BomDto> rs = BomConvert.INSTANCE.convertList2Dto(bomService.list());
return R.success(rs);
}

4
zsw-erp/src/main/java/com/zsw/erp/controller/MaterialController.java → zsw-erp/src/main/java/com/zsw/erp/controller/BxgProductController.java

@ -34,8 +34,8 @@ import static com.zsw.erp.utils.ResponseJsonUtil.returnJson;
@RestController
@RequestMapping(value = "/material")
@Api(tags = {"商品管理"})
public class MaterialController {
private Logger logger = LoggerFactory.getLogger(MaterialController.class);
public class BxgProductController {
private Logger logger = LoggerFactory.getLogger(BxgProductController.class);
@Resource
private MaterialService materialService;

10
zsw-erp/src/main/java/com/zsw/erp/controller/DepotController.java

@ -7,7 +7,6 @@ import com.zsw.erp.datasource.entities.DepotEx;
import com.zsw.erp.datasource.entities.MaterialInitialStock;
import com.zsw.erp.service.depot.DepotService;
import com.zsw.erp.service.material.MaterialService;
import com.zsw.erp.service.userBusiness.UserBusinessService;
import com.zsw.base.R;
import com.zsw.erp.utils.ErpInfo;
import io.swagger.annotations.Api;
@ -33,9 +32,6 @@ public class DepotController {
@Resource
private DepotService depotService;
@Resource
private UserBusinessService userBusinessService;
@Resource
private MaterialService materialService;
@ -66,7 +62,6 @@ public class DepotController {
JSONArray arr = new JSONArray();
try {
//获取权限信息
List<Long> ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId);
List<Depot> dataList = depotService.findUserDepot();
//开始拼接json数据
JSONObject outer = new JSONObject();
@ -85,10 +80,7 @@ public class DepotController {
item.put("value", depot.getId());
item.put("title", depot.getName());
item.put("attributes", depot.getName());
Boolean flag = ubValue.contains(depot.getId());
if (flag) {
item.put("checked", true);
}
dataArray.add(item);
}
}

13
zsw-erp/src/main/java/com/zsw/erp/controller/DepotHeadController.java

@ -3,6 +3,8 @@ package com.zsw.erp.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zsw.base.R;
@ -14,7 +16,7 @@ import com.zsw.erp.datasource.vo.DepotHeadVo4InDetail;
import com.zsw.erp.datasource.vo.DepotHeadVo4InOutMCount;
import com.zsw.erp.datasource.vo.DepotHeadVo4List;
import com.zsw.erp.datasource.vo.DepotHeadVo4StatementAccount;
import com.zsw.erp.service.account.AccountService;
import com.zsw.erp.dto.depot.DepotConvert;
import com.zsw.erp.service.accountHead.AccountHeadService;
import com.zsw.erp.service.depot.DepotService;
import com.zsw.erp.service.depotHead.DepotHeadService;
@ -54,7 +56,8 @@ public class DepotHeadController {
private AccountHeadService accountHeadService;
@Resource
private AccountService accountService;
private AdminUserService adminUserService;
@Resource
private SupplierService supplierService;
@ -464,15 +467,15 @@ public class DepotHeadController {
body.setInfo(head);
List<DepotItem> list = depotItemService.getListByHeaderId(head.getId());
List<DepotItemDto> listRs = BeanUtil.copyToList(list, DepotItemDto.class);
List<DepotItemDto> listRs = DepotConvert.INSTANCE.convertList(list);
body.setRows(listRs);
body.setId(head.getId());
String sub = no.substring(0, 4).toUpperCase();
logger.info("sub:{}",sub);
Supplier supplier = supplierService.getSupplier(head.getOrganId());
Account acc = accountService.getAccount(head.getAccountId());
AdminUserDO user = adminUserService.getUser(head.getAccountId());
model.addObject("supplier",supplier.getSupplier());
model.addObject("create_time", DateUtil.format(head.getCreateTime(), DatePattern.NORM_DATETIME_PATTERN));
@ -482,7 +485,7 @@ public class DepotHeadController {
model.addObject("discount_money",head.getDiscountMoney());
model.addObject("discount_last_money",head.getDiscountLastMoney());
model.addObject("other_money",head.getOtherMoney());
model.addObject("account",acc.getName());
model.addObject("account",user.getNickname());
model.addObject("total_price",head.getTotalPrice());
model.addObject("debt",head.getDiscountLastMoney().subtract(head.getChangeAmount()));

2
zsw-erp/src/main/java/com/zsw/erp/controller/ResourceController.java → zsw-erp/src/main/java/com/zsw/erp/controller/ErpController.java

@ -22,7 +22,7 @@ import static com.zsw.erp.utils.ResponseJsonUtil.returnJson;
@RestController
@Api(tags = {"资源接口"})
public class ResourceController {
public class ErpController {
@Resource
private CommonQueryManager configResourceManager;

25
zsw-erp/src/main/java/com/zsw/erp/controller/SystemConfigController.java → zsw-erp/src/main/java/com/zsw/erp/controller/ErpSystemConfigController.java

@ -16,8 +16,6 @@ import com.zsw.erp.config.QiniuConfigProperty;
import com.zsw.erp.datasource.entities.SystemConfig;
import com.zsw.erp.service.depot.DepotService;
import com.zsw.erp.service.systemConfig.SystemConfigService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.service.userBusiness.UserBusinessService;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.utils.Tools;
import io.swagger.annotations.Api;
@ -53,30 +51,21 @@ import java.util.List;
@RequestMapping(value = "/systemConfig")
@Api(tags = {"系统参数"})
@EnableConfigurationProperties(QiniuConfigProperty.class)
public class SystemConfigController {
private Logger logger = LoggerFactory.getLogger(SystemConfigController.class);
public class ErpSystemConfigController {
private Logger logger = LoggerFactory.getLogger(ErpSystemConfigController.class);
@Resource
QiniuConfigProperty qiniuConfigProperty;
@Resource
private UserService userService;
@Resource
private DepotService depotService;
@Resource
private UserBusinessService userBusinessService;
@Resource
private SystemConfigService systemConfigService;
@Value(value="${spring.servlet.multipart.max-file-size}")
private Long maxFileSize;
@Value(value="${spring.servlet.multipart.max-request-size}")
private Long maxRequestSize;
/**
* 获取当前租户的配置信息
* @param request
@ -104,13 +93,7 @@ public class SystemConfigController {
@ApiOperation(value = "获取文件大小限制")
public R fileSizeLimit(HttpServletRequest request) throws Exception {
Long limit = 0L;
if(maxFileSize<maxRequestSize) {
limit = maxFileSize;
} else {
limit = maxRequestSize;
}
return R.success(limit);
return R.success("");
}
/**

241
zsw-erp/src/main/java/com/zsw/erp/controller/FunctionController.java

@ -1,241 +0,0 @@
package com.zsw.erp.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.google.common.collect.Lists;
import com.zsw.erp.datasource.entities.BtnDto;
import com.zsw.erp.datasource.entities.Function;
import com.zsw.erp.datasource.entities.UserBusiness;
import com.zsw.erp.service.functions.FunctionService;
import com.zsw.erp.service.userBusiness.UserBusinessService;
import com.zsw.base.R;
import com.zsw.erp.utils.Tools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(value = "/function")
@Api(tags = {"功能管理"})
public class FunctionController {
private Logger logger = LoggerFactory.getLogger(FunctionController.class);
@Resource
private FunctionService functionService;
@Resource
private UserBusinessService userBusinessService;
/**
* 根据父编号查询菜单
* @param jsonObject
* @param request
* @return
* @throws Exception
*/
@PostMapping(value = "/findMenuByPNumber")
@ApiOperation(value = "根据父编号查询菜单")
public JSONArray findMenuByPNumber(@RequestBody JSONObject jsonObject,
HttpServletRequest request)throws Exception {
String pNumber = jsonObject.getStr("pNumber");
Long userId = jsonObject.getLong("userId");
//存放数据json数组
JSONArray dataArray = new JSONArray();
try {
Long roleId = 0L;
List<Long> fc = Lists.newArrayList();
UserBusiness role = userBusinessService.getBasicData(userId, "UserRole");
roleId = role.getValue().get(0).longValue();
//当前用户所拥有的功能列表,格式如:[1][2][5]
// List<UserBusiness> funList = userBusinessService.getBasicData(roleId.toString(), "RoleFunctions");
// if(funList!=null && funList.size()>0){
// fc = funList.get(0).getValue();
// }
// List<Function> dataList = functionService.getRoleFunction(pNumber);
List<Function> dataList;
if (roleId == 1L){
logger.info("当前是系统管理员,给予全部菜单和权限。");
dataList = functionService.getRoleFunction(pNumber);
fc = functionService.getFunction().stream().map(Function::getId).collect(Collectors.toList());
}else{
dataList = functionService.getRoleFunction(pNumber);
UserBusiness fun = userBusinessService.getBasicData(roleId, "RoleFunctions");
fc = fun.getValue().stream().map(Number::longValue).collect(Collectors.toList());
}
if (dataList.size() != 0) {
dataArray = getMenuByFunction(dataList, fc);
//增加首页菜单项
JSONObject homeItem = new JSONObject();
homeItem.set("id", 0);
homeItem.set("text", "首页");
homeItem.set("icon", "home");
homeItem.set("url", "/dashboard/analysis");
homeItem.set("component", "/layouts/TabLayout");
dataArray.add(0,homeItem);
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>>>>>>>>>>>查找异常", e);
}
return dataArray;
}
public JSONArray getMenuByFunction(List<Function> dataList, List<Long> fc) throws Exception {
dataList = dataList.stream()
.filter(function -> fc.contains(function.getId()))
.collect(Collectors.toList());
JSONArray dataArray = new JSONArray();
for (Function function : dataList) {
JSONObject item = new JSONObject();
List<Function> newList = functionService.getRoleFunction(function.getNumber());
item.set("id", function.getId());
item.set("text", function.getName());
item.set("icon", function.getIcon());
item.set("url", function.getUrl());
item.set("component", function.getComponent());
if (newList.size()>0) {
JSONArray childrenArr = getMenuByFunction(newList, fc);
if(childrenArr.size()>0) {
item.put("children", childrenArr);
dataArray.add(item);
}
} else {
if (fc.contains(function.getId())) {
dataArray.add(item);
}
}
}
return dataArray;
}
/**
* 角色对应功能显示
* @param request
* @return
*/
@GetMapping(value = "/findRoleFunction")
@ApiOperation(value = "角色对应功能显示")
public JSONArray findRoleFunction(@RequestParam("UBType") String type, @RequestParam("UBKeyId") Long keyId,
HttpServletRequest request)throws Exception {
JSONArray arr = new JSONArray();
try {
List<Function> dataListFun = functionService.findRoleFunction("0");
//开始拼接json数据
JSONObject outer = new JSONObject();
outer.set("id", 0);
outer.set("key", 0);
outer.set("value", 0);
outer.set("title", "功能列表");
outer.set("attributes", "功能列表");
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataListFun) {
//根据条件从列表里面移除"系统管理"
List<Function> dataList = new ArrayList<>();
for (Function fun : dataListFun) {
String token = request.getHeader("X-Access-Token");
Long tenantId = Tools.getTenantIdByToken(token);
if (tenantId!=0L) {
if(!("系统管理").equals(fun.getName())) {
dataList.add(fun);
}
} else {
//超管
dataList.add(fun);
}
}
dataArray = getFunctionList(dataList, type, keyId);
outer.set("children", dataArray);
}
arr.add(outer);
} catch (Exception e) {
e.printStackTrace();
}
return arr;
}
public JSONArray getFunctionList(List<Function> dataList, String type, Long keyId) throws Exception {
JSONArray dataArray = new JSONArray();
//获取权限信息
List<Long> ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId);
if (null != dataList) {
for (Function function : dataList) {
JSONObject item = new JSONObject();
item.set("id", function.getId());
item.set("key", function.getId());
item.set("value", function.getId());
item.set("title", function.getName());
item.set("attributes", function.getName());
List<Function> funList = functionService.findRoleFunction(function.getNumber());
if(funList.size()>0) {
JSONArray funArr = getFunctionList(funList, type, keyId);
item.set("children", funArr);
} else {
if (ubValue == null){
item.set("checked", false);
}else {
Boolean flag = ubValue.contains(function.getId());
item.set("checked", flag);
}
}
dataArray.add(item);
}
}
return dataArray;
}
/**
* 根据id列表查找功能信息
* @param roleId
* @param request
* @return
*/
@GetMapping(value = "/findRoleFunctionsById")
@ApiOperation(value = "根据id列表查找功能信息")
public R findByIds(@RequestParam("roleId") Long roleId,
HttpServletRequest request)throws Exception {
UserBusiness ub = userBusinessService.getBasicData(roleId, "RoleFunctions");
//按钮
Map<Long,String> btnMap = new HashMap<>();
List<BtnDto> btnStr = ub.getBtnStr();
if(ObjectUtil.isNotEmpty(btnStr)) {
for(BtnDto obj: btnStr) {
if(obj.getFunId()!=null && obj.getBtnStr()!=null) {
btnMap.put(obj.getFunId(), obj.getBtnStr());
}
}
}
//菜单
List<Long> funIds = ub.getValue().stream().map(Number::longValue).collect(Collectors.toList());
List<Function> dataList = functionService.findByIds(funIds);
JSONObject outer = new JSONObject();
outer.set("total", dataList.size());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (ObjectUtil.isNotEmpty(dataList)) {
for (Function function : dataList) {
JSONObject item = new JSONObject();
item.set("id", function.getId());
item.set("name", function.getName());
item.set("pushBtn", function.getPushBtn());
item.set("btnStr", ObjectUtil.isEmpty(btnMap.get(function.getId()))?"":btnMap.get(function.getId()));
dataArray.add(item);
}
}
outer.set("rows", dataArray);
return R.success(outer);
}
}

14
zsw-erp/src/main/java/com/zsw/erp/controller/IndexController.java

@ -1,14 +0,0 @@
package com.zsw.erp.controller;
import com.zsw.base.R;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class IndexController {
@RequestMapping("/")
public R<String> index(){
return R.success("","欢迎访问回乡进销存系统");
}
}

116
zsw-erp/src/main/java/com/zsw/erp/controller/PlatformConfigController.java

@ -1,116 +0,0 @@
package com.zsw.erp.controller;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.datasource.entities.PlatformConfig;
import com.zsw.erp.service.platformConfig.PlatformConfigService;
import com.zsw.erp.service.user.UserService;
import com.zsw.base.R;
import com.zsw.erp.utils.ErpInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import static com.zsw.erp.utils.ResponseJsonUtil.returnJson;
@RestController
@RequestMapping(value = "/platformConfig")
@Api(tags = {"平台参数"})
public class PlatformConfigController {
private Logger logger = LoggerFactory.getLogger(PlatformConfigController.class);
@Value("${demonstrate.open}")
private boolean demonstrateOpen;
@Resource
private PlatformConfigService platformConfigService;
@Resource
private UserService userService;
private static final String TEST_USER = "jsh";
/**
* 获取平台名称
* @param request
* @return
*/
@GetMapping(value = "/getPlatform/name")
@ApiOperation(value = "获取平台名称")
public String getPlatformName(HttpServletRequest request)throws Exception {
String res;
try {
String platformKey = "platform_name";
PlatformConfig platformConfig = platformConfigService.getPlatformConfigByKey(platformKey);
res = platformConfig.getPlatformValue();
} catch(Exception e){
e.printStackTrace();
res = "ERP系统";
}
return res;
}
/**
* 获取官方网站地址
* @param request
* @return
*/
@GetMapping(value = "/getPlatform/url")
@ApiOperation(value = "获取官方网站地址")
public String getPlatformUrl(HttpServletRequest request)throws Exception {
String res;
try {
String platformKey = "platform_url";
PlatformConfig platformConfig = platformConfigService.getPlatformConfigByKey(platformKey);
res = platformConfig.getPlatformValue();
} catch(Exception e){
e.printStackTrace();
res = "#";
}
return res;
}
/**
* 根据platformKey更新platformValue
* @param object
* @param request
* @return
*/
@PostMapping(value = "/updatePlatformConfigByKey")
@ApiOperation(value = "根据platformKey更新platformValue")
public String updatePlatformConfigByKey(@RequestBody JSONObject object,
HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
String platformKey = object.getString("platformKey");
String platformValue = object.getString("platformValue");
int res = platformConfigService.updatePlatformConfigByKey(platformKey, platformValue);
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
/**
* 根据platformKey查询信息
* @param platformKey
* @param request
* @return
*/
@GetMapping(value = "/getPlatformConfigByKey")
@ApiOperation(value = "根据platformKey查询信息")
public R getPlatformConfigByKey(@RequestParam("platformKey") String platformKey,
HttpServletRequest request)throws Exception {
PlatformConfig platformConfig = platformConfigService.getPlatformConfigByKey(platformKey);
return R.success(platformConfig);
}
}

71
zsw-erp/src/main/java/com/zsw/erp/controller/RoleController.java

@ -1,71 +0,0 @@
package com.zsw.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.datasource.entities.Role;
import com.zsw.erp.service.role.RoleService;
import com.zsw.erp.service.userBusiness.UserBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping(value = "/role")
@Api(tags = {"角色管理"})
public class RoleController {
private Logger logger = LoggerFactory.getLogger(RoleController.class);
@Resource
private RoleService roleService;
@Resource
private UserBusinessService userBusinessService;
/**
* 角色对应应用显示
* @param request
* @return
*/
@GetMapping(value = "/findUserRole")
@ApiOperation(value = "查询用户的角色")
public JSONArray findUserRole(@RequestParam("UBType") String type, @RequestParam("UBKeyId") Long keyId,
HttpServletRequest request)throws Exception {
JSONArray arr = new JSONArray();
try {
//获取权限信息
List<Long> ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId);
List<Role> dataList = roleService.findUserRole();
if (null != dataList) {
for (Role role : dataList) {
JSONObject item = new JSONObject();
item.put("id", role.getId());
item.put("text", role.getName());
Boolean flag = ubValue.contains(role.getId());
if (flag) {
item.put("checked", true);
}
arr.add(item);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return arr;
}
@GetMapping(value = "/allList")
@ApiOperation(value = "查询全部角色列表")
public List<Role> allList(HttpServletRequest request)throws Exception {
return roleService.allList();
}
}

30
zsw-erp/src/main/java/com/zsw/erp/controller/SupplierController.java

@ -8,9 +8,8 @@ import com.zsw.erp.datasource.entities.Supplier;
import com.zsw.erp.dto.supplier.SupplierVo;
import com.zsw.erp.service.supplier.SupplierService;
import com.zsw.erp.service.systemConfig.SystemConfigService;
import com.zsw.erp.service.tenant.TenantService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.service.userBusiness.UserBusinessService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.base.R;
import com.zsw.erp.utils.ErpInfo;
import com.zsw.erp.utils.ExportExecUtil;
@ -41,17 +40,10 @@ public class SupplierController {
@Resource
private SupplierService supplierService;
@Resource
private UserBusinessService userBusinessService;
@Resource
private SystemConfigService systemConfigService;
@Resource
private UserService userService;
@Resource
private TenantService tenantService;
@GetMapping(value = "/checkIsNameAndTypeExist")
@ApiOperation(value = "检查名称和类型是否存在")
@ -162,19 +154,15 @@ public class SupplierController {
}
//2、获取客户信息
String type = "UserCustomer";
Long userId = userService.getUserId(request);
List<Long> ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, userId);
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
List<Supplier> customerList = supplierService.findBySelectCus();
if (null != customerList) {
boolean customerFlag = systemConfigService.getCustomerFlag();
for (Supplier supplier : customerList) {
JSONObject item = new JSONObject();
Boolean flag = ubValue.contains(supplier.getId());
if (!customerFlag || flag) {
item.put("id", supplier.getId());
item.put("supplier", supplier.getSupplier() + "[客户]"); //客户名称
dataArray.add(item);
}
item.put("id", supplier.getId());
item.put("supplier", supplier.getSupplier() + "[客户]"); //客户名称
dataArray.add(item);
}
}
arr = dataArray;
@ -248,7 +236,6 @@ public class SupplierController {
JSONArray arr = new JSONArray();
try {
//获取权限信息
List<Long> ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId);
List<Supplier> dataList = supplierService.findUserCustomer();
//开始拼接json数据
JSONObject outer = new JSONObject();
@ -267,10 +254,7 @@ public class SupplierController {
item.put("value", supplier.getId());
item.put("title", supplier.getSupplier());
item.put("attributes", supplier.getSupplier());
Boolean flag = ubValue.contains(supplier.getId());
if (flag) {
item.put("checked", true);
}
item.put("checked", true);
dataArray.add(item);
}
}

57
zsw-erp/src/main/java/com/zsw/erp/controller/TenantController.java

@ -1,57 +0,0 @@
package com.zsw.erp.controller;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.service.tenant.TenantService;
import com.zsw.erp.utils.ErpInfo;
import com.zsw.erp.utils.ResponseCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import static com.zsw.erp.utils.ResponseJsonUtil.returnJson;
import static com.zsw.erp.utils.ResponseJsonUtil.success;
@RestController
@RequestMapping(value = "/tenant")
@Api(tags = {"租户管理"})
public class TenantController {
private Logger logger = LoggerFactory.getLogger(TenantController.class);
@Resource
private TenantService tenantService;
/**
* 批量设置状态-启用或者禁用
* @param jsonObject
* @param request
* @return
*/
@PostMapping(value = "/batchSetStatus")
@ApiOperation(value = "批量设置状态")
public String batchSetStatus(@RequestBody JSONObject jsonObject,
HttpServletRequest request)throws Exception {
Boolean status = jsonObject.getBoolean("status");
String ids = jsonObject.getString("ids");
Map<String, Object> objectMap = new HashMap<>();
int res = tenantService.batchSetStatus(status, ids);
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
@GetMapping("/listAllTenant")
@ApiOperation("列举全部租户")
public ResponseCode listAllTenant() throws Exception {
return success(tenantService.getTenant());
}
}

35
zsw-erp/src/main/java/com/zsw/erp/controller/TestController.java

@ -1,35 +0,0 @@
package com.zsw.erp.controller;
import com.zsw.base.R;
import com.zsw.jwt.model.TenantAuthInfo;
import com.zsw.pos.authority.dto.auth.LoginParamDTO;
import com.zsw.pos.oauth.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Slf4j
@Validated
public class TestController {
@DubboReference
private LoginService loginService;
@GetMapping("/test/login")
public R test(@RequestParam String username, @RequestParam String password){
LoginParamDTO dto = new LoginParamDTO();
dto.setAccount(username);
dto.setPassword(password);
dto.setGrantType("password");
R<TenantAuthInfo> rs = loginService.grant(dto);
log.debug("login result : {}",rs.getData());
return rs;
}
}

104
zsw-erp/src/main/java/com/zsw/erp/controller/UserBusinessController.java

@ -1,104 +0,0 @@
package com.zsw.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.zsw.erp.datasource.dto.BtnStrDto;
import com.zsw.erp.datasource.entities.UserBusiness;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.service.userBusiness.UserBusinessService;
import com.zsw.base.R;
import com.zsw.erp.utils.ErpInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.zsw.erp.utils.ResponseJsonUtil.returnJson;
@RestController
@RequestMapping(value = "/userBusiness")
@Api(tags = {"用户角色模块的关系"})
public class UserBusinessController {
private Logger logger = LoggerFactory.getLogger(UserBusinessController.class);
@Resource
private UserBusinessService userBusinessService;
@Resource
private UserService userService;
/**
* 获取信息
* @param keyId
* @param type
* @param request
* @return
* @throws Exception
*/
@GetMapping(value = "/getBasicData")
@ApiOperation(value = "获取信息")
public R getBasicData(@RequestParam(value = "KeyId") Long keyId,
@RequestParam(value = "Type") String type,
HttpServletRequest request)throws Exception {
UserBusiness list = userBusinessService.getBasicData(keyId, type);
Map<String, List> mapData = new HashMap<String, List>();
mapData.put("userBusinessList", Lists.newArrayList(list));
return R.success(mapData);
}
/**
* 校验存在
* @param type
* @param keyId
* @param request
* @return
* @throws Exception
*/
@GetMapping(value = "/checkIsValueExist")
@ApiOperation(value = "校验存在")
public String checkIsValueExist(@RequestParam(value ="type", required = false) String type,
@RequestParam(value ="keyId", required = false) String keyId,
HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<String, Object>();
Long id = userBusinessService.checkIsValueExist(type, keyId);
if(id != null) {
objectMap.put("id", id);
} else {
objectMap.put("id", null);
}
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
}
/**
* 更新角色的按钮权限
* @param jsonObject
* @param request
* @return
*/
@PostMapping(value = "/updateBtnStr")
@ApiOperation(value = "更新角色的按钮权限")
public R updateBtnStr(@RequestBody BtnStrDto dto,
HttpServletRequest request)throws Exception {
String roleId = dto.getRoleId();
// JSONArray btnStrArray = jsonObject.getJSONArray("btnStr");
// List<BtnDto> btnStr = btnStrArray.toJavaList(BtnDto.class);
String keyId = roleId;
String type = "RoleFunctions";
int back = userBusinessService.updateBtnStr(keyId, type, dto.getBtnStr());
if(back > 0) {
return R.success("成功");
}else {
return R.fail("更新失败");
}
}
}

483
zsw-erp/src/main/java/com/zsw/erp/controller/UserController.java

@ -1,483 +0,0 @@
package com.zsw.erp.controller;
import cn.hutool.core.date.*;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.jwt.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.constants.ExceptionConstants;
import com.zsw.erp.datasource.entities.BtnDto;
import com.zsw.erp.datasource.dto.UserLoginDto;
import com.zsw.erp.datasource.entities.Tenant;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.entities.UserEx;
import com.zsw.erp.datasource.vo.TreeNodeEx;
import com.zsw.erp.exception.BusinessParamCheckingException;
import com.zsw.erp.service.inventorySeason.InventorySeasonService;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.redis.RedisService;
import com.zsw.erp.service.tenant.TenantService;
import com.zsw.erp.service.user.UserService;
import com.zsw.base.R;
import com.zsw.erp.utils.*;
import com.zsw.jwt.model.AuthInfo;
import com.zsw.jwt.model.TenantAuthInfo;
import com.zsw.pos.authority.dto.auth.LoginParamDTO;
import com.zsw.pos.oauth.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import static com.zsw.erp.utils.ResponseJsonUtil.returnJson;
@RestController
@RequestMapping(value = "/user")
@Api(tags = {"用户管理"})
public class UserController {
private Logger logger = LoggerFactory.getLogger(UserController.class);
@Value("${manage.roleId}")
private Integer manageRoleId;
@Value("${demonstrate.open}")
private boolean demonstrateOpen;
@Resource
private UserService userService;
@Resource
private TenantService tenantService;
@Resource
private LogService logService;
@Resource
private RedisService redisService;
@Resource
private InventorySeasonService inventorySeasonService;
@DubboReference
private LoginService loginService;
@Value("${tenant.userNumLimit}")
private Integer systemLimit;
private static final String TEST_USER = "jsh";
private static String SUCCESS = "操作成功";
private static String ERROR = "操作失败";
private static final String HTTP = "http://";
private static final String CODE_OK = "200";
private static final String BASE_CHECK_CODES = "qwertyuiplkjhgfdsazxcvbnmQWERTYUPLKJHGFDSAZXCVBNM1234567890";
@PostMapping(value = "/login")
@ApiOperation(value = "登录")
public R login(@RequestBody User userParam,
HttpServletRequest request)throws Exception {
logger.info("============用户登录 login 方法调用开始==============");
String msgTip = "";
User user=null;
String loginName = userParam.getLoginName().trim();
String password = userParam.getPassword().trim();
String posTenantCode = null;
JWTPayload payload = new JWTPayload();
// 登录zsw-admin
LoginParamDTO dto = new LoginParamDTO();
dto.setAccount(loginName);
dto.setPassword(password);
R<TenantAuthInfo> result = loginService.grant(dto);
logger.error("result:{}",result);
if (result.getIsSuccess()){
// 检查系统里是否存在租户和账户 没有准备走注册流程
posTenantCode = result.getData().getTenantCode();
// 在这里带了太多的门店ID
payload.setPayload("loginName",loginName);
payload.setPayload("tenantId",posTenantCode);
}
//获取用户状态
//int userStatus = -1;
redisService.deleteObjectBySession(request,"userId");
UserLoginDto loginDto = userService.validateUser(loginName, password);
switch (loginDto.getUserStatus()) {
case ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST:
msgTip = "user is not exist";
if (posTenantCode != null){
// 用户不存在 但是用户不存在 可能报错。
UserEx ex = new UserEx();
ex.setLoginName(loginName);
ex.setPassword(password);
ex.setTenantId(Long.parseLong(posTenantCode));
LocalDateTime time = LocalDateTimeUtil.offset(LocalDateTime.now(), 10, ChronoUnit.YEARS);
DateTimeFormatter formater = DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN);
String t = time.format(formater);
ex.setExpireTime(t);
user = this.registerUser(ex,request);
payload.setPayload("userId",user.getId());
payload.setPayload("loginName",loginName);
payload.setPayload("tenantId",posTenantCode);
msgTip = "user can login";
}
break;
case ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR:
msgTip = "user password error";
break;
case ExceptionCodeConstants.UserExceptionCode.BLACK_USER:
msgTip = "user is black";
break;
case ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION:
msgTip = "access service error";
break;
case ExceptionCodeConstants.UserExceptionCode.BLACK_TENANT:
msgTip = "tenant is black";
break;
case ExceptionCodeConstants.UserExceptionCode.EXPIRE_TENANT:
msgTip = "tenant is expire";
break;
case ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT:
msgTip = "user can login";
user = loginDto.getUser();
payload.setPayload("userId",user.getId());
payload.setPayload("loginName",loginName);
payload.setPayload("tenantId",user.getTenantId());
break;
default:
break;
}
// 1个月过期
DateTime exAt = DateUtil.offset(new Date(), DateField.MONTH, 1);
payload.setExpiresAt(exAt);
String token = JWTUtil.createToken(payload.getClaimsJson(), "88888888".getBytes(StandardCharsets.UTF_8));
Map<String, Object> data = new HashMap<String, Object>();
data.put("msgTip", msgTip);
if(user!=null){
redisService.storageObjectBySession(token,"userId",user.getId());
String roleType = userService.getRoleTypeByUserId(user.getId()); //角色类型
if (roleType == null){
logger.error("角色错误!");
}
redisService.storageObjectBySession(token,"roleType",roleType);
redisService.storageObjectBySession(token,"clientIp", Tools.getLocalIp(request));
logService.insertLogWithUserId(user.getId(), user.getTenantId(), "用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_LOGIN).append(user.getLoginName()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
List<BtnDto> btnStrArr = userService.getBtnStrArrById(user.getId());
data.put("token", token);
data.put("user", user);
LocalUser.setTenantId(user.getTenantId());
LocalUser.setUserId(user.getId());
data.put("season",inventorySeasonService.getNow());
//用户的按钮权限
if(!"admin".equals(user.getLoginName())){
data.put("userBtn", btnStrArr);
}
data.put("roleType", roleType);
logger.info("===============用户登录 login 方法调用结束===============");
return R.success(data);
}else{
return R.fail("用户名或者密码错误");
}
}
@GetMapping(value = "/getUserSession")
@ApiOperation(value = "获取用户信息")
public R getSessionUser(HttpServletRequest request)throws Exception {
Map<String, Object> data = new HashMap<>();
Long userId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userId").toString());
User user = userService.getUser(userId);
user.setPassword(null);
data.put("user", user);
return R.success(data);
}
@GetMapping(value = "/logout")
@ApiOperation(value = "退出")
public R logout(HttpServletRequest request, HttpServletResponse response)throws Exception {
redisService.deleteObjectBySession(request,"userId");
return R.success();
}
@PostMapping(value = "/resetPwd")
@ApiOperation(value = "重置密码")
public String resetPwd(@RequestBody JSONObject jsonObject,
HttpServletRequest request) throws Exception {
Map<String, Object> objectMap = new HashMap<>();
Long id = jsonObject.getLong("id");
String password = "123456";
String md5Pwd = Tools.md5Encryp(password);
int update = userService.resetPwd(md5Pwd, id);
if(update > 0) {
return returnJson(objectMap, SUCCESS, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ERROR, ErpInfo.ERROR.code);
}
}
@PutMapping(value = "/updatePwd")
@ApiOperation(value = "更新密码")
public String updatePwd(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception {
Integer flag = 0;
Map<String, Object> objectMap = new HashMap<String, Object>();
try {
String info = "";
Long userId = jsonObject.getLong("userId");
String oldpwd = jsonObject.getString("oldpassword");
String password = jsonObject.getString("password");
User user = userService.getUser(userId);
//必须和原始密码一致才可以更新密码
if(demonstrateOpen && user.getLoginName().equals(TEST_USER)){
flag = 3; //jsh用户不能修改密码
info = "jsh用户不能修改密码";
} else if (oldpwd.equalsIgnoreCase(user.getPassword())) {
user.setPassword(password);
flag = userService.updateUserByObj(user); //1-成功
info = "修改成功";
} else {
flag = 2; //原始密码输入错误
info = "原始密码输入错误";
}
objectMap.put("status", flag);
if(flag > 0) {
return returnJson(objectMap, info, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ERROR, ErpInfo.ERROR.code);
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>修改用户ID为 : " + jsonObject.getLong("userId") + "密码信息失败", e);
flag = 3;
objectMap.put("status", flag);
return returnJson(objectMap, ERROR, ErpInfo.ERROR.code);
}
}
/**
* 获取全部用户数据列表
* @param request
* @return
*/
@GetMapping(value = "/getAllList")
@ApiOperation(value = "获取全部用户数据列表")
public R getAllList(HttpServletRequest request)throws Exception {
Map<String, Object> data = new HashMap<String, Object>();
List<User> dataList = userService.getUser();
if(dataList!=null) {
data.put("userList", dataList);
}
return R.success(data);
}
/**
* 用户列表用于用户下拉框
* @param request
* @return
* @throws Exception
*/
@GetMapping(value = "/getUserList")
@ApiOperation(value = "用户列表")
public JSONArray getUserList(HttpServletRequest request)throws Exception {
JSONArray dataArray = new JSONArray();
try {
List<User> dataList = userService.getUser();
if (null != dataList) {
for (User user : dataList) {
JSONObject item = new JSONObject();
item.put("id", user.getId());
item.put("userName", user.getUsername());
dataArray.add(item);
}
}
} catch(Exception e){
e.printStackTrace();
}
return dataArray;
}
/**
* create by: cjl
* description:
* 新增用户及机构和用户关系
* create time: 2019/3/8 16:06
* @Param: beanJson
* @return java.lang.Object
*/
@PostMapping("/addUser")
@ApiOperation(value = "新增用户")
@ResponseBody
public Object addUser(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception{
JSONObject result = ExceptionConstants.standardSuccess();
// 系统的人数限制
Object limit = redisService.getObjectFromSessionByKey(request, "userNumLimit");
Long userNumLimit = ObjectUtil.isNotEmpty(limit)
? Long.parseLong(limit.toString())
: systemLimit;
Long count = userService.countUser(null,null);
if(count>= userNumLimit) {
throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE,
ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG);
} else {
UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class);
userService.addUserAndOrgUserRel(ue, request);
}
return result;
}
/**
* create by: cjl
* description:
* 修改用户及机构和用户关系
* create time: 2019/3/8 16:06
* @Param: beanJson
* @return java.lang.Object
*/
@PutMapping("/updateUser")
@ApiOperation(value = "修改用户")
@ResponseBody
public Object updateUser(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception{
JSONObject result = ExceptionConstants.standardSuccess();
UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class);
userService.updateUserAndOrgUserRel(ue, request);
return result;
}
/**
* 注册用户
* @param ue
* @return
* @throws Exception
*/
@PostMapping(value = "/registerUser")
@ApiOperation(value = "注册用户")
public UserEx registerUser(@RequestBody UserEx ue,
HttpServletRequest request)throws Exception{
logger.error("用户注册开始...");
JSONObject result = ExceptionConstants.standardSuccess();
ue.setUsername(ue.getLoginName());
userService.checkUserNameAndLoginName(ue); //检查用户名和登录名
ue = userService.registerUser(ue,manageRoleId,request);
return ue;
}
/**
* 获取机构用户树
* @return
* @throws Exception
*/
@RequestMapping("/getOrganizationUserTree")
@ApiOperation(value = "获取机构用户树")
public JSONArray getOrganizationUserTree()throws Exception{
JSONArray arr=new JSONArray();
List<TreeNodeEx> organizationUserTree= userService.getOrganizationUserTree();
if(organizationUserTree!=null&&organizationUserTree.size()>0){
for(TreeNodeEx node:organizationUserTree){
String str=JSON.toJSONString(node);
JSONObject obj=JSON.parseObject(str);
arr.add(obj) ;
}
}
return arr;
}
/**
* 获取当前用户的角色类型
* @param request
* @return
*/
@GetMapping("/getRoleTypeByCurrentUser")
@ApiOperation(value = "获取当前用户的角色类型")
public R getRoleTypeByCurrentUser(HttpServletRequest request) {
Map<String, Object> data = new HashMap<String, Object>();
String roleType = redisService.getObjectFromSessionByKey(request,"roleType").toString();
data.put("roleType", roleType);
return R.success(data);
}
/**
* 获取随机校验码
* @param response
* @param key
* @return
*/
@GetMapping(value = "/randomImage/{key}")
@ApiOperation(value = "获取随机校验码")
public R randomImage(HttpServletResponse response,@PathVariable String key) throws IOException {
Map<String, Object> data = new HashMap<>();
String codeNum = Tools.getCharAndNum(4);
String base64 = RandImageUtil.generate(codeNum);
data.put("codeNum", codeNum);
data.put("base64", base64);
return R.success(data);
}
/**
* 批量设置状态-启用或者禁用
* @param jsonObject
* @param request
* @return
*/
@PostMapping(value = "/batchSetStatus")
@ApiOperation(value = "批量设置状态")
public String batchSetStatus(@RequestBody JSONObject jsonObject,
HttpServletRequest request)throws Exception {
Byte status = jsonObject.getByte("status");
String ids = jsonObject.getString("ids");
Map<String, Object> objectMap = new HashMap<>();
int res = userService.batchSetStatus(status, ids);
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
/**
* 获取当前用户的用户数量和租户信息
* @param request
* @return
*/
@GetMapping(value = "/infoWithTenant")
@ApiOperation(value = "获取当前用户的用户数量和租户信息")
public R randomImage(HttpServletRequest request){
Map<String, Object> data = new HashMap<>();
Long userId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userId").toString());
User user = userService.getUser(userId);
//获取当前用户数
Long userCurrentNum = userService.countUser(null, null);
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
data.put("type", tenant.getType()); //租户类型,0免费租户,1付费租户
data.put("expireTime", Tools.parseDateToStr(tenant.getExpireTime()));
data.put("userCurrentNum", userCurrentNum);
data.put("userNumLimit", tenant.getUserNumLimit());
return R.success(data);
}
}

20
zsw-erp/src/main/java/com/zsw/erp/datasource/dto/UserLoginDto.java

@ -1,20 +0,0 @@
package com.zsw.erp.datasource.dto;
import com.zsw.erp.datasource.entities.User;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
public class UserLoginDto {
private Integer userStatus;
private User user;
public static UserLoginDto buildStatus(Integer status){
return UserLoginDto.builder().userStatus(status).build();
}
}

178
zsw-erp/src/main/java/com/zsw/erp/datasource/entities/DepotItemVo4WithInfoEx.java

@ -1,7 +1,10 @@
package com.zsw.erp.datasource.entities;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class DepotItemVo4WithInfoEx extends DepotItem{
private Long MId;
@ -48,179 +51,4 @@ public class DepotItemVo4WithInfoEx extends DepotItem{
private String barCode;
public Long getMId() {
return MId;
}
public void setMId(Long MId) {
this.MId = MId;
}
public String getMName() {
return MName;
}
public void setMName(String MName) {
this.MName = MName;
}
public String getMModel() {
return MModel;
}
public void setMModel(String MModel) {
this.MModel = MModel;
}
public String getMaterialUnit() {
return MaterialUnit;
}
public void setMaterialUnit(String materialUnit) {
MaterialUnit = materialUnit;
}
public String getMColor() {
return MColor;
}
public void setMColor(String MColor) {
this.MColor = MColor;
}
public String getMStandard() {
return MStandard;
}
public void setMStandard(String MStandard) {
this.MStandard = MStandard;
}
public String getMMfrs() {
return MMfrs;
}
public void setMMfrs(String MMfrs) {
this.MMfrs = MMfrs;
}
public String getMOtherField1() {
return MOtherField1;
}
public void setMOtherField1(String MOtherField1) {
this.MOtherField1 = MOtherField1;
}
public String getMOtherField2() {
return MOtherField2;
}
public void setMOtherField2(String MOtherField2) {
this.MOtherField2 = MOtherField2;
}
public String getMOtherField3() {
return MOtherField3;
}
public void setMOtherField3(String MOtherField3) {
this.MOtherField3 = MOtherField3;
}
public String getEnableSerialNumber() {
return enableSerialNumber;
}
public void setEnableSerialNumber(String enableSerialNumber) {
this.enableSerialNumber = enableSerialNumber;
}
public String getEnableBatchNumber() {
return enableBatchNumber;
}
public void setEnableBatchNumber(String enableBatchNumber) {
this.enableBatchNumber = enableBatchNumber;
}
public String getDepotName() {
return DepotName;
}
public void setDepotName(String depotName) {
DepotName = depotName;
}
public String getAnotherDepotName() {
return AnotherDepotName;
}
public void setAnotherDepotName(String anotherDepotName) {
AnotherDepotName = anotherDepotName;
}
public Long getUnitId() {
return UnitId;
}
public void setUnitId(Long unitId) {
UnitId = unitId;
}
public String getUnitName() {
return unitName;
}
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public Integer getRatio() {
return ratio;
}
public void setRatio(Integer ratio) {
this.ratio = ratio;
}
public String getOtherUnit() {
return otherUnit;
}
public void setOtherUnit(String otherUnit) {
this.otherUnit = otherUnit;
}
public BigDecimal getPresetPriceOne() {
return presetPriceOne;
}
public void setPresetPriceOne(BigDecimal presetPriceOne) {
this.presetPriceOne = presetPriceOne;
}
public String getPriceStrategy() {
return priceStrategy;
}
public void setPriceStrategy(String priceStrategy) {
this.priceStrategy = priceStrategy;
}
public BigDecimal getPurchaseDecimal() {
return purchaseDecimal;
}
public void setPurchaseDecimal(BigDecimal purchaseDecimal) {
this.purchaseDecimal = purchaseDecimal;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
}

3
zsw-erp/src/main/java/com/zsw/erp/datasource/entities/InventorySeason.java

@ -1,5 +1,8 @@
package com.zsw.erp.datasource.entities;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import java.time.LocalDateTime;

76
zsw-erp/src/main/java/com/zsw/erp/datasource/entities/Role.java

@ -1,76 +0,0 @@
package com.zsw.erp.datasource.entities;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
public class Role {
@TableId(type = IdType.AUTO)
private Long id;
private String name;
private String type;
private String value;
private String description;
private Long tenantId;
private String deleteFlag;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value == null ? null : value.trim();
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
public Long getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
public String getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(String deleteFlag) {
this.deleteFlag = deleteFlag == null ? null : deleteFlag.trim();
}
}

669
zsw-erp/src/main/java/com/zsw/erp/datasource/entities/RoleExample.java

@ -1,669 +0,0 @@
package com.zsw.erp.datasource.entities;
import java.util.ArrayList;
import java.util.List;
public class RoleExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public RoleExample() {
oredCriteria = new ArrayList<>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("name is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("name is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("name =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("name <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("name >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("name >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("name <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("name <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("name like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("name not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("name in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("name not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("name between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("name not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("type is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("type =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("type <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("type >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("type >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("type <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("type <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("type like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("type not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("type in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("type not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("type between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andValueIsNull() {
addCriterion("value is null");
return (Criteria) this;
}
public Criteria andValueIsNotNull() {
addCriterion("value is not null");
return (Criteria) this;
}
public Criteria andValueEqualTo(String value) {
addCriterion("value =", value, "value");
return (Criteria) this;
}
public Criteria andValueNotEqualTo(String value) {
addCriterion("value <>", value, "value");
return (Criteria) this;
}
public Criteria andValueGreaterThan(String value) {
addCriterion("value >", value, "value");
return (Criteria) this;
}
public Criteria andValueGreaterThanOrEqualTo(String value) {
addCriterion("value >=", value, "value");
return (Criteria) this;
}
public Criteria andValueLessThan(String value) {
addCriterion("value <", value, "value");
return (Criteria) this;
}
public Criteria andValueLessThanOrEqualTo(String value) {
addCriterion("value <=", value, "value");
return (Criteria) this;
}
public Criteria andValueLike(String value) {
addCriterion("value like", value, "value");
return (Criteria) this;
}
public Criteria andValueNotLike(String value) {
addCriterion("value not like", value, "value");
return (Criteria) this;
}
public Criteria andValueIn(List<String> values) {
addCriterion("value in", values, "value");
return (Criteria) this;
}
public Criteria andValueNotIn(List<String> values) {
addCriterion("value not in", values, "value");
return (Criteria) this;
}
public Criteria andValueBetween(String value1, String value2) {
addCriterion("value between", value1, value2, "value");
return (Criteria) this;
}
public Criteria andValueNotBetween(String value1, String value2) {
addCriterion("value not between", value1, value2, "value");
return (Criteria) this;
}
public Criteria andDescriptionIsNull() {
addCriterion("description is null");
return (Criteria) this;
}
public Criteria andDescriptionIsNotNull() {
addCriterion("description is not null");
return (Criteria) this;
}
public Criteria andDescriptionEqualTo(String value) {
addCriterion("description =", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotEqualTo(String value) {
addCriterion("description <>", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionGreaterThan(String value) {
addCriterion("description >", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionGreaterThanOrEqualTo(String value) {
addCriterion("description >=", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLessThan(String value) {
addCriterion("description <", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLessThanOrEqualTo(String value) {
addCriterion("description <=", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLike(String value) {
addCriterion("description like", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotLike(String value) {
addCriterion("description not like", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionIn(List<String> values) {
addCriterion("description in", values, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotIn(List<String> values) {
addCriterion("description not in", values, "description");
return (Criteria) this;
}
public Criteria andDescriptionBetween(String value1, String value2) {
addCriterion("description between", value1, value2, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotBetween(String value1, String value2) {
addCriterion("description not between", value1, value2, "description");
return (Criteria) this;
}
public Criteria andTenantIdIsNull() {
addCriterion("tenant_id is null");
return (Criteria) this;
}
public Criteria andTenantIdIsNotNull() {
addCriterion("tenant_id is not null");
return (Criteria) this;
}
public Criteria andTenantIdEqualTo(Long value) {
addCriterion("tenant_id =", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotEqualTo(Long value) {
addCriterion("tenant_id <>", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdGreaterThan(Long value) {
addCriterion("tenant_id >", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdGreaterThanOrEqualTo(Long value) {
addCriterion("tenant_id >=", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdLessThan(Long value) {
addCriterion("tenant_id <", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdLessThanOrEqualTo(Long value) {
addCriterion("tenant_id <=", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdIn(List<Long> values) {
addCriterion("tenant_id in", values, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotIn(List<Long> values) {
addCriterion("tenant_id not in", values, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdBetween(Long value1, Long value2) {
addCriterion("tenant_id between", value1, value2, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotBetween(Long value1, Long value2) {
addCriterion("tenant_id not between", value1, value2, "tenantId");
return (Criteria) this;
}
public Criteria andDeleteFlagIsNull() {
addCriterion("delete_flag is null");
return (Criteria) this;
}
public Criteria andDeleteFlagIsNotNull() {
addCriterion("delete_flag is not null");
return (Criteria) this;
}
public Criteria andDeleteFlagEqualTo(String value) {
addCriterion("delete_flag =", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagNotEqualTo(String value) {
addCriterion("delete_flag <>", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagGreaterThan(String value) {
addCriterion("delete_flag >", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagGreaterThanOrEqualTo(String value) {
addCriterion("delete_flag >=", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagLessThan(String value) {
addCriterion("delete_flag <", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagLessThanOrEqualTo(String value) {
addCriterion("delete_flag <=", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagLike(String value) {
addCriterion("delete_flag like", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagNotLike(String value) {
addCriterion("delete_flag not like", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagIn(List<String> values) {
addCriterion("delete_flag in", values, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagNotIn(List<String> values) {
addCriterion("delete_flag not in", values, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagBetween(String value1, String value2) {
addCriterion("delete_flag between", value1, value2, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagNotBetween(String value1, String value2) {
addCriterion("delete_flag not between", value1, value2, "deleteFlag");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

38
zsw-erp/src/main/java/com/zsw/erp/datasource/entities/User.java

@ -1,38 +0,0 @@
package com.zsw.erp.datasource.entities;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
@Data
public class User {
@TableId(type = IdType.AUTO)
private Long id;
private String username;
private String loginName;
private String password;
private String position;
private String department;
private String email;
private String phonenum;
private Byte ismanager;
private Byte isystem;
private Byte status;
private String description;
private String remark;
private Long tenantId;
}

33
zsw-erp/src/main/java/com/zsw/erp/datasource/entities/UserBusiness.java

@ -1,33 +0,0 @@
package com.zsw.erp.datasource.entities;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.zsw.erp.config.ArrayListTypeHandler;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@TableName(autoResultMap = true)
public class UserBusiness implements Serializable {
@TableId(type = IdType.AUTO)
private Long id;
private String type;
private String keyId;
@TableField(value = "`value`",typeHandler = JacksonTypeHandler.class)
private List<Number> value;
@TableField(value = "`btn_str`",typeHandler = ArrayListTypeHandler.class)
private List<BtnDto> btnStr;
private Long tenantId;
private String deleteFlag;
}

669
zsw-erp/src/main/java/com/zsw/erp/datasource/entities/UserBusinessExample.java

@ -1,669 +0,0 @@
package com.zsw.erp.datasource.entities;
import java.util.ArrayList;
import java.util.List;
public class UserBusinessExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public UserBusinessExample() {
oredCriteria = new ArrayList<>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("type is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("type =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("type <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("type >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("type >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("type <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("type <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("type like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("type not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("type in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("type not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("type between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andKeyIdIsNull() {
addCriterion("key_id is null");
return (Criteria) this;
}
public Criteria andKeyIdIsNotNull() {
addCriterion("key_id is not null");
return (Criteria) this;
}
public Criteria andKeyIdEqualTo(String value) {
addCriterion("key_id =", value, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdNotEqualTo(String value) {
addCriterion("key_id <>", value, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdGreaterThan(String value) {
addCriterion("key_id >", value, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdGreaterThanOrEqualTo(String value) {
addCriterion("key_id >=", value, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdLessThan(String value) {
addCriterion("key_id <", value, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdLessThanOrEqualTo(String value) {
addCriterion("key_id <=", value, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdLike(String value) {
addCriterion("key_id like", value, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdNotLike(String value) {
addCriterion("key_id not like", value, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdIn(List<String> values) {
addCriterion("key_id in", values, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdNotIn(List<String> values) {
addCriterion("key_id not in", values, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdBetween(String value1, String value2) {
addCriterion("key_id between", value1, value2, "keyId");
return (Criteria) this;
}
public Criteria andKeyIdNotBetween(String value1, String value2) {
addCriterion("key_id not between", value1, value2, "keyId");
return (Criteria) this;
}
public Criteria andValueIsNull() {
addCriterion("value is null");
return (Criteria) this;
}
public Criteria andValueIsNotNull() {
addCriterion("value is not null");
return (Criteria) this;
}
public Criteria andValueEqualTo(String value) {
addCriterion("value =", value, "value");
return (Criteria) this;
}
public Criteria andValueNotEqualTo(String value) {
addCriterion("value <>", value, "value");
return (Criteria) this;
}
public Criteria andValueGreaterThan(String value) {
addCriterion("value >", value, "value");
return (Criteria) this;
}
public Criteria andValueGreaterThanOrEqualTo(String value) {
addCriterion("value >=", value, "value");
return (Criteria) this;
}
public Criteria andValueLessThan(String value) {
addCriterion("value <", value, "value");
return (Criteria) this;
}
public Criteria andValueLessThanOrEqualTo(String value) {
addCriterion("value <=", value, "value");
return (Criteria) this;
}
public Criteria andValueLike(String value) {
addCriterion("value like", value, "value");
return (Criteria) this;
}
public Criteria andValueNotLike(String value) {
addCriterion("value not like", value, "value");
return (Criteria) this;
}
public Criteria andValueIn(List<String> values) {
addCriterion("value in", values, "value");
return (Criteria) this;
}
public Criteria andValueNotIn(List<String> values) {
addCriterion("value not in", values, "value");
return (Criteria) this;
}
public Criteria andValueBetween(String value1, String value2) {
addCriterion("value between", value1, value2, "value");
return (Criteria) this;
}
public Criteria andValueNotBetween(String value1, String value2) {
addCriterion("value not between", value1, value2, "value");
return (Criteria) this;
}
public Criteria andBtnStrIsNull() {
addCriterion("btn_str is null");
return (Criteria) this;
}
public Criteria andBtnStrIsNotNull() {
addCriterion("btn_str is not null");
return (Criteria) this;
}
public Criteria andBtnStrEqualTo(String value) {
addCriterion("btn_str =", value, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrNotEqualTo(String value) {
addCriterion("btn_str <>", value, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrGreaterThan(String value) {
addCriterion("btn_str >", value, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrGreaterThanOrEqualTo(String value) {
addCriterion("btn_str >=", value, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrLessThan(String value) {
addCriterion("btn_str <", value, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrLessThanOrEqualTo(String value) {
addCriterion("btn_str <=", value, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrLike(String value) {
addCriterion("btn_str like", value, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrNotLike(String value) {
addCriterion("btn_str not like", value, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrIn(List<String> values) {
addCriterion("btn_str in", values, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrNotIn(List<String> values) {
addCriterion("btn_str not in", values, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrBetween(String value1, String value2) {
addCriterion("btn_str between", value1, value2, "btnStr");
return (Criteria) this;
}
public Criteria andBtnStrNotBetween(String value1, String value2) {
addCriterion("btn_str not between", value1, value2, "btnStr");
return (Criteria) this;
}
public Criteria andTenantIdIsNull() {
addCriterion("tenant_id is null");
return (Criteria) this;
}
public Criteria andTenantIdIsNotNull() {
addCriterion("tenant_id is not null");
return (Criteria) this;
}
public Criteria andTenantIdEqualTo(Long value) {
addCriterion("tenant_id =", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotEqualTo(Long value) {
addCriterion("tenant_id <>", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdGreaterThan(Long value) {
addCriterion("tenant_id >", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdGreaterThanOrEqualTo(Long value) {
addCriterion("tenant_id >=", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdLessThan(Long value) {
addCriterion("tenant_id <", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdLessThanOrEqualTo(Long value) {
addCriterion("tenant_id <=", value, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdIn(List<Long> values) {
addCriterion("tenant_id in", values, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotIn(List<Long> values) {
addCriterion("tenant_id not in", values, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdBetween(Long value1, Long value2) {
addCriterion("tenant_id between", value1, value2, "tenantId");
return (Criteria) this;
}
public Criteria andTenantIdNotBetween(Long value1, Long value2) {
addCriterion("tenant_id not between", value1, value2, "tenantId");
return (Criteria) this;
}
public Criteria andDeleteFlagIsNull() {
addCriterion("delete_flag is null");
return (Criteria) this;
}
public Criteria andDeleteFlagIsNotNull() {
addCriterion("delete_flag is not null");
return (Criteria) this;
}
public Criteria andDeleteFlagEqualTo(String value) {
addCriterion("delete_flag =", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagNotEqualTo(String value) {
addCriterion("delete_flag <>", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagGreaterThan(String value) {
addCriterion("delete_flag >", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagGreaterThanOrEqualTo(String value) {
addCriterion("delete_flag >=", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagLessThan(String value) {
addCriterion("delete_flag <", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagLessThanOrEqualTo(String value) {
addCriterion("delete_flag <=", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagLike(String value) {
addCriterion("delete_flag like", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagNotLike(String value) {
addCriterion("delete_flag not like", value, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagIn(List<String> values) {
addCriterion("delete_flag in", values, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagNotIn(List<String> values) {
addCriterion("delete_flag not in", values, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagBetween(String value1, String value2) {
addCriterion("delete_flag between", value1, value2, "deleteFlag");
return (Criteria) this;
}
public Criteria andDeleteFlagNotBetween(String value1, String value2) {
addCriterion("delete_flag not between", value1, value2, "deleteFlag");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

36
zsw-erp/src/main/java/com/zsw/erp/datasource/entities/UserEx.java

@ -1,36 +0,0 @@
package com.zsw.erp.datasource.entities;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
/**
* Description
*
* @Author: cjl
* @Date: 2019/3/8 15:12
*/
@Data
public class UserEx extends User{
//机构简称
private String orgAbr;
//机构id
private Long orgaId;
//用户在部门中排序
private String userBlngOrgaDsplSeq;
//机构用户关联关系id
private Long orgaUserRelId;
private Long roleId;
private String roleName;
private String userType;
private Integer userNumLimit;
private String expireTime;
@TableField(exist = false)
private Long storeId;
}

1129
zsw-erp/src/main/java/com/zsw/erp/datasource/entities/UserExample.java

File diff suppressed because it is too large Load Diff

2
zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/LogMapper.java → zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/ErpLogMapper.java

@ -5,7 +5,7 @@ import com.zsw.erp.datasource.entities.LogExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface LogMapper {
public interface ErpLogMapper {
long countByExample(LogExample example);
int deleteByExample(LogExample example);

2
zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/SystemConfigMapper.java → zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/ErpSystemConfigMapper.java

@ -8,7 +8,7 @@ import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SystemConfigMapper extends BaseMapper<SystemConfig> {
public interface ErpSystemConfigMapper extends BaseMapper<SystemConfig> {
long countByExample(SystemConfigExample example);
int deleteByExample(SystemConfigExample example);

32
zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/RoleMapper.java

@ -1,32 +0,0 @@
package com.zsw.erp.datasource.mappers;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.zsw.erp.datasource.entities.Role;
import com.zsw.erp.datasource.entities.RoleExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface RoleMapper {
long countByExample(RoleExample example);
int deleteByExample(RoleExample example);
int deleteByPrimaryKey(Long id);
int insert(Role record);
int insertSelective(Role record);
List<Role> selectByExample(RoleExample example);
@InterceptorIgnore
Role selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") Role record, @Param("example") RoleExample example);
int updateByExample(@Param("record") Role record, @Param("example") RoleExample example);
int updateByPrimaryKeySelective(Role record);
int updateByPrimaryKey(Role record);
}

20
zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/RoleMapperEx.java

@ -1,20 +0,0 @@
package com.zsw.erp.datasource.mappers;
import com.zsw.erp.datasource.entities.Role;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface RoleMapperEx {
List<Role> selectByConditionRole(
@Param("name") String name,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
Long countsByRole(
@Param("name") String name);
int batchDeleteRoleByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
}

32
zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/TenantMapper.java

@ -1,32 +0,0 @@
package com.zsw.erp.datasource.mappers;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsw.erp.datasource.entities.Tenant;
import com.zsw.erp.datasource.entities.TenantExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface TenantMapper extends BaseMapper<Tenant> {
long countByExample(TenantExample example);
int deleteByExample(TenantExample example);
int deleteByPrimaryKey(Long id);
List<Tenant> selectByExample(TenantExample example);
@InterceptorIgnore(tenantLine = "true")
Tenant selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") Tenant record, @Param("example") TenantExample example);
int updateByExample(@Param("record") Tenant record, @Param("example") TenantExample example);
int updateByPrimaryKeySelective(Tenant record);
int updateByPrimaryKey(Tenant record);
}

21
zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/TenantMapperEx.java

@ -1,21 +0,0 @@
package com.zsw.erp.datasource.mappers;
import com.zsw.erp.datasource.entities.TenantEx;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TenantMapperEx {
List<TenantEx> selectByConditionTenant(
@Param("loginName") String loginName,
@Param("type") String type,
@Param("enabled") String enabled,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
Long countsByTenant(
@Param("loginName") String loginName,
@Param("type") String type,
@Param("enabled") String enabled);
}

13
zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/UserBusinessMapper.java

@ -1,13 +0,0 @@
package com.zsw.erp.datasource.mappers;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsw.erp.datasource.entities.UserBusiness;
import com.zsw.erp.datasource.entities.UserBusinessExample;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface UserBusinessMapper extends BaseMapper<UserBusiness> {
}

17
zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/UserBusinessMapperEx.java

@ -1,17 +0,0 @@
package com.zsw.erp.datasource.mappers;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/**
* Description
*
* @Author: qiankunpingtai
* @Date: 2019/3/29 15:09
*/
public interface UserBusinessMapperEx {
int batchDeleteUserBusinessByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
}

30
zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/UserMapper.java

@ -1,30 +0,0 @@
package com.zsw.erp.datasource.mappers;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.entities.UserExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface UserMapper extends BaseMapper<User> {
long countByExample(UserExample example);
int deleteByExample(UserExample example);
int deleteByPrimaryKey(Long id);
List<User> selectByExample(UserExample example);
User selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);
int updateByExample(@Param("record") User record, @Param("example") UserExample example);
int updateByPrimaryKeySelective(User record);
int updateByPrimaryKey(User record);
}

30
zsw-erp/src/main/java/com/zsw/erp/datasource/mappers/UserMapperEx.java

@ -1,30 +0,0 @@
package com.zsw.erp.datasource.mappers;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.entities.UserEx;
import com.zsw.erp.datasource.vo.TreeNodeEx;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface UserMapperEx {
List<UserEx> selectByConditionUser(
@Param("userName") String userName,
@Param("loginName") String loginName,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
Long countsByUser(
@Param("userName") String userName,
@Param("loginName") String loginName);
List<User> getUserListByUserNameOrLoginName(@Param("userName") String userName,
@Param("loginName") String loginName);
int batDeleteOrUpdateUser(@Param("ids") String ids[], @Param("status") byte status);
List<TreeNodeEx> getNodeTree();
List<TreeNodeEx> getNextNodeTree(Map<String, Object> parameterMap);
}

19
zsw-erp/src/main/java/com/zsw/erp/dto/bom/BomConvert.java

@ -0,0 +1,19 @@
package com.zsw.erp.dto.bom;
import cn.iocoder.yudao.module.system.controller.admin.CpUser.vo.CpUserRespVO;
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO;
import com.zsw.erp.datasource.dto.BomDto;
import com.zsw.erp.datasource.entities.Bom;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface BomConvert {
BomConvert INSTANCE = Mappers.getMapper(BomConvert.class);
List<BomDto> convertList2Dto(List<Bom> list);
}

18
zsw-erp/src/main/java/com/zsw/erp/dto/depot/DepotConvert.java

@ -0,0 +1,18 @@
package com.zsw.erp.dto.depot;
import com.zsw.erp.datasource.dto.DepotItemDto;
import com.zsw.erp.datasource.entities.DepotItem;
import com.zsw.erp.dto.bom.BomConvert;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface DepotConvert {
DepotConvert INSTANCE = Mappers.getMapper(DepotConvert.class);
List<DepotItemDto> convertList(List<DepotItem> list);
}

75
zsw-erp/src/main/java/com/zsw/erp/service/account/AccountComponent.java

@ -1,75 +0,0 @@
package com.zsw.erp.service.account;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.service.ICommonQuery;
import com.zsw.erp.utils.Constants;
import com.zsw.erp.utils.QueryUtils;
import com.zsw.erp.utils.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Service(value = "account_component")
@AccountResource
public class AccountComponent implements ICommonQuery {
@Resource
private AccountService accountService;
@Override
public Object selectOne(Long id) throws Exception {
return accountService.getAccount(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getAccountList(map);
}
private List<?> getAccountList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String serialNo = StringUtil.getInfo(search, "serialNo");
String remark = StringUtil.getInfo(search, "remark");
String order = QueryUtils.order(map);
return accountService.select(name, serialNo, remark, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String serialNo = StringUtil.getInfo(search, "serialNo");
String remark = StringUtil.getInfo(search, "remark");
return accountService.countAccount(name, serialNo, remark);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request) throws Exception{
return accountService.insertAccount(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return accountService.updateAccount(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return accountService.deleteAccount(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return accountService.batchDeleteAccount(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return accountService.checkIsNameExist(id, name);
}
}

13
zsw-erp/src/main/java/com/zsw/erp/service/account/AccountResource.java

@ -1,13 +0,0 @@
package com.zsw.erp.service.account;
import com.zsw.erp.service.ResourceInfo;
import java.lang.annotation.*;
@ResourceInfo(value = "account")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface AccountResource {
}

575
zsw-erp/src/main/java/com/zsw/erp/service/account/AccountService.java

@ -1,575 +0,0 @@
package com.zsw.erp.service.account;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.constants.ExceptionConstants;
import com.zsw.erp.datasource.vo.AccountVo4InOutList;
import com.zsw.erp.datasource.vo.AccountVo4List;
import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.utils.Tools;
import com.zsw.erp.datasource.entities.*;
import com.zsw.erp.datasource.mappers.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
@Service
public class AccountService {
private Logger logger = LoggerFactory.getLogger(AccountService.class);
@Resource
private AccountMapper accountMapper;
@Resource
private AccountMapperEx accountMapperEx;
@Resource
private DepotHeadMapper depotHeadMapper;
@Resource
private DepotHeadMapperEx depotHeadMapperEx;
@Resource
private AccountHeadMapper accountHeadMapper;
@Resource
private AccountHeadMapperEx accountHeadMapperEx;
@Resource
private AccountItemMapper accountItemMapper;
@Resource
private AccountItemMapperEx accountItemMapperEx;
@Resource
private LogService logService;
@Resource
private UserService userService;
public Account getAccount(long id) throws Exception{
return accountMapper.selectByPrimaryKey(id);
}
public List<Account> getAccountListByIds(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
List<Account> list = new ArrayList<>();
try{
AccountExample example = new AccountExample();
example.createCriteria().andIdIn(idList);
list = accountMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<Account> getAccount() throws Exception{
AccountExample example = new AccountExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Account> list=null;
try{
list=accountMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<Account> getAccountByParam(String name, String serialNo) {
List<Account> list=null;
try{
list=accountMapperEx.getAccountByParam(name, serialNo);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<AccountVo4List> select(String name, String serialNo, String remark, int offset, int rows) throws Exception{
List<AccountVo4List> resList = new ArrayList<AccountVo4List>();
List<AccountVo4List> list=null;
try{
list = accountMapperEx.selectByConditionAccount(name, serialNo, remark, offset, rows);
}catch(Exception e){
BoomException.readFail(e);
}
String timeStr = Tools.getCurrentMonth();
if (null != list && null !=timeStr) {
for (AccountVo4List al : list) {
DecimalFormat df = new DecimalFormat(".##");
BigDecimal thisMonthAmount = getAccountSum(al.getId(), timeStr, "month").add(getAccountSumByHead(al.getId(), timeStr, "month")).add(getAccountSumByDetail(al.getId(), timeStr, "month")).add(getManyAccountSum(al.getId(), timeStr, "month"));
String thisMonthAmountFmt = "0";
if ((thisMonthAmount.compareTo(BigDecimal.ZERO))!=0) {
thisMonthAmountFmt = df.format(thisMonthAmount);
}
al.setThisMonthAmount(thisMonthAmountFmt); //本月发生额
BigDecimal currentAmount = getAccountSum(al.getId(), "", "month").add(getAccountSumByHead(al.getId(), "", "month")).add(getAccountSumByDetail(al.getId(), "", "month")).add(getManyAccountSum(al.getId(), "", "month")) .add(al.getInitialAmount()) ;
al.setCurrentAmount(currentAmount);
resList.add(al);
}
}
return resList;
}
public Long countAccount(String name, String serialNo, String remark)throws Exception {
Long result=null;
try{
result=accountMapperEx.countsByAccount(name, serialNo, remark);
}catch(Exception e){
BoomException.readFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertAccount(JSONObject obj, HttpServletRequest request)throws Exception {
Account account = JSONObject.parseObject(obj.toJSONString(), Account.class);
if(account.getInitialAmount() == null) {
account.setInitialAmount(BigDecimal.ZERO);
}
account.setIsDefault(false);
int result=0;
try{
result = accountMapper.insertSelective(account);
logService.insertLog("账户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(account.getName()).toString(), request);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAccount(JSONObject obj, HttpServletRequest request)throws Exception {
Account account = JSONObject.parseObject(obj.toJSONString(), Account.class);
int result=0;
try{
result = accountMapper.updateByPrimaryKeySelective(account);
logService.insertLog("账户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(account.getName()).toString(), request);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteAccount(Long id, HttpServletRequest request) throws Exception{
return batchDeleteAccountByIds(id.toString());
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccount(String ids, HttpServletRequest request)throws Exception {
return batchDeleteAccountByIds(ids);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountByIds(String ids) throws Exception{
int result=0;
String [] idArray=ids.split(",");
//校验财务主表 jsh_accounthead
List<AccountHead> accountHeadList=null;
try{
accountHeadList = accountHeadMapperEx.getAccountHeadListByAccountIds(idArray);
}catch(Exception e){
BoomException.readFail(e);
}
if(accountHeadList!=null&&accountHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
}
//校验财务子表 jsh_accountitem
List<AccountItem> accountItemList=null;
try{
accountItemList = accountItemMapperEx.getAccountItemListByAccountIds(idArray);
}catch(Exception e){
BoomException.readFail(e);
}
if(accountItemList!=null&&accountItemList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
}
//校验单据主表 jsh_depot_head
List<DepotHead> depotHeadList =null;
try{
depotHeadList = depotHeadMapperEx.getDepotHeadListByAccountIds(idArray);
}catch(Exception e){
BoomException.readFail(e);
}
if(depotHeadList!=null&&depotHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
}
//记录日志
StringBuffer sb = new StringBuffer();
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
List<Account> list = getAccountListByIds(ids);
for(Account account: list){
sb.append("[").append(account.getName()).append("]");
}
logService.insertLog("账户", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
//校验通过执行删除操作
try{
result = accountMapperEx.batchDeleteAccountByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
AccountExample example = new AccountExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Account> list=null;
try{
list = accountMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list==null?0:list.size();
}
public List<Account> findBySelect()throws Exception {
AccountExample example = new AccountExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id desc");
List<Account> list=null;
try{
list = accountMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
/**
* 单个账户的金额求和-入库和出库
*
* @param id
* @return
*/
public BigDecimal getAccountSum(Long id, String timeStr, String type) throws Exception{
BigDecimal accountSum = BigDecimal.ZERO;
try {
DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
if (type.equals("month")) {
example.createCriteria().andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款")
.andOperTimeGreaterThanOrEqualTo(bTime).andOperTimeLessThanOrEqualTo(eTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else if (type.equals("date")) {
example.createCriteria().andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款")
.andOperTimeLessThanOrEqualTo(mTime).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
} else {
example.createCriteria().andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款")
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
List<DepotHead> dataList=null;
try{
dataList = depotHeadMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
if (dataList != null) {
for (DepotHead depotHead : dataList) {
if(depotHead.getChangeAmount()!=null) {
accountSum = accountSum .add(depotHead.getChangeAmount()) ;
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-收入支出转账的单据表头的合计
*
* @param id
* @return
*/
public BigDecimal getAccountSumByHead(Long id, String timeStr, String type) throws Exception{
BigDecimal accountSum = BigDecimal.ZERO;
try {
AccountHeadExample example = new AccountHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
if (type.equals("month")) {
example.createCriteria().andAccountIdEqualTo(id)
.andBillTimeGreaterThanOrEqualTo(bTime).andBillTimeLessThanOrEqualTo(eTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else if (type.equals("date")) {
example.createCriteria().andAccountIdEqualTo(id)
.andBillTimeLessThanOrEqualTo(mTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
} else {
example.createCriteria().andAccountIdEqualTo(id)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
List<AccountHead> dataList=null;
try{
dataList = accountHeadMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
if (dataList != null) {
for (AccountHead accountHead : dataList) {
if(accountHead.getChangeAmount()!=null) {
accountSum = accountSum.add(accountHead.getChangeAmount());
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-收款付款转账收预付款的单据明细的合计
*
* @param id
* @return
*/
public BigDecimal getAccountSumByDetail(Long id, String timeStr, String type)throws Exception {
BigDecimal accountSum =BigDecimal.ZERO ;
try {
AccountHeadExample example = new AccountHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
if (type.equals("month")) {
example.createCriteria().andBillTimeGreaterThanOrEqualTo(bTime).andBillTimeLessThanOrEqualTo(eTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else if (type.equals("date")) {
example.createCriteria().andBillTimeLessThanOrEqualTo(mTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
}
List<AccountHead> dataList=null;
try{
dataList = accountHeadMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
if (dataList != null) {
String ids = "";
for (AccountHead accountHead : dataList) {
ids = ids + accountHead.getId() + ",";
}
if (!ids.equals("")) {
ids = ids.substring(0, ids.length() - 1);
}
AccountItemExample exampleAi = new AccountItemExample();
if (!ids.equals("")) {
List<Long> idList = StringUtil.strToLongList(ids);
exampleAi.createCriteria().andAccountIdEqualTo(id).andHeaderIdIn(idList)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<AccountItem> dataListOne = accountItemMapper.selectByExample(exampleAi);
if (dataListOne != null) {
for (AccountItem accountItem : dataListOne) {
if(accountItem.getEachAmount()!=null) {
accountSum = accountSum.add(accountItem.getEachAmount());
}
}
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
} catch (Exception e) {
logger.error(">>>>>>>>>异常信息:", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-多账户的明细合计
*
* @param id
* @return
*/
public BigDecimal getManyAccountSum(Long id, String timeStr, String type)throws Exception {
BigDecimal accountSum = BigDecimal.ZERO;
try {
DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null);
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null);
if (type.equals("month")) {
example.createCriteria().andAccountIdListLike("%" +id.toString() + "%")
.andOperTimeGreaterThanOrEqualTo(bTime).andOperTimeLessThanOrEqualTo(eTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else if (type.equals("date")) {
example.createCriteria().andAccountIdListLike("%" +id.toString() + "%")
.andOperTimeLessThanOrEqualTo(mTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
} else {
example.createCriteria().andAccountIdListLike("%" +id.toString() + "%")
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
List<DepotHead> dataList=null;
try{
dataList = depotHeadMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
if (dataList != null) {
for (DepotHead depotHead : dataList) {
String accountIdList = depotHead.getAccountIdList();
String accountMoneyList = depotHead.getAccountMoneyList();
if(StringUtil.isNotEmpty(accountIdList) && StringUtil.isNotEmpty(accountMoneyList)) {
accountIdList = accountIdList.replace("[", "").replace("]", "").replace("\"", "");
accountMoneyList = accountMoneyList.replace("[", "").replace("]", "").replace("\"", "");
String[] aList = accountIdList.split(",");
String[] amList = accountMoneyList.split(",");
for (int i = 0; i < aList.length; i++) {
if (aList[i].toString().equals(id.toString())) {
if(amList!=null && amList.length>0) {
accountSum = accountSum.add(new BigDecimal(amList[i]));
}
}
}
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找信息异常", e);
}
return accountSum;
}
public List<AccountVo4InOutList> findAccountInOutList(Long accountId, Integer offset, Integer rows) throws Exception{
List<AccountVo4InOutList> list=null;
try{
list = accountMapperEx.findAccountInOutList(accountId, offset, rows);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public int findAccountInOutListCount(Long accountId) throws Exception{
int result=0;
try{
result = accountMapperEx.findAccountInOutListCount(accountId);
}catch(Exception e){
BoomException.readFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateIsDefault(Long accountId) throws Exception{
int result=0;
try{
//全部取消默认
Account allAccount = new Account();
allAccount.setIsDefault(false);
AccountExample allExample = new AccountExample();
allExample.createCriteria();
accountMapper.updateByExampleSelective(allAccount, allExample);
//给指定账户设为默认
Account account = new Account();
account.setIsDefault(true);
AccountExample example = new AccountExample();
example.createCriteria().andIdEqualTo(accountId);
accountMapper.updateByExampleSelective(account, example);
logService.insertLog("账户",BusinessConstants.LOG_OPERATION_TYPE_EDIT+accountId,
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
result = 1;
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
public Map<Long,String> getAccountMap() throws Exception {
List<Account> accountList = getAccount();
Map<Long,String> accountMap = new HashMap<>();
for(Account account : accountList){
accountMap.put(account.getId(), account.getName());
}
return accountMap;
}
public String getAccountStrByIdAndMoney(Map<Long,String> accountMap, String accountIdList, String accountMoneyList){
StringBuffer sb = new StringBuffer();
List<Long> idList = StringUtil.strToLongList(accountIdList);
List<Long> moneyList = StringUtil.strToLongList(accountMoneyList);
for (int i = 0; i < idList.size(); i++) {
Long id = idList.get(i);
BigDecimal money = BigDecimal.valueOf(moneyList.get(i)).abs();
sb.append(accountMap.get(id) + "(" + money + "元) ");
}
return sb.toString();
}
public Map<String, Object> getStatistics(String name, String serialNo) {
Map<String, Object> map = new HashMap<>();
try {
List<Account> list = getAccountByParam(name, serialNo);
String timeStr = Tools.getCurrentMonth();
BigDecimal allMonthAmount = BigDecimal.ZERO;
BigDecimal allCurrentAmount = BigDecimal.ZERO;
if (null != list && null !=timeStr) {
for (Account a : list) {
BigDecimal monthAmount = getAccountSum(a.getId(), timeStr, "month").add(getAccountSumByHead(a.getId(), timeStr, "month"))
.add(getAccountSumByDetail(a.getId(), timeStr, "month")).add(getManyAccountSum(a.getId(), timeStr, "month"));
BigDecimal currentAmount = getAccountSum(a.getId(), "", "month").add(getAccountSumByHead(a.getId(), "", "month"))
.add(getAccountSumByDetail(a.getId(), "", "month")).add(getManyAccountSum(a.getId(), "", "month")).add(a.getInitialAmount());
allMonthAmount = allMonthAmount.add(monthAmount);
allCurrentAmount = allCurrentAmount.add(currentAmount);
}
}
map.put("allCurrentAmount", priceFormat(allCurrentAmount)); //当前总金额
map.put("allMonthAmount", priceFormat(allMonthAmount)); //本月发生额
} catch (Exception e) {
BoomException.readFail(e);
}
return map;
}
/**
* 价格格式化
* @param price
* @return
*/
private String priceFormat(BigDecimal price) {
String priceFmt = "0";
DecimalFormat df = new DecimalFormat(".##");
if ((price.compareTo(BigDecimal.ZERO))!=0) {
priceFmt = df.format(price);
}
return priceFmt;
}
}

15
zsw-erp/src/main/java/com/zsw/erp/service/accountHead/AccountHeadService.java

@ -1,5 +1,7 @@
package com.zsw.erp.service.accountHead;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.constants.ExceptionConstants;
@ -12,13 +14,11 @@ import com.zsw.erp.service.accountItem.AccountItemService;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.orgaUserRel.OrgaUserRelService;
import com.zsw.erp.service.supplier.SupplierService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.utils.Tools;
import com.zsw.erp.datasource.entities.AccountHead;
import com.zsw.erp.datasource.entities.AccountHeadExample;
import com.zsw.erp.datasource.entities.AccountHeadVo4ListEx;
import com.zsw.erp.datasource.entities.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@ -46,8 +46,7 @@ public class AccountHeadService {
private OrgaUserRelService orgaUserRelService;
@Resource
private AccountItemService accountItemService;
@Resource
private UserService userService;
@Resource
private SupplierService supplierService;
@Resource
@ -139,7 +138,7 @@ public class AccountHeadService {
*/
private String[] getCreatorArray(String roleType) throws Exception {
String creator = "";
User user = userService.getCurrentUser();
LoginUser user = SecurityFrameworkUtils.getLoginUser();
if(BusinessConstants.ROLE_TYPE_PRIVATE.equals(roleType)) {
creator = user.getId().toString();
} else if(BusinessConstants.ROLE_TYPE_THIS_ORG.equals(roleType)) {
@ -157,7 +156,7 @@ public class AccountHeadService {
AccountHead accountHead = JSONObject.parseObject(obj.toJSONString(), AccountHead.class);
int result=0;
try{
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
accountHead.setCreator(userInfo==null?null:userInfo.getId());
result = accountHeadMapper.insertSelective(accountHead);
logService.insertLog("财务",
@ -204,7 +203,7 @@ public class AccountHeadService {
String.format(ExceptionConstants.ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_MSG));
}
}
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
String [] idArray=ids.split(",");
//删除主表
accountItemMapperEx.batchDeleteAccountItemByHeadIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
@ -263,7 +262,7 @@ public class AccountHeadService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception {
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
accountHead.setCreator(userInfo==null?null:userInfo.getId());
accountHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT);
accountHeadMapper.insertSelective(accountHead);

13
zsw-erp/src/main/java/com/zsw/erp/service/accountItem/AccountItemService.java

@ -1,12 +1,14 @@
package com.zsw.erp.service.accountItem;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.constants.ExceptionConstants;
import com.zsw.erp.datasource.entities.AccountItem;
import com.zsw.erp.datasource.entities.AccountItemExample;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.mappers.AccountItemMapper;
import com.zsw.erp.datasource.mappers.AccountItemMapperEx;
import com.zsw.erp.datasource.vo.AccountItemVo4List;
@ -14,7 +16,6 @@ import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.depotHead.DepotHeadService;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -39,8 +40,7 @@ public class AccountItemService {
private AccountItemMapperEx accountItemMapperEx;
@Resource
private LogService logService;
@Resource
private UserService userService;
@Resource
private DepotHeadService depotHeadService;
@ -245,11 +245,12 @@ public class AccountItemService {
logService.insertLog("财务明细",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result = accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
result = accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),loginUser.getId(),idArray);
}catch(Exception e){
BoomException.writeFail(e);
}

30
zsw-erp/src/main/java/com/zsw/erp/service/depot/DepotService.java

@ -1,5 +1,7 @@
package com.zsw.erp.service.depot;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -14,8 +16,6 @@ import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.systemConfig.SystemConfigService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.service.userBusiness.UserBusinessService;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.datasource.entities.*;
import org.slf4j.Logger;
@ -38,12 +38,10 @@ public class DepotService extends ServiceImpl<DepotMapper, Depot> {
private DepotMapper depotMapper;
@Resource
private DepotMapperEx depotMapperEx;
@Resource
private UserService userService;
@Resource
private SystemConfigService systemConfigService;
@Resource
private UserBusinessService userBusinessService;
@Resource
private LogService logService;
@Resource
@ -121,23 +119,6 @@ public class DepotService extends ServiceImpl<DepotMapper, Depot> {
depot.setType(0);
depot.setIsDefault(false);
result=depotMapper.insert(depot);
//新增仓库时给当前用户自动授权
Long userId = userService.getUserId(request);
Long depotId = getIdByName(depot.getName());
//String ubKey = "[" + depotId + "]";
UserBusiness ubInfo = userBusinessService.getBasicData(userId, "UserDepot");
if(ubInfo == null) {
ubInfo = new UserBusiness();
ubInfo.setType("UserDepot");
ubInfo.setKeyId(userId.toString());
ArrayList<Number> l = Lists.newArrayList();
l.add(depotId);
ubInfo.setValue(l);
userBusinessService.insertUserBusiness(ubInfo, request);
} else {
ubInfo.getValue().add(depotId);
userBusinessService.updateUserBusiness(ubInfo, request);
}
logService.insertLog("仓库",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depot.getName()).toString(), request);
}catch(Exception e){
@ -196,7 +177,7 @@ public class DepotService extends ServiceImpl<DepotMapper, Depot> {
}
logService.insertLog("仓库", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
//校验通过执行删除操作
try{
result = depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
@ -274,7 +255,6 @@ public class DepotService extends ServiceImpl<DepotMapper, Depot> {
public JSONArray findDepotByCurrentUser() throws Exception {
JSONArray arr = new JSONArray();
String type = "UserDepot";
Long userId = userService.getCurrentUser().getId();
List<Depot> dataList = findUserDepot();
//开始拼接json数据
if (null != dataList) {

50
zsw-erp/src/main/java/com/zsw/erp/service/depotHead/DepotHeadService.java

@ -1,5 +1,9 @@
package com.zsw.erp.service.depotHead;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zsw.erp.constants.BusinessConstants;
@ -14,7 +18,6 @@ import com.zsw.erp.datasource.vo.DepotHeadVo4List;
import com.zsw.erp.datasource.vo.DepotHeadVo4StatementAccount;
import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.account.AccountService;
import com.zsw.erp.service.accountItem.AccountItemService;
import com.zsw.erp.service.depot.DepotService;
import com.zsw.erp.service.depotItem.DepotItemService;
@ -24,8 +27,6 @@ import com.zsw.erp.service.person.PersonService;
import com.zsw.erp.service.redis.RedisService;
import com.zsw.erp.service.serialNumber.SerialNumberService;
import com.zsw.erp.service.supplier.SupplierService;
import com.zsw.erp.service.tenant.TenantService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.utils.Tools;
import org.slf4j.Logger;
@ -58,9 +59,6 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
@Resource
private DepotHeadMapperEx depotHeadMapperEx;
@Resource
private UserService userService;
@Resource
private DepotService depotService;
@ -80,7 +78,8 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
private PersonService personService;
@Resource
private AccountService accountService;
private TenantService tenantService;
@Resource
@Lazy
@ -95,8 +94,6 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
@Resource
private RedisService redisService;
@Resource
private TenantService tenantService;
public DepotHead getDepotHead(long id) throws Exception {
DepotHead result = null;
@ -130,17 +127,17 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
String[] creatorArray = getCreatorArray(roleType);
String[] statusArray = StringUtil.isNotEmpty(status) ? status.split(",") : null;
Map<Long, String> personMap = personService.getPersonMap();
Map<Long, String> accountMap = accountService.getAccountMap();
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime, BusinessConstants.DAY_LAST_TIME);
list = depotHeadMapperEx.selectByConditionDepotHead(type, subType, creatorArray, statusArray, number, linkNumber, beginTime, endTime,
materialParam, organId, creator, depotId, depotArray, offset, rows,startTime);
if (null != list) {
for (DepotHeadVo4List dh : list) {
if (accountMap != null && StringUtil.isNotEmpty(dh.getAccountIdList()) && StringUtil.isNotEmpty(dh.getAccountMoneyList())) {
String accountStr = accountService.getAccountStrByIdAndMoney(accountMap, dh.getAccountIdList(), dh.getAccountMoneyList());
dh.setAccountName(accountStr);
}
// 这段代码是什么意思 单据全表
// if (accountMap != null && StringUtil.isNotEmpty(dh.getAccountIdList()) && StringUtil.isNotEmpty(dh.getAccountMoneyList())) {
// String accountStr = accountService.getAccountStrByIdAndMoney(accountMap, dh.getAccountIdList(), dh.getAccountMoneyList());
// dh.setAccountName(accountStr);
// }
if (dh.getAccountIdList() != null) {
String accountidlistStr = dh.getAccountIdList().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setAccountIdList(accountidlistStr);
@ -229,7 +226,7 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
*/
public String getCreatorByRoleType(String roleType) {
String creator = "";
User user = userService.getCurrentUser();
LoginUser user = SecurityFrameworkUtils.getLoginUser();
if (BusinessConstants.ROLE_TYPE_PRIVATE.equals(roleType)) {
creator = user.getId().toString();
} else if (BusinessConstants.ROLE_TYPE_THIS_ORG.equals(roleType)) {
@ -294,7 +291,7 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
sb.append("[").append(depotHead.getNumber()).append("]");
//只有未审核的单据才能被删除
if ("0".equals(depotHead.getStatus())) {
User userInfo = userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
//删除出库数据回收序列号
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
&& !BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubType())) {
@ -366,7 +363,7 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotHeadByIds(String ids) throws Exception {
User userInfo = userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
String[] idArray = ids.split(",");
int result = 0;
try {
@ -654,14 +651,14 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
List<DepotHeadVo4List> list = null;
try {
Map<Long, String> personMap = personService.getPersonMap();
Map<Long, String> accountMap = accountService.getAccountMap();
list = depotHeadMapperEx.getDetailByNumber(number);
if (null != list) {
for (DepotHeadVo4List dh : list) {
if (accountMap != null && StringUtil.isNotEmpty(dh.getAccountIdList()) && StringUtil.isNotEmpty(dh.getAccountMoneyList())) {
String accountStr = accountService.getAccountStrByIdAndMoney(accountMap, dh.getAccountIdList(), dh.getAccountMoneyList());
dh.setAccountName(accountStr);
}
// if (accountMap != null && StringUtil.isNotEmpty(dh.getAccountIdList()) && StringUtil.isNotEmpty(dh.getAccountMoneyList())) {
// String accountStr = accountService.getAccountStrByIdAndMoney(accountMap, dh.getAccountIdList(), dh.getAccountMoneyList());
// dh.setAccountName(accountStr);
// }
if (dh.getAccountIdList() != null) {
String accountidlistStr = dh.getAccountIdList().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setAccountIdList(accountidlistStr);
@ -681,7 +678,8 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
}
dh.setOperTimeStr(getCenternTime(dh.getOperTime()));
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
dh.setCreatorName(userService.getUser(dh.getCreator()).getUsername());
LoginUser user = SecurityFrameworkUtils.getLoginUser();
dh.setCreatorName(user.getUsername());
resList.add(dh);
}
}
@ -719,7 +717,7 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
}
}
//判断用户是否已经登录过,登录过不再处理
User userInfo = userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
depotHead.setCreator(userInfo == null ? null : userInfo.getId());
depotHead.setCreateTime(new Timestamp(System.currentTimeMillis()));
depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT);
@ -742,8 +740,8 @@ public class DepotHeadService extends ServiceImpl<DepotHeadMapper, DepotHead> {
// 租户供应链订单
if (depotHead.getTargetType()){
// 将发起人设置为 租户编号
Tenant tenant = tenantService.getTenant(depotHead.getOrganId());
depotHead.setOrganId(tenant.getTenantId());
TenantDO tenant = tenantService.getTenant(depotHead.getOrganId());
depotHead.setOrganId(tenant.getId());
}
try {

8
zsw-erp/src/main/java/com/zsw/erp/service/depotItem/DepotItemService.java

@ -1,6 +1,8 @@
package com.zsw.erp.service.depotItem;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -22,7 +24,6 @@ import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.material.MaterialService;
import com.zsw.erp.service.serialNumber.SerialNumberService;
import com.zsw.erp.service.systemConfig.SystemConfigService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.utils.QueryUtils;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.utils.Tools;
@ -61,8 +62,7 @@ public class DepotItemService {
private DepotHeadMapper depotHeadMapper;
@Resource
SerialNumberService serialNumberService;
@Resource
private UserService userService;
@Resource
private SystemConfigService systemConfigService;
@Resource
@ -323,7 +323,7 @@ public class DepotItemService {
//查询单据主表信息
DepotHead depotHead = depotHeadMapper.selectByPrimaryKey(headerId);
//获得当前操作人
User userInfo = userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
//首先回收序列号,如果是调拨,不用处理序列号
// 如果是出库 计算当前出库的加权金额 用于后续统计和扣除金额 。
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())

73
zsw-erp/src/main/java/com/zsw/erp/service/functions/FunctionComponent.java

@ -1,73 +0,0 @@
package com.zsw.erp.service.functions;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.service.ICommonQuery;
import com.zsw.erp.utils.Constants;
import com.zsw.erp.utils.QueryUtils;
import com.zsw.erp.utils.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Service(value = "function_component")
@FunctionResource
public class FunctionComponent implements ICommonQuery {
@Resource
private FunctionService functionService;
@Override
public Object selectOne(Long id) throws Exception {
return functionService.getFunction(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getFunctionsList(map);
}
private List<?> getFunctionsList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type");
String order = QueryUtils.order(map);
return functionService.select(name, type, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type");
return functionService.countFunction(name, type);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return functionService.insertFunction(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return functionService.updateFunction(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return functionService.deleteFunction(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return functionService.batchDeleteFunction(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return functionService.checkIsNameExist(id, name);
}
}

13
zsw-erp/src/main/java/com/zsw/erp/service/functions/FunctionResource.java

@ -1,13 +0,0 @@
package com.zsw.erp.service.functions;
import com.zsw.erp.service.ResourceInfo;
import java.lang.annotation.*;
@ResourceInfo(value = "function")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface FunctionResource {
}

211
zsw-erp/src/main/java/com/zsw/erp/service/functions/FunctionService.java

@ -1,211 +0,0 @@
package com.zsw.erp.service.functions;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.datasource.entities.Function;
import com.zsw.erp.datasource.entities.FunctionExample;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.mappers.FunctionMapper;
import com.zsw.erp.datasource.mappers.FunctionMapperEx;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class FunctionService {
private Logger logger = LoggerFactory.getLogger(FunctionService.class);
@Resource
private FunctionMapper functionsMapper;
@Resource
private FunctionMapperEx functionMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
public Function getFunction(long id)throws Exception {
Function result=null;
try{
result=functionsMapper.selectByPrimaryKey(id);
}catch(Exception e){
BoomException.readFail(e);
}
return result;
}
public List<Function> getFunctionListByIds(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
List<Function> list = new ArrayList<>();
try{
FunctionExample example = new FunctionExample();
example.createCriteria().andIdIn(idList);
list = functionsMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<Function> getFunction()throws Exception {
FunctionExample example = new FunctionExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Function> list=null;
try{
list=functionsMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<Function> select(String name, String type, int offset, int rows)throws Exception {
List<Function> list=null;
try{
list= functionMapperEx.selectByConditionFunction(name, type, offset, rows);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public Long countFunction(String name, String type)throws Exception {
Long result=null;
try{
result= functionMapperEx.countsByFunction(name, type);
}catch(Exception e){
BoomException.readFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertFunction(JSONObject obj, HttpServletRequest request)throws Exception {
Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class);
int result=0;
try{
result=functionsMapper.insert(functions);
logService.insertLog("功能",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(functions.getName()).toString(),request);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateFunction(JSONObject obj, HttpServletRequest request) throws Exception{
Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class);
int result=0;
try{
result=functionsMapper.updateByPrimaryKeySelective(functions);
logService.insertLog("功能",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(functions.getName()).toString(), request);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteFunction(Long id, HttpServletRequest request)throws Exception {
return batchDeleteFunctionByIds(id.toString());
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteFunction(String ids, HttpServletRequest request)throws Exception {
return batchDeleteFunctionByIds(ids);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteFunctionByIds(String ids)throws Exception {
StringBuffer sb = new StringBuffer();
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
List<Function> list = getFunctionListByIds(ids);
for(Function functions: list){
sb.append("[").append(functions.getName()).append("]");
}
logService.insertLog("功能", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result = functionMapperEx.batchDeleteFunctionByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
FunctionExample example = new FunctionExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Function> list=null;
try{
list = functionsMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list==null?0:list.size();
}
// 菜单到下级菜单
public List<Function> getRoleFunction(String pNumber)throws Exception {
FunctionExample example = new FunctionExample();
example.createCriteria()
.andEnabledEqualTo(true)
.andParentNumberEqualTo(pNumber)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort");
List<Function> list=null;
try{
list = functionsMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<Function> findRoleFunction(String pnumber)throws Exception{
FunctionExample example = new FunctionExample();
example.createCriteria().andEnabledEqualTo(true).andParentNumberEqualTo(pnumber)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort");
List<Function> list=null;
try{
list =functionsMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<Function> findByIds(List<Long> functionsIds)throws Exception{
FunctionExample example = new FunctionExample();
example.createCriteria().andEnabledEqualTo(true).andIdIn(functionsIds).andPushBtnIsNotNull().andPushBtnNotEqualTo("")
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort asc");
List<Function> list=null;
try{
list =functionsMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
}

9
zsw-erp/src/main/java/com/zsw/erp/service/inOutItem/InOutItemService.java

@ -9,12 +9,12 @@ import com.zsw.erp.datasource.mappers.InOutItemMapperEx;
import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.datasource.entities.AccountItem;
import com.zsw.erp.datasource.entities.InOutItem;
import com.zsw.erp.datasource.entities.InOutItemExample;
import com.zsw.erp.datasource.entities.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@ -37,8 +37,7 @@ public class InOutItemService {
@Resource
private InOutItemMapperEx inOutItemMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
@Resource
@ -163,7 +162,7 @@ public class InOutItemService {
}
logService.insertLog("收支项目", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
try{
result=inOutItemMapperEx.batchDeleteInOutItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){

9
zsw-erp/src/main/java/com/zsw/erp/service/inventorySeason/InventorySeasonService.java

@ -12,9 +12,9 @@ import com.zsw.erp.datasource.entities.MaterialInitialStock;
import com.zsw.erp.datasource.mappers.InventorySeasonMapper;
import com.zsw.erp.datasource.mappers.MaterialInitialStockMapper;
import com.zsw.erp.service.materialCurrentStock.MaterialCurrentStockService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.erp.utils.Constants;
import com.zsw.erp.utils.LocalUser;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
@ -36,8 +36,6 @@ public class InventorySeasonService extends ServiceImpl<InventorySeasonMapper, I
@Autowired
MaterialCurrentStockService materialCurrentStockService;
@Autowired
UserService userService;
// 获取当前期次
public InventorySeason getNow(){
@ -49,7 +47,8 @@ public class InventorySeasonService extends ServiceImpl<InventorySeasonMapper, I
InventorySeason seasion = this.getOne(wrap,false);
if (seasion == null){
seasion = new InventorySeason();
seasion.setCreator(LocalUser.getUserId());
seasion.setCreator(SecurityFrameworkUtils.getLoginUserId());
seasion.setBatch("系统期初");
seasion.setStartTime(LocalDateTimeUtil.parse("2020-01-01 00:00:00","yyyy-MM-dd HH:mm:ss"));
seasion.setDeleteFlag("0");

33
zsw-erp/src/main/java/com/zsw/erp/service/log/LogService.java

@ -1,20 +1,20 @@
package com.zsw.erp.service.log;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.datasource.entities.Log;
import com.zsw.erp.datasource.entities.LogExample;
import com.zsw.erp.datasource.mappers.LogMapper;
import com.zsw.erp.datasource.mappers.ErpLogMapper;
import com.zsw.erp.datasource.mappers.LogMapperEx;
import com.zsw.erp.datasource.vo.LogVo4List;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.redis.RedisService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.utils.Tools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -29,14 +29,11 @@ import static com.zsw.erp.utils.Tools.getLocalIp;
public class LogService {
private Logger logger = LoggerFactory.getLogger(LogService.class);
@Resource
private LogMapper logMapper;
private ErpLogMapper erpLogMapper;
@Resource
private LogMapperEx logMapperEx;
@Resource
@Lazy
private UserService userService;
@Resource
private RedisService redisService;
@ -44,7 +41,7 @@ public class LogService {
public Log getLog(long id)throws Exception {
Log result=null;
try{
result=logMapper.selectByPrimaryKey(id);
result= erpLogMapper.selectByPrimaryKey(id);
}catch(Exception e){
BoomException.readFail(e);
}
@ -55,7 +52,7 @@ public class LogService {
LogExample example = new LogExample();
List<Log> list=null;
try{
list=logMapper.selectByExample(example);
list= erpLogMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
@ -99,7 +96,7 @@ public class LogService {
Log log = JSONObject.parseObject(obj.toJSONString(), Log.class);
int result=0;
try{
result=logMapper.insertSelective(log);
result= erpLogMapper.insertSelective(log);
}catch(Exception e){
BoomException.writeFail(e);
}
@ -111,7 +108,7 @@ public class LogService {
Log log = JSONObject.parseObject(obj.toJSONString(), Log.class);
int result=0;
try{
result=logMapper.updateByPrimaryKeySelective(log);
result= erpLogMapper.updateByPrimaryKeySelective(log);
}catch(Exception e){
BoomException.writeFail(e);
}
@ -122,7 +119,7 @@ public class LogService {
public int deleteLog(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
result=logMapper.deleteByPrimaryKey(id);
result= erpLogMapper.deleteByPrimaryKey(id);
}catch(Exception e){
BoomException.writeFail(e);
}
@ -136,7 +133,7 @@ public class LogService {
example.createCriteria().andIdIn(idList);
int result=0;
try{
result=logMapper.deleteByExample(example);
result= erpLogMapper.deleteByExample(example);
}catch(Exception e){
BoomException.writeFail(e);
}
@ -145,8 +142,8 @@ public class LogService {
public void insertLog(String moduleName, String content, HttpServletRequest request) {
try{
Long userId = userService.getUserId(request);
if(userId!=null) {
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
if(userInfo!=null) {
String clientIp = getLocalIp(request);
String createTime = Tools.getNow3();
Long count = logMapperEx.getCountByIpAndDate(moduleName, clientIp, createTime);
@ -155,14 +152,14 @@ public class LogService {
redisService.deleteObjectByKeyAndIp("clientIp", clientIp, "userId");
} else {
Log log = new Log();
log.setUserId(userId);
log.setUserId(userInfo.getId());
log.setOperation(moduleName);
log.setClientIp(getLocalIp(request));
log.setCreateTime(new Date());
Byte status = 0;
log.setStatus(status);
log.setContent(content);
logMapper.insertSelective(log);
erpLogMapper.insertSelective(log);
}
}
}catch(Exception e){
@ -182,7 +179,7 @@ public class LogService {
log.setStatus(status);
log.setContent(content);
log.setTenantId(tenantId);
logMapper.insertSelective(log);
erpLogMapper.insertSelective(log);
}
}catch(Exception e){
BoomException.writeFail(e);

13
zsw-erp/src/main/java/com/zsw/erp/service/material/MaterialService.java

@ -5,6 +5,8 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -26,7 +28,6 @@ import com.zsw.erp.service.materialCategory.MaterialCategoryService;
import com.zsw.erp.service.redis.RedisService;
import com.zsw.erp.service.sequence.SequenceService;
import com.zsw.erp.service.unit.UnitService;
import com.zsw.erp.service.user.UserService;
import com.zsw.base.R;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.datasource.entities.*;
@ -64,8 +65,6 @@ public class MaterialService {
@Resource
private LogService logService;
@Resource
private UserService userService;
@Resource
private DepotItemMapperEx depotItemMapperEx;
@Resource
@Lazy
@ -340,7 +339,7 @@ public class MaterialService {
}
logService.insertLog("商品", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo = userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
//校验通过执行删除操作
try {
//逻辑删除商品
@ -676,7 +675,7 @@ public class MaterialService {
materialMapper.updateByPrimaryKeySelective(material);
}
//给商品新增条码与价格相关信息
User user = userService.getCurrentUser();
LoginUser user = SecurityFrameworkUtils.getLoginUser();
JSONObject materialExObj = m.getMaterialExObj();
if (StringUtil.isExist(materialExObj.get("basic"))) {
String basicStr = materialExObj.getString("basic");
@ -685,8 +684,8 @@ public class MaterialService {
basicMaterialExtend.setDefaultFlag("1");
basicMaterialExtend.setCreateTime(new Date());
basicMaterialExtend.setUpdateTime(System.currentTimeMillis());
basicMaterialExtend.setCreateSerial(user.getLoginName());
basicMaterialExtend.setUpdateSerial(user.getLoginName());
basicMaterialExtend.setCreateSerial(user.getUsername());
basicMaterialExtend.setUpdateSerial(user.getUsername());
Long meId = materialExtendService.selectIdByMaterialIdAndDefaultFlag(mId, "1");
if (meId == 0L) {
materialExtendMapper.insertSelective(basicMaterialExtend);

13
zsw-erp/src/main/java/com/zsw/erp/service/materialCategory/MaterialCategoryService.java

@ -10,12 +10,12 @@ import com.zsw.erp.datasource.vo.TreeNode;
import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.datasource.entities.Material;
import com.zsw.erp.datasource.entities.MaterialCategory;
import com.zsw.erp.datasource.entities.MaterialCategoryExample;
import com.zsw.erp.datasource.entities.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@ -37,8 +37,7 @@ public class MaterialCategoryService {
private MaterialCategoryMapper materialCategoryMapper;
@Resource
private MaterialCategoryMapperEx materialCategoryMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
@Resource
@ -196,7 +195,7 @@ public class MaterialCategoryService {
//更新时间
Date updateDate =new Date();
//更新人
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
Long updater=userInfo==null?null:userInfo.getId();
String strArray[]=ids.split(",");
if(strArray.length<1){
@ -280,7 +279,7 @@ public class MaterialCategoryService {
checkMaterialCategorySerialNo(mc);
//数据状态新增时默认设置为启用
Date date=new Date();
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
//创建时间
mc.setCreateTime(date);
//更新时间
@ -308,7 +307,7 @@ public class MaterialCategoryService {
//更新时间
mc.setUpdateTime(new Date());
//更新人
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
int result=0;
try{
result= materialCategoryMapperEx.editMaterialCategory(mc);

22
zsw-erp/src/main/java/com/zsw/erp/service/materialExtend/MaterialExtendService.java

@ -8,7 +8,7 @@ import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.constants.ExceptionConstants;
import com.zsw.erp.datasource.entities.MaterialExtend;
import com.zsw.erp.datasource.entities.MaterialExtendExample;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.mappers.MaterialExtendMapper;
import com.zsw.erp.datasource.mappers.MaterialExtendMapperEx;
import com.zsw.erp.datasource.vo.MaterialExtendVo4List;
@ -16,7 +16,8 @@ import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.redis.RedisService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -43,8 +44,7 @@ public class MaterialExtendService {
private MaterialExtendMapperEx materialExtendMapperEx;
@Resource
private LogService logService;
@Resource
private UserService userService;
@Resource
private RedisService redisService;
@ -230,12 +230,12 @@ public class MaterialExtendService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertMaterialExtend(MaterialExtend materialExtend)throws Exception {
User user = userService.getCurrentUser();
LoginUser user = SecurityFrameworkUtils.getLoginUser();
materialExtend.setDeleteFlag(BusinessConstants.DELETE_FLAG_EXISTS);
materialExtend.setCreateTime(new Date());
materialExtend.setUpdateTime(new Date().getTime());
materialExtend.setCreateSerial(user.getLoginName());
materialExtend.setUpdateSerial(user.getLoginName());
materialExtend.setCreateSerial(user.getUsername());
materialExtend.setUpdateSerial(user.getUsername());
int result =0;
try{
result= materialExtendMapper.insertSelective(materialExtend);
@ -247,9 +247,9 @@ public class MaterialExtendService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateMaterialExtend(MaterialExtend MaterialExtend) throws Exception{
User user = userService.getCurrentUser();
LoginUser user = SecurityFrameworkUtils.getLoginUser();
MaterialExtend.setUpdateTime(System.currentTimeMillis());
MaterialExtend.setUpdateSerial(user.getLoginName());
MaterialExtend.setUpdateSerial(user.getUsername());
int res =0;
try{
res= materialExtendMapper.updateByPrimaryKeySelective(MaterialExtend);
@ -292,9 +292,9 @@ public class MaterialExtendService {
materialExtend.setId(id);
materialExtend.setDeleteFlag(BusinessConstants.DELETE_FLAG_DELETED);
Long userId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userId").toString());
User user = userService.getUser(userId);
LoginUser user = SecurityFrameworkUtils.getLoginUser();
materialExtend.setUpdateTime(new Date().getTime());
materialExtend.setUpdateSerial(user.getLoginName());
materialExtend.setUpdateSerial(user.getUsername());
try{
result= materialExtendMapper.updateByPrimaryKeySelective(materialExtend);
}catch(Exception e){

10
zsw-erp/src/main/java/com/zsw/erp/service/materialProperty/MaterialPropertyService.java

@ -4,12 +4,13 @@ import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.datasource.entities.MaterialProperty;
import com.zsw.erp.datasource.entities.MaterialPropertyExample;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.mappers.MaterialPropertyMapper;
import com.zsw.erp.datasource.mappers.MaterialPropertyMapperEx;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@ -31,8 +32,7 @@ public class MaterialPropertyService {
@Resource
private MaterialPropertyMapperEx materialPropertyMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
@ -121,7 +121,7 @@ public class MaterialPropertyService {
logService.insertLog("商品属性",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
String [] idArray=ids.split(",");
int result=0;
try{

36
zsw-erp/src/main/java/com/zsw/erp/service/msg/MsgService.java

@ -6,13 +6,14 @@ import com.zsw.erp.constants.ExceptionConstants;
import com.zsw.erp.datasource.entities.Msg;
import com.zsw.erp.datasource.entities.MsgEx;
import com.zsw.erp.datasource.entities.MsgExample;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.mappers.MsgMapper;
import com.zsw.erp.datasource.mappers.MsgMapperEx;
import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.service.depotHead.DepotHeadService;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.utils.Tools;
import org.slf4j.Logger;
@ -42,8 +43,7 @@ public class MsgService {
@Resource
private DepotHeadService depotHeadService;
@Resource
private UserService userService;
@Resource
private LogService logService;
@ -79,8 +79,8 @@ public class MsgService {
public List<MsgEx> select(String name, int offset, int rows)throws Exception {
List<MsgEx> list=null;
try{
User userInfo = userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getUsername())) {
list = msgMapperEx.selectByConditionMsg(name, offset, rows);
if (null != list) {
for (MsgEx msgEx : list) {
@ -102,8 +102,8 @@ public class MsgService {
public Long countMsg(String name)throws Exception {
Long result=null;
try{
User userInfo = userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getUsername())) {
result = msgMapperEx.countsByMsg(name);
}
}catch(Exception e){
@ -120,8 +120,8 @@ public class MsgService {
Msg msg = JSONObject.parseObject(obj.toJSONString(), Msg.class);
int result=0;
try{
User userInfo = userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getUsername())) {
msg.setCreateTime(new Date());
msg.setStatus("1");
result=msgMapper.insertSelective(msg);
@ -231,8 +231,8 @@ public class MsgService {
public List<MsgEx> getMsgByStatus(String status)throws Exception {
List<MsgEx> resList=new ArrayList<>();
try{
User userInfo = userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getUsername())) {
MsgExample example = new MsgExample();
example.createCriteria().andStatusEqualTo(status).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Msg> list = msgMapper.selectByExample(example);
@ -280,8 +280,8 @@ public class MsgService {
public Long getMsgCountByStatus(String status)throws Exception {
Long result=null;
try{
User userInfo=userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getUsername())) {
result = msgMapperEx.getMsgCountByStatus(status, userInfo.getId());
}
}catch(Exception e){
@ -296,8 +296,8 @@ public class MsgService {
public Integer getMsgCountByType(String type)throws Exception {
int msgCount = 0;
try{
User userInfo = userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getUsername())) {
MsgExample example = new MsgExample();
example.createCriteria().andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Msg> list = msgMapper.selectByExample(example);
@ -315,8 +315,8 @@ public class MsgService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void readAllMsg() throws Exception{
try{
User userInfo = userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getUsername())) {
Msg msg = new Msg();
msg.setStatus("2");
MsgExample example = new MsgExample();

12
zsw-erp/src/main/java/com/zsw/erp/service/orgaUserRel/OrgaUserRelService.java

@ -4,13 +4,14 @@ import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.datasource.entities.OrgaUserRel;
import com.zsw.erp.datasource.entities.OrgaUserRelExample;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.mappers.OrgaUserRelMapper;
import com.zsw.erp.datasource.mappers.OrgaUserRelMapperEx;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.organization.OrganizationService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -37,8 +38,7 @@ public class OrgaUserRelService {
private OrgaUserRelMapper orgaUserRelMapper;
@Resource
private OrgaUserRelMapperEx orgaUserRelMapperEx;
@Resource
private UserService userService;
@Resource
private OrganizationService organizationService;
@Resource
@ -110,7 +110,7 @@ public class OrgaUserRelService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public OrgaUserRel addOrgaUserRel(OrgaUserRel orgaUserRel) throws Exception{
Date date = new Date();
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
//创建时间
if(orgaUserRel.getCreateTime()==null){
orgaUserRel.setCreateTime(date);
@ -149,7 +149,7 @@ public class OrgaUserRelService {
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public OrgaUserRel updateOrgaUserRel(OrgaUserRel orgaUserRel) throws Exception{
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
//更新时间
if(orgaUserRel.getUpdateTime()==null){
orgaUserRel.setUpdateTime(new Date());

14
zsw-erp/src/main/java/com/zsw/erp/service/organization/OrganizationService.java

@ -5,14 +5,15 @@ import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.constants.ExceptionConstants;
import com.zsw.erp.datasource.entities.Organization;
import com.zsw.erp.datasource.entities.OrganizationExample;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.mappers.OrganizationMapper;
import com.zsw.erp.datasource.mappers.OrganizationMapperEx;
import com.zsw.erp.datasource.vo.TreeNode;
import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -41,8 +42,7 @@ public class OrganizationService {
private OrganizationMapper organizationMapper;
@Resource
private OrganizationMapperEx organizationMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
@ -113,7 +113,7 @@ public class OrganizationService {
}
logService.insertLog("机构", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
String [] idArray=ids.split(",");
int result=0;
List <Organization> organList = organizationMapperEx.getOrganizationByParentIds(idArray);
@ -149,7 +149,7 @@ public class OrganizationService {
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
//新增时间
Date date=new Date();
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
org.setCreateTime(date);
//修改时间
org.setUpdateTime(date);
@ -180,7 +180,7 @@ public class OrganizationService {
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
//修改时间
org.setUpdateTime(new Date());
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
/**
* 修改的时候检测机构编号是否已存在
* */

6
zsw-erp/src/main/java/com/zsw/erp/service/person/PersonService.java

@ -10,7 +10,8 @@ import com.zsw.erp.datasource.mappers.PersonMapperEx;
import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.datasource.entities.AccountHead;
import com.zsw.erp.datasource.entities.DepotHead;
@ -36,8 +37,7 @@ public class PersonService {
@Resource
private PersonMapperEx personMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
@Resource

70
zsw-erp/src/main/java/com/zsw/erp/service/role/RoleComponent.java

@ -1,70 +0,0 @@
package com.zsw.erp.service.role;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.service.ICommonQuery;
import com.zsw.erp.utils.Constants;
import com.zsw.erp.utils.QueryUtils;
import com.zsw.erp.utils.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Service(value = "role_component")
@RoleResource
public class RoleComponent implements ICommonQuery {
@Resource
private RoleService roleService;
@Override
public Object selectOne(Long id) throws Exception {
return roleService.getRole(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getRoleList(map);
}
private List<?> getRoleList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
return roleService.select(name, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
return roleService.countRole(name);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return roleService.insertRole(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return roleService.updateRole(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return roleService.deleteRole(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return roleService.batchDeleteRole(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return roleService.checkIsNameExist(id, name);
}
}

13
zsw-erp/src/main/java/com/zsw/erp/service/role/RoleResource.java

@ -1,13 +0,0 @@
package com.zsw.erp.service.role;
import com.zsw.erp.service.ResourceInfo;
import java.lang.annotation.*;
@ResourceInfo(value = "role")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface RoleResource {
}

184
zsw-erp/src/main/java/com/zsw/erp/service/role/RoleService.java

@ -1,184 +0,0 @@
package com.zsw.erp.service.role;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.datasource.entities.Role;
import com.zsw.erp.datasource.entities.RoleExample;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.mappers.RoleMapper;
import com.zsw.erp.datasource.mappers.RoleMapperEx;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class RoleService {
private Logger logger = LoggerFactory.getLogger(RoleService.class);
@Resource
private RoleMapper roleMapper;
@Resource
private RoleMapperEx roleMapperEx;
@Resource
private LogService logService;
@Resource
private UserService userService;
public Role getRole(long id)throws Exception {
Role result=null;
try{
result=roleMapper.selectByPrimaryKey(id);
}catch(Exception e){
BoomException.readFail(e);
}
return result;
}
public List<Role> getRoleListByIds(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
List<Role> list = new ArrayList<>();
try{
RoleExample example = new RoleExample();
example.createCriteria().andIdIn(idList);
list = roleMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<Role> allList()throws Exception {
RoleExample example = new RoleExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Role> list=null;
try{
list=roleMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<Role> select(String name, int offset, int rows)throws Exception {
List<Role> list=null;
try{
list=roleMapperEx.selectByConditionRole(name, offset, rows);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public Long countRole(String name)throws Exception {
Long result=null;
try{
result=roleMapperEx.countsByRole(name);
}catch(Exception e){
BoomException.readFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertRole(JSONObject obj, HttpServletRequest request)throws Exception {
Role role = JSONObject.parseObject(obj.toJSONString(), Role.class);
int result=0;
try{
result=roleMapper.insertSelective(role);
logService.insertLog("角色",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(role.getName()).toString(), request);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateRole(JSONObject obj, HttpServletRequest request) throws Exception{
Role role = JSONObject.parseObject(obj.toJSONString(), Role.class);
int result=0;
try{
result=roleMapper.updateByPrimaryKeySelective(role);
logService.insertLog("角色",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(role.getName()).toString(), request);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteRole(Long id, HttpServletRequest request)throws Exception {
return batchDeleteRoleByIds(id.toString());
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteRole(String ids, HttpServletRequest request) throws Exception{
return batchDeleteRoleByIds(ids);
}
public int checkIsNameExist(Long id, String name) throws Exception{
RoleExample example = new RoleExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Role> list =null;
try{
list=roleMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list==null?0:list.size();
}
public List<Role> findUserRole()throws Exception{
RoleExample example = new RoleExample();
example.setOrderByClause("Id");
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Role> list=null;
try{
list=roleMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
/**
* create by: qiankunpingtai
* 逻辑删除角色信息
* create time: 2019/3/28 15:44
* @Param: ids
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteRoleByIds(String ids) throws Exception{
StringBuffer sb = new StringBuffer();
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
List<Role> list = getRoleListByIds(ids);
for(Role role: list){
sb.append("[").append(role.getName()).append("]");
}
logService.insertLog("角色", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result=roleMapperEx.batchDeleteRoleByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
}

21
zsw-erp/src/main/java/com/zsw/erp/service/serialNumber/SerialNumberService.java

@ -1,5 +1,7 @@
package com.zsw.erp.service.serialNumber;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.constants.ExceptionConstants;
@ -7,7 +9,6 @@ import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.material.MaterialService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.datasource.entities.*;
import com.zsw.erp.datasource.mappers.MaterialMapper;
@ -48,8 +49,6 @@ public class SerialNumberService {
@Resource
private MaterialService materialService;
@Resource
private UserService userService;
@Resource
private LogService logService;
@ -110,7 +109,7 @@ public class SerialNumberService {
Date date=new Date();
serialNumberEx.setCreateTime(date);
serialNumberEx.setUpdateTime(date);
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
serialNumberEx.setCreator(userInfo==null?null:userInfo.getId());
serialNumberEx.setUpdater(userInfo==null?null:userInfo.getId());
result = serialNumberMapperEx.addSerialNumber(serialNumberEx);
@ -130,7 +129,7 @@ public class SerialNumberService {
serialNumberEx.setMaterialId(getSerialNumberMaterialIdByBarCode(serialNumberEx.getMaterialCode()));
Date date=new Date();
serialNumberEx.setUpdateTime(date);
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
serialNumberEx.setUpdater(userInfo==null?null:userInfo.getId());
result = serialNumberMapperEx.updateSerialNumber(serialNumberEx);
logService.insertLog("序列号",
@ -169,7 +168,7 @@ public class SerialNumberService {
}
logService.insertLog("序列号", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
String [] idArray=ids.split(",");
int result=0;
try{
@ -265,7 +264,7 @@ public class SerialNumberService {
* @Param: List<DepotItem>
* @return void
*/
public void checkAndUpdateSerialNumber(DepotItem depotItem, String outBillNo,User userInfo, String snList) throws Exception{
public void checkAndUpdateSerialNumber(DepotItem depotItem, String outBillNo,LoginUser userInfo, String snList) throws Exception{
if(depotItem!=null){
sellSerialNumber(depotItem.getMaterialId(), outBillNo, snList,userInfo);
}
@ -285,7 +284,7 @@ public class SerialNumberService {
* @Param: Count 卖出或者赎回的数量
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int sellSerialNumber(Long materialId, String outBillNo, String snList, User user) throws Exception{
public int sellSerialNumber(Long materialId, String outBillNo, String snList, LoginUser user) throws Exception{
int result=0;
try{
String [] snArray=snList.split(",");
@ -308,7 +307,7 @@ public class SerialNumberService {
* @return com.jsh.erp.datasource.entities.SerialNumberEx
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int cancelSerialNumber(Long materialId, String outBillNo,int count,User user) throws Exception{
public int cancelSerialNumber(Long materialId, String outBillNo, int count, LoginUser user) throws Exception{
int result=0;
try{
result = serialNumberMapperEx.cancelSerialNumber(materialId,outBillNo,count,new Date(),user==null?null:user.getId());
@ -338,7 +337,7 @@ public class SerialNumberService {
Long materialId = getSerialNumberMaterialIdByBarCode(materialCode);
List<SerialNumberEx> list = null;
//当前用户
User userInfo = userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
Long userId = userInfo == null ? null : userInfo.getId();
Date date = null;
Long million = null;
@ -412,7 +411,7 @@ public class SerialNumberService {
Date date = new Date();
serialNumber.setCreateTime(date);
serialNumber.setUpdateTime(date);
User userInfo = userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
serialNumber.setCreator(userInfo == null ? null : userInfo.getId());
serialNumber.setUpdater(userInfo == null ? null : userInfo.getId());
serialNumber.setInBillNo(inBillNo);

28
zsw-erp/src/main/java/com/zsw/erp/service/supplier/SupplierService.java

@ -14,8 +14,8 @@ import com.zsw.erp.service.accountHead.AccountHeadService;
import com.zsw.erp.service.depotHead.DepotHeadService;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.systemConfig.SystemConfigService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.service.userBusiness.UserBusinessService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.base.R;
import com.zsw.erp.utils.ExcelUtils;
import com.zsw.erp.utils.StringUtil;
@ -50,8 +50,7 @@ public class SupplierService {
private SupplierMapperEx supplierMapperEx;
@Resource
private LogService logService;
@Resource
private UserService userService;
@Resource
private AccountHeadMapperEx accountHeadMapperEx;
@Resource
@ -64,8 +63,6 @@ public class SupplierService {
private AccountHeadService accountHeadService;
@Resource
private SystemConfigService systemConfigService;
@Resource
private UserBusinessService userBusinessService;
public Supplier getSupplier(long id)throws Exception {
Supplier result=null;
@ -154,23 +151,6 @@ public class SupplierService {
supplier.setEnabled(true);
result=supplierMapper.insertSelective(supplier);
//新增客户时给当前用户自动授权
if("客户".equals(supplier.getType())) {
Long userId = userService.getUserId(request);
Supplier sInfo = supplierMapperEx.getSupplierByNameAndType(supplier.getSupplier(), supplier.getType());
UserBusiness ubInfo = userBusinessService.getBasicData(userId, "UserCustomer");
if(ubInfo ==null ) {
ubInfo = new UserBusiness();
ubInfo.setType("UserCustomer");
ubInfo.setKeyId(userId.toString());
ArrayList<Number> l = Lists.newArrayList();
l.add(sInfo.getId());
ubInfo.setValue(l);
userBusinessService.insertUserBusiness(ubInfo, request);
} else {
ubInfo.getValue().add(sInfo.getId());
userBusinessService.updateUserBusiness(ubInfo, request);
}
}
logService.insertLog("商家",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(supplier.getSupplier()).toString(),request);
}catch(Exception e){
@ -248,7 +228,7 @@ public class SupplierService {
}
logService.insertLog("商家", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
//校验通过执行删除操作
try{
result = supplierMapperEx.batchDeleteSupplierByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);

50
zsw-erp/src/main/java/com/zsw/erp/service/systemConfig/SystemConfigService.java

@ -1,17 +1,17 @@
package com.zsw.erp.service.systemConfig;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.datasource.entities.SystemConfig;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.mappers.SystemConfigMapper;
import com.zsw.erp.datasource.mappers.ErpSystemConfigMapper;
import com.zsw.erp.datasource.mappers.SystemConfigMapperEx;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@ -30,25 +30,24 @@ public class SystemConfigService {
private Logger logger = LoggerFactory.getLogger(SystemConfigService.class);
@Resource
private SystemConfigMapper systemConfigMapper;
private ErpSystemConfigMapper erpSystemConfigMapper;
@Resource
private SystemConfigMapperEx systemConfigMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
public SystemConfig getSystemConfig(long id){
return systemConfigMapper.selectById(id);
return erpSystemConfigMapper.selectById(id);
}
public SystemConfig getSystemConfigByTenentId(Long tenantId){
return systemConfigMapper.selectByTenantId(tenantId);
return erpSystemConfigMapper.selectByTenantId(tenantId);
}
public List<SystemConfig> getSystemConfig(){
return systemConfigMapper.selectList(Wrappers.emptyWrapper());
return erpSystemConfigMapper.selectList(Wrappers.emptyWrapper());
}
public List<SystemConfig> select(String companyName, int offset, int rows)throws Exception {
List<SystemConfig> list=null;
@ -75,13 +74,10 @@ public class SystemConfigService {
SystemConfig systemConfig = JSONObject.parseObject(obj.toJSONString(), SystemConfig.class);
int result=0;
try{
if(userService.checkIsTestUser()) {
result=-1;
} else {
result=systemConfigMapper.insert(systemConfig);
logService.insertLog("系统配置",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(systemConfig.getCompanyName()).toString(), request);
}
// 测试用户返回-1
result= erpSystemConfigMapper.insert(systemConfig);
logService.insertLog("系统配置",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(systemConfig.getCompanyName()).toString(), request);
}catch(Exception e){
BoomException.writeFail(e);
}
@ -93,13 +89,9 @@ public class SystemConfigService {
SystemConfig systemConfig = JSONObject.parseObject(obj.toJSONString(), SystemConfig.class);
int result=0;
try{
if(userService.checkIsTestUser()) {
result=-1;
} else {
result = systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
logService.insertLog("系统配置",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(systemConfig.getCompanyName()).toString(), request);
}
result = erpSystemConfigMapper.updateByPrimaryKeySelective(systemConfig);
logService.insertLog("系统配置",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(systemConfig.getCompanyName()).toString(), request);
}catch(Exception e){
BoomException.writeFail(e);
}
@ -121,15 +113,11 @@ public class SystemConfigService {
logService.insertLog("系统配置",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
String [] idArray=ids.split(",");
int result=0;
try{
if(userService.checkIsTestUser()) {
result=-1;
} else {
result = systemConfigMapperEx.batchDeleteSystemConfigByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray);
}
result = systemConfigMapperEx.batchDeleteSystemConfigByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray);
}catch(Exception e){
BoomException.writeFail(e);
}
@ -141,7 +129,7 @@ public class SystemConfigService {
.eq(SystemConfig::getCompanyName, name)
.ne(SystemConfig::getId, id)
.eq(SystemConfig::getDepotFlag, BusinessConstants.DELETE_FLAG_EXISTS);
return systemConfigMapper.selectCount(wrappers);
return erpSystemConfigMapper.selectCount(wrappers);
}
/**

78
zsw-erp/src/main/java/com/zsw/erp/service/tenant/TenantComponent.java

@ -1,78 +0,0 @@
package com.zsw.erp.service.tenant;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.datasource.entities.Tenant;
import com.zsw.erp.service.ICommonQuery;
import com.zsw.erp.utils.Constants;
import com.zsw.erp.utils.QueryUtils;
import com.zsw.erp.utils.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Service(value = "tenant_component")
@TenantResource
public class TenantComponent implements ICommonQuery {
@Resource
private TenantService tenantService;
@Override
public Object selectOne(Long id) throws Exception {
return tenantService.getTenant(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getTenantList(map);
}
private List<?> getTenantList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String loginName = StringUtil.getInfo(search, "loginName");
String type = StringUtil.getInfo(search, "type");
String enabled = StringUtil.getInfo(search, "enabled");
return tenantService.select(loginName, type, enabled, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String loginName = StringUtil.getInfo(search, "loginName");
String type = StringUtil.getInfo(search, "type");
String enabled = StringUtil.getInfo(search, "enabled");
return tenantService.countTenant(loginName, type, enabled);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
Tenant tenant = JSONUtil.toBean(obj.toJSONString(), Tenant.class);
return tenantService.insertTenant(tenant, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
Tenant tenant = JSONUtil.toBean(obj.toJSONString(), Tenant.class);
return tenantService.updateTenant(tenant, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return tenantService.deleteTenant(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return tenantService.batchDeleteTenant(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return tenantService.checkIsNameExist(id, name);
}
}

13
zsw-erp/src/main/java/com/zsw/erp/service/tenant/TenantResource.java

@ -1,13 +0,0 @@
package com.zsw.erp.service.tenant;
import com.zsw.erp.service.ResourceInfo;
import java.lang.annotation.*;
@ResourceInfo(value = "tenant")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TenantResource {
}

182
zsw-erp/src/main/java/com/zsw/erp/service/tenant/TenantService.java

@ -1,182 +0,0 @@
package com.zsw.erp.service.tenant;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.datasource.mappers.TenantMapper;
import com.zsw.erp.datasource.mappers.TenantMapperEx;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.utils.Tools;
import com.zsw.erp.datasource.entities.Tenant;
import com.zsw.erp.datasource.entities.TenantEx;
import com.zsw.erp.datasource.entities.TenantExample;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@Service
public class TenantService {
private Logger logger = LoggerFactory.getLogger(TenantService.class);
@Resource
private TenantMapper tenantMapper;
@Resource
private TenantMapperEx tenantMapperEx;
@Resource
@Lazy
private LogService logService;
@Value("${tenant.userNumLimit}")
private Integer userNumLimit;
@Value("${tenant.tryDayLimit}")
private Integer tryDayLimit;
public Tenant getTenant(long id)throws Exception {
Tenant result=null;
try{
result=tenantMapper.selectByPrimaryKey(id);
}catch(Exception e){
BoomException.readFail(e);
}
return result;
}
public List<Tenant> getTenant(){
TenantExample example = new TenantExample();
List<Tenant> list=null;
try{
list=tenantMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<TenantEx> select(String loginName, String type, String enabled, int offset, int rows)throws Exception {
List<TenantEx> list= new ArrayList<>();
try{
list = tenantMapperEx.selectByConditionTenant(loginName, type, enabled, offset, rows);
if (null != list) {
for (TenantEx tenantEx : list) {
tenantEx.setCreateTimeStr(Tools.getCenternTime(tenantEx.getCreateTime()));
tenantEx.setExpireTimeStr(Tools.getCenternTime(tenantEx.getExpireTime()));
}
}
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public Long countTenant(String loginName, String type, String enabled)throws Exception {
Long result=null;
try{
result=tenantMapperEx.countsByTenant(loginName, type, enabled);
}catch(Exception e){
BoomException.readFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertTenant(Tenant tenant, HttpServletRequest request)throws Exception {
tenant.setCreateTime(new Date());
if(tenant.getUserNumLimit()==null) {
tenant.setUserNumLimit(userNumLimit); //默认用户限制数量
}
if(tenant.getExpireTime()==null) {
tenant.setExpireTime(Tools.addDays(new Date(), tryDayLimit)); //租户允许试用的天数
}
return tenantMapper.insert(tenant);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateTenant(Tenant tenant, HttpServletRequest request)throws Exception {
return tenantMapper.updateById(tenant);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteTenant(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
result= tenantMapper.deleteByPrimaryKey(id);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteTenant(String ids, HttpServletRequest request)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
TenantExample example = new TenantExample();
example.createCriteria().andIdIn(idList);
int result=0;
try{
result= tenantMapper.deleteByExample(example);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
TenantExample example = new TenantExample();
example.createCriteria().andIdNotEqualTo(id).andLoginNameEqualTo(name);
List<Tenant> list=null;
try{
list= tenantMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list==null?0:list.size();
}
public Tenant getTenantByTenantId(long tenantId) {
Tenant tenant = new Tenant();
TenantExample example = new TenantExample();
example.createCriteria().andTenantIdEqualTo(tenantId);
List<Tenant> list = tenantMapper.selectByExample(example);
if(list.size()>0) {
tenant = list.get(0);
}
return tenant;
}
public int batchSetStatus(Boolean status, String ids)throws Exception {
int result=0;
try{
String statusStr ="";
if(status) {
statusStr ="批量启用";
} else {
statusStr ="批量禁用";
}
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ids).append("-").append(statusStr).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
List<Long> idList = StringUtil.strToLongList(ids);
Tenant tenant = new Tenant();
tenant.setEnabled(status);
TenantExample example = new TenantExample();
example.createCriteria().andIdIn(idList);
result = tenantMapper.updateByExampleSelective(tenant, example);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
}

10
zsw-erp/src/main/java/com/zsw/erp/service/unit/UnitService.java

@ -9,12 +9,13 @@ import com.zsw.erp.datasource.mappers.UnitMapperEx;
import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.datasource.entities.Material;
import com.zsw.erp.datasource.entities.Unit;
import com.zsw.erp.datasource.entities.UnitExample;
import com.zsw.erp.datasource.entities.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@ -38,8 +39,7 @@ public class UnitService {
@Resource
private UnitMapperEx unitMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
@Resource
@ -189,7 +189,7 @@ public class UnitService {
}
logService.insertLog("计量单位", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo = userService.getCurrentUser();
LoginUser userInfo = SecurityFrameworkUtils.getLoginUser();
//校验通过执行删除操作
try {
result = unitMapperEx.batchDeleteUnitByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray);

73
zsw-erp/src/main/java/com/zsw/erp/service/user/UserComponent.java

@ -1,73 +0,0 @@
package com.zsw.erp.service.user;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.service.ICommonQuery;
import com.zsw.erp.utils.Constants;
import com.zsw.erp.utils.QueryUtils;
import com.zsw.erp.utils.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@Service(value = "user_component")
@UserResource
public class UserComponent implements ICommonQuery {
@Resource
private UserService userService;
@Override
public Object selectOne(Long id) throws Exception {
return userService.getUser(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getUserList(map);
}
private List<?> getUserList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String userName = StringUtil.getInfo(search, "userName");
String loginName = StringUtil.getInfo(search, "loginName");
String order = QueryUtils.order(map);
String filter = QueryUtils.filter(map);
return userService.select(userName, loginName, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String userName = StringUtil.getInfo(search, "userName");
String loginName = StringUtil.getInfo(search, "loginName");
return userService.countUser(userName, loginName);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return userService.insertUser(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return userService.updateUser(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return userService.deleteUser(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return userService.batchDeleteUser(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return userService.checkIsNameExist(id, name);
}
}

13
zsw-erp/src/main/java/com/zsw/erp/service/user/UserResource.java

@ -1,13 +0,0 @@
package com.zsw.erp.service.user;
import com.zsw.erp.service.ResourceInfo;
import java.lang.annotation.*;
@ResourceInfo(value = "user")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface UserResource {
}

815
zsw-erp/src/main/java/com/zsw/erp/service/user/UserService.java

@ -1,815 +0,0 @@
package com.zsw.erp.service.user;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.zsw.erp.datasource.entities.BtnDto;
import com.zsw.erp.datasource.dto.UserLoginDto;
import com.zsw.erp.service.redis.RedisService;
import com.zsw.erp.service.role.RoleService;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.constants.ExceptionConstants;
import com.zsw.erp.datasource.entities.*;
import com.zsw.erp.datasource.mappers.UserMapper;
import com.zsw.erp.datasource.mappers.UserMapperEx;
import com.zsw.erp.datasource.vo.TreeNodeEx;
import com.zsw.erp.exception.BusinessRunTimeException;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.orgaUserRel.OrgaUserRelService;
import com.zsw.erp.service.userBusiness.UserBusinessService;
import com.zsw.erp.utils.LocalUser;
import org.springframework.context.annotation.Lazy;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.tenant.TenantService;
import com.zsw.erp.utils.ExceptionCodeConstants;
import com.zsw.erp.utils.StringUtil;
import com.zsw.erp.utils.Tools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
@Service
public class UserService {
private Logger logger = LoggerFactory.getLogger(UserService.class);
private static final String TEST_USER = "jsh";
@Value("${demonstrate.open}")
private boolean demonstrateOpen;
@Resource
private UserMapper userMapper;
@Resource
private UserMapperEx userMapperEx;
@Resource
@Lazy
private OrgaUserRelService orgaUserRelService;
@Resource
@Lazy
private LogService logService;
@Resource
private TenantService tenantService;
@Resource
private UserBusinessService userBusinessService;
@Resource
@Lazy
private RoleService roleService;
@Resource
private RedisService redisService;
public User getUser(long id) {
User result=null;
result=userMapper.selectByPrimaryKey(id);
return result;
}
public List<User> getUserListByIds(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
List<User> list = new ArrayList<>();
try{
UserExample example = new UserExample();
example.createCriteria().andIdIn(idList);
list = userMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<User> getUser()throws Exception {
UserExample example = new UserExample();
example.createCriteria().andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
List<User> list=null;
try{
list=userMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<UserEx> select(String userName, String loginName, int offset, int rows)throws Exception {
List<UserEx> list=null;
try{
list=userMapperEx.selectByConditionUser(userName, loginName, offset, rows);
for(UserEx ue: list){
String userType = "";
if(demonstrateOpen && TEST_USER.equals(ue.getLoginName())){
userType = "演示用户";
} else {
if (ue.getId().equals(ue.getTenantId())) {
userType = "租户";
} else if(ue.getTenantId() == null){
userType = "超管";
} else {
userType = "普通";
}
}
ue.setUserType(userType);
}
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public Long countUser(String userName, String loginName) {
Long result=null;
try{
result=userMapperEx.countsByUser(userName, loginName);
}catch(Exception e){
BoomException.readFail(e);
}
return result;
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:30
* @Param: beanJson
 * @Param: request
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUser(JSONObject obj, HttpServletRequest request)throws Exception {
User user = JSONObject.parseObject(obj.toJSONString(), User.class);
String password = "123456";
//因密码用MD5加密,需要对密码进行转化
try {
password = Tools.md5Encryp(password);
user.setPassword(password);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 :" + e.getMessage());
}
int result=0;
try{
result=userMapper.insert(user);
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(user.getLoginName()).toString(), request);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:31
* @Param: beanJson
 * @Param: id
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUser(JSONObject obj, HttpServletRequest request) throws Exception{
User user = JSONObject.parseObject(obj.toJSONString(), User.class);
int result=0;
try{
result=userMapper.updateByPrimaryKeySelective(user);
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getLoginName()).toString(), request);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:32
* @Param: user
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserByObj(User user) throws Exception{
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getId()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
int result=0;
try{
result=userMapper.updateByPrimaryKeySelective(user);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:33
* @Param: md5Pwd
 * @Param: id
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int resetPwd(String md5Pwd, Long id) throws Exception{
int result=0;
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User u = getUser(id);
String loginName = u.getLoginName();
if("admin".equals(loginName)){
logger.info("禁止重置超管密码");
} else {
User user = new User();
user.setId(id);
user.setPassword(md5Pwd);
try{
result=userMapper.updateByPrimaryKeySelective(user);
}catch(Exception e){
BoomException.writeFail(e);
}
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUser(Long id, HttpServletRequest request)throws Exception {
return batDeleteUser(id.toString());
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUser(String ids, HttpServletRequest request)throws Exception {
return batDeleteUser(ids);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batDeleteUser(String ids) throws Exception{
int result=0;
StringBuffer sb = new StringBuffer();
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
List<User> list = getUserListByIds(ids);
for(User user: list){
if(demonstrateOpen && user.getLoginName().equals(TEST_USER)){
logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
ExceptionConstants.USER_LIMIT_DELETE_CODE,ExceptionConstants.USER_LIMIT_DELETE_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.USER_LIMIT_DELETE_CODE,
ExceptionConstants.USER_LIMIT_DELETE_MSG);
}
if(user.getId().equals(user.getTenantId())) {
logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
ExceptionConstants.USER_LIMIT_TENANT_DELETE_CODE,ExceptionConstants.USER_LIMIT_TENANT_DELETE_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.USER_LIMIT_TENANT_DELETE_CODE,
ExceptionConstants.USER_LIMIT_TENANT_DELETE_MSG);
}
sb.append("[").append(user.getLoginName()).append("]");
}
logService.insertLog("用户", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
String idsArray[]=ids.split(",");
try{
result=userMapperEx.batDeleteOrUpdateUser(idsArray,BusinessConstants.USER_STATUS_DELETE);
}catch(Exception e){
BoomException.writeFail(e);
}
if(result<1){
logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
ExceptionConstants.USER_DELETE_FAILED_CODE,ExceptionConstants.USER_DELETE_FAILED_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.USER_DELETE_FAILED_CODE,
ExceptionConstants.USER_DELETE_FAILED_MSG);
}
return result;
}
public UserLoginDto validateUser(String loginName, String password) {
/**默认是可以登录的*/
try {
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getLoginName, loginName));
if (user == null) {
//return UserLoginDto.builder().userStatus(ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST).build();
return UserLoginDto.buildStatus(ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST);
} else {
if(user.getStatus()!=0) {
return UserLoginDto.buildStatus(ExceptionCodeConstants.UserExceptionCode.BLACK_USER);
}
Long tenantId = user.getTenantId();
Tenant tenant = tenantService.getTenantByTenantId(tenantId);
if(tenant!=null) {
if(tenant.getEnabled()!=null && !tenant.getEnabled()) {
return UserLoginDto.buildStatus(ExceptionCodeConstants.UserExceptionCode.BLACK_TENANT);
}
if(tenant.getExpireTime()!=null && tenant.getExpireTime().getTime()<System.currentTimeMillis()){
return UserLoginDto.buildStatus(ExceptionCodeConstants.UserExceptionCode.EXPIRE_TENANT);
}
}
}
} catch (Exception e) {
logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e);
return UserLoginDto.buildStatus(ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION);
}
try {
LambdaQueryWrapper<User> wrap = Wrappers.<User>lambdaQuery().eq(User::getLoginName, loginName)
.eq(User::getPassword, SecureUtil.md5(password))
.eq(User::getStatus, BusinessConstants.USER_STATUS_NORMAL);
User user = userMapper.selectOne(wrap);
if (null == user) {
return UserLoginDto.buildStatus(ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR);
}
UserLoginDto dto = UserLoginDto.buildStatus(ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT);
dto.setUser(user);
return dto;
} catch (Exception e) {
logger.error(">>>>>>>>>>访问验证用户密码后台信息异常", e);
return UserLoginDto.buildStatus(ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION);
}
}
public User getUserByLoginName(String loginName)throws Exception {
UserExample example = new UserExample();
example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
List<User> list=null;
try{
list= userMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
User user =null;
if(list!=null&&list.size()>0){
user = list.get(0);
}
return user;
}
public int checkIsNameExist(Long id, String name)throws Exception {
UserExample example = new UserExample();
List <Byte> userStatus=new ArrayList<Byte>();
userStatus.add(BusinessConstants.USER_STATUS_DELETE);
userStatus.add(BusinessConstants.USER_STATUS_BANNED);
example.createCriteria().andIdNotEqualTo(id).andLoginNameEqualTo(name).andStatusNotIn(userStatus);
List<User> list=null;
try{
list= userMapper.selectByExample(example);
}catch(Exception e){
BoomException.readFail(e);
}
return list==null?0:list.size();
}
/**
* create by: cjl
* description:
* 获取当前用户信息
* create time: 2019/1/24 10:01
* @Param:
* @return com.jsh.erp.datasource.entities.User
*/
public User getCurrentUser(){
Long userId = LocalUser.getUserId();
return getUser(userId);
}
/**
* 检查当前用户是否是演示用户
* @return
*/
public Boolean checkIsTestUser() throws Exception{
Boolean result = false;
try {
if (demonstrateOpen) {
User user = getCurrentUser();
if (TEST_USER.equals(user.getLoginName())) {
result = true;
}
}
} catch (Exception e) {
BoomException.readFail(e);
}
return result;
}
/**
* 根据用户名查询id
* @param loginName
* @return
*/
public Long getIdByLoginName(String loginName) {
Long userId = 0L;
UserExample example = new UserExample();
example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
List<User> list = userMapper.selectByExample(example);
if(list!=null) {
userId = list.get(0).getId();
}
return userId;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addUserAndOrgUserRel(UserEx ue, HttpServletRequest request) throws Exception{
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
} else {
logService.insertLog("用户",
BusinessConstants.LOG_OPERATION_TYPE_ADD,
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
//检查用户名和登录名
checkUserNameAndLoginName(ue);
//新增用户信息
ue= this.addUser(ue);
if(ue==null){
logger.error("异常码[{}],异常提示[{}],参数,[{}]",
ExceptionConstants.USER_ADD_FAILED_CODE,ExceptionConstants.USER_ADD_FAILED_MSG);
throw new BusinessRunTimeException(ExceptionConstants.USER_ADD_FAILED_CODE,
ExceptionConstants.USER_ADD_FAILED_MSG);
}
//用户id,根据用户名查询id
Long userId = getIdByLoginName(ue.getLoginName());
if(ue.getRoleId()!=null){
UserBusiness userBusiness = new UserBusiness();
userBusiness.setType("UserRole");
userBusiness.setKeyId(userId.toString());
userBusiness.setValue(Lists.newArrayList(ue.getRoleId()));
userBusinessService.insertUserBusiness(userBusiness, request);
}
if(ue.getOrgaId()==null){
//如果没有选择机构,就不建机构和用户的关联关系
return;
}
//新增用户和机构关联关系
OrgaUserRel oul=new OrgaUserRel();
//机构id
oul.setOrgaId(ue.getOrgaId());
oul.setUserId(userId);
//用户在机构中的排序
oul.setUserBlngOrgaDsplSeq(ue.getUserBlngOrgaDsplSeq());
oul=orgaUserRelService.addOrgaUserRel(oul);
if(oul==null){
logger.error("异常码[{}],异常提示[{}],参数,[{}]",
ExceptionConstants.ORGA_USER_REL_ADD_FAILED_CODE,ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_ADD_FAILED_CODE,
ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
}
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public UserEx addUser(UserEx ue) throws Exception{
/**
* 新增用户默认设置
* 1密码默认123456
* 2是否系统自带默认为非系统自带
* 3是否管理者默认为员工
* 4默认用户状态为正常
* */
ue.setPassword(Tools.md5Encryp(BusinessConstants.USER_DEFAULT_PASSWORD));
ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM);
if(ue.getIsmanager()==null){
ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
}
ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
int result=0;
try{
result= userMapper.insert(ue);
}catch(Exception e){
BoomException.writeFail(e);
}
if(result>0){
return ue;
}
return null;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public UserEx registerUser(UserEx ue, Integer manageRoleId, HttpServletRequest request) throws Exception{
/**
* create by: qiankunpingtai
* create time: 2019/4/9 18:00
* 多次创建事务事物之间无法协同应该在入口处创建一个事务以做协调
*/
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
} else {
ue.setPassword(SecureUtil.md5(ue.getPassword()));
ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM);
if (ue.getIsmanager() == null) {
ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
}
ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
int result=0;
try{
result= userMapper.insert(ue);
Long userId = getIdByLoginName(ue.getLoginName());
ue.setId(userId);
}catch(Exception e){
BoomException.writeFail(e);
}
//更新租户id
User user = new User();
user.setId(ue.getId());
user.setTenantId(ue.getTenantId());
this.updateUserTenant(user);
//新增用户与角色的关系
UserBusiness userBusiness = new UserBusiness();
userBusiness.setType("UserRole");
userBusiness.setKeyId(ue.getId().toString());
userBusiness.setValue(Lists.newArrayList(manageRoleId));
userBusiness.setTenantId(ue.getTenantId() != null ? ue.getTenantId() :ue.getId());
userBusinessService.insertUserBusiness(userBusiness, null);
//创建租户信息
Tenant tenant = new Tenant();
tenant.setTenantId(ue.getTenantId() != null ? ue.getTenantId() :ue.getId());
tenant.setLoginName(ue.getLoginName());
tenant.setUserNumLimit(ue.getUserNumLimit());
tenant.setExpireTime(DateUtil.parse(ue.getExpireTime(), DatePattern.NORM_DATETIME_PATTERN));
tenant.setRemark(ue.getRemark());
tenantService.insertTenant(tenant, request);
logger.info("===============创建租户信息完成===============");
if (result > 0) {
return ue;
}
return null;
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateUserTenant(User user) throws Exception{
UserExample example = new UserExample();
example.createCriteria().andIdEqualTo(user.getId());
try{
userMapper.updateByPrimaryKeySelective(user);
}catch(Exception e){
BoomException.writeFail(e);
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateUserAndOrgUserRel(UserEx ue, HttpServletRequest request) throws Exception{
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
} else {
if(demonstrateOpen && ue.getLoginName().equals(TEST_USER)){
logger.error("异常码[{}],异常提示[{}],参数,obj:[{}]",
ExceptionConstants.USER_LIMIT_UPDATE_CODE,ExceptionConstants.USER_LIMIT_UPDATE_MSG, TEST_USER);
throw new BusinessRunTimeException(ExceptionConstants.USER_LIMIT_UPDATE_CODE,
ExceptionConstants.USER_LIMIT_UPDATE_MSG);
}
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ue.getId()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
//检查用户名和登录名
checkUserNameAndLoginName(ue);
//更新用户信息
ue = this.updateUser(ue);
if (ue == null) {
logger.error("异常码[{}],异常提示[{}],参数,[{}]",
ExceptionConstants.USER_EDIT_FAILED_CODE, ExceptionConstants.USER_EDIT_FAILED_MSG);
throw new BusinessRunTimeException(ExceptionConstants.USER_EDIT_FAILED_CODE,
ExceptionConstants.USER_EDIT_FAILED_MSG);
}
if(ue.getRoleId()!=null){
UserBusiness ub = userBusinessService.getBasicData(ue.getId(), "UserRole");
Long ubId = userBusinessService.checkIsValueExist("UserRole", ue.getId().toString());
if(ubId!=null) {
ub.setValue(Lists.newArrayList(ue.getRoleId()));
userBusinessService.updateUserBusiness(ub, request);
} else {
ub = new UserBusiness();
ub.setType("UserRole");
ub.setKeyId(ue.getId().toString());
ub.setValue(Lists.newArrayList(ue.getRoleId()));
userBusinessService.insertUserBusiness(ub, request);
}
}
if (ue.getOrgaId() == null) {
//如果没有选择机构,就不建机构和用户的关联关系
return;
}
//更新用户和机构关联关系
OrgaUserRel oul = new OrgaUserRel();
//机构和用户关联关系id
oul.setId(ue.getOrgaUserRelId());
//机构id
oul.setOrgaId(ue.getOrgaId());
//用户id
oul.setUserId(ue.getId());
//用户在机构中的排序
oul.setUserBlngOrgaDsplSeq(ue.getUserBlngOrgaDsplSeq());
if (oul.getId() != null) {
//已存在机构和用户的关联关系,更新
oul = orgaUserRelService.updateOrgaUserRel(oul);
} else {
//不存在机构和用户的关联关系,新建
oul = orgaUserRelService.addOrgaUserRel(oul);
}
if (oul == null) {
logger.error("异常码[{}],异常提示[{}],参数,[{}]",
ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_CODE, ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_MSG);
throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_CODE,
ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_MSG);
}
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public UserEx updateUser(UserEx ue)throws Exception{
int result =0;
try{
result=userMapper.updateByPrimaryKeySelective(ue);
}catch(Exception e){
BoomException.writeFail(e);
}
if(result>0){
return ue;
}
return null;
}
/**
* create by: cjl
* description:
* 检查用户名称和登录名不能重复
* create time: 2019/3/12 11:36
* @Param: userEx
* @return void
*/
public void checkUserNameAndLoginName(UserEx userEx)throws Exception{
List<User> list=null;
if(userEx==null){
return;
}
Long userId=userEx.getId();
//检查登录名
if(!StringUtils.isEmpty(userEx.getLoginName())){
String loginName=userEx.getLoginName();
list=this.getUserListByloginName(loginName);
if(list!=null&&list.size()>0){
if(list.size()>1){
//超过一条数据存在,该登录名已存在
logger.error("异常码[{}],异常提示[{}],参数,loginName:[{}]",
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG,loginName);
throw new BusinessRunTimeException(ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG);
}
//一条数据,新增时抛出异常,修改时和当前的id不同时抛出异常
if(list.size()==1){
if(userId==null||(userId!=null&&!userId.equals(list.get(0).getId()))){
logger.error("异常码[{}],异常提示[{}],参数,loginName:[{}]",
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG,loginName);
throw new BusinessRunTimeException(ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG);
}
}
}
}
//检查用户名
if(!StringUtils.isEmpty(userEx.getUsername())){
String userName=userEx.getUsername();
list=this.getUserListByUserName(userName);
if(list!=null&&list.size()>0){
if(list.size()>1){
//超过一条数据存在,该用户名已存在
logger.error("异常码[{}],异常提示[{}],参数,userName:[{}]",
ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_MSG,userName);
throw new BusinessRunTimeException(ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_CODE,
ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_MSG);
}
//一条数据,新增时抛出异常,修改时和当前的id不同时抛出异常
if(list.size()==1){
if(userId==null||(userId!=null&&!userId.equals(list.get(0).getId()))){
logger.error("异常码[{}],异常提示[{}],参数,userName:[{}]",
ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_MSG,userName);
throw new BusinessRunTimeException(ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_CODE,
ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_MSG);
}
}
}
}
}
/**
* 通过用户名获取用户列表
* */
public List<User> getUserListByUserName(String userName)throws Exception{
List<User> list =null;
try{
list=userMapperEx.getUserListByUserNameOrLoginName(userName,null);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
/**
* 通过登录名获取用户列表
* */
public List<User> getUserListByloginName(String loginName){
List<User> list =null;
try{
list=userMapperEx.getUserListByUserNameOrLoginName(null,loginName);
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
public List<TreeNodeEx> getOrganizationUserTree()throws Exception {
List<TreeNodeEx> list =null;
try{
list=userMapperEx.getNodeTree();
}catch(Exception e){
BoomException.readFail(e);
}
return list;
}
/**
* 根据用户id查询角色类型
* @param userId
* @return
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public String getRoleTypeByUserId(long userId) throws Exception {
if (userId == 1L || userId == 2L){
return "全部数据";
}
UserBusiness ub = userBusinessService.getBasicData(userId, "UserRole");
List<Number> values = ub.getValue();
Role role = roleService.getRole(values.get(0).longValue());
if(role!=null) {
return role.getType();
} else {
return null;
}
}
/**
* 获取用户id
* @param request
* @return
*/
public Long getUserId(HttpServletRequest request) throws Exception{
Object userIdObj = redisService.getObjectFromSessionByKey(request,"userId");
Long userId = null;
if(userIdObj != null) {
userId = Long.parseLong(userIdObj.toString());
}
return userId;
}
/**
* 用户的按钮权限
* @param userId
* @return
* @throws Exception
*/
public List<BtnDto> getBtnStrArrById(Long userId) {
UserBusiness ub = userBusinessService.getBasicData(userId, "UserRole");
List<Number> roleValue = ub.getValue();
if(ObjectUtil.isNotEmpty(roleValue)){
UserBusiness fun = userBusinessService.getBasicData(roleValue.get(0).longValue(), "RoleFunctions");
return fun.getBtnStr();
}
return null;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetStatus(Byte status, String ids)throws Exception {
int result=0;
List<User> list = getUserListByIds(ids);
for(User user: list) {
if (demonstrateOpen && user.getLoginName().equals(TEST_USER)) {
logger.error("异常码[{}],异常提示[{}],参数,obj:[{}]",
ExceptionConstants.USER_LIMIT_UPDATE_CODE, ExceptionConstants.USER_LIMIT_UPDATE_MSG, TEST_USER);
throw new BusinessRunTimeException(ExceptionConstants.USER_LIMIT_UPDATE_CODE,
ExceptionConstants.USER_LIMIT_UPDATE_MSG);
}
}
String statusStr ="";
if(status == 0) {
statusStr ="批量启用";
} else if(status == 2) {
statusStr ="批量禁用";
}
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ids).append("-").append(statusStr).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
List<Long> idList = StringUtil.strToLongList(ids);
User user = new User();
user.setStatus(status);
UserExample example = new UserExample();
example.createCriteria().andIdIn(idList);
result = userMapper.updateByExampleSelective(user, example);
return result;
}
}

67
zsw-erp/src/main/java/com/zsw/erp/service/userBusiness/UserBusinessComponent.java

@ -1,67 +0,0 @@
package com.zsw.erp.service.userBusiness;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.datasource.entities.UserBusiness;
import com.zsw.erp.service.ICommonQuery;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Service(value = "userBusiness_component")
@UserBusinessResource
public class UserBusinessComponent implements ICommonQuery {
@Resource
private UserBusinessService userBusinessService;
@Override
public Object selectOne(Long id) throws Exception {
return userBusinessService.getUserBusiness(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getUserBusinessList(map);
}
private List<?> getUserBusinessList(Map<String, String> map)throws Exception {
return null;
}
@Override
public Long counts(Map<String, String> map)throws Exception {
return BusinessConstants.DEFAULT_LIST_NULL_NUMBER;
}
@Override
public int insert(JSONObject obj, HttpServletRequest request) throws Exception {
return userBusinessService.insertUserBusiness(JSON.parseObject(obj.toJSONString(),UserBusiness.class), request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return userBusinessService.updateUserBusiness(JSON.parseObject(obj.toJSONString(),UserBusiness.class), request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return userBusinessService.deleteUserBusiness(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return userBusinessService.batchDeleteUserBusiness(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return userBusinessService.checkIsNameExist(id, name);
}
}

13
zsw-erp/src/main/java/com/zsw/erp/service/userBusiness/UserBusinessResource.java

@ -1,13 +0,0 @@
package com.zsw.erp.service.userBusiness;
import com.zsw.erp.service.ResourceInfo;
import java.lang.annotation.*;
@ResourceInfo(value = "userBusiness")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface UserBusinessResource {
}

163
zsw-erp/src/main/java/com/zsw/erp/service/userBusiness/UserBusinessService.java

@ -1,163 +0,0 @@
package com.zsw.erp.service.userBusiness;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.zsw.erp.constants.BusinessConstants;
import com.zsw.erp.datasource.entities.BtnDto;
import com.zsw.erp.datasource.mappers.UserBusinessMapper;
import com.zsw.erp.datasource.mappers.UserBusinessMapperEx;
import com.zsw.erp.exception.BoomException;
import com.zsw.erp.service.log.LogService;
import com.zsw.erp.service.user.UserService;
import com.zsw.erp.utils.Tools;
import com.zsw.erp.datasource.entities.User;
import com.zsw.erp.datasource.entities.UserBusiness;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class UserBusinessService {
private Logger logger = LoggerFactory.getLogger(UserBusinessService.class);
@Resource
private UserBusinessMapper userBusinessMapper;
@Resource
private UserBusinessMapperEx userBusinessMapperEx;
@Resource
private LogService logService;
@Resource
@Lazy
private UserService userService;
public UserBusiness getUserBusiness(long id)throws Exception {
return userBusinessMapper.selectById(id);
}
public List<UserBusiness> getUserBusiness(){
return userBusinessMapper.selectList(Wrappers.<UserBusiness>lambdaQuery()
.eq(UserBusiness::getDeleteFlag,BusinessConstants.DELETE_FLAG_EXISTS));
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUserBusiness(UserBusiness userBusiness, HttpServletRequest request) throws Exception {
int result=0;
try{
String token = "";
if(request!=null) {
token = request.getHeader("X-Access-Token");
Long tenantId = Tools.getTenantIdByToken(token);
if(tenantId!=0L) {
userBusiness.setTenantId(tenantId);
}
}
result=userBusinessMapper.insert(userBusiness);
logService.insertLog("关联关系", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserBusiness(UserBusiness userBusiness, HttpServletRequest request) throws Exception {
int result=0;
try{
result = userBusinessMapper.updateById(userBusiness);
logService.insertLog("关联关系", BusinessConstants.LOG_OPERATION_TYPE_EDIT, request);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUserBusiness(Long id, HttpServletRequest request)throws Exception {
return batchDeleteUserBusinessByIds(id.toString());
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUserBusiness(String ids, HttpServletRequest request)throws Exception {
return batchDeleteUserBusinessByIds(ids);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUserBusinessByIds(String ids) throws Exception{
logService.insertLog("关联关系",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result= userBusinessMapperEx.batchDeleteUserBusinessByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
return 1;
}
public UserBusiness getBasicData(Long keyId, String type){
return userBusinessMapper.selectOne(Wrappers.<UserBusiness>lambdaQuery()
.eq(UserBusiness::getType, type)
.eq(UserBusiness::getKeyId,keyId)
.eq(UserBusiness::getDeleteFlag, BusinessConstants.DELETE_FLAG_EXISTS));
}
public List<UserBusiness> getListBy(String keyId, String type){
return userBusinessMapper.selectList(Wrappers.<UserBusiness>lambdaQuery()
.eq(UserBusiness::getKeyId,keyId)
.eq(UserBusiness::getType,type)
.eq(UserBusiness::getDeleteFlag,BusinessConstants.DELETE_FLAG_EXISTS));
}
public List<Long> getUBValueByTypeAndKeyId(String type, Long keyId) throws Exception {
List<Number> list = Lists.newArrayList();
UserBusiness ubList = getBasicData(keyId, type);
if (ubList == null){
return null;
}
return ubList.getValue().stream().map(Number::longValue).collect(Collectors.toList());
}
public Long checkIsValueExist(String type, String keyId)throws Exception {
UserBusiness business = userBusinessMapper.selectOne(Wrappers.<UserBusiness>lambdaQuery()
.eq(UserBusiness::getKeyId,keyId)
.eq(UserBusiness::getType,type)
.eq(UserBusiness::getDeleteFlag,BusinessConstants.DELETE_FLAG_EXISTS));
return business==null ? null : business.getId();
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateBtnStr(String keyId, String type, List<BtnDto> btnStr) throws Exception{
logService.insertLog("关联关系",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append("角色的按钮权限").toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
UserBusiness userBusiness = new UserBusiness();
userBusiness.setBtnStr(btnStr);
int result=0;
try{
result= userBusinessMapper.update(userBusiness,
Wrappers.<UserBusiness>lambdaUpdate()
.eq(UserBusiness::getType,type)
.eq(UserBusiness::getKeyId,keyId));
}catch(Exception e){
BoomException.writeFail(e);
}
return result;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save