|
@@ -30,6 +30,7 @@ import cn.ezhizao.project.business.company.service.IBizCompanyService;
|
|
|
import cn.ezhizao.project.business.company.service.IDictRegionService;
|
|
|
import cn.ezhizao.project.business.order.domain.*;
|
|
|
import cn.ezhizao.project.business.order.domain.vo.InputVo;
|
|
|
+import cn.ezhizao.project.business.order.domain.vo.TimeVo;
|
|
|
import cn.ezhizao.project.business.order.mapper.BizArchiveInputMapper;
|
|
|
import cn.ezhizao.project.business.order.service.IBizArchiveInputDetailProcessService;
|
|
|
import cn.ezhizao.project.business.order.service.IBizArchiveInputDetailService;
|
|
@@ -610,6 +611,32 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
|
|
|
l.setMonthNum(months);
|
|
|
l.setEndMonth(endDate);
|
|
|
l.setIsContinue(0);
|
|
|
+ List<BizArchiveInputDetail> inputDetailList = archiveInputDetailService
|
|
|
+ .query()
|
|
|
+ .eq("contract_id",bizArchiveInput.getId())
|
|
|
+ .list();
|
|
|
+ for(BizArchiveInputDetail inputDetail : inputDetailList){
|
|
|
+ TimeVo time = getTime(bizArchiveInput.getId(),inputDetail.getId(),l.getTaskTypeId(),l.getCompanyId());
|
|
|
+
|
|
|
+ if(null != time){
|
|
|
+ // 获取当前日期的 LocalDate 对象
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ // 将 LocalDate 对象的日期设置为当前月份的第一天
|
|
|
+ LocalDate firstDayOfMonth = now.withDayOfMonth(1);
|
|
|
+ // 将 LocalDate 对象转换为 Date 对象
|
|
|
+ endDate = Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
|
|
+ int i = DateDifferenceMonths(time.getStartTime(),endDate);
|
|
|
+ // workOrderDetailService.updateByContractDetailId(i,l.getCompanyId(),inputDetail.getContractId(),inputDetail.getId(),l.getTaskTypeId());
|
|
|
+ details.stream()
|
|
|
+ .filter(v->v.getContractId().equals(inputDetail.getContractId())
|
|
|
+ && v.getContractDetailId().equals(inputDetail.getId())
|
|
|
+ && v.getTaskTypeId().equals(inputDetail.getTaskTypeId())
|
|
|
+ ).forEach(v->{
|
|
|
+ v.setServiceNum(i+1);
|
|
|
+ v.setFreeNum(0);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
// 当前这个工单所对应的委托根据endDate去查询,查询条件是大于endDate的,更新字段deleted为1
|
|
|
bizArchiveInputMapper.deleteByDate(l.getId(),endDate,l.getTaskTypeId(),SecurityUtils.getUserId());
|
|
|
// 旧任务明细 停止
|
|
@@ -628,7 +655,85 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
+ public TimeVo getTime(Long contractId, Long contractDetailId, Long typeId, Long companyId) {
|
|
|
+ //排序获取当前索引位置
|
|
|
+ BizWorkOrderDetail one = workOrderDetailService.getOne(
|
|
|
+ new LambdaQueryWrapper<BizWorkOrderDetail>()
|
|
|
+ .eq(BizWorkOrderDetail::getContractId, contractId)
|
|
|
+ .eq(BizWorkOrderDetail::getContractDetailId, contractDetailId)
|
|
|
+ .eq(BizWorkOrderDetail::getCompanyId, companyId)
|
|
|
+ .eq(BizWorkOrderDetail::getTaskTypeId, typeId).eq(BizWorkOrderDetail::getDeleted, 0));
|
|
|
+
|
|
|
+ if (one == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Long workOrderId = one.getWorkOrderId();
|
|
|
+
|
|
|
+ BizWorkOrder workOrder = workOrderService.getById(workOrderId);
|
|
|
+
|
|
|
+ //一个工单对应多个工单详细,一个工单可以挂多个合同
|
|
|
+ //获取工单对应的工单详细(里面的数据有一些是从合同写入的)需要用签约日期排序
|
|
|
+ List<BizWorkOrderDetail> list = workOrderDetailService.selectByWorkOrderId(contractId,workOrderId,typeId);
|
|
|
+ //合同详细id转成list
|
|
|
+ List<Long> indexList = list.stream().map(m -> m.getContractDetailId()).collect(Collectors.toList());
|
|
|
+ //确定当前索引元素
|
|
|
+ //获取当前方法传入的合同详细id在列表中的位置
|
|
|
+ int i = indexList.indexOf(contractDetailId);
|
|
|
+ if (i == -1) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //当前元素所有月份
|
|
|
+ BizWorkOrderDetail bizWorkOrderDetail = list.get(i);
|
|
|
+ List<BizArchiveInput> bizArchiveInputList = this.query()
|
|
|
+ .eq("id",bizWorkOrderDetail.getContractId())
|
|
|
+ .list();
|
|
|
+
|
|
|
+ int monthNum = bizWorkOrderDetail.getFreeNum() + bizWorkOrderDetail.getServiceNum();
|
|
|
+ //获取位置之前所有数据月数的和(设置结束月)
|
|
|
+ //判断是不是第一个
|
|
|
+ if (i == 0) {
|
|
|
+ DateTime startMonth = DateTime.of(workOrder.getStartMonth());
|
|
|
+ java.sql.Date endMonth = startMonth.offset(DateField.MONTH, monthNum - 1).toSqlDate();
|
|
|
+ return new TimeVo(workOrder.getStartMonth(), endMonth);
|
|
|
+ } else {
|
|
|
+ //中间的工单
|
|
|
+ //获取起始时间 并获取 i 之前所有月数 相加为起始时间
|
|
|
+ int totalNum = getMonthNum(i - 1, list);
|
|
|
+// if(bizArchiveInputList.get(0).getDissolution().equals(1)){
|
|
|
+// monthNum = DateDifferenceMonths(startMonth,new java.util.Date());
|
|
|
+// }
|
|
|
+ DateTime month = DateTime.of(workOrder.getStartMonth());
|
|
|
+ java.sql.Date startMonth = month.offset(DateField.MONTH, totalNum).toSqlDate();
|
|
|
+ DateTime startMonthTemp = DateTime.of(startMonth);
|
|
|
+
|
|
|
+ java.sql.Date endMonth = startMonthTemp.offset(DateField.MONTH, monthNum - 1).toSqlDate();
|
|
|
+ return new TimeVo(startMonth, endMonth);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ public int DateDifferenceMonths(java.util.Date date1, java.util.Date date2) {
|
|
|
+ Calendar startCalendar = Calendar.getInstance();
|
|
|
+ startCalendar.setTime(date1);
|
|
|
|
|
|
+ Calendar endCalendar = Calendar.getInstance();
|
|
|
+ endCalendar.setTime(date2);
|
|
|
+
|
|
|
+ // 计算年份和月份的差异
|
|
|
+ int yearDiff = endCalendar.get(Calendar.YEAR) - startCalendar.get(Calendar.YEAR);
|
|
|
+ int monthDiff = endCalendar.get(Calendar.MONTH) - startCalendar.get(Calendar.MONTH);
|
|
|
+
|
|
|
+ // 总的月份差异
|
|
|
+ return yearDiff * 12 + monthDiff;
|
|
|
+ }
|
|
|
+ public static int getMonthNum(int i, List<BizWorkOrderDetail> list) {
|
|
|
+ int total = 0;
|
|
|
+ while (i >= 0) {
|
|
|
+ BizWorkOrderDetail bizWorkOrderDetail = list.get(i);
|
|
|
+ total += bizWorkOrderDetail.getFreeNum() + bizWorkOrderDetail.getServiceNum();
|
|
|
+ i--;
|
|
|
+ }
|
|
|
+ return total;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public boolean checkWorkOrderStatusProcess(List<BizArchiveInputDetailProcess> delProcess) {
|