erp工厂新增、编辑、批量更新、定时任务、分页查询优化
This commit is contained in:
@@ -88,6 +88,14 @@ public class ErpFactoryController {
|
||||
return success(BeanUtils.toBean(pageResult, ErpFactoryRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/pageByCpn")
|
||||
@Operation(summary = "获得ERP工厂分页")
|
||||
@PreAuthorize("@ss.hasPermission('base:erp-factory:query')")
|
||||
public CommonResult<PageResult<ErpFactoryRespVO>> getErpFactoryPageByCpn(@Valid ErpFactoryPageReqVO pageReqVO) {
|
||||
PageResult<ErpFactoryDO> pageResult = erpFactoryService.getErpFactoryPageByCpn(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ErpFactoryRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出ERP工厂 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('base:erp-factory:export')")
|
||||
@@ -101,6 +109,14 @@ public class ErpFactoryController {
|
||||
BeanUtils.toBean(list, ErpFactoryRespVO.class));
|
||||
}
|
||||
|
||||
@PutMapping("/enable-list")
|
||||
@Operation(summary = "批量更新")
|
||||
@PreAuthorize("@ss.hasPermission('base:erp-factory:update')")
|
||||
public CommonResult<Boolean> enableFactoryList(@RequestBody List<ErpFactoryRespVO> saveReqVOS) {
|
||||
erpFactoryService.enableFactoryList(saveReqVOS);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/getErpFactoryTask")
|
||||
@Operation(summary = "定时获得erp工厂数据")
|
||||
@PreAuthorize("@ss.hasPermission('base:erp-factory:create')")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.module.erp.controller.admin.erp.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@@ -14,4 +15,13 @@ public class ErpFactoryPageReqVO extends PageParam {
|
||||
@Schema(description = "工厂编码")
|
||||
private String number;
|
||||
|
||||
@Schema(description = "公司编号")
|
||||
private String companyNumber;
|
||||
|
||||
@Schema(description = "公司名称")
|
||||
private String companyName;
|
||||
|
||||
@Schema(description = "类型")
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -22,4 +22,18 @@ public class ErpFactoryRespVO {
|
||||
@ExcelProperty("工厂编码")
|
||||
private String number;
|
||||
|
||||
@Schema(description = "公司编号")
|
||||
private String companyNumber;
|
||||
|
||||
@Schema(description = "类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "绑定工厂名")
|
||||
private String relName;
|
||||
|
||||
@Schema(description = "绑定工厂编码")
|
||||
private String relnumber;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private String isEnable;
|
||||
}
|
||||
@@ -19,4 +19,21 @@ public class ErpFactorySaveReqVO {
|
||||
@NotEmpty(message = "工厂编码不能为空")
|
||||
private String number;
|
||||
|
||||
@Schema(description = "公司编号")
|
||||
private String companyNumber;
|
||||
|
||||
@Schema(description = "公司编号")
|
||||
private String companyName;
|
||||
|
||||
@Schema(description = "类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "绑定工厂名")
|
||||
private String relName;
|
||||
|
||||
@Schema(description = "绑定工厂编码")
|
||||
private String relnumber;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private String isEnable;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.zt.plat.module.erp.dal.dataobject.erp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* ERP工厂 DO
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
* ERP工厂 DO
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@TableName("sply_erp_fact")
|
||||
@KeySequence("sply_erp_fact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@@ -16,31 +18,58 @@ import lombok.*;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
/**
|
||||
* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO
|
||||
*/
|
||||
public class ErpFactoryDO {
|
||||
|
||||
|
||||
* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO
|
||||
*/
|
||||
public class ErpFactoryDO extends BusinessBaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 工厂名称
|
||||
*/
|
||||
* 工厂名称
|
||||
*/
|
||||
@TableField("NAME")
|
||||
private String name;
|
||||
/**
|
||||
* 工厂编码
|
||||
*/
|
||||
* 工厂编码
|
||||
*/
|
||||
@TableField("NUM")
|
||||
private String number;
|
||||
/**
|
||||
* 公司编号
|
||||
*/
|
||||
* 公司编号
|
||||
*/
|
||||
@TableField("CPN_ID")
|
||||
private String companyId;
|
||||
private String companyNumber;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@TableField("TP")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 绑定工厂名
|
||||
*/
|
||||
@TableField("REL_NAME")
|
||||
private String relName;
|
||||
|
||||
/**
|
||||
* 绑定工厂编码
|
||||
*/
|
||||
@TableField("REL_NUM")
|
||||
private String relnumber;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@TableField("IS_ENB")
|
||||
private String isEnable;
|
||||
}
|
||||
@@ -41,4 +41,10 @@ public class ErpWarehouseDO {
|
||||
@TableField("NUM")
|
||||
private String number;
|
||||
|
||||
/**
|
||||
* 类别
|
||||
*/
|
||||
@TableField("TP")
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -25,6 +25,4 @@ public interface ErpBomMapper extends BaseMapperX<ErpBomDO> {
|
||||
.eqIfPresent(ErpBomDO::getUnit, reqVO.getUnit())
|
||||
.orderByDesc(ErpBomDO::getId));
|
||||
}
|
||||
|
||||
Long insertGetId(ErpBomDO aDo);
|
||||
}
|
||||
@@ -29,6 +29,4 @@ public interface ErpCostcenterMapper extends BaseMapperX<ErpCostcenterDO> {
|
||||
.betweenIfPresent(ErpCostcenterDO::getEndDate, reqVO.getEndDate())
|
||||
.orderByDesc(ErpCostcenterDO::getId));
|
||||
}
|
||||
|
||||
void updateBatchByNumber(@Param("list") List<ErpCostcenterDO> toUpdate);
|
||||
}
|
||||
@@ -22,9 +22,11 @@ public interface ErpFactoryMapper extends BaseMapperX<ErpFactoryDO> {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ErpFactoryDO>()
|
||||
.likeIfPresent(ErpFactoryDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ErpFactoryDO::getNumber, reqVO.getNumber())
|
||||
.eqIfPresent(ErpFactoryDO::getType, reqVO.getType())
|
||||
.orderByDesc(ErpFactoryDO::getId));
|
||||
}
|
||||
|
||||
void updateBatch(@Param("toUpdate") List<ErpFactoryDO> toUpdate);
|
||||
String selectMaxCode();
|
||||
|
||||
List<ErpFactoryDO> getPageByReq(ErpFactoryPageReqVO pageReqVO);
|
||||
}
|
||||
@@ -77,12 +77,12 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteErpContractListByIds(List<Long> ids) {
|
||||
public void deleteErpContractListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateErpContractExists(ids);
|
||||
// 删除
|
||||
erpContractMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateErpContractExists(List<Long> ids) {
|
||||
List<ErpContractDO> list = erpContractMapper.selectByIds(ids);
|
||||
@@ -177,17 +177,44 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
@XxlJob("getErpContractTask")
|
||||
public void callErpRfcInterface() {
|
||||
try {
|
||||
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.合同信息;
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.合同信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String commanyKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(commanyKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
}
|
||||
String cstmKey = "erpMap" + OftenEnum.FuncnrEnum.客商信息.getFuncnr();
|
||||
Map<String, Long> redisCachecstmKey = myRedisConfig.getRedisCacheMap(cstmKey);
|
||||
if (CollUtil.isEmpty(redisCachecstmKey)) {
|
||||
return;
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (CollUtil.isEmpty(dataArray)) {
|
||||
for (String INEDR : new String[]{"1", "2"}) {
|
||||
req.put("INEDR", INEDR);
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
for (String partner : redisCachecstmKey.keySet()) {
|
||||
req.put("PARTNER", partner);
|
||||
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray!= null) {
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArray,funcnrEnum);
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
|
||||
// 3. 批量保存数据
|
||||
saveData(result);
|
||||
@@ -203,7 +230,7 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erp" + funcnr.getFuncnr();
|
||||
Map<String,List<String>> numbers = myRedisConfig.numbers(dataArray, key,funcnr.getDatakey());
|
||||
Map<String, List<String>> numbers = myRedisConfig.numbers(dataArray, key, funcnr.getDatakey());
|
||||
List<String> allnumbers = numbers.get("all");
|
||||
List<String> comnumbers = numbers.get("com");
|
||||
List<ErpContractDO> toUpdate = new ArrayList<>();
|
||||
@@ -229,7 +256,7 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
}
|
||||
}
|
||||
|
||||
return new ProcessingResult(toUpdate, toInsert,key,allnumbers);
|
||||
return new ProcessingResult(toUpdate, toInsert, key, allnumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +270,7 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpContractMapper.updateBatch(result.toUpdate);
|
||||
}
|
||||
myRedisConfig.updateRedisCache(result.key,result.allnumbers);
|
||||
myRedisConfig.updateRedisCache(result.key, result.allnumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,7 +282,7 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
private final String key;
|
||||
private final List<String> allnumbers;
|
||||
|
||||
public ProcessingResult(List<ErpContractDO> toUpdate, List<ErpContractDO> toInsert,String key,List<String> allnumbers) {
|
||||
public ProcessingResult(List<ErpContractDO> toUpdate, List<ErpContractDO> toInsert, String key, List<String> allnumbers) {
|
||||
this.toUpdate = toUpdate;
|
||||
this.toInsert = toInsert;
|
||||
this.key = key;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user