bug修复

This commit is contained in:
xiaofajia 2024-11-02 16:52:31 +08:00
parent 6b4ec9c046
commit 05696bff5e

View File

@ -217,7 +217,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// });
// 门店信息
Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();
DeptRespDTO dept = deptApi.getDept(deptId);
@ -438,7 +437,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
userDTO.setPassword("123456");
adminUserApi.createUser(userDTO);
// 如果新增了数据id没有回填
if (ObjectUtil.isEmpty(userDTO.getId())){
if (ObjectUtil.isEmpty(userDTO.getId())) {
AdminUserRespDTO byMobile = adminUserApi.getUserByMobile(userDTO.getMobile());
userDTO.setId(byMobile.getId());
}
@ -450,12 +449,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
if (ObjectUtil.isEmpty(customerAndCarVO.getUserInfo().getId())) {
// 新增之前判断一下电话号码是否重复
List<CustomerMain> list = customerService.list(new LambdaQueryWrapper<CustomerMain>().eq(CustomerMain::getPhoneNumber, customerAndCarVO.getUserInfo().getPhoneNumber()));
if (CollectionUtil.isNotEmpty(list)){
if (CollectionUtil.isNotEmpty(list)) {
throw exception0(500, "电话号码重复");
}
customerService.save(customerAndCarVO.getUserInfo());
// 如果新增了数据id没有回填
if (ObjectUtil.isEmpty(customerAndCarVO.getUserInfo().getId())){
if (ObjectUtil.isEmpty(customerAndCarVO.getUserInfo().getId())) {
CustomerMain byPhoneNumber = customerService.getOne(new LambdaQueryWrapper<CustomerMain>().eq(CustomerMain::getPhoneNumber, customerAndCarVO.getUserInfo().getPhoneNumber()));
customerAndCarVO.getUserInfo().setId(byPhoneNumber.getId());
}
@ -469,12 +468,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
customerAndCarVO.getCarInfo().setUserId(customerAndCarVO.getUserInfo().getUserId());
// 新增之前判断一下车牌重复没
List<CarMain> list = carMainService.list(new LambdaQueryWrapper<CarMain>().eq(CarMain::getLicenseNumber, customerAndCarVO.getCarInfo().getLicenseNumber()));
if (CollectionUtil.isNotEmpty(list)){
if (CollectionUtil.isNotEmpty(list)) {
throw exception0(500, "车牌重复");
}
carMainService.createCarMain(customerAndCarVO.getCarInfo());
// 如果新增了数据id没有回填
if (ObjectUtil.isEmpty(customerAndCarVO.getCarInfo().getId())){
if (ObjectUtil.isEmpty(customerAndCarVO.getCarInfo().getId())) {
CarMain byLicenseNumber = carMainService.getOne(new LambdaQueryWrapper<CarMain>().eq(CarMain::getLicenseNumber, customerAndCarVO.getCarInfo().getLicenseNumber()));
customerAndCarVO.getCarInfo().setId(byLicenseNumber.getId());
}
@ -514,7 +513,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
public void print(HttpServletResponse response, String id) {
// 开始之前先计算一次工单
boolean flag = computeTicket(id);
if (!flag){
if (!flag) {
throw exception0(500, "系统异常");
}
// 预备工作
@ -706,7 +705,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
params.put("matlabourFavorable", "0.00");
// 管理费救援费三包费定损费结算备注这个是因为和工单备注用的同一个todo 客户签字
params.put("manageCost", ObjectUtil.isNotEmpty(tickets.getManagerMoney()) ? tickets.getManagerMoney() : "0.00") ;
params.put("manageCost", ObjectUtil.isNotEmpty(tickets.getManagerMoney()) ? tickets.getManagerMoney() : "0.00");
params.put("rescueCost", ObjectUtil.isNotEmpty(tickets.getRescueMoney()) ? tickets.getRescueMoney() : "0.00");
params.put("tripleCost", ObjectUtil.isNotEmpty(tickets.getThreePackMoney()) ? tickets.getThreePackMoney() : "0.00");
params.put("lossCost", ObjectUtil.isNotEmpty(tickets.getConfirmFaultMoney()) ? tickets.getConfirmFaultMoney() : "0.00");
@ -756,7 +755,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
String bank = "";
String bankAddress = "";
String account = "";
if (company != null){
if (company != null) {
corporation = company.getCorpName();
bankAddress = company.getAddress();
bank = company.getBankAccount();
@ -777,10 +776,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 生成收款二维码
int width = 100, height = 100;
byte[] texts = CreateQRCodeUtil.GenerateQRCode(payUrl, width, height);
if (ObjectUtil.isNotEmpty(texts)){
if (ObjectUtil.isNotEmpty(texts)) {
params.put("qrCode", new PictureRenderData(width, height, PictureType.PNG, texts));
}
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
@ -832,12 +831,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 所有的员工信息
String userIdsStr = "";
List<Long> userIds = new ArrayList<>();
for (RepairWorker worker:list){
for (RepairWorker worker : list) {
userIds.add(worker.getUserId());
if("".equals(userIdsStr)){
if ("".equals(userIdsStr)) {
userIdsStr = String.valueOf(worker.getUserId());
}else{
userIdsStr = ","+worker.getUserId();
} else {
userIdsStr = "," + worker.getUserId();
}
}
repairTicketsReqVO.setUserIds(userIds);
@ -1176,56 +1175,54 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
item.eq(DlTicketWares::getTicketId, id)
.notIn(DlTicketWares::getStatus, status);
}));
// 查配件申请表的所有已领取数量小于申请数量的子表信息
List<String> ids = list.stream().map(DlTicketWares::getId).collect(Collectors.toList());
List<DlTwItem> twItems = new ArrayList<>();
if (CollectionUtil.isNotEmpty(ids)){
twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
if (CollectionUtil.isNotEmpty(list)) {
// 查配件申请表的所有已领取数量小于申请数量的子表信息
List<String> ids = list.stream().map(DlTicketWares::getId).collect(Collectors.toList());
List<DlTwItem> twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
item.in(DlTwItem::getTwId, ids)
.apply("wares_already_count < wares_count");
}));
}
if (CollectionUtil.isNotEmpty(twItems)) {
// 更新工单子表主要是把已领料的字段同步给工单配件的数量字段
// 查询工单子表三个查询条件属于那个工单属于配件类型属于需要改变的即申请表的已领取数量小于申请数量的
Set<String> waresId = twItems.stream().map(DlTwItem::getWaresId).collect(Collectors.toSet());
List<DlRepairTitem> items = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(item -> {
item.eq(DlRepairTitem::getTicketId, id)
.eq(DlRepairTitem::getItemType, "02")
.in(DlRepairTitem::getPartId, waresId);
}));
// 同一个配件可能申请过多次属于是一个工单配件可能是对应多个申请表配件
List<DlTwItem> finalTwItems = twItems;
List<DlRepairTitem> AllItems = items.stream().map(item -> {
DlRepairTitem titem = new DlRepairTitem();
titem.setId(item.getId());
List<DlTwItem> wares = finalTwItems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).collect(Collectors.toList());
int sum = wares.stream().mapToInt(DlTwItem::getWaresAlreadyCount).sum();
titem.setItemCount(sum);
BigDecimal discount = item.getItemDiscount() == null ? BigDecimal.ONE : item.getItemDiscount();
titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(sum)).multiply(discount));
return titem;
}).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(twItems)) {
// 更新工单子表主要是把已领料的字段同步给工单配件的数量字段
// 查询工单子表三个查询条件属于那个工单属于配件类型属于需要改变的即申请表的已领取数量小于申请数量的
Set<String> waresId = twItems.stream().map(DlTwItem::getWaresId).collect(Collectors.toSet());
List<DlRepairTitem> items = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(item -> {
item.eq(DlRepairTitem::getTicketId, id)
.eq(DlRepairTitem::getItemType, "02")
.in(DlRepairTitem::getPartId, waresId);
}));
// 同一个配件可能申请过多次属于是一个工单配件可能是对应多个申请表配件
List<DlRepairTitem> AllItems = items.stream().map(item -> {
DlRepairTitem titem = new DlRepairTitem();
titem.setId(item.getId());
List<DlTwItem> wares = twItems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).collect(Collectors.toList());
int sum = wares.stream().mapToInt(DlTwItem::getWaresAlreadyCount).sum();
titem.setItemCount(sum);
BigDecimal discount = item.getItemDiscount() == null ? BigDecimal.ONE : item.getItemDiscount();
titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(sum)).multiply(discount));
return titem;
}).collect(Collectors.toList());
// 可能出现配件申请单审核通过了没有任何领取或全部退了的情况所以如果itemCount等于0直接把这个数据删掉
// 过滤出需要删除的数据
List<DlRepairTitem> delItems = AllItems.stream().filter(item -> item.getItemCount() == 0).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(delItems)) {
// 删除需要删的
titemService.removeBatchByIds(delItems);
Set<String> delIds = delItems.stream().map(DlRepairTitem::getId).collect(Collectors.toSet());
// 得到需要改的
List<DlRepairTitem> updateItems = AllItems.stream().filter(item -> delIds.contains(item.getId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(updateItems)) {
titemService.updateBatchById(updateItems);
// 可能出现配件申请单审核通过了没有任何领取或全部退了的情况所以如果itemCount等于0直接把这个数据删掉
// 过滤出需要删除的数据
List<DlRepairTitem> delItems = AllItems.stream().filter(item -> item.getItemCount() == 0).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(delItems)) {
// 删除需要删的
titemService.removeBatchByIds(delItems);
Set<String> delIds = delItems.stream().map(DlRepairTitem::getId).collect(Collectors.toSet());
// 得到需要改的
List<DlRepairTitem> updateItems = AllItems.stream().filter(item -> delIds.contains(item.getId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(updateItems)) {
titemService.updateBatchById(updateItems);
}
} else {
// 没有需要删的就是全部都需要改
titemService.updateBatchById(AllItems);
}
} else {
// 没有需要删的就是全部都需要改
titemService.updateBatchById(AllItems);
}
// 重新计算维修工单
return computeTicket(id);
// 重新计算维修工单
return computeTicket(id);
}
}
return true;
}
@ -1335,7 +1332,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 查子表
List<DlRepairTitem> list = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().eq(DlRepairTitem::getTicketId, ticketId));
// 计算子表
if (CollectionUtil.isEmpty(list)){
if (CollectionUtil.isEmpty(list)) {
throw exception0(500, "没有项目、配件或其他");
}
List<DlRepairTitem> updateItems = list.stream().map(item -> {
@ -1516,19 +1513,19 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
/**
* 修改工单主表只是主表
*
* @param respVO 请求对象
* @author 小李
* @date 10:25 2024/10/30
* @param respVO 请求对象
**/
@Override
@DSTransactional
public void updateTicket(DlRepairTicketsRespVO respVO){
public void updateTicket(DlRepairTicketsRespVO respVO) {
// 更新主表
baseMapper.updateById(respVO);
// 重新计算
boolean flag = computeTicket(respVO.getId());
if (!flag){
if (!flag) {
throw exception0(500, "系统异常");
}
}
@ -1536,13 +1533,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
/**
* 删除工单
*
* @param id 工单ID
* @author 小李
* @date 20:05 2024/11/1
* @param id 工单ID
**/
@Override
@DSTransactional
public void removeTicketById(String id){
public void removeTicketById(String id) {
// 删除订单
repairOrderInfoService.remove(new LambdaQueryWrapper<RepairOrderInfo>().eq(RepairOrderInfo::getGoodsId, id));
// 删除工单