From 6ee9d58d62dbbccf95ce809f358ec9f8d088b705 Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期五, 17 十一月 2023 09:16:16 +0800
Subject: [PATCH] Changes15 websocket
---
mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java | 479 ++++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 354 insertions(+), 125 deletions(-)
diff --git a/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java b/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java
index bd34f17..01b4adc 100644
--- a/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java
+++ b/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java
@@ -5,7 +5,6 @@
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.BooleanUtil;
-import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.excel.EasyExcel;
@@ -26,9 +25,9 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chinaztt.ifs.api.feign.IfsFeignClient;
import com.chinaztt.mes.basic.entity.Part;
-import com.chinaztt.mes.basic.entity.Staff;
import com.chinaztt.mes.basic.mapper.PartMapper;
import com.chinaztt.mes.basic.mapper.StaffMapper;
+import com.chinaztt.mes.basic.mapper.UserServiceMapper;
import com.chinaztt.mes.basic.util.RedisUtils;
import com.chinaztt.mes.common.handler.StateMachineHandler;
import com.chinaztt.mes.common.numgen.NumberGenerator;
@@ -37,7 +36,6 @@
import com.chinaztt.mes.common.oa.OAResult;
import com.chinaztt.mes.common.util.StateResult;
import com.chinaztt.mes.common.util.WechatMsgTips;
-import com.chinaztt.mes.common.util.WxCpUtils;
import com.chinaztt.mes.common.wechat.WechatProperty;
import com.chinaztt.mes.plan.dto.*;
import com.chinaztt.mes.plan.entity.*;
@@ -52,6 +50,8 @@
import com.chinaztt.mes.plan.util.CustomerOrderClientConfigure;
import com.chinaztt.mes.plan.util.CustomerOrderUnitWhiteListConfig;
import com.chinaztt.mes.plan.util.CustomerOrderUtil;
+import com.chinaztt.mes.plan.util.FileSaveUtil;
+import com.chinaztt.mes.plan.vo.CustomerOrderVO1;
import com.chinaztt.mes.quality.dto.CustomOrderSyncDTO;
import com.chinaztt.mes.technology.entity.*;
import com.chinaztt.mes.technology.mapper.*;
@@ -83,7 +83,6 @@
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.messaging.Message;
@@ -94,23 +93,22 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
-import org.springframework.util.Assert;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
-import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
/**
* 瀹㈡埛璁㈠崟琛�
@@ -181,6 +179,7 @@
private WechatProperty wechatProperty;
+ private UserServiceMapper userServiceMapper;
private final OssProperties ossProperties;
private final OssTemplate minioTemplate;
@@ -188,6 +187,14 @@
private final static String MO_RETURN_STAFF = "MO_RETURN_STAFF";
private Environment environment;
+
+ private final static String OTC_MAIN_STATUS_CANCEL = "宸插彇娑�";
+
+ private final static String OTC_MAIN_STATUS_TRANSMIT = "宸蹭笅杈�";
+
+ private final static String AFFILIATED_CONTRACT = "涓ぉ娉ㄥ鍘�";
+
+ //private FileSaveUtil fileSaveUtil;
@Override
public void otcDownload(Long id, HttpServletResponse response) {
@@ -213,9 +220,12 @@
@Override
public IPage getCustomerOrderPage(Page page, QueryWrapper<CustomerOrder> planCustomerOrder, String type) {
- IPage iPage = baseMapper.getCustomerOrderPage(page, planCustomerOrder, type);
- return iPage;
+ //ZttUser currentUser = SecurityUtils.getUser();
+ ////鑾峰彇鍛樺伐id
+ //Long staffId = userServiceMapper.selectById(currentUser.getId()).getStaffId();
+ return customerOrderMapper.getCustomerOrderPage(page, planCustomerOrder);
}
+
@Override
public boolean changeMarkPlanned(List<Long> ids, String coState) {
@@ -247,8 +257,9 @@
private void changeAudit(CustomerOrder customerOrder, String isAudit) {
//瀹℃牳鐘舵�� 閫氳繃 璁㈠崟鐘舵�佸緟璁″垝
if (isAudit.equals(AuditStateStringValues.ACCEPTED)) {
+ //TODO: 瑕佸姞闆朵欢id鍙傛暟
Document document = documentMapper.selectById(customerOrder.getTechnologyDocumentId());
- Part part = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getEngChgLevel, "1").eq(Part::getPartNo, customerOrder.getPartNo()));
+ Part part = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getEngChgLevel, "1").eq(Part::getId,customerOrder.getPartId() ));
if (null == part) {
throw new RuntimeException("鏍规嵁闆朵欢缂栧彿 = 銆�" + customerOrder.getPartNo() + "銆慚ES鏈湴鏌ユ棤鍖归厤闆朵欢瀵硅薄");
}
@@ -276,42 +287,17 @@
@Override
- public R fullUpdate(CustomerOrderDTO customerOrderDTO) {
- List<String> unitWhitMapList = customerOrderUnitWhiteListConfig.getUnitWhitListMap();
- String unitConcat = customerOrderDTO.getOtcUnit() + "_" + customerOrderDTO.getIfsSalesUnit();
- if (!customerOrderDTO.getOtcUnit().equals(customerOrderDTO.getIfsSalesUnit()) && !unitWhitMapList.contains(unitConcat)) {
- //濡傛灉閿�鍞崟浣嶅拰ifs涓攢鍞崟浣嶄笉涓�鏍峰垯涓嶇粰淇濆瓨A
- return R.failed("璁㈠崟琛岄攢鍞崟浣嶅拰閿�鍞欢閿�鍞閲忓崟浣嶄笉涓�鑷村苟涓旂櫧鍚嶅崟涓笉瀛樺湪瀵瑰簲鍏崇郴");
- } else {
- if (StringUtils.isNotBlank(customerOrderDTO.getPartNo())) {
- Part part = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, customerOrderDTO.getPartNo()));
- if (null == part) {
- throw new RuntimeException("鏍规嵁闆朵欢缂栧彿 = 銆�" + customerOrderDTO.getPartNo() + "銆慚ES鏈湴鏌ユ棤鍖归厤闆朵欢瀵硅薄");
- }
- }
- if (StringUtils.isNotBlank(customerOrderDTO.getSalesPartNo())) {
- Part part = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, customerOrderDTO.getSalesPartNo()));
- if (null == part) {
- throw new RuntimeException("鏍规嵁閿�鍞欢缂栧彿 = 銆�" + customerOrderDTO.getSalesPartNo() + "銆慚ES鏈湴鏌ユ棤鍖归厤闆朵欢瀵硅薄");
- }
- }
- // 濡傛灉閿�鍞浂浠跺彿鏈慨鏀癸紝otc鍚屾鐘舵�佷笉闇�瑕佹洿鏂�
- CustomerOrder oriCustomerOrder = customerOrderMapper.selectById(customerOrderDTO.getId());
- if (!org.apache.commons.lang3.StringUtils.equals(oriCustomerOrder.getSalesPartNo(),
- customerOrderDTO.getSalesPartNo())) {
- customerOrderDTO.setOtcPartSync(false);
- }
- //mes鏁伴噺 = 璁㈠崟鏁伴噺 * 鍥犲瓙
- Assert.notNull(customerOrderDTO.getIfsConvFactor(), "璇烽�夋嫨閿�鍞浂浠跺彿");
- customerOrderDTO.setBuyQtyDue(customerOrderDTO.getIfsConvFactor().multiply(customerOrderDTO.getOtcQuantity()));
- if (BooleanUtil.isTrue(customerOrderDTO.getIsDocument())) {
- customerOrderDTO.setCoState(CustomerOrderStateStringValues.PLAN);
- } else {
- customerOrderDTO.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
- }
- updateById(customerOrderDTO);
- return R.ok();
- }
+ public R fullUpdate(CustomerOrderVO1 customerOrderVO1) {
+ CustomerOrder customerOrder = new CustomerOrder();
+ BeanUtils.copyProperties(customerOrderVO1,customerOrder);
+ customerOrder.setId(customerOrderVO1.getId());
+ customerOrderMapper.updateById(customerOrder);
+
+ Customer customer = new Customer();
+ BeanUtils.copyProperties(customerOrderVO1,customer);
+ customer.setId(customerOrderMapper.selectById(customerOrderVO1.getId()).getCustomerId());
+ customerMapper.updateById(customer);
+ return R.ok("淇敼鎴愬姛!");
}
@Override
@@ -327,39 +313,25 @@
@Override
- public CustomerOrderDTO getCustomerOrderById(Long id) {
- CustomerOrder newCustomerOrder = baseMapper.selectById(id);
- Customer customer = customerMapper.selectById(newCustomerOrder.getCustomerId());
- CustomerOrderDTO customerOrderDTO = new CustomerOrderDTO();
- BeanUtils.copyProperties(newCustomerOrder, customerOrderDTO);
- customerOrderDTO.setComment(customer.getComment());
- //鑾峰彇瀛楁鍜屽垪鍚�
- List<OrderParamDTO> orderParamList = orderParamMapper.getAllOrder();
- customerOrderDTO.setOrderParamList(orderParamList);
- //鎷兼帴crosstab鎵�闇�瑕佺殑楠岃瘉鏁版嵁
- // OrderParam orderParam = orderParamMapper.getParam();
- //鑾峰彇瀹㈡埛璁㈠崟鍜岀粦瀹氱殑璁㈠崟鍙傛暟
- JSONObject customerOrderList = baseMapper.getCustomerOrderByIdnew(id);
- customerOrderDTO.setCustomerOrderList(customerOrderList);
- List<JSONObject> list = new ArrayList<>();
- customerOrderDTO.setCustomerOrderAttachmentList(list);
- // 鑾峰彇宸ュ崟鎵�闇�鐗╂枡
- List<OperationTaskProduce> operationTaskProduceList = operationTaskProduceMapper.selectList(Wrappers.<OperationTaskProduce>lambdaQuery()
- .eq(OperationTaskProduce::getCustomerOrderId, id).orderByAsc(OperationTaskProduce::getSort));
- customerOrderDTO.setOutPutBatchList(operationTaskProduceList);
- if (newCustomerOrder.getTechnologyDocumentId() != null) {
- Document document = documentMapper.selectById(newCustomerOrder.getTechnologyDocumentId());
+ public CustomerOrderVO1 getCustomerOrderById(Long id) {
+ CustomerOrderVO1 customerOrderVO1 = new CustomerOrderVO1();
+ //閿�鍞骇鍝佸崟(瀹㈡埛琛岃〃)
+ CustomerOrder customerOrder = baseMapper.selectById(id);
+ BeanUtils.copyProperties(customerOrder, customerOrderVO1);
+ //瀹㈡埛涓昏〃
+ Customer customer = customerMapper.selectById(customerOrder.getCustomerId());
+ BeanUtils.copyProperties(customer,customerOrderVO1);
+ if (customerOrder.getTechnologyDocumentId() != null) {
+ Document document = documentMapper.selectById(customerOrder.getTechnologyDocumentId());
if (document != null) {
- customerOrderDTO.setDocNumber(document.getNumber());
+ //宸ヨ壓鏂囦欢缂栧彿
+ customerOrderVO1.setDocNumber(document.getNumber());
+ //宸ヨ壓鏂囦欢鍚嶇О
+ customerOrderVO1.setDocName(document.getName());
}
}
- List<OrderProcessConfigFileDTO> configFiles =
- orderProcessConfigFileMapper.getProcessConfigFiles(newCustomerOrder.getCustomerOrderNo(),
- newCustomerOrder.getOtcLineNo());
- customerOrderDTO.setConfigFiles(configFiles);
- ProcessConfigDTO processConfigdto = processConfigService.getProcessConfig(id);
- customerOrderDTO.setProcessConfigDTO(processConfigdto);
- return customerOrderDTO;
+ customerOrderVO1.setId(id);
+ return customerOrderVO1;
}
@Override
@@ -400,18 +372,28 @@
// }
//淇濆瓨涓荤敓浜ц鍒�
MasterProductionSchedule masterProductionSchedule = new MasterProductionSchedule();
+ //涓荤敓浜ц鍒掑彿
masterProductionSchedule.setMpsNo(scheduleNumberGenerator.generateNumberWithPrefix(MasterProductionSchedule.DIGIT, MasterProductionSchedule.PREFIX, MasterProductionSchedule::getMpsNo));
- masterProductionSchedule.setPartId(customerOrderDTO.getPartId());
+ Part part = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, customerOrderDTO.getPartNo()));
+ //闆朵欢id
+ masterProductionSchedule.setPartId(part.getId());
//灏嗗鏍哥姸鎬佸拰宸ヨ壓鏂囦欢鐨刬d鍚屾缁欑敓浜ц鍒�
masterProductionSchedule.setIsAudit(customerOrderDTO.getIsAudit());
masterProductionSchedule.setTechnologyDocumentId(customerOrderDTO.getTechnologyDocumentId());
masterProductionSchedule.setManufactureAttr(customerOrderDTO.getManufactureAttr());
masterProductionSchedule.setDocNumber(customerOrderDTO.getDocNumber());
+ //闇�姹傛暟閲�
+ masterProductionSchedule.setQtyRequired(qta);
+ //闇�姹傛棩鏈�
+ masterProductionSchedule.setRequiredDate(customerOrderDTO.getDeliveryDate());
+ //澶囨敞
+ masterProductionSchedule.setRemark(customerOrderDTO.getRemark());
masterProductionSchedule.setQtyRequired(qta);
masterProductionSchedule.setRequiredDate(customerOrderDTO.getWantedDeliveryDate());
masterProductionSchedule.setRemark(customerOrderDTO.getRemark());
masterProductionSchedule.setSource("閿�鍞鍗�");
masterProductionScheduleMapper.insert(masterProductionSchedule);
+ customerOrderDTO.setRequireNumber(customerOrderDTO.getQtyPlaned());
// if (CollectionUtil.isNotEmpty(operationTaskProduceList)) {
// for (OperationTaskProduce operationTaskProduce : operationTaskProduceList) {
@@ -438,6 +420,7 @@
return true;
}
+ //澶氫釜閿�鍞鍗曞垱寤轰竴涓富鐢熶骇璁″垝
@Override
public MasterProductionSchedule createOneMasterProductionScheduleByCustomerOrders(List<CustomerOrderDTO> customerOrders) {
List<Long> ids = customerOrders.stream().map(CustomerOrderDTO::getId).collect(Collectors.toList());
@@ -599,17 +582,20 @@
return R.failed("宸ヨ壓鏂囦欢缂哄け");
}
List<CustomerOrder> customerOrderList = baseMapper.selectBatchIds(ids);
+ customerOrderList.forEach(l->{
+ log.info("鍏宠仈鏁版嵁==============================>"+l);
+ });
String msg = "";
for (CustomerOrder customerOrder : customerOrderList) {
if (BooleanUtil.isTrue(customerOrder.getIsDocument())) {
msg += customerOrder.getCustomerOrderNo() + "宸插叧鑱斿伐鑹烘枃浠讹紒";
}
- if (StringUtils.isBlank(customerOrder.getSalesPartNo())) {
+ if (StringUtils.isBlank(customerOrder.getPartNo())) {
msg += customerOrder.getCustomerOrderNo() + "鏈�夋嫨閿�鍞欢锛�";
}
- if (StringUtils.isBlank(customerOrder.getPartNo())) {
- customerOrder.setPartNo(document.getPartNo());
- }
+ //if (StringUtils.isBlank(customerOrder.getPartNo())) {
+ // customerOrder.setPartNo(document.getPartNo());
+ //}
customerOrder.setIsDocument(true);
customerOrder.setCoState(CustomerOrderStateStringValues.PLAN);
customerOrder.setTechnologyDocumentId(docId);
@@ -668,31 +654,19 @@
* @return
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public R otcCustomerOrderSync(String selectTime, String pathCode) {
try {
if (StringUtils.isBlank(selectTime)) {
return R.failed("缂哄皯鏌ヨ鏃堕棿");
}
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
- LocalDateTime startDate = LocalDateTime.parse(selectTime, formatter);
- Long days = LocalDate.now().toEpochDay() - startDate.toLocalDate().toEpochDay();
- if (days > 30) {
- return R.failed("瓒呭嚭鏌ヨ鏃堕棿鑼冨洿");
- }
String token = customerOrderUtil.getToken();
-
- if (pathCode.equals("0")) {
- return addCustomerFromOtc(selectTime, token);
- } else if (pathCode.equals("1")) {
- return addCustomerFromOtcForJointStockCompany(selectTime, token);
- } else {
- throw new RuntimeException("璺緞璇锋眰鐮� = 銆�" + pathCode + "銆戦潪娉�");
- }
-
+ return addCustomerFromOtc(selectTime, token);
} catch (Exception e) {
return R.failed(e.getMessage());
}
}
+
/**
* 娣诲姞涓昏〃淇℃伅
@@ -707,7 +681,7 @@
if (StringUtils.isNotBlank(selectTime)) {
map.put("selectTime", selectTime);
}
- String str = HttpRequest.get(customerOrderClientConfigure.getOtcHost() + customerOrderClientConfigure.getOtcCusomerUrl())
+ String str = HttpRequest.get(customerOrderClientConfigure.getOtcHost() + customerOrderClientConfigure.getOtcCustomerUrl())
.contentType("application/json")
.header("Authorization", "Bearer " + token).form(map).execute().body();
JSONObject result = JSONObject.parseObject(str);
@@ -725,6 +699,12 @@
String otcMainStatus = customerJSONObject.getString("status");
//鎵�灞炲叕鍙�
String affiliatedCompany = customerJSONObject.getString("affiliatedCompany");
+ //鎵�灞炲伐鍘�
+ String affiliatedContract=customerJSONObject.getString("affiliatedContract");
+ //鍙媺鍙栨墍灞炲叕鍙镐负涓ぉ娴锋磱绯荤粺鏈夐檺鍏徃鐨勬暟鎹�
+ if (!AFFILIATED_CONTRACT.equals(affiliatedContract)){
+ continue;
+ }
// 涓嶅湪杩欏嚑涓姸鎬佷腑鐨勬暟鎹氨璺宠繃
if (!Arrays.asList(CustomerOrderStateStringValues.GETOTCSTATE).contains(otcMainStatus)) {
continue;
@@ -734,15 +714,15 @@
customer = new Customer();
}
//濡傛灉OTC涓富琛ㄧ姸鎬佹槸鍙栨秷閭e氨璺宠繃鎴栬�呭垹闄ゅ凡缁忓悓姝ョ殑鏁版嵁
- if (otcMainStatus.equals("宸插彇娑�")) {
+ if (OTC_MAIN_STATUS_CANCEL.equals(otcMainStatus)) {
if (customer.getId() != null) {
customerMapper.deleteById(customer.getId());
baseMapper.delete(Wrappers.<CustomerOrder>lambdaQuery().eq(CustomerOrder::getCustomerId, customer.getId()));
}
continue;
}
- if (null == affiliatedCompany || !Arrays.asList("宸插鏍�", "宸蹭笅杈�").contains(otcMainStatus) || affiliatedCompany.equals("姹熻嫃涓ぉ绉戞妧鑲′唤鏈夐檺鍏徃")) {
- continue;//鍙幏鍙朞TC涓凡瀹℃牳鍙婂凡涓嬭揪鐨勮鍗曪紝涓旀墍灞炲叕鍙镐笉鏄腑澶╃鎶�
+ if (!OTC_MAIN_STATUS_TRANSMIT.equals(otcMainStatus)) {//null == affiliatedCompany || !Arrays.asList("宸蹭笅杈�").contains(otcMainStatus) /*|| affiliatedCompany.equals("姹熻嫃涓ぉ绉戞妧鑲′唤鏈夐檺鍏徃")*/) {
+ continue;//鍙幏鍙朞TC涓凡瀹℃牳鍙婂凡涓嬭揪鐨勮鍗曪紝
}
//瀹㈡埛缂栧彿
customer.setCustomerNo(customerJSONObject.getString("customerNo"));
@@ -799,7 +779,6 @@
}
}
-
/**
* 娣诲姞瀛愯〃淇℃伅
*
@@ -830,7 +809,7 @@
customerOrder = new CustomerOrder();
}
//濡傛灉杩欎釜鍗曞瓙鍦∣TC涓彇娑堢姸鎬� 閭e氨鍒犻櫎
- if (otcOrderStatus.equals("宸插彇娑�")) {
+ if (otcOrderStatus.equals(OTC_MAIN_STATUS_CANCEL)) {
if (customerOrder.getId() != null) {
baseMapper.deleteById(customerOrder.getId());
}
@@ -841,17 +820,19 @@
//otc琛屽彿
customerOrder.setOtcLineNo(otcLoneId);
//闆朵欢鍙�
- customerOrder.setSalesPartNo(customerOrderJSONObject.getString("partNo"));
- //鏉ユ簮
- customerOrder.setSourceId("OTC");
+ customerOrder.setPartNo(customerOrderJSONObject.getString("partNo"));
+ //鏉ユ簮 0:鑷姩
+ customerOrder.setSourceId("0");
//鍚堝悓鍙�
customerOrder.setCustomerOrderNo(customer.getContractNo());
//瀹㈡埛鍙�
customerOrder.setCustomerNo(customer.getCustomerNo());
//瀹㈡埛鍚嶇О
customerOrder.setCustomerName(customer.getCustomerName());
- //閿�鍞暟閲忓師鍏圤TC鐨勫崟浣�
- customerOrder.setOtcQuantity(customerOrderJSONObject.getBigDecimal("quantity"));
+ //宸ョ▼鍚嶇О
+ customerOrder.setEntityName(customer.getEntityName());
+ //鏁伴噺
+ customerOrder.setBuyQtyDue(customerOrderJSONObject.getBigDecimal("quantity"));
//OTC鍗曚綅
customerOrder.setOtcUnit(customerOrderJSONObject.getString("unit"));
//鏈熸湜浜よ揣鏃ユ湡
@@ -890,8 +871,8 @@
customerOrder.setSalesmanName(customer.getSalesMan());
//鐩橀暱瑕佹眰
customerOrder.setLengthRequirement(customerOrderJSONObject.getString("lengthRequirement"));
- //澶囨敞脧
- customerOrder.setRemark(customerOrderJSONObject.getString("comment"));
+ //浜у搧澶囨敞脧
+ customerOrder.setRemark(customerOrderJSONObject.getString("orderComment"));
//浜у搧绫诲瀷
customerOrder.setProductType(customerOrderJSONObject.getString("productType"));
//浜у搧鍒嗙粍
@@ -916,20 +897,18 @@
} else {
customerOrder.setCoState(CustomerOrderStateStringValues.PARTUNCHECKED);
}
- if (org.apache.commons.lang3.StringUtils.equals("宸蹭笅杈�", otcMainStatus)) {
+ if (org.apache.commons.lang3.StringUtils.equals(OTC_MAIN_STATUS_TRANSMIT, otcMainStatus)) {
customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
customerOrder.setOtcPartSync(Boolean.TRUE);
}
- //瀹℃牳鐘舵�佷负 01draft 鑽夌
- customerOrder.setIsAudit(AuditStateStringValues.DRAFT);
+ // 濡傛灉鐘舵�佷负闆朵欢寰呴�夛紝涓旈浂浠跺彿涓嶄负绌猴紝鏇存柊鐘舵��
+ if (StrUtil.isNotBlank(customerOrder.getPartNo()) && CustomerOrderStateStringValues.PARTUNCHECKED.equals(customerOrder.getCoState())) {
+ customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
+ customerOrder.setOtcPartSync(Boolean.TRUE);
+ }
+ //瀹℃牳鐘舵�佷负 03accepted 閫氳繃
+ customerOrder.setIsAudit(AuditStateStringValues.ACCEPTED);
baseMapper.insert(customerOrder);
- } else {
- // 濡傛灉鐘舵�佷负闆朵欢寰呴�夛紝涓旈攢鍞欢鍙蜂笉涓虹┖锛屾洿鏂扮姸鎬�
- if (StrUtil.isNotBlank(customerOrder.getSalesPartNo()) && CustomerOrderStateStringValues.PARTUNCHECKED.equals(customerOrder.getCoState())) {
- customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
- customerOrder.setOtcPartSync(Boolean.TRUE);
- }
- baseMapper.updateById(customerOrder);
}
addCustomerPara(customerJSONObject, customerOrderJSONObject, customerOrder, orderParamList);
num += 1;
@@ -940,6 +919,253 @@
}
return num;
}
+
+ ///**
+ // * 娣诲姞涓昏〃淇℃伅
+ // *
+ // * @param selectTime 鏃堕棿
+ // * @param token token
+ // * @return
+ // */
+ //private R addCustomerFromOtc(String selectTime, String token) {
+ // try {
+ // Map<String, Object> map = new HashMap<>();
+ // if (StringUtils.isNotBlank(selectTime)) {
+ // map.put("selectTime", selectTime);
+ // }
+ // String str = HttpRequest.get(customerOrderClientConfigure.getOtcHost() + customerOrderClientConfigure.getOtcCusomerUrl())
+ // .contentType("application/json")
+ // .header("Authorization", "Bearer " + token).form(map).execute().body();
+ // JSONObject result = JSONObject.parseObject(str);
+ // //涓昏〃鍙傛暟琛�
+ // List<OrderParam> orderParams = orderParamService.list();
+ // if (result.getInteger("code") == 0) {
+ // int num = 0;
+ // int detailNum = 0;
+ // JSONArray jsonArray = result.getJSONArray("data");
+ // for (Object obj : jsonArray) {
+ // JSONObject customerJSONObject = JSONObject.parseObject(obj.toString());
+ // //鍚堝悓缂栧彿
+ // String contractNo = customerJSONObject.getString("orderNo");
+ // //涓昏〃鍦∣TC涓殑鐘舵��
+ // String otcMainStatus = customerJSONObject.getString("status");
+ // //鎵�灞炲叕鍙�
+ // String affiliatedCompany = customerJSONObject.getString("affiliatedCompany");
+ // // 涓嶅湪杩欏嚑涓姸鎬佷腑鐨勬暟鎹氨璺宠繃
+ // if (!Arrays.asList(CustomerOrderStateStringValues.GETOTCSTATE).contains(otcMainStatus)) {
+ // continue;
+ // }
+ // Customer customer = customerMapper.selectOne(Wrappers.<Customer>lambdaQuery().eq(Customer::getContractNo, contractNo));
+ // if (customer == null) {
+ // customer = new Customer();
+ // }
+ // //濡傛灉OTC涓富琛ㄧ姸鎬佹槸鍙栨秷閭e氨璺宠繃鎴栬�呭垹闄ゅ凡缁忓悓姝ョ殑鏁版嵁
+ // if (otcMainStatus.equals("宸插彇娑�")) {
+ // if (customer.getId() != null) {
+ // customerMapper.deleteById(customer.getId());
+ // baseMapper.delete(Wrappers.<CustomerOrder>lambdaQuery().eq(CustomerOrder::getCustomerId, customer.getId()));
+ // }
+ // continue;
+ // }
+ // if (null == affiliatedCompany || !Arrays.asList("宸插鏍�", "宸蹭笅杈�").contains(otcMainStatus) || affiliatedCompany.equals("姹熻嫃涓ぉ绉戞妧鑲′唤鏈夐檺鍏徃")) {
+ // continue;//鍙幏鍙朞TC涓凡瀹℃牳鍙婂凡涓嬭揪鐨勮鍗曪紝涓旀墍灞炲叕鍙镐笉鏄腑澶╃鎶�
+ // }
+ // //瀹㈡埛缂栧彿
+ // customer.setCustomerNo(customerJSONObject.getString("customerNo"));
+ // //鍚堝悓鍙�
+ // customer.setContractNo(contractNo);
+ // //瀹㈡埛鍚堝悓鍙�
+ // customer.setCustomerContractNo(customerJSONObject.getString("customerContractNumber"));
+ // //瀹㈡埛鍚嶇О
+ // customer.setCustomerName(customerJSONObject.getString("customerName"));
+ // //宸ョ▼鍚嶇О
+ // customer.setEntityName(customerJSONObject.getString("projectName"));
+ // //浜よ揣鏃ユ湡
+ // customer.setDeliveryDate(customerJSONObject.get("wantedDeliveryDate") != null ?
+ // customerJSONObject.getDate("wantedDeliveryDate").toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime() : null);
+ // //浜嬩笟閮�
+ // customer.setSalesDepartment(customerJSONObject.getString("division"));
+ // //鐪佷唤
+ // customer.setProvince(customerJSONObject.getString("province"));
+ // //涓氬姟鍛樺悕绉�
+ // customer.setSalesMan(customerJSONObject.getString("salesmanName"));
+ // //涓氬姟鍛樼紪鍙�
+ // customer.setSalerWorkCode(customerJSONObject.getString("salesmanNo"));
+ // //姝f湰鐘舵��
+ // customer.setOriginalContractStatus(customerJSONObject.getString("originalStatus"));
+ // //鍚堝悓姝f湰鐘舵��
+ // customer.setReturnStatus(customerJSONObject.getString("returnStatus"));
+ // //椤圭洰鎬ц川
+ // customer.setIsCp(customerJSONObject.getString("natureOfProjectExecution"));
+ // //涓嬪崟鏃ユ湡
+ // customer.setPlaceOrderDate(customerJSONObject.getDate("orderDate").toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
+ // //瀹℃牳鏃ユ湡
+ // customer.setVerifyDate(customerJSONObject.get("reviewTime") != null ?
+ // customerJSONObject.getDate("reviewTime").toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime() : null);
+ // //宸ュ巶涓嬪崟鏃ユ湡
+ // customer.setFactoryPlaceOrderDate(customerJSONObject.get("factoryOrderDate") != null ?
+ // customerJSONObject.getDate("factoryOrderDate").toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime() : null);
+ // //澶囨敞
+ // customer.setComment(customerJSONObject.getString("comment"));
+ // if (customer.getId() == null) {
+ // customerMapper.insert(customer);
+ // } else {
+ // customerMapper.updateById(customer);
+ // }
+ // num += 1;
+ //
+ // detailNum += addCustomerOrderFromOtc(customerJSONObject, customer, token, orderParams, otcMainStatus);
+ // }
+ // return R.ok().setMsg("鍚屾鎴栨洿鏂板悎鍚屼富浣�" + num + "鏉�,鍚堝悓鏄庣粏" + detailNum + "鏉★紒");
+ // } else {
+ // return R.failed("璁㈠崟涓讳綋鑾峰彇澶辫触");
+ // }
+ // } catch (Exception e) {
+ // throw new RuntimeException(e.getMessage());
+ // }
+ //}
+ //
+
+ /**
+ * 娣诲姞瀛愯〃淇℃伅
+ *
+ * @param customer
+ * @param otcMainStatus
+ * @throws Exception
+ */
+ //private int addCustomerOrderFromOtc(JSONObject customerJSONObject, Customer customer, String token, List<OrderParam> orderParamList, String otcMainStatus) {
+ // Map<String, String> productTypeGroupMap = customerOrderUnitWhiteListConfig.getProductTypeGroupMap();
+ // int num = 0;
+ // try {
+ // Map<String, Object> map = new HashMap<>();
+ // map.put("orderNo", customer.getContractNo());
+ // map.put("selectTime", "1899-12-31 23:59:59");
+ // JSONObject result = JSONObject.parseObject(HttpRequest.get(customerOrderClientConfigure.getOtcHost() + customerOrderClientConfigure.getOtcCustomerOrderUrl())
+ // .contentType("application/json")
+ // .header("Authorization", "Bearer " + token).form(map).execute().body());
+ // if (result.getInteger("code") == 0) {
+ // JSONArray jsonArray = result.getJSONArray("data");
+ // for (Object obj : jsonArray) {
+ // JSONObject customerOrderJSONObject = JSONObject.parseObject(obj.toString());
+ // String otcLoneId = customerOrderJSONObject.getLong("id").toString();
+ // //OTC鐨勮鍗曠姸鎬�
+ // String otcOrderStatus = customerOrderJSONObject.getString("lineStatus").toString();
+ // CustomerOrder customerOrder = baseMapper.selectOne(Wrappers.<CustomerOrder>lambdaQuery()
+ // .eq(CustomerOrder::getOtcLineNo, otcLoneId));
+ // if (customerOrder == null) {
+ // customerOrder = new CustomerOrder();
+ // }
+ // //濡傛灉杩欎釜鍗曞瓙鍦∣TC涓彇娑堢姸鎬� 閭e氨鍒犻櫎
+ // if (otcOrderStatus.equals("宸插彇娑�")) {
+ // if (customerOrder.getId() != null) {
+ // baseMapper.deleteById(customerOrder.getId());
+ // }
+ // continue;
+ // }
+ // //OTC鍚堝悓鍙蜂富琛╥d
+ // customerOrder.setOtcOrderId(customerOrderJSONObject.getLong("orderId"));
+ // //otc琛屽彿
+ // customerOrder.setOtcLineNo(otcLoneId);
+ // //闆朵欢鍙�
+ // customerOrder.setSalesPartNo(customerOrderJSONObject.getString("partNo"));
+ // //鏉ユ簮
+ // customerOrder.setSourceId("OTC");
+ // //鍚堝悓鍙�
+ // customerOrder.setCustomerOrderNo(customer.getContractNo());
+ // //瀹㈡埛鍙�
+ // customerOrder.setCustomerNo(customer.getCustomerNo());
+ // //瀹㈡埛鍚嶇О
+ // customerOrder.setCustomerName(customer.getCustomerName());
+ // //閿�鍞暟閲忓師鍏圤TC鐨勫崟浣�
+ // customerOrder.setOtcQuantity(customerOrderJSONObject.getBigDecimal("quantity"));
+ // //OTC鍗曚綅
+ // customerOrder.setOtcUnit(customerOrderJSONObject.getString("unit"));
+ // //鏈熸湜浜よ揣鏃ユ湡
+ // customerOrder.setWantedDeliveryDate(customer.getDeliveryDate());
+ // //涓昏〃id
+ // customerOrder.setCustomerId(customer.getId());
+ // //鐢靛帇绛夌骇
+ // customerOrder.setVoltAgeClass(customerOrderJSONObject.getString("voltageLevel"));
+ // //澶栧懠棰滆壊
+ // customerOrder.setOuterColor(customerOrderJSONObject.getString("outerSheathColor"));
+ // //瀹㈡埛闆朵欢鍚嶇О
+ // customerOrder.setProductName(customerOrderJSONObject.getString("productName"));
+ // //瀹㈡埛闆朵欢瑙勬牸
+ // customerOrder.setCustomerPartSpec(customerOrderJSONObject.getString("specificationModel"));
+ // //璁㈠崟鐗堟湰
+ // customerOrder.setVersion(customerOrderJSONObject.getInteger("version"));
+ // //浜嬩笟閮�
+ // customerOrder.setDivision(customerOrderJSONObject.getString("division"));
+ // //鍗板瓧绫诲瀷
+ // customerOrder.setPrintType(customerOrderJSONObject.getString("printType"));
+ // //鍗板瓧鍐呭
+ // customerOrder.setPrintContent(customerOrderJSONObject.getString("printContent"));
+ // //鍗板瓧瑕佹眰
+ // customerOrder.setPrintingRequirements(customerOrderJSONObject.getString("printingRequirements"));
+ // //鍖呰瑕佹眰
+ // customerOrder.setPackageRequire(customerOrderJSONObject.getString("packageRequire"));
+ // //璐ㄩ噺瑕佹眰
+ // customerOrder.setQualityRequire(customerOrderJSONObject.getString("qualityRequire"));
+ // //鐢熶骇闇�姹傝鏄�
+ // customerOrder.setOtherProductRequire(customerOrderJSONObject.getString("otherProductRequire"));
+ // //绯荤粺
+ // customerOrder.setDivisionSystem(customerOrderJSONObject.getString("divisionSystem"));
+ // //鏀惰揣鍦板潃
+ // customerOrder.setShippingAddress(customerOrderJSONObject.getString("shippingAddress"));
+ // //涓氬姟鍛�
+ // customerOrder.setSalesmanName(customer.getSalesMan());
+ // //鐩橀暱瑕佹眰
+ // customerOrder.setLengthRequirement(customerOrderJSONObject.getString("lengthRequirement"));
+ // //澶囨敞脧
+ // customerOrder.setRemark(customerOrderJSONObject.getString("comment"));
+ // //浜у搧绫诲瀷
+ // customerOrder.setProductType(customerOrderJSONObject.getString("productType"));
+ // //浜у搧鍒嗙粍
+ // customerOrder.setProductGroup(productTypeGroupMap.get(customerOrderJSONObject.getString("productType")));
+ // //閲囬泦鎬ц川
+ // customerOrder.setCentralizedMiningProperty(customerJSONObject.getString("centralizedMiningProperty"));
+ // //鏈�缁堝鎴峰悕绉�
+ // customerOrder.setFinalCustomerName(customerJSONObject.getString("finalCustomerName"));
+ // //閿�鍞欢鎻忚堪
+ // customerOrder.setSalesPartName(customerOrderJSONObject.getString("partDesc"));
+ //
+ // if (customerOrder.getId() == null) {
+ // // 闆朵欢鏄惁鎺ㄩ��
+ // customerOrder.setOtcPartSync(false);
+ // // 榛樿涓篘 鏁版嵁瀛楀吀涓猴細N锛氭櫘閫氾紝S锛氭牱鍝侊紝D锛氱爺鍙�
+ // customerOrder.setManufactureAttr("N");
+ // //鏄惁鍏宠仈宸ヨ壓鏂囦欢涓哄惁
+ // customerOrder.setIsDocument(false);
+ // //鐘舵�佷负 濡傛灉閲囬泦鎬ц川 闈為噰闆嗗拰 鐪侀噰闆� 鐘舵�佷綅缂栬緫 鍚﹀垯涓� 闆朵欢寰呴��
+ // if (customerOrder.getCentralizedMiningProperty().equals("闈為泦閲�") || customerOrder.getCentralizedMiningProperty().equals("鐪侀泦閲�")) {
+ // customerOrder.setCoState(CustomerOrderStateStringValues.UNIEDIT);
+ // } else {
+ // customerOrder.setCoState(CustomerOrderStateStringValues.PARTUNCHECKED);
+ // }
+ // if (org.apache.commons.lang3.StringUtils.equals("宸蹭笅杈�", otcMainStatus)) {
+ // customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
+ // customerOrder.setOtcPartSync(Boolean.TRUE);
+ // }
+ // //瀹℃牳鐘舵�佷负 01draft 鑽夌
+ // customerOrder.setIsAudit(AuditStateStringValues.DRAFT);
+ // baseMapper.insert(customerOrder);
+ // } else {
+ // // 濡傛灉鐘舵�佷负闆朵欢寰呴�夛紝涓旈攢鍞欢鍙蜂笉涓虹┖锛屾洿鏂扮姸鎬�
+ // if (StrUtil.isNotBlank(customerOrder.getSalesPartNo()) && CustomerOrderStateStringValues.PARTUNCHECKED.equals(customerOrder.getCoState())) {
+ // customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
+ // customerOrder.setOtcPartSync(Boolean.TRUE);
+ // }
+ // baseMapper.updateById(customerOrder);
+ // }
+ // addCustomerPara(customerJSONObject, customerOrderJSONObject, customerOrder, orderParamList);
+ // num += 1;
+ // }
+ // }
+ // } catch (Exception e) {
+ // throw new RuntimeException("璁㈠崟琛屾暟鎹幏鍙栧け璐ワ紝鍘熷洜锛�" + e.getMessage());
+ // }
+ // return num;
+ //}
/**
* @param jsonObjMain 涓昏〃鐨刯sonObj
@@ -1635,15 +1861,14 @@
@Override
public R uploadProcessConfigFile(MultipartFile file, String orderNumber, String lineNumber) {
- String fileName = IdUtil.simpleUUID() + StrUtil.DOT + FileUtil.extName(file.getOriginalFilename());
+ String fileName = FileUtil.extName(file.getOriginalFilename());
try {
- minioTemplate.putObject(ossProperties.getBucketName(), fileName, file.getInputStream());
OrderProcessConfigFile configFile = new OrderProcessConfigFile();
configFile.setFileName(fileName);
configFile.setOriginalFileName(file.getOriginalFilename());
configFile.setOrderNumber(orderNumber);
configFile.setLineNumber(lineNumber);
- configFile.setBucketName(ossProperties.getBucketName());
+ configFile.setBucketName(FileSaveUtil.StoreFile(file));
orderProcessConfigFileMapper.insert(configFile);
ProcessConfigFileOrderMapping mapping = ProcessConfigFileOrderMapping.builder().configFileId(configFile.getId())
.orderNumber(orderNumber).lineNumber(lineNumber).build();
@@ -1670,7 +1895,9 @@
@Override
public void getFile(String bucket, String fileName, HttpServletResponse response) {
- try (InputStream inputStream = minioTemplate.getObject(bucket, fileName)) {
+ try {
+ String path = FileSaveUtil.FILE_PATH + bucket;
+ InputStream inputStream = new FileInputStream(path);
response.setContentType("application/octet-stream; charset=UTF-8");
IoUtil.copy(inputStream, response.getOutputStream());
} catch (Exception e) {
@@ -1682,7 +1909,9 @@
public R deleteProcessConfigFile(Long id) {
try {
OrderProcessConfigFile configFile = orderProcessConfigFileMapper.selectById(id);
- minioTemplate.removeObject(configFile.getBucketName(), configFile.getFileName());
+ String filePath=FileSaveUtil.FILE_PATH+"//"+configFile.getBucketName();
+ boolean del = FileUtil.del(new File(filePath));
+ //minioTemplate.removeObject(configFile.getBucketName(), configFile.getFileName());
orderProcessConfigFileMapper.deleteById(id);
processConfigFileOrderMappingMapper.delete(Wrappers.<ProcessConfigFileOrderMapping>lambdaQuery().eq(ProcessConfigFileOrderMapping::getConfigFileId, id));
return R.ok();
@@ -1832,7 +2061,7 @@
if (StringUtils.isNotBlank(selectTime)) {
map.put("selectTime", selectTime);
}
- String str = HttpRequest.get(customerOrderClientConfigure.getOtcHost() + customerOrderClientConfigure.getOtcCusomerUrl())
+ String str = HttpRequest.get(customerOrderClientConfigure.getOtcHost() + customerOrderClientConfigure.getOtcCustomerUrl())
.contentType("application/json")
.header("Authorization", "Bearer " + token).form(map).execute().body();
JSONObject result = JSONObject.parseObject(str);
--
Gitblit v1.9.3