Merge branch 'dev' into dev_user0622

# Conflicts:
#	mhd_wms/src/main/resources/mapper/pickingOrder/PickingOrderMapper.xml
This commit is contained in:
王奎兴
2026-07-02 19:09:31 +08:00
30 changed files with 858 additions and 246 deletions
@@ -357,6 +357,10 @@ public interface SystemServiceFeign {
@GetMapping("/contractManageApi/getInfoByCustomer") @GetMapping("/contractManageApi/getInfoByCustomer")
public AjaxResult getInfoByCustomer(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType); public AjaxResult getInfoByCustomer(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType);
@ApiOperation("根据结算主体和费用科目获取合同信息")
@GetMapping(value = "/contractManageApi/getInfoByCustomerAndSecondSubjectCode")
public AjaxResult getInfoByCustomerAndSecondSubjectCode(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("firstSubjectCode") String firstSubjectCode,@RequestParam("topOrganizationId") Long topOrganizationId,@RequestParam("organizationId") Long organizationId);
/** /**
* 根据结算主体获取合同信息 * 根据结算主体获取合同信息
*/ */
@@ -284,6 +284,10 @@ public class RemoteSystemFeignFallbackFactory implements FallbackFactory<SystemS
return AjaxResult.error("查询失败"); return AjaxResult.error("查询失败");
} }
@Override
public AjaxResult getInfoByCustomerAndSecondSubjectCode(String settlementCustomersCode, Integer contractType, String firstSubjectCode, Long topOrganizationId, Long organizationId) {
return null;
}
@Override @Override
public AjaxResult getInfoByCustomer2(String settlementCustomersCode, Integer contractType, Long topOrganizationId) { public AjaxResult getInfoByCustomer2(String settlementCustomersCode, Integer contractType, Long topOrganizationId) {
return AjaxResult.error("查询失败"); return AjaxResult.error("查询失败");
@@ -310,4 +314,4 @@ public class RemoteSystemFeignFallbackFactory implements FallbackFactory<SystemS
} }
}; };
} }
} }
@@ -268,12 +268,25 @@ public class ContractManageApplicationService {
Long organizationId = contractManageDTO.getOrganizationId(); Long organizationId = contractManageDTO.getOrganizationId();
String sunjectCode = contractManageDTO.getSubjectCode(); String sunjectCode = contractManageDTO.getSubjectCode();
Long topOrganizationId = contractManageDTO.getTopOrganizationId(); Long topOrganizationId = contractManageDTO.getTopOrganizationId();
List<ContractManage> UserContractManages = contractManageMapper.selectList(new LambdaQueryWrapper<ContractManage>() ContractManageDO contractManageDO = new ContractManageDO();
.eq(ContractManage::getSettlementCustomersId, settlementCustomersId) contractManageDO.setOrganizationId(organizationId);
.eq(ContractManage::getDelFlag, 1) contractManageDO.setSettlementCustomersId(settlementCustomersId);
.eq(ContractManage::getOrganizationId, organizationId) contractManageDO.setTopOrganizationId(topOrganizationId);
.eq(ContractManage::getTopOrganizationId, topOrganizationId) contractManageDO.setCommonContractFlag(2);
.eq(ContractManage::getCommonContractFlag, 2)); contractManageDO.setDelFlag(1);
contractManageDO.setFirstSubjectCode(sunjectCode);
List<ContractManagePO> contractManagePOS = contractManageMapper.queryList(contractManageDO);
if (contractManagePOS != null && contractManagePOS.size() > 1) {
throw new RuntimeException("同一费用科目存在多条合同,请检查");
}
List<ContractManage> UserContractManages = new ArrayList<>();
if (contractManagePOS != null) {
for (ContractManagePO po : contractManagePOS) {
ContractManage contractManage = new ContractManage();
BeanUtils.copyProperties(po, contractManage);
UserContractManages.add(contractManage);
}
}
if (UserContractManages != null && UserContractManages.size() > 0) { if (UserContractManages != null && UserContractManages.size() > 0) {
//用户合同计费策略 //用户合同计费策略
calucateSubjectAndPriceStrategy(UserContractManages, organizationId, topOrganizationId, sunjectCode, result); calucateSubjectAndPriceStrategy(UserContractManages, organizationId, topOrganizationId, sunjectCode, result);
@@ -595,7 +608,8 @@ public class ContractManageApplicationService {
通用合同:同一时间段、同一合同类型,只能存在一个 通用合同:同一时间段、同一合同类型,只能存在一个
特殊合同:同一结算主体、同一时间段、同一合同类型,只能存在一个 特殊合同:同一结算主体、同一时间段、同一合同类型,只能存在一个
*/ */
checkContract(contractManageDO); //20260702取消同一时间段不能有相同合同校验
//checkContract(contractManageDO);
handleData(contractManageDO); handleData(contractManageDO);
handleDict(contractManageDO); handleDict(contractManageDO);
contractManageDO.setContractNumber(OrderSequence.getOrderCode("HT")); contractManageDO.setContractNumber(OrderSequence.getOrderCode("HT"));
@@ -831,7 +845,7 @@ public class ContractManageApplicationService {
@Transactional @Transactional
public Boolean update(ContractManageDO contractManageDO) { public Boolean update(ContractManageDO contractManageDO) {
validateContractType(contractManageDO.getContractType()); validateContractType(contractManageDO.getContractType());
checkContract(contractManageDO); //checkContract(contractManageDO);
handleData(contractManageDO); handleData(contractManageDO);
handleDetils(contractManageDO); handleDetils(contractManageDO);
handleDict(contractManageDO); handleDict(contractManageDO);
@@ -935,6 +949,78 @@ public class ContractManageApplicationService {
return resultContract; return resultContract;
} }
public ContractManagePO getInfoByCustomerAndSecondSubjectCode(String settlementCustomersCode,Integer contractType, Long topOrganizationId, Long organizationId,String firstSubjectCode) {
/*
首先根据合同类型(仓储、运输、其他),以及结算客户,查询合同信息
如果传了结算主体,则根据结算主体以及当前时间查询有效的特殊合同,如果特殊合同没有,则查询通用合同
*/
//获取当前登录人信息
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"));
queryParam.setFirstSubjectCode(firstSubjectCode);
queryParam.setOrganizationId(organizationId);
queryParam.setTopOrganizationId(topOrganizationId);
List<ContractManagePO> contractManagePOList = contractManageDomainService.queryList(queryParam);
List<ContractManagePO> contractManagePOs = contractManagePOList.stream()
.filter(item -> item.getSettlementCustomersCode().equals(settlementCustomersCode)
&& Objects.equals(item.getContractType(), contractType))
.collect(Collectors.toList());
if (contractManagePOs != null && contractManagePOs.size() > 1) {
throw new ServiceException("存在多条相同费用科目的合同,请检查");
}
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){
resultContract = findGeneralContract(contractManagePOList, contractType);
}else {
resultContract = contractManagePO;
}
}else {
resultContract = findGeneralContract(contractManagePOList, contractType);
}
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 settlementCustomersCode 结算主体code * @param settlementCustomersCode 结算主体code
@@ -214,4 +214,6 @@ public class ContractManageDO extends BaseVOEntity{
@ApiModelProperty(name = "是否包含运输费用(1-包含,2-包含)") @ApiModelProperty(name = "是否包含运输费用(1-包含,2-包含)")
private Integer transportationCosts; private Integer transportationCosts;
@ApiModelProperty("一级费用科目code")
private String firstSubjectCode;
} }
@@ -68,6 +68,20 @@ public class StorageSectionDomainService {
storageSectionDO.getStorageCode(), storageSectionDO.getStorageName(), null); storageSectionDO.getStorageCode(), storageSectionDO.getStorageName(), null);
//设置仓库 //设置仓库
setWarehouseInfo(storageSectionDO); setWarehouseInfo(storageSectionDO);
String storageCode = storageSectionDO.getStorageCode();
String storageName = storageSectionDO.getStorageName();
Long warehouseId = storageSectionDO.getWarehouseId();
List<StorageSection> codelist = storageSectionService.list(new QueryWrapper<StorageSection>().lambda()
.eq(StorageSection::getStorageCode, storageCode)
.eq(StorageSection::getWarehouseId, warehouseId)
.eq(StorageSection::getDelFlag, 1));
List<StorageSection> namelist = storageSectionService.list(new QueryWrapper<StorageSection>().lambda()
.eq(StorageSection::getStorageName, storageName)
.eq(StorageSection::getWarehouseId, warehouseId)
.eq(StorageSection::getDelFlag, 1));
if ((codelist != null && codelist.size() > 0) || (namelist != null && namelist.size() > 0)) {
throw new ServiceException("库区编码或名称已存在");
}
return storageSectionService.insert(storageSectionDO); return storageSectionService.insert(storageSectionDO);
} }
@@ -86,6 +100,22 @@ public class StorageSectionDomainService {
storageSectionDO.getStorageSectionId()); storageSectionDO.getStorageSectionId());
//设置仓库 //设置仓库
setWarehouseInfo(storageSectionDO); setWarehouseInfo(storageSectionDO);
String storageCode = storageSectionDO.getStorageCode();
String storageName = storageSectionDO.getStorageName();
Long warehouseId = storageSectionDO.getWarehouseId();
List<StorageSection> codelist = storageSectionService.list(new QueryWrapper<StorageSection>().lambda()
.eq(StorageSection::getStorageCode, storageCode)
.eq(StorageSection::getWarehouseId, warehouseId)
.ne(StorageSection::getStorageSectionId, storageSectionDO.getStorageSectionId())
.eq(StorageSection::getDelFlag, 1));
List<StorageSection> namelist = storageSectionService.list(new QueryWrapper<StorageSection>().lambda()
.eq(StorageSection::getStorageName, storageName)
.eq(StorageSection::getWarehouseId, warehouseId)
.ne(StorageSection::getStorageSectionId, storageSectionDO.getStorageSectionId())
.eq(StorageSection::getDelFlag, 1));
if ((codelist != null && codelist.size() > 0) || (namelist != null && namelist.size() > 0)) {
throw new ServiceException("库区编码或名称已存在");
}
return storageSectionService.update(storageSectionDO); return storageSectionService.update(storageSectionDO);
} }
@@ -168,4 +198,4 @@ public class StorageSectionDomainService {
} }
} }
@@ -160,6 +160,13 @@ public class ContractManageApi extends BaseController{
return AjaxResult.success(contractManageApplicationService.getInfoByCustomer(settlementCustomersCode,contractType,null)); return AjaxResult.success(contractManageApplicationService.getInfoByCustomer(settlementCustomersCode,contractType,null));
} }
@ApiOperation("根据结算主体和费用科目获取合同信息")
@GetMapping(value = "/getInfoByCustomerAndSecondSubjectCode")
public AjaxResult getInfoByCustomerAndSecondSubjectCode(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("firstSubjectCode") String firstSubjectCode,@RequestParam("topOrganizationId") Long topOrganizationId,@RequestParam("organizationId") Long organizationId)
{
return AjaxResult.success(contractManageApplicationService.getInfoByCustomerAndSecondSubjectCode(settlementCustomersCode,contractType,topOrganizationId,organizationId,firstSubjectCode));
}
@ApiOperation("根据结算主体获取合同信息") @ApiOperation("根据结算主体获取合同信息")
@GetMapping(value = "/getInfoByCustomer2") @GetMapping(value = "/getInfoByCustomer2")
public AjaxResult getInfoByCustomer2(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("topOrganizationId") Long topOrganizationId) public AjaxResult getInfoByCustomer2(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("topOrganizationId") Long topOrganizationId)
@@ -6,11 +6,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectContractManagePo"> <sql id="selectContractManagePo">
select SELECT DISTINCT a.*
* FROM CONTRACT_MANAGE a
from contract_manage INNER JOIN CONTRACT_MANAGE_DETAIL b
ON a.CONTRACT_MANAGE_ID = b.CONTRACT_MANAGE_ID
where where
del_flag = 1 a.del_flag = 1
</sql> </sql>
<sql id="selectContractManagePo1"> <sql id="selectContractManagePo1">
@@ -46,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and contract_state = #{contractState} and contract_state = #{contractState}
</if> </if>
<if test="signingUnit != null and signingUnit != ''"> <if test="signingUnit != null and signingUnit != ''">
and signing_unit = #{signingUnit} and asigning_unit = #{signingUnit}
</if> </if>
<if test="settlementCustomers != null and settlementCustomers != ''"> <if test="settlementCustomers != null and settlementCustomers != ''">
and settlement_customers = #{settlementCustomers} and settlement_customers = #{settlementCustomers}
@@ -108,6 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="theyOperatorPhone != null and theyOperatorPhone != ''"> <if test="theyOperatorPhone != null and theyOperatorPhone != ''">
and they_operator_phone = #{theyOperatorPhone} and they_operator_phone = #{theyOperatorPhone}
</if> </if>
</where> </where>
</sql> </sql>
@@ -132,73 +134,76 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="common_where"> <sql id="common_where">
<if test="contractManageDO.contractNumber != null and contractManageDO.contractNumber != ''"> <if test="contractManageDO.contractNumber != null and contractManageDO.contractNumber != ''">
and contract_number like concat('%', #{contractManageDO.contractNumber}, '%') and a.contract_number like concat('%', #{contractManageDO.contractNumber}, '%')
</if> </if>
<if test="contractManageDO.originalContractNumber != null and contractManageDO.originalContractNumber != ''"> <if test="contractManageDO.originalContractNumber != null and contractManageDO.originalContractNumber != ''">
and original_contract_number like concat('%', #{contractManageDO.originalContractNumber}, '%') and a.original_contract_number like concat('%', #{contractManageDO.originalContractNumber}, '%')
</if> </if>
<if test="contractManageDO.commonContractFlag != null"> <if test="contractManageDO.commonContractFlag != null">
and common_contract_flag = #{contractManageDO.commonContractFlag} and a.common_contract_flag = #{contractManageDO.commonContractFlag}
</if> </if>
<if test="contractManageDO.contractType != null"> <if test="contractManageDO.contractType != null">
and contract_type = #{contractManageDO.contractType} and a.contract_type = #{contractManageDO.contractType}
</if> </if>
<if test="contractManageDO.settlementCustomers != null and contractManageDO.settlementCustomers != '' " > <if test="contractManageDO.settlementCustomers != null and contractManageDO.settlementCustomers != '' " >
and settlement_customers like concat('%', #{contractManageDO.settlementCustomers}, '%') and a.settlement_customers like concat('%', #{contractManageDO.settlementCustomers}, '%')
</if> </if>
<if test="contractManageDO.settlementCustomersCode != null"> <if test="contractManageDO.settlementCustomersCode != null">
and settlement_customers_code = #{contractManageDO.settlementCustomersCode} and a.settlement_customers_code = #{contractManageDO.settlementCustomersCode}
</if> </if>
<if test="contractManageDO.signingUnit != null and contractManageDO.signingUnit != ''"> <if test="contractManageDO.signingUnit != null and contractManageDO.signingUnit != ''">
and signing_unit like concat('%', #{contractManageDO.signingUnit}, '%') and a.signing_unit like concat('%', #{contractManageDO.signingUnit}, '%')
</if> </if>
<if test="contractManageDO.contractName != null and contractManageDO.contractName != ''"> <if test="contractManageDO.contractName != null and contractManageDO.contractName != ''">
and contract_name like concat('%', #{contractManageDO.contractName}, '%') and a.contract_name like concat('%', #{contractManageDO.contractName}, '%')
</if> </if>
<if test="contractManageDO.contractState != null"> <if test="contractManageDO.contractState != null">
and contract_state = #{contractManageDO.contractState} and a.contract_state = #{contractManageDO.contractState}
</if> </if>
<if test="contractManageDO.signingDateStart != null and contractManageDO.signingDateStart != ''"> <if test="contractManageDO.signingDateStart != null and contractManageDO.signingDateStart != ''">
AND date_format(signing_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.signingDateStart} AND date_format(a.signing_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.signingDateStart}
</if> </if>
<if test="contractManageDO.signingDateEnd != null and contractManageDO.signingDateEnd != ''"> <if test="contractManageDO.signingDateEnd != null and contractManageDO.signingDateEnd != ''">
AND date_format(signing_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.signingDateEnd} AND date_format(a.signing_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.signingDateEnd}
</if> </if>
<if test="contractManageDO.effectiveDateStart != null and contractManageDO.effectiveDateStart != ''"> <if test="contractManageDO.effectiveDateStart != null and contractManageDO.effectiveDateStart != ''">
AND date_format(effective_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.effectiveDateStart} AND date_format(a.effective_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.effectiveDateStart}
</if> </if>
<if test="contractManageDO.effectiveDateEnd != null and contractManageDO.effectiveDateEnd != ''"> <if test="contractManageDO.effectiveDateEnd != null and contractManageDO.effectiveDateEnd != ''">
AND date_format(effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.effectiveDateEnd} AND date_format(a.effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.effectiveDateEnd}
</if> </if>
<if test="contractManageDO.expirationDateStart != null and contractManageDO.expirationDateStart != ''"> <if test="contractManageDO.expirationDateStart != null and contractManageDO.expirationDateStart != ''">
AND date_format(expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.expirationDateStart} AND date_format(a.expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.expirationDateStart}
</if> </if>
<if test="contractManageDO.expirationDateEnd != null and contractManageDO.expirationDateEnd != ''"> <if test="contractManageDO.expirationDateEnd != null and contractManageDO.expirationDateEnd != ''">
AND date_format(expiration_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateEnd} AND date_format(a.expiration_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateEnd}
</if> </if>
<!-- 时间段重叠判断:只有当已有合同与传入的有效期真正有交集时才算冲突 <!-- 时间段重叠判断:只有当已有合同与传入的有效期真正有交集时才算冲突
条件:已有合同开始日期 <= 新合同结束日期 且 已有合同结束日期 >= 新合同开始日期 --> 条件:已有合同开始日期 <= 新合同结束日期 且 已有合同结束日期 >= 新合同开始日期 -->
<if test="contractManageDO.effectiveDateString != null and contractManageDO.effectiveDateString != '' <if test="contractManageDO.effectiveDateString != null and contractManageDO.effectiveDateString != ''
and contractManageDO.expirationDateString != null and contractManageDO.expirationDateString != ''"> and contractManageDO.expirationDateString != null and contractManageDO.expirationDateString != ''">
AND ( AND (
date_format(effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateString} date_format(a.effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateString}
AND date_format(expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.effectiveDateString} AND date_format(a.expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.effectiveDateString}
) )
</if> </if>
<if test="contractManageDO.nowDateString != null and contractManageDO.nowDateString != ''"> <if test="contractManageDO.nowDateString != null and contractManageDO.nowDateString != ''">
AND ( AND (
date_format(expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.nowDateString} date_format(a.expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.nowDateString}
AND date_format(effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.nowDateString} AND date_format(a.effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.nowDateString}
) )
</if> </if>
<if test="contractManageDO.organizationId != null"> <if test="contractManageDO.organizationId != null">
and organization_id = #{contractManageDO.organizationId} and a.organization_id = #{contractManageDO.organizationId}
</if> </if>
<if test="contractManageDO.topOrganizationId != null"> <if test="contractManageDO.topOrganizationId != null">
and top_organization_id = #{contractManageDO.topOrganizationId} and a.top_organization_id = #{contractManageDO.topOrganizationId}
</if>
<if test="contractManageDO.firstSubjectCode != null and contractManageDO.firstSubjectCode != ''">
and b.FIRST_SUBJECT_CODE = #{contractManageDO.firstSubjectCode}
</if> </if>
</sql> </sql>
</mapper> </mapper>
@@ -7,10 +7,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mhd.bms.application.server.billingRules.CostCalculationApplicationService; import com.mhd.bms.application.server.billingRules.CostCalculationApplicationService;
import com.mhd.bms.application.server.settlementCustomers.SettlementCustomersApplicationService; import com.mhd.bms.application.server.settlementCustomers.SettlementCustomersApplicationService;
import com.mhd.bms.domain.billManage.entity.BillDetail;
import com.mhd.bms.domain.billManage.entity.BillManage;
import com.mhd.bms.domain.billManage.repository.facade.IBillDetailService;
import com.mhd.bms.domain.billManage.repository.facade.IBillManageService;
import com.mhd.bms.domain.billingRules.repository.po.BillingParamsPO; import com.mhd.bms.domain.billingRules.repository.po.BillingParamsPO;
import com.mhd.bms.domain.billingRules.repository.po.BillingRulesPO; import com.mhd.bms.domain.billingRules.repository.po.BillingRulesPO;
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
import com.mhd.bms.domain.billingStatement.repository.mapper.BillingStatementMapper;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementDO;
import com.mhd.bms.domain.billingStatement.service.BillingStatementDomainService; import com.mhd.bms.domain.billingStatement.service.BillingStatementDomainService;
import com.mhd.bms.domain.businessDocument.entity.BusinessDocument; import com.mhd.bms.domain.businessDocument.entity.BusinessDocument;
import com.mhd.bms.domain.businessDocument.repository.mapper.BusinessDocumentMapper;
import com.mhd.bms.domain.businessDocument.repository.po.BusinessDocumentPO; import com.mhd.bms.domain.businessDocument.repository.po.BusinessDocumentPO;
import com.mhd.bms.domain.businessDocument.repository.todo.BusinessDocumentDO; import com.mhd.bms.domain.businessDocument.repository.todo.BusinessDocumentDO;
import com.mhd.bms.domain.businessDocument.service.BusinessDocumentDomainService; import com.mhd.bms.domain.businessDocument.service.BusinessDocumentDomainService;
@@ -30,6 +38,7 @@ import com.mhd.bms.infrastructure.feign.vo.ContractManagePO;
import com.mhd.bms.infrastructure.feign.vo.ExpenseAccountPO; import com.mhd.bms.infrastructure.feign.vo.ExpenseAccountPO;
import com.mhd.bms.interfaces.assembler.businessDocument.BusinessDocumentAssembler; import com.mhd.bms.interfaces.assembler.businessDocument.BusinessDocumentAssembler;
import com.mhd.bms.interfaces.dto.billingRules.CostCalculationDTO; import com.mhd.bms.interfaces.dto.billingRules.CostCalculationDTO;
import com.mhd.bms.interfaces.dto.billingStatement.BillingStatementDTO;
import com.mhd.bms.interfaces.dto.businessDocument.BusinessDocumentDTO; import com.mhd.bms.interfaces.dto.businessDocument.BusinessDocumentDTO;
import com.mhd.common.core.domain.dto.BusinessDataPushDTO; import com.mhd.common.core.domain.dto.BusinessDataPushDTO;
import com.mhd.common.core.domain.po.OrganizationPo; import com.mhd.common.core.domain.po.OrganizationPo;
@@ -86,6 +95,14 @@ public class BusinessDocumentApplicationService {
private CostCalculationApplicationService costCalculationApplicationService; private CostCalculationApplicationService costCalculationApplicationService;
@Autowired @Autowired
private ISettlementCustomersService settlementCustomersService; private ISettlementCustomersService settlementCustomersService;
@Autowired
private BusinessDocumentMapper businessDocumentMapper;
@Autowired
private BillingStatementMapper billingStatementMapper;
@Autowired
private IBillManageService billManageService;
@Autowired
private IBillDetailService billDetailService;
/** /**
@@ -202,6 +219,112 @@ public class BusinessDocumentApplicationService {
return businessDocumentDomainService.insert(businessDocumentDO); return businessDocumentDomainService.insert(businessDocumentDO);
} }
@Transactional(rollbackFor = Exception.class)
public Boolean manageAddFee(BusinessDocumentDO businessDocumentDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//先设置组织信息,因为handleDate方法中需要使用topOrganizationId
businessDocumentDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
businessDocumentDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
businessDocumentDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
UserPo userPo = loginUser.getUserPo();
businessDocumentDO.setCreateBy(userPo.getUserId());
businessDocumentDO.setCreateByName(userPo.getUserName());
//校验使用的表单是否必填校验
checkDoucumentType(businessDocumentDO);
//处理数据
handleDate(businessDocumentDO);
businessDocumentDO.setDataSources(2);
businessDocumentDO.setBusinessFlow(OrderSequence.getOrderCode("LS"));
//调用费用计算,计算费用金额进行保存
CostCalculationDTO costCalculationDTO = new CostCalculationDTO();
costCalculationDTO.setOriginalBusinessNum(businessDocumentDO.getOriginalBusinessNum());
costCalculationDTO.setContractNumber(businessDocumentDO.getContractNumber());
costCalculationDTO.setFormJson(businessDocumentDO.getDocumentFormJson());
costCalculationDTO.setSubjectCode(StringUtils.isEmpty(businessDocumentDO.getSecondSubjectCode()) ? businessDocumentDO.getFirstSubjectCode():businessDocumentDO.getSecondSubjectCode());
costCalculationDTO.setDocumentTypeCode(businessDocumentDO.getDocumentTypeCode());
costCalculationDTO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
costCalculationDTO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
costCalculationDTO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
BillingCostPo billingCostPo = costCalculationApplicationService.costCalculation(costCalculationDTO);
businessDocumentDO.setEstimatedCost(billingCostPo.getComputationalCost());
BillingRulesPO billingRulesPO = billingCostPo.getBillingRulesPO();
List<BillingParamsPO> billingParamsPOList = billingRulesPO.getBillingParamsPOList();
if (ObjectUtil.isNotNull(billingParamsPOList)&&billingParamsPOList.size()>0) {
BillingParamsPO billingParamsPO = billingParamsPOList.get(0);
String billingParamsJson = billingParamsPO.getBillingParamsJson();
String preSetRules = billingParamsPO.getPreSetRules();
String documentFormJson = businessDocumentDO.getDocumentFormJson();
JSONObject paramObj = JSONObject.parseObject(documentFormJson);
List<BillingParamsEntity> billingParamsEntityList = JSON.parseArray(billingParamsJson, BillingParamsEntity.class);
for (BillingParamsEntity billingParamsEntity : billingParamsEntityList) {
String isFee = billingParamsEntity.getIsFee();
String fields = billingParamsEntity.getFields();
// 安全获取值并转 BigDecimal(不会报错)
BigDecimal value = getSafeBigDecimal(paramObj, fields);
if ("1".equals(isFee)) {
businessDocumentDO.setBillingUnitPrice(value.setScale(2, BigDecimal.ROUND_HALF_UP));
} else {
businessDocumentDO.setBillingNum(value.setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
}
BusinessDocument businessDocument = businessDocumentDomainService.insertRetrun(businessDocumentDO);
BusinessDocumentDTO businessDocumentDTO = new BusinessDocumentDTO();
businessDocumentDTO.setBusinessDocumentIds(businessDocument.getBusinessDocumentId().toString());
businessDocumentDTO.setAuditOperation(1);
takeEffectByIds(businessDocumentDTO);
auditByIds(businessDocumentDTO);
List<BillingStatement> billingStatements = billingStatementMapper.selectList(new LambdaQueryWrapper<BillingStatement>()
.eq(BillingStatement::getBusinessDocumentId, businessDocument.getBusinessDocumentId())
.eq(BillingStatement::getDelFlag, 1));
BillingStatement billingStatement = null;
if (ObjectUtil.isNotNull(billingStatements)&&billingStatements.size()>0) {
billingStatement = billingStatements.get(0);
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
billingStatementDTO.setBillingStatementIds(billingStatement.getBillingStatementId().toString());
billingStatementDTO.setAuditOperation(1);
billingStatementDomainService.reviewBilling(billingStatementDTO);
}
BillManage billManage = billManageService.getById(businessDocumentDO.getBillManageId());
BillDetail billDetail = new BillDetail();
billDetail.setBillManageId(businessDocumentDO.getBillManageId());
billDetail.setBillNumber(billManage.getBillNumber());
billDetail.setBillingStatementId(billingStatement.getBillingStatementId());
billDetail.setBillingFlow(billingStatement.getBillingFlow());
billDetail.setOrganizationId(billManage.getOrganizationId());
billDetail.setOrganizationName(billManage.getOrganizationName());
billDetail.setTopOrganizationId(billManage.getTopOrganizationId());
billDetail.setCreateBy(userPo.getUserId());
billDetail.setCreateByName(userPo.getUserName());
billDetail.setCreateTime(new Date());
billDetail.setDelFlag(1);
billDetail.setBillingTotalAmount(billingStatement.getBillingAmount());
billDetail.setBillingDiscountAmount(BigDecimal.ZERO);
billDetail.setBillingAmount(billingStatement.getBillingAmount());
billDetail.setBillType(1);
billDetail.setBillingExpectedAmount(BigDecimal.ZERO);
billDetail.setFeeType(billingStatement.getServiceItemsName());
billDetail.setInvoiceItem(billingStatement.getFirstSubjectCode());
billDetail.setInvoiceItemName(billingStatement.getFirstSubjectName());
billDetail.setSettlementCurrency(billingStatement.getSettlementCurrency());
billDetail.setTaxAmount(billingStatement.getTaxAmount());
billDetail.setTaxFreeFee(billingStatement.getTaxFreeFee());
billDetail.setTaxRate(billingStatement.getTaxRate());
billDetailService.save(billDetail);
BigDecimal billAmount = billManage.getBillAmount();
BigDecimal amount = billAmount.add(billDetail.getBillingAmount());
billManage.setBillAmount(amount);
billManage.setBillTotalAmount(amount);
billManageService.updateById(billManage);
return true;
}
/** /**
* 从 JSONObject 安全获取 BigDecimal,支持: * 从 JSONObject 安全获取 BigDecimal,支持:
* 数字、整数字符串、小数字符串、null、空字符串 * 数字、整数字符串、小数字符串、null、空字符串
@@ -484,7 +607,7 @@ public class BusinessDocumentApplicationService {
if(businessDocumentDO.getBelongModuleCode().equals(BelongModuleCode.WMS.getCode())){ if(businessDocumentDO.getBelongModuleCode().equals(BelongModuleCode.WMS.getCode())){
contractType = 1; contractType = 1;
} }
AjaxResult ajaxResult = systemServiceFeign.getInfoByCustomerAndOrganizationId(businessDocumentDO.getSettlementCustomersCode(),contractType,businessDocumentDO.getTopOrganizationId(),businessDocumentDO.getOrganizationId()); AjaxResult ajaxResult = systemServiceFeign.getInfoByCustomerAndSecondSubjectCode(businessDocumentDO.getSettlementCustomersCode(),contractType,businessDocumentDO.getFirstSubjectCode(),businessDocumentDO.getTopOrganizationId(),businessDocumentDO.getOrganizationId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) { if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("合同信息未找到"); throw new ServiceException("合同信息未找到");
} }
@@ -675,8 +675,8 @@ public class BillingStatementDomainService {
billingStatementDO.setSettlementCustomersCode(billManagePO.getSettlementCustomersCode()); billingStatementDO.setSettlementCustomersCode(billManagePO.getSettlementCustomersCode());
billingStatementDO.setBelongModuleCode(billManagePO.getBelongModuleCode()); billingStatementDO.setBelongModuleCode(billManagePO.getBelongModuleCode());
billingStatementDO.setAccountExpenseType(billManagePO.getBillType()); billingStatementDO.setAccountExpenseType(billManagePO.getBillType());
billingStatementDO.setCycleBeginTime(billManagePO.getCycleBeginTime()); // billingStatementDO.setCycleBeginTime(billManagePO.getCycleBeginTime());
billingStatementDO.setCycleEndTime(billManagePO.getCycleEndTime()); // billingStatementDO.setCycleEndTime(billManagePO.getCycleEndTime());
billingStatementDO.setBillingState(2); billingStatementDO.setBillingState(2);
startPage(); startPage();
return billingStatementService.queryList(billingStatementDO); return billingStatementService.queryList(billingStatementDO);
@@ -218,4 +218,6 @@ public class BusinessDocumentDO extends BaseVOEntity{
private BigDecimal billingUnitPrice; private BigDecimal billingUnitPrice;
@ApiModelProperty("nc科目编码") @ApiModelProperty("nc科目编码")
private String ncSubjectCode; private String ncSubjectCode;
private Long billManageId;
} }
@@ -213,4 +213,6 @@ public class BusinessDocumentDTO extends BaseVOEntity{
private String paymentAccountId; private String paymentAccountId;
@ApiModelProperty("收款帐户名称") @ApiModelProperty("收款帐户名称")
private String paymentAccountName; private String paymentAccountName;
private Long billManageId;
} }
@@ -79,6 +79,25 @@ public class BusinessDocumentApi extends BaseController{
} }
/**
* 保存业务单据
*/
@ApiOperation("账单添加费用")
@PostMapping("/manageAddFee")
public AjaxResult manageAddFee(@RequestBody BusinessDocumentDTO businessDocumentDTO)
{
try {
//转换实体
BusinessDocumentDO businessDocumentDO = businessDocumentAssembler.toDO(businessDocumentDTO);
return toAjax(businessDocumentApplicationService.manageAddFee(businessDocumentDO));
} catch (ServiceException e) {
return AjaxResult.error(e.getMessage());
} catch (Exception e){
return AjaxResult.error("保存业务单据失败:" + e.getMessage());
}
}
/** /**
* 保存业务单据 * 保存业务单据
@@ -25,6 +25,8 @@ import com.mhd.oms.domain.gwLog.entity.GwLog;
import com.mhd.oms.domain.gwLog.repository.mapper.GwLogMapper; import com.mhd.oms.domain.gwLog.repository.mapper.GwLogMapper;
import com.mhd.oms.domain.documentPushMaterialRecord.entity.DocumentPushMaterialRecord; import com.mhd.oms.domain.documentPushMaterialRecord.entity.DocumentPushMaterialRecord;
import com.mhd.oms.domain.documentPushMaterialRecord.repository.mapper.DocumentPushMaterialRecordMapper; import com.mhd.oms.domain.documentPushMaterialRecord.repository.mapper.DocumentPushMaterialRecordMapper;
import com.mhd.oms.domain.erpCountry.entity.ErpCountry;
import com.mhd.oms.domain.erpCountry.repository.mapper.ErpCountryMapper;
import com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessAuditDTO; import com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessAuditDTO;
import com.mhd.oms.interfaces.dto.businessDocumentOrder.BusinessDocumentOrderDTO; import com.mhd.oms.interfaces.dto.businessDocumentOrder.BusinessDocumentOrderDTO;
import com.mhd.system.api.model.LoginUser; import com.mhd.system.api.model.LoginUser;
@@ -42,6 +44,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@@ -93,6 +96,9 @@ public class BusinessDocumentOrderApplicationService {
@Resource @Resource
private DocumentPushMaterialRecordMapper documentPushMaterialRecordMapper; private DocumentPushMaterialRecordMapper documentPushMaterialRecordMapper;
@Resource
private ErpCountryMapper erpCountryMapper;
/** /**
* 分页查询请填写功能名称列表 * 分页查询请填写功能名称列表
*/ */
@@ -246,6 +252,10 @@ public class BusinessDocumentOrderApplicationService {
body.put("goodsType", goodsType != null ? goodsType : ""); body.put("goodsType", goodsType != null ? goodsType : "");
body.put("ieFlag", order.getIeType() != null ? order.getIeType() : ""); body.put("ieFlag", order.getIeType() != null ? order.getIeType() : "");
body.put("corpCode", corpCode != null ? corpCode : ""); body.put("corpCode", corpCode != null ? corpCode : "");
// 启运/运抵国地区收货地ErpCountry表
body.put("stshipTrsarvNatcd", lookupErpCountryCode(order.getUnloadAreaId(), order.getUnloadName()));
// 贸易国地区发货地ErpCountry表
body.put("tradeAreaCode", lookupErpCountryCode(order.getLoadingAreaId(), order.getLoadingName()));
List<Map<String, Object>> billList = new ArrayList<>(); List<Map<String, Object>> billList = new ArrayList<>();
if (cargoList != null && !cargoList.isEmpty()) { if (cargoList != null && !cargoList.isEmpty()) {
@@ -257,28 +267,53 @@ public class BusinessDocumentOrderApplicationService {
billMap.put("packNo", cargo.getCargoNum() != null ? cargo.getCargoNum() : ""); billMap.put("packNo", cargo.getCargoNum() != null ? cargo.getCargoNum() : "");
billMap.put("erpQty", cargo.getCargoNum() != null ? cargo.getCargoNum() : ""); billMap.put("erpQty", cargo.getCargoNum() != null ? cargo.getCargoNum() : "");
// 查询物料基础信息计算净重和毛重 // 查询物料基础信息
MaterialBaseInfoPO material = null;
if (cargo.getMaterialBaseInfoId() != null) { if (cargo.getMaterialBaseInfoId() != null) {
MaterialBaseInfoPO material = reservationStockInOrderMapper.getinfo(cargo.getMaterialBaseInfoId()); material = reservationStockInOrderMapper.getinfo(cargo.getMaterialBaseInfoId());
if (material != null && cargo.getCargoNum() != null) { }
if (material.getWeightLimit() != null) { if (material != null) {
billMap.put("netWt", material.getWeightLimit().multiply(cargo.getCargoNum())); // 净重和毛重
} else { if (cargo.getCargoNum() != null) {
billMap.put("netWt", ""); billMap.put("netWt", material.getWeightLimit() != null
} ? material.getWeightLimit().multiply(cargo.getCargoNum()) : "");
if (material.getGrossWeight() != null) { billMap.put("grossWt", material.getGrossWeight() != null
billMap.put("grossWt", material.getGrossWeight().multiply(cargo.getCargoNum())); ? material.getGrossWeight().multiply(cargo.getCargoNum()) : "");
} else {
billMap.put("grossWt", "");
}
} else { } else {
billMap.put("netWt", ""); billMap.put("netWt", "");
billMap.put("grossWt", ""); billMap.put("grossWt", "");
} }
// 货物名称
billMap.put("goodsName", material.getMaterialName() != null ? material.getMaterialName() : "");
// 成交单位申报单位
billMap.put("gUnit", material.getDeclarationUnit() != null ? material.getDeclarationUnit() : "");
// 币制
billMap.put("currency", material.getCurrency() != null ? material.getCurrency() : "");
// 原产国countryCode
billMap.put("countryCode", material.getOriginCountry() != null ? material.getOriginCountry() : "");
// 单价企业单价
BigDecimal unitPrice = material.getUnitPrice();
billMap.put("unitPrice", unitPrice != null ? unitPrice : "");
// 总价entTotal = 成交数量 × 单价
if (unitPrice != null && cargo.getCargoNum() != null) {
billMap.put("entTotal", unitPrice.multiply(cargo.getCargoNum()));
} else {
billMap.put("entTotal", "");
}
} else { } else {
billMap.put("netWt", ""); billMap.put("netWt", "");
billMap.put("grossWt", ""); billMap.put("grossWt", "");
billMap.put("goodsName", "");
billMap.put("gUnit", "");
billMap.put("currency", "");
billMap.put("countryCode", "");
billMap.put("unitPrice", "");
billMap.put("entTotal", "");
} }
// 最终目的国收货地
billMap.put("destinationCountry", order.getUnloadName() != null ? order.getUnloadName() : "");
// 境内货源地发货地
billMap.put("domesticSourcePlace", order.getLoadingName() != null ? order.getLoadingName() : "");
billList.add(billMap); billList.add(billMap);
} }
} }
@@ -401,6 +436,30 @@ public class BusinessDocumentOrderApplicationService {
} }
/** 根据区域ID或名称查ErpCountry表获取国别编码 */
private String lookupErpCountryCode(String areaId, String areaName) {
if (areaId == null && areaName == null) return "";
try {
LambdaQueryWrapper<ErpCountry> qw = new LambdaQueryWrapper<>();
qw.eq(ErpCountry::getDelFlag, 1);
if (areaId != null) {
qw.eq(ErpCountry::getErpCountryCode, areaId);
}
List<ErpCountry> list = erpCountryMapper.selectList(qw);
if (!list.isEmpty()) return list.get(0).getErpCountryCode();
// 按名称模糊匹配
if (areaName != null) {
LambdaQueryWrapper<ErpCountry> qw2 = new LambdaQueryWrapper<>();
qw2.eq(ErpCountry::getDelFlag, 1).like(ErpCountry::getErpCountryName, areaName);
List<ErpCountry> list2 = erpCountryMapper.selectList(qw2);
if (!list2.isEmpty()) return list2.get(0).getErpCountryCode();
}
} catch (Exception e) {
log.warn("查ErpCountry失败 areaId={} areaName={}", areaId, areaName, e);
}
return areaId != null ? areaId : "";
}
private void updatePushStatus(Long id, Integer pushStatus, Date pushTime, String pushBy, String pushByName) { private void updatePushStatus(Long id, Integer pushStatus, Date pushTime, String pushBy, String pushByName) {
try { try {
@@ -819,6 +819,18 @@ public class OrderWithMaterialDTO {
@ApiModelProperty("启运/运抵国地区")
private String stshipTrsarvNatcd;
@ApiModelProperty("贸易国地区")
private String tradeAreaCode;
@ApiModelProperty("企业总价")
private BigDecimal entTotal;
@ApiModelProperty("原产国(与originCountry同源)")
private String countryCode;
@ApiModelProperty("删改单申请类型:0-改单 1-删除 2-作废") @ApiModelProperty("删改单申请类型:0-改单 1-删除 2-作废")
private Integer reviseApplyType; private Integer reviseApplyType;
@@ -13,11 +13,16 @@ import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCarg
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.mapper.BusinessDocumentCargoMultiMapper; import com.mhd.oms.domain.businessDocumentCargoMulti.repository.mapper.BusinessDocumentCargoMultiMapper;
import com.mhd.oms.domain.businessDocumentOrder.repository.po.BusinessDocumentOrderPO; import com.mhd.oms.domain.businessDocumentOrder.repository.po.BusinessDocumentOrderPO;
import com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocumentOrderDO; import com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocumentOrderDO;
import com.mhd.oms.domain.erpCountry.entity.ErpCountry;
import com.mhd.oms.domain.erpCountry.repository.mapper.ErpCountryMapper;
import com.mhd.oms.domain.reservationStockInOrder.repository.mapper.ReservationStockInOrderMapper;
import com.mhd.oms.domain.reservationStockInOrder.repository.po.MaterialBaseInfoPO;
import com.mhd.oms.interfaces.assembler.businessDocumentOrder.BusinessDocumentOrderAssembler; import com.mhd.oms.interfaces.assembler.businessDocumentOrder.BusinessDocumentOrderAssembler;
import com.mhd.oms.interfaces.dto.businessDocumentOrder.BusinessDocumentOrderDTO; import com.mhd.oms.interfaces.dto.businessDocumentOrder.BusinessDocumentOrderDTO;
import com.mhd.oms.interfaces.dto.originalImportExportDocument.OrderWithMaterialDTO; import com.mhd.oms.interfaces.dto.originalImportExportDocument.OrderWithMaterialDTO;
import com.mhd.system.api.WmsServiceFeign; import com.mhd.system.api.WmsServiceFeign;
import com.mhd.system.api.domain.MaterialInfoDTO; import com.mhd.system.api.domain.MaterialInfoDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@@ -29,6 +34,8 @@ import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.reflections.Reflections.log;
@Api(tags = "进出口原始单证") @Api(tags = "进出口原始单证")
@RestController @RestController
@RequestMapping("/OriginalImportExportDocumentApi") @RequestMapping("/OriginalImportExportDocumentApi")
@@ -43,6 +50,12 @@ public class OriginalImportExportDocumentApi extends BaseController {
@Resource @Resource
private BusinessDocumentOrderAssembler businessDocumentOrderAssembler; private BusinessDocumentOrderAssembler businessDocumentOrderAssembler;
@Resource
private ErpCountryMapper erpCountryMapper;
@Resource
private ReservationStockInOrderMapper reservationStockInOrderMapper;
@Resource @Resource
private WmsServiceFeign wmsServiceFeign; private WmsServiceFeign wmsServiceFeign;
@@ -117,6 +130,7 @@ public class OriginalImportExportDocumentApi extends BaseController {
Page<BusinessDocumentOrderPO> page = (Page<BusinessDocumentOrderPO>) orderList; Page<BusinessDocumentOrderPO> page = (Page<BusinessDocumentOrderPO>) orderList;
List<OrderWithMaterialDTO> resultList = convertToOrderWithMaterialList(orderList); List<OrderWithMaterialDTO> resultList = convertToOrderWithMaterialList(orderList);
populateTradeFields(resultList, orderList);
//return getDataTable(resultList); //return getDataTable(resultList);
TableDataInfo tableDataInfo = new TableDataInfo(); TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setData(resultList); tableDataInfo.setData(resultList);
@@ -185,6 +199,53 @@ public class OriginalImportExportDocumentApi extends BaseController {
return resultList; return resultList;
} }
/** 填充贸易相关字段:启运/运抵国地区、贸易国地区、企业总价、原产国 */
private void populateTradeFields(List<OrderWithMaterialDTO> resultList, List<BusinessDocumentOrderPO> orderList) {
for (int i = 0; i < resultList.size(); i++) {
OrderWithMaterialDTO dto = resultList.get(i);
BusinessDocumentOrderPO order = orderList.get(i);
// 启运/运抵国地区收货地 ErpCountry
dto.setStshipTrsarvNatcd(lookupCountryCode(order.getUnloadAreaId(), order.getUnloadName()));
// 贸易国地区发货地 ErpCountry
dto.setTradeAreaCode(lookupCountryCode(order.getLoadingAreaId(), order.getLoadingName()));
// 原产国直接取originCountry
dto.setCountryCode(dto.getOriginCountry());
// 企业总价 = 数量 × 单价
List<BusinessDocumentCargoMulti> cargoList = order.getBusinessDocumentCargoMultiList();
if (cargoList != null && !cargoList.isEmpty()) {
BusinessDocumentCargoMulti cargo = cargoList.get(0);
if (cargo.getMaterialBaseInfoId() != null) {
MaterialBaseInfoPO material = reservationStockInOrderMapper.getinfo(cargo.getMaterialBaseInfoId());
if (material != null && material.getUnitPrice() != null && cargo.getCargoNum() != null) {
dto.setEntTotal(material.getUnitPrice().multiply(cargo.getCargoNum()));
}
}
}
}
}
/** 查 ErpCountry 表获取国别编码 */
private String lookupCountryCode(String areaId, String areaName) {
if (areaId == null && areaName == null) return "";
try {
LambdaQueryWrapper<ErpCountry> qw = new LambdaQueryWrapper<>();
qw.eq(ErpCountry::getDelFlag, 1);
if (areaId != null) qw.eq(ErpCountry::getErpCountryCode, areaId);
List<ErpCountry> list = erpCountryMapper.selectList(qw);
if (!list.isEmpty()) return list.get(0).getErpCountryCode();
if (areaName != null) {
LambdaQueryWrapper<ErpCountry> qw2 = new LambdaQueryWrapper<>();
qw2.eq(ErpCountry::getDelFlag, 1).like(ErpCountry::getErpCountryName, areaName);
List<ErpCountry> list2 = erpCountryMapper.selectList(qw2);
if (!list2.isEmpty()) return list2.get(0).getErpCountryCode();
}
} catch (Exception e) { log.warn("查ErpCountry失败", e); }
return areaId != null ? areaId : "";
}
@ApiOperation("批量推送") @ApiOperation("批量推送")
@PostMapping("/batchPushForReviseApply") @PostMapping("/batchPushForReviseApply")
@@ -336,6 +336,17 @@ public class ReviewOrderApplicationService {
syncOutOrderCheckQtyByReviewConfirm(reviewOrderId, loginUser); syncOutOrderCheckQtyByReviewConfirm(reviewOrderId, loginUser);
// 与出库单复核确认一致复核数量与拣货数量不一致时生成复核异常单FHYC // 与出库单复核确认一致复核数量与拣货数量不一致时生成复核异常单FHYC
genOutOrderAbnormalAfterReviewConfirm(reviewOrderId); genOutOrderAbnormalAfterReviewConfirm(reviewOrderId);
// 校验复核确认前已复核数量必须等于计划数量
List<ReviewMaterialDetailPO> details = reviewOrderMapper.queryDetailByReviewOrderId(reviewOrderId);
if (!CollectionUtils.isEmpty(details)) {
for (ReviewMaterialDetailPO detail : details) {
BigDecimal reviewed = nz(detail.getReviewedQty());
BigDecimal plan = nz(detail.getMaterialPlanQty());
if (reviewed.compareTo(plan) != 0) {
throw new ServiceException("该物料已复核数量不等于计划数量");
}
}
}
ReviewOrder order = reviewOrderMapper.selectById(reviewOrderId); ReviewOrder order = reviewOrderMapper.selectById(reviewOrderId);
if (order == null) { if (order == null) {
continue; continue;
@@ -38,6 +38,8 @@ import com.mhd.wms.domain.materialBaseInfo.repository.facade.IMaterialBaseInfoSe
import com.mhd.wms.domain.materialBaseInfo.repository.po.MaterialBaseInfoPO; import com.mhd.wms.domain.materialBaseInfo.repository.po.MaterialBaseInfoPO;
import com.mhd.wms.domain.materialBaseInfo.repository.todo.MaterialBaseInfoDO; import com.mhd.wms.domain.materialBaseInfo.repository.todo.MaterialBaseInfoDO;
import com.mhd.wms.domain.pickingMaterialDetail.repository.mapper.PickingMaterialDetailMapper; import com.mhd.wms.domain.pickingMaterialDetail.repository.mapper.PickingMaterialDetailMapper;
import com.mhd.wms.domain.receiptMaterialDetail.entity.ReceiptMaterialDetail;
import com.mhd.wms.domain.receiptMaterialDetail.repository.facade.IReceiptMaterialDetailService;
import com.mhd.wms.domain.receiptOrderAccount.entity.ReceiptOrderAccount; import com.mhd.wms.domain.receiptOrderAccount.entity.ReceiptOrderAccount;
import com.mhd.wms.domain.receiptOrderAccount.repository.facade.IReceiptOrderAccountService; import com.mhd.wms.domain.receiptOrderAccount.repository.facade.IReceiptOrderAccountService;
import com.mhd.wms.domain.stockInOrder.entity.StockInOrder; import com.mhd.wms.domain.stockInOrder.entity.StockInOrder;
@@ -107,6 +109,8 @@ public class StockInOrderApplicationService {
@Autowired @Autowired
private IStockReceiptOrderService stockReceiptOrderService; private IStockReceiptOrderService stockReceiptOrderService;
@Autowired @Autowired
private IReceiptMaterialDetailService receiptMaterialDetailService;
@Autowired
private IStockOutOrderService stockOutOrderService; private IStockOutOrderService stockOutOrderService;
@Autowired @Autowired
private IHandoverTaskOrderService handoverTaskOrderService; private IHandoverTaskOrderService handoverTaskOrderService;
@@ -452,9 +456,36 @@ public class StockInOrderApplicationService {
throw new ServiceException("入库单不存在,入库单ID" + inOrderId); throw new ServiceException("入库单不存在,入库单ID" + inOrderId);
} }
// 只有已创建状态status = 1的入库单可以删除 // 只有已创建状态status = 1的入库单可以删除
if (stockInOrderPO.getStatus() == null || !stockInOrderPO.getStatus().equals(1)) { // if (stockInOrderPO.getStatus() == null || !stockInOrderPO.getStatus().equals(1)) {
throw new ServiceException("只有已创建状态的入库单可以删除,入库单号:" + stockInOrderPO.getInOrderNumber() + ",当前状态:" + getStatusName(stockInOrderPO.getStatus())); // throw new ServiceException("只有已创建状态的入库单可以删除,入库单号:" + stockInOrderPO.getInOrderNumber() + ",当前状态:" + getStatusName(stockInOrderPO.getStatus()));
// }
List<InMaterialDetail> list = inMaterialDetailService.list(new LambdaQueryWrapper<InMaterialDetail>()
.eq(InMaterialDetail::getInOrderNumber, stockInOrderPO.getInOrderNumber())
.eq(InMaterialDetail::getDelFlag, 1));
if (list != null && list.size() > 0) {
for (InMaterialDetail inMaterialDetail : list) {
inMaterialDetail.setDelFlag(2);
inMaterialDetailService.updateById(inMaterialDetail);
}
} }
StockReceiptOrder stockReceiptOrder = stockReceiptOrderService.getOne(new LambdaQueryWrapper<StockReceiptOrder>()
.eq(StockReceiptOrder::getInOrderNumber, stockInOrderPO.getInOrderNumber())
.eq(StockReceiptOrder::getDelFlag, 1),false);
if (stockReceiptOrder != null) {
stockReceiptOrder.setDelFlag(2);
stockReceiptOrderService.updateById(stockReceiptOrder);
List<ReceiptMaterialDetail> list1 = receiptMaterialDetailService.list(new LambdaQueryWrapper<ReceiptMaterialDetail>()
.eq(ReceiptMaterialDetail::getReceiptOrderNumber, stockReceiptOrder.getReceiptOrderNumber())
.eq(ReceiptMaterialDetail::getDelFlag, 1));
if (list1 != null && list1.size() > 0) {
for (ReceiptMaterialDetail receiptMaterialDetail : list1) {
receiptMaterialDetail.setDelFlag(2);
receiptMaterialDetailService.updateById(receiptMaterialDetail);
}
}
}
} }
return stockInOrderDomainService.delete(inOrderIds); return stockInOrderDomainService.delete(inOrderIds);
@@ -229,4 +229,8 @@ public class MaterialInventoryPO extends MaterialBasePO {
@ApiModelProperty("LOT编号") @ApiModelProperty("LOT编号")
@Excel(name = "LOT编号") @Excel(name = "LOT编号")
private String lotNumber; private String lotNumber;
@ApiModelProperty("规格型号")
@Excel(name = "规格型号")
private String specificationModel;
} }
@@ -250,4 +250,13 @@ public class MaterialInventoryDO extends MaterialBaseDO {
private String expiryDateStr; private String expiryDateStr;
private String productionDateStr; private String productionDateStr;
private String updateTimeStr; private String updateTimeStr;
private String expiryDateStart;
private String expiryDateEnd;
private String productionDateStart;
private String productionDateEnd;
private String updateTimeStart;
private String updateTimeEnd;
} }
@@ -125,6 +125,9 @@ public class PickingOrderPO extends StockOutOrderBasePO {
@ApiModelProperty("出库单号") @ApiModelProperty("出库单号")
@Excel(name = "出库单号") @Excel(name = "出库单号")
private String outOrderNumber; private String outOrderNumber;
@ApiModelProperty("出库单id")
@Excel(name = "出库单id")
private String outOrderId;
@ApiModelProperty("业务单号") @ApiModelProperty("业务单号")
@Excel(name = "业务单号") @Excel(name = "业务单号")
@@ -405,4 +405,7 @@ public class ShelfMaterialDetailPO extends BaseVOEntity {
private BigDecimal erpPriceGw; private BigDecimal erpPriceGw;
//申报总价 //申报总价
private BigDecimal amountGw; private BigDecimal amountGw;
@ApiModelProperty("规格型号")
private String specificationModel;
} }
@@ -27,6 +27,7 @@ import com.mhd.wms.domain.materialBaseInfo.repository.todo.MaterialBaseInfoDO;
import com.mhd.wms.domain.outMaterialDetail.repository.todo.OutMaterialDetailDO; import com.mhd.wms.domain.outMaterialDetail.repository.todo.OutMaterialDetailDO;
import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder; import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder;
import com.mhd.wms.domain.stockOutOrder.repository.facade.IStockOutOrderService; import com.mhd.wms.domain.stockOutOrder.repository.facade.IStockOutOrderService;
import com.mhd.wms.domain.stockOutOrder.repository.mapper.StockOutOrderMapper;
import com.mhd.wms.domain.stockOutOrder.repository.todo.StockOutOrderDO; import com.mhd.wms.domain.stockOutOrder.repository.todo.StockOutOrderDO;
import com.mhd.wms.domain.stockOutOrder.service.StockOutOrderDomainService; import com.mhd.wms.domain.stockOutOrder.service.StockOutOrderDomainService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -58,6 +59,8 @@ public class ExcelParseService {
private MaterialBaseInfoApplicationService materialBaseInfoService; private MaterialBaseInfoApplicationService materialBaseInfoService;
@Autowired @Autowired
private StockOutOrderDomainService stockOutOrderDomainService; private StockOutOrderDomainService stockOutOrderDomainService;
@Autowired
private StockOutOrderMapper stockOutOrderMapper;
@Resource @Resource
private UserServiceFeign userServiceFeign; private UserServiceFeign userServiceFeign;
/** /**
@@ -111,6 +114,10 @@ public class ExcelParseService {
stockOutOrder.setWarehouseName(warehouseName); stockOutOrder.setWarehouseName(warehouseName);
stockOutOrder.setWarehouseCode(warehouseCode); stockOutOrder.setWarehouseCode(warehouseCode);
stockOutOrder.setWarehouseId(warehouseId); stockOutOrder.setWarehouseId(warehouseId);
stockOutOrder.setSalesmanId(String.valueOf(loginUser.getUserPo().getUserId()));
stockOutOrder.setSalesmanName(loginUser.getUserPo().getUserName());
String settlementCurrency = stockOutOrderMapper.getSettlementCurrency(shipperId);
stockOutOrder.setSettlementCurrency(settlementCurrency);
initDict(stockOutOrder); initDict(stockOutOrder);
if (loginUser != null){ if (loginUser != null){
stockOutOrder.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); stockOutOrder.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
@@ -236,17 +243,17 @@ public class ExcelParseService {
errorMsg.append(validateShipperMaterialDetails(stockOutOrder)); errorMsg.append(validateShipperMaterialDetails(stockOutOrder));
if (stockOutOrder.getMaterialDetailList() == null || stockOutOrder.getMaterialDetailList().isEmpty()) errorMsg.append("物料明细列表不能为空或匹配不上物料信息; "); if (stockOutOrder.getMaterialDetailList() == null || stockOutOrder.getMaterialDetailList().isEmpty()) errorMsg.append("物料明细列表不能为空或匹配不上物料信息; ");
if (StringUtils.isEmpty(stockOutOrder.getTo())) errorMsg.append("To不能为空; "); if (StringUtils.isEmpty(stockOutOrder.getTo())) errorMsg.append("To不能为空; ");
if (StringUtils.isEmpty(stockOutOrder.getEntrustNo())) errorMsg.append("委托单号不能为空; "); // if (StringUtils.isEmpty(stockOutOrder.getEntrustNo())) errorMsg.append("委托单号不能为空; ");
if (StringUtils.isEmpty(stockOutOrder.getCarrier())) errorMsg.append("承运商不能为空; "); if (StringUtils.isEmpty(stockOutOrder.getCarrier())) errorMsg.append("承运商不能为空; ");
if (StringUtils.isEmpty(stockOutOrder.getTransportModeCode())) errorMsg.append("运输方式不能为空; "); if (StringUtils.isEmpty(stockOutOrder.getTransportModeCode())) errorMsg.append("运输方式不能为空; ");
if (StringUtils.isEmpty(stockOutOrder.getSupervisionModeCode())) errorMsg.append("监督方式不能为空; "); if (StringUtils.isEmpty(stockOutOrder.getSupervisionModeCode())) errorMsg.append("监督方式不能为空; ");
// if (StringUtils.isEmpty(stockOutOrder.getContainerNo())) errorMsg.append("柜号不能为空; "); // if (StringUtils.isEmpty(stockOutOrder.getContainerNo())) errorMsg.append("柜号不能为空; ");
if (StringUtils.isEmpty(stockOutOrder.getDepartureArrivalCountry())) errorMsg.append("出发/到达国家不能为空; "); if (StringUtils.isEmpty(stockOutOrder.getDepartureArrivalCountry())) errorMsg.append("出发/到达国家不能为空; ");
if (StringUtils.isEmpty(stockOutOrder.getManufacturer())) errorMsg.append("制造商不能为空; "); // if (StringUtils.isEmpty(stockOutOrder.getManufacturer())) errorMsg.append("制造商不能为空; ");
// if (ObjectUtil.isEmpty(stockOutOrder.getOutboundDate())) errorMsg.append("出仓日期不能为空; "); // if (ObjectUtil.isEmpty(stockOutOrder.getOutboundDate())) errorMsg.append("出仓日期不能为空; ");
if (StringUtils.isEmpty(stockOutOrder.getContactPerson())) errorMsg.append("联系人不能为空; "); if (StringUtils.isEmpty(stockOutOrder.getContactPerson())) errorMsg.append("联系人不能为空; ");
if (StringUtils.isEmpty(stockOutOrder.getTel())) errorMsg.append("Tel不能为空; "); // if (StringUtils.isEmpty(stockOutOrder.getTel())) errorMsg.append("Tel不能为空; ");
if (StringUtils.isEmpty(stockOutOrder.getFax())) errorMsg.append("Fax不能为空; "); // if (StringUtils.isEmpty(stockOutOrder.getFax())) errorMsg.append("Fax不能为空; ");
if (ObjectUtil.isEmpty(stockOutOrder.getShipperId())) errorMsg.append("客户名称不能为空或匹配不上客户信息; "); if (ObjectUtil.isEmpty(stockOutOrder.getShipperId())) errorMsg.append("客户名称不能为空或匹配不上客户信息; ");
//if (StringUtils.isEmpty(stockOutOrder.getNeedDeclareFlag())) errorMsg.append("是否需要申报不能为空; "); //if (StringUtils.isEmpty(stockOutOrder.getNeedDeclareFlag())) errorMsg.append("是否需要申报不能为空; ");
if (StringUtils.isEmpty(stockOutOrder.getDeclareCustoms())) errorMsg.append("申报地关区不能为空; "); if (StringUtils.isEmpty(stockOutOrder.getDeclareCustoms())) errorMsg.append("申报地关区不能为空; ");
@@ -34,7 +34,12 @@ public class HeaderListener extends AnalysisEventListener<Map<Integer, Object>>
// 将Map转换为List再转为数组 // 将Map转换为List再转为数组
List<String> dataList = mapToList(stringData); List<String> dataList = mapToList(stringData);
Object[] rowData = listToArray(dataList); Object[] rowData = listToArray(dataList);
String stringValue1 = getStringValue(rowData[0]);
if (stringValue1 != null && !stringValue1.isEmpty()) {
if ("备注:".equals(stringValue1)) {
stockOutOrder.setRemark(getStringValue(rowData[1]));
}
}
// 根据行号提取对应信息 // 根据行号提取对应信息
switch (rowNum) { switch (rowNum) {
case 4: // 第5行to仓库联系人车型及车牌委托编码 case 4: // 第5行to仓库联系人车型及车牌委托编码
@@ -37,6 +37,8 @@ public interface StockOutOrderMapper extends BaseMapper<StockOutOrder> {
public String getUserNcCode(@Param("id") Long id); public String getUserNcCode(@Param("id") Long id);
public String getSettlementCurrency(@Param("id") Long id);
public Long getKcId(@Param("lotNo") String lotNo); public Long getKcId(@Param("lotNo") String lotNo);
public String getInOrderNumber(@Param("id") Long id); public String getInOrderNumber(@Param("id") Long id);
@@ -194,4 +194,13 @@ public class MaterialInventoryDTO extends MaterialBaseDTO {
private String productionDateStr; private String productionDateStr;
private String updateTimeStr; private String updateTimeStr;
private String expiryDateStart;
private String expiryDateEnd;
private String productionDateStart;
private String productionDateEnd;
private String updateTimeStart;
private String updateTimeEnd;
} }
@@ -99,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.common, b.common,
b.pack_id, b.pack_id,
b.pack_code, b.pack_code,
b.SPECIFICATION_MODEL,
b.pack_name b.pack_name
</sql> </sql>
@@ -64,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="barCode" column="inv_bar_code" /> <result property="barCode" column="inv_bar_code" />
<result property="inOrderNumber" column="in_order_number" /> <result property="inOrderNumber" column="in_order_number" />
<result property="lotNumber" column="lot_number" /> <result property="lotNumber" column="lot_number" />
<result property="specificationModel" column="specification_model" />
</resultMap> </resultMap>
@@ -241,6 +242,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTimeStr != null and updateTimeStr != ''"> <if test="updateTimeStr != null and updateTimeStr != ''">
AND TO_CHAR(a.update_time, 'yyyy-MM-dd') = #{updateTimeStr} AND TO_CHAR(a.update_time, 'yyyy-MM-dd') = #{updateTimeStr}
</if> </if>
<if test="updateTimeStart != null and updateTimeStart != ''">
and a.update_time >= #{updateTimeStart}
</if>
<if test="updateTimeEnd != null and updateTimeEnd != ''">
and a.update_time <![CDATA[ < ]]> DATEADD(DAY, 1, #{updateTimeEnd})
</if>
<if test="productionDateStart != null and productionDateStart != ''">
and a.production_date >= #{productionDateStart}
</if>
<if test="productionDateEnd != null and productionDateEnd != ''">
and a.production_date <![CDATA[ < ]]> DATEADD(DAY, 1, #{productionDateEnd})
</if>
<if test="expiryDateStart != null and expiryDateStart != ''">
and a.expiry_date >= #{expiryDateStart}
</if>
<if test="expiryDateEnd != null and expiryDateEnd != ''">
and a.expiry_date <![CDATA[ < ]]> DATEADD(DAY, 1, #{expiryDateEnd})
</if>
</sql> </sql>
<!-- 与 selectMaterialInventoryPo1 相同条件,表别名为 mi(用于 queryListByWl 最新明细子查询) --> <!-- 与 selectMaterialInventoryPo1 相同条件,表别名为 mi(用于 queryListByWl 最新明细子查询) -->
@@ -38,6 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="pushBy" column="push_by" /> <result property="pushBy" column="push_by" />
<result property="pushByName" column="push_by_name" /> <result property="pushByName" column="push_by_name" />
<result property="goodsType" column="goods_type" /> <result property="goodsType" column="goods_type" />
<result property="outOrderId" column="out_order_id" />
</resultMap> </resultMap>
@@ -45,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.picking_order_id, a.organization_id, a.organization_name, a.top_organization_id, a.order_number, a.picking_order_number, a.picking_order_id, a.organization_id, a.organization_name, a.top_organization_id, a.order_number, a.picking_order_number,
a.status, a.type, a.warehouse_id, a.warehouse_code, a.warehouse_name, a.shipper_id, a.shipper_name, a.quantity, a.weight_limit, a.volume_limit, a.material_quantity, a.status, a.type, a.warehouse_id, a.warehouse_code, a.warehouse_name, a.shipper_id, a.shipper_name, a.quantity, a.weight_limit, a.volume_limit, a.material_quantity,
IFNULL((SELECT SUM(b.picking_quantity) FROM picking_material_detail b WHERE b.picking_order_number = a.picking_order_number AND b.del_flag = 1), 0) AS picking_quantity, IFNULL((SELECT SUM(b.picking_quantity) FROM picking_material_detail b WHERE b.picking_order_number = a.picking_order_number AND b.del_flag = 1), 0) AS picking_quantity,
a.picking_material_quantity, a.abnormal, a.task_distribution, a.remark, a.create_time, a.create_by, a.create_by_name, a.update_time, a.picking_material_quantity, a.abnormal, a.task_distribution, a.remark, a.create_time, a.create_by, a.create_by_name, a.update_time,b.out_order_id,
a.update_by, a.update_by_name, a.del_flag,a.out_order_number, a.business_order_no, a.order_type_code, a.order_type_name, a.priority_level_code, a.priority_level_name a.update_by, a.update_by_name, a.del_flag,a.out_order_number, a.business_order_no, a.order_type_code, a.order_type_name, a.priority_level_code, a.priority_level_name
,a.push_status,a.push_time,a.push_by,a.push_by_name, ,a.push_status,a.push_time,a.push_by,a.push_by_name,
(SELECT m.goods_type FROM PICKING_MATERIAL_DETAIL d (SELECT m.goods_type FROM PICKING_MATERIAL_DETAIL d
@@ -144,7 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectPickingOrderPo"/> <include refid="selectPickingOrderPo"/>
,b.need_Declare_Flag ,b.need_Declare_Flag
from picking_order a from picking_order a
left join STOCK_OUT_ORDER b ON a.order_number = b.out_Order_number and b.del_flag = 1 and a.del_flag = 1 left join STOCK_OUT_ORDER b ON a.order_number = b.out_order_number and b.del_flag = 1 and a.del_flag = 1
<where> <where>
<include refid="selectPickingOrderPo1"/> <include refid="selectPickingOrderPo1"/>
</where> </where>
@@ -84,198 +84,284 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="erpCurrGw" column="erp_curr_gw" /> <result property="erpCurrGw" column="erp_curr_gw" />
<result property="erpPriceGw" column="erp_price_gw" /> <result property="erpPriceGw" column="erp_price_gw" />
<result property="amountGw" column="amount_gw" /> <result property="amountGw" column="amount_gw" />
<result property="specificationModel" column="SPECIFICATION_MODEL" />
</resultMap> </resultMap>
<sql id="selectShelfMaterialDetailPo"> <sql id="selectShelfMaterialDetailPo">
select material_detail_id, organization_id, organization_name, top_organization_id, unique_id, shelf_order_number, material_base_info_id, material_code, material_name, bar_code, dimensions, quantity, already_shelves_quantity, shelves_quantity, shelves_status, pack_id, pack_code, pack_name, OMS_IN_MATERIAL_DETAIL, select a.material_detail_id,
CASE a.organization_id,
WHEN pack_detail_id IS NULL OR TRIM(pack_detail_id) = '' THEN NULL a.organization_name,
ELSE CAST(pack_detail_id AS BIGINT) a.top_organization_id,
END as pack_detail_id, unit_code, a.unique_id,
line_num_gw, a.shelf_order_number,
spec_gw, a.material_base_info_id,
unit_gw, a.material_code,
qty_gw, a.material_name,
erp_curr_gw, a.bar_code,
erp_price_gw, a.dimensions,
amount_gw, a.quantity,
in_order_number_gw, a.already_shelves_quantity,
in_line_num_gw, a.shelves_quantity,
unit_name, unit_number, material_warehouse_control_id, serial_number_manage, quality_inspection_manage, quality_inspection_stage, quality_inspection_rule, quality_inspection_ratio, quality_inspection_term, quality_inspection_results, allow_overcharge, overcharge_ratio, batch_number, material_status_code, material_status_name, distribute_rule_id, distribute_rule_code, distribute_rule_name, container_id, container_code, container_type, container_type_name, warehouse_id, warehouse_code, warehouse_name, storage_section_id, storage_code, storage_name, storage_location_id, storage_location_code, storage_location_name, level, parent_unique_id, in_unique_id, receipt_unique_id, allow_modify, remark, batch_ref_no, sheet_ref_no, box_pallet_no, ext_attr_1, ext_attr_2, production_date, expiry_date, inventory_date, ext_attr_3, ext_attr_4, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag,total_net_weight,total_gross_weight,total_volume,total_area,in_order_number,lot_number,pallet_number,copy_batch,copy_quantity,copy_details from shelf_material_detail a.shelves_status,
a.pack_id,
a.pack_code,
a.pack_name,
a.OMS_IN_MATERIAL_DETAIL,
CASE
WHEN a.pack_detail_id IS NULL OR TRIM(a.pack_detail_id) = '' THEN NULL
ELSE CAST(a.pack_detail_id AS BIGINT)
END as pack_detail_id,
a.unit_code,
a.line_num_gw,
a.spec_gw,
a.unit_gw,
a.qty_gw,
a.erp_curr_gw,
a.erp_price_gw,
a.amount_gw,
a.in_order_number_gw,
a.in_line_num_gw,
a.unit_name,
a.unit_number,
a.material_warehouse_control_id,
a.serial_number_manage,
a.quality_inspection_manage,
a.quality_inspection_stage,
a.quality_inspection_rule,
a.quality_inspection_ratio,
a.quality_inspection_term,
a.quality_inspection_results,
a.allow_overcharge,
a.overcharge_ratio,
a.batch_number,
a.material_status_code,
a.material_status_name,
a.distribute_rule_id,
a.distribute_rule_code,
a.distribute_rule_name,
a.container_id,
a.container_code,
a.container_type,
a.container_type_name,
a.warehouse_id,
a.warehouse_code,
a.warehouse_name,
a.storage_section_id,
a.storage_code,
a.storage_name,
a.storage_location_id,
a.storage_location_code,
a.storage_location_name,
a.level,
a.parent_unique_id,
a.in_unique_id,
a.receipt_unique_id,
a.allow_modify,
a.remark,
a.batch_ref_no,
a.sheet_ref_no,
a.box_pallet_no,
a.ext_attr_1,
a.ext_attr_2,
a.production_date,
a.expiry_date,
a.inventory_date,
a.ext_attr_3,
a.ext_attr_4,
a.create_time,
a.create_by,
a.create_by_name,
a.update_time,
a.update_by,
a.update_by_name,
a.del_flag,
a.total_net_weight,
a.total_gross_weight,
a.total_volume,
a.total_area,
a.in_order_number,
a.lot_number,
a.pallet_number,
a.copy_batch,
a.copy_quantity,
a.copy_details,
c.SPECIFICATION_MODEL
from shelf_material_detail a
LEFT JOIN MATERIAL_BASE_INFO c ON a.MATERIAL_BASE_INFO_ID = c.MATERIAL_BASE_INFO_ID AND c.DEL_FLAG = 1
</sql> </sql>
<sql id="selectShelfMaterialDetailPo1"> <sql id="selectShelfMaterialDetailPo1">
<where> <where>
<if test="organizationId != null "> <if test="organizationId != null ">
and organization_id = #{organizationId} and a.organization_id = #{organizationId}
</if> </if>
<if test="organizationName != null and organizationName != ''"> <if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%') and a.organization_name like concat('%', #{organizationName}, '%')
</if> </if>
<if test="topOrganizationId != null "> <if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId} and a.top_organization_id = #{topOrganizationId}
</if> </if>
<if test="uniqueId != null "> <if test="uniqueId != null ">
and unique_id = #{uniqueId} and a.unique_id = #{uniqueId}
</if> </if>
<if test="shelfOrderNumber != null and shelfOrderNumber != ''"> <if test="shelfOrderNumber != null and shelfOrderNumber != ''">
and shelf_order_number = #{shelfOrderNumber} and a.shelf_order_number = #{shelfOrderNumber}
</if> </if>
<if test="materialBaseInfoId != null "> <if test="materialBaseInfoId != null ">
and material_base_info_id = #{materialBaseInfoId} and a.material_base_info_id = #{materialBaseInfoId}
</if> </if>
<if test="materialCode != null and materialCode != ''"> <if test="materialCode != null and materialCode != ''">
and material_code = #{materialCode} and a.material_code = #{materialCode}
</if> </if>
<if test="materialName != null and materialName != ''"> <if test="materialName != null and materialName != ''">
and material_name like concat('%', #{materialName}, '%') and a.material_name like concat('%', #{materialName}, '%')
</if> </if>
<if test="barCode != null and barCode != ''"> <if test="barCode != null and barCode != ''">
and bar_code = #{barCode} and a.bar_code = #{barCode}
</if> </if>
<if test="quantity != null "> <if test="quantity != null ">
and quantity = #{quantity} and a.quantity = #{quantity}
</if> </if>
<if test="shelvesQuantity != null "> <if test="shelvesQuantity != null ">
and shelves_quantity = #{shelvesQuantity} and a.shelves_quantity = #{shelvesQuantity}
</if> </if>
<if test="alreadyShelvesQuantity != null "> <if test="alreadyShelvesQuantity != null ">
and already_shelves_quantity = #{alreadyShelvesQuantity} and a.already_shelves_quantity = #{alreadyShelvesQuantity}
</if> </if>
<if test="shelvesStatus != null "> <if test="shelvesStatus != null ">
and shelves_status = #{shelvesStatus} and a.shelves_status = #{shelvesStatus}
</if> </if>
<if test="packId != null "> <if test="packId != null ">
and pack_id = #{packId} and a.pack_id = #{packId}
</if> </if>
<if test="packCode != null and packCode != ''"> <if test="packCode != null and packCode != ''">
and pack_code = #{packCode} and a.pack_code = #{packCode}
</if> </if>
<if test="packName != null and packName != ''"> <if test="packName != null and packName != ''">
and pack_name like concat('%', #{packName}, '%') and a.pack_name like concat('%', #{packName}, '%')
</if> </if>
<if test="packDetailId != null and packDetailId != ''"> <if test="packDetailId != null and packDetailId != ''">
and pack_detail_id = #{packDetailId} and a.pack_detail_id = #{packDetailId}
</if> </if>
<if test="unitCode != null and unitCode != ''"> <if test="unitCode != null and unitCode != ''">
and unit_code = #{unitCode} and a.unit_code = #{unitCode}
</if> </if>
<if test="unitName != null and unitName != ''"> <if test="unitName != null and unitName != ''">
and unit_name like concat('%', #{unitName}, '%') and a.unit_name like concat('%', #{unitName}, '%')
</if> </if>
<if test="unitNumber != null "> <if test="unitNumber != null ">
and unit_number = #{unitNumber} and a.unit_number = #{unitNumber}
</if> </if>
<if test="materialWarehouseControlId != null "> <if test="materialWarehouseControlId != null ">
and material_warehouse_control_id = #{materialWarehouseControlId} and a.material_warehouse_control_id = #{materialWarehouseControlId}
</if> </if>
<if test="serialNumberManage != null "> <if test="serialNumberManage != null ">
and serial_number_manage = #{serialNumberManage} and a.serial_number_manage = #{serialNumberManage}
</if> </if>
<if test="qualityInspectionManage != null "> <if test="qualityInspectionManage != null ">
and quality_inspection_manage = #{qualityInspectionManage} and a.quality_inspection_manage = #{qualityInspectionManage}
</if> </if>
<if test="qualityInspectionStage != null "> <if test="qualityInspectionStage != null ">
and quality_inspection_stage = #{qualityInspectionStage} and a.quality_inspection_stage = #{qualityInspectionStage}
</if> </if>
<if test="qualityInspectionRule != null "> <if test="qualityInspectionRule != null ">
and quality_inspection_rule = #{qualityInspectionRule} and a.quality_inspection_rule = #{qualityInspectionRule}
</if> </if>
<if test="qualityInspectionRatio != null "> <if test="qualityInspectionRatio != null ">
and quality_inspection_ratio = #{qualityInspectionRatio} and a.quality_inspection_ratio = #{qualityInspectionRatio}
</if> </if>
<if test="qualityInspectionTerm != null "> <if test="qualityInspectionTerm != null ">
and quality_inspection_term = #{qualityInspectionTerm} and a.quality_inspection_term = #{qualityInspectionTerm}
</if> </if>
<if test="qualityInspectionResults != null "> <if test="qualityInspectionResults != null ">
and quality_inspection_results = #{qualityInspectionResults} and a.quality_inspection_results = #{qualityInspectionResults}
</if> </if>
<if test="allowOvercharge != null "> <if test="allowOvercharge != null ">
and allow_overcharge = #{allowOvercharge} and a.allow_overcharge = #{allowOvercharge}
</if> </if>
<if test="overchargeRatio != null "> <if test="overchargeRatio != null ">
and overcharge_ratio = #{overchargeRatio} and a.overcharge_ratio = #{overchargeRatio}
</if> </if>
<if test="batchNumber != null and batchNumber != ''"> <if test="batchNumber != null and batchNumber != ''">
and batch_number = #{batchNumber} and a.batch_number = #{batchNumber}
</if> </if>
<if test="lotNumber != null and lotNumber != ''"> <if test="lotNumber != null and lotNumber != ''">
and lot_number = #{lotNumber} and a.lot_number = #{lotNumber}
</if> </if>
<if test="palletNumber != null and palletNumber != ''"> <if test="palletNumber != null and palletNumber != ''">
and pallet_number like concat('%', #{palletNumber}, '%') and a.pallet_number like concat('%', #{palletNumber}, '%')
</if> </if>
<if test="materialStatusCode != null and materialStatusCode != ''"> <if test="materialStatusCode != null and materialStatusCode != ''">
and material_status_code = #{materialStatusCode} and a.material_status_code = #{materialStatusCode}
</if> </if>
<if test="materialStatusName != null and materialStatusName != ''"> <if test="materialStatusName != null and materialStatusName != ''">
and material_status_name like concat('%', #{materialStatusName}, '%') and a.material_status_name like concat('%', #{materialStatusName}, '%')
</if> </if>
<if test="distributeRuleId != null "> <if test="distributeRuleId != null ">
and distribute_rule_id = #{distributeRuleId} and a.distribute_rule_id = #{distributeRuleId}
</if> </if>
<if test="distributeRuleCode != null and distributeRuleCode != ''"> <if test="distributeRuleCode != null and distributeRuleCode != ''">
and distribute_rule_code = #{distributeRuleCode} and a.distribute_rule_code = #{distributeRuleCode}
</if> </if>
<if test="distributeRuleName != null and distributeRuleName != ''"> <if test="distributeRuleName != null and distributeRuleName != ''">
and distribute_rule_name like concat('%', #{distributeRuleName}, '%') and a.distribute_rule_name like concat('%', #{distributeRuleName}, '%')
</if> </if>
<if test="containerId != null "> <if test="containerId != null ">
and container_id = #{containerId} and a.container_id = #{containerId}
</if> </if>
<if test="containerCode != null and containerCode != ''"> <if test="containerCode != null and containerCode != ''">
and container_code = #{containerCode} and a.container_code = #{containerCode}
</if> </if>
<if test="containerType != null and containerType != ''"> <if test="containerType != null and containerType != ''">
and container_type = #{containerType} and a.container_type = #{containerType}
</if> </if>
<if test="containerTypeName != null and containerTypeName != ''"> <if test="containerTypeName != null and containerTypeName != ''">
and container_type_name like concat('%', #{containerTypeName}, '%') and a.container_type_name like concat('%', #{containerTypeName}, '%')
</if> </if>
<if test="warehouseId != null "> <if test="warehouseId != null ">
and warehouse_id = #{warehouseId} and a.warehouse_id = #{warehouseId}
</if> </if>
<if test="warehouseCode != null and warehouseCode != ''"> <if test="warehouseCode != null and warehouseCode != ''">
and warehouse_code = #{warehouseCode} and a.warehouse_code = #{warehouseCode}
</if> </if>
<if test="warehouseName != null and warehouseName != ''"> <if test="warehouseName != null and warehouseName != ''">
and warehouse_name like concat('%', #{warehouseName}, '%') and a.warehouse_name like concat('%', #{warehouseName}, '%')
</if> </if>
<if test="storageSectionId != null "> <if test="storageSectionId != null ">
and storage_section_id = #{storageSectionId} and a.storage_section_id = #{storageSectionId}
</if> </if>
<if test="storageCode != null and storageCode != ''"> <if test="storageCode != null and storageCode != ''">
and storage_code = #{storageCode} and a.storage_code = #{storageCode}
</if> </if>
<if test="storageName != null and storageName != ''"> <if test="storageName != null and storageName != ''">
and storage_name like concat('%', #{storageName}, '%') and a.storage_name like concat('%', #{storageName}, '%')
</if> </if>
<if test="storageLocationId != null "> <if test="storageLocationId != null ">
and storage_location_id = #{storageLocationId} and a.storage_location_id = #{storageLocationId}
</if> </if>
<if test="storageLocationCode != null and storageLocationCode != ''"> <if test="storageLocationCode != null and storageLocationCode != ''">
and storage_location_code = #{storageLocationCode} and a.storage_location_code = #{storageLocationCode}
</if> </if>
<if test="storageLocationName != null and storageLocationName != ''"> <if test="storageLocationName != null and storageLocationName != ''">
and storage_location_name like concat('%', #{storageLocationName}, '%') and a.storage_location_name like concat('%', #{storageLocationName}, '%')
</if> </if>
<if test="level != null "> <if test="level != null ">
and level = #{level} and a.level = #{level}
</if> </if>
<if test="parentUniqueId != null "> <if test="parentUniqueId != null ">
and parent_unique_id = #{parentUniqueId} and a.parent_unique_id = #{parentUniqueId}
</if> </if>
<if test="createByName != null and createByName != ''"> <if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%') and a.create_by_name like concat('%', #{createByName}, '%')
</if> </if>
<if test="updateByName != null and updateByName != ''"> <if test="updateByName != null and updateByName != ''">
and update_by_name like concat('%', #{updateByName}, '%') and a.update_by_name like concat('%', #{updateByName}, '%')
</if> </if>
<choose> <choose>
<when test="delFlag != null"> and del_flag = #{delFlag} </when> <when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and del_flag = 1 </otherwise> <otherwise> and a.del_flag = 1 </otherwise>
</choose> </choose>
</where> </where>
</sql> </sql>
@@ -480,6 +480,10 @@
<select id="getUserNcCode" parameterType="java.lang.Long" resultType="java.lang.String"> <select id="getUserNcCode" parameterType="java.lang.Long" resultType="java.lang.String">
select CUSTOMER_NC_CODE from "NGWL_TEST_USER".USER_SHIPPER where 1 = 1 and DEL_FLAG = 1 and USER_ID = #{id} limit 1 select CUSTOMER_NC_CODE from "NGWL_TEST_USER".USER_SHIPPER where 1 = 1 and DEL_FLAG = 1 and USER_ID = #{id} limit 1
</select> </select>
<select id="getSettlementCurrency" parameterType="java.lang.Long" resultType="java.lang.String">
select SETTLEMENT_CURRENCY from "NGWL_TEST_USER".USER_SHIPPER where 1 = 1 and DEL_FLAG = 1 and USER_ID = #{id} limit 1
</select>
<select id="getKcId" parameterType="java.lang.String" resultType="java.lang.Long"> <select id="getKcId" parameterType="java.lang.String" resultType="java.lang.Long">
select MATERIAL_INVENTORY_ID from "NGWL_TEST_WMS".OUT_MATERIAL_DETAIL where lot_no = #{lotNo} select MATERIAL_INVENTORY_ID from "NGWL_TEST_WMS".OUT_MATERIAL_DETAIL where lot_no = #{lotNo}
</select> </select>