配件申请单加上图片和一些其他修改

This commit is contained in:
xiaofajia 2024-11-13 19:58:46 +08:00
parent c179d59cc2
commit eaf06a2d77
8 changed files with 129 additions and 18 deletions

View File

@ -3,12 +3,10 @@ package cn.iocoder.yudao.module.tickets.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.tickets.entity.DlTwItem;
import cn.iocoder.yudao.module.tickets.service.DlTwItemService;
import cn.iocoder.yudao.module.tickets.vo.AddTwiVO;
import cn.iocoder.yudao.module.tickets.vo.DlTwItemReqVO;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -41,5 +39,19 @@ public class DlTwItemController {
public CommonResult<?> listTwItem(DlTwItemReqVO reqVO){
return success(dlTwItemService.listTwItem(reqVO));
}
/**
* 给配件申请表子表添加数据
*
* @author 小李
* @date 17:47 2024/11/13
* @param addTwiVO 对象
**/
@PostMapping("/addTwi")
@Operation(summary = "给配件申请表子表添加数据")
public CommonResult<?> addTwi(@RequestBody AddTwiVO addTwiVO){
dlTwItemService.addTwi(addTwiVO);
return CommonResult.ok();
}
}

View File

@ -65,4 +65,7 @@ public class DlTicketWares extends TenantBaseDO {
/** 备注 */
private String remark;
/** 多个图片地址,英文逗号分隔(拍照上传配件申请单时用) */
private String images;
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.tickets.service;
import cn.iocoder.yudao.module.tickets.entity.DlTwItem;
import cn.iocoder.yudao.module.tickets.vo.AddTwiVO;
import cn.iocoder.yudao.module.tickets.vo.DlTwItemReqVO;
import cn.iocoder.yudao.module.tickets.vo.DlTwItemRespVO;
import com.baomidou.mybatisplus.extension.service.IService;
@ -23,4 +24,13 @@ public interface DlTwItemService extends IService<DlTwItem> {
* @param reqVO 请求对象
**/
List<DlTwItemRespVO> listTwItem(DlTwItemReqVO reqVO);
/**
* 给配件申请表子表添加数据
*
* @author 小李
* @date 17:47 2024/11/13
* @param addTwiVO 对象
**/
void addTwi(AddTwiVO addTwiVO);
}

View File

@ -1427,7 +1427,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
titem.setId(item.getId());
// 取出折扣
BigDecimal discount = item.getItemDiscount() == null ? new BigDecimal("1") : item.getItemDiscount();
titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(discount));
BigDecimal itemPrice = item.getItemPrice() == null ? BigDecimal.ZERO : item.getItemPrice();
titem.setItemMoney(itemPrice.multiply(BigDecimal.valueOf(item.getItemCount())).multiply(discount));
return titem;
}).collect(Collectors.toList());
// 更新

View File

@ -205,21 +205,27 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
ticketWares.setAdviserId(Long.valueOf(tickets.getAdviserId()));
ticketWares.setAdviserName(tickets.getAdviserName());
// 图片
if (ObjectUtil.isNotEmpty(respVO.getImages())){
ticketWares.setImages(respVO.getImages());
}
baseMapper.insertOrUpdate(ticketWares);
// 新增修改子表
List<DlTwItem> list = respVO.getItems().stream()
.map(item -> {
DlTwItem twItem = BeanUtil.toBean(item, DlTwItem.class);
twItem.setTwId(ticketWares.getId());
twItem.setWaresStatus("");
twItem.setWaresAlreadyCount(0);
return twItem;
}).collect(Collectors.toList());
if (CollectionUtil.isEmpty(list)) {
throw exception0(500, "配件列表为空");
if (CollectionUtil.isNotEmpty(respVO.getItems())){
List<DlTwItem> list = respVO.getItems().stream()
.map(item -> {
DlTwItem twItem = BeanUtil.toBean(item, DlTwItem.class);
twItem.setTwId(ticketWares.getId());
twItem.setWaresStatus("");
twItem.setWaresAlreadyCount(0);
return twItem;
}).collect(Collectors.toList());
if (CollectionUtil.isEmpty(list)) {
throw exception0(500, "配件列表为空");
}
twItemService.saveOrUpdateBatch(list);
}
twItemService.saveOrUpdateBatch(list);
// 通知对应的维修服务顾问和总检
// 维修服务顾问即创建工单时选的是谁
@ -323,7 +329,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getId())).findFirst().orElse(null);
titem.setItemCount(twItem != null ? twItem.getWaresCount() : 0);
titem.setItemUnit(item.getUnit());
titem.setItemPrice(item.getPrice() != null ? item.getPrice() : BigDecimal.ZERO);
titem.setItemPrice((item.getPrice() != null) ? item.getPrice() : BigDecimal.ZERO);
titem.setItemDiscount(BigDecimal.ONE);
titem.setItemMoney(titem.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(titem.getItemDiscount()));
titem.setRepairIds(String.valueOf(ticketWares.getRepairId()));

View File

@ -6,9 +6,12 @@ import cn.iocoder.yudao.module.project.entity.RepairWares;
import cn.iocoder.yudao.module.project.service.RepairWaresService;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
import cn.iocoder.yudao.module.tickets.entity.DlTicketWares;
import cn.iocoder.yudao.module.tickets.entity.DlTwItem;
import cn.iocoder.yudao.module.tickets.mapper.DlTwItemMapper;
import cn.iocoder.yudao.module.tickets.service.DlTicketWaresService;
import cn.iocoder.yudao.module.tickets.service.DlTwItemService;
import cn.iocoder.yudao.module.tickets.vo.AddTwiVO;
import cn.iocoder.yudao.module.tickets.vo.DlTwItemReqVO;
import cn.iocoder.yudao.module.tickets.vo.DlTwItemRespVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -22,6 +25,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.RepairCons.DICT_REPAIR_UNIT;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
/**
* 针对表dl_tw_item(工单配件申请/退回子表)的数据库操作Service实现
@ -40,6 +44,9 @@ public class DlTwItemServiceImpl extends ServiceImpl<DlTwItemMapper, DlTwItem>
@Resource
@Lazy
private RepairWaresService waresService;
@Resource
@Lazy
private DlTicketWaresService ticketWaresService;
/**
* 根据主表查看全部
@ -78,6 +85,34 @@ public class DlTwItemServiceImpl extends ServiceImpl<DlTwItemMapper, DlTwItem>
}
return null;
}
/**
* 给配件申请表子表添加数据
*
* @author 小李
* @date 17:47 2024/11/13
* @param addTwiVO 对象
**/
@Override
public void addTwi(AddTwiVO addTwiVO){
// 构建子表数据
if (CollectionUtil.isEmpty(addTwiVO.getItems())){
throw exception0(500, "请选择配件");
}
List<DlTwItem> twItems = addTwiVO.getItems().stream().map(item -> {
DlTwItem twItem = new DlTwItem();
twItem.setTwId(addTwiVO.getId());
twItem.setWaresId(item.getId());
twItem.setWaresName(item.getName());
twItem.setWaresCount(item.getCount());
twItem.setWaresAlreadyCount(0);
twItem.setWaresStatus("");
twItem.setRemark(item.getRemark());
return twItem;
}).collect(Collectors.toList());
// 新增
baseMapper.insert(twItems);
}
}

View File

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.tickets.vo;
import lombok.Data;
import java.util.List;
/**
* 给配件申请表子表添加数据
*
* @author 小李
* @date 17:41 2024/11/13
**/
@Data
public class AddTwiVO {
private String id;
private List<AddTwiVoItem> items;
/**
* 配件的信息
*
* @author 小李
* @date 17:45 2024/11/13
**/
@Data
public static class AddTwiVoItem {
/** 配件ID */
private String id;
/** 配件名称 */
private String name;
/** 配件数量 */
private Integer count;
/** 备注 */
private String remark;
}
}

View File

@ -21,6 +21,7 @@
<result property="status" column="status" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" />
<result property="images" column="images" />
</resultMap>
<sql id="Base_SQL">
@ -40,7 +41,8 @@
dtw.adviser_name,
dtw.status,
dtw.remark,
dtw.create_time
dtw.create_time,
dtw.images
from dl_ticket_wares dtw
left join dl_repair_tickets drt
on dtw.ticket_id = drt.id