|  | @@ -0,0 +1,163 @@
 | 
											
												
													
														|  | 
 |  | +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.extension.service.impl.ServiceImpl;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.documents.orderData.entity.SyOrderData;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.documents.orderData.entity.SyOrderDataVO;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.documents.orderData.mapper.SyGetOrderMapper;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.documents.orderData.service.ISyGetOrderService;
 | 
											
												
													
														|  | 
 |  | +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.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 java.util.ArrayList;
 | 
											
												
													
														|  | 
 |  | +import java.util.List;
 | 
											
												
													
														|  | 
 |  | +import java.util.Map;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +@Service
 | 
											
												
													
														|  | 
 |  | +public class SyGetOrderServiceImpl extends ServiceImpl<SyGetOrderMapper, SyOrderDataVO> implements ISyGetOrderService, ApplicationContextAware {
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private static IDxpDataPlanService dxpDataPlanService;
 | 
											
												
													
														|  | 
 |  | +    private static SyGetOrderMapper syGetOrderMapper;
 | 
											
												
													
														|  | 
 |  | +    private static ISenYuDataSourceOne senYuDataSourceOne;
 | 
											
												
													
														|  | 
 |  | +    private static ISenYuDataSourceTwo senYuDataSourceTwo;
 | 
											
												
													
														|  | 
 |  | +    private static ISenYuDataSourceThree senYuDataSourceThree;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    public SyOrderDataVO queryOrder(String orderItemID){
 | 
											
												
													
														|  | 
 |  | +        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" +
 | 
											
												
													
														|  | 
 |  | +                    " ompoId,ompoIdItem,ompoId,supplierCode,v.cVenAbbName as supplier,iTaxPrice" +
 | 
											
												
													
														|  | 
 |  | +                    " FROM" +
 | 
											
												
													
														|  | 
 |  | +                    " SO_SODetails s" +
 | 
											
												
													
														|  | 
 |  | +                    " left join (" +
 | 
											
												
													
														|  | 
 |  | +                    " SELECT om.cCode as ompoCode,om.MOID as ompoId,od.MODetailsID as ompoIdItem," +
 | 
											
												
													
														|  | 
 |  | +                    " 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);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        }else if(account[1].equals(syOrderDataVO.getAccount())){
 | 
											
												
													
														|  | 
 |  | +            String sql = "SELECT" +
 | 
											
												
													
														|  | 
 |  | +                    " ompoId,ompoIdItem,ompoId,supplierCode,v.cVenAbbName as supplier,iTaxPrice" +
 | 
											
												
													
														|  | 
 |  | +                    " FROM" +
 | 
											
												
													
														|  | 
 |  | +                    " SO_SODetails s" +
 | 
											
												
													
														|  | 
 |  | +                    " left join (" +
 | 
											
												
													
														|  | 
 |  | +                    " SELECT pm.cPOID as ompoCode,pm.POID as ompoId,pd.id as ompoIdItem,pd.irowno as poIrowno," +
 | 
											
												
													
														|  | 
 |  | +                    " 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().equals("马菲羊")){
 | 
											
												
													
														|  | 
 |  | +                return result;
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            String sql2 = "SELECT" +
 | 
											
												
													
														|  | 
 |  | +                    " ompoId,ompoIdItem,ompoId,supplierCode,v.cVenAbbName as supplier,iTaxPrice" +
 | 
											
												
													
														|  | 
 |  | +                    " FROM" +
 | 
											
												
													
														|  | 
 |  | +                    " SO_SODetails s" +
 | 
											
												
													
														|  | 
 |  | +                    " left join (" +
 | 
											
												
													
														|  | 
 |  | +                    " SELECT pm.cPOID as ompoCode,pm.POID as ompoId,pd.id as ompoIdItem," +
 | 
											
												
													
														|  | 
 |  | +                    " 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," +
 | 
											
												
													
														|  | 
 |  | +                    " 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);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        }else if(account[2].equals(syOrderDataVO.getAccount())){
 | 
											
												
													
														|  | 
 |  | +            String sql = "SELECT" +
 | 
											
												
													
														|  | 
 |  | +                    " ompoId,ompoIdItem,ompoId,supplierCode,v.cVenAbbName as supplier,iTaxPrice" +
 | 
											
												
													
														|  | 
 |  | +                    " FROM" +
 | 
											
												
													
														|  | 
 |  | +                    " SO_SODetails s" +
 | 
											
												
													
														|  | 
 |  | +                    " left join (" +
 | 
											
												
													
														|  | 
 |  | +                    " SELECT pm.cPOID as ompoCode,pm.POID as ompoId,pd.id as ompoIdItem," +
 | 
											
												
													
														|  | 
 |  | +                    " 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," +
 | 
											
												
													
														|  | 
 |  | +                    " 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;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @Override
 | 
											
												
													
														|  | 
 |  | +    public List<SyOrderDataVO> queryList(SyOrderDataVO sy) {
 | 
											
												
													
														|  | 
 |  | +        return null;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @Override
 | 
											
												
													
														|  | 
 |  | +    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
 | 
											
												
													
														|  | 
 |  | +        this.dxpDataPlanService = applicationContext.getBean(IDxpDataPlanService.class);
 | 
											
												
													
														|  | 
 |  | +        this.syGetOrderMapper = applicationContext.getBean(SyGetOrderMapper.class);
 | 
											
												
													
														|  | 
 |  | +        this.senYuDataSourceOne = applicationContext.getBean(ISenYuDataSourceOne.class);
 | 
											
												
													
														|  | 
 |  | +        this.senYuDataSourceTwo = applicationContext.getBean(ISenYuDataSourceTwo.class);
 | 
											
												
													
														|  | 
 |  | +        this.senYuDataSourceThree = applicationContext.getBean(ISenYuDataSourceThree.class);
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +}
 |