|  | @@ -0,0 +1,517 @@
 | 
	
		
			
				|  |  | +package org.jeecg.modules.quartz.job;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +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 lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.documents.orderData.entity.SyOrderData;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.documents.orderData.entity.SyOrderDataItem;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.documents.orderData.entity.SyOrderDataVO;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.documents.orderData.service.ISyOrderDataItemService;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.documents.orderData.service.ISyOrderDataService;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.documents.orderData.service.impl.SyOrderDataItemServiceImpl;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.documents.orderData.service.impl.SyOrderDataServiceImpl;
 | 
	
		
			
				|  |  | +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.openApi.service.ISenYuDataSourceThree;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.openApi.service.ISenYuDataSourceTwo;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.system.util.JsonChangeUtils;
 | 
	
		
			
				|  |  | +import org.quartz.*;
 | 
	
		
			
				|  |  | +import org.springframework.beans.BeansException;
 | 
	
		
			
				|  |  | +import org.springframework.context.ApplicationContext;
 | 
	
		
			
				|  |  | +import org.springframework.context.ApplicationContextAware;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | +import java.util.ArrayList;
 | 
	
		
			
				|  |  | +import java.util.Date;
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.Map;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@PersistJobDataAfterExecution
 | 
	
		
			
				|  |  | +@DisallowConcurrentExecution
 | 
	
		
			
				|  |  | +@Slf4j
 | 
	
		
			
				|  |  | +public class AddOrderJob implements Job,ApplicationContextAware {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private static IDxpDataPlanService dxpDataPlanService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private static ISyOrderDataItemService syOrderDataItemService;
 | 
	
		
			
				|  |  | +    private static ISyOrderDataService syOrderDataService;
 | 
	
		
			
				|  |  | +    //数据源one
 | 
	
		
			
				|  |  | +    private static ISenYuDataSourceOne senYuDataSourceOne;
 | 
	
		
			
				|  |  | +    private static ISenYuDataSourceTwo senYuDataSourceTwo;
 | 
	
		
			
				|  |  | +    private static ISenYuDataSourceThree senYuDataSourceThree;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
 | 
	
		
			
				|  |  | +        System.out.println("销售订单拉取U8数据定时任务开始========================》");
 | 
	
		
			
				|  |  | +        //得到系统时间
 | 
	
		
			
				|  |  | +        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);
 | 
	
		
			
				|  |  | +            String toDay = sf.format(day);//若客户单据日期没有具体时间 则要在同步数据前删除这次同步时间段的数据
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            for (String str : pkorgSplit) {
 | 
	
		
			
				|  |  | +                String pkorgStr = str;
 | 
	
		
			
				|  |  | +                String pkorgValue[] = pkorgStr.split(":");
 | 
	
		
			
				|  |  | +                //得到对应的账套
 | 
	
		
			
				|  |  | +                String account = pkorgValue[1];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                /*
 | 
	
		
			
				|  |  | +                SO_SOMain 销售订单数据 单据时间没有详细时间 只有日期
 | 
	
		
			
				|  |  | +                SO_SODetails 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," +
 | 
	
		
			
				|  |  | +                        "t.cSTName AS salesTypeText," +
 | 
	
		
			
				|  |  | +                        "cc.cCusAbbName AS customerAbbreviation," +
 | 
	
		
			
				|  |  | +                        "cc.cCusName AS customerName," +
 | 
	
		
			
				|  |  | +                        "s.iExchRate AS exchangeRate," +
 | 
	
		
			
				|  |  | +                        "de.cDepName AS salesDepartment," +
 | 
	
		
			
				|  |  | +                        "pe.cPersonName  AS salesman," +
 | 
	
		
			
				|  |  | +                        "s.cexch_name AS currencyText," +
 | 
	
		
			
				|  |  | +                        "s.cdefine2 as brandSide," +
 | 
	
		
			
				|  |  | +                        "s.cdefine1 as thirdParty," +
 | 
	
		
			
				|  |  | +                        "s.cdefine3 as customerOrderNumber," +
 | 
	
		
			
				|  |  | +                        "s.cdefine11 as endCustomer," +
 | 
	
		
			
				|  |  | +                        "s.cCusCode as customerCode," +
 | 
	
		
			
				|  |  | +                        "s.fbookratio AS depositRatio," +
 | 
	
		
			
				|  |  | +                        "s.iMoney AS deposit," +
 | 
	
		
			
				|  |  | +                        "s.cMemo AS orderRemarks," +
 | 
	
		
			
				|  |  | +                        "s.cDefine14 AS orderChangeDescription," +
 | 
	
		
			
				|  |  | +                        "s.cDefine12 AS garmentFactory," +
 | 
	
		
			
				|  |  | +                        "v.cVenCode AS garmentFactoryCode,"+
 | 
	
		
			
				|  |  | +                        "s.cDefine5 as garmentNmb," +
 | 
	
		
			
				|  |  | +                        "s.cMemo AS memo," +
 | 
	
		
			
				|  |  | +                        "f.chdefine4 AS priceRemarks," +
 | 
	
		
			
				|  |  | +                        "f.chdefine1 AS collaborativeRoute," +
 | 
	
		
			
				|  |  | +                        "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" +
 | 
	
		
			
				|  |  | +                        " LEFT JOIN Department de ON s.cDepCode = de.cDepCode" +
 | 
	
		
			
				|  |  | +                        " LEFT JOIN Customer cc ON s.cCusCode = cc.cCusCode" +
 | 
	
		
			
				|  |  | +                        " LEFT JOIN Person  pe ON s.cPersonCode = pe.cPersonCode" +
 | 
	
		
			
				|  |  | +                        " left join Vendor v on s.cDefine12=v.cVenName" +
 | 
	
		
			
				|  |  | +                        " where s.iStatus = 1  AND (s.cdefine15 is null or  s.cdefine15 !='1')  order by s.dDate desc ";//and s.dverifysystime > '"+lastTimeSf+"'
 | 
	
		
			
				|  |  | +                List<Map<String, Object>> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +                if(pkorgValue[0].equals("one")){
 | 
	
		
			
				|  |  | +                    list = senYuDataSourceOne.queryForList(sql);
 | 
	
		
			
				|  |  | +                }else if(pkorgValue[0].equals("two")){
 | 
	
		
			
				|  |  | +                    list = senYuDataSourceTwo.queryForList(sql);
 | 
	
		
			
				|  |  | +                }else if(pkorgValue[0].equals("three")){
 | 
	
		
			
				|  |  | +                    list = senYuDataSourceThree.queryForList(sql);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                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 " +
 | 
	
		
			
				|  |  | +                        "s.AutoID AS id," +
 | 
	
		
			
				|  |  | +                        "s.ID AS syOrderDataId," +
 | 
	
		
			
				|  |  | +                        "s.cDefine22 AS itemNumber," +
 | 
	
		
			
				|  |  | +                        "s.dPreDate AS preDeliveryDate," +
 | 
	
		
			
				|  |  | +                        "s.dPreMoDate AS preCompletionDate," +
 | 
	
		
			
				|  |  | +                        "s.cDefine32 AS packId," +
 | 
	
		
			
				|  |  | +                        "s.cDefine28 AS smallPo," +
 | 
	
		
			
				|  |  | +                        "s.cDefine29 AS distributionPoint," +
 | 
	
		
			
				|  |  | +                        "s.cInvCode AS inventoryCode," +
 | 
	
		
			
				|  |  | +                        "c.cInvCcode AS inventoryCcode," +
 | 
	
		
			
				|  |  | +                        "c.cInvName AS inventoryName," +
 | 
	
		
			
				|  |  | +                        "s.cFree1 AS colour," +
 | 
	
		
			
				|  |  | +                        "s.cFree2 AS size," +
 | 
	
		
			
				|  |  | +                        "s.cFree3 AS codingRules," +
 | 
	
		
			
				|  |  | +                        "s.cFree4 AS guangpeiGateWidth," +
 | 
	
		
			
				|  |  | +                        "s.cFree6 AS weight,"+
 | 
	
		
			
				|  |  | +                        "s.cDefine35 AS boxNumber," +
 | 
	
		
			
				|  |  | +                        "s.iQuantity AS quantity," +
 | 
	
		
			
				|  |  | +                        "s.iQuantity AS surplusNum," +
 | 
	
		
			
				|  |  | +                        "s.iTaxUnitPrice AS unitPriceIncludingTax," +
 | 
	
		
			
				|  |  | +                        "s.iSum AS totalPriceAndTax," +
 | 
	
		
			
				|  |  | +                        "s.iTaxRate AS taxRate," +
 | 
	
		
			
				|  |  | +                        "s.cMemo AS remarks ," +
 | 
	
		
			
				|  |  | +                        "d.cComUnitName as masterMetering," +
 | 
	
		
			
				|  |  | +                        "c.cInvStd as specificationAndModel," +
 | 
	
		
			
				|  |  | +                        "case when c.cInvDefine14 is null then 1 else cInvDefine14 end as numberOfSets,"+
 | 
	
		
			
				|  |  | +                        "s.cSCloser as bankClosedBy," +
 | 
	
		
			
				|  |  | +                        "be.cbdefine2 as ymoney"+
 | 
	
		
			
				|  |  | +                        " FROM" +
 | 
	
		
			
				|  |  | +                        " SO_SODetails s" +
 | 
	
		
			
				|  |  | +                        " left join Inventory c on c.cInvCode=s.cInvCode" +
 | 
	
		
			
				|  |  | +                        " left join ComputationUnit d on d.cComunitCode=c.cComUnitCode"+
 | 
	
		
			
				|  |  | +                        " left join SO_SODetails_extradefine be on be.iSOsID=s.iSOsID"+
 | 
	
		
			
				|  |  | +                        " where s.ID = "+ID;
 | 
	
		
			
				|  |  | +                List<Map<String, Object>> listSon = new ArrayList<>();
 | 
	
		
			
				|  |  | +                if(sy.getAccount().equals("901")){
 | 
	
		
			
				|  |  | +                    listSon = senYuDataSourceOne.queryForList(sql);
 | 
	
		
			
				|  |  | +                }else if(sy.getAccount().equals("902")){
 | 
	
		
			
				|  |  | +                    listSon = senYuDataSourceTwo.queryForList(sql);
 | 
	
		
			
				|  |  | +                }else if(sy.getAccount().equals("903")){
 | 
	
		
			
				|  |  | +                    listSon = senYuDataSourceThree.queryForList(sql);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                List<JSONObject> jianSon = JsonChangeUtils.toJSONObject(listSon);
 | 
	
		
			
				|  |  | +                int size = 0;
 | 
	
		
			
				|  |  | +                for (JSONObject Object:jianSon) {
 | 
	
		
			
				|  |  | +                    SyOrderDataItem sy2 = JSONObject.toJavaObject(Object, SyOrderDataItem.class);
 | 
	
		
			
				|  |  | +                    sy2.setId(sy.getAccount()+sy2.getId());
 | 
	
		
			
				|  |  | +                    sy2.setSyOrderDataId(sy.getAccount()+sy2.getSyOrderDataId());
 | 
	
		
			
				|  |  | +                    SyOrderDataVO ordervo = queryOrder(sy2.getId());
 | 
	
		
			
				|  |  | +                    if(ordervo != null){
 | 
	
		
			
				|  |  | +                        sy2.setOmpoAccount(ordervo.getOmpoAccount());
 | 
	
		
			
				|  |  | +                        sy2.setOmpoCode(ordervo.getOmpoCode());
 | 
	
		
			
				|  |  | +                        sy2.setOmpoId(ordervo.getOmpoId());
 | 
	
		
			
				|  |  | +                        sy2.setOmpoIdItem(ordervo.getOmpoIdItem());
 | 
	
		
			
				|  |  | +                        sy2.setITaxPrice(ordervo.getITaxPrice());
 | 
	
		
			
				|  |  | +                        sy2.setGuangpeiGateWidth(ordervo.getGuangpeiGateWidth());
 | 
	
		
			
				|  |  | +                        sy2.setSupplier(ordervo.getSupplier());
 | 
	
		
			
				|  |  | +                        if(sy2.getInventoryCcode().substring(0,2).equals("09")){
 | 
	
		
			
				|  |  | +                            sy2.setGarmentFactory(ordervo.getSupplier());
 | 
	
		
			
				|  |  | +                        }else if(sy.getCustomerAbbreviation().equals("森语集团") || sy.getCustomerAbbreviation().equals("宁波森语") ) {
 | 
	
		
			
				|  |  | +                            sy2.setGarmentFactory(queryGSupplier(sy.getOrderNumber(),sy.getAccount(),sy.getCustomerCode()));
 | 
	
		
			
				|  |  | +                        }else {
 | 
	
		
			
				|  |  | +                            sy2.setGarmentFactory(sy.getGarmentFactory());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        sy2.setSupplierCode(ordervo.getSupplierCode());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if(sy2.getOmpoIdItem()==null || sy2.getOmpoIdItem().equals("")){
 | 
	
		
			
				|  |  | +                        continue;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if(sy2.getOmpoIdItem()!=null && sy.getAccount()!=null){
 | 
	
		
			
				|  |  | +                        List<String> rsup = queryRSupplier(sy2.getOmpoIdItem(),sy.getAccount());
 | 
	
		
			
				|  |  | +                        if(rsup.size()>0){
 | 
	
		
			
				|  |  | +                            sy2.setRSupplierCode(rsup.get(0));
 | 
	
		
			
				|  |  | +                            sy2.setRSupplier(rsup.get(1));
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    syOrderDataItemService.save(sy2);
 | 
	
		
			
				|  |  | +                    size++;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if(size<=0){
 | 
	
		
			
				|  |  | +                    continue;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                //添加主表数据进入数据库
 | 
	
		
			
				|  |  | +                String syId = sy.getId();
 | 
	
		
			
				|  |  | +                sy.setId(sy.getAccount()+sy.getId());
 | 
	
		
			
				|  |  | +                syOrderDataService.save(sy);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                String blackWrite = "UPDATE SO_SOMain SET cdefine15 = '1' WHERE id='"+syId+"'";
 | 
	
		
			
				|  |  | +                if(sy.getAccount().equals("901")){
 | 
	
		
			
				|  |  | +                    senYuDataSourceOne.update(blackWrite);
 | 
	
		
			
				|  |  | +                }else if(sy.getAccount().equals("902")){
 | 
	
		
			
				|  |  | +                    senYuDataSourceTwo.update(blackWrite);
 | 
	
		
			
				|  |  | +                }else if(sy.getAccount().equals("903")){
 | 
	
		
			
				|  |  | +                    senYuDataSourceThree.update(blackWrite);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            dxpDataPlanService.updateLastTime(day,"senYu_syOrder");
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            System.out.print("jian:更新失败");
 | 
	
		
			
				|  |  | +            e.printStackTrace();
 | 
	
		
			
				|  |  | +            log.error(e.getMessage());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /*
 | 
	
		
			
				|  |  | +     * 查询成衣工厂  (面辅料供应商编码 面辅料供应商名称)
 | 
	
		
			
				|  |  | +     * */
 | 
	
		
			
				|  |  | +    public String queryGSupplier(String soCode,String zhangtao,String customerCode){
 | 
	
		
			
				|  |  | +        /*
 | 
	
		
			
				|  |  | +        查询账套用于判断
 | 
	
		
			
				|  |  | +         */
 | 
	
		
			
				|  |  | +        QueryWrapper<DxpDataPlan> queryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +        queryWrapper.eq("code", "senYu_syOrder");
 | 
	
		
			
				|  |  | +        List<DxpDataPlan> pageList = dxpDataPlanService.list(queryWrapper);
 | 
	
		
			
				|  |  | +        String pkorg = pageList.get(0).getPkOrg();
 | 
	
		
			
				|  |  | +        String pkorgSplit[] = pkorg.split(",");
 | 
	
		
			
				|  |  | +        //定义账套集合
 | 
	
		
			
				|  |  | +        String account[] = new String[3];
 | 
	
		
			
				|  |  | +        int index = 0;
 | 
	
		
			
				|  |  | +        //得到对应的账套
 | 
	
		
			
				|  |  | +        for (String str : pkorgSplit) {
 | 
	
		
			
				|  |  | +            String pkorgValue[] = str.split(":");
 | 
	
		
			
				|  |  | +            account[index] = pkorgValue[1];
 | 
	
		
			
				|  |  | +            index++;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String resql = " select max(ss.cSOCode) as soCode from  PO_Podetails t  " +
 | 
	
		
			
				|  |  | +                "  left join PO_Pomain m  on m.poid=t.poid " +
 | 
	
		
			
				|  |  | +                "  left join SO_SODetails s on s.isosid=t.iorderdid " +
 | 
	
		
			
				|  |  | +                " left join SO_SOMain ss on ss.id=s.id " +
 | 
	
		
			
				|  |  | +                "  where m.cpoid = '"+soCode+"'";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<Map<String, Object>> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +        if(zhangtao.equals(account[2]) && customerCode.equals("T020001")){
 | 
	
		
			
				|  |  | +            list = senYuDataSourceThree.queryForList(resql);
 | 
	
		
			
				|  |  | +            List<JSONObject> jSONObject = JsonChangeUtils.toJSONObject(list);
 | 
	
		
			
				|  |  | +            if(jSONObject.size()>0){
 | 
	
		
			
				|  |  | +                for (JSONObject json:jSONObject) {
 | 
	
		
			
				|  |  | +                    soCode = json.get("soCode").toString();
 | 
	
		
			
				|  |  | +                    zhangtao = account[0];
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String sql = "SELECT max(v.cVenName) as cVenName from OM_MOMain m right join OM_MODetails t on m.moid = t.moid " +
 | 
	
		
			
				|  |  | +                "  left join Vendor v on m.cVenCode=v.cVenCode " +
 | 
	
		
			
				|  |  | +                "  where t.isosid=( select max(s.isosid) from  PO_Podetails t  " +
 | 
	
		
			
				|  |  | +                "  left join PO_Pomain m  on m.poid=t.poid " +
 | 
	
		
			
				|  |  | +                "  left join SO_SODetails s on s.isosid=t.iorderdid " +
 | 
	
		
			
				|  |  | +                "  where m.cpoid = '"+soCode+"') ";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if(zhangtao.equals(account[0])){
 | 
	
		
			
				|  |  | +            list = senYuDataSourceOne.queryForList(sql);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<JSONObject> jSONObject = JsonChangeUtils.toJSONObject(list);
 | 
	
		
			
				|  |  | +        String result = "";
 | 
	
		
			
				|  |  | +        if(jSONObject.size()>0){
 | 
	
		
			
				|  |  | +            for (JSONObject json:jSONObject) {
 | 
	
		
			
				|  |  | +                result=json.get("cVenName").toString();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /*
 | 
	
		
			
				|  |  | +     * 查询染厂供应商编码 供应商名称
 | 
	
		
			
				|  |  | +     * */
 | 
	
		
			
				|  |  | +    public List<String>  queryRSupplier(String id,String zhangtao){
 | 
	
		
			
				|  |  | +        /*
 | 
	
		
			
				|  |  | +        查询账套用于判断
 | 
	
		
			
				|  |  | +         */
 | 
	
		
			
				|  |  | +        QueryWrapper<DxpDataPlan> queryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +        queryWrapper.eq("code", "senYu_syOrder");
 | 
	
		
			
				|  |  | +        List<DxpDataPlan> pageList = dxpDataPlanService.list(queryWrapper);
 | 
	
		
			
				|  |  | +        String pkorg = pageList.get(0).getPkOrg();
 | 
	
		
			
				|  |  | +        String pkorgSplit[] = pkorg.split(",");
 | 
	
		
			
				|  |  | +        //定义账套集合
 | 
	
		
			
				|  |  | +        String account[] = new String[3];
 | 
	
		
			
				|  |  | +        int index = 0;
 | 
	
		
			
				|  |  | +        //得到对应的账套
 | 
	
		
			
				|  |  | +        for (String str : pkorgSplit) {
 | 
	
		
			
				|  |  | +            String pkorgValue[] = str.split(":");
 | 
	
		
			
				|  |  | +            account[index] = pkorgValue[1];
 | 
	
		
			
				|  |  | +            index++;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String sql = "select om.cVenCode as cVenCode,v.cVenName as cVenName From OM_MODetails  o " +
 | 
	
		
			
				|  |  | +                "join ( " +
 | 
	
		
			
				|  |  | +                " select ommos.isosid,ommom.cInvCode from  " +
 | 
	
		
			
				|  |  | +                " OM_MODetails ommos  " +
 | 
	
		
			
				|  |  | +                "left join OM_MOMaterials ommom on ommom.MoDetailsID=ommos.MODetailsID  " +
 | 
	
		
			
				|  |  | +                "where ommos.MODetailsID = '"+id+"' " +
 | 
	
		
			
				|  |  | +                ")tab on tab.isosid=o.isosid and tab.cInvCode =o.cInvCode  " +
 | 
	
		
			
				|  |  | +                "left join OM_MOMain om on om.moid=o.moid " +
 | 
	
		
			
				|  |  | +                "LEFT JOIN Vendor v ON om.cVenCode=v.cVenCode " +
 | 
	
		
			
				|  |  | +                "union " +
 | 
	
		
			
				|  |  | +                "select om.cVenCode as cVenCode,v.cVenName as cVenName From PO_Podetails  o " +
 | 
	
		
			
				|  |  | +                "join ( " +
 | 
	
		
			
				|  |  | +                " select ommos.isosid,ommom.cInvCode from  " +
 | 
	
		
			
				|  |  | +                " OM_MODetails ommos  " +
 | 
	
		
			
				|  |  | +                "left join OM_MOMaterials ommom on ommom.MoDetailsID=ommos.MODetailsID  " +
 | 
	
		
			
				|  |  | +                "where ommos.MODetailsID = '"+id+"' " +
 | 
	
		
			
				|  |  | +                ")tab on tab.isosid=o.isosid and tab.cInvCode =o.cInvCode  " +
 | 
	
		
			
				|  |  | +                "left join PO_Pomain om on om.POID=o.POID " +
 | 
	
		
			
				|  |  | +                "LEFT JOIN Vendor v ON om.cVenCode=v.cVenCode";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<Map<String, Object>> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +        if(zhangtao.equals(account[0])){
 | 
	
		
			
				|  |  | +            list = senYuDataSourceOne.queryForList(sql);
 | 
	
		
			
				|  |  | +        }else if(zhangtao.equals(account[1])){
 | 
	
		
			
				|  |  | +            list = senYuDataSourceTwo.queryForList(sql);
 | 
	
		
			
				|  |  | +        }else if(zhangtao.equals(account[2])){
 | 
	
		
			
				|  |  | +            list = senYuDataSourceThree.queryForList(sql);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<JSONObject> jSONObject = JsonChangeUtils.toJSONObject(list);
 | 
	
		
			
				|  |  | +        List<String> result = new ArrayList<>();
 | 
	
		
			
				|  |  | +        if(jSONObject.size()>0){
 | 
	
		
			
				|  |  | +            for (JSONObject json:jSONObject) {
 | 
	
		
			
				|  |  | +                result.add(json.get("cVenCode").toString());
 | 
	
		
			
				|  |  | +                result.add(json.get("cVenName").toString());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /*
 | 
	
		
			
				|  |  | +   查询最终供应商数据
 | 
	
		
			
				|  |  | +    */
 | 
	
		
			
				|  |  | +    public SyOrderDataVO queryOrder(String orderItemID) throws Exception{
 | 
	
		
			
				|  |  | +        SyOrderDataVO syOrderDataVO = new SyOrderDataVO();
 | 
	
		
			
				|  |  | +        syOrderDataVO.setId(orderItemID);
 | 
	
		
			
				|  |  | +        List<Map<String, Object>> listSon = new ArrayList<>();
 | 
	
		
			
				|  |  | +        SyOrderDataVO result = new SyOrderDataVO();
 | 
	
		
			
				|  |  | +        /*
 | 
	
		
			
				|  |  | +        查询账套用于判断
 | 
	
		
			
				|  |  | +         */
 | 
	
		
			
				|  |  | +        QueryWrapper<DxpDataPlan> queryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +        queryWrapper.eq("code", "senYu_syOrder");
 | 
	
		
			
				|  |  | +        List<DxpDataPlan> pageList = dxpDataPlanService.list(queryWrapper);
 | 
	
		
			
				|  |  | +        String pkorg = pageList.get(0).getPkOrg();
 | 
	
		
			
				|  |  | +        String pkorgSplit[] = pkorg.split(",");
 | 
	
		
			
				|  |  | +        //定义账套集合
 | 
	
		
			
				|  |  | +        String account[] = new String[4];
 | 
	
		
			
				|  |  | +        int index = 0;
 | 
	
		
			
				|  |  | +        //得到对应的账套
 | 
	
		
			
				|  |  | +        for (String str : pkorgSplit) {
 | 
	
		
			
				|  |  | +            String pkorgValue[] = str.split(":");
 | 
	
		
			
				|  |  | +            account[index] = pkorgValue[1];
 | 
	
		
			
				|  |  | +            index++;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        /*
 | 
	
		
			
				|  |  | +        对应账套取对应的值
 | 
	
		
			
				|  |  | +         */
 | 
	
		
			
				|  |  | +        if(account[0].equals(syOrderDataVO.getAccount())){
 | 
	
		
			
				|  |  | +            String sql = "  SELECT" +
 | 
	
		
			
				|  |  | +                    " ompoCode,ompoIdItem,ompoId,supplierCode,v.cVenAbbName as supplier,iTaxPrice,guangpeiGateWidth," +account[0]+" as ompoAccount"+
 | 
	
		
			
				|  |  | +                    " FROM" +
 | 
	
		
			
				|  |  | +                    " SO_SODetails s" +
 | 
	
		
			
				|  |  | +                    " left join (" +
 | 
	
		
			
				|  |  | +                    " SELECT om.cCode as ompoCode,om.MOID as ompoId,od.MODetailsID as ompoIdItem," +
 | 
	
		
			
				|  |  | +                    " od.cDefine23  as guangpeiGateWidth,"+
 | 
	
		
			
				|  |  | +                    " om.cVenCode as supplierCode,od.iTaxPrice,od.cInvCode,od.isosid" +
 | 
	
		
			
				|  |  | +                    " FROM OM_MOMain om" +
 | 
	
		
			
				|  |  | +                    " LEFT JOIN  OM_MODetails  od on om.MOID =od.MOID" +
 | 
	
		
			
				|  |  | +                    " where om.cState = 1" +
 | 
	
		
			
				|  |  | +                    ") p on s.isosid  = p.isosid and s.cInvCode = p.cInvCode" +
 | 
	
		
			
				|  |  | +                    " left join Vendor v on p.supplierCode=v.cVenCode" +
 | 
	
		
			
				|  |  | +                    " where s.autoid ="+syOrderDataVO.getId();
 | 
	
		
			
				|  |  | +            listSon = senYuDataSourceOne.queryForList(sql);
 | 
	
		
			
				|  |  | +            List<JSONObject> jian = JsonChangeUtils.toJSONObject(listSon);
 | 
	
		
			
				|  |  | +            for (JSONObject jsonObject:jian) {
 | 
	
		
			
				|  |  | +                result = JSONObject.toJavaObject(jsonObject, SyOrderDataVO.class);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return result;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        }else if(account[1].equals(syOrderDataVO.getAccount())){
 | 
	
		
			
				|  |  | +            String sql = "SELECT" +
 | 
	
		
			
				|  |  | +                    " ompoCode,ompoIdItem,ompoId,supplierCode,v.cVenAbbName as supplier,iTaxPrice,guangpeiGateWidth," +account[1]+" as ompoAccount"+
 | 
	
		
			
				|  |  | +                    " FROM" +
 | 
	
		
			
				|  |  | +                    " SO_SODetails s" +
 | 
	
		
			
				|  |  | +                    " left join (" +
 | 
	
		
			
				|  |  | +                    " SELECT pm.cPOID as ompoCode,pm.POID as ompoId,pd.id as ompoIdItem,pd.irowno as poIrowno,"+
 | 
	
		
			
				|  |  | +                    " pd.cDefine23  as guangpeiGateWidth,"+
 | 
	
		
			
				|  |  | +                    " pm.cVenCode as supplierCode,pd.iTaxPrice,pd.cInvCode,pd.iorderdid as isosid" +
 | 
	
		
			
				|  |  | +                    " FROM PO_Pomain pm" +
 | 
	
		
			
				|  |  | +                    " LEFT JOIN  PO_Podetails pd on pm.POID=pd.POID" +
 | 
	
		
			
				|  |  | +                    " where pm.cState = 1" +
 | 
	
		
			
				|  |  | +                    ") p on s.isosid  = p.isosid and s.cInvCode = p.cInvCode" +
 | 
	
		
			
				|  |  | +                    " left join Vendor v on p.supplierCode=v.cVenCode"+
 | 
	
		
			
				|  |  | +                    " where s.autoid ="+syOrderDataVO.getId();
 | 
	
		
			
				|  |  | +            List<Map<String, Object>> list = senYuDataSourceTwo.queryForList(sql);
 | 
	
		
			
				|  |  | +            List<JSONObject> jian = JsonChangeUtils.toJSONObject(list);
 | 
	
		
			
				|  |  | +            for (JSONObject jsonObject:jian) {
 | 
	
		
			
				|  |  | +                result = JSONObject.toJavaObject(jsonObject, SyOrderDataVO.class);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if(result.getSupplier()==null){
 | 
	
		
			
				|  |  | +                return result;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if(!result.getSupplier().equals("马菲羊")){
 | 
	
		
			
				|  |  | +                return result;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            String sql2 = "SELECT" +
 | 
	
		
			
				|  |  | +                    " ompoCode,ompoIdItem,ompoId,supplierCode,v.cVenAbbName as supplier,iTaxPrice,guangpeiGateWidth," +account[2]+" as ompoAccount"+
 | 
	
		
			
				|  |  | +                    " FROM" +
 | 
	
		
			
				|  |  | +                    " SO_SODetails s" +
 | 
	
		
			
				|  |  | +                    " left join (" +
 | 
	
		
			
				|  |  | +                    " SELECT pm.cPOID as ompoCode,pm.POID as ompoId,pd.id as ompoIdItem," +
 | 
	
		
			
				|  |  | +                    " pd.cDefine23  as guangpeiGateWidth,"+
 | 
	
		
			
				|  |  | +                    " pm.cVenCode as supplierCode,pd.iTaxPrice,pd.cInvCode,pd.iorderdid as isosid" +
 | 
	
		
			
				|  |  | +                    " FROM PO_Pomain pm" +
 | 
	
		
			
				|  |  | +                    " LEFT JOIN  PO_Podetails pd on pm.POID=pd.POID" +
 | 
	
		
			
				|  |  | +                    " where pm.cState = 1" +
 | 
	
		
			
				|  |  | +                    " UNION" +
 | 
	
		
			
				|  |  | +                    " SELECT om.cCode as ompoCode,om.MOID as ompoId,od.MODetailsID as ompoIdItem," +
 | 
	
		
			
				|  |  | +                    " od.cDefine23  as guangpeiGateWidth,"+
 | 
	
		
			
				|  |  | +                    " om.cVenCode as supplierCode,od.iTaxPrice,od.cInvCode,od.isosid" +
 | 
	
		
			
				|  |  | +                    " FROM OM_MOMain om" +
 | 
	
		
			
				|  |  | +                    " LEFT JOIN  OM_MODetails  od on om.MOID =od.MOID" +
 | 
	
		
			
				|  |  | +                    " where om.cState = 1" +
 | 
	
		
			
				|  |  | +                    " ) p on s.isosid  = p.isosid and s.cInvCode = p.cInvCode" +
 | 
	
		
			
				|  |  | +                    " left join Vendor v on p.supplierCode=v.cVenCode"+
 | 
	
		
			
				|  |  | +                    " where s.iRowNo ="+syOrderDataVO.getPoIrowno();
 | 
	
		
			
				|  |  | +            listSon = senYuDataSourceThree.queryForList(sql2);
 | 
	
		
			
				|  |  | +            List<JSONObject> jian2 = JsonChangeUtils.toJSONObject(listSon);
 | 
	
		
			
				|  |  | +            for (JSONObject jsonObject:jian2) {
 | 
	
		
			
				|  |  | +                result = JSONObject.toJavaObject(jsonObject, SyOrderDataVO.class);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return result;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        }else if(account[2].equals(syOrderDataVO.getAccount())){
 | 
	
		
			
				|  |  | +            String sql = "SELECT" +
 | 
	
		
			
				|  |  | +                    " ompoCode,ompoIdItem,ompoId,supplierCode,v.cVenAbbName as supplier,iTaxPrice,guangpeiGateWidth," +account[2]+" as ompoAccount"+
 | 
	
		
			
				|  |  | +                    " FROM" +
 | 
	
		
			
				|  |  | +                    " SO_SODetails s" +
 | 
	
		
			
				|  |  | +                    " left join (" +
 | 
	
		
			
				|  |  | +                    " SELECT pm.cPOID as ompoCode,pm.POID as ompoId,pd.id as ompoIdItem," +
 | 
	
		
			
				|  |  | +                    " pd.cDefine23  as guangpeiGateWidth,"+
 | 
	
		
			
				|  |  | +                    " pm.cVenCode as supplierCode,pd.iTaxPrice,pd.cInvCode,pd.iorderdid as isosid" +
 | 
	
		
			
				|  |  | +                    " FROM PO_Pomain pm" +
 | 
	
		
			
				|  |  | +                    " LEFT JOIN  PO_Podetails pd on pm.POID=pd.POID" +
 | 
	
		
			
				|  |  | +                    " where pm.cState = 1" +
 | 
	
		
			
				|  |  | +                    " UNION" +
 | 
	
		
			
				|  |  | +                    " SELECT om.cCode as ompoCode,om.MOID as ompoId,od.MODetailsID as ompoIdItem," +
 | 
	
		
			
				|  |  | +                    " od.cDefine23  as guangpeiGateWidth,"+
 | 
	
		
			
				|  |  | +                    " om.cVenCode as supplierCode,od.iTaxPrice,od.cInvCode,od.isosid" +
 | 
	
		
			
				|  |  | +                    " FROM OM_MOMain om" +
 | 
	
		
			
				|  |  | +                    " LEFT JOIN  OM_MODetails  od on om.MOID =od.MOID" +
 | 
	
		
			
				|  |  | +                    " where om.cState = 1" +
 | 
	
		
			
				|  |  | +                    ") p on s.isosid  = p.isosid and s.cInvCode = p.cInvCode" +
 | 
	
		
			
				|  |  | +                    " left join Vendor v on p.supplierCode=v.cVenCode"+
 | 
	
		
			
				|  |  | +                    " where s.autoid ="+syOrderDataVO.getId();
 | 
	
		
			
				|  |  | +            listSon = senYuDataSourceThree.queryForList(sql);
 | 
	
		
			
				|  |  | +            List<JSONObject> jian = JsonChangeUtils.toJSONObject(listSon);
 | 
	
		
			
				|  |  | +            for (JSONObject jsonObject:jian) {
 | 
	
		
			
				|  |  | +                result = JSONObject.toJavaObject(jsonObject, SyOrderDataVO.class);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return result;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return null;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        this.dxpDataPlanService = applicationContext.getBean(IDxpDataPlanService.class);
 | 
	
		
			
				|  |  | +        this.senYuDataSourceOne = applicationContext.getBean(ISenYuDataSourceOne.class);
 | 
	
		
			
				|  |  | +        this.senYuDataSourceTwo = applicationContext.getBean(ISenYuDataSourceTwo.class);
 | 
	
		
			
				|  |  | +        this.senYuDataSourceThree = applicationContext.getBean(ISenYuDataSourceThree.class);
 | 
	
		
			
				|  |  | +        this.syOrderDataItemService = applicationContext.getBean(SyOrderDataItemServiceImpl.class);
 | 
	
		
			
				|  |  | +        this.syOrderDataService = applicationContext.getBean(SyOrderDataServiceImpl.class);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 |