Merge branch 'dev_20260429' into dev_WMS20260401
# Conflicts: # mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java # mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/UserServiceFeign.java # mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteOmsFeignFallbackFactory.java # mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteUserFeignFallbackFactory.java # mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/batchDetail/BatchDetailApplicationService.java # mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/batchDetail/service/BatchDetailDomainService.java # mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/sysTableConfig/SysTableConfigApi.java
This commit is contained in:
+2
-2
@@ -106,10 +106,10 @@ public class BatchDetailApplicationService {
|
||||
throw new ServiceException("获取物料规则信息失败");
|
||||
}
|
||||
MaterialGoodsRuleFeign materialGoodsRuleFeign = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), MaterialGoodsRuleFeign.class);
|
||||
// 无商品规则或未绑定批次模板时,不返回任何批次属性(避免 batchId 空导致查全表)
|
||||
if (ObjectUtil.isNull(materialGoodsRuleFeign) || materialGoodsRuleFeign.getBatchId() == null) {
|
||||
// 未绑定批次时只返回空列表,不可按空 batchId 全表查 batch_detail
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return getBatchDetailListByBatchId(materialGoodsRuleFeign.getBatchId());
|
||||
}
|
||||
}
|
||||
}
|
||||
+253
@@ -337,6 +337,165 @@ public class ContractManageApplicationService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 单据类型「仓库进出仓单」编码(与 BMS / WMS 推送一致) */
|
||||
public static final String DOCUMENT_TYPE_CODE_WAREHOUSE_IN_OUT_ORDER = "WMS_ckjccd";
|
||||
|
||||
/**
|
||||
* 按结算主体取仓储合同结算设置中,单据类型包含指定类型的费用科目编码(按明细行顺序,可重复,调用方去重)。
|
||||
* 科目编码优先取二级 {@code second_subject_code},为空则取一级 {@code first_subject_code}。
|
||||
* settlementCustomersCode 为空时与同模块合同逻辑一致:使用通用仓储合同(commonContractFlag=1)。
|
||||
*/
|
||||
public List<String> listSecondSubjectCodesBySettlementAndDocumentType(String settlementCustomersCode,
|
||||
Long organizationId,
|
||||
Long topOrganizationId,
|
||||
String documentTypeCode) {
|
||||
if (StringUtils.isEmpty(documentTypeCode)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ContractManagePO contractManagePO = getInfoByCustomerAndOrganizationId(settlementCustomersCode, 1, topOrganizationId, organizationId);
|
||||
if (contractManagePO == null || contractManagePO.getContractManageId() == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ContractManageDetailPO> detailPOS = contractManageDetailDomainService.queryListByManageId(contractManagePO.getContractManageId());
|
||||
if (detailPOS == null || detailPOS.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> codes = new ArrayList<>();
|
||||
for (ContractManageDetailPO detail : detailPOS) {
|
||||
if (detail == null) {
|
||||
continue;
|
||||
}
|
||||
String subjectCode = resolveContractDetailExpenseSubjectCode(detail);
|
||||
if (StringUtils.isEmpty(subjectCode)) {
|
||||
continue;
|
||||
}
|
||||
if (!matchesContractDetailWarehouseInOut(detail, documentTypeCode)) {
|
||||
continue;
|
||||
}
|
||||
codes.add(subjectCode);
|
||||
}
|
||||
return codes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合同结算行的费用科目编码:有二级科目用二级,否则用一级。
|
||||
*/
|
||||
private static String resolveContractDetailExpenseSubjectCode(ContractManageDetailPO detail) {
|
||||
if (detail == null) {
|
||||
return null;
|
||||
}
|
||||
if (!StringUtils.isEmpty(detail.getSecondSubjectCode())) {
|
||||
return detail.getSecondSubjectCode().trim();
|
||||
}
|
||||
if (!StringUtils.isEmpty(detail.getFirstSubjectCode())) {
|
||||
return detail.getFirstSubjectCode().trim();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否属于「仓库进出仓单」类结算行:优先按单据类型编码精确匹配(含逗号分隔多编码),
|
||||
* 避免因 BMS 主数据编码与 WMS 计费推送编码(如 WMS_ckjccd)不一致导致筛掉全部行;
|
||||
* 兼容按单据类型名称包含「仓库进出仓」判定(合同保存时会拼接中文名称)。
|
||||
*/
|
||||
private static boolean matchesContractDetailWarehouseInOut(ContractManageDetailPO detail, String documentTypeCode) {
|
||||
if (detail == null || StringUtils.isEmpty(documentTypeCode)) {
|
||||
return false;
|
||||
}
|
||||
if (contractDetailContainsDocumentType(detail.getDocumentTypeCode(), documentTypeCode)) {
|
||||
return true;
|
||||
}
|
||||
String typeNames = detail.getDocumentType();
|
||||
if (StringUtils.isEmpty(typeNames)) {
|
||||
return false;
|
||||
}
|
||||
return Stream.of(typeNames.split(","))
|
||||
.map(String::trim)
|
||||
.filter(s -> !StringUtils.isEmpty(s))
|
||||
.anyMatch(n -> n.contains("仓库进出仓"));
|
||||
}
|
||||
|
||||
private static boolean contractDetailContainsDocumentType(String detailDocumentTypeCodes, String documentTypeCode) {
|
||||
if (StringUtils.isEmpty(detailDocumentTypeCodes)) {
|
||||
return false;
|
||||
}
|
||||
return Stream.of(detailDocumentTypeCodes.split(","))
|
||||
.map(String::trim)
|
||||
.filter(s -> !StringUtils.isEmpty(s))
|
||||
.anyMatch(code -> code.equalsIgnoreCase(documentTypeCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按单据类型取合同结算行上的计费单价(计费策略展开的 isFee 项)。
|
||||
* <p>多条结算明细共用同一计费策略(accounting_strategy_id 相同)时,只展开一次策略参数,
|
||||
* 避免前端出现重复的单价列。</p>
|
||||
*/
|
||||
public List<SubjectAndPriceReturn> getPrice(String documentTypeCode, String settlementCustomersCode,Long organizationId,Long topOrganizationId) {
|
||||
List<SubjectAndPriceReturn> result = new ArrayList<>();
|
||||
ContractManagePO contractManagePO = getInfoByCustomerAndOrganizationId(settlementCustomersCode, 1, topOrganizationId, organizationId);
|
||||
List<ContractManageDetailPO> detailPOS = contractManageDetailDomainService.queryListByManageId(contractManagePO.getContractManageId());
|
||||
contractManagePO.setContractManageDetailPOList(detailPOS);
|
||||
if (contractManagePO != null) {
|
||||
List<ContractManageDetailPO> contractManageDetailPOList = contractManagePO.getContractManageDetailPOList();
|
||||
if (contractManageDetailPOList != null && contractManageDetailPOList.size() > 0) {
|
||||
List<ContractManageDetailPO> contractManageDetailPOs = contractManageDetailPOList.stream()
|
||||
.filter(item -> contractDetailContainsDocumentType(item.getDocumentTypeCode(), documentTypeCode))
|
||||
.collect(Collectors.toList());
|
||||
if (contractManageDetailPOs != null && contractManageDetailPOs.size() > 0) {
|
||||
Set<Long> expandedAccountingStrategyIds = new HashSet<>();
|
||||
for (ContractManageDetailPO contractManageDetailPO : contractManageDetailPOs) {
|
||||
Long accountingStrategyId = contractManageDetailPO.getAccountingStrategyId();
|
||||
if (accountingStrategyId == null || !expandedAccountingStrategyIds.add(accountingStrategyId)) {
|
||||
continue;
|
||||
}
|
||||
List<BillingParamsPO> billingParams = contractManageDetailMapper.getBillingParams(accountingStrategyId);
|
||||
if (billingParams != null && billingParams.size() > 0) {
|
||||
//if (billingParams != null && billingParams.size() > 0) {
|
||||
BillingParamsPO billingParam = billingParams.get(0);
|
||||
String billingParamsJson = billingParam.getBillingParamsJson();
|
||||
String preSetRules = billingParam.getPreSetRules();
|
||||
Long billingParamsId = billingParam.getBillingParamsId();
|
||||
List<Map<String, Object>> preSetRulesList = JSON.parseObject(preSetRules, new TypeReference<List<Map<String, Object>>>() {});
|
||||
List<Map<String, Object>> billingParamsList = JSON.parseObject(billingParamsJson, new TypeReference<List<Map<String, Object>>>() {});
|
||||
if (preSetRulesList != null && preSetRulesList.size() > 0) {
|
||||
Map<String, Object> stringObjectMap1 = preSetRulesList.get(0);
|
||||
for (Map<String, Object> stringObjectMap : billingParamsList) {
|
||||
String fieldsName = (String) stringObjectMap.get("fieldsName");
|
||||
String isShow = (String) stringObjectMap.get("isShow");
|
||||
String isFee = (String) stringObjectMap.get("isFee");
|
||||
String isPush = (String) stringObjectMap.get("isPush");
|
||||
if ("1".equals(isFee)) {
|
||||
Integer sort = (Integer) stringObjectMap.get("sort");
|
||||
String chargingId = (String) stringObjectMap.get("chargingId");
|
||||
String fields = (String) stringObjectMap.get("fields");
|
||||
String price = (String) stringObjectMap1.get("fields" + sort);
|
||||
SubjectAndPriceReturn subjectAndPriceReturn = new SubjectAndPriceReturn();
|
||||
subjectAndPriceReturn.setName(fieldsName);
|
||||
subjectAndPriceReturn.setPrice(new BigDecimal(price));
|
||||
subjectAndPriceReturn.setChargingId(chargingId);
|
||||
subjectAndPriceReturn.setFields(fields);
|
||||
subjectAndPriceReturn.setBillingRulesId(accountingStrategyId);
|
||||
subjectAndPriceReturn.setIsShow(isShow);
|
||||
subjectAndPriceReturn.setIsFee(isFee);
|
||||
subjectAndPriceReturn.setIsPush(isPush);
|
||||
subjectAndPriceReturn.setRulesId(billingParamsId);
|
||||
result.add(subjectAndPriceReturn);
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
} else {
|
||||
throw new ServiceException("计费参数不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ServiceException("合同信息不存在");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<SubjectAndPriceReturn> getSubject(SubjectAndPriceDTO contractManageDTO) {
|
||||
List<SubjectAndPriceReturn> result = new ArrayList<>();
|
||||
Long settlementCustomersId = contractManageDTO.getSettlementCustomersId();
|
||||
@@ -757,6 +916,100 @@ public class ContractManageApplicationService {
|
||||
return resultContract;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据结算主体获取合同信息
|
||||
* @param settlementCustomersCode 结算主体code
|
||||
* @param contractType 合同类型
|
||||
*/
|
||||
public ContractManagePO getInfoByCustomerAndOrganizationId(String settlementCustomersCode,Integer contractType, Long topOrganizationId, Long organizationId) {
|
||||
/*
|
||||
首先根据合同类型(仓储、运输),以及结算客户,查询合同信息
|
||||
如果传了结算主体,则根据结算主体以及当前时间查询有效的特殊合同,如果特殊合同没有,则查询通用合同
|
||||
*/
|
||||
//获取当前登录人信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser) && topOrganizationId == null) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
if(contractType==null){
|
||||
throw new ServiceException("合同类型不能为空");
|
||||
}
|
||||
ContractManagePO resultContract = new ContractManagePO();
|
||||
//查询当前日期在有效期内的合同
|
||||
ContractManageDO queryParam = new ContractManageDO();
|
||||
queryParam.setNowDateString(DateUtil.format(new Date(),"yyyy-MM-dd"));
|
||||
if (!ObjectUtil.isNull(loginUser)) {
|
||||
queryParam.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}else {
|
||||
queryParam.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(organizationId)) {
|
||||
queryParam.setOrganizationId(organizationId);
|
||||
}
|
||||
List<ContractManagePO> contractManagePOList = contractManageDomainService.queryList(queryParam);
|
||||
if(contractManagePOList != null && contractManagePOList.size()>0){
|
||||
if(StringUtils.isNotEmpty(settlementCustomersCode)){
|
||||
//根据结算对象,及合同的类型 查询对应合同信息
|
||||
ContractManagePO contractManagePO = contractManagePOList.stream()
|
||||
.filter(item -> item.getSettlementCustomersCode().equals(settlementCustomersCode) && Objects.equals(item.getContractType(), contractType)).findFirst().orElse(null);
|
||||
if(null == contractManagePO){
|
||||
if(contractType==1){
|
||||
//仓储合同
|
||||
resultContract = contractManagePOList.stream()
|
||||
.filter(item ->
|
||||
item.getContractType()==1 &&
|
||||
item.getCommonContractFlag() == 1 && item.getContractState() ==2)
|
||||
.findFirst().orElse(null);
|
||||
}else{
|
||||
//运输合同
|
||||
resultContract = contractManagePOList.stream().filter(item -> item.getContractType()==2
|
||||
&& item.getCommonContractFlag() == 1 && item.getContractState() ==2).findFirst().orElse(null);
|
||||
}
|
||||
}else {
|
||||
resultContract = contractManagePO;
|
||||
}
|
||||
}else {
|
||||
if(contractType==1){
|
||||
//仓储合同
|
||||
resultContract = contractManagePOList.stream().filter(contractManagePO -> contractManagePO.getContractType()==1
|
||||
&& contractManagePO.getCommonContractFlag() == 1 && contractManagePO.getContractState() ==2).findFirst().orElse(null);
|
||||
}else{
|
||||
//运输合同
|
||||
resultContract = contractManagePOList.stream().filter(contractManagePO -> contractManagePO.getContractType()==2
|
||||
&& contractManagePO.getCommonContractFlag() == 1 && contractManagePO.getContractState() ==2).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
if(null == resultContract){
|
||||
throw new ServiceException("找不到匹配的合同,请重试");
|
||||
}
|
||||
//得到合同后,查询合同明细
|
||||
List<ContractManageDetailPO> contractManageDetailPOList = contractManageDetailDomainService.queryListByManageId(resultContract.getContractManageId());
|
||||
List<ContractManageDetailPO> contractManageDetailSaveList = new ArrayList<>();
|
||||
if(contractManageDetailPOList != null && contractManageDetailPOList.size()>0){
|
||||
//将临时合同中没有,但是通用合同中有的数据过滤出(使用 ObjectUtil.equal 避免 firstSubjectCode/secondSubjectCode 为 null 时 NPE)
|
||||
contractManageDetailSaveList = contractManageDetailPOList.stream().filter(item -> contractManageDetailPOList.stream().noneMatch(item1 -> ObjectUtil.equal(item1.getFirstSubjectCode(), item.getFirstSubjectCode()) && ObjectUtil.equal(item1.getSecondSubjectCode(), item.getSecondSubjectCode()) && item1.getSubjectType()==1)).collect(Collectors.toList());
|
||||
//首先根据结算科目类型将临时合同过滤出
|
||||
List<ContractManageDetailPO> tempContractManageDetailPOList = contractManageDetailPOList.stream().filter(item -> item.getSubjectType()==2).collect(Collectors.toList());
|
||||
//遍历两个集合,将相同费用科目code的数据,进行比较,如果结算科目类型是临时且合同有效期有效,则使用该条数据,将另一条移除
|
||||
for (ContractManageDetailPO manageDetailPO : tempContractManageDetailPOList) {
|
||||
for (ContractManageDetailPO contractManageDetailPO : contractManageDetailPOList) {
|
||||
if(ObjectUtil.equal(contractManageDetailPO.getFirstSubjectCode(), manageDetailPO.getFirstSubjectCode()) && ObjectUtil.equal(contractManageDetailPO.getSecondSubjectCode(), manageDetailPO.getSecondSubjectCode())){
|
||||
//判断如果是临时合同在有效期内,则将该条数据保存到集合contractManageDetailSaveList
|
||||
DateTime start = DateUtil.parseDate(DateUtil.format(manageDetailPO.getSubjectEffectiveDate(),"yyyy-MM-dd"));
|
||||
DateTime end = DateUtil.parseDateTime(DateUtil.format(manageDetailPO.getSubjectEffectiveDate(),"yyyy-MM-dd"));
|
||||
DateTime now = DateUtil.beginOfDay(DateUtil.date());
|
||||
if (now.isAfterOrEquals(start) && now.isBefore(end)) {
|
||||
contractManageDetailSaveList.add(manageDetailPO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resultContract.setContractManageDetailPOList(contractManageDetailSaveList);
|
||||
}
|
||||
return resultContract;
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废合同
|
||||
* @param contractManageDTO
|
||||
|
||||
+59
@@ -9,6 +9,7 @@ import com.mhd.basic.domain.expenseAccount.repository.po.QueryExpenseAccountPO;
|
||||
import com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDO;
|
||||
import com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDoMap;
|
||||
import com.mhd.basic.domain.expenseAccount.repository.todo.SearchExpenseAccountDO;
|
||||
import com.mhd.basic.application.service.contractManage.ContractManageApplicationService;
|
||||
import com.mhd.basic.domain.expenseAccount.service.ExpenseAccountDomainService;
|
||||
import com.mhd.basic.infrastructure.feign.vo.SysDictDataVo;
|
||||
import com.mhd.basic.interfaces.dto.expenseAccount.ExpenseAccountDTO;
|
||||
@@ -27,8 +28,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -45,8 +48,64 @@ public class ExpenseAccountApplicationService {
|
||||
@Autowired
|
||||
private ExpenseAccountDomainService expenseAccountDomainService;
|
||||
@Autowired
|
||||
private ContractManageApplicationService contractManageApplicationService;
|
||||
@Autowired
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
|
||||
/**
|
||||
* 入库/出库费用登记等场景:按仓储合同「仓库进出仓单」结算行取科目(二级编码优先,否则一级),再关联费用科目主数据。
|
||||
* <p>科目范围以合同结算设置为准;若 {@code expenseAccountDO.inOrderDisplay} 或 {@code expenseAccountDO.outOrderDisplay} 非空,
|
||||
* 再按主数据「入库单是否固定显示 / 出库单是否固定显示」(0-否 1-是)与入参相等过滤,二者同时传则同时满足(AND)。</p>
|
||||
* settlementCustomersCode 不传或为空时使用通用仓储合同。
|
||||
*/
|
||||
public List<ExpenseAccountPO> queryListFromContractWarehouseInOutSettlement(ExpenseAccountDO expenseAccountDO, String settlementCustomersCode) {
|
||||
Long topOrgIdForExpense = expenseAccountDO.getTopOrganizationId();
|
||||
if (topOrgIdForExpense == null) {
|
||||
LoginUser lu = SecurityUtils.getLoginUser();
|
||||
if (lu != null && lu.getUserPo() != null && lu.getUserPo().getTopOrganizationId() != null) {
|
||||
topOrgIdForExpense = lu.getUserPo().getTopOrganizationId();
|
||||
}
|
||||
}
|
||||
List<String> orderedCodes = contractManageApplicationService.listSecondSubjectCodesBySettlementAndDocumentType(
|
||||
settlementCustomersCode,
|
||||
expenseAccountDO.getOrganizationId(),
|
||||
topOrgIdForExpense,
|
||||
ContractManageApplicationService.DOCUMENT_TYPE_CODE_WAREHOUSE_IN_OUT_ORDER);
|
||||
log.info("按合同取费用科目编码:topOrgIdForExpense={}, 命中结算行科目数={}", topOrgIdForExpense,
|
||||
orderedCodes != null ? orderedCodes.size() : 0);
|
||||
boolean filterIn = expenseAccountDO.getInOrderDisplay() != null;
|
||||
boolean filterOut = expenseAccountDO.getOutOrderDisplay() != null;
|
||||
if (filterIn || filterOut) {
|
||||
log.info("合同科目叠加主数据出入库显示过滤:inOrderDisplay={}, outOrderDisplay={}",
|
||||
expenseAccountDO.getInOrderDisplay(), expenseAccountDO.getOutOrderDisplay());
|
||||
}
|
||||
List<ExpenseAccountPO> result = new ArrayList<>();
|
||||
for (String code : orderedCodes) {
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
continue;
|
||||
}
|
||||
ExpenseAccountPO po = expenseAccountDomainService.getInfoByCode2(code.trim(), topOrgIdForExpense);
|
||||
if (po != null && po.getExpenseAccountId() != null && passWarehouseInOutDisplayFilter(po, expenseAccountDO)) {
|
||||
result.add(po);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合同路径下可选:与主数据 in_order_display / out_order_display 一致才保留(入参为 null 的维度不参与过滤)。
|
||||
*/
|
||||
private static boolean passWarehouseInOutDisplayFilter(ExpenseAccountPO po, ExpenseAccountDO filter) {
|
||||
if (filter.getInOrderDisplay() != null
|
||||
&& !Objects.equals(po.getInOrderDisplay(), filter.getInOrderDisplay())) {
|
||||
return false;
|
||||
}
|
||||
if (filter.getOutOrderDisplay() != null
|
||||
&& !Objects.equals(po.getOutOrderDisplay(), filter.getOutOrderDisplay())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询费用科目列表
|
||||
|
||||
+25
-8
@@ -107,7 +107,31 @@ public class AssociationWarehouseImpl extends ServiceImpl<AssociationWarehouseMa
|
||||
associationWarehouseDO.setWarehouseId(associationWarehouseDO.getWarehouseIdIdList().get(0));
|
||||
//设置仓库信息
|
||||
warehouseParam(associationWarehouseDO);
|
||||
for (Long correlationId : associationWarehouseDO.getCorrelationIdList()){
|
||||
// 先删该仓下「非默认仓」绑定,再批量插入本次提交的用户;保留 is_default=2(如新建仓自动写入的创建人默认仓),避免前端列表不展示该条却全量保存时被误删
|
||||
remove(new QueryWrapper<AssociationWarehouse>().lambda()
|
||||
.eq(AssociationWarehouse::getWarehouseId, associationWarehouseDO.getWarehouseId())
|
||||
.eq(AssociationWarehouse::getDelFlag, 1)
|
||||
.and(w -> w.isNull(AssociationWarehouse::getIsDefault)
|
||||
.or()
|
||||
.ne(AssociationWarehouse::getIsDefault, 2)));
|
||||
List<AssociationWarehouse> stillBoundRows = associationWarehouseMapper.selectList(new QueryWrapper<AssociationWarehouse>().lambda()
|
||||
.eq(AssociationWarehouse::getWarehouseId, associationWarehouseDO.getWarehouseId())
|
||||
.eq(AssociationWarehouse::getDelFlag, 1));
|
||||
Set<Long> alreadyBoundCorrelationIds = stillBoundRows.stream()
|
||||
.map(AssociationWarehouse::getCorrelationId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
LinkedHashSet<Long> distinctCorrelationIds = CollectionUtils.isEmpty(associationWarehouseDO.getCorrelationIdList())
|
||||
? new LinkedHashSet<>()
|
||||
: new LinkedHashSet<>(associationWarehouseDO.getCorrelationIdList());
|
||||
for (Long correlationId : distinctCorrelationIds) {
|
||||
if (correlationId == null) {
|
||||
continue;
|
||||
}
|
||||
// 仍在库内的绑定(多为创建人默认仓 is_default=2)不再插入,否则撞唯一 IDX_ASS_COR_WAR_ID
|
||||
if (alreadyBoundCorrelationIds.contains(correlationId)) {
|
||||
continue;
|
||||
}
|
||||
AssociationWarehouse associationWarehouse = new AssociationWarehouse();
|
||||
associationWarehouse.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
associationWarehouse.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
@@ -121,13 +145,6 @@ public class AssociationWarehouseImpl extends ServiceImpl<AssociationWarehouseMa
|
||||
associationWarehouse.setCreateTime(new Date());
|
||||
associationWarehouseList.add(associationWarehouse);
|
||||
}
|
||||
// 先删该仓下「非默认仓」绑定,再批量插入本次提交的用户;保留 is_default=2(如新建仓自动写入的创建人默认仓),避免前端列表不展示该条却全量保存时被误删
|
||||
remove(new QueryWrapper<AssociationWarehouse>().lambda()
|
||||
.eq(AssociationWarehouse::getWarehouseId, associationWarehouseDO.getWarehouseId())
|
||||
.eq(AssociationWarehouse::getDelFlag, 1)
|
||||
.and(w -> w.isNull(AssociationWarehouse::getIsDefault)
|
||||
.or()
|
||||
.ne(AssociationWarehouse::getIsDefault, 2)));
|
||||
}
|
||||
return saveBatch(associationWarehouseList);
|
||||
}
|
||||
|
||||
+1
-1
@@ -75,4 +75,4 @@ public class BatchDetailDomainService {
|
||||
batchDetailDO.setBatchId(batchId);
|
||||
return batchDetailService.queryList(batchDetailDO);
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -1,6 +1,7 @@
|
||||
package com.mhd.basic.domain.expenseAccount.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.mhd.common.core.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -113,4 +114,25 @@ public class ExpenseAccount extends BaseVOEntity{
|
||||
@ApiModelProperty("费率")
|
||||
private BigDecimal rate;
|
||||
|
||||
@ApiModelProperty("计费单位")
|
||||
private String billingUnit;
|
||||
|
||||
@ApiModelProperty("计费单位英文")
|
||||
private String billingUnitEn;
|
||||
|
||||
@ApiModelProperty("计费单位2")
|
||||
private String billingUnit2;
|
||||
|
||||
@ApiModelProperty("计费单位2英文")
|
||||
private String billingUnitEn2;
|
||||
|
||||
@ApiModelProperty("计费单位中文默认")
|
||||
private String billingUnitDefaultCn;
|
||||
|
||||
@ApiModelProperty("计费单位英文默认")
|
||||
private String billingUnitDefaultEn;
|
||||
|
||||
@ApiModelProperty("nc科目编码")
|
||||
private String ncSubjectCode;
|
||||
|
||||
}
|
||||
+23
@@ -1,5 +1,6 @@
|
||||
package com.mhd.basic.domain.expenseAccount.repository.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.mhd.common.core.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
@@ -136,4 +137,26 @@ public class ExpenseAccountPO extends BaseVOEntity{
|
||||
|
||||
@ApiModelProperty(name = "出库单是否固定显示 0-否 1-是")
|
||||
private Integer outOrderDisplay;
|
||||
|
||||
|
||||
@ApiModelProperty("计费单位")
|
||||
private String billingUnit;
|
||||
|
||||
@ApiModelProperty("计费单位英文")
|
||||
private String billingUnitEn;
|
||||
|
||||
@ApiModelProperty("计费单位2")
|
||||
private String billingUnit2;
|
||||
|
||||
@ApiModelProperty("计费单位2英文")
|
||||
private String billingUnitEn2;
|
||||
|
||||
@ApiModelProperty("计费单位中文默认")
|
||||
private String billingUnitDefaultCn;
|
||||
|
||||
@ApiModelProperty("计费单位英文默认")
|
||||
private String billingUnitDefaultEn;
|
||||
|
||||
@ApiModelProperty("nc科目编码")
|
||||
private String ncSubjectCode;
|
||||
}
|
||||
+28
@@ -153,4 +153,32 @@ public class ExpenseAccountDO extends BaseVOEntity{
|
||||
|
||||
@ApiModelProperty(name = "创建者姓名")
|
||||
private String updateByName;
|
||||
|
||||
|
||||
@ApiModelProperty("计费单位")
|
||||
private String billingUnit;
|
||||
|
||||
@ApiModelProperty("计费单位英文")
|
||||
private String billingUnitEn;
|
||||
|
||||
@ApiModelProperty("计费单位2")
|
||||
private String billingUnit2;
|
||||
|
||||
@ApiModelProperty("计费单位2英文")
|
||||
private String billingUnitEn2;
|
||||
|
||||
@ApiModelProperty("计费单位中文默认")
|
||||
private String billingUnitDefaultCn;
|
||||
|
||||
@ApiModelProperty("计费单位英文默认")
|
||||
private String billingUnitDefaultEn;
|
||||
|
||||
@ApiModelProperty("nc科目编码")
|
||||
private String ncSubjectCode;
|
||||
|
||||
/** 查询参数:是否按仓储合同结算设置拉取科目 */
|
||||
private Boolean contractSettlementQuery;
|
||||
|
||||
/** 查询参数:结算主体编码(货主编码等) */
|
||||
private String settlementCustomersCode;
|
||||
}
|
||||
+9
@@ -389,4 +389,13 @@ public class MaterialBaseInfo extends BaseVOEntity{
|
||||
@ApiModelProperty("是否抄码: 1-是 2-否")
|
||||
@Excel(name = "是否抄码: 1-是 2-否")
|
||||
private Integer copyCode;
|
||||
|
||||
@ApiModelProperty("货物类型:0-物料 1-半成品 2-成品")
|
||||
@Excel(name = "货物类型:0-物料 1-半成品 2-成品")
|
||||
private Integer goodsType;
|
||||
|
||||
@ApiModelProperty("毛重(kg)")
|
||||
@Excel(name = "毛重(kg)")
|
||||
private BigDecimal grossWeight;
|
||||
|
||||
}
|
||||
+8
@@ -365,6 +365,14 @@ public class MaterialBaseInfoPO extends BaseVOEntity{
|
||||
@Excel(name = "是否抄码: 1-是 2-否")
|
||||
private Integer copyCode;
|
||||
|
||||
@ApiModelProperty("货物类型:0-物料 1-半成品 2-成品")
|
||||
@Excel(name = "货物类型:0-物料 1-半成品 2-成品")
|
||||
private Integer goodsType;
|
||||
|
||||
@ApiModelProperty("毛重(kg)")
|
||||
@Excel(name = "毛重(kg)")
|
||||
private BigDecimal grossWeight;
|
||||
|
||||
@ApiModelProperty("商品规则")
|
||||
private MaterialGoodsRuleFeign materialGoodsRule;
|
||||
|
||||
|
||||
+8
@@ -385,4 +385,12 @@ public class MaterialBaseInfoDO extends BaseVOEntity{
|
||||
@ApiModelProperty("是否抄码: 1-是 2-否")
|
||||
@Excel(name = "是否抄码: 1-是 2-否")
|
||||
private Integer copyCode;
|
||||
|
||||
@ApiModelProperty("货物类型:0-物料 1-半成品 2-成品")
|
||||
@Excel(name = "货物类型:0-物料 1-半成品 2-成品")
|
||||
private Integer goodsType;
|
||||
|
||||
@ApiModelProperty("毛重(kg)")
|
||||
@Excel(name = "毛重(kg)")
|
||||
private BigDecimal grossWeight;
|
||||
}
|
||||
+31
@@ -138,4 +138,35 @@ public class ExpenseAccountDTO extends BaseVOEntity{
|
||||
|
||||
@ApiModelProperty(name = "出库单是否固定显示 0-否 1-是")
|
||||
private Integer outOrderDisplay;
|
||||
|
||||
|
||||
@ApiModelProperty("计费单位")
|
||||
private String billingUnit;
|
||||
|
||||
@ApiModelProperty("计费单位英文")
|
||||
private String billingUnitEn;
|
||||
|
||||
@ApiModelProperty("计费单位2")
|
||||
private String billingUnit2;
|
||||
|
||||
@ApiModelProperty("计费单位2英文")
|
||||
private String billingUnitEn2;
|
||||
|
||||
@ApiModelProperty("计费单位中文默认")
|
||||
private String billingUnitDefaultCn;
|
||||
|
||||
@ApiModelProperty("计费单位英文默认")
|
||||
private String billingUnitDefaultEn;
|
||||
|
||||
@ApiModelProperty("nc科目编码")
|
||||
private String ncSubjectCode;
|
||||
|
||||
/**
|
||||
* 为 true 时从仓储合同「结算设置」取费用科目(入库/出库费用登记等)
|
||||
*/
|
||||
@ApiModelProperty("是否按合同结算设置查询费用科目(入库/出库费用登记;为 true 时可传 inOrderDisplay=1 或 outOrderDisplay=1 再按主数据入库/出库显示过滤)")
|
||||
private Boolean contractSettlementQuery;
|
||||
|
||||
@ApiModelProperty("结算主体编码(通常为货主编码);不传则按通用仓储合同的结算设置取科目")
|
||||
private String settlementCustomersCode;
|
||||
}
|
||||
+9
@@ -364,4 +364,13 @@ public class MaterialBaseInfoDTO extends BaseVOEntity{
|
||||
@ApiModelProperty("是否抄码: 1-是 2-否")
|
||||
@Excel(name = "是否抄码: 1-是 2-否")
|
||||
private Integer copyCode;
|
||||
|
||||
@ApiModelProperty("货物类型:0-物料 1-半成品 2-成品")
|
||||
@Excel(name = "货物类型:0-物料 1-半成品 2-成品")
|
||||
private Integer goodsType;
|
||||
|
||||
@ApiModelProperty("毛重(kg)")
|
||||
@Excel(name = "毛重(kg)")
|
||||
private BigDecimal grossWeight;
|
||||
|
||||
}
|
||||
+20
@@ -70,6 +70,19 @@ public class ContractManageApi extends BaseController{
|
||||
return AjaxResult.success(contractManageApplicationService.getSubject(subjectAndPriceDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单价
|
||||
*/
|
||||
@ApiOperation("获取单价")
|
||||
@GetMapping(value = "/getPrice")
|
||||
public AjaxResult getPrice(@RequestParam("documentTypeCode") String documentTypeCode,
|
||||
@RequestParam("settlementCustomersCode") String settlementCustomersCode,
|
||||
@RequestParam("organizationId") Long organizationId,
|
||||
@RequestParam("topOrganizationId") Long topOrganizationId)
|
||||
{
|
||||
return AjaxResult.success(contractManageApplicationService.getPrice(documentTypeCode,settlementCustomersCode,organizationId,topOrganizationId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取科目和单价
|
||||
*/
|
||||
@@ -154,6 +167,13 @@ public class ContractManageApi extends BaseController{
|
||||
return AjaxResult.success(contractManageApplicationService.getInfoByCustomer(settlementCustomersCode,contractType,topOrganizationId));
|
||||
}
|
||||
|
||||
@ApiOperation("根据结算主体获取合同信息")
|
||||
@GetMapping(value = "/getInfoByCustomerAndOrganizationId")
|
||||
public AjaxResult getInfoByCustomerAndOrganizationId(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("topOrganizationId") Long topOrganizationId,@RequestParam("organizationId") Long organizationId)
|
||||
{
|
||||
return AjaxResult.success(contractManageApplicationService.getInfoByCustomerAndOrganizationId(settlementCustomersCode,contractType,topOrganizationId,organizationId));
|
||||
}
|
||||
|
||||
@ApiOperation("根据合同编码获取合同管理")
|
||||
@GetMapping(value = "/getInfoByCode")
|
||||
public AjaxResult getInfoByCode(@RequestParam(value = "contractNumber",required = true) String contractNumber)
|
||||
|
||||
+17
@@ -50,6 +50,11 @@ public class ExpenseAccountApi extends BaseController{
|
||||
|
||||
/**
|
||||
* 分页查询费用科目列表
|
||||
*
|
||||
* <p>入库/出库费用登记等场景传 {@code contractSettlementQuery=true}(与单据类型「仓库进出仓单」合同结算行一致),
|
||||
* 科目来源、结算主体为空走通用合同等逻辑<strong>入库与出库相同</strong>。
|
||||
* 先按合同结算行取科目,再关联主数据;若请求中传入 {@code inOrderDisplay} 或 {@code outOrderDisplay}(0-否 1-是),
|
||||
* 则再按主数据「入库单 / 出库单是否固定显示」与入参相等过滤(二者都传则同时满足)。不传则不在此维度过滤。</p>
|
||||
*/
|
||||
@ApiOperation("查询费用科目列表")
|
||||
@GetMapping("/list")
|
||||
@@ -62,6 +67,18 @@ public class ExpenseAccountApi extends BaseController{
|
||||
expenseAccountDTO = new ExpenseAccountDTO();
|
||||
logger.info("expenseAccountDTO 为 null,创建新对象");
|
||||
}
|
||||
if (Boolean.TRUE.equals(expenseAccountDTO.getContractSettlementQuery())) {
|
||||
ExpenseAccountDO contractQueryDO = new ExpenseAccountDO();
|
||||
BeanUtils.copyProperties(expenseAccountDTO, contractQueryDO);
|
||||
logger.info("按合同结算设置查询费用科目,settlementCustomersCode={},inOrderDisplay={},outOrderDisplay={}",
|
||||
expenseAccountDTO.getSettlementCustomersCode(),
|
||||
expenseAccountDTO.getInOrderDisplay(), expenseAccountDTO.getOutOrderDisplay());
|
||||
List<ExpenseAccountPO> contractList =
|
||||
expenseAccountApplicationService.queryListFromContractWarehouseInOutSettlement(
|
||||
contractQueryDO, expenseAccountDTO.getSettlementCustomersCode());
|
||||
logger.info("按合同结算设置查询完成,条数:{}", contractList != null ? contractList.size() : 0);
|
||||
return getDataTable(contractList != null ? contractList : new ArrayList<>());
|
||||
}
|
||||
ExpenseAccountDO expenseAccountDO = new ExpenseAccountDO();
|
||||
BeanUtils.copyProperties(expenseAccountDTO, expenseAccountDO);
|
||||
logger.info("转换后的 ExpenseAccountDO:{}", expenseAccountDO);
|
||||
|
||||
+18
@@ -5,6 +5,9 @@ import com.mhd.basic.interfaces.vo.MaterialStockInfoVo;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mhd.system.api.OmsServiceFeign;
|
||||
import com.mhd.system.api.domain.ErpCountryDTO;
|
||||
import com.mhd.system.api.domain.ErpEnterpriseUnitDTO;
|
||||
import com.mhd.system.api.domain.MaterialBarCodeFeign;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -41,6 +44,9 @@ public class MaterialBaseInfoApi extends BaseController{
|
||||
@Resource
|
||||
private MaterialBaseInfoAssembler materialBaseInfoAssembler;
|
||||
|
||||
@Resource
|
||||
private OmsServiceFeign omsServiceFeign;
|
||||
|
||||
/**
|
||||
* 分页查询物料基础信息列表
|
||||
*/
|
||||
@@ -108,4 +114,16 @@ public class MaterialBaseInfoApi extends BaseController{
|
||||
return R.ok(materialBaseInfoApplicationService.getMaterialStockList(shipperName,materialName,machineCode,pageNum,pageSize));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取企业单位列表-申报单位下拉框用")
|
||||
@GetMapping("/getDeclarationUnitList")
|
||||
public AjaxResult getDeclarationUnitList(ErpEnterpriseUnitDTO erpEnterpriseUnitDTO) {
|
||||
return omsServiceFeign.getUnitList(erpEnterpriseUnitDTO);
|
||||
}
|
||||
|
||||
@ApiOperation("获取企业国别列表-原产国下拉框用")
|
||||
@GetMapping("/getCountryList")
|
||||
public AjaxResult getCountryList(ErpCountryDTO erpCountryDTO) {
|
||||
return omsServiceFeign.getCountryList(erpCountryDTO);
|
||||
}
|
||||
}
|
||||
|
||||
+48
-2
@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.mhd.common.core.constant.UserConstants;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.core.utils.poi.ExcelUtil;
|
||||
import com.mhd.common.core.web.controller.BaseController;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
@@ -23,6 +25,7 @@ import com.mhd.common.log.annotation.Log;
|
||||
import com.mhd.common.log.enums.BusinessType;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.domain.SysDictType;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
|
||||
/**
|
||||
* 数据字典信息
|
||||
@@ -73,14 +76,56 @@ public class SysDictTypeController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
||||
{
|
||||
fillDictTypeOrganization(dict);
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||
{
|
||||
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型编码「" + dict.getDictType() + "」已存在(全局不可重复)");
|
||||
}
|
||||
dict.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(dictTypeService.insertDictType(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入组织维度:优先使用请求体中选择的组织;未传时使用当前登录用户所属组织;无登录上下文时按平台(0)处理。
|
||||
*/
|
||||
private void fillDictTypeOrganization(SysDictType dict)
|
||||
{
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser == null || loginUser.getUserPo() == null)
|
||||
{
|
||||
if (dict.getOrganizationId() == null)
|
||||
{
|
||||
dict.setOrganizationId(0L);
|
||||
}
|
||||
return;
|
||||
}
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
if (dict.getOrganizationId() == null)
|
||||
{
|
||||
dict.setOrganizationId(userPo.getOrganizationId());
|
||||
if (StringUtils.isEmpty(dict.getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName(userPo.getOrganizationName());
|
||||
}
|
||||
if (dict.getTopOrganizationId() == null)
|
||||
{
|
||||
dict.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dict.getTopOrganizationId() == null)
|
||||
{
|
||||
dict.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||
}
|
||||
if (StringUtils.isEmpty(dict.getOrganizationName())
|
||||
&& java.util.Objects.equals(dict.getOrganizationId(), userPo.getOrganizationId()))
|
||||
{
|
||||
dict.setOrganizationName(userPo.getOrganizationName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
@@ -89,9 +134,10 @@ public class SysDictTypeController extends BaseController
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
||||
{
|
||||
fillDictTypeOrganization(dict);
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||
{
|
||||
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型编码「" + dict.getDictType() + "」已存在(全局不可重复)");
|
||||
}
|
||||
dict.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(dictTypeService.updateDictType(dict));
|
||||
|
||||
@@ -98,4 +98,12 @@ public interface SysDictDataMapper extends BaseMapper<SysDictData>
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType);
|
||||
|
||||
/**
|
||||
* 按字典类型批量同步字典数据的组织信息(与字典类型归属一致)
|
||||
*/
|
||||
int updateDictDataOrganizationByDictType(@Param("dictType") String dictType,
|
||||
@Param("organizationId") Long organizationId,
|
||||
@Param("organizationName") String organizationName,
|
||||
@Param("topOrganizationId") Long topOrganizationId);
|
||||
}
|
||||
|
||||
@@ -79,5 +79,5 @@ public interface SysDictTypeMapper
|
||||
* @param dictType 字典类型
|
||||
* @return 结果
|
||||
*/
|
||||
public SysDictType checkDictTypeUnique(String dictType);
|
||||
public SysDictType checkDictTypeUnique(SysDictType dictType);
|
||||
}
|
||||
|
||||
+107
-5
@@ -4,17 +4,24 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhd.basic.infrastructure.feign.ProductServiceFeign;
|
||||
import com.mhd.basic.infrastructure.util.annotation.DataPermissions;
|
||||
import com.mhd.common.core.domain.po.OrganizationPo;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.domain.SysDictType;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import com.mhd.system.domain.vo.SysBankDictInfo;
|
||||
import com.mhd.system.domain.vo.SysDictDataVO;
|
||||
import com.mhd.system.mapper.SysDictDataMapper;
|
||||
import com.mhd.system.service.ISysDictDataService;
|
||||
import com.mhd.system.service.ISysDictTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.mhd.common.security.utils.DictUtils;
|
||||
import com.mhd.system.api.domain.SysDictData;
|
||||
@@ -33,6 +40,12 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
@Resource
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
|
||||
@Resource
|
||||
private ISysDictTypeService dictTypeService;
|
||||
|
||||
@Resource
|
||||
private ProductServiceFeign productServiceFeign;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
*
|
||||
@@ -126,9 +139,20 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
data.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
data.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
data.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
applyOrganizationFromDictType(data, null);
|
||||
fillOrganizationNameFromProductForDictData(data);
|
||||
if (data.getOrganizationId() == null)
|
||||
{
|
||||
data.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
}
|
||||
if (StringUtils.isEmpty(data.getOrganizationName()))
|
||||
{
|
||||
data.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
}
|
||||
if (data.getTopOrganizationId() == null)
|
||||
{
|
||||
data.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
data.setCreateBy(loginUser.getUserPo().getUserName());
|
||||
int row = dictDataMapper.insertDictData(data);
|
||||
if (row > 0)
|
||||
@@ -179,14 +203,29 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
throw new ServiceException("修改失败:无权修改其他组织的字典数据");
|
||||
}
|
||||
}
|
||||
applyOrganizationFromDictType(data, sysDictData.getDictType());
|
||||
fillOrganizationNameFromProductForDictData(data);
|
||||
if (data.getOrganizationId() == null)
|
||||
{
|
||||
data.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
}
|
||||
if (StringUtils.isEmpty(data.getOrganizationName()))
|
||||
{
|
||||
data.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
}
|
||||
if (data.getTopOrganizationId() == null)
|
||||
{
|
||||
data.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
data.setUpdateBy(loginUser.getUserPo().getUserName());
|
||||
int row = dictDataMapper.updateDictData(data);
|
||||
if (row > 0)
|
||||
{
|
||||
String dictTypeForCache = StringUtils.isNotEmpty(data.getDictType()) ? data.getDictType() : sysDictData.getDictType();
|
||||
SysDictData dictData = new SysDictData();
|
||||
dictData.setDictType(data.getDictType());
|
||||
dictData.setDictType(dictTypeForCache);
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictData);
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
DictUtils.setDictCache(dictTypeForCache, dictDatas);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
@@ -386,6 +425,69 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织信息优先从所属字典类型上带出;类型上未配置的字段由调用方用登录用户等补齐。
|
||||
*
|
||||
* @param dictTypeWhenDataTypeEmpty 修改场景下请求体可能不传 dictType,此时用库中原记录的字典类型编码查询类型表
|
||||
*/
|
||||
private void applyOrganizationFromDictType(SysDictData data, String dictTypeWhenDataTypeEmpty)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String dictType = StringUtils.isNotEmpty(data.getDictType()) ? data.getDictType() : dictTypeWhenDataTypeEmpty;
|
||||
if (StringUtils.isEmpty(dictType))
|
||||
{
|
||||
return;
|
||||
}
|
||||
SysDictType dictTypeRow = dictTypeService.selectDictTypeByType(dictType);
|
||||
if (dictTypeRow == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (dictTypeRow.getOrganizationId() != null)
|
||||
{
|
||||
data.setOrganizationId(dictTypeRow.getOrganizationId());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dictTypeRow.getOrganizationName()))
|
||||
{
|
||||
data.setOrganizationName(dictTypeRow.getOrganizationName());
|
||||
}
|
||||
if (dictTypeRow.getTopOrganizationId() != null)
|
||||
{
|
||||
data.setTopOrganizationId(dictTypeRow.getTopOrganizationId());
|
||||
}
|
||||
}
|
||||
|
||||
private void fillOrganizationNameFromProductForDictData(SysDictData data)
|
||||
{
|
||||
if (data == null || data.getOrganizationId() == null || StringUtils.isNotEmpty(data.getOrganizationName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Long oid = data.getOrganizationId();
|
||||
if (oid == 0L)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
AjaxResult res = productServiceFeign.getOrganizationInfo(oid);
|
||||
if (res != null && "200".equals(String.valueOf(res.get("code"))) && res.get("data") != null)
|
||||
{
|
||||
OrganizationPo po = JSONObject.parseObject(JSONObject.toJSONString(res.get("data")), OrganizationPo.class);
|
||||
if (po != null && StringUtils.isNotEmpty(po.getOrganizationName()))
|
||||
{
|
||||
data.setOrganizationName(po.getOrganizationName());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDictData> selectDictList(SysDictData sysDictData) {
|
||||
return dictDataMapper.selectDictDataList(sysDictData);
|
||||
|
||||
+87
-1
@@ -3,9 +3,14 @@ package com.mhd.system.service.impl;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mhd.basic.infrastructure.feign.ProductServiceFeign;
|
||||
import com.mhd.common.core.domain.po.OrganizationPo;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.system.mapper.SysDictDataMapper;
|
||||
import com.mhd.system.mapper.SysDictTypeMapper;
|
||||
import com.mhd.system.service.ISysDictTypeService;
|
||||
@@ -16,8 +21,10 @@ import com.mhd.common.core.constant.UserConstants;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.security.utils.DictUtils;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.domain.SysDictData;
|
||||
import com.mhd.system.api.domain.SysDictType;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
|
||||
/**
|
||||
* 字典 业务层处理
|
||||
@@ -33,6 +40,9 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Autowired
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
|
||||
@Autowired
|
||||
private ProductServiceFeign productServiceFeign;
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化字典到缓存
|
||||
*/
|
||||
@@ -177,6 +187,11 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Override
|
||||
public int insertDictType(SysDictType dict)
|
||||
{
|
||||
fillOrganizationNameFromProductCenter(dict);
|
||||
if (dict.getOrganizationId() != null && StringUtils.isEmpty(dict.getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName("");
|
||||
}
|
||||
int row = dictTypeMapper.insertDictType(dict);
|
||||
if (row > 0)
|
||||
{
|
||||
@@ -196,10 +211,16 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
public int updateDictType(SysDictType dict)
|
||||
{
|
||||
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId());
|
||||
mergeDictTypeOrganizationNameForUpdate(dict, oldDict);
|
||||
dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType());
|
||||
int row = dictTypeMapper.updateDictType(dict);
|
||||
if (row > 0)
|
||||
{
|
||||
if (dictDataMapper.countDictDataByType(dict.getDictType()) > 0)
|
||||
{
|
||||
dictDataMapper.updateDictDataOrganizationByDictType(dict.getDictType(),
|
||||
dict.getOrganizationId(), dict.getOrganizationName(), dict.getTopOrganizationId());
|
||||
}
|
||||
SysDictData dictData = new SysDictData();
|
||||
dictData.setDictType(dict.getDictType());
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictData);
|
||||
@@ -218,11 +239,76 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
public String checkDictTypeUnique(SysDictType dict)
|
||||
{
|
||||
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
||||
SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
|
||||
SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict);
|
||||
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型时,请求体常不带 organizationName;若与库中或当前登录用户组织一致则补全,避免 UPDATE 把名称写成 null。
|
||||
*/
|
||||
private void mergeDictTypeOrganizationNameForUpdate(SysDictType dict, SysDictType oldDict)
|
||||
{
|
||||
if (dict == null || oldDict == null || StringUtils.isNotEmpty(dict.getOrganizationName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (dict.getOrganizationId() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Objects.equals(dict.getOrganizationId(), oldDict.getOrganizationId())
|
||||
&& StringUtils.isNotEmpty(oldDict.getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName(oldDict.getOrganizationName());
|
||||
return;
|
||||
}
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null && loginUser.getUserPo() != null
|
||||
&& Objects.equals(dict.getOrganizationId(), loginUser.getUserPo().getOrganizationId())
|
||||
&& StringUtils.isNotEmpty(loginUser.getUserPo().getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
}
|
||||
fillOrganizationNameFromProductCenter(dict);
|
||||
if (dict.getOrganizationId() != null && StringUtils.isEmpty(dict.getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 已存在 organizationId 但名称为空时,从产品中心按组织 id 补全名称(与 BasicAgreement 等模块一致)。
|
||||
*/
|
||||
private void fillOrganizationNameFromProductCenter(SysDictType dict)
|
||||
{
|
||||
if (dict == null || dict.getOrganizationId() == null || StringUtils.isNotEmpty(dict.getOrganizationName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Long oid = dict.getOrganizationId();
|
||||
if (oid == 0L)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
AjaxResult res = productServiceFeign.getOrganizationInfo(oid);
|
||||
if (res != null && "200".equals(String.valueOf(res.get("code"))) && res.get("data") != null)
|
||||
{
|
||||
OrganizationPo po = JSONObject.parseObject(JSONObject.toJSONString(res.get("data")), OrganizationPo.class);
|
||||
if (po != null && StringUtils.isNotEmpty(po.getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName(po.getOrganizationName());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
// 远程不可用时保持后续逻辑(如置空字符串以便 UPDATE 写入列)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,12 +107,12 @@
|
||||
<select id="selectCostSubject" parameterType="com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDO"
|
||||
resultType="com.mhd.basic.domain.expenseAccount.repository.po.ExpenseAccountPO">
|
||||
select
|
||||
*
|
||||
from expense_account
|
||||
a.*
|
||||
from expense_account a left join service_items_manage b ON a.service_items_manage_id = b.service_items_manage_id
|
||||
where
|
||||
del_flag = 1
|
||||
and status = 1
|
||||
and first_subject_flag = 1
|
||||
a.del_flag = 1
|
||||
and a.status = 1
|
||||
and a.first_subject_flag = 1
|
||||
<include refid="common_where_two"></include>
|
||||
</select>
|
||||
<select id="selectAllCostSubject"
|
||||
@@ -149,11 +149,15 @@
|
||||
<!-- 如果 organizationId 和 topOrganizationId 都为 null,表示查询所有组织的数据(不添加组织过滤条件) -->
|
||||
<if test="expenseAccountDO.organizationId != null">
|
||||
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
|
||||
and organization_id = #{expenseAccountDO.organizationId}
|
||||
and a.organization_id = #{expenseAccountDO.organizationId}
|
||||
</if>
|
||||
<if test="expenseAccountDO.topOrganizationId != null and expenseAccountDO.organizationId == null">
|
||||
<!-- 如果设置了 topOrganizationId 但没有设置 organizationId,添加 top_organization_id 条件 -->
|
||||
and top_organization_id = #{expenseAccountDO.topOrganizationId}
|
||||
and a.top_organization_id = #{expenseAccountDO.topOrganizationId}
|
||||
</if>
|
||||
<if test="expenseAccountDO.serviceItemsCode != null and expenseAccountDO.serviceItemsCode != ''">
|
||||
<!-- 如果设置了 topOrganizationId 但没有设置 organizationId,添加 top_organization_id 条件 -->
|
||||
and b.service_items_code = #{expenseAccountDO.serviceItemsCode}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
|
||||
+4
-1
@@ -48,6 +48,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result column="material_unit" property="materialUnit" jdbcType="VARCHAR"/>
|
||||
<result column="machine_code" property="machineCode" jdbcType="VARCHAR"/>
|
||||
<result property="copyCode" column="copy_code"/>
|
||||
<result property="goodsType" column="goods_type"/>
|
||||
<result property="grossWeight" column="gross_weight"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
@@ -55,7 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select material_base_info_id, organization_id, organization_name, top_organization_id, shipper_id, shipper_name, material_code, material_name, bar_code, material_classify_code,
|
||||
material_classify_name, material_type, material_type_name, pack_id, pack_code, pack_name, unit_code, unit_name, brand_id, brand_code, brand_name, shelf_life, weight_limit,
|
||||
volume_limit, material_shape, material_shape_name, material_size, material_length, material_width, material_height, remark, nullify, create_time, create_by, create_by_name,
|
||||
update_time, update_by, update_by_name, del_flag, common,material_model,material_unit,machine_code,sku_code, unit_price, currency, origin_country, hs_code, declaration_unit, statutory_unit, statutory_second_unit, copy_code
|
||||
update_time, update_by, update_by_name, del_flag, common,material_model,material_unit,machine_code,sku_code, unit_price, currency, origin_country, hs_code, declaration_unit, statutory_unit, statutory_second_unit, copy_code,
|
||||
goods_type,gross_weight
|
||||
from material_base_info
|
||||
</sql>
|
||||
|
||||
|
||||
@@ -112,6 +112,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType}
|
||||
</update>
|
||||
|
||||
<update id="updateDictDataOrganizationByDictType">
|
||||
update sys_dict_data
|
||||
set organization_id = #{organizationId},
|
||||
organization_name = #{organizationName},
|
||||
top_organization_id = #{topOrganizationId},
|
||||
update_time = sysdate()
|
||||
where dict_type = #{dictType}
|
||||
</update>
|
||||
|
||||
<insert id="insertDictData" parameterType="SysDictData">
|
||||
insert into sys_dict_data(
|
||||
<if test="dictSort != null">dict_sort,</if>
|
||||
|
||||
@@ -13,10 +13,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="organizationId" column="organization_id" />
|
||||
<result property="organizationName" column="organization_name" />
|
||||
<result property="topOrganizationId" column="top_organization_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDictTypeVo">
|
||||
select dict_id, dict_name, dict_type, status, create_by, create_time, remark
|
||||
select dict_id, dict_name, dict_type, status, create_by, create_time, remark,
|
||||
organization_id, organization_name, top_organization_id
|
||||
from sys_dict_type
|
||||
</sql>
|
||||
|
||||
@@ -32,6 +37,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="dictType != null and dictType != ''">
|
||||
AND dict_type like concat('%', #{dictType}, '%')
|
||||
</if>
|
||||
<if test="organizationId != null">
|
||||
AND organization_id = #{organizationId}
|
||||
</if>
|
||||
<if test="topOrganizationId != null">
|
||||
AND (top_organization_id = #{topOrganizationId} OR IFNULL(organization_id, 0) = 0)
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
@@ -55,9 +66,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where dict_type = #{dictType}
|
||||
</select>
|
||||
|
||||
<select id="checkDictTypeUnique" parameterType="String" resultMap="SysDictTypeResult">
|
||||
<select id="checkDictTypeUnique" parameterType="SysDictType" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_type = #{dictType} limit 1
|
||||
where dict_type = #{dictType}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<delete id="deleteDictTypeById" parameterType="Long">
|
||||
@@ -78,6 +90,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="organizationId != null">organization_id = #{organizationId},</if>
|
||||
<if test="organizationName != null">organization_name = #{organizationName},</if>
|
||||
<if test="topOrganizationId != null">top_organization_id = #{topOrganizationId},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
@@ -90,6 +105,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="dictType != null and dictType != ''">dict_type,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="organizationId != null">organization_id,</if>
|
||||
<if test="organizationId != null">organization_name,</if>
|
||||
<if test="topOrganizationId != null">top_organization_id,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
@@ -97,6 +115,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="organizationId != null">#{organizationId},</if>
|
||||
<if test="organizationId != null">#{organizationName},</if>
|
||||
<if test="topOrganizationId != null">#{topOrganizationId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user