定时获取发货单、商品调整
This commit is contained in:
		
							parent
							
								
									f278fd8aef
								
							
						
					
					
						commit
						f9d7fa8890
					
				|  | @ -269,14 +269,15 @@ public class InvoiceController extends BaseController { | |||
|     @ApiOperation(value = "生成发货单PDF") | ||||
|     @PostMapping(value = "/generateInvPdf") | ||||
|     public Map<String, Object> generateInvPdf( | ||||
|             @ApiParam(required = true, value = "单据日期") @RequestParam(required = true) String invoiceDate, | ||||
|             @ApiParam(required = false, value = "单据日期") @RequestParam(required = false) String invoiceDate, | ||||
|             @ApiParam(required = false, value = "主键") @RequestParam(required = false) String invoiceId, | ||||
|             HttpServletRequest request) { | ||||
|         StopWatch stopWatch = new StopWatch(); | ||||
|         // 开始时间 | ||||
|         stopWatch.start(); | ||||
|         Map<String, Object> params = new HashMap<>(); | ||||
|         // params.put("invoiceDate", "2021-11"); | ||||
|         params.put("invoiceDate", invoiceDate); | ||||
|         params.put("invoiceId", invoiceId); | ||||
|         List<InvoiceInfo> orderList = invoiceService.findAll(params, ".pageList"); | ||||
|         String path = ReadXmlutils.xmlForMap("", "invOrderPath"); | ||||
|         int totalNum = 0; | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ package com.yb.lb.webapp.ueight.job; | |||
| import com.yb.lb.common.utils.ErrorUtils; | ||||
| import com.yb.lb.common.utils.FINALCMD; | ||||
| import com.yb.lb.webapp.message.service.MessageService; | ||||
| import com.yb.lb.webapp.u8.thread.U8OrderThread; | ||||
| import com.yb.lb.webapp.u8.ueight.service.OrderCronService; | ||||
| import com.yb.lb.webapp.u8.ueight.service.OrderUeightService; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | @ -13,8 +13,6 @@ import org.springframework.stereotype.Component; | |||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.concurrent.ExecutorService; | ||||
| import java.util.concurrent.Executors; | ||||
| 
 | ||||
| @Component("orderU8Controller") | ||||
| public class OrderU8Controller { | ||||
|  | @ -25,21 +23,24 @@ public class OrderU8Controller { | |||
|     OrderUeightService orderService; | ||||
|     @Autowired | ||||
|     MessageService messageService; | ||||
|     @Autowired | ||||
|     OrderCronService orderCronService; | ||||
| 
 | ||||
|     public Map<String, Object> findClassOne() { | ||||
|         Map<String, Object> result = new HashMap<>(); | ||||
|         Map<String, Object> params = new HashMap<>(); | ||||
|         try { | ||||
|             ExecutorService pool = Executors.newFixedThreadPool(2); | ||||
|             // ExecutorService pool = Executors.newFixedThreadPool(2); | ||||
|             String[] companyIds = {FINALCMD.KESAI, FINALCMD.DEHAO}; | ||||
|             for (String companyId : companyIds) { | ||||
|                 List list = orderService.findList(".pageOrder", null, companyId); | ||||
|                 List list1 = orderService.findList(".pageDetail", null, companyId); | ||||
|                 U8OrderThread thread = new U8OrderThread(list, list1, orderService, messageService, companyId); | ||||
|                 orderCronService.syncU8Orders(list, list1, companyId); | ||||
|                 // U8OrderThread thread = new U8OrderThread(list, list1, orderService, messageService, companyId); | ||||
|                 //提交线程池 执行 | ||||
|                 pool.submit(thread); | ||||
|                 // pool.submit(thread); | ||||
|             } | ||||
|             pool.shutdown();//关闭线程池 | ||||
|             // pool.shutdown();//关闭线程池 | ||||
|             result.put("data", true); | ||||
|             result.put("code", ErrorUtils.SUCCESS); | ||||
|             result.put("msg", "操作成功"); | ||||
|  |  | |||
|  | @ -46,7 +46,7 @@ | |||
|                 and goodsTypeId LIKE '%' + #{typeId} + '%' | ||||
|             </if> | ||||
|             <if test="updateDate !=null and updateDate !=''"> | ||||
|                 and updateDate > #{updateDate} | ||||
|                 and (updateDate > #{updateDate} or createTime > #{updateDate}) | ||||
|             </if> | ||||
|             <if test="keywords !=null and keywords !=''"> | ||||
|                 and | ||||
|  |  | |||
|  | @ -0,0 +1,140 @@ | |||
| package com.yb.lb.webapp.u8.ueight.service; | ||||
| 
 | ||||
| import com.yb.lb.common.config.UserConfig; | ||||
| import com.yb.lb.common.utils.*; | ||||
| import com.yb.lb.webapp.message.entity.MessageConfig; | ||||
| import com.yb.lb.webapp.message.service.MessageService; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| /** | ||||
|  * 定时同步U8订单数据到CRM系统 | ||||
|  * | ||||
|  * @author mzr | ||||
|  * @date 2024-04-16 | ||||
|  */ | ||||
| @Service | ||||
| public class OrderCronService { | ||||
|     private static final Logger logger = LoggerFactory.getLogger(OrderCronService.class); | ||||
| 
 | ||||
|     @Autowired | ||||
|     OrderUeightService orderUeightService; | ||||
|     @Autowired | ||||
|     MessageService messageService; | ||||
| 
 | ||||
|     /** | ||||
|      * 获取U8的销售出库单 | ||||
|      * | ||||
|      * @author mzr | ||||
|      * @date 2023/08/02 | ||||
|      **/ | ||||
|     public void syncU8Orders(List<Map> orderList, List<Map> goodsList, String companyId) { | ||||
|         try { | ||||
|             if (orderList.size() > 0) { | ||||
|                 String invConfigId = UserConfig.getInvConfigId(); | ||||
|                 Map<String, Object> params = new HashMap<>(); | ||||
|                 params.put("companyId", companyId); | ||||
|                 //获取业务员集合 | ||||
|                 List<Map> servicerList = orderUeightService.findListOracle(params, ".pageServicer"); | ||||
|                 for (Map map : orderList) { | ||||
|                     String staffId = map.get("staffId") + ""; | ||||
|                     String clientId = map.get("clientId") + ""; | ||||
| 
 | ||||
|                     Map<String, Object> tMap = new HashMap<>(); | ||||
|                     tMap.put("clientId", clientId); | ||||
|                     tMap.put("companyId", companyId); | ||||
|                     Map clientInfoMap = orderUeightService.oneById(tMap, ".findByNo"); | ||||
|                     if (clientInfoMap != null) { | ||||
|                         map.put("clientId", clientInfoMap.get("id") + ""); | ||||
|                         map.put("phone", clientInfoMap.get("phone") != null ? clientInfoMap.get("phone") + "" : ""); | ||||
|                         map.put("region", clientInfoMap.get("region") != null ? clientInfoMap.get("region") + "" : ""); | ||||
|                         map.put("regionName", clientInfoMap.get("regionName") != null ? clientInfoMap.get("regionName") + "" : ""); | ||||
|                         map.put("ancestors", clientInfoMap.get("ancestors") != null ? clientInfoMap.get("ancestors") + "" : ""); | ||||
|                     } else { | ||||
|                         map.put("phone", ""); | ||||
|                         map.put("region", ""); | ||||
|                         map.put("regionName", ""); | ||||
|                         map.put("ancestors", ""); | ||||
|                     } | ||||
| 
 | ||||
|                     // 匹配业务员 | ||||
|                     List<Map> list = servicerList.stream().filter(staffMap -> staffId.equals(staffMap.get("staffNo"))).collect(Collectors.toList()); | ||||
|                     Map staffMap = null; | ||||
|                     if (list.size() > 0) { | ||||
|                         staffMap = list.get(0); | ||||
|                         map.put("staffId", staffMap.get("staffId") + ""); | ||||
|                     } | ||||
| 
 | ||||
|                     String orderId = map.get("id") + ""; | ||||
|                     List<Map> goodsList1 = goodsList.stream().filter(goodsMap -> orderId.equals(goodsMap.get("invoiceId") + "")).collect(Collectors.toList()); | ||||
|                     if (goodsList1.size() <= 0) { | ||||
|                         logger.info("orderId:{}", orderId); | ||||
|                         continue; | ||||
|                     } | ||||
|                     Map<String, Object> info = new HashMap<>(); | ||||
|                     info.put("id", orderId); | ||||
|                     info.put("cDefine8", "1"); | ||||
|                     // 新增发货单 | ||||
|                     map.put("companyId", companyId); | ||||
|                     String invoiceNo = map.get("invoiceNo") + ""; | ||||
|                     String saleOrderNo = map.get("saleOrderNo") + ""; | ||||
|                     String clientName = map.get("clientName") + ""; | ||||
|                     String companyUrl = "2".equals(companyId) ? "/dehao/" : "/kesai/"; | ||||
|                     String pdfFileName = clientName + invoiceNo + "-" + saleOrderNo + ".pdf"; | ||||
|                     map.put("invUrl", "/invOrder" + companyUrl + pdfFileName); | ||||
|                     if (orderUeightService.addOrder1(map)) { | ||||
|                         String createTime = StringUtil.isNotEmpty(map.get("createTime")) ? map.get("createTime") + "" : DateUtil.getTime(); | ||||
|                         // 新增发货单的商品详情 | ||||
|                         for (Map goodsMap1 : goodsList1) { | ||||
|                             goodsMap1.put("companyId", companyId); | ||||
|                             goodsMap1.put("createTime", createTime); | ||||
|                         } | ||||
|                         if (orderUeightService.addOrderDetail(goodsList1)) { | ||||
|                             // 回写U8销售出库单的状态 | ||||
|                             if (FINALCMD.KESAI.equals(companyId)) { | ||||
|                                 orderUeightService.update(".updateOrderInfo", info); | ||||
|                             } else if (FINALCMD.DEHAO.equals(companyId)) { | ||||
|                                 orderUeightService.updateInfo1(".updateOrderInfo", info); | ||||
|                             } | ||||
|                             // 调用积木报表生成pdf文件 | ||||
|                             String fileUrl = ReadXmlutils.xmlForMap("", "invOrderPath") + companyUrl + pdfFileName; | ||||
|                             MyFileUtils.exportPdf(invConfigId, orderId, fileUrl, "2"); | ||||
|                             // 单据同步成功之后再发送消息 | ||||
|                             if (staffMap != null && !staffMap.isEmpty()) { | ||||
|                                 //给业务员发送消息 | ||||
|                                 Map<String, Object> msgMap = new HashMap<>(); | ||||
|                                 msgMap.put("userId", map.get("staffId") + ""); | ||||
|                                 msgMap.put("newsId", map.get("id")); | ||||
|                                 msgMap.put("type", MessageConfig.TYPE_6); | ||||
|                                 msgMap.put("messageContent", "您分管的客户," + map.get("clientName") + "的货物已经" + map.get("invoiceDate") + "发货,发货单编码为" + map.get("invoiceNo") + ",请您随时关注物流状况"); | ||||
|                                 messageService.add(msgMap); | ||||
|                             } | ||||
|                             if (clientInfoMap != null && !clientInfoMap.isEmpty()) { | ||||
|                                 //给客户发送消息 | ||||
|                                 Map<String, Object> msgMap = new HashMap<>(); | ||||
|                                 msgMap.put("userId", map.get("clientId") + ""); | ||||
|                                 msgMap.put("newsId", map.get("id")); | ||||
|                                 msgMap.put("type", MessageConfig.TYPE_6); | ||||
|                                 msgMap.put("messageContent", "您的货物已经" + map.get("invoiceDate") + "发货,发货单编码为" + map.get("invoiceNo") + ",请您随时关注物流状况,如果收到货后尽快扫描入库"); | ||||
|                                 messageService.add(msgMap); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                 } | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.error("获取U8销售出库单异常:{}", e.getMessage()); | ||||
|             Logs.writeLogs("获取U8销售出库单异常:" + DateUtil.getSdfTimess() + "---" + e.getMessage()); | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue