MaterialErpService.java 1.94 KB
package com.huaheng.pc.config.material.service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.pc.config.address.domain.Address;
import com.huaheng.pc.config.address.service.AddressService;
import com.huaheng.pc.config.material.domain.MaterialErp;
import com.huaheng.pc.config.material.mapper.MaterialErpMapper;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.utils.DateUtils;
import com.huaheng.framework.aspectj.lang.annotation.Ds;
import com.huaheng.framework.aspectj.lang.constant.DataSourceName;

import javax.annotation.Resource;


@Service
public class MaterialErpService extends ServiceImpl<MaterialErpMapper, MaterialErp>{

    @Resource
    private AddressService addressService;
    SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    /**
     * 查找erp数据库的供应商数据
     * @return
     */
    @Ds(name= DataSourceName.SLAVE)
   public List<MaterialErp> findMaterialData(Integer time){
//        String startTime= DateUtils.getNowPreDays("yyyy-MM-dd HH:mm:ss", 18);
//        time=time*60*24;
        Address address=addressService.selectAddressByParam("ERP", QuantityConstant.WAREHOUSE_CS);
        String startTime= DateUtils.getNowPreMin("yyyy-MM-dd HH:mm:ss", time);
        Date date=null;
        try{
            date=sf.parse(startTime);
        }catch (Exception e){
        }
        QueryWrapper<MaterialErp> queryWrapper = new QueryWrapper<>();
        queryWrapper.ge("imaamoddt", date);
        queryWrapper.eq("imaaent", address.getUserDef2());
        queryWrapper.eq("imaastus", "Y");
        queryWrapper.select("  imaa001,imaal003,imaal004,imaa006,imaa004,imaamoddt");
        List<MaterialErp> lists = this.list(queryWrapper);
        return lists;
   }


}