From 6b004099d32bd39dd36660842266a3b4e90e71a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=91=E6=98=8E=E6=A2=81?= <2429105222@qq.com>
Date: Thu, 1 Jun 2023 17:59:46 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=8D=95=E6=8D=AE=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 6 ++
.../controller/basic/UdiSyncController.java | 74 +++++++++++++++
.../purchase/IoPurChangeService.java | 89 ++++++++++---------
.../api/entity/basic/BasicProductsEntity.java | 4 +
.../basic/CompanyProductRelevanceRequest.java | 3 +
.../mybatis/mapper/basic/UdiRlSupDao.xml | 10 ++-
6 files changed, 143 insertions(+), 43 deletions(-)
diff --git a/pom.xml b/pom.xml
index b991aa14..caecc425 100644
--- a/pom.xml
+++ b/pom.xml
@@ -277,6 +277,12 @@
jasperreports-fonts
6.0.0
+
+
+
+ com.belerweb
+ pinyin4j
+ 2.5.1
diff --git a/src/main/java/com/glxp/api/controller/basic/UdiSyncController.java b/src/main/java/com/glxp/api/controller/basic/UdiSyncController.java
index 620d440b..cb08b1e6 100644
--- a/src/main/java/com/glxp/api/controller/basic/UdiSyncController.java
+++ b/src/main/java/com/glxp/api/controller/basic/UdiSyncController.java
@@ -7,6 +7,8 @@ import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.AsyncDiDlHelper;
+import com.glxp.api.dao.basic.BasicProductsDao;
+import com.glxp.api.dao.basic.UdiProductDao;
import com.glxp.api.entity.basic.*;
import com.glxp.api.req.basic.*;
import com.glxp.api.http.sync.SpGetHttpClient;
@@ -16,6 +18,11 @@ import com.glxp.api.service.basic.*;
import com.glxp.api.util.OkHttpCli;
import com.glxp.api.util.udi.FilterUdiUtils;
import lombok.extern.slf4j.Slf4j;
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -23,6 +30,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* 国家库产品信息相关接口
@@ -43,6 +52,9 @@ public class UdiSyncController {
ProductInfoService productInfoService;
@Resource
UdiCompanyService udiCompanyService;
+ @Resource
+ BasicProductsDao basicProductsDao;
+
//获取同步库UDI信息
@@ -183,5 +195,67 @@ public class UdiSyncController {
return ResultVOUtils.success(udiCompanyEntities);
}
+
+
+
+ @GetMapping("udiwms/test")
+ public void filterUdi() {
+ FilterUdiRelRequest filterUdiRelRequest=new FilterUdiRelRequest();
+ List data = basicProductsDao.selectList();
+ int i=0;
+ try {
+ for (BasicProductsEntity datum : data) {
+ if(StrUtil.isNotEmpty(datum.getCpmctymc()) && StrUtil.isEmpty(datum.getPinyinInitial()) && !datum.getCpmctymc().substring(0,1).equals("α")){
+ i++;
+ String a=datum.getCpmctymc().substring(0,1);
+ datum.setPinyinInitial(converterToFirstSpell(datum.getCpmctymc()));
+ System.out.println("-----------------------------------------------------"+i);
+ }
+ }
+ }catch (Exception e){
+ System.out.println("|||||||||||||||||||||||"+e.getMessage());
+ }
+ basicProductsDao.updateBatchById(data);
+ }
+
+ //汉字转换位汉语拼音首字母,英文字符不变
+ public static String converterToFirstSpell(String chines) {
+ chines = cleanChar(chines);
+ String pinyinName = "";
+ char[] nameChar = chines.toCharArray();
+ HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
+ defaultFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE);
+ defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+ for (int i = 0; i < nameChar.length; i++) {
+ if (nameChar[i] > 128) {
+ try {
+ pinyinName += PinyinHelper.toHanyuPinyinStringArray(nameChar[i], defaultFormat)[0].charAt(0);
+ } catch (BadHanyuPinyinOutputFormatCombination e) {
+ e.printStackTrace();
+ }
+ } else {
+ pinyinName += nameChar[i];
+ }
+ }
+ return pinyinName;
+ }
+
+ /**
+ * 清理特殊字符以便得到
+ * @param chines
+ * @return
+ */
+ public static String cleanChar(String chines) {
+ chines = chines.replaceAll("[\\p{Punct}\\p{Space}]+", ""); // 正则去掉所有字符操作
+ // 正则表达式去掉所有中文的特殊符号
+ String regEx = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}<>《》【】‘;:”“’。,、?ⅢγⅣβⅡⅠ×π]";
+ Pattern pattern = Pattern.compile(regEx);
+ Matcher matcher = pattern.matcher(chines);
+ chines = matcher.replaceAll("").trim();
+ return chines;
+ }
+
+
+
}
diff --git a/src/main/java/com/glxp/api/controller/purchase/IoPurChangeService.java b/src/main/java/com/glxp/api/controller/purchase/IoPurChangeService.java
index 6be65a21..630a7d23 100644
--- a/src/main/java/com/glxp/api/controller/purchase/IoPurChangeService.java
+++ b/src/main/java/com/glxp/api/controller/purchase/IoPurChangeService.java
@@ -139,7 +139,7 @@ public class IoPurChangeService {
if (basicBusTypeChangeEntity.getBusBeforeTime() != null) {
purPlanEntity.setCreateTime(DateUtil.timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
purPlanEntity.setUpdateTime(DateUtil.timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
- }else{
+ } else {
purPlanEntity.setCreateTime(purApplyEntity.getCreateTime());
purPlanEntity.setUpdateUser(purApplyEntity.getAuditUser());
}
@@ -182,59 +182,66 @@ public class IoPurChangeService {
public void purPlanChange(PurPlanEntity purPlanEntity) {
BasicBusTypeChangeEntity basicBusTypeChangeEntity;
-
+ String billNos = null;
//---------------------------------判断计划为已审核就生成计划单-------------------------------------------//\
- PurOrderEntity purOrderEntity = new PurOrderEntity();
if (purPlanEntity.getStatus() == 3) {
//查询计划详情
List purPlanDetailEntityList = purPlanDetailService.findByOrderId(purPlanEntity.getId() + "");
+ //根据供应商分组
+ Map> purPlanDetailMap = purPlanDetailEntityList.stream().collect(Collectors.groupingBy(PurPlanDetailEntity::getSupId));
basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction("CGJH");
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
- purOrderEntity.setBillNo(gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.CG_ORDER, "yyyyMMdd")));
- purOrderEntity.setBillDate(purPlanEntity.getBillDate());
- purOrderEntity.setStatus(basicBusTypeChangeEntity.getBusAuditStatus());
- purOrderEntity.setRemark(purPlanEntity.getRemark());
- purOrderEntity.setEmergency(purPlanEntity.getEmergency());
- purOrderEntity.setArrivalTime(purPlanEntity.getArrivalTime());
- purOrderEntity.setInvCode(purPlanEntity.getInvCode());
- purOrderEntity.setDeptCode(purPlanEntity.getDeptCode());
- purOrderEntity.setCreateUser(purPlanEntity.getAuditUser());
- purOrderEntity.setUpdateUser(purPlanEntity.getAuditUser());
- if (basicBusTypeChangeEntity.getBusBeforeTime() != null) {
- purPlanEntity.setCreateTime(DateUtil.timeProcess(purOrderEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
- purPlanEntity.setUpdateTime(DateUtil.timeProcess(purOrderEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
- }else{
- purPlanEntity.setCreateTime(purOrderEntity.getCreateTime());
- purPlanEntity.setUpdateUser(purOrderEntity.getAuditUser());
- }
- if (purOrderEntity.getStatus() == 3) {
- purOrderEntity.setAuditUser("");
- purOrderEntity.setAuditTime(new Date());
+ for (String key : purPlanDetailMap.keySet()) {
+ PurOrderEntity purOrderEntity = new PurOrderEntity();
+ List purPlanDetailEntitys = purPlanDetailMap.get(key);
+ purOrderEntity.setBillNo(gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.CG_ORDER, "yyyyMMdd")));
+ purOrderEntity.setBillDate(purPlanEntity.getBillDate());
+ purOrderEntity.setSupId(key);
+ purOrderEntity.setStatus(basicBusTypeChangeEntity.getBusAuditStatus());
+ purOrderEntity.setRemark(purPlanEntity.getRemark());
+ purOrderEntity.setEmergency(purPlanEntity.getEmergency());
+ purOrderEntity.setArrivalTime(purPlanEntity.getArrivalTime());
+ purOrderEntity.setInvCode(purPlanEntity.getInvCode());
+ purOrderEntity.setDeptCode(purPlanEntity.getDeptCode());
+ purOrderEntity.setCreateUser(purPlanEntity.getAuditUser());
+ purOrderEntity.setUpdateUser(purPlanEntity.getAuditUser());
+ if (basicBusTypeChangeEntity.getBusBeforeTime() != null) {
+ purOrderEntity.setCreateTime(DateUtil.timeProcess(new Date(), basicBusTypeChangeEntity.getBusBeforeTime()));
+ purOrderEntity.setUpdateTime(DateUtil.timeProcess(new Date(), basicBusTypeChangeEntity.getBusBeforeTime()));
+ } else {
+ purOrderEntity.setCreateTime(new Date());
+ purOrderEntity.setUpdateTime(new Date());
+ }
+ if (purOrderEntity.getStatus() == 3) {
+ purOrderEntity.setAuditUser("");
+ purOrderEntity.setAuditTime(new Date());
+ }
+ //插入订单主表
+ purOrderService.insert(purOrderEntity);
+ //用stream流复制list
+ List purOrderDetailEntityList = purPlanDetailEntitys.stream().map(e -> {
+ PurOrderDetailEntity d = new PurOrderDetailEntity();
+ d.setOrderIdFk(purOrderEntity.getId() + "");
+ d.setProductId(e.getProductId());
+ d.setProductName(e.getProductName());
+ d.setCount(e.getCount());
+ d.setSupId(e.getSupId());
+ d.setZczbhhzbapzbh(e.getZczbhhzbapzbh());
+ return d;
+ }).collect(Collectors.toList());
+ purOrderDetailService.insertPurOrderDetailEntity(purOrderDetailEntityList);
+ billNos = "," + billNos + purPlanEntity.getBillNo();
}
- //插入订单主表
- purOrderService.insert(purOrderEntity);
- //用stream流复制list
- List purOrderDetailEntityList = purPlanDetailEntityList.stream().map(e -> {
- PurOrderDetailEntity d = new PurOrderDetailEntity();
- d.setOrderIdFk(purOrderEntity.getId() + "");
- d.setProductId(e.getProductId());
- d.setProductName(e.getProductName());
- d.setCount(e.getCount());
- d.setSupId(e.getSupId());
- d.setZczbhhzbapzbh(e.getZczbhhzbapzbh());
- return d;
- }).collect(Collectors.toList());
- purOrderDetailService.insertPurOrderDetailEntity(purOrderDetailEntityList);
// 更新计划表信息插入订单单号
PurPlanEntity purPlanEntity1 = new PurPlanEntity();
purPlanEntity1.setId(purPlanEntity.getId());
- purPlanEntity1.setStockOrderNo(purOrderEntity.getBillNo());
+ purPlanEntity1.setStockOrderNo(billNos.substring(0));
// purPlanEntity.sets(true);
purPlanService.update(purPlanEntity1);
}
- if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
- purPlanGen(purPlanEntity);
- }
+// if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
+// purPlanGen(purPlanEntity);
+// }
}
}
diff --git a/src/main/java/com/glxp/api/entity/basic/BasicProductsEntity.java b/src/main/java/com/glxp/api/entity/basic/BasicProductsEntity.java
index b895b594..9e16f181 100644
--- a/src/main/java/com/glxp/api/entity/basic/BasicProductsEntity.java
+++ b/src/main/java/com/glxp/api/entity/basic/BasicProductsEntity.java
@@ -348,6 +348,10 @@ public class BasicProductsEntity {
@TableField(value = "remark")
private String remark;
+ @TableField(value = "pinyinInitial")
+ private String pinyinInitial;
+
+
public static final String COL_ID = "id";
public static final String COL_UUID = "uuid";
diff --git a/src/main/java/com/glxp/api/req/basic/CompanyProductRelevanceRequest.java b/src/main/java/com/glxp/api/req/basic/CompanyProductRelevanceRequest.java
index c86834d3..660258bb 100644
--- a/src/main/java/com/glxp/api/req/basic/CompanyProductRelevanceRequest.java
+++ b/src/main/java/com/glxp/api/req/basic/CompanyProductRelevanceRequest.java
@@ -35,11 +35,14 @@ public class CompanyProductRelevanceRequest extends ListPageRequest {
private String thrPiId;
+
private Boolean isCheck;
private Integer filterType; //0:全部,1.对照完成,2.未对照DI,3.未对照产品编码,4.未对照其他产品编码
private String customerId;
+ private String pinyinInitial;
+ private String code;
private String auditStatus;
private String companyName;
diff --git a/src/main/resources/mybatis/mapper/basic/UdiRlSupDao.xml b/src/main/resources/mybatis/mapper/basic/UdiRlSupDao.xml
index 3d7c6806..7d42be1e 100644
--- a/src/main/resources/mybatis/mapper/basic/UdiRlSupDao.xml
+++ b/src/main/resources/mybatis/mapper/basic/UdiRlSupDao.xml
@@ -111,6 +111,7 @@
ON basic_udirel.uuid = basic_products.uuid
left JOIN basic_corp on basic_corp.erpId = company_product_relevance.customerId
left join basic_hosp_type bht on basic_udirel.relCode = bht.code
+ left join thr_products tp on tp.code = basic_udirel.mainId
AND ylqxzcrbarmc LIKE concat(#{ylqxzcrbarmc}, '%')
@@ -184,7 +185,12 @@
AND basic_udirel.updateTime is NULL
-
+
+ AND basic_products.pinyinInitial like concat('%', #{pinyinInitial}, '%')
+
+
+ AND basic_udirel.mainId = #{code}
+
AND company_product_relevance.customerId = #{customerId}
@@ -195,7 +201,7 @@
AND basic_udirel.id = #{id}
- AND basic_corp.name = #{companyName}
+ AND basic_corp.name like concat('%', #{companyName}, '%')
AND basic_udirel.lockStatus = #{lockStatus}