Merge branch 'refs/heads/dev' into test
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.zt.plat.module.contractorder.api;
|
package com.zt.plat.module.contractorder.api;
|
||||||
|
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.module.contractorder.api.dto.ContractFormulaRespDTO;
|
import com.zt.plat.module.contractorder.api.dto.ContractFormulaRespDTO;
|
||||||
import com.zt.plat.module.contractorder.enums.ApiConstants;
|
import com.zt.plat.module.contractorder.enums.ApiConstants;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -19,4 +20,7 @@ public interface ContractApi {
|
|||||||
@GetMapping(PREFIX + "/formulas")
|
@GetMapping(PREFIX + "/formulas")
|
||||||
@Operation(summary = "通过合同编号获取对应的结算条款数据")
|
@Operation(summary = "通过合同编号获取对应的结算条款数据")
|
||||||
List<ContractFormulaRespDTO> getFormulas(@RequestParam("contractPaperNumber") String contractPaperNumber);
|
List<ContractFormulaRespDTO> getFormulas(@RequestParam("contractPaperNumber") String contractPaperNumber);
|
||||||
|
@GetMapping(PREFIX + "/updateOrderStatus")
|
||||||
|
@Operation(summary = "更新订单状态")
|
||||||
|
CommonResult<Boolean> updateOrderStatus(@RequestParam("orderId") Long orderId, @RequestParam("status") String status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode PURCHASE_ORDER_NOT_EXISTS = new ErrorCode(1_008_000_001, "采购订单不存在");
|
ErrorCode PURCHASE_ORDER_NOT_EXISTS = new ErrorCode(1_008_000_001, "采购订单不存在");
|
||||||
ErrorCode ORDER_ID_NOT_EXISTS = new ErrorCode(1_008_000_010, "订单id不能为空");
|
ErrorCode ORDER_ID_NOT_EXISTS = new ErrorCode(1_008_000_010, "订单id不能为空");
|
||||||
ErrorCode PRCH_ORD_DTL_NOT_EXISTS = new ErrorCode(1_008_001_001, "采购订单明细不存在");
|
ErrorCode PRCH_ORD_DTL_NOT_EXISTS = new ErrorCode(1_008_001_001, "采购订单明细不存在");
|
||||||
|
ErrorCode PURCHASE_ORDER_STATUS_ERROR = new ErrorCode(1_008_001_020, "订单状态不存在");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.zt.plat.module.contractorder.api;
|
package com.zt.plat.module.contractorder.api;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.module.contractorder.api.dto.ContractFormulaRespDTO;
|
import com.zt.plat.module.contractorder.api.dto.ContractFormulaRespDTO;
|
||||||
import com.zt.plat.module.contractorder.service.contract.ContractService;
|
import com.zt.plat.module.contractorder.service.contract.ContractService;
|
||||||
|
import com.zt.plat.module.contractorder.service.purchaseorder.PurchaseOrderService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -9,6 +11,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Validated
|
@Validated
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -16,9 +20,16 @@ public class ContractApiImpl implements ContractApi {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ContractService contractService;
|
private ContractService contractService;
|
||||||
|
@Resource
|
||||||
|
private PurchaseOrderService purchaseOrderService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ContractFormulaRespDTO> getFormulas(String contractPaperNumber) {
|
public List<ContractFormulaRespDTO> getFormulas(String contractPaperNumber) {
|
||||||
return contractService.getFormulasByPaperNumber(contractPaperNumber);
|
return contractService.getFormulasByPaperNumber(contractPaperNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<Boolean> updateOrderStatus(Long orderId, String status) {
|
||||||
|
return success(purchaseOrderService.updateOrderStatus(orderId, status));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,4 +67,11 @@ public interface PurchaseOrderService {
|
|||||||
|
|
||||||
String submitErp(List<Long> ids);
|
String submitErp(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过订单id更新订单状态
|
||||||
|
*
|
||||||
|
* @param orderId status 订单id 订单状态
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
boolean updateOrderStatus(Long orderId, String status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ import com.zt.plat.framework.common.util.object.BeanUtils;
|
|||||||
|
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.module.contractorder.enums.purchaseorder.ErrorCodeConstants.ORDER_ID_NOT_EXISTS;
|
import static com.zt.plat.module.contractorder.enums.purchaseorder.ErrorCodeConstants.*;
|
||||||
import static com.zt.plat.module.contractorder.enums.purchaseorder.ErrorCodeConstants.PURCHASE_ORDER_NOT_EXISTS;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,5 +239,16 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateOrderStatus(Long orderId, String status) {
|
||||||
|
// 校验存在
|
||||||
|
validatePurchaseOrderExists(orderId);
|
||||||
|
PurchaseOrderStatusEnum byCode = PurchaseOrderStatusEnum.getByCode(status);
|
||||||
|
if (byCode== null){
|
||||||
|
throw exception(PURCHASE_ORDER_STATUS_ERROR);
|
||||||
|
}
|
||||||
|
return purchaseOrderMapper.updateById(new PurchaseOrderDO().setId(orderId).setStatus(status))>0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode ERP_NOT_EXISTS = new ErrorCode(1_000_000_001, "获取ERP数据为空");
|
ErrorCode ERP_NOT_EXISTS = new ErrorCode(1_000_000_001, "获取ERP数据为空");
|
||||||
ErrorCode ERP_NOT_JSON_EXISTS = new ErrorCode(1_000_000_002, "ERP接口响应无法解析为JSON");
|
ErrorCode ERP_NOT_JSON_EXISTS = new ErrorCode(1_000_000_002, "ERP接口响应无法解析为JSON");
|
||||||
ErrorCode ERP_ERROR_EXISTS = new ErrorCode(1_000_000_003, "调用ERP RFC接口失败");
|
ErrorCode ERP_ERROR_EXISTS = new ErrorCode(1_000_000_003, "调用ERP RFC接口失败");
|
||||||
|
ErrorCode ERP_REDIS_EXISTS = new ErrorCode(1_000_000_004, "公司调用缓存失败");
|
||||||
|
|
||||||
ErrorCode ERP_CUSTOMER_NOT_EXISTS = new ErrorCode(1_001_000_001, "ERP客商主数据不存在");
|
ErrorCode ERP_CUSTOMER_NOT_EXISTS = new ErrorCode(1_001_000_001, "ERP客商主数据不存在");
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,12 @@ public class ErpCompanyController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/test")
|
||||||
|
@Operation(summary = "定时获得erp更新公司")
|
||||||
|
@PreAuthorize("@ss.hasPermission('sply:erp-company:create')")
|
||||||
|
public CommonResult<Boolean> test() {
|
||||||
|
erpCompanyService.test();
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -70,4 +70,6 @@ public interface ErpCompanyService {
|
|||||||
* @return ERP公司
|
* @return ERP公司
|
||||||
*/
|
*/
|
||||||
ErpCompanyDO getErpCompanyByNumber(String number);
|
ErpCompanyDO getErpCompanyByNumber(String number);
|
||||||
|
|
||||||
|
void test();
|
||||||
}
|
}
|
||||||
@@ -131,8 +131,9 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
|||||||
saveData(result);
|
saveData(result);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("调用ERP RFC接口失败: {}", e);
|
// log.error("调用ERP RFC接口失败: {}", e);
|
||||||
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
throw e;
|
||||||
|
// throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,4 +236,18 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
|||||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void test() {
|
||||||
|
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.公司代码;
|
||||||
|
String funcnr = funcnrEnum.getFuncnr();
|
||||||
|
//防止缓存数据丢失
|
||||||
|
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||||
|
myRedisConfig.getRedisCacheMap(key);
|
||||||
|
// 1. 调用ERP接口获取数据
|
||||||
|
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
|
||||||
|
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||||
|
if (CollUtil.isEmpty(dataArray)) {
|
||||||
|
throw exception(ERP_COMPANY_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,8 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||||
import static dm.jdbc.util.DriverUtil.log;
|
import static dm.jdbc.util.DriverUtil.log;
|
||||||
|
|
||||||
|
|
||||||
@@ -72,8 +74,6 @@ public class MyRedisConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//list
|
//list
|
||||||
public Map<String, List<String>> numbers(JSONArray dataArray, String key, String dataKey) {
|
public Map<String, List<String>> numbers(JSONArray dataArray, String key, String dataKey) {
|
||||||
// 使用 Redis 获取缓存数据
|
// 使用 Redis 获取缓存数据
|
||||||
@@ -152,9 +152,13 @@ public class MyRedisConfig {
|
|||||||
|
|
||||||
//map
|
//map
|
||||||
public Map<String, Long> getRedisCacheMap(String key) {
|
public Map<String, Long> getRedisCacheMap(String key) {
|
||||||
// 使用 Redis 获取缓存数据
|
try {
|
||||||
Map<String, Long> result = (Map<String, Long>) redisTemplate.opsForHash().entries(key);
|
// 使用 Redis 获取缓存数据
|
||||||
return result;
|
Map<String, Long> result = (Map<String, Long>) redisTemplate.opsForHash().entries(key);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw exception(ERP_REDIS_EXISTS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRedisCacheMap(String key, Map<String, Long> allnumbers) {
|
public void addRedisCacheMap(String key, Map<String, Long> allnumbers) {
|
||||||
@@ -179,13 +183,4 @@ public class MyRedisConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user