Browse Source

可以删除发票号;特殊字符处理

java8
han\hanst 7 months ago
parent
commit
c2ffdc3505
  1. 7
      src/main/java/com/xujie/sys/modules/ecss/controller/CoDelController.java
  2. 2
      src/main/java/com/xujie/sys/modules/ecss/service/CoDelService.java
  3. 45
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java
  4. 34
      src/main/resources/mapper/ecss/CoDelMapper.xml

7
src/main/java/com/xujie/sys/modules/ecss/controller/CoDelController.java

@ -67,8 +67,11 @@ public class CoDelController {
}
@PostMapping("/saveEcssCoDelNotifyByExcel")
public R saveEcssCoDelNotifyByExcel(@RequestParam(value = "file") MultipartFile file, @ModelAttribute EcssCoDelNotifyHeaderData data, HttpServletRequest request){
Map<String, List<String>> resultMap = coDelService.saveEcssCoDelNotifyByExcel(file, data, request);
public R saveEcssCoDelNotifyByExcel(@RequestParam(value = "file") MultipartFile file,
@ModelAttribute EcssCoDelNotifyHeaderData data,
@RequestParam(value = "deletedInvoices", required = false) String deletedInvoices,
HttpServletRequest request){
Map<String, List<String>> resultMap = coDelService.saveEcssCoDelNotifyByExcel(file, data, deletedInvoices, request);
return R.ok().put("resultMap", resultMap);
}

2
src/main/java/com/xujie/sys/modules/ecss/service/CoDelService.java

@ -24,7 +24,7 @@ public interface CoDelService {
PageUtils searchEcssCoDelNotifyHeaderForDanZheng(EcssCoDelNotifyHeaderData data);
List<EcssCoDelNotifyDetailData> searchEcssCoDelNotifyDetail(EcssCoDelNotifyHeaderData data);
List<Map<String, Object>> previewExcel(MultipartFile file, EcssCoDelNotifyHeaderData data);
Map<String, List<String>> saveEcssCoDelNotifyByExcel(MultipartFile file, EcssCoDelNotifyHeaderData data, HttpServletRequest request);
Map<String, List<String>> saveEcssCoDelNotifyByExcel(MultipartFile file, EcssCoDelNotifyHeaderData data, String deletedInvoices, HttpServletRequest request);
void updateEcssDelHeader(EcssCoDelNotifyHeaderData data);

45
src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java

@ -138,7 +138,7 @@ public class CoDelServiceImpl implements CoDelService {
@Override
@Transactional
public Map<String, List<String>> saveEcssCoDelNotifyByExcel(MultipartFile file, EcssCoDelNotifyHeaderData inData, HttpServletRequest request) {
public Map<String, List<String>> saveEcssCoDelNotifyByExcel(MultipartFile file, EcssCoDelNotifyHeaderData inData, String deletedInvoices, HttpServletRequest request) {
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
String site = coDelMapper.getSiteByBu(inData.getBuNo());
List<EcssCoDelNotifyData> excelList = new ArrayList<>();
@ -153,6 +153,24 @@ public class CoDelServiceImpl implements CoDelService {
throw new RuntimeException("导入失败:" + e.getMessage());
}
// 处理删除的发票号
if (deletedInvoices != null && !deletedInvoices.trim().isEmpty()) {
try {
// 解析删除的发票号列表
List<String> deletedInvoiceList = parseDeletedInvoices(deletedInvoices);
if (!deletedInvoiceList.isEmpty()) {
// 过滤掉被删除的发票号
excelList = excelList.stream()
.filter(data -> !deletedInvoiceList.contains(data.getCmcInvoice()))
.collect(Collectors.toList());
log.info("已过滤删除的发票号: {}", deletedInvoiceList);
}
} catch (Exception e) {
log.error("解析删除发票号列表失败: {}", e.getMessage());
throw new RuntimeException("解析删除发票号列表失败:" + e.getMessage());
}
}
// 成功和失败列表
List<String> successList = new ArrayList<>();
List<String> failList = new ArrayList<>();
@ -257,6 +275,9 @@ public class CoDelServiceImpl implements CoDelService {
}
// 获得该行
XSSFRow row = sheet.getRow(j);
if (row.getCell(18) != null && getStringCellValue(row, 18).equals("内销")) {
continue;
}
if (row.getCell(13) == null || StringUtils.isBlank(getStringCellValue(row, 13))) {
continue;
}
@ -2684,4 +2705,26 @@ public class CoDelServiceImpl implements CoDelService {
return coDelMapper.getCustomerTemplateList(params);
}
/**
* 解析删除的发票号列表
* @param deletedInvoices JSON格式的删除发票号字符串
* @return 删除的发票号列表
*/
private List<String> parseDeletedInvoices(String deletedInvoices) {
if (deletedInvoices == null || deletedInvoices.trim().isEmpty()) {
return new ArrayList<>();
}
try {
ObjectMapper objectMapper = new ObjectMapper();
// 解析JSON数组字符串为List<String>
List<String> invoiceList = objectMapper.readValue(deletedInvoices,
objectMapper.getTypeFactory().constructCollectionType(List.class, String.class));
return invoiceList != null ? invoiceList : new ArrayList<>();
} catch (Exception e) {
log.error("解析删除发票号JSON失败: {}, 原始数据: {}", e.getMessage(), deletedInvoices);
throw new RuntimeException("删除发票号数据格式错误");
}
}
}

34
src/main/resources/mapper/ecss/CoDelMapper.xml

@ -168,8 +168,8 @@
<insert id="saveEcssCoDelNotifyHeader" >
insert into ecss_CoDelNotifyHeader(site,bu_no,delNo,ready_date,customer_name,Destination,shipping_mode,erp_flag,notify_status,
remark,createDate,createBy,cmc_invoice,overseasShipper,overseasAddress,cnative,localShipAddress,salesArea)
values(#{site},#{buNo},#{delNo},#{readyDate},#{customerName},#{destination},#{shippingMode},'N',#{notifyStatus},#{remark},GetDate(),
#{createBy},#{cmcInvoice},#{overseasShipper},#{overseasAddress},#{cnative},#{localShipAddress}, #{salesArea})
values(#{site},#{buNo},#{delNo},#{readyDate},#{customerName,jdbcType=NVARCHAR},#{destination,jdbcType=NVARCHAR},#{shippingMode},'N',#{notifyStatus},#{remark,jdbcType=NVARCHAR},GetDate(),
#{createBy},#{cmcInvoice},#{overseasShipper,jdbcType=NVARCHAR},#{overseasAddress,jdbcType=NVARCHAR},#{cnative,jdbcType=NVARCHAR},#{localShipAddress,jdbcType=NVARCHAR}, #{salesArea,jdbcType=NVARCHAR})
</insert>
<insert id="batchSaveEcssCoDelNotifyDetail">
insert into ecss_CoDelNotifyDetail (site,bu_no,delNo,item_no,salesOrder,salesOrder_item_no,customerPO,line,version,
@ -178,10 +178,10 @@
so,upc,remark,pn,surplus_qty,vat,roll,carton,saleslt,manufacturer_name)
values
<foreach collection="list" separator="," item="item">
(#{item.site},#{item.buNo},#{item.delNo},#{item.itemNo,jdbcType=INTEGER},#{item.salesOrder},#{item.salesOrderItemNo},#{item.customerPO},#{item.line},#{item.version},
#{item.status},#{item.family},#{item.partNo},#{item.partDescription},#{item.qty,jdbcType=DECIMAL},#{item.lt,jdbcType=DECIMAL},#{item.cmcComment},#{item.saleType},
#{item.awbBl},#{item.shippingNumber},#{item.forwarderInfo},#{item.currency},#{item.tp,jdbcType=DECIMAL},#{item.ttlAmount,jdbcType=DECIMAL},#{item.sumPrice,jdbcType=DECIMAL},
#{item.so},#{item.upc},#{item.remark},#{item.pn},#{item.qty},#{item.vat},#{item.roll},#{item.carton},#{item.saleslt},#{item.manufacturerName})
(#{item.site},#{item.buNo},#{item.delNo},#{item.itemNo,jdbcType=INTEGER},#{item.salesOrder,jdbcType=NVARCHAR},#{item.salesOrderItemNo},#{item.customerPO,jdbcType=NVARCHAR},#{item.line,jdbcType=NVARCHAR},#{item.version,jdbcType=NVARCHAR},
#{item.status,jdbcType=NVARCHAR},#{item.family,jdbcType=NVARCHAR},#{item.partNo},#{item.partDescription,jdbcType=NVARCHAR},#{item.qty,jdbcType=DECIMAL},#{item.lt,jdbcType=DECIMAL},#{item.cmcComment,jdbcType=NVARCHAR},#{item.saleType,jdbcType=NVARCHAR},
#{item.awbBl,jdbcType=NVARCHAR},#{item.shippingNumber,jdbcType=NVARCHAR},#{item.forwarderInfo,jdbcType=NVARCHAR},#{item.currency,jdbcType=NVARCHAR},#{item.tp,jdbcType=DECIMAL},#{item.ttlAmount,jdbcType=DECIMAL},#{item.sumPrice,jdbcType=DECIMAL},
#{item.so,jdbcType=NVARCHAR},#{item.upc,jdbcType=NVARCHAR},#{item.remark,jdbcType=NVARCHAR},#{item.pn,jdbcType=NVARCHAR},#{item.qty},#{item.vat},#{item.roll},#{item.carton},#{item.saleslt,jdbcType=NVARCHAR},#{item.manufacturerName,jdbcType=NVARCHAR})
</foreach>
</insert>
@ -200,9 +200,9 @@
</select>
<update id="updateEcssDelHeader" >
update ecss_CoDelNotifyHeader set ready_date=#{readyDate,jdbcType=TIMESTAMP} ,customer_name=#{customerName},
Destination=#{destination},shipping_mode=#{shippingMode},
remark=#{remark} ,cmc_invoice=#{cmcInvoice},overseasShipper=#{overseasShipper} ,overseasAddress=#{overseasAddress}
update ecss_CoDelNotifyHeader set ready_date=#{readyDate,jdbcType=TIMESTAMP} ,customer_name=#{customerName,jdbcType=NVARCHAR},
Destination=#{destination,jdbcType=NVARCHAR},shipping_mode=#{shippingMode},
remark=#{remark,jdbcType=NVARCHAR} ,cmc_invoice=#{cmcInvoice},overseasShipper=#{overseasShipper,jdbcType=NVARCHAR} ,overseasAddress=#{overseasAddress,jdbcType=NVARCHAR}
where site=#{site} and delNo=#{delNo}
</update>
@ -554,11 +554,11 @@ create_by,create_date,update_by,update_date
permit_number,cmc_invoice,sales_area,receive_area,shipping_port,exit_port,documents,remark,package_type,package_qty,
gross_weight,net_weight,payment_type,ship_price,premium,other_price,special_relationship_comfirm,price_influence_confirm,
royalty_payments_confirm,create_by,create_date,delNo,overseas_address,box_qty)
values(#{site},#{declarationNo},#{customsOfficeCode},#{inputCode},#{localShipper},#{localShipAddress},#{shipType},#{shipDate},#{submitDate},
#{filingNo},#{overseasShipper},#{shippingMode},#{shippingData},#{deliverNo},#{salesPartner},#{regulatoryMethod},#{dutyStatus},
#{permitNumber},#{cmcInvoice},#{salesArea},#{receiveArea},#{shippingPort},#{exitPort},#{documents},#{remark},#{packageType},#{packageQty,jdbcType=INTEGER},
#{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{paymentType},#{shipPrice,jdbcType=DECIMAL},#{premium,jdbcType=DECIMAL},#{otherPrice,jdbcType=DECIMAL},#{specialRelationshipComfirm},#{priceInfluenceConfirm},
#{royaltyPaymentsConfirm},#{createBy},GETDATE(),#{delNo},#{overseasAddress},#{boxQty})
values(#{site},#{declarationNo},#{customsOfficeCode},#{inputCode},#{localShipper,jdbcType=NVARCHAR},#{localShipAddress,jdbcType=NVARCHAR},#{shipType},#{shipDate},#{submitDate},
#{filingNo},#{overseasShipper,jdbcType=NVARCHAR},#{shippingMode,jdbcType=NVARCHAR},#{shippingData},#{deliverNo},#{salesPartner,jdbcType=NVARCHAR},#{regulatoryMethod,jdbcType=NVARCHAR},#{dutyStatus,jdbcType=NVARCHAR},
#{permitNumber},#{cmcInvoice},#{salesArea,jdbcType=NVARCHAR},#{receiveArea,jdbcType=NVARCHAR},#{shippingPort,jdbcType=NVARCHAR},#{exitPort,jdbcType=NVARCHAR},#{documents,jdbcType=NVARCHAR},#{remark,jdbcType=NVARCHAR},#{packageType,jdbcType=NVARCHAR},#{packageQty,jdbcType=INTEGER},
#{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{paymentType,jdbcType=NVARCHAR},#{shipPrice,jdbcType=DECIMAL},#{premium,jdbcType=DECIMAL},#{otherPrice,jdbcType=DECIMAL},#{specialRelationshipComfirm,jdbcType=NVARCHAR},#{priceInfluenceConfirm,jdbcType=NVARCHAR},
#{royaltyPaymentsConfirm,jdbcType=NVARCHAR},#{createBy},GETDATE(),#{delNo},#{overseasAddress,jdbcType=NVARCHAR},#{boxQty})
</insert>
<insert id="saveEcssDeclarationDetail">
@ -957,7 +957,7 @@ left join ecss_CoDelNotifyHeader noHeader on a.site=noHeader.site and a.delNo=no
insert into ecss_template (customName,site,buNo,name,type,upc,so,origin,palletWeight,material,hsCode,packaging,itemNo,
kgs,shippingMark,boxChange,hsCodeDesc,contractFlag,hsCodeDescType,goodsLabel,hsCodeFlag,shippingMode,CreateBy,CreateDate,
salesMethod,currency,madeArea,sendPort,shipper,voyage,deliveryGoodsDate,shippingDate,fscWeight, remark)
values(#{customName},#{site},#{buNo},#{name},#{type},#{upc},#{so},#{origin},#{palletWeight},#{material},#{hsCode},#{packaging},
values(#{customName,jdbcType=NVARCHAR},#{site},#{buNo},#{name},#{type},#{upc},#{so},#{origin},#{palletWeight},#{material},#{hsCode},#{packaging},
#{itemNo},#{kgs},#{shippingMark},#{boxChange},
#{hsCodeDesc},#{contractFlag},#{hsCodeDescType},#{goodsLabel},#{hsCodeFlag},#{shippingMode},#{createBy},GetDate(),
#{salesMethod},#{currency},#{madeArea},#{sendPort},#{shipper},#{voyage},#{deliveryGoodsDate},#{shippingDate},#{fscWeight},#{remark})
@ -968,7 +968,7 @@ left join ecss_CoDelNotifyHeader noHeader on a.site=noHeader.site and a.delNo=no
palletWeight=#{palletWeight},material=#{material},hsCode=#{hsCode},itemNo=#{itemNo},
packaging=#{packaging},kgs=#{kgs},shippingMark=#{shippingMark},hsCodeDesc=#{hsCodeDesc},
contractFlag=#{contractFlag},hsCodeDescType=#{hsCodeDescType},goodsLabel=#{goodsLabel},hsCodeFlag=#{hsCodeFlag},
shippingMode=#{shippingMode},UpdateDate=GetDate(),UpdateBy=#{updateBy},customName=#{customName},salesMethod= #{salesMethod},
shippingMode=#{shippingMode},UpdateDate=GetDate(),UpdateBy=#{updateBy},customName=#{customName,jdbcType=NVARCHAR},salesMethod= #{salesMethod},
currency= #{currency},madeArea= #{madeArea},sendPort= #{sendPort},shipper= #{shipper},remark= #{remark},
voyage= #{voyage},deliveryGoodsDate= #{deliveryGoodsDate},shippingDate= #{shippingDate},fscWeight=#{fscWeight}
where buNo=#{buNo} and name=#{nameNative}
@ -1039,7 +1039,7 @@ left join ecss_CoDelNotifyHeader noHeader on a.site=noHeader.site and a.delNo=no
</select>
<select id="queryUsersByRoleName" resultType="com.xujie.sys.modules.sys.entity.SysUserEntity">
select u.* from sys_user u
select u.email from sys_user u
LEFT JOIN sys_user_role ur on ur.user_id = u.user_id
LEFT JOIN sys_role r on r.role_id = ur.role_id
where r.role_name = #{roleName} and u.site = #{site}

Loading…
Cancel
Save