|
@@ -1,5 +1,6 @@
|
|
package org.jeecg.modules.fbsWorkshopDispatchList.service.impl;
|
|
package org.jeecg.modules.fbsWorkshopDispatchList.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import org.jeecg.modules.fbsWorkshopDispatchList.entity.FbsWorkshopDispatchList;
|
|
import org.jeecg.modules.fbsWorkshopDispatchList.entity.FbsWorkshopDispatchList;
|
|
import org.jeecg.modules.fbsWorkshopDispatchList.mapper.FbsWorkshopDispatchListMapper;
|
|
import org.jeecg.modules.fbsWorkshopDispatchList.mapper.FbsWorkshopDispatchListMapper;
|
|
import org.jeecg.modules.fbsWorkshopDispatchList.service.IFbsWorkshopDispatchListService;
|
|
import org.jeecg.modules.fbsWorkshopDispatchList.service.IFbsWorkshopDispatchListService;
|
|
@@ -8,6 +9,13 @@ import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.text.ParseException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
|
|
* @Description: 车间派工单
|
|
* @Description: 车间派工单
|
|
* @author: jeecg-boot
|
|
* @author: jeecg-boot
|
|
@@ -18,8 +26,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|
@Transactional
|
|
@Transactional
|
|
public class FbsWorkshopDispatchListServiceImpl extends ServiceImpl<FbsWorkshopDispatchListMapper, FbsWorkshopDispatchList> implements IFbsWorkshopDispatchListService {
|
|
public class FbsWorkshopDispatchListServiceImpl extends ServiceImpl<FbsWorkshopDispatchListMapper, FbsWorkshopDispatchList> implements IFbsWorkshopDispatchListService {
|
|
|
|
|
|
|
|
+ @Resource
|
|
private IFbsWorkshopDispatchListService iFbsWorkshopDispatchListService;
|
|
private IFbsWorkshopDispatchListService iFbsWorkshopDispatchListService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private FbsWorkshopDispatchListMapper fbsWorkshopDispatchListMapper;
|
|
|
|
|
|
* 更新状态
|
|
* 更新状态
|
|
* @param state 状态(0初始,1接单,2暂停,3完成)
|
|
* @param state 状态(0初始,1接单,2暂停,3完成)
|
|
@@ -27,6 +38,107 @@ public class FbsWorkshopDispatchListServiceImpl extends ServiceImpl<FbsWorkshopD
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public int updateState(String state,String id){
|
|
public int updateState(String state,String id){
|
|
- return iFbsWorkshopDispatchListService.updateState(state,id);
|
|
+ return fbsWorkshopDispatchListMapper.updateState(state,id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<FbsWorkshopDispatchList> getSumDispatch() {
|
|
|
|
+
|
|
|
|
+ List<FbsWorkshopDispatchList> fbsWorkshopDispatchListListSum=fbsWorkshopDispatchListMapper.getSumDispatch();
|
|
|
|
+
|
|
|
|
+ LambdaQueryWrapper<FbsWorkshopDispatchList> lambdaQueryWrapper=new LambdaQueryWrapper<>();
|
|
|
|
+ lambdaQueryWrapper.eq(FbsWorkshopDispatchList::getDelFlag,"0");
|
|
|
|
+ List<FbsWorkshopDispatchList> fbsWorkshopDispatchListList=iFbsWorkshopDispatchListService.list(lambdaQueryWrapper);
|
|
|
|
+
|
|
|
|
+ List<Date> dateList=startDateAndEndDate("2020-10-14","2020-10-17");
|
|
|
|
+ SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+
|
|
|
|
+ if(fbsWorkshopDispatchListListSum!=null&&fbsWorkshopDispatchListList!=null&&dateList!=null){
|
|
|
|
+ for(FbsWorkshopDispatchList dispatchListSum:fbsWorkshopDispatchListListSum){
|
|
|
|
+ List<FbsWorkshopDispatchList> dispatchListAdd=new ArrayList<>();
|
|
|
|
+ for(Date date:dateList){
|
|
|
|
+ String dateString=fmt.format(date);
|
|
|
|
+ boolean isorder=false;
|
|
|
|
+ for(FbsWorkshopDispatchList dispatchList:fbsWorkshopDispatchListList){
|
|
|
|
+ Integer orderIdSum=dispatchListSum.getProductionOrderNumberId();
|
|
|
|
+ Integer orderId=dispatchList.getProductionOrderNumberId();
|
|
|
|
+ String dispatchDate=fmt.format(dispatchList.getDate());
|
|
|
|
+
|
|
|
|
+ if(orderIdSum.equals(orderId)&&dateString.equals(dispatchDate)){
|
|
|
|
+ dispatchListAdd.add(dispatchList);
|
|
|
|
+ isorder=true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(isorder==false){
|
|
|
|
+ FbsWorkshopDispatchList fbsWorkshopDispatchList=new FbsWorkshopDispatchList();
|
|
|
|
+ fbsWorkshopDispatchList.setDate(date);
|
|
|
|
+ dispatchListAdd.add(fbsWorkshopDispatchList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ dispatchListSum.setFbsWorkshopDispatchListList(dispatchListAdd);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ mergeLines(fbsWorkshopDispatchListListSum);
|
|
|
|
+ return fbsWorkshopDispatchListListSum;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<Date> startDateAndEndDate(String startDate, String endDate) {
|
|
|
|
+ List<Date> list = new ArrayList<>();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ String date1 = startDate;
|
|
|
|
+ String date2 = endDate;
|
|
|
|
+ Long startTIme = null;
|
|
|
|
+ try {
|
|
|
|
+ startTIme = sdf.parse(date1).getTime();
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ Long endTime = null;
|
|
|
|
+ try {
|
|
|
|
+ endTime = sdf.parse(date2).getTime();
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ Long oneDay = 1000 * 60 * 60 * 24l;
|
|
|
|
+ Long time = startTIme;
|
|
|
|
+ while (time <= endTime) {
|
|
|
|
+ Date d = new Date(time);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ list.add(d);
|
|
|
|
+ time += oneDay;
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * @Author chenchuang
|
|
|
|
+ * @Description
|
|
|
|
+ * @Date 2020/10/17 17:23
|
|
|
|
+ * @Param [fbsWorkshopDispatchListList]
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+ public void mergeLines(List<FbsWorkshopDispatchList> fbsWorkshopDispatchListList){
|
|
|
|
+ if(fbsWorkshopDispatchListList!=null){
|
|
|
|
+ String productionLineId="";
|
|
|
|
+ Integer sort=1;
|
|
|
|
+ for(FbsWorkshopDispatchList fbsWorkshopDispatchList:fbsWorkshopDispatchListList){
|
|
|
|
+ Integer mergeLines=0;
|
|
|
|
+ if(productionLineId.equals("")||!productionLineId.equals(fbsWorkshopDispatchList.getProductionLineId())){
|
|
|
|
+ productionLineId=fbsWorkshopDispatchList.getProductionLineId();
|
|
|
|
+ for(FbsWorkshopDispatchList workshopDispatchList:fbsWorkshopDispatchListList){
|
|
|
|
+ if(productionLineId.equals(workshopDispatchList.getProductionLineId())){
|
|
|
|
+ mergeLines++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ fbsWorkshopDispatchList.setSort(sort);
|
|
|
|
+ sort++;
|
|
|
|
+ }
|
|
|
|
+ fbsWorkshopDispatchList.setMergeLines(mergeLines);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|