From a7a6f62fdcfde8bad76e39b0afc5615461bc1583 Mon Sep 17 00:00:00 2001 From: zouyu <2723363702@qq.com> Date: 星期二, 14 十一月 2023 12:03:20 +0800 Subject: [PATCH] 销售订单 --- mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java | 159 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 135 insertions(+), 24 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..f80edeb 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 @@ -26,7 +26,6 @@ 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.util.RedisUtils; @@ -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.*; @@ -83,7 +81,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; @@ -103,14 +100,12 @@ 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; /** * 瀹㈡埛璁㈠崟琛� @@ -673,26 +668,27 @@ 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("瓒呭嚭鏌ヨ鏃堕棿鑼冨洿"); - } + //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 + "銆戦潪娉�"); - } - + //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,10 +703,13 @@ 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); + //JSONArray jsonArray = result.getJSONArray("data"); + //jsonArray.forEach(); + //return null; //涓昏〃鍙傛暟琛� List<OrderParam> orderParams = orderParamService.list(); if (result.getInteger("code") == 0) { @@ -725,6 +724,12 @@ String otcMainStatus = customerJSONObject.getString("status"); //鎵�灞炲叕鍙� String affiliatedCompany = customerJSONObject.getString("affiliatedCompany"); + //鎵�灞炲伐鍘� + String affiliatedContract=customerJSONObject.getString("affiliatedContract"); + //鍙媺鍙栨墍灞炲叕鍙镐负涓ぉ娴锋磱绯荤粺鏈夐檺鍏徃鐨勬暟鎹� + if (!"涓ぉ鏉愭枡鍘�".equals(affiliatedContract)){ + continue; + } // 涓嶅湪杩欏嚑涓姸鎬佷腑鐨勬暟鎹氨璺宠繃 if (!Arrays.asList(CustomerOrderStateStringValues.GETOTCSTATE).contains(otcMainStatus)) { continue; @@ -734,15 +739,15 @@ customer = new Customer(); } //濡傛灉OTC涓富琛ㄧ姸鎬佹槸鍙栨秷閭e氨璺宠繃鎴栬�呭垹闄ゅ凡缁忓悓姝ョ殑鏁版嵁 - if (otcMainStatus.equals("宸插彇娑�")) { + if ("宸插彇娑�".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 (!"宸蹭笅杈�".equals(otcMainStatus)) {//null == affiliatedCompany || !Arrays.asList("宸蹭笅杈�").contains(otcMainStatus) /*|| affiliatedCompany.equals("姹熻嫃涓ぉ绉戞妧鑲′唤鏈夐檺鍏徃")*/) { + continue;//鍙幏鍙朞TC涓凡瀹℃牳鍙婂凡涓嬭揪鐨勮鍗曪紝 } //瀹㈡埛缂栧彿 customer.setCustomerNo(customerJSONObject.getString("customerNo")); @@ -799,6 +804,112 @@ } } + + ///** + // * 娣诲姞涓昏〃淇℃伅 + // * + // * @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()); + // } + //} + // /** * 娣诲姞瀛愯〃淇℃伅 @@ -1832,7 +1943,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