|
@@ -1,11 +1,32 @@
|
|
|
package org.jeecg.modules.documents.orderData.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.jeecg.modules.documents.orderData.entity.SyOrderData;
|
|
|
+import org.jeecg.modules.documents.orderData.entity.SyOrderDataItem;
|
|
|
import org.jeecg.modules.documents.orderData.mapper.SyOrderDataMapper;
|
|
|
+import org.jeecg.modules.documents.orderData.service.ISyOrderDataItemService;
|
|
|
import org.jeecg.modules.documents.orderData.service.ISyOrderDataService;
|
|
|
+import org.jeecg.modules.openApi.entity.DxpDataPlan;
|
|
|
+import org.jeecg.modules.openApi.service.IDxpDataPlanService;
|
|
|
+import org.jeecg.modules.openApi.service.ISenYuDataSourceOne;
|
|
|
+import org.jeecg.modules.system.util.JsonChangeUtils;
|
|
|
+import org.springframework.beans.BeansException;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.context.ApplicationContextAware;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description: 订单主表
|
|
@@ -14,6 +35,138 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
* @Version: V1.0
|
|
|
*/
|
|
|
@Service
|
|
|
-public class SyOrderDataServiceImpl extends ServiceImpl<SyOrderDataMapper, SyOrderData> implements ISyOrderDataService {
|
|
|
+@Transactional
|
|
|
+public class SyOrderDataServiceImpl extends ServiceImpl<SyOrderDataMapper, SyOrderData> implements ISyOrderDataService, ApplicationContextAware {
|
|
|
+
|
|
|
+ private static IDxpDataPlanService dxpDataPlanService;
|
|
|
+
|
|
|
+ private static ISyOrderDataItemService syOrderDataItemService;
|
|
|
+ //数据源one
|
|
|
+ private static ISenYuDataSourceOne senYuDataSourceOne;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doQuerySyOrder() {
|
|
|
+ QuerySyOrder();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 51 9 * * ?")
|
|
|
+ public JSONObject QuerySyOrder() {
|
|
|
+ //得到系统时间
|
|
|
+ Date day=new Date();
|
|
|
+ //传出JSON
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ //定义集合
|
|
|
+ List<Map<String, Object>> sumlist = new ArrayList<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ //查询IP及账套信息、时间戳
|
|
|
+ QueryWrapper<DxpDataPlan> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("code", "senYu_syOrder");
|
|
|
+ Page<DxpDataPlan> page = new Page<DxpDataPlan>(1, 100);
|
|
|
+
|
|
|
+ IPage<DxpDataPlan> pageList = dxpDataPlanService.page(page, queryWrapper);
|
|
|
+ List<DxpDataPlan> resultList = pageList.getRecords();
|
|
|
+ String pkorg = resultList.get(0).getPkOrg();
|
|
|
+ String pkorgSplit[] = pkorg.split(",");
|
|
|
+ Date lastTiem = resultList.get(0).getLastTime();
|
|
|
+ SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String lastTimeSf = sf.format(lastTiem);
|
|
|
+
|
|
|
+ for (String str : pkorgSplit) {
|
|
|
+ String pkorgStr = str;
|
|
|
+ String pkorgValue[] = pkorgStr.split(":");
|
|
|
+ //得到对应的账套
|
|
|
+ String account = pkorgValue[1];
|
|
|
+
|
|
|
+ /*SO_SODetails SO_SOMain
|
|
|
+ String sql = "select top 3 ID as id,cSOCode as orderNumber,dDate as orderDate,cBusType as businessTypeValue,cCusCode as customerName," +
|
|
|
+ "cPersonCode as salesman,cDepCode as salesDepartment,cexch_name as currencyValue,fbookratio as depositRatio," +
|
|
|
+ "iMoney as deposit,cMemo as memo from SO_SOMain";*/
|
|
|
+
|
|
|
+ String sql = "SELECT " +
|
|
|
+ "s.ID AS id," +
|
|
|
+ "s.cSOCode AS orderNumber," +
|
|
|
+ "s.dDate AS orderDate," +
|
|
|
+ "s.cBusType AS businessTypeValue," +
|
|
|
+ "s.cSTCode AS salesTypeValue," +
|
|
|
+ "s.cCusCode AS customerAbbreviation," +
|
|
|
+ "s.cCusName AS customerName," +
|
|
|
+ "s.iExchRate AS exchangeRate," +
|
|
|
+ "s.cDepCode AS salesDepartment," +
|
|
|
+ "s.cCrmpersonName AS salesman," +
|
|
|
+ "s.cexch_name AS currencyText," +
|
|
|
+ "s.fbookratio AS depositRatio," +
|
|
|
+ "s.iMoney AS deposit," +
|
|
|
+ "s.cMemo AS orderRemarks," +
|
|
|
+ "s.cDefine14 AS orderChangeDescription," +
|
|
|
+ "s.cDefine12 AS garmentFactory," +
|
|
|
+ "s.cMemo AS memo," +
|
|
|
+ "f.chdefine4 as priceRemarks," +
|
|
|
+ "f.chdefine1 as collaborativeRoute," +
|
|
|
+ "t.cSTName as salesTypeText," +
|
|
|
+ "y.cexch_code as currencyValue," +
|
|
|
+ "p.cPayName as termOfPayment," +account+
|
|
|
+ " as account" +
|
|
|
+ " from SO_SOMain s" +
|
|
|
+ " left join SO_SOMain_extradefine f on s.ID = f.ID" +
|
|
|
+ " left join SaleType t on s.cSTCode = t.cSTCode" +
|
|
|
+ " left join foreigncurrency y on s.cexch_name = y.cexch_name" +
|
|
|
+ " left join PayCondition p on s.cPayCode = p.cPayCode where s.dDate > '"+lastTimeSf+"'";
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ if(pkorgValue[0].equals("one")){
|
|
|
+ list = senYuDataSourceOne.queryForList(sql);
|
|
|
+ System.out.println("========================="+list.size());
|
|
|
+ }else if(pkorgValue[0].equals("two")){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for(Map<String, Object> map:list){
|
|
|
+ sumlist.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<JSONObject> jian = JsonChangeUtils.toJSONObject(sumlist);
|
|
|
+ for (JSONObject jsonObject:jian) {
|
|
|
+ SyOrderData sy = JSONObject.toJavaObject(jsonObject,SyOrderData.class);
|
|
|
+ String ID = sy.getId();
|
|
|
+ String sql = "SELECT " +
|
|
|
+ "AutoID as id,ID as syOrderDataId,cDefine22 as itemNumber,dPreDate as preDeliveryDate," +
|
|
|
+ "dPreMoDate as preCompletionDate,cDefine32 as packId,cDefine28 as smallPo,cDefine29 as distributionPoint," +
|
|
|
+ "cInvCode as inventoryCode,cInvName as inventoryName,cFree1 as colour,cFree2 as size,cFree3 as codingRules," +
|
|
|
+ "cFree4 as guangpeiGateWidth,cDefine35 as boxNumber,iQuantity as quantity,iQuantity as surplusNum," +
|
|
|
+ "iTaxUnitPrice as unitPriceIncludingTax,iSum as totalPriceAndTax,iTaxRate as taxRate," +
|
|
|
+ "cMemo as remarks" +
|
|
|
+ " FROM SO_SODetails where ID = "+ID;
|
|
|
+
|
|
|
+ List<Map<String, Object>> listSon = new ArrayList<>();
|
|
|
+ if(sy.getAccount().equals("903")){
|
|
|
+ listSon = senYuDataSourceOne.queryForList(sql);
|
|
|
+ }else if(sy.getAccount().equals("888")){
|
|
|
+
|
|
|
+ }
|
|
|
+ List<JSONObject> jianSon = JsonChangeUtils.toJSONObject(listSon);
|
|
|
+ for (JSONObject Object:jianSon) {
|
|
|
+ SyOrderDataItem sy2 = JSONObject.toJavaObject(Object, SyOrderDataItem.class);
|
|
|
+ syOrderDataItemService.save(sy2);
|
|
|
+ }
|
|
|
+ //添加主表数据进入数据库
|
|
|
+ save(sy);
|
|
|
+ }
|
|
|
+ dxpDataPlanService.updateLastTime(day,"senYu_syOrder");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
|
+
|
|
|
+ this.dxpDataPlanService = applicationContext.getBean(IDxpDataPlanService.class);
|
|
|
+ this.senYuDataSourceOne = applicationContext.getBean(ISenYuDataSourceOne.class);
|
|
|
+ this.syOrderDataItemService = applicationContext.getBean(SyOrderDataItemServiceImpl.class);
|
|
|
|
|
|
+ }
|
|
|
}
|