赋码自动生成
This commit is contained in:
parent
631bf22bcd
commit
832d71055f
@ -185,11 +185,21 @@ public class UserConstants
|
|||||||
public static final String VIRTUAL_WA ="XBKKW_VIRTUAL";
|
public static final String VIRTUAL_WA ="XBKKW_VIRTUAL";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 条码类型
|
* 条码格式
|
||||||
*/
|
*/
|
||||||
public static final String QR_CODE = "QR_CODE";
|
public static final String QR_CODE = "QR_CODE";
|
||||||
public static final String EAN_CODE = "EAN_CODE";
|
public static final String EAN_CODE = "EAN_CODE";
|
||||||
public static final String UPC_CODE = "UPC_CODE";
|
public static final String UPC_CODE = "UPC_CODE";
|
||||||
public static final String CODE39_CODE = "CODE39_CODE";
|
public static final String CODE39_CODE = "CODE39_CODE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条码类型
|
||||||
|
*/
|
||||||
|
public static final String BARCODE_TYPE_ITEM = "ITEM";
|
||||||
|
public static final String BARCODE_TYPE_PACKAGE = "PACKAGE";
|
||||||
|
public static final String BARCODE_TYPE_STOCK = "STOCK";
|
||||||
|
public static final String BARCODE_TYPE_MACHINERY = "MACHINERY";
|
||||||
|
public static final String BARCODE_TYPE_WORKSTATION = "WORKSTATION";
|
||||||
|
public static final String BARCODE_TYPE_WAREHOUSE = "WAREHOUSE";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
14
ktg-mes/src/main/java/com/ktg/mes/aspect/BarcodeGen.java
Normal file
14
ktg-mes/src/main/java/com/ktg/mes/aspect/BarcodeGen.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.ktg.mes.aspect;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface BarcodeGen {
|
||||||
|
/**
|
||||||
|
* 业务类型
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String barcodeType();
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.ktg.mes.aspect;
|
||||||
|
|
||||||
|
import com.ktg.common.constant.UserConstants;
|
||||||
|
import com.ktg.common.core.domain.AjaxResult;
|
||||||
|
import com.ktg.mes.wm.domain.WmBarcodeConfig;
|
||||||
|
import com.ktg.mes.wm.service.IWmBarcodeConfigService;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
public class BarcodeGenAspect {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(BarcodeGenAspect.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IWmBarcodeConfigService wmBarcodeConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据业务controller的类型和返回值生成对应的条码
|
||||||
|
* @param joinPoint
|
||||||
|
* @param gen
|
||||||
|
* @param returnResult
|
||||||
|
*/
|
||||||
|
@AfterReturning(pointcut = "@annotation(gen)",returning = "returnResult")
|
||||||
|
public void doAfter(JoinPoint joinPoint, BarcodeGen gen, AjaxResult returnResult){
|
||||||
|
//先判断当前类型的业务是否配置了需要自动生成条码
|
||||||
|
if(!wmBarcodeConfigService.isAutoGen(gen.barcodeType())){
|
||||||
|
//无需自动生成条码
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
WmBarcodeConfig param = new WmBarcodeConfig();
|
||||||
|
param.setBarcodeType(gen.barcodeType());
|
||||||
|
List<WmBarcodeConfig> confgs = wmBarcodeConfigService.selectWmBarcodeConfigList(param);
|
||||||
|
if(CollectionUtils.isEmpty(confgs)){
|
||||||
|
log.warn("当前类型的业务未配置对应的条码生成规则!{}",gen.barcodeType());
|
||||||
|
}
|
||||||
|
|
||||||
|
Long businessId = (Long)returnResult.get("data"); //获取业务ID
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.ktg.mes.md.controller;
|
package com.ktg.mes.md.controller;
|
||||||
|
|
||||||
|
import com.ktg.mes.aspect.BarcodeGen;
|
||||||
import com.ktg.mes.md.service.IMdItemService;
|
import com.ktg.mes.md.service.IMdItemService;
|
||||||
import com.ktg.common.annotation.Log;
|
import com.ktg.common.annotation.Log;
|
||||||
import com.ktg.common.constant.UserConstants;
|
import com.ktg.common.constant.UserConstants;
|
||||||
@ -59,6 +60,7 @@ public class MdItemController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('mes:md:mditem:add')")
|
@PreAuthorize("@ss.hasPermi('mes:md:mditem:add')")
|
||||||
@Log(title = "物料管理",businessType = BusinessType.INSERT)
|
@Log(title = "物料管理",businessType = BusinessType.INSERT)
|
||||||
|
@BarcodeGen(barcodeType = UserConstants.BARCODE_TYPE_ITEM)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody MdItem mdItem){
|
public AjaxResult add(@Validated @RequestBody MdItem mdItem){
|
||||||
if(UserConstants.NOT_UNIQUE.equals(mdItemService.checkItemCodeUnique(mdItem))){
|
if(UserConstants.NOT_UNIQUE.equals(mdItemService.checkItemCodeUnique(mdItem))){
|
||||||
|
@ -108,7 +108,7 @@ public class WmBarcodeConfigServiceImpl implements IWmBarcodeConfigService
|
|||||||
param.setBarcodeType(barcodeType);
|
param.setBarcodeType(barcodeType);
|
||||||
List<WmBarcodeConfig> configs = wmBarcodeConfigMapper.selectWmBarcodeConfigList(param);
|
List<WmBarcodeConfig> configs = wmBarcodeConfigMapper.selectWmBarcodeConfigList(param);
|
||||||
if(!CollectionUtils.isEmpty(configs)){
|
if(!CollectionUtils.isEmpty(configs)){
|
||||||
return configs.get(0).getAutoGenFlag() == UserConstants.YES ?true:false;
|
return UserConstants.YES.equals(configs.get(0).getAutoGenFlag())?true:false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user