1
This commit is contained in:
parent
c7eb922c72
commit
36d499dbd5
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.custom.entity;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@ -113,4 +114,10 @@ public class CustomerMain extends TenantBaseDO {
|
||||
*/
|
||||
private String isHangAccount;
|
||||
|
||||
/**
|
||||
* 客户来源text
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String dataFromText;
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ public enum RecordTypeEnum {
|
||||
* 创建工单
|
||||
*/
|
||||
CJGD("cjgd","创建工单"),
|
||||
/**
|
||||
* 修改工单
|
||||
*/
|
||||
XGGD("xggd","修改工单"),
|
||||
/**
|
||||
* 指派施工
|
||||
*/
|
||||
|
@ -16,6 +16,8 @@ public class RepairCons {
|
||||
public static final String DICT_REPAIR_RECORDS_TYPE = "repair_records_type";
|
||||
/**数据字典常量-repair_type-*/
|
||||
public static final String DICT_REPAIR_TYPE = "repair_type";
|
||||
/**数据字典常量-cus_data_from-*/
|
||||
public static final String DICT_CUS_DATA_FROM = "cus_data_from";
|
||||
/**数据字典常量-insurance_type-*/
|
||||
public static final String DICT_INSURANCE_TYPE = "insurance_type";
|
||||
/**数据字典常量-repair_unit-*/
|
||||
|
@ -3,10 +3,12 @@ package cn.iocoder.yudao.module.tickets.controller.admin;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.iocoder.yudao.common.RecordTypeEnum;
|
||||
import cn.iocoder.yudao.common.RepairCons;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.base.service.RepairRecordsService;
|
||||
import cn.iocoder.yudao.module.custom.entity.CarMain;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||
import cn.iocoder.yudao.module.custom.service.CarMainService;
|
||||
@ -48,6 +50,8 @@ public class DlRepairTicketsController {
|
||||
private CustomerMainService customerMainService;
|
||||
@Resource
|
||||
private CarMainService carMainService;
|
||||
@Resource
|
||||
private RepairRecordsService repairRecordsService;
|
||||
|
||||
|
||||
/**
|
||||
@ -105,7 +109,12 @@ public class DlRepairTicketsController {
|
||||
@GetMapping("/getById")
|
||||
@Operation(summary = "查工单主表信息")
|
||||
public CommonResult<?> getById(@RequestParam("id") String id) {
|
||||
return success(dlRepairTicketsService.getById(id));
|
||||
DlRepairTickets repairTickets = dlRepairTicketsService.getById(id);
|
||||
DlRepairTicketsRespVO respVO = new DlRepairTicketsRespVO();
|
||||
org.springframework.beans.BeanUtils.copyProperties(repairTickets,respVO);
|
||||
CustomerMain customerMain = customerMainService.getById(repairTickets.getUserId());
|
||||
respVO.setCustomerInfo(customerMain);
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,11 +126,12 @@ public class DlRepairTicketsController {
|
||||
**/
|
||||
@PostMapping("/updateById")
|
||||
@Operation(summary = "维修工单表 更新")
|
||||
public CommonResult<?> createTicket(@RequestBody DlRepairTickets repairTickets) {
|
||||
public CommonResult<?> updateById(@RequestBody DlRepairTicketsRespVO repairTickets) {
|
||||
//更新客户表
|
||||
CustomerMain customerMain = new CustomerMain();
|
||||
customerMain.setId(repairTickets.getUserId());
|
||||
customerMain.setCusName(repairTickets.getUserName());
|
||||
customerMain.setDataFrom(repairTickets.getCusFrom());
|
||||
customerMain.setPhoneNumber(repairTickets.getUserMobile());
|
||||
customerMainService.updateById(customerMain);
|
||||
//更新车辆表
|
||||
@ -158,6 +168,8 @@ public class DlRepairTicketsController {
|
||||
carMain.setShangye(repairTickets.getShangye());
|
||||
}
|
||||
carMainService.updateById(carMain);
|
||||
//最后记录操作日志--创建工单
|
||||
repairRecordsService.saveRepairRecord(repairTickets.getId(), null, RecordTypeEnum.XGGD.getCode(), "修改工单", repairTickets.getImage());
|
||||
return CommonResult.success(dlRepairTicketsService.updateById(repairTickets));
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.tickets.entity;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@ -88,6 +89,10 @@ public class DlRepairTickets extends TenantBaseDO {
|
||||
* 车辆品牌类型(base_car_brand表的brand_type)
|
||||
*/
|
||||
private String carBrandType;
|
||||
/**
|
||||
* 业务来源(字典:repair_busi_from)
|
||||
*/
|
||||
private String busiFrom;
|
||||
/**
|
||||
* 最近保养日期
|
||||
*/
|
||||
@ -241,4 +246,14 @@ public class DlRepairTickets extends TenantBaseDO {
|
||||
private BigDecimal jiaoqiang;
|
||||
/** 商业险保费 */
|
||||
private BigDecimal shangye;
|
||||
|
||||
/** 更新时上传的图片 */
|
||||
@TableField(exist = false)
|
||||
private String image;
|
||||
/** 维修类型文本 */
|
||||
@TableField(exist = false)
|
||||
private String repairTypeText;
|
||||
/** 支付方式文本 */
|
||||
@TableField(exist = false)
|
||||
private String payTypeText;
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService;
|
||||
import cn.iocoder.yudao.module.tickets.service.DlTicketWaresService;
|
||||
import cn.iocoder.yudao.module.tickets.service.DlTwItemService;
|
||||
import cn.iocoder.yudao.module.tickets.tools.WordUtil;
|
||||
import cn.iocoder.yudao.module.tickets.utils.TicketsOperateUtil;
|
||||
import cn.iocoder.yudao.module.tickets.vo.*;
|
||||
import cn.iocoder.yudao.util.CreateQRCodeUtil;
|
||||
import cn.iocoder.yudao.util.SendSmsUtil;
|
||||
@ -195,6 +196,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
private CompanyService companyService;
|
||||
@Resource
|
||||
private AdminUserService userService;
|
||||
@Resource
|
||||
private TicketsOperateUtil operateUtil;
|
||||
|
||||
/**
|
||||
* 维修工单表 新增
|
||||
@ -241,8 +244,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
|
||||
/* 更新车辆的字段最近保养日期、最近保养公里数等等 start */
|
||||
if(null!=ticketsRespVO.getMaintenanceDate() || null!= ticketsRespVO.getMaintenanceMileage()){
|
||||
CarMain carMain = new CarMain();
|
||||
carMain.setId(ticketsRespVO.getCarId());
|
||||
CarMain carMain = carMainService.getById(ticketsRespVO.getCarId());
|
||||
if(null!=carMain.getCarRegisterDate()){
|
||||
carMain.setCarYear(operateUtil.computeCarYear(Date.from(carMain.getCarRegisterDate().atZone(ZoneId.systemDefault()).toInstant())));
|
||||
}
|
||||
//保养日期
|
||||
if(null!=ticketsRespVO.getMaintenanceDate()){
|
||||
carMain.setMaintenanceDate(ticketsRespVO.getMaintenanceDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||
@ -277,6 +282,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
}
|
||||
/* 更新车辆的最近保养日期、最近保养公里数 end */
|
||||
|
||||
/* 更新客户来源 */
|
||||
if(StringUtils.isNotEmpty(ticketsRespVO.getCusFrom())){
|
||||
CustomerMain customerMain = customerMainService.getById(ticketsRespVO.getUserId());
|
||||
customerMain.setDataFrom(ticketsRespVO.getCusFrom());
|
||||
customerMainService.updateById(customerMain);
|
||||
}
|
||||
|
||||
// 计算参考成本、参考毛利、领料状态、工单进行状态
|
||||
// TODO 参考成本 暂时为0
|
||||
ticketsRespVO.setCost(new BigDecimal("0"));
|
||||
@ -415,22 +427,27 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
CarMainRespVO carInfo = carMainService.queryCarById(dlRepairTickets.getCarId());
|
||||
//计算车龄
|
||||
if(null!=carInfo.getCarRegisterDate()){
|
||||
Long betweenMonth = DateUtil.betweenMonth(Date.from(carInfo.getCarRegisterDate().atZone(ZoneId.systemDefault()).toInstant()), new Date(), true);
|
||||
String carYear = String.format("%.2f",betweenMonth.doubleValue() / 12);
|
||||
Double carYear = operateUtil.computeCarYear(Date.from(carInfo.getCarRegisterDate().atZone(ZoneId.systemDefault()).toInstant()));
|
||||
//更新回去
|
||||
CarMain carMain = new CarMain();
|
||||
carMain.setId(dlRepairTickets.getCarId());
|
||||
carMain.setCarYear(Double.parseDouble(carYear));
|
||||
if(null==carInfo.getCarYear() ||!carInfo.getCarYear().equals(Double.parseDouble(carYear))){
|
||||
carMain.setCarYear(carYear);
|
||||
if(null==carInfo.getCarYear() ||!carInfo.getCarYear().equals(carYear)){
|
||||
carMainService.updateById(carMain);
|
||||
}
|
||||
carInfo.setCarYear(Double.parseDouble(carYear));
|
||||
carInfo.setCarYear(carYear);
|
||||
}
|
||||
result.setCarInfo(carInfo);
|
||||
}
|
||||
|
||||
//查用户信息
|
||||
CustomerMain customerInfo = customerService.getById(dlRepairTickets.getUserId());
|
||||
if(StringUtils.isNotEmpty(customerInfo.getDataFrom())){
|
||||
//翻译客户来源
|
||||
List<DictDataRespDTO> dataFromList = dictDataApi.getDictDataList(DICT_CUS_DATA_FROM);
|
||||
Map<String,String> dataFromMap = dataFromList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel));
|
||||
customerInfo.setDataFromText(dataFromMap.get(customerInfo.getDataFrom()));
|
||||
}
|
||||
result.setCustomerInfo(customerInfo);
|
||||
// 查工单子表
|
||||
List<DlRepairTitem> itemList = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().eq(DlRepairTitem::getTicketId, id));
|
||||
@ -1011,6 +1028,39 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译字典
|
||||
* @author vinjor-M
|
||||
* @date 16:25 2025/1/9
|
||||
* @param dlRepairTicketsIPage TODO
|
||||
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.tickets.entity.DlRepairTickets>
|
||||
**/
|
||||
private IPage<DlRepairTickets> dealDictText(IPage<DlRepairTickets> dlRepairTicketsIPage){
|
||||
//维修类型
|
||||
List<DictDataRespDTO> repairTypeList = dictDataApi.getDictDataList(DICT_REPAIR_TYPE);
|
||||
Map<String,String> repairTypeMap = repairTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel));
|
||||
//支付方式
|
||||
List<DictDataRespDTO> payTypeList = dictDataApi.getDictDataList(DICT_REPAIR_PAY_TYPE);
|
||||
|
||||
dlRepairTicketsIPage.getRecords().forEach(item->{
|
||||
if(StringUtils.isNotEmpty(item.getRepairType())){
|
||||
item.setRepairTypeText(repairTypeMap.get(item.getRepairType()));
|
||||
}
|
||||
if(StringUtils.isNotEmpty(item.getPayType())){
|
||||
payTypeList.forEach(payType->{
|
||||
if(item.getPayType().contains(payType.getValue())){
|
||||
if(StringUtils.isEmpty(item.getPayTypeText())){
|
||||
item.setPayTypeText(payType.getLabel());
|
||||
}else{
|
||||
item.setPayTypeText(item.getPayTypeText()+","+payType.getLabel());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return dlRepairTicketsIPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类查询工单分页
|
||||
*
|
||||
@ -1025,7 +1075,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
//根据id集和查询
|
||||
DlRepairTicketsReqVO queryObj = new DlRepairTicketsReqVO();
|
||||
queryObj.setIdList(repairTicketsReqVO.getIdList());
|
||||
return baseMapper.getPageTypeAll(queryObj, page);
|
||||
return dealDictText(baseMapper.getPageTypeAll(queryObj, page));
|
||||
}
|
||||
if (userRoleCode.equals(RepairRoleEnum.ADMIN.getCode())) {
|
||||
//维修管理员看所有数据
|
||||
@ -1071,7 +1121,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
}
|
||||
if (RepairCons.TICKETS_WAITING.equals(repairTicketsReqVO.getSelectType())) {
|
||||
//查待处理
|
||||
return baseMapper.getPageType(repairTicketsReqVO, page);
|
||||
return dealDictText(baseMapper.getPageType(repairTicketsReqVO, page));
|
||||
} else {
|
||||
//查所有,
|
||||
if(("jinchang".equals(repairTicketsReqVO.getTicketsStatus()) ||
|
||||
@ -1126,7 +1176,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
repairTicketsReqVO.setStatusList(statusList);
|
||||
}
|
||||
}
|
||||
return baseMapper.getPageTypeAll(repairTicketsReqVO, page);
|
||||
return dealDictText(baseMapper.getPageTypeAll(repairTicketsReqVO, page));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
package cn.iocoder.yudao.module.tickets.utils;
|
||||
|
||||
import cn.iocoder.yudao.module.base.service.RepairRecordsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 工单操作常用util
|
||||
* @author vinjor-M
|
||||
@ -11,8 +12,17 @@ import org.springframework.stereotype.Component;
|
||||
**/
|
||||
@Component
|
||||
public class TicketsOperateUtil {
|
||||
@Autowired
|
||||
private RepairRecordsService repairRecordsService;
|
||||
|
||||
|
||||
/**
|
||||
* 计算车龄
|
||||
* @author vinjor-M
|
||||
* @date 14:47 2025/1/9
|
||||
* @param registerDate 车辆注册日期
|
||||
* @return java.lang.Double
|
||||
**/
|
||||
public Double computeCarYear(Date registerDate){
|
||||
long betweenMonth = DateUtil.betweenMonth(registerDate, new Date(), true);
|
||||
String carYear = String.format("%.2f", (double) betweenMonth / 12);
|
||||
return Double.parseDouble(carYear);
|
||||
}
|
||||
}
|
||||
|
@ -72,4 +72,7 @@ public class DlRepairTicketsRespVO extends DlRepairTickets {
|
||||
private String repairTypeText;
|
||||
/** 车辆实际竣工(总检完成)时间 */
|
||||
private String realOverDate;
|
||||
|
||||
/** 客户来源 */
|
||||
private String cusFrom;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
<result property="carBrandId" column="car_brand_id" jdbcType="VARCHAR"/>
|
||||
<result property="carBrandName" column="car_brand_name" jdbcType="VARCHAR"/>
|
||||
<result property="carBrandType" column="car_brand_type" jdbcType="VARCHAR"/>
|
||||
<result property="busiFrom" column="busi_from" jdbcType="VARCHAR"/>
|
||||
<result property="adviserId" column="adviser_id" jdbcType="VARCHAR"/>
|
||||
<result property="adviserName" column="adviser_name" jdbcType="VARCHAR"/>
|
||||
<result property="payType" column="pay_type" jdbcType="VARCHAR"/>
|
||||
@ -74,6 +75,7 @@
|
||||
<result property="carBrandId" column="car_brand_id" jdbcType="VARCHAR"/>
|
||||
<result property="carBrandName" column="car_brand_name" jdbcType="VARCHAR"/>
|
||||
<result property="carBrandType" column="car_brand_type" jdbcType="VARCHAR"/>
|
||||
<result property="busiFrom" column="busi_from" jdbcType="VARCHAR"/>
|
||||
<result property="adviserId" column="adviser_id" jdbcType="VARCHAR"/>
|
||||
<result property="adviserName" column="adviser_name" jdbcType="VARCHAR"/>
|
||||
<result property="payType" column="pay_type" jdbcType="VARCHAR"/>
|
||||
@ -136,6 +138,7 @@
|
||||
car_brand_id,
|
||||
car_brand_name,
|
||||
car_brand_type,
|
||||
busi_from,
|
||||
adviser_id,
|
||||
adviser_name,
|
||||
pay_type,
|
||||
@ -368,7 +371,7 @@
|
||||
left join base_customer_main bcm ON drt.user_id = bcm.id
|
||||
</if>
|
||||
left join dl_repair_titem drti
|
||||
on drt.id = drti.ticket_id AND drti.deleted = '0'
|
||||
on drt.id = drti.ticket_id AND drti.deleted = '0' AND drti.item_type='01'
|
||||
where drt.deleted = '0'
|
||||
<if test="map.ticketNo != null and map.ticketNo != ''">
|
||||
and (
|
||||
@ -381,6 +384,12 @@
|
||||
drt.user_mobile like concat('%', #{map.ticketNo}, '%')
|
||||
or
|
||||
drt.remark like concat('%', #{map.ticketNo}, '%')
|
||||
or
|
||||
drt.car_brand_name like concat('%', #{map.ticketNo}, '%')
|
||||
or
|
||||
drt.handle_name like concat('%', #{map.ticketNo}, '%')
|
||||
or
|
||||
drti.item_name like concat('%', #{map.ticketNo}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="map.searchTimeArray != null and map.searchTimeArray.length > 0">
|
||||
|
Loading…
Reference in New Issue
Block a user