MaterialErpService.java
3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.huaheng.pc.config.material.service;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.List;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.StringUtils;
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 org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@Service
public class MaterialErpService extends ServiceImpl<MaterialErpMapper, MaterialErp>{
@Resource
private MaterialErpService materialErpService;
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 查找erp数据库的供应商数据
* @return
*/
@Ds(name= DataSourceName.SLAVE)
public List<MaterialErp> findMaterialData(Date endtime,Address address,Date syncTimes,String codeStart,String codeEnd){
// String startTime= DateUtils.getNowPreDays("yyyy-MM-dd HH:mm:ss", 18);
// time=time*60*24;
// 将Date转换为Instant
Instant instant = syncTimes.toInstant();
// 将Instant往前推移10分钟
Instant newInstant = instant.minus(5, ChronoUnit.MINUTES);
// 将新的Instant转换回Date
Date newDate = Date.from(newInstant);
QueryWrapper<MaterialErp> queryWrapper = new QueryWrapper<>();
// 10101000001-10602000001 暂停 11400001543-12204001543-35004001543
if(StringUtils.isNotEmpty(codeStart)){
queryWrapper.ge("imaa001", codeStart);
queryWrapper.le("imaa001",codeEnd);
}else{
queryWrapper.ge("imaamoddt", newDate);
if(endtime!=null){
queryWrapper.le("imaamoddt", endtime);
}
}
queryWrapper.eq("imaaent", address.getUserDef2());
queryWrapper.eq("imaastus", "Y");
queryWrapper.select(" imaa001,imaal003,imaal004,imaa006,imaa004,imaamoddt,oocal003");
// queryWrapper.apply(" ROWNUM > 100 AND ROWNUM <= 200");
List<MaterialErp> lists = this.list(queryWrapper);
return lists;
}
/**
* 查找erp数据库的供应商数据
* @return
*/
@Ds(name= DataSourceName.SLAVE)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public MaterialErp erpMaterialByCode(String code,String datakeyEntId){
QueryWrapper<MaterialErp> queryWrapper = new QueryWrapper<>();
queryWrapper.ge("IMAA001", code);
queryWrapper.eq("imaaent", datakeyEntId);
queryWrapper.select(" imaa001,imaal003,imaal004,imaa006,imaa004,imaamoddt");
queryWrapper.last(" and rownum=1");
MaterialErp materialErp = materialErpService.getOne(queryWrapper);
return materialErp;
}
}