|
@@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.winsea.svc.base.base.entity.CommonStaff;
|
|
import com.winsea.svc.base.base.entity.CommonStaff;
|
|
import com.winsea.svc.base.base.service.ICommonStaffService;
|
|
import com.winsea.svc.base.base.service.ICommonStaffService;
|
|
|
|
+import com.winsea.svc.base.workflow.entity.Workflow;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
|
|
+import com.yh.saas.plugin.base.entity.CommonBillOperateHis;
|
|
|
|
+import com.yh.saas.plugin.base.service.ICommonBillOperateHisService;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.YException;
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.YException;
|
|
@@ -23,10 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
-import java.util.Date;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -49,7 +49,8 @@ public class FuelFillingInfoServiceImpl extends ServiceImpl<FuelFillingInfoMappe
|
|
private INewWorkflowService workflowService;
|
|
private INewWorkflowService workflowService;
|
|
@Autowired
|
|
@Autowired
|
|
private ICommonStaffService staffService;
|
|
private ICommonStaffService staffService;
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommonBillOperateHisService commonBillOperateHisService;
|
|
/**
|
|
/**
|
|
* 添加长途加油信息
|
|
* 添加长途加油信息
|
|
*
|
|
*
|
|
@@ -58,66 +59,107 @@ public class FuelFillingInfoServiceImpl extends ServiceImpl<FuelFillingInfoMappe
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public String addFilling(FuelFillingInfo fuelFillingInfo) {
|
|
public String addFilling(FuelFillingInfo fuelFillingInfo) {
|
|
- String id = "";
|
|
|
|
- //判断开始/结束轨迹(0开始1结束)
|
|
|
|
- if ("0".equals(fuelFillingInfo.getTrackFlag())) {
|
|
|
|
|
|
+ if("1".equals(fuelFillingInfo.getFlag())){
|
|
//新增主键id
|
|
//新增主键id
|
|
fuelFillingInfo.setId(IdGenerator.generateUUID());
|
|
fuelFillingInfo.setId(IdGenerator.generateUUID());
|
|
- //行程状态改为已开始
|
|
|
|
- fuelFillingInfo.setTravelStatus(StatusEnum.TRACK_START.getName());
|
|
|
|
- fuelFillingInfo.setTravelStatusFlag(StatusEnum.TRACK_START.getFlag());
|
|
|
|
- //获取当前年月日
|
|
|
|
- SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");//设置日期格式
|
|
|
|
- String date = f.format(new Date(System.currentTimeMillis()));
|
|
|
|
- //查询信息数量包括已删除的集合
|
|
|
|
- List<FuelFillingInfo> fuelFillingInfoList = this.selectFillingNoList(fuelFillingInfo);//调用Service中的方法
|
|
|
|
- //生成请假编号
|
|
|
|
- if (fuelFillingInfoList.size() > 0) {
|
|
|
|
- //取第一条数据的编号
|
|
|
|
- String n = fuelFillingInfoList.get(0).getFillingNo();
|
|
|
|
- //截取编号后4位
|
|
|
|
- int intNumber = Integer.parseInt(n.substring(13));
|
|
|
|
- intNumber++;
|
|
|
|
- String Number = String.valueOf(intNumber);
|
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
|
- Number = Number.length() < 4 ? "0" + Number : Number;
|
|
|
|
|
|
+
|
|
|
|
+ this.insert(fuelFillingInfo);
|
|
|
|
+ FillingDetailInfo fillingDetailInfo = fuelFillingInfo.getFillingDetailInfo();
|
|
|
|
+ if(fillingDetailInfo != null){
|
|
|
|
+ fillingDetailInfo.setId(IdGenerator.generateUUID());
|
|
|
|
+ fillingDetailInfo.setFillingId(fuelFillingInfo.getId());
|
|
|
|
+ fillingDetailInfoService.insert(fillingDetailInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ boolean isStartWorkflow = com.alipay.sofa.rpc.common.utils.StringUtils.isBlank(fuelFillingInfo.getWorkflowId());
|
|
|
|
+ // 不是退回的单子
|
|
|
|
+ if (isStartWorkflow) {
|
|
|
|
+ Workflow workflow = workflowService
|
|
|
|
+ .findLatestWorkflowByBusinessCodeByApp(fuelFillingInfo.getCompId(), "JIAYOU-SHENHE-APPROVE");
|
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
|
+ if (workflow == null) {
|
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // 开启审核流
|
|
|
|
+ else {
|
|
|
|
+ // 设置状态 已提交审核
|
|
|
|
+ fuelFillingInfo.setWorkflowId(workflow.getId());
|
|
|
|
+ fuelFillingInfoService.updateById(fuelFillingInfo);
|
|
|
|
+ workflowService.startInstance(workflow.getId(), fuelFillingInfo.getId());
|
|
}
|
|
}
|
|
- //编号自增
|
|
|
|
- Number = "JY" + date + Number;
|
|
|
|
- fuelFillingInfo.setFillingNo(Number);
|
|
|
|
- } else {
|
|
|
|
- //如果当天数据为空,生成第一条数据
|
|
|
|
- String Number = "JY" + date + "0001";
|
|
|
|
- fuelFillingInfo.setFillingNo(Number);
|
|
|
|
}
|
|
}
|
|
- if (fuelFillingInfo.getFillingNo().contains("null")) {
|
|
|
|
- throw new YException(YExceptionEnum.QUALITY_HAVE_ERROR);
|
|
|
|
|
|
+ // 退回的单子 再启用
|
|
|
|
+ else {
|
|
|
|
+ fuelFillingInfoService.updateById(fuelFillingInfo);
|
|
|
|
+ workflowService.activateInstance(fuelFillingInfo.getWorkflowId(), fuelFillingInfo.getId());
|
|
}
|
|
}
|
|
|
|
|
|
- this.insert(fuelFillingInfo);
|
|
|
|
- id = fuelFillingInfo.getId();
|
|
|
|
- } else {
|
|
|
|
-// FuelFillingInfo fuelFillingInfo1 = fuelFillingInfoService.selectOne(new EntityWrapper<FuelFillingInfo>()
|
|
|
|
-// .eq("comp_id", fuelFillingInfo.getCompId())
|
|
|
|
-// .eq("common_id", fuelFillingInfo.getCommonId())
|
|
|
|
-// .eq("car_no", fuelFillingInfo.getCarNo()));
|
|
|
|
- FuelFillingInfo fuelFillingInfo1 = this.selectById(fuelFillingInfo.getId());
|
|
|
|
- if (fuelFillingInfo1 != null) {
|
|
|
|
- //行程状态改为已结束
|
|
|
|
- fuelFillingInfo1.setTravelStatusFlag(StatusEnum.TRACK_END.getFlag());
|
|
|
|
- fuelFillingInfo1.setTravelStatus(StatusEnum.TRACK_END.getName());
|
|
|
|
- fuelFillingInfo1.setCarNo(fuelFillingInfo.getCarNo());
|
|
|
|
- fuelFillingInfo1.setDestinationProvince(fuelFillingInfo.getDestinationProvince());
|
|
|
|
- fuelFillingInfo1.setDestinationCity(fuelFillingInfo.getDestinationCity());
|
|
|
|
- fuelFillingInfo1.setDestinationArea(fuelFillingInfo.getDestinationArea());
|
|
|
|
- fuelFillingInfo1.setDestinationAddress(fuelFillingInfo.getDestinationAddress());
|
|
|
|
- fuelFillingInfo1.setDestinationLongitude(fuelFillingInfo.getDestinationLongitude());
|
|
|
|
- fuelFillingInfo1.setDestinationLatitude(fuelFillingInfo.getDestinationLatitude());
|
|
|
|
- this.updateById(fuelFillingInfo1);
|
|
|
|
- id = fuelFillingInfo1.getId();
|
|
|
|
|
|
+ // 添加提交历史
|
|
|
|
+ CommonBillOperateHis commonBillOperateHis = new CommonBillOperateHis();
|
|
|
|
+ commonBillOperateHis.setBillId(fuelFillingInfo.getId());
|
|
|
|
+ commonBillOperateHis.setId(IdGenerator.generateUUID());
|
|
|
|
+ commonBillOperateHis.setBillType("JIAYOU-SHENHE-APPROVE");
|
|
|
|
+ commonBillOperateHis.setOperateDate(new Date());
|
|
|
|
+ commonBillOperateHis.setOperateUser(fuelFillingInfo.getCreateUserId());
|
|
|
|
+ JSONObject jsonObject = (JSONObject) JSONObject.toJSON(fuelFillingInfo);
|
|
|
|
+ commonBillOperateHis.setBusinessHistory(jsonObject.toJSONString());
|
|
|
|
+ commonBillOperateHisService.create(commonBillOperateHis);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ this.updateById(fuelFillingInfo);
|
|
|
|
+ FillingDetailInfo fillingDetailInfo = fuelFillingInfo.getFillingDetailInfo();
|
|
|
|
+ if(fillingDetailInfo != null){
|
|
|
|
+ fillingDetailInfoService.delete(new EntityWrapper<FillingDetailInfo>()
|
|
|
|
+ .eq("filling_id",fuelFillingInfo.getId()));
|
|
|
|
+ fillingDetailInfo.setId(IdGenerator.generateUUID());
|
|
|
|
+ fillingDetailInfo.setFillingId(fuelFillingInfo.getId());
|
|
|
|
+ fillingDetailInfoService.insert(fillingDetailInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ boolean isStartWorkflow = StringUtils.isBlank(fuelFillingInfo.getWorkflowId());
|
|
|
|
+ // 不是退回的单子
|
|
|
|
+ if (isStartWorkflow) {
|
|
|
|
+ Workflow workflow = workflowService
|
|
|
|
+ .findLatestWorkflowByBusinessCodeByApp(fuelFillingInfo.getCompId(), "JIAYOU-SHENHE-APPROVE");
|
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
|
+ if (workflow == null) {
|
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // 开启审核流
|
|
|
|
+ else {
|
|
|
|
+ // 设置状态 已提交审核
|
|
|
|
+ fuelFillingInfo.setWorkflowId(workflow.getId());
|
|
|
|
+ this.updateById(fuelFillingInfo);
|
|
|
|
+ workflowService.startInstance(workflow.getId(), fuelFillingInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 退回的单子 再启用
|
|
|
|
+ else {
|
|
|
|
+ if ("发起人撤回".equals(fuelFillingInfo.getApproveStatus())) {
|
|
|
|
+ Workflow workflow = workflowService
|
|
|
|
+ .findLatestWorkflowByBusinessCodeByApp(fuelFillingInfo.getCompId(), "JIAYOU-SHENHE-APPROVE");
|
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
|
+ if (workflow == null) {
|
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // 开启审核流
|
|
|
|
+ else {
|
|
|
|
+ // 设置状态 已提交审核
|
|
|
|
+ fuelFillingInfo.setWorkflowId(workflow.getId());
|
|
|
|
+ this.updateById(fuelFillingInfo);
|
|
|
|
+ workflowService.startInstance(workflow.getId(), fuelFillingInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ this.updateById(fuelFillingInfo);
|
|
|
|
+ workflowService.activateInstance(fuelFillingInfo.getWorkflowId(), fuelFillingInfo.getId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return id;
|
|
|
|
|
|
+
|
|
|
|
+ return fuelFillingInfo.getId();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -140,6 +182,11 @@ public class FuelFillingInfoServiceImpl extends ServiceImpl<FuelFillingInfoMappe
|
|
// 查询总数
|
|
// 查询总数
|
|
Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
List<FuelFillingInfo> dataList = baseMapper.getListByCondition(pageView);
|
|
List<FuelFillingInfo> dataList = baseMapper.getListByCondition(pageView);
|
|
|
|
+ for(int i=0;i<dataList.size();i++){
|
|
|
|
+ dataList.get(i).setFillingDetailInfo(fillingDetailInfoService.selectOne(new EntityWrapper<FillingDetailInfo>()
|
|
|
|
+ .eq("filling_id",dataList.get(i).getId())));
|
|
|
|
+
|
|
|
|
+ }
|
|
Page<FuelFillingInfo> page = new Page<>();
|
|
Page<FuelFillingInfo> page = new Page<>();
|
|
page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
page.setTotal(dataCount == null ? 0 : dataCount);
|
|
page.setTotal(dataCount == null ? 0 : dataCount);
|
|
@@ -161,8 +208,8 @@ public class FuelFillingInfoServiceImpl extends ServiceImpl<FuelFillingInfoMappe
|
|
if(fuelFillingInfo != null){
|
|
if(fuelFillingInfo != null){
|
|
CommonStaff commonStaff = staffService.getInfo(fuelFillingInfo.getCreateUserId());
|
|
CommonStaff commonStaff = staffService.getInfo(fuelFillingInfo.getCreateUserId());
|
|
fuelFillingInfo.setCreater(commonStaff.getStaffName());
|
|
fuelFillingInfo.setCreater(commonStaff.getStaffName());
|
|
- List<FillingDetailInfo> fillingDetailInfos = fillingDetailInfoService.selectList(new EntityWrapper<FillingDetailInfo>().eq("filling_id",id).orderBy("serial_number"));
|
|
|
|
- fuelFillingInfo.setFillingDetailInfoList(fillingDetailInfos);
|
|
|
|
|
|
+ fuelFillingInfo.setFillingDetailInfo(fillingDetailInfoService.selectOne(new EntityWrapper<FillingDetailInfo>()
|
|
|
|
+ .eq("filling_id",fuelFillingInfo.getId())));
|
|
//短途行程列表
|
|
//短途行程列表
|
|
List<ShortFillingInfo> shortFillingInfoList = shortFillingInfoService.selectList(new EntityWrapper<ShortFillingInfo>()
|
|
List<ShortFillingInfo> shortFillingInfoList = shortFillingInfoService.selectList(new EntityWrapper<ShortFillingInfo>()
|
|
.eq("filling_id", id)
|
|
.eq("filling_id", id)
|
|
@@ -181,6 +228,57 @@ public class FuelFillingInfoServiceImpl extends ServiceImpl<FuelFillingInfoMappe
|
|
return fuelFillingInfo;
|
|
return fuelFillingInfo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看长途加油信息
|
|
|
|
+ *
|
|
|
|
+ * @param carNo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String gettime(String carNo) {
|
|
|
|
+ //根据id查询加油信息
|
|
|
|
+ List<FuelFillingInfo> fuelFillingInfoList = this.selectList(new EntityWrapper<FuelFillingInfo>()
|
|
|
|
+ .eq("car_no",carNo).orderBy("create_date",false));
|
|
|
|
+ if(CollectionUtils.isNotEmpty(fuelFillingInfoList)){
|
|
|
|
+ if("3".equals(fuelFillingInfoList.get(0).getStatusFlag())){
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String time = simpleDateFormat.format(fuelFillingInfoList.get(0).getCreateDate());
|
|
|
|
+ return time;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ throw new YException(YExceptionEnum.CARNO_ERROR);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ calendar.setTime(new Date());
|
|
|
|
+ calendar.add(Calendar.MONTH, -1);
|
|
|
|
+ Date m = calendar.getTime();
|
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String mon = format.format(m);
|
|
|
|
+ return mon;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看长途加油信息
|
|
|
|
+ *
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String deleteFilling(String id) {
|
|
|
|
+ this.deleteById(id);
|
|
|
|
+ fillingDetailInfoService.delete(new EntityWrapper<FillingDetailInfo>()
|
|
|
|
+ .eq("filling_id",id));
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 加油管理列表(PC)
|
|
* 加油管理列表(PC)
|
|
*
|
|
*
|