|
|
@@ -1,17 +1,20 @@
|
|
|
package com.model.service.impl;
|
|
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.model.entity.Client;
|
|
|
import com.model.entity.Dispatch;
|
|
|
import com.model.entity.DispatchSublist;
|
|
|
+import com.model.mapper.ClientMapper;
|
|
|
import com.model.mapper.DispatchMapper;
|
|
|
import com.model.result.CommRes;
|
|
|
+import com.model.service.ClientService;
|
|
|
import com.model.service.DispatchService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.UUID;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @program: model
|
|
|
@@ -24,6 +27,9 @@ public class DispatchServiceImpl implements DispatchService {
|
|
|
@Autowired
|
|
|
private DispatchMapper dispatchMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ClientMapper clientMapper;
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -58,6 +64,32 @@ public class DispatchServiceImpl implements DispatchService {
|
|
|
public CommRes updDispatch(Dispatch dispatch) {
|
|
|
try {
|
|
|
dispatchMapper.updDispatch(dispatch);
|
|
|
+
|
|
|
+ //添加收货的时间/时长
|
|
|
+ Dispatch dispatch1 = dispatchMapper.getDispatch(dispatch);
|
|
|
+
|
|
|
+ SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date star = dft.parse(dispatch1.getScrq());//开始时间
|
|
|
+ Date endDay = dft.parse(dispatch1.getFinalTime());//结束时间
|
|
|
+ Long starTime=star.getTime();
|
|
|
+ Long endTime=endDay.getTime();
|
|
|
+ Long num=endTime-starTime;//时间戳相差的毫秒数
|
|
|
+ String nums = String.valueOf(num/24/60/60/1000);
|
|
|
+ System.out.println("相差天数为:"+nums);//除以一天的毫秒数
|
|
|
+
|
|
|
+ //改变时间
|
|
|
+ Client client = new Client();
|
|
|
+ client.setCode(dispatch1.getCustomer());
|
|
|
+ client.setDays(nums);
|
|
|
+ Client client1 = clientMapper.getClient(client);
|
|
|
+
|
|
|
+ if (client1 == null){
|
|
|
+ //添加
|
|
|
+ clientMapper.addClient(client);
|
|
|
+ }else {
|
|
|
+ //修改
|
|
|
+ clientMapper.updClient(client);
|
|
|
+ }
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -73,18 +105,18 @@ public class DispatchServiceImpl implements DispatchService {
|
|
|
*/
|
|
|
@Override
|
|
|
public CommRes getDispatchList(Dispatch dispatch) {
|
|
|
- LinkedList<Dispatch> linkedList = new LinkedList<>();
|
|
|
+ PageInfo<Dispatch> pageInfo = null ;
|
|
|
try {
|
|
|
- List<Dispatch> list = dispatchMapper.getDispatchList(dispatch);
|
|
|
- for (Dispatch dispatch1 : list) {
|
|
|
+ PageHelper.startPage(dispatch.getPage(), dispatch.getLimit());
|
|
|
+ pageInfo = new PageInfo<>(dispatchMapper.getDispatchList(dispatch));
|
|
|
+ for (Dispatch dispatch1 : pageInfo.getList()) {
|
|
|
List<DispatchSublist> list1 = dispatchMapper.getDispatchLists(dispatch1);
|
|
|
dispatch1.setDataList(list1);
|
|
|
- linkedList.add(dispatch1);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return CommRes.success(linkedList);
|
|
|
+ return CommRes.success(pageInfo);
|
|
|
}
|
|
|
|
|
|
}
|