|
@@ -25,6 +25,10 @@ import cn.ezhizao.project.business.taskType.domain.BizTaskTypeDetail;
|
|
|
import cn.ezhizao.project.business.taskType.service.IBizTaskTypeDetailService;
|
|
|
import cn.ezhizao.project.business.taskType.service.IBizTaskTypeService;
|
|
|
import cn.ezhizao.project.business.workOrder.domain.BizWorkOrder;
|
|
|
+import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderDetail;
|
|
|
+import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord;
|
|
|
+import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderDetailService;
|
|
|
+import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderRecordService;
|
|
|
import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderService;
|
|
|
import cn.ezhizao.project.system.domain.SysFileStorage;
|
|
|
import cn.ezhizao.project.system.domain.SysUser;
|
|
@@ -85,6 +89,13 @@ public class BizArchiveInputController extends BaseController {
|
|
|
private IBizWorkOrderService workOrderService;
|
|
|
@Resource
|
|
|
private IBizCollectionDetailService bizCollectionDetailService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IBizWorkOrderDetailService bizWorkOrderDetailService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IBizWorkOrderRecordService workOrderRecordService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询档案入库列表
|
|
|
*/
|
|
@@ -199,9 +210,9 @@ public class BizArchiveInputController extends BaseController {
|
|
|
detail.setFreeNum(0);
|
|
|
}
|
|
|
for (BizArchiveInputDetail bizArchiveInputDetail : list) {
|
|
|
- if(detail.getTaskTypeId().equals(bizArchiveInputDetail.getTaskTypeId())) {
|
|
|
- detail.setId(bizArchiveInputDetail.getId());
|
|
|
- }
|
|
|
+ if (detail.getTaskTypeId().equals(bizArchiveInputDetail.getTaskTypeId())) {
|
|
|
+ detail.setId(bizArchiveInputDetail.getId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -301,8 +312,9 @@ public class BizArchiveInputController extends BaseController {
|
|
|
BizArchiveInputDetail newItem = newBizArchiveInput.getDetails().stream().filter(v -> l.getId().equals(v.getId())).findFirst().orElse(new BizArchiveInputDetail());
|
|
|
delProcess.addAll(l.getProcesses().stream().filter(v -> newItem.getProcesses().stream().noneMatch(e -> e.getId().equals(v.getId()))).collect(Collectors.toList()));
|
|
|
if (newBizArchiveInput.getServiceType().equals(1)) {
|
|
|
-
|
|
|
- if ((newItem.getFreeNum() + newItem.getServiceNum()) != (l.getServiceNum() + l.getFreeNum())) {
|
|
|
+ boolean a = (newItem.getFreeNum() + newItem.getServiceNum()) != (l.getServiceNum() + l.getFreeNum());
|
|
|
+ boolean b = newItem.getPrice().subtract(newItem.getDiscountAmount()) != (l.getPrice().subtract(l.getDiscountAmount()));
|
|
|
+ if (a || b) {
|
|
|
changeList.add(l);
|
|
|
}
|
|
|
}
|
|
@@ -311,30 +323,46 @@ public class BizArchiveInputController extends BaseController {
|
|
|
// 假设是单次任务判断删掉的任务是否已开始
|
|
|
if (newBizArchiveInput.getServiceType().equals(2)) {
|
|
|
if (!(delProcess.isEmpty() || bizArchiveInputService.checkWorkOrderStatusProcess(delProcess))) {
|
|
|
- throw new ServiceException("存在任务已完成,不能删除合同明细。");
|
|
|
+ throw new ServiceException("存在任务已完成,不能删除该合同明细。");
|
|
|
}
|
|
|
// newBizArchiveInput.get
|
|
|
}
|
|
|
if (newBizArchiveInput.getServiceType().equals(1)) {
|
|
|
// 假设是循环任务判断判断删掉的任务是否已经开始
|
|
|
if (!delList.isEmpty() && !bizArchiveInputService.checkWorkOrderStatus(delList)) {
|
|
|
- throw new ServiceException("存在任务已完成或填报,不能删除合同明细");
|
|
|
+ throw new ServiceException("存在任务已完成或填报,不能删除或修改该合同明细");
|
|
|
}
|
|
|
- // 假设是循环任务判断修改数量的任务是否和已完成的任务数量相符
|
|
|
- if (!changeList.isEmpty() && !bizArchiveInputService.checkWorkOrderChangeStatus(changeList)) {
|
|
|
- throw new ServiceException("修改任务月数小于已完成月数。");
|
|
|
+ //任务开始就不可以修改
|
|
|
+ for (BizArchiveInputDetail item : changeList) {
|
|
|
+ BizWorkOrderDetail one = bizWorkOrderDetailService.getOne(new LambdaQueryWrapper<BizWorkOrderDetail>()
|
|
|
+ .eq(BizWorkOrderDetail::getContractDetailId, item.getId())
|
|
|
+ .eq(BizWorkOrderDetail::getIsStop, 0));
|
|
|
+ //通过明细查询workorderID 进而查询record表
|
|
|
+ if (one != null) {
|
|
|
+ Long workOrderId = one.getWorkOrderId();
|
|
|
+ List<BizWorkOrderRecord> list = workOrderRecordService.list(new LambdaQueryWrapper<BizWorkOrderRecord>()
|
|
|
+ .eq(BizWorkOrderRecord::getWorkOrderId, workOrderId));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ throw new ServiceException("存在已开始的任务,不能修改该合同明细");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- for (BizArchiveInputDetail item : delList) {
|
|
|
-
|
|
|
- List<BizCollectionDetail> list = bizCollectionDetailService.list(new LambdaQueryWrapper<BizCollectionDetail>()
|
|
|
- .eq(BizCollectionDetail::getContractId, newBizArchiveInput.getId())
|
|
|
- .eq(BizCollectionDetail::getContractDetailId, item.getId())
|
|
|
- .eq(BizCollectionDetail::getTaskTypeId, item.getTaskTypeId()));
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
- throw new RuntimeException("已存在该任务类型的收款合同,无法删除");
|
|
|
+
|
|
|
+ // 假设是循环任务判断修改数量的任务是否和已完成的任务数量相符
|
|
|
+// if (!changeList.isEmpty() && !bizArchiveInputService.checkWorkOrderChangeStatus(changeList)) {
|
|
|
+// throw new ServiceException("修改任务月数小于已完成月数。");
|
|
|
+// }
|
|
|
+ for (BizArchiveInputDetail item : delList) {
|
|
|
+
|
|
|
+ List<BizCollectionDetail> list = bizCollectionDetailService.list(new LambdaQueryWrapper<BizCollectionDetail>()
|
|
|
+ .eq(BizCollectionDetail::getContractId, newBizArchiveInput.getId())
|
|
|
+ .eq(BizCollectionDetail::getContractDetailId, item.getId())
|
|
|
+ .eq(BizCollectionDetail::getTaskTypeId, item.getTaskTypeId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ throw new RuntimeException("已存在该任务类型的收款合同,无法删除");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -348,7 +376,7 @@ public class BizArchiveInputController extends BaseController {
|
|
|
// 获取 入Excel 表头字段
|
|
|
List<String> excelHeaders = util.readExcelHeaders(file.getInputStream());
|
|
|
//获取实体类字段
|
|
|
- List<String> names=getExcelAnnotatedFields(OrderExcelImportLoopModel.class);
|
|
|
+ List<String> names = getExcelAnnotatedFields(OrderExcelImportLoopModel.class);
|
|
|
//如果不存在模板中的字段,返回错误
|
|
|
if (!names.containsAll(excelHeaders)) {
|
|
|
return error("导入数据与模板不匹配!");
|
|
@@ -356,6 +384,7 @@ public class BizArchiveInputController extends BaseController {
|
|
|
String message = bizArchiveInputService.importLoop(orderList, SecurityUtils.getUserId(), getTenantId() == null ? 0 : getTenantId());
|
|
|
return success(message);
|
|
|
}
|
|
|
+
|
|
|
@Log(title = "合同导入", businessType = BusinessType.IMPORT)
|
|
|
@PreAuthorize("@ss.hasPermi('business:archive:order:import')")
|
|
|
@PostMapping("/importOnce")
|
|
@@ -366,7 +395,7 @@ public class BizArchiveInputController extends BaseController {
|
|
|
// 获取 入Excel 表头字段
|
|
|
List<String> excelHeaders = util.readExcelHeaders(file.getInputStream());
|
|
|
//获取实体类字段
|
|
|
- List<String> names=getExcelAnnotatedFields(OrderExcelImportOnceModel.class);
|
|
|
+ List<String> names = getExcelAnnotatedFields(OrderExcelImportOnceModel.class);
|
|
|
//如果不存在模板中的字段,返回错误
|
|
|
if (!names.containsAll(excelHeaders)) {
|
|
|
return error("导入数据与模板不匹配!");
|
|
@@ -375,7 +404,7 @@ public class BizArchiveInputController extends BaseController {
|
|
|
return success(message);
|
|
|
}
|
|
|
|
|
|
- public List<String> getExcelAnnotatedFields(Class<?> clazz) {
|
|
|
+ public List<String> getExcelAnnotatedFields(Class<?> clazz) {
|
|
|
Field[] fields = clazz.getDeclaredFields();
|
|
|
List<String> result = new ArrayList<>();
|
|
|
for (Field field : fields) {
|
|
@@ -413,6 +442,7 @@ public class BizArchiveInputController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@Log(title = "合同模板导出", businessType = BusinessType.EXPORT)
|
|
|
@PreAuthorize("@ss.hasPermi('business:archive:order:export')")
|
|
|
@PostMapping("/exportOnceTemplate")
|
|
@@ -453,22 +483,22 @@ public class BizArchiveInputController extends BaseController {
|
|
|
List<BizArchiveInputDetail> details = archiveInputDetailService.getList(conditions);
|
|
|
List<BizArchiveInputDetail> checkResult = new ArrayList<>();
|
|
|
// 判断循环工单是否有旧工单
|
|
|
- for (BizArchiveInputDetail detail: details) {
|
|
|
+ for (BizArchiveInputDetail detail : details) {
|
|
|
BizWorkOrder workOrder = workOrderService.query().eq("company_id", item.getCompanyId()).eq("task_type_id", detail.getTaskTypeId()).orderByDesc("end_month").eq("is_stop", 0).last("limit 1").one();
|
|
|
if (workOrder != null && workOrder.getEndMonth() != null) {
|
|
|
DateTime endMonth = DateTime.of(workOrder.getEndMonth());
|
|
|
if (workOrder.getTaskTypeId().equals(1L)) {
|
|
|
// 记账报税做前一个月的所以结束月为上上个月的要判断是否接着上个工单
|
|
|
- if (DateTime.now().offset(DateField.MONTH, -2).toString("yyyyMM").compareTo( endMonth.toString("yyyyMM")) > 0) {
|
|
|
+ if (DateTime.now().offset(DateField.MONTH, -2).toString("yyyyMM").compareTo(endMonth.toString("yyyyMM")) > 0) {
|
|
|
detail.setEndMonth(workOrder.getEndMonth());
|
|
|
checkResult.add(detail);
|
|
|
}
|
|
|
} else {
|
|
|
// 社保公积金还有返税申报是这个月的所以结束月是上个月的判断是否接上个工单。
|
|
|
- if (DateTime.now().offset(DateField.MONTH, -1).toString("yyyyMM").compareTo( endMonth.toString("yyyyMM")) > 0) {
|
|
|
- detail.setEndMonth(workOrder.getEndMonth());
|
|
|
- checkResult.add(detail);
|
|
|
- }
|
|
|
+ if (DateTime.now().offset(DateField.MONTH, -1).toString("yyyyMM").compareTo(endMonth.toString("yyyyMM")) > 0) {
|
|
|
+ detail.setEndMonth(workOrder.getEndMonth());
|
|
|
+ checkResult.add(detail);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|