|
@@ -22,13 +22,15 @@ import java.util.List;
|
|
|
* @Date: 2020/2/4 15:44
|
|
|
*/
|
|
|
@Service
|
|
|
-@Transactional(readOnly = true)
|
|
|
+@Transactional()
|
|
|
public class MsReportService {
|
|
|
|
|
|
@Autowired
|
|
|
private MsSuspectedMapper msSuspectedMapper;
|
|
|
@Autowired
|
|
|
private MsReportMapper msReportMapper;
|
|
|
+ @Autowired
|
|
|
+ private MsReportService msReportService;
|
|
|
|
|
|
public List<MsSuspected> getByReportId(Long reportId) {
|
|
|
return msSuspectedMapper.selectByReportId(reportId);
|
|
@@ -47,6 +49,8 @@ public class MsReportService {
|
|
|
|
|
|
//获取今天数据
|
|
|
public MsReport getReportByDateNow(Long userCreate) {
|
|
|
+ //根据昨天的获取今天的
|
|
|
+ msReportService.getNowByYesterday(userCreate);
|
|
|
Date t = new Date();
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String reportDate = df.format(t);
|
|
@@ -78,19 +82,27 @@ public class MsReportService {
|
|
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
public void getNowByYesterday(Long userCreate) {
|
|
|
|
|
|
- //判断昨天是否有数据
|
|
|
SimpleDateFormat sj = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Date d = new Date();
|
|
|
+
|
|
|
+ //判断今天是否有数据
|
|
|
+ String DateNow = sj.format(d);
|
|
|
+ List<MsReport> listReport = msReportMapper.selectByReportDate(DateNow, userCreate);
|
|
|
+ if(listReport!=null && listReport.size()>0)
|
|
|
+ return;
|
|
|
+
|
|
|
+ //判断昨天是否有数据
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(d);
|
|
|
calendar.add(Calendar.DATE, -1);
|
|
|
String reportDate = sj.format(calendar.getTime());
|
|
|
- List<MsReport> listReport = msReportMapper.selectByReportDate(reportDate, userCreate);
|
|
|
+ List<MsReport> listReport1 = msReportMapper.selectByReportDate(reportDate, userCreate);
|
|
|
//有数据
|
|
|
- if (listReport != null && listReport.size() > 0) {
|
|
|
+ if (listReport1 != null && listReport1.size() > 0) {
|
|
|
//添加到今天日报
|
|
|
- MsReport msReport = msReportMapper.selectById(Long.parseLong(listReport.get(0).getReportId().toString()));
|
|
|
- if (msReport != null) {
|
|
|
+ MsReport msReport = msReportMapper.selectById(Long.parseLong(listReport1.get(0).getReportId().toString()));
|
|
|
+ Long reportId=0L;
|
|
|
+ if (msReport != null ) {
|
|
|
MsReport msReport1 = new MsReport();
|
|
|
msReport1.setReportId(IdWorker.getId());
|
|
|
msReport1.setHouseId(msReport.getHouseId());
|
|
@@ -106,16 +118,16 @@ public class MsReportService {
|
|
|
msReport1.setTimeCreate(DateTime.now());
|
|
|
msReport1.setUserUpdate(userCreate);
|
|
|
msReport1.setTimeUpdate(DateTime.now());
|
|
|
- msReportMapper.insert(msReport);
|
|
|
+ msReportMapper.insert(msReport1);
|
|
|
+ reportId=msReport1.getReportId();
|
|
|
}
|
|
|
//添加今日家庭
|
|
|
- List<MsSuspected> listSuspected = msSuspectedMapper.selectByReportId(Long.parseLong(listReport.get(0).getReportId().toString()));
|
|
|
+ List<MsSuspected> listSuspected = msSuspectedMapper.selectByReportId(Long.parseLong(listReport1.get(0).getReportId().toString()));
|
|
|
if (listSuspected != null && listSuspected.size() > 0) {
|
|
|
for (MsSuspected msSuspected : listSuspected) {
|
|
|
-
|
|
|
MsSuspected msSuspected1 = new MsSuspected();
|
|
|
msSuspected1.setSuspectedId(IdWorker.getId());
|
|
|
- msSuspected1.setReportId(Long.parseLong(listReport.get(0).getReportId().toString()));
|
|
|
+ msSuspected1.setReportId(reportId);
|
|
|
msSuspected1.setUserName(msSuspected.getUserName());
|
|
|
msSuspected1.setGrender(msSuspected.getGrender());
|
|
|
msSuspected1.setAge(msSuspected.getAge());
|
|
@@ -134,7 +146,7 @@ public class MsReportService {
|
|
|
msSuspected1.setTimeCreate(DateTime.now());
|
|
|
msSuspected1.setUserUpdate(userCreate);
|
|
|
msSuspected1.setTimeUpdate(DateTime.now());
|
|
|
- msSuspectedMapper.insert(msSuspected);
|
|
|
+ msSuspectedMapper.insert(msSuspected1);
|
|
|
}
|
|
|
}
|
|
|
}
|