|
@@ -58,12 +58,12 @@ import java.util.stream.Collectors;
|
|
|
public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMapper, MaintenanceRecord> {
|
|
|
|
|
|
|
|
|
- private LiftService liftService;
|
|
|
- private MtRecordCostService mtRecordCostService;
|
|
|
- private MtRecordImgService mtRecordImgService;
|
|
|
+ private LiftService liftService;
|
|
|
+ private MtRecordCostService mtRecordCostService;
|
|
|
+ private MtRecordImgService mtRecordImgService;
|
|
|
private MaintenancePlanService maintenancePlanService;
|
|
|
- private EvaluationService evaluationService;
|
|
|
- private ProjectService projectService;
|
|
|
+ private EvaluationService evaluationService;
|
|
|
+ private ProjectService projectService;
|
|
|
private ProjectLiftRelevanceService projectLiftRelevanceService;
|
|
|
|
|
|
private Gson gson;
|
|
@@ -91,7 +91,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
* @description 根据电梯id获取经纬度
|
|
|
* @date 2020/1/13 11:37 上午
|
|
|
*/
|
|
|
- public String getCoordinate(Long id){
|
|
|
+ public String getCoordinate(Long id) {
|
|
|
Lift lift = liftService.getById(id);
|
|
|
return Optional.ofNullable(lift).map(Lift::getCoordinate).orElse(null);
|
|
|
}
|
|
@@ -110,7 +110,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param planId 计划id
|
|
|
+ * @param planId 计划id
|
|
|
* @param mtCompanyId 公司id
|
|
|
* @return 是否存在
|
|
|
* @description 根据计划id和公司id查询是否有保养记录
|
|
@@ -253,7 +253,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
|
|
|
record.setStatus(CommonEnum.MaintenanceRecordStatus.COMPLETE.getCode());
|
|
|
boolean result = updateById(record);
|
|
|
- if (!result){
|
|
|
+ if (!result) {
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
}
|
|
|
log.info("维保记录:" + gson.toJson(oldRecord));
|
|
@@ -264,7 +264,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
plan.setWorkDate(LocalDate.now());
|
|
|
//修改保养计划为完成
|
|
|
boolean planResult = maintenancePlanService.updateById(plan);
|
|
|
- if (!planResult){
|
|
|
+ if (!planResult) {
|
|
|
rollback();
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
}
|
|
@@ -277,7 +277,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
imageList.add(image);
|
|
|
});
|
|
|
boolean ret = mtRecordImgService.saveBatch(imageList, imageList.size());
|
|
|
- if (!ret){
|
|
|
+ if (!ret) {
|
|
|
rollback();
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
}
|
|
@@ -312,50 +312,61 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
|
|
|
/**
|
|
|
* 根据条件分页查询维保-日常保养
|
|
|
- * @author wcz
|
|
|
+ *
|
|
|
* @param request MtRecordRequest
|
|
|
* @return IPage<MtRecordResponse>
|
|
|
+ * @author wcz
|
|
|
*/
|
|
|
- public IPage<MtRecordResponse> pageRecordByCondition(MtRecordRequest request){
|
|
|
- return baseMapper.pageRecordByCondition(request.getPage(),request);
|
|
|
+ public IPage<MtRecordResponse> pageRecordByCondition(MtRecordRequest request) {
|
|
|
+ return baseMapper.pageRecordByCondition(request.getPage(), request);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据维保公司统计维保-日常保养
|
|
|
- * @author wcz
|
|
|
+ *
|
|
|
* @param request MtRecordRequest
|
|
|
* @return long
|
|
|
+ * @author wcz
|
|
|
*/
|
|
|
- public long countRecordByCondition(MtRecordRequest request){
|
|
|
+ public long countRecordByCondition(MtRecordRequest request) {
|
|
|
return baseMapper.countRecordByCondition(request);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 日常保养-保养单:根据id查询,带关联信息
|
|
|
- * @author wcz
|
|
|
+ *
|
|
|
* @param request MtRecordRequest
|
|
|
* @return boolean
|
|
|
+ * @author wcz
|
|
|
*/
|
|
|
- public MtRecordResponse infoById(MtRecordRequest request){
|
|
|
+ public MtRecordResponse infoById(MtRecordRequest request) {
|
|
|
return baseMapper.infoById(request);
|
|
|
}
|
|
|
|
|
|
- private void rollback(){
|
|
|
+ private void rollback() {
|
|
|
//强制手动事务回滚
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 点击填写保养单,带收费项,新增record
|
|
|
- * @author wcz
|
|
|
+ *
|
|
|
* @param entity MaintenanceRecord
|
|
|
* @return boolean
|
|
|
+ * @author wcz
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public RestResponse tofill(MaintenanceRecord entity){
|
|
|
+ public RestResponse tofill(MaintenanceRecord entity) {
|
|
|
//总计 partsCost, manCost, 拼接sparepart
|
|
|
List<MtRecordCost> mtRecordCosts = entity.getMtRecordCosts();
|
|
|
- if(IterUtil.isNotEmpty(mtRecordCosts)){
|
|
|
+ ArrayList<MtRecordCost> removeList = new ArrayList<>();
|
|
|
+ for (MtRecordCost mtRecordCost : mtRecordCosts) {
|
|
|
+ if (mtRecordCost.getSparepart() == null || "".equals(mtRecordCost.getSparepart())) {
|
|
|
+ removeList.add(mtRecordCost);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mtRecordCosts.retainAll(removeList);
|
|
|
+ if (IterUtil.isNotEmpty(mtRecordCosts)) {
|
|
|
BigDecimal partsCost = mtRecordCosts.stream().map(MtRecordCost::getPartsCost).reduce(BigDecimal.ZERO, (m1, m2) -> m1.add(m2));
|
|
|
BigDecimal manCost = mtRecordCosts.stream().map(MtRecordCost::getManCost).reduce(BigDecimal.ZERO, (m1, m2) -> m1.add(m2));
|
|
|
String sparepart = mtRecordCosts.stream().map(MtRecordCost::getSparepart).collect(Collectors.joining(";"));
|
|
@@ -364,31 +375,31 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
entity.setSparepart(sparepart);
|
|
|
}
|
|
|
boolean mr = saveOrUpdate(entity);
|
|
|
- if(!mr){
|
|
|
+ if (!mr) {
|
|
|
return RestResponse.fail("修改保养单失败,请稍后重试");
|
|
|
}
|
|
|
//如果没有收费项
|
|
|
- if(IterUtil.isEmpty(mtRecordCosts)){
|
|
|
+ if (IterUtil.isEmpty(mtRecordCosts)) {
|
|
|
return RestResponse.success(entity.getId());
|
|
|
}
|
|
|
- mtRecordCosts.forEach(cost ->{
|
|
|
+ mtRecordCosts.forEach(cost -> {
|
|
|
cost.setMtRecordId(entity.getId());
|
|
|
});
|
|
|
boolean rc = mtRecordCostService.saveOrUpdateBatch(mtRecordCosts, mtRecordCosts.size());
|
|
|
- if(!rc){
|
|
|
+ if (!rc) {
|
|
|
//强制手动事务回滚
|
|
|
rollback();
|
|
|
return RestResponse.fail("修改保养收费项失败,请稍后重试");
|
|
|
}
|
|
|
MaintenancePlan plan = maintenancePlanService.getById(entity.getMtPlanId());
|
|
|
- if(Objects.isNull(plan)){
|
|
|
+ if (Objects.isNull(plan)) {
|
|
|
return RestResponse.success(entity.getId());
|
|
|
}
|
|
|
plan.setWorkDate(LocalDate.now());
|
|
|
boolean mp = maintenancePlanService.updateById(plan);
|
|
|
- if(mp){
|
|
|
+ if (mp) {
|
|
|
return RestResponse.success(entity.getId());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//强制手动事务回滚
|
|
|
rollback();
|
|
|
return RestResponse.fail("修改保养计划执行时间失败,请稍后重试");
|
|
@@ -397,18 +408,19 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
|
|
|
/**
|
|
|
* 填写保养单-确认,带维保项和现场图片 ,修改record
|
|
|
- * @author wcz
|
|
|
+ *
|
|
|
* @param entity MaintenanceRecord
|
|
|
- * @param imgs List<String>
|
|
|
+ * @param imgs List<String>
|
|
|
* @return boolean
|
|
|
+ * @author wcz
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public RestResponse fill(MaintenanceRecord entity,List<String> imgs){
|
|
|
+ public RestResponse fill(MaintenanceRecord entity, List<String> imgs) {
|
|
|
boolean mr = saveOrUpdate(entity);
|
|
|
- if(!mr){
|
|
|
+ if (!mr) {
|
|
|
return RestResponse.fail("修改保养单失败,请稍后重试");
|
|
|
}
|
|
|
- if(IterUtil.isEmpty(imgs)){
|
|
|
+ if (IterUtil.isEmpty(imgs)) {
|
|
|
return RestResponse.success(true);
|
|
|
}
|
|
|
List<MtRecordImg> mtRecordImgs = new ArrayList<>();
|
|
@@ -419,10 +431,10 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
mri.setSort(i);
|
|
|
mtRecordImgs.add(mri);
|
|
|
}
|
|
|
- boolean mi = mtRecordImgService.saveBatch(mtRecordImgs,mtRecordImgs.size());
|
|
|
- if(mi){
|
|
|
+ boolean mi = mtRecordImgService.saveBatch(mtRecordImgs, mtRecordImgs.size());
|
|
|
+ if (mi) {
|
|
|
return RestResponse.success(true);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//强制手动事务回滚
|
|
|
rollback();
|
|
|
return RestResponse.fail("修改保养单收费项失败,请稍后重试");
|
|
@@ -432,27 +444,28 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
/**
|
|
|
* 通过:app端提交的保养单点通过后生成正式保养单 status:-1 -> 2
|
|
|
* 清除超期: 超期的计划修改status ->1,workDate -> now
|
|
|
- * @author wcz
|
|
|
+ *
|
|
|
* @param entity MaintenanceRecord
|
|
|
* @return boolean
|
|
|
+ * @author wcz
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public RestResponse pass(MaintenanceRecord entity){
|
|
|
+ public RestResponse pass(MaintenanceRecord entity) {
|
|
|
boolean mr = updateById(entity);
|
|
|
- if(!mr){
|
|
|
+ if (!mr) {
|
|
|
return RestResponse.fail("修改保养单失败,请稍后重试");
|
|
|
}
|
|
|
//清除超期
|
|
|
MaintenancePlan plan = maintenancePlanService.getById(entity.getMtPlanId());
|
|
|
- if(Objects.isNull(plan)){
|
|
|
+ if (Objects.isNull(plan)) {
|
|
|
return RestResponse.success(true);
|
|
|
}
|
|
|
plan.setStatus(1);
|
|
|
plan.setWorkDate(LocalDate.now());
|
|
|
boolean mp = maintenancePlanService.updateById(plan);
|
|
|
- if(mp){
|
|
|
+ if (mp) {
|
|
|
return RestResponse.success(true);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//强制手动事务回滚
|
|
|
rollback();
|
|
|
return RestResponse.fail("修改维保计划失败,请稍后重试");
|
|
@@ -461,21 +474,22 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
|
|
|
/**
|
|
|
* 维保记录评价,同时更新维保记录状态 status -> 3
|
|
|
- * @author wcz
|
|
|
+ *
|
|
|
* @param record MaintenanceRecord
|
|
|
* @param entity Evaluation
|
|
|
* @return boolean
|
|
|
+ * @author wcz
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public RestResponse evaluate(MaintenanceRecord record, Evaluation entity){
|
|
|
+ public RestResponse evaluate(MaintenanceRecord record, Evaluation entity) {
|
|
|
boolean ev = evaluationService.save(entity);
|
|
|
- if(!ev){
|
|
|
+ if (!ev) {
|
|
|
return RestResponse.fail("添加评价失败,请稍后重试");
|
|
|
}
|
|
|
boolean mr = updateById(record);
|
|
|
- if(mr){
|
|
|
+ if (mr) {
|
|
|
return RestResponse.success(true);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//强制手动事务回滚
|
|
|
rollback();
|
|
|
return RestResponse.fail("更新维保记录失败,请稍后重试");
|
|
@@ -484,10 +498,11 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
|
|
|
/**
|
|
|
* 删除维保收费项,汇总金额,拼接sparepart
|
|
|
- * @author wcz
|
|
|
- * @param record MaintenanceRecord
|
|
|
+ *
|
|
|
+ * @param record MaintenanceRecord
|
|
|
* @param mtRecordCost MtRecordCost
|
|
|
* @return boolean
|
|
|
+ * @author wcz
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public RestResponse deleteCost(MaintenanceRecord record, MtRecordCost mtRecordCost) {
|
|
@@ -516,7 +531,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public IPage<MtRecordResponse> pageByLift(MtRecordRequest request){
|
|
|
+ public IPage<MtRecordResponse> pageByLift(MtRecordRequest request) {
|
|
|
return baseMapper.pageByLift(request.getPage(), request);
|
|
|
}
|
|
|
}
|