删掉了 ,spc不需要的模块

This commit is contained in:
caixiang 2022-06-30 15:28:19 +08:00
parent c15c0e1f1c
commit 4c2e20bf0d
27 ha cambiato i file con 152 aggiunte e 461 eliminazioni

Vedi File

@ -12,10 +12,8 @@
<module>ym-admin</module>
<module>ym-generator</module>
<module>ym-gateway</module>
<module>ym-barcode</module>
<module>ym-baisc</module>
<module>ym-schedule-task</module>
<module>ym-websocket</module>
</modules>
<packaging>pom</packaging>

Vedi File

@ -31,10 +31,10 @@ import java.util.Map;
* 产品类型 前端控制器
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
@RestController
@RequestMapping("/basic/productType")
@RequestMapping("/code/productType")
@Api(tags="产品类型 表")
public class ProductTypeController {
@Autowired
@ -43,12 +43,12 @@ public class ProductTypeController {
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class)
})
// @PreAuthorize("@ex.hasAuthority('basic:productType:page')")
// @PreAuthorize("@ex.hasAuthority('code:productType:page')")
public Result<PageData<ProductTypeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<ProductTypeDTO> page = productTypeService.page(params);
@ -57,7 +57,7 @@ public class ProductTypeController {
@GetMapping("{id}")
@ApiOperation("信息")
// @PreAuthorize("@ex.hasAuthority('basic:productType:info')")
// @PreAuthorize("@ex.hasAuthority('code:productType:info')")
public Result<ProductTypeDTO> get(@PathVariable("id") Long id){
ProductTypeDTO data = productTypeService.get(id);
@ -67,7 +67,7 @@ public class ProductTypeController {
@PostMapping
@ApiOperation("保存")
@LogOperation("保存")
// @PreAuthorize("@ex.hasAuthority('basic:productType:save')")
// @PreAuthorize("@ex.hasAuthority('code:productType:save')")
public Result save(@RequestBody ProductTypeDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
@ -80,7 +80,7 @@ public class ProductTypeController {
@PutMapping
@ApiOperation("修改")
@LogOperation("修改")
// @PreAuthorize("@ex.hasAuthority('basic:productType:update')")
// @PreAuthorize("@ex.hasAuthority('code:productType:update')")
public Result update(@RequestBody ProductTypeDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
@ -93,7 +93,7 @@ public class ProductTypeController {
@DeleteMapping
@ApiOperation("删除")
@LogOperation("删除")
// @PreAuthorize("@ex.hasAuthority('basic:productType:delete')")
// @PreAuthorize("@ex.hasAuthority('code:productType:delete')")
public Result delete(@RequestBody Long[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
@ -106,7 +106,7 @@ public class ProductTypeController {
@GetMapping("export")
@ApiOperation("导出")
@LogOperation("导出")
// @PreAuthorize("@ex.hasAuthority('basic:productType:export')")
// @PreAuthorize("@ex.hasAuthority('code:productType:export')")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ProductTypeDTO> list = productTypeService.list(params);

Vedi File

@ -1,4 +1,4 @@
package com.cnbm.generator.controller;
package com.cnbm.basic.controller;
import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.common.constant.Constant;
@ -10,15 +10,15 @@ import com.cnbm.common.validator.ValidatorUtils;
import com.cnbm.common.validator.group.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.generator.dto.ProductTypeDTO;
import com.cnbm.generator.excel.ProductTypeExcel;
import com.cnbm.generator.service.IProductTypeService;
import com.cnbm.basic.dto.UnitDTO;
import com.cnbm.basic.excel.UnitExcel;
import com.cnbm.basic.service.IUnitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -28,51 +28,51 @@ import java.util.Map;
/**
* 产品类型 前端控制器
* 单位 前端控制器
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
@RestController
@RequestMapping("/generator/productType")
@Api(tags="产品类型")
public class ProductTypeController {
@RequestMapping("/code/unit")
@Api(tags="单位")
public class UnitController {
@Autowired
private IProductTypeService productTypeService;
private IUnitService unitService;
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class)
})
@PreAuthorize("@ex.hasAuthority('generator:productType:page')")
public Result<PageData<ProductTypeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<ProductTypeDTO> page = productTypeService.page(params);
@PreAuthorize("@ex.hasAuthority('code:unit:page')")
public Result<PageData<UnitDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<UnitDTO> page = unitService.page(params);
return new Result<PageData<ProductTypeDTO>>().ok(page);
return new Result<PageData<UnitDTO>>().ok(page);
}
@GetMapping("{id}")
@ApiOperation("信息")
@PreAuthorize("@ex.hasAuthority('generator:productType:info')")
public Result<ProductTypeDTO> get(@PathVariable("id") Long id){
ProductTypeDTO data = productTypeService.get(id);
@PreAuthorize("@ex.hasAuthority('code:unit:info')")
public Result<UnitDTO> get(@PathVariable("id") Long id){
UnitDTO data = unitService.get(id);
return new Result<ProductTypeDTO>().ok(data);
return new Result<UnitDTO>().ok(data);
}
@PostMapping
@ApiOperation("保存")
@LogOperation("保存")
@PreAuthorize("@ex.hasAuthority('generator:productType:save')")
public Result save(@RequestBody ProductTypeDTO dto){
@PreAuthorize("@ex.hasAuthority('code:unit:save')")
public Result save(@RequestBody UnitDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
productTypeService.save(dto);
unitService.save(dto);
return new Result();
}
@ -80,12 +80,12 @@ public class ProductTypeController {
@PutMapping
@ApiOperation("修改")
@LogOperation("修改")
@PreAuthorize("@ex.hasAuthority('generator:productType:update')")
public Result update(@RequestBody ProductTypeDTO dto){
@PreAuthorize("@ex.hasAuthority('code:unit:update')")
public Result update(@RequestBody UnitDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
productTypeService.update(dto);
unitService.update(dto);
return new Result();
}
@ -93,12 +93,12 @@ public class ProductTypeController {
@DeleteMapping
@ApiOperation("删除")
@LogOperation("删除")
@PreAuthorize("@ex.hasAuthority('generator:productType:delete')")
@PreAuthorize("@ex.hasAuthority('code:unit:delete')")
public Result delete(@RequestBody Long[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
productTypeService.delete(ids);
unitService.delete(ids);
return new Result();
}
@ -106,11 +106,11 @@ public class ProductTypeController {
@GetMapping("export")
@ApiOperation("导出")
@LogOperation("导出")
@PreAuthorize("@ex.hasAuthority('generator:productType:export')")
@PreAuthorize("@ex.hasAuthority('code:unit:export')")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ProductTypeDTO> list = productTypeService.list(params);
List<UnitDTO> list = unitService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, ProductTypeExcel.class);
ExcelUtils.exportExcelToTarget(response, null, list, UnitExcel.class);
}
}

Vedi File

@ -13,7 +13,7 @@ import java.time.LocalDateTime;
* 产品类型
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
@Data
@ApiModel(value = "产品类型 表DTO对象")

Vedi File

@ -1,23 +1,23 @@
package com.cnbm.generator.dto;
package com.cnbm.basic.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 产品类型
* 单位
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
@Data
@ApiModel(value = "产品类型 表DTO对象")
public class ProductTypeDTO implements Serializable {
@ApiModel(value = "单位 表DTO对象")
public class UnitDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ -25,14 +25,14 @@ public class ProductTypeDTO implements Serializable {
@ApiModelProperty(value = "ID")
private BigDecimal id;
@ApiModelProperty(value = "产品类型")
@ApiModelProperty(value = "单位")
private String name;
@ApiModelProperty(value = "产品类型 编码")
@ApiModelProperty(value = "单位 编码")
private String code;
@ApiModelProperty(value = "描述")
private String desc;
@ApiModelProperty(value = "单位类型1 可计数2 不可计数")
private BigDecimal type;
@ApiModelProperty(value = "1 可用0 不可用")
private BigDecimal status;

Vedi File

@ -15,7 +15,7 @@ import java.time.LocalDateTime;
* </p>
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
@Data
@TableName("product_type")
@ -34,7 +34,7 @@ public class ProductType implements Serializable {
private String code;
@ApiModelProperty("描述")
private String desc;
private String descs;
@ApiModelProperty("1 可用0 不可用")
private BigDecimal status;

Vedi File

@ -1,39 +1,38 @@
package com.cnbm.generator.entity;
package com.cnbm.basic.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* <p>
* 产品类型
* 单位
* </p>
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
@Data
@TableName("product_type")
@ApiModel(value = "ProductType对象", description = "产品类型 表")
public class ProductType implements Serializable {
@ApiModel(value = "Unit对象", description = "单位 表")
public class Unit implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("ID")
private BigDecimal id;
@ApiModelProperty("产品类型")
@ApiModelProperty("单位")
private String name;
@ApiModelProperty("产品类型 编码")
@ApiModelProperty("单位 编码")
private String code;
@ApiModelProperty("描述")
private String desc;
@ApiModelProperty("单位类型1 可计数2 不可计数")
private BigDecimal type;
@ApiModelProperty("1 可用0 不可用")
private BigDecimal status;

Vedi File

@ -10,7 +10,7 @@ import java.time.LocalDateTime;
* 产品类型
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
@Data
public class ProductTypeExcel {

Vedi File

@ -1,27 +1,27 @@
package com.cnbm.generator.excel;
package com.cnbm.basic.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 产品类型
* 单位
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
@Data
public class ProductTypeExcel {
public class UnitExcel {
@Excel(name = "ID")
private BigDecimal id;
@Excel(name = "产品类型")
@Excel(name = "单位")
private String name;
@Excel(name = "产品类型 编码")
@Excel(name = "单位 编码")
private String code;
@Excel(name = "描述")
private String desc;
@Excel(name = "单位类型1 可计数2 不可计数")
private BigDecimal type;
@Excel(name = "1 可用0 不可用")
private BigDecimal status;
@Excel(name = "备注")

Vedi File

@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
* 产品类型
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
@Mapper
public interface ProductTypeMapper extends BaseDao<ProductType> {

Vedi File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cnbm.generator.mapper.ProductTypeMapper">
<mapper namespace="com.cnbm.generator.code.mapper.ProductTypeMapper">
</mapper>

Vedi File

@ -0,0 +1,16 @@
package com.cnbm.basic.mapper;
import com.cnbm.common.dao.BaseDao;
import com.cnbm.basic.entity.Unit;
import org.apache.ibatis.annotations.Mapper;
/**
* 单位
*
* @author why
* @since 2022-06-30
*/
@Mapper
public interface UnitMapper extends BaseDao<Unit> {
}

Vedi File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cnbm.basic.mapper.ProductTypeMapper">
<mapper namespace="com.cnbm.generator.code.mapper.UnitMapper">
</mapper>

Vedi File

@ -8,7 +8,7 @@ import com.cnbm.basic.entity.ProductType;
* 产品类型
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
public interface IProductTypeService extends CrudService<ProductType, ProductTypeDTO> {

Vedi File

@ -0,0 +1,15 @@
package com.cnbm.basic.service;
import com.cnbm.common.service.CrudService;
import com.cnbm.basic.dto.UnitDTO;
import com.cnbm.basic.entity.Unit;
/**
* 单位
*
* @author why
* @since 2022-06-30
*/
public interface IUnitService extends CrudService<Unit, UnitDTO> {
}

Vedi File

@ -15,7 +15,7 @@ import java.util.Map;
* 产品类型
*
* @author why
* @since 2022-06-21
* @since 2022-06-30
*/
@Service
public class ProductTypeServiceImpl extends CrudServiceImpl<ProductTypeMapper, ProductType, ProductTypeDTO> implements IProductTypeService {

Vedi File

@ -0,0 +1,34 @@
package com.cnbm.basic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.basic.dto.UnitDTO;
import com.cnbm.basic.entity.Unit;
import com.cnbm.basic.mapper.UnitMapper;
import com.cnbm.basic.service.IUnitService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 单位
*
* @author why
* @since 2022-06-30
*/
@Service
public class UnitServiceImpl extends CrudServiceImpl<UnitMapper, Unit, UnitDTO> implements IUnitService {
@Override
public QueryWrapper<Unit> getWrapper(Map<String, Object> params){
String id = (String)params.get("id");
QueryWrapper<Unit> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
return wrapper;
}
}

Vedi File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ym-pass</artifactId>
<groupId>com.cnbm</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ym-barcode</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.github.kwhat</groupId>
<artifactId>jnativehook</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
</project>

Vedi File

@ -1,101 +0,0 @@
package com.cnbm.barcode.listener;
import com.github.kwhat.jnativehook.GlobalScreen;
import com.github.kwhat.jnativehook.NativeHookException;
import com.github.kwhat.jnativehook.keyboard.NativeKeyEvent;
import com.github.kwhat.jnativehook.keyboard.NativeKeyListener;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* @Author weihongyang
* @Date 2022/6/20 4:08 PM
* @Version 1.0
*/
@Log4j2
@Component
@Profile("prod")
public class GlobalKeyListenerExample implements NativeKeyListener {
static {
try {
GlobalScreen.registerNativeHook();
} catch (NativeHookException e) {
throw new RuntimeException(e);
}
GlobalScreen.addNativeKeyListener(new GlobalKeyListenerExample());
}
protected final static LinkedBlockingQueue<Integer> queue = new LinkedBlockingQueue();
public void nativeKeyPressed(NativeKeyEvent e) {
log.info("Key Pressed: " + NativeKeyEvent.getKeyText(e.getKeyCode()));
try {
queue.put(e.getKeyCode());
} catch (InterruptedException ex) {
ex.printStackTrace();
}
log.info("queue的数据是"+queue.toString());
int[] hotKeyArray1 = {NativeKeyEvent.VC_X, NativeKeyEvent.VC_Y,NativeKeyEvent.VC_Z};
if (5 <= queue.size() && queue.size()<= 6 && e.getKeyCode() == NativeKeyEvent.VC_ENTER && judgeCombinationKey(hotKeyArray1)){
String result = "";
List<String> collect = queue.stream().map(n -> {
return NativeKeyEvent.getKeyText(n);
}).collect(Collectors.toList());
if (queue.size() == 5) {
for (String s : collect) {
result = result + s;
}
}else {
for (int i = 1; i < collect.size(); i++) {
result = result + collect.get(i);
}
}
log.info("符合标准的扫码是:"+ result.replace("Enter",""));
queue.clear();
}
if (queue.size() == 6){
queue.poll();
}
if (e.getKeyCode() == NativeKeyEvent.VC_ESCAPE) {
try {
GlobalScreen.unregisterNativeHook();
} catch (NativeHookException nativeHookException) {
nativeHookException.printStackTrace();
}
}
}
protected Boolean judgeCombinationKey(int[] hotKeyArray){
Object[] queueKey = queue.toArray();
Predicate<int[]> keyArrayPredicateOne = hotKeies -> (int)queueKey[0] == hotKeies[0]
&& (int)queueKey[1] == hotKeies[1]
&& (int)queueKey[2] == hotKeies[2];
Predicate<int[]> keyArrayPredicateTwo = hotKeies -> (int)queueKey[1] == hotKeies[0]
&& (int)queueKey[2] == hotKeies[1]
&& (int)queueKey[3] == hotKeies[2];
return queue.size() == 3 ? keyArrayPredicateOne.test(hotKeyArray) :
keyArrayPredicateOne.or(keyArrayPredicateTwo).test(hotKeyArray);
}
public void nativeKeyReleased(NativeKeyEvent e) {
log.info("Key Released: " + NativeKeyEvent.getKeyText(e.getKeyCode()));
}
public void nativeKeyTyped(NativeKeyEvent e) {
log.info("Key Typed: " + e.getKeyText(e.getKeyCode()));
}
}

Vedi File

@ -27,11 +27,6 @@
<artifactId>ym-admin</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.cnbm</groupId>
<artifactId>ym-barcode</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.cnbm</groupId>
<artifactId>ym-baisc</artifactId>
@ -42,11 +37,6 @@
<artifactId>ym-schedule-task</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.cnbm</groupId>
<artifactId>ym-websocket</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>

Vedi File

@ -1,16 +0,0 @@
package com.cnbm.generator.mapper;
import com.cnbm.common.dao.BaseDao;
import com.cnbm.generator.entity.ProductType;
import org.apache.ibatis.annotations.Mapper;
/**
* 产品类型
*
* @author why
* @since 2022-06-21
*/
@Mapper
public interface ProductTypeMapper extends BaseDao<ProductType> {
}

Vedi File

@ -1,15 +0,0 @@
package com.cnbm.generator.service;
import com.cnbm.common.service.CrudService;
import com.cnbm.generator.dto.ProductTypeDTO;
import com.cnbm.generator.entity.ProductType;
/**
* 产品类型
*
* @author why
* @since 2022-06-21
*/
public interface IProductTypeService extends CrudService<ProductType, ProductTypeDTO> {
}

Vedi File

@ -1,34 +0,0 @@
package com.cnbm.generator.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.generator.dto.ProductTypeDTO;
import com.cnbm.generator.mapper.ProductTypeMapper;
import com.cnbm.generator.entity.ProductType;
import com.cnbm.generator.service.IProductTypeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 产品类型
*
* @author why
* @since 2022-06-21
*/
@Service
public class ProductTypeServiceImpl extends CrudServiceImpl<ProductTypeMapper, ProductType, ProductTypeDTO> implements IProductTypeService {
@Override
public QueryWrapper<ProductType> getWrapper(Map<String, Object> params){
String id = (String)params.get("id");
QueryWrapper<ProductType> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
return wrapper;
}
}

Vedi File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ym-pass</artifactId>
<groupId>com.cnbm</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ym-websocket</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.cnbm</groupId>
<artifactId>ym-schedule-task</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
</dependencies>
</project>

Vedi File

@ -1,20 +0,0 @@
package com.cnbm.websocket.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* @Author weihongyang
* @Date 2022/6/29 8:58 AM
* @Version 1.0
*/
@Configuration
@EnableWebSocket
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpoint(){
return new ServerEndpointExporter();
}
}

Vedi File

@ -1,79 +0,0 @@
package com.cnbm.websocket.server;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
/**
* @Author weihongyang
* @Date 2022/6/29 8:59 AM
* @Version 1.0
*/
@Log4j2
@Component
@ServerEndpoint("/websocket/info") // 指定websocket 连接的url
public class WebSocketServer {
private static int onlineCount = 0;
public static ConcurrentHashMap<String,WebSocketServer> webSocketMap = new ConcurrentHashMap<>();
private Session session;
private String sessionId;
@OnOpen
public void onOpen(Session session) {
log.info("客户端:{}连接成功",session.getId());
this.session = session;
this.sessionId = session.getId();
if (webSocketMap.containsKey(session.getId())){
webSocketMap.remove(sessionId);
webSocketMap.put(sessionId,this);
}else {
webSocketMap.put(sessionId,this);
addOnlineCount();
}
}
@OnClose
public void onClose(Session session) {
if (webSocketMap.containsKey(sessionId)) {
webSocketMap.remove(sessionId);
subOnlineCount();
}
log.info("客户端:{}连接断开",session.getId());
}
@OnMessage
public String onMsg(String message,Session session) {
log.info("从客户端:{} 收到<--:{}", session.getId(),message);
String send=message.toUpperCase();
String result="客户:%s您好来自server 的消息:%s";
result = String.format(result, session.getId(), send);
return "来自server 的消息:" + result;
}
public void sendMsg(String message) throws IOException{
this.session.getBasicRemote().sendText(message);
}
private static synchronized void addOnlineCount() {
WebSocketServer.onlineCount++;
}
private static synchronized void subOnlineCount() {
WebSocketServer.onlineCount--;
}
}

Vedi File

@ -1,37 +0,0 @@
package com.cnbm.websocket.task;
import com.cnbm.scheduletask.task.ITask;
import com.cnbm.websocket.server.WebSocketServer;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @Author weihongyang
* @Date 2022/6/29 2:01 PM
* @Version 1.0
*/
@Log4j2
@Component("sendMessageTask")
public class SendMessageTask implements ITask {
public void run(String params) {
Iterator<Map.Entry<String, WebSocketServer>> socketIt = WebSocketServer.webSocketMap.entrySet().iterator();
while (socketIt.hasNext()) {
Map.Entry<String, WebSocketServer> socketServerEntry = socketIt.next();
try {
socketServerEntry.getValue().sendMsg("定时发送:"+new Date().toString());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
log.info("sendMessageTask定时任务正在执行参数为{}", params);
}
}