问题修改
This commit is contained in:
parent
45b9fc59fc
commit
5a970eff6a
|
|
@ -32,7 +32,7 @@ public class BookCarInfoDto {
|
|||
private String bookCode;
|
||||
|
||||
@ApiModelProperty(value = "订单日期")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date orderTime;
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ public class BookCarInfoDto {
|
|||
private String creater;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
|
|
@ -66,11 +66,13 @@ public class BookCarInfoDto {
|
|||
private String updater;
|
||||
|
||||
@ApiModelProperty(value = "修改日期")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
private String address;
|
||||
|
||||
private List<BookCarDetailDto> detailList;
|
||||
|
||||
private String devType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public interface BookCarMapper {
|
|||
|
||||
/**
|
||||
* 添加预约车详情
|
||||
*
|
||||
* @param bookCarInfoDto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -24,6 +25,7 @@ public interface BookCarMapper {
|
|||
|
||||
/**
|
||||
* 查询预约车详情
|
||||
*
|
||||
* @param devInfo
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -31,18 +33,22 @@ public interface BookCarMapper {
|
|||
|
||||
/**
|
||||
* 查询设备详情
|
||||
*
|
||||
* @param maId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
DevInfoVo selectDevInfoByMaId(@Param("maId") String maId, @Param("userId") Long userId);
|
||||
DevInfoVo selectDevInfoByMaId(@Param("maId") String maId, @Param("userId") Long userId, @Param("devType") String devType);
|
||||
|
||||
/**
|
||||
* 删除预约车
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
int deleteByIds(@Param("array") Integer[] ids);
|
||||
|
||||
List<DevInfoVo> getBookCarDetailsTool(BookCarInfoDto bookCarInfoDto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class BookCarServiceImpl implements BookCarService {
|
|||
bookCarInfoDto.setCreater(userId.toString());
|
||||
bookCarInfoDto.setOrderUser(userId);
|
||||
//先根据设备id查询设备信息
|
||||
DevInfoVo devInfoVo = bookCarMapper.selectDevInfoByMaId(bookCarInfoDto.getMaId(), userId);
|
||||
DevInfoVo devInfoVo = bookCarMapper.selectDevInfoByMaId(bookCarInfoDto.getMaId(), userId, bookCarInfoDto.getDevType());
|
||||
if (devInfoVo != null) {
|
||||
return AjaxResult.error("该设备已添加到预约车,请勿重复添加");
|
||||
}
|
||||
|
|
@ -59,7 +59,8 @@ public class BookCarServiceImpl implements BookCarService {
|
|||
List<BookCarVo> list = new ArrayList<>();
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
bookCarInfoDto.setOrderUser(userId);
|
||||
List<DevInfoVo> bookCarDetails = bookCarMapper.getBookCarDetails(bookCarInfoDto);
|
||||
List<DevInfoVo> bookCarDetails = new ArrayList<>();
|
||||
bookCarDetails = bookCarMapper.getBookCarDetails(bookCarInfoDto);
|
||||
// 如果 bookCarDetails 不为空,处理文件信息
|
||||
if (CollectionUtils.isNotEmpty(bookCarDetails)) {
|
||||
// 为每个 DevInfoVo 设置文件信息
|
||||
|
|
@ -73,6 +74,7 @@ public class BookCarServiceImpl implements BookCarService {
|
|||
bookCarDetail.setPicUrl(mainFileInfoList.get(0).getFileUrl());
|
||||
}
|
||||
}
|
||||
|
||||
// 根据 companyName, person, personPhone 进行分组
|
||||
Map<CompanyPersonPhoneKey, List<DevInfoVo>> groupedByKey = bookCarDetails.stream()
|
||||
.collect(Collectors.groupingBy(bookCarDetail -> new CompanyPersonPhoneKey(
|
||||
|
|
@ -101,6 +103,7 @@ public class BookCarServiceImpl implements BookCarService {
|
|||
|
||||
/**
|
||||
* 删除预约车
|
||||
*
|
||||
* @param devInfo
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -124,12 +127,13 @@ public class BookCarServiceImpl implements BookCarService {
|
|||
|
||||
/**
|
||||
* 查询立即承租详情
|
||||
*
|
||||
* @param devInfo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getBookCarDetailByMaId(BookCarInfoDto devInfo) {
|
||||
log.info("查询立即承租详情{}",devInfo);
|
||||
log.info("查询立即承租详情{}", devInfo);
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
devInfo.setOrderUser(userId);
|
||||
List<DevInfoVo> bookCarDetails = bookCarMapper.getBookCarDetails(devInfo);
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ public class MaDevInfoController extends BaseController {
|
|||
@PostMapping("/export")
|
||||
public void export(MaDevInfo o, HttpServletResponse response) throws IOException {
|
||||
// 1. 查询所有符合条件的数据(忽略分页)
|
||||
List<MaDevInfo> dataList = service.list(o);
|
||||
List<MaDevInfo> dataList = service.export(o);
|
||||
|
||||
// 2. 转换数据为导出格式(处理特殊字段)
|
||||
List<Map<String, Object>> exportData = dataList.stream()
|
||||
|
|
|
|||
|
|
@ -340,4 +340,6 @@ public class MaDevInfo {
|
|||
|
||||
private String remainingStopYear;
|
||||
|
||||
private String actualStopYear;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,4 +30,6 @@ public interface MaDevInfoService {
|
|||
MaDevInfo getDevice(Integer maId);
|
||||
|
||||
AjaxResult getDeviceByMaIds(String maIds);
|
||||
|
||||
List<MaDevInfo> export(MaDevInfo o);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,6 +120,24 @@ public class MaDevInfoServiceImpl implements MaDevInfoService {
|
|||
return AjaxResult.success(mapper.getDeviceByMaIds(maIdArray));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MaDevInfo> export(MaDevInfo o) {
|
||||
/* Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||
o.setPropertyUnitId(Math.toIntExact(thisLoginUserDeptId));*/
|
||||
List<MaDevInfo> list = mapper.list(o);
|
||||
list.forEach(item -> {
|
||||
List<DevInfoPropertyVo> propertiiesList = mapper.getProperties(item);
|
||||
if (propertiiesList != null && !propertiiesList.isEmpty()) {
|
||||
item.setPropertyVoList(propertiiesList);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将扁平列表构建成树,并添加一个总的根节点,根节点名称包含设备总数
|
||||
*/
|
||||
|
|
@ -127,7 +145,7 @@ public class MaDevInfoServiceImpl implements MaDevInfoService {
|
|||
// 统计设备总数(列表的size即为总数量)
|
||||
//int totalCount = list == null ? 0 : list.size();
|
||||
|
||||
Integer totalCount=mapper.selectTotalDeviceCount();
|
||||
Integer totalCount = mapper.selectTotalDeviceCount();
|
||||
|
||||
if (list == null || list.isEmpty()) {
|
||||
// 空列表时显示总数为0
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import java.util.Objects;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dev")
|
||||
@Api(value = "设备信息",tags = "设备管理")
|
||||
@Api(value = "设备信息", tags = "设备管理")
|
||||
public class DevInfoController extends BaseController {
|
||||
|
||||
@Resource
|
||||
|
|
@ -88,6 +88,7 @@ public class DevInfoController extends BaseController {
|
|||
|
||||
/**
|
||||
* 获取公司列表(供装备新增及首页所属公司筛选使用)
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -118,7 +119,7 @@ public class DevInfoController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
// @RequiresPermissions("equip:info:list")
|
||||
// @RequiresPermissions("equip:info:list")
|
||||
@ApiOperation(value = "装备推荐列表")
|
||||
@GetMapping("/hotList")
|
||||
public AjaxResult hotList(DevInfoVo devInfo) {
|
||||
|
|
@ -143,6 +144,18 @@ public class DevInfoController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备信息详细信息
|
||||
*/
|
||||
//@RequiresPermissions("equip:info:query")
|
||||
@ApiOperation(value = "装备详情")
|
||||
@GetMapping(value = "/getInfo")
|
||||
public AjaxResult getInfoById(Long id, String devType,
|
||||
@RequestParam(value = "isHome", required = false) Boolean isHome) {
|
||||
return success(devType.equals("0") ? devInfoService.selectDevInfoByMaId(id, isHome) : devInfoService.selectToolByMaId(id, isHome));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上下架(批量)
|
||||
*/
|
||||
|
|
@ -156,7 +169,7 @@ public class DevInfoController extends BaseController {
|
|||
/**
|
||||
* 修改设备信息
|
||||
*/
|
||||
// @RequiresPermissions("equip:info:edit")
|
||||
// @RequiresPermissions("equip:info:edit")
|
||||
@ApiOperation(value = "修改装备信息")
|
||||
@PostMapping("edit")
|
||||
public AjaxResult edit(@RequestBody @Valid DevInfo devInfo) {
|
||||
|
|
@ -168,7 +181,7 @@ public class DevInfoController extends BaseController {
|
|||
*/
|
||||
//@RequiresPermissions("equip:info:remove")
|
||||
@ApiOperation(value = "删除装备")
|
||||
@PostMapping("/remove")
|
||||
@PostMapping("/remove")
|
||||
public AjaxResult remove(@RequestBody Long[] maIds) {
|
||||
return toAjax(devInfoService.deleteDevInfoByMaIds(maIds));
|
||||
}
|
||||
|
|
@ -176,6 +189,7 @@ public class DevInfoController extends BaseController {
|
|||
|
||||
/**
|
||||
* 设备信息录入---录入经纬度
|
||||
*
|
||||
* @param infoMotionDto 设备信息
|
||||
*/
|
||||
@ApiOperation(value = "装备信息录入--含经纬度")
|
||||
|
|
@ -186,11 +200,12 @@ public class DevInfoController extends BaseController {
|
|||
|
||||
/**
|
||||
* 添加设备--UUID生成CODE--字符串
|
||||
*
|
||||
* @param devInfo 设备信息
|
||||
*/
|
||||
@ApiOperation(value = "添加设备--字符串传入--UUID生成CODE")
|
||||
@PostMapping("/outType")
|
||||
public void outType(@RequestBody String devInfo){
|
||||
public void outType(@RequestBody String devInfo) {
|
||||
devInfoService.insertOutType(devInfo);
|
||||
}
|
||||
|
||||
|
|
@ -218,7 +233,7 @@ public class DevInfoController extends BaseController {
|
|||
/**
|
||||
* 导出设备信息列表
|
||||
*/
|
||||
// @RequiresPermissions("equip:info:export")
|
||||
// @RequiresPermissions("equip:info:export")
|
||||
@ApiOperation(value = "导出装备信息")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DevInfoVo devInfo) {
|
||||
|
|
@ -269,28 +284,28 @@ public class DevInfoController extends BaseController {
|
|||
|
||||
/**
|
||||
* 设备信息导入
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "设备信息导入")
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file)
|
||||
{
|
||||
public AjaxResult importData(MultipartFile file) {
|
||||
return devInfoService.importTbPeople(file);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "设备信息-审核")
|
||||
@PostMapping("/updateDeviceStatus")
|
||||
public AjaxResult updateDeviceStatus(String ids, String status){
|
||||
public AjaxResult updateDeviceStatus(String ids, String status) {
|
||||
try {
|
||||
Integer i = devInfoService.updateCheckStatus(ids,status);
|
||||
if (i > 0){
|
||||
Integer i = devInfoService.updateCheckStatus(ids, status);
|
||||
if (i > 0) {
|
||||
return AjaxResult.success("审核成功");
|
||||
}else {
|
||||
} else {
|
||||
return AjaxResult.error("审核失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("报错啦",e);
|
||||
} catch (Exception e) {
|
||||
logger.error("报错啦", e);
|
||||
return AjaxResult.error("调用异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,4 +194,8 @@ public class DevInfoVo extends DevInfo {
|
|||
|
||||
private String status;
|
||||
private String csId;
|
||||
|
||||
private String devType;
|
||||
|
||||
private String manageMode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,5 +307,7 @@ public interface DevInfoMapper {
|
|||
int getTurnoverRateByLevel(DevInfoReq devInfoReq);
|
||||
|
||||
int getProjectNUm();
|
||||
|
||||
DevInfoVo selectToolByMaId(Long maId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,4 +130,6 @@ public interface DevInfoService {
|
|||
List<DevInfoVo> selectCheckDevInfoList(DevInfoVo devInfo);
|
||||
|
||||
Integer updateCheckStatus(String ids, String status);
|
||||
|
||||
DevInfoVo selectToolByMaId(Long maId, Boolean isHome);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1075,6 +1075,16 @@ public class DevInfoServiceImpl implements DevInfoService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maId
|
||||
* @param isHome
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DevInfoVo selectToolByMaId(Long maId, Boolean isHome) {
|
||||
return devInfoMapper.selectToolByMaId(maId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取Excel表格数据,做非空判断
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import com.bonus.material.lease.domain.DeptDto;
|
|||
import com.bonus.material.lease.mapper.LeaseRepairRecordMapper;
|
||||
import com.bonus.material.order.domain.OrderDetailDto;
|
||||
import com.bonus.material.order.domain.OrderInfoDto;
|
||||
import com.bonus.material.order.domain.ProDto;
|
||||
import com.bonus.material.order.mapper.OrderMapper;
|
||||
import com.bonus.material.order.service.OrderService;
|
||||
import com.bonus.system.api.RemoteFileService;
|
||||
|
|
@ -84,8 +85,8 @@ public class OrderController extends BaseController {
|
|||
@ApiOperation(value = "提交预约车到订单")
|
||||
@PostMapping("/submitBookCar")
|
||||
@PreventRepeatSubmit
|
||||
public AjaxResult submitBookCar(@RequestBody List<OrderInfoDto> orderInfoDto) {
|
||||
Integer i = orderService.submitOrderInfo(orderInfoDto);
|
||||
public AjaxResult submitBookCar(@RequestBody ProDto proDto) {
|
||||
Integer i = orderService.submitOrderInfo(proDto);
|
||||
if (i > 0) {
|
||||
return success("下单成功");
|
||||
} else {
|
||||
|
|
@ -128,6 +129,7 @@ public class OrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 获取单个订单取件码
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -286,7 +288,9 @@ public class OrderController extends BaseController {
|
|||
if (text != null) {
|
||||
for (Map.Entry<String, String> entry : replacements.entrySet()) {
|
||||
String entryValue = entry.getValue();
|
||||
if (entryValue == null) {continue;}
|
||||
if (entryValue == null) {
|
||||
continue;
|
||||
}
|
||||
text = text.replace(entry.getKey(), entryValue);
|
||||
}
|
||||
run.setText(text, 0);
|
||||
|
|
|
|||
|
|
@ -44,12 +44,16 @@ public class OrderDetailDto {
|
|||
@ApiModelProperty(value = "设备ids")
|
||||
private List<Integer> maIds;
|
||||
|
||||
/** 设备编码 */
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
@Excel(name = "设备编码")
|
||||
@ApiModelProperty(value = "设备编码")
|
||||
private String code;
|
||||
|
||||
/** 设备唯一标识符,用户输入,比如车架号 */
|
||||
/**
|
||||
* 设备唯一标识符,用户输入,比如车架号
|
||||
*/
|
||||
@Excel(name = "设备唯一标识符")
|
||||
@ApiModelProperty(value = "设备唯一标识符")
|
||||
private String identifyCode;
|
||||
|
|
@ -190,4 +194,6 @@ public class OrderDetailDto {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private String receivingTime;
|
||||
|
||||
private String devType;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,4 +173,31 @@ public class OrderInfoDto {
|
|||
|
||||
|
||||
private String maIds;
|
||||
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty(value = "需求单位")
|
||||
private String useUnit;
|
||||
|
||||
@ApiModelProperty(value = "项目编号")
|
||||
private String proCode;
|
||||
|
||||
@ApiModelProperty(value = "使用项目")
|
||||
private String proName;
|
||||
|
||||
@ApiModelProperty(value = "项目类型")
|
||||
private String proType;
|
||||
|
||||
@ApiModelProperty(value = "电压等级")
|
||||
private String voltageLevel;
|
||||
|
||||
@ApiModelProperty(value = "省")
|
||||
private String proProvince;
|
||||
|
||||
@ApiModelProperty(value = "市")
|
||||
private String proCity;
|
||||
|
||||
@ApiModelProperty(value = "区/县")
|
||||
private String proCounty;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package com.bonus.material.order.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ProDto {
|
||||
|
||||
@ApiModelProperty(value = "需求单位")
|
||||
private String useUnit;
|
||||
|
||||
@ApiModelProperty(value = "项目编号")
|
||||
private String proCode;
|
||||
|
||||
@ApiModelProperty(value = "使用项目")
|
||||
private String proName;
|
||||
|
||||
@ApiModelProperty(value = "项目类型")
|
||||
private String proType;
|
||||
|
||||
@ApiModelProperty(value = "电压等级")
|
||||
private String voltageLevel;
|
||||
|
||||
@ApiModelProperty(value = "省")
|
||||
private String proProvince;
|
||||
|
||||
@ApiModelProperty(value = "市")
|
||||
private String proCity;
|
||||
|
||||
@ApiModelProperty(value = "区/县")
|
||||
private String proCounty;
|
||||
|
||||
|
||||
List<OrderInfoDto> orderInfoDto;
|
||||
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import com.bonus.material.device.domain.vo.DevInfoVo;
|
|||
import com.bonus.material.largeScreen.entity.OrderData;
|
||||
import com.bonus.material.order.domain.OrderDetailDto;
|
||||
import com.bonus.material.order.domain.OrderInfoDto;
|
||||
import com.bonus.material.order.domain.ProDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ import java.util.List;
|
|||
*/
|
||||
public interface OrderService {
|
||||
|
||||
Integer submitOrderInfo(List<OrderInfoDto> orderInfoDto);
|
||||
Integer submitOrderInfo(ProDto proDto);
|
||||
|
||||
List<OrderInfoDto> getOrderDetails(OrderInfoDto orderInfoDto) throws Exception;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.bonus.material.lease.domain.LeaseRepairRecord;
|
|||
import com.bonus.material.lease.mapper.LeaseRepairRecordMapper;
|
||||
import com.bonus.material.order.domain.OrderDetailDto;
|
||||
import com.bonus.material.order.domain.OrderInfoDto;
|
||||
import com.bonus.material.order.domain.ProDto;
|
||||
import com.bonus.material.order.mapper.OrderMapper;
|
||||
import com.bonus.material.order.service.OrderService;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
|
|
@ -88,10 +89,10 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer submitOrderInfo(List<OrderInfoDto> orderInfoDtos) {
|
||||
public Integer submitOrderInfo(ProDto proDto) {
|
||||
int j = 0;
|
||||
orderInfoDtos.removeIf(Objects::isNull);
|
||||
for (OrderInfoDto orderInfoDto : orderInfoDtos) {
|
||||
proDto.getOrderInfoDto().removeIf(Objects::isNull);
|
||||
for (OrderInfoDto orderInfoDto : proDto.getOrderInfoDto()) {
|
||||
// 首先判断库存是否足够
|
||||
List<OrderDetailDto> orderDetailDtos = orderInfoDto.getDetailsList();
|
||||
if (orderDetailDtos == null) {
|
||||
|
|
@ -111,14 +112,6 @@ public class OrderServiceImpl implements OrderService {
|
|||
throw new RuntimeException("设备非在库状态,无法下单!");
|
||||
}
|
||||
String devPersonPhone = maInfo.getPersonPhone();
|
||||
|
||||
//如果是编码设备,改设备状态为共享中
|
||||
// orderDetailDto.setMaStatus(MaStatusEnum.UNDER_RENT.getCode().toString());
|
||||
// Integer updateDeviceStatus = orderMapper.updateDeviceStatus(orderDetailDto);
|
||||
// if (updateDeviceStatus < 1) {
|
||||
// throw new RuntimeException("设备状态修改失败");
|
||||
// }
|
||||
// 更改购物车状态为已下单
|
||||
orderMapper.updateMaStatus(orderDetailDto);
|
||||
}
|
||||
|
||||
|
|
@ -126,6 +119,14 @@ public class OrderServiceImpl implements OrderService {
|
|||
orderInfoDto.setBuyerId(userid.intValue());
|
||||
orderInfoDto.setBuyerCompany(Optional.ofNullable(SecurityUtils.getLoginUser().getSysUser().getCompanyId()).orElse(SecurityUtils.getLoginUser().getSysUser().getDeptId()).intValue());
|
||||
orderInfoDto.setCreater(userid);
|
||||
orderInfoDto.setUseUnit(proDto.getUseUnit());
|
||||
orderInfoDto.setProCode(proDto.getProCode());
|
||||
orderInfoDto.setProName(proDto.getProName());
|
||||
orderInfoDto.setProType(proDto.getProType());
|
||||
orderInfoDto.setVoltageLevel(proDto.getVoltageLevel());
|
||||
orderInfoDto.setProProvince(proDto.getProProvince());
|
||||
orderInfoDto.setProCity(proDto.getProCity());
|
||||
orderInfoDto.setProCounty(proDto.getProCounty());
|
||||
Integer i = orderMapper.insertOrderInfo(orderInfoDto);
|
||||
j += i;
|
||||
if (i > 0) {
|
||||
|
|
@ -256,7 +257,11 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
// 计算天数差
|
||||
long days = ChronoUnit.DAYS.between(preOutboundLocalDate, rentEndLocalDate);
|
||||
if (days == 0) { days = 1;} else {days = days + 1;}
|
||||
if (days == 0) {
|
||||
days = 1;
|
||||
} else {
|
||||
days = days + 1;
|
||||
}
|
||||
return days;
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException("日期转换错误", e);
|
||||
|
|
@ -378,8 +383,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
tmTask.setTaskStatus(minOrderStatus.getAsInt());
|
||||
tmTask.setCode(dtos.get(0).getOrderCode());
|
||||
if (orderInfoDto.getOrderStatus().equals(OrderStatusEnum.ORDER_PENDING_SHIPMENT.getStatus().toString()) ||
|
||||
orderInfoDto.getOrderStatus().equals(OrderStatusEnum.ORDER_TERMINATED.getStatus().toString()))
|
||||
{
|
||||
orderInfoDto.getOrderStatus().equals(OrderStatusEnum.ORDER_TERMINATED.getStatus().toString())) {
|
||||
tmTask.setNoticeCompanyId(tmTask.getBuyerCompanyId());
|
||||
|
||||
} else if (orderInfoDto.getOrderStatus().equals(OrderStatusEnum.ORDER_RECEIVE.getStatus().toString()) ||
|
||||
|
|
|
|||
|
|
@ -76,4 +76,44 @@ public class ToolLedgerController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 工具台账表格
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return 表格
|
||||
*/
|
||||
@ApiOperation(value = "工具台账表格")
|
||||
@GetMapping("/getToolByTypeId")
|
||||
public TableDataInfo getToolByTypeId(ToolLedgerEntity entity) {
|
||||
try {
|
||||
startPage();
|
||||
List<ToolLedgerEntity> list = toolLedgerService.getToolByTypeId(entity);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 工具台账表格
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return 表格
|
||||
*/
|
||||
@ApiOperation(value = "工具台账表格")
|
||||
@GetMapping("/getToolByPro")
|
||||
public TableDataInfo getToolByPro(ToolLedgerEntity entity) {
|
||||
try {
|
||||
startPage();
|
||||
List<ToolLedgerEntity> list = toolLedgerService.getToolByPro(entity);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,11 @@ public class ToolLedgerEntity implements Serializable {
|
|||
*/
|
||||
private BigDecimal scrapNum;
|
||||
|
||||
/**
|
||||
* 共享数量
|
||||
*/
|
||||
private BigDecimal shareNum;
|
||||
|
||||
/**
|
||||
* 厂家id(非空,默认0)
|
||||
*/
|
||||
|
|
@ -186,4 +191,6 @@ public class ToolLedgerEntity implements Serializable {
|
|||
private String fileList;
|
||||
|
||||
private List<DevInfoPropertyVo> propertyVoList;
|
||||
|
||||
private String proName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,9 @@ public interface ToolLedgerMapper {
|
|||
void delProperties(Long toolId);
|
||||
|
||||
Integer insertDevInfoProperties(@Param("list") List<DevInfoPropertyVo> item, @Param("toolId") Long toolId);
|
||||
|
||||
List<ToolLedgerEntity> getToolByTypeId(ToolLedgerEntity entity);
|
||||
|
||||
List<ToolLedgerEntity> getToolByPro(ToolLedgerEntity entity);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,4 +65,22 @@ public class ToolLedgerServiceImpl implements ToolLedgerService {
|
|||
return AjaxResult.error("修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ToolLedgerEntity> getToolByTypeId(ToolLedgerEntity entity) {
|
||||
return mapper.getToolByTypeId(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ToolLedgerEntity> getToolByPro(ToolLedgerEntity entity) {
|
||||
return mapper.getToolByPro(entity);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,4 +25,9 @@ public interface ToolLedgerService {
|
|||
|
||||
|
||||
AjaxResult updateById(ToolLedgerEntity entity);
|
||||
|
||||
List<ToolLedgerEntity> getToolByTypeId(ToolLedgerEntity entity);
|
||||
|
||||
|
||||
List<ToolLedgerEntity> getToolByPro(ToolLedgerEntity entity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,23 +6,20 @@ server:
|
|||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: Jjsp@nacos2023
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:18848
|
||||
namespace: material_mall
|
||||
namespace: 37661b6d-55f6-4d12-b2ed-e6ff49e6bb9a
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:18848
|
||||
namespace: material_mall
|
||||
namespace: 37661b6d-55f6-4d12-b2ed-e6ff49e6bb9a
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
|
||||
|
||||
#加密组件
|
||||
jasypt:
|
||||
encryptor:
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ spring:
|
|||
name: bonus-material-mall
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: material_mall_test
|
||||
active: material_mall_local
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<mapper namespace="com.bonus.material.book.mapper.BookCarMapper">
|
||||
|
||||
<insert id="addBookCarDetail">
|
||||
insert into book_car_detail(ma_id, order_status, order_company, order_user, address, creater, create_time)
|
||||
values(#{maId}, 0, #{orderCompany}, #{orderUser}, #{address}, #{creater}, now())
|
||||
insert into book_car_detail(ma_id, order_status, order_company, order_user, address, creater, create_time,
|
||||
devType)
|
||||
values (#{maId}, 0, #{orderCompany}, #{orderUser}, #{address}, #{creater}, now(), #{devType})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById">
|
||||
|
|
@ -21,45 +22,138 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
<select id="getBookCarDetails" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
|
||||
SELECT
|
||||
bcd.id as id,
|
||||
d.ma_id as maId,
|
||||
d.code as code,
|
||||
d.device_name as deviceName,
|
||||
d.device_count as deviceCount,
|
||||
d.type_id as typeId,
|
||||
d.ma_status as maStatus,
|
||||
d.brand as brand,
|
||||
mt.type_name as typeName,
|
||||
mt.manage_type as manageType,
|
||||
d.production_date as productionDate,
|
||||
d.working_hours as workingHours,
|
||||
d.person as person,
|
||||
d.person_phone as personPhone,
|
||||
c.company_name as companyName,
|
||||
c.company_id as companyId,
|
||||
c.operate_address as operateAddress,
|
||||
d.create_time as createTime,
|
||||
bcd.order_user as orderUser,
|
||||
bcd.address as address
|
||||
(SELECT
|
||||
bcd.id as id,
|
||||
d.ma_id as maId,
|
||||
d.code as code,
|
||||
d.device_name as deviceName,
|
||||
d.device_count as deviceCount,
|
||||
d.type_id as typeId,
|
||||
d.ma_status as maStatus,
|
||||
d.brand as brand,
|
||||
'0' AS devType,
|
||||
mt.type_name as typeName,
|
||||
mt.manage_type as manageType,
|
||||
d.production_date as productionDate,
|
||||
d.working_hours as workingHours,
|
||||
d.person as person,
|
||||
d.person_phone as personPhone,
|
||||
c.company_name as companyName,
|
||||
c.company_id as companyId,
|
||||
c.operate_address as operateAddress,
|
||||
d.create_time as createTime,
|
||||
d.up_down_status as upDownStatus,
|
||||
bcd.order_user as orderUser,
|
||||
bcd.address as address
|
||||
FROM ma_dev_info d
|
||||
LEFT JOIN bm_company_info c ON d.on_company = c.company_id
|
||||
LEFT JOIN book_car_detail bcd ON d.ma_id = bcd.ma_id
|
||||
LEFT JOIN bm_company_info c ON d.on_company = c.company_id
|
||||
LEFT JOIN book_car_detail bcd ON d.ma_id = bcd.ma_id
|
||||
LEFT JOIN ma_type mt ON d.type_id = mt.type_id and mt.del_flag = '0'
|
||||
where d.is_active = '1' and bcd.order_status = '0'
|
||||
<if test="maId != null and maId != ''">
|
||||
where d.is_active = '1' and bcd.order_status = '0' and bcd.devType ='0'
|
||||
<if test="maId != null and maId != ''">
|
||||
and bcd.ma_id = #{maId}
|
||||
</if>
|
||||
</if>
|
||||
<if test="orderUser != null and orderUser != ''">
|
||||
and bcd.order_user = #{orderUser}
|
||||
</if>)
|
||||
UNION ALL
|
||||
(
|
||||
SELECT
|
||||
bcd.id as id,
|
||||
tl.id as maId,
|
||||
tl.tool_code as code,
|
||||
tt1.type_name as deviceName,
|
||||
tl.available_num as deviceCount,
|
||||
tl.type_id as typeId,
|
||||
tl.`status` as maStatus,
|
||||
ms.supplier_name as brand,
|
||||
tt.type_name as typeName,
|
||||
'1' AS devType,
|
||||
tl.manage_mode as manageType,
|
||||
tl.production_date as productionDate,
|
||||
'' as workingHours,
|
||||
sd.leader as person,
|
||||
sd.phone as personPhone,
|
||||
c.company_name as companyName,
|
||||
c.company_id as companyId,
|
||||
c.operate_address as operateAddress,
|
||||
tt.create_time as createTime,
|
||||
tl.up_down_status AS upDownStatus,
|
||||
bcd.order_user as orderUser,
|
||||
bcd.address as address
|
||||
FROM
|
||||
tool_ledger tl
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = tl.company_id
|
||||
LEFT JOIN tool_type tt ON tt.type_id = tl.type_id
|
||||
LEFT JOIN tool_type tt1 ON tt.parent_id = tt1.type_id
|
||||
LEFT JOIN bm_company_info c ON tl.company_id = c.company_id
|
||||
LEFT JOIN book_car_detail bcd ON tl.id = bcd.ma_id
|
||||
LEFT JOIN ma_supplier ms ON ms.supplier_id = tl.supplier_id
|
||||
WHERE
|
||||
tl.up_down_status = '1' and bcd.order_status = '0' and bcd.devType ='1'
|
||||
-- 工具表也可添加动态筛选条件(如需),示例:
|
||||
<if test="maId != null and maId != ''">
|
||||
and bcd.ma_id = #{maId}
|
||||
</if>
|
||||
<if test="orderUser != null and orderUser != ''">
|
||||
and bcd.order_user = #{orderUser}
|
||||
</if>
|
||||
-- 子查询加 limit 避免 order by 问题(如果工具表也需要排序,可在这里加)
|
||||
LIMIT 1000000
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="selectDevInfoByMaId" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
|
||||
SELECT ma_id as maId,
|
||||
order_user as orderUser
|
||||
from book_car_detail
|
||||
where ma_id = #{maId}
|
||||
and order_user = #{userId}
|
||||
and order_status = '0'
|
||||
and devType = #{devType}
|
||||
</select>
|
||||
<select id="getBookCarDetailsTool" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
|
||||
SELECT tl.fileList AS picUrl, -- 1. 对应第一部分 picUrl
|
||||
'' AS proType, -- 2. 对应 proType
|
||||
'' AS mainGx, -- 3. 对应 mainGx
|
||||
'' AS childGx, -- 4. 对应 childGx
|
||||
'' AS devCategory, -- 5. 对应 devCategory
|
||||
'' AS devSubcategory, -- 6. 对应 devSubcategory
|
||||
tt.type_name AS typeName, -- 7. 对应 devName
|
||||
'1' AS devType, -- 8. 对应 devType
|
||||
tl.manage_mode AS manageMode, -- 9. 对应 manageMode(与第一部分位置一致!)
|
||||
bcd.id AS id, -- 10. 对应 maId
|
||||
tl.id AS maId, -- 10. 对应 maId
|
||||
tl.tool_code AS `code`, -- 11. 对应 code
|
||||
tl.identify_code AS identifyCode, -- 12. 对应 identifyCode
|
||||
tt1.type_name AS deviceName, -- 13. 对应 deviceName
|
||||
tl.available_num AS deviceCount, -- 14. 对应 deviceCount
|
||||
tl.type_id AS typeId, -- 15. 对应 typeId
|
||||
tl.STATUS AS maStatus, -- 16. 对应 maStatus
|
||||
'' AS brand, -- 17. 对应 brand
|
||||
tl.production_date AS productionDate, -- 18. 对应 productionDate
|
||||
0 AS workingHours, -- 19. 对应 workingHours
|
||||
sd.leader AS person, -- 20. 对应 person
|
||||
sd.phone AS personPhone, -- 21. 对应 personPhone
|
||||
tl.create_time AS createTime, -- 22. 对应 createTime
|
||||
tl.update_time AS updateTime, -- 23. 对应 updateTime
|
||||
tl.company_id AS companyId, -- 24. 对应 companyId
|
||||
sd.dept_name AS companyName, -- 25. 对应 companyName
|
||||
c.operate_address AS operateAddress, -- 26. 对应 operateAddress(列数对齐!)
|
||||
tt.create_time AS companyCreateTime
|
||||
FROM tool_ledger tl
|
||||
LEFT JOIN sys_dept sd ON tl.company_id = sd.dept_id
|
||||
INNER JOIN tool_type tt ON tt.type_id = tl.type_id
|
||||
INNER JOIN tool_type tt1 ON tt.parent_id = tt1.type_id -- 确保 tt 有 parent_id,否则可能查不到数据
|
||||
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
|
||||
LEFT JOIN book_car_detail bcd ON tl.id = bcd.ma_id
|
||||
where bcd.order_status = '0' and bcd.devType ='0'
|
||||
<if test="maId != null and maId != ''">
|
||||
and bcd.ma_id = #{maId}
|
||||
</if>
|
||||
<if test="orderUser != null and orderUser != ''">
|
||||
and bcd.order_user = #{orderUser}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectDevInfoByMaId" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
|
||||
SELECT ma_id as maId,
|
||||
order_user as orderUser
|
||||
from book_car_detail
|
||||
where ma_id = #{maId} and order_user = #{userId} and order_status = '0'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -159,18 +159,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="equipmentTurnoverRate" resultType="com.bonus.material.cityScreen.VO.EquipmentTurnoverRateVO">
|
||||
select
|
||||
mtv.proType as major,
|
||||
mtv.mainGx as mainProcess,
|
||||
mtv.childGx as subprocess,
|
||||
mdi.device_name as deviceName,
|
||||
CONCAT(ROUND(count(cdcd.dev_id)/mdi.device_count, 2),'次/年') as turnoverRate
|
||||
select mtv.proType as major,
|
||||
mtv.mainGx as mainProcess,
|
||||
mtv.childGx as subprocess,
|
||||
mdi.device_name as deviceName,
|
||||
CONCAT(ROUND(count(cdcd.real_num) / mdi.device_count, 2), '次/年') as turnoverRate
|
||||
from ma_dev_info mdi
|
||||
INNER join ma_type_view mtv on mtv.typeId = mdi.type_id
|
||||
left join cs_device_change_details cdcd on cdcd.dev_id = mdi.ma_id
|
||||
left join cs_device_change cdc on cdc.id = cdcd.change_id
|
||||
where mdi.is_active = 1 and mdi.on_company = #{companyId} and mdi.change_status != 4 and cdc.type = 2 and cdc.del_flag = 0
|
||||
and TIMESTAMPDIFF(MONTH , NOW(),cdc.create_time) between 0 and 12
|
||||
left join cs_device_change_details cdcd
|
||||
on cdcd.dev_code = mdi.code and cdcd.use_time is not null and cdcd.is_finished = '1'
|
||||
left join cs_device_change cdc on cdc.id = cdcd.change_id
|
||||
where mdi.is_active = 1
|
||||
and mdi.on_company = #{companyId}
|
||||
and mdi.change_status != 4
|
||||
and cdc.type = 2
|
||||
and cdc.del_flag = 0
|
||||
and TIMESTAMPDIFF(MONTH, NOW(), cdc.create_time) between 0 and 12
|
||||
group by mtv.proType, mtv.mainGx, mtv.childGx, mdi.device_name
|
||||
order by turnoverRate desc
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -13,33 +13,39 @@
|
|||
mdi.`code` AS code,
|
||||
ms.supplier_name AS manufacturer,
|
||||
mdi.production_date AS productionDate,
|
||||
mdi.expiration_time AS expirationTime,
|
||||
IF(STR_TO_DATE(production_date, '%Y-%m-%d') IS NOT NULL AND STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT
|
||||
NULL,
|
||||
TIMESTAMPDIFF(YEAR, STR_TO_DATE(production_date,
|
||||
'%Y-%m-%d'), expiration_time), 0) AS expirationYears,
|
||||
DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR) AS expirationTime,
|
||||
mdi.max_working_hours AS expirationYears,
|
||||
IF(STR_TO_DATE(production_date, '%Y-%m-%d') IS NOT NULL, DATEDIFF(CURDATE(), STR_TO_DATE(production_date,
|
||||
'%Y-%m-%d')), 0) AS daysDiff,
|
||||
IF(STR_TO_DATE(production_date, '%Y-%m-%d') IS NOT NULL, TIMESTAMPDIFF(YEAR, STR_TO_DATE(production_date,
|
||||
'%Y-%m-%d'), CURDATE()), 0) AS yearsDiff,
|
||||
IF(STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
|
||||
AND STR_TO_DATE(expiration_time, '%Y-%m-%d') >= CURDATE(), DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'),
|
||||
|
||||
IF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d') IS NOT NULL
|
||||
AND STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d') >= CURDATE(), DATEDIFF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d'),
|
||||
CURDATE()), 0) AS remainingDays,
|
||||
IF(STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
|
||||
AND STR_TO_DATE(expiration_time, '%Y-%m-%d') >= CURDATE(), TIMESTAMPDIFF(YEAR, CURDATE(),
|
||||
STR_TO_DATE(expiration_time, '%Y-%m-%d')), 0) AS remainingYears,
|
||||
|
||||
IF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d') IS NOT NULL
|
||||
AND STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d') >= CURDATE(), TIMESTAMPDIFF(YEAR, CURDATE(),
|
||||
STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d')), 0) AS remainingYears,
|
||||
|
||||
CASE
|
||||
WHEN STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
|
||||
AND DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'), CURDATE()) > 365
|
||||
THEN '正常使用'
|
||||
WHEN STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
|
||||
AND DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'), CURDATE()) > 0
|
||||
AND DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'), CURDATE()) <= 365
|
||||
THEN CONCAT('临近', DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'), CURDATE()), '天退役')
|
||||
WHEN STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
|
||||
AND STR_TO_DATE(expiration_time, '%Y-%m-%d') <= CURDATE()
|
||||
THEN '已过期'
|
||||
ELSE '日期无效'
|
||||
-- 告警2:已超期(剩余年限≤0)
|
||||
WHEN ROUND(TIMESTAMPDIFF(DAY, mdi.production_date, NOW()) / 365.25, 1) >= mdi.max_working_hours
|
||||
THEN CONCAT('告警:已超最大使用年限', ROUND(
|
||||
ROUND(TIMESTAMPDIFF(DAY, mdi.production_date, NOW()) / 365.25, 1) - mdi.max_working_hours,
|
||||
1
|
||||
), '年')
|
||||
-- 告警1:未超期,但剩余可用年限≤1年(相差小于等于1年)
|
||||
WHEN (mdi.max_working_hours - ROUND(TIMESTAMPDIFF(DAY, mdi.production_date, NOW()) / 365.25, 1)) <= 1
|
||||
THEN CONCAT('告警:即将超期,剩余可用年限', ROUND(
|
||||
mdi.max_working_hours - ROUND(TIMESTAMPDIFF(DAY, mdi.production_date, NOW()) / 365.25, 1),
|
||||
1
|
||||
), '年')
|
||||
-- 正常:未超期,且剩余可用年限>1年(相差大于1年)
|
||||
ELSE CONCAT('正常:剩余可用年限', ROUND(
|
||||
mdi.max_working_hours - ROUND(TIMESTAMPDIFF(DAY, mdi.production_date, NOW()) / 365.25, 1),
|
||||
1
|
||||
), '年')
|
||||
END AS status
|
||||
FROM
|
||||
ma_dev_info mdi
|
||||
|
|
@ -63,10 +69,10 @@
|
|||
</if>
|
||||
<if test="isWarn != null and isWarn != ''">
|
||||
<if test="isWarn == 1">
|
||||
AND device_status != '正常使用'
|
||||
AND status like concat('%','告警','%')
|
||||
</if>
|
||||
<if test="isWarn == 0">
|
||||
AND device_status = '正常使用'
|
||||
AND status like concat('%','正常','%')
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
|
|
|
|||
|
|
@ -49,66 +49,71 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</sql>
|
||||
|
||||
<select id="selectDevInfoList" parameterType="com.bonus.material.device.domain.vo.DevInfoVo" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
|
||||
<!-- 注意:UNION ALL 组合查询时,需给每个子查询加括号,且单个子查询的 order by 需配合 limit(否则可能失效) -->
|
||||
(
|
||||
SELECT
|
||||
ifnull(mdf.file_url, bfi.url) as picUrl,
|
||||
mtv.proType,
|
||||
mtv.mainGx,
|
||||
mtv.childGx,
|
||||
mtv.devCategory,
|
||||
mtv.devSubcategory,
|
||||
mtv.devName,
|
||||
d.ma_id as maId,
|
||||
d.code as `code`,
|
||||
d.identify_code as identifyCode,
|
||||
d.device_name as deviceName,
|
||||
d.device_count as deviceCount,
|
||||
d.type_id as typeId,
|
||||
d.ma_status as maStatus,
|
||||
d.brand as brand,
|
||||
d.production_date as productionDate,
|
||||
d.working_hours as workingHours,
|
||||
d.person as person,
|
||||
d.person_phone as personPhone,
|
||||
d.create_time as createTime,
|
||||
d.update_time as updateTime,
|
||||
d.on_company as companyId,
|
||||
sd.dept_name as companyName,
|
||||
c.operate_address as operateAddress
|
||||
IFNULL(mdf.file_url, bfi.url) AS picUrl,
|
||||
mtv.proType,
|
||||
mtv.mainGx,
|
||||
mtv.childGx,
|
||||
mtv.devCategory,
|
||||
mtv.devSubcategory,
|
||||
mtv.devName,
|
||||
'0' AS devType,
|
||||
'0' AS manageMode, -- 第一部分的 manageMode(第9列)
|
||||
d.ma_id AS maId, -- 第10列
|
||||
d.code AS `code`, -- 第11列
|
||||
d.identify_code AS identifyCode, -- 第12列
|
||||
d.device_name AS deviceName, -- 第13列
|
||||
d.device_count AS deviceCount, -- 第14列
|
||||
d.type_id AS typeId, -- 第15列
|
||||
d.ma_status AS maStatus, -- 第16列
|
||||
d.brand AS brand, -- 第17列
|
||||
d.production_date AS productionDate, -- 第18列
|
||||
d.working_hours AS workingHours, -- 第19列
|
||||
d.person AS person, -- 第20列
|
||||
d.person_phone AS personPhone, -- 第21列
|
||||
d.create_time AS createTime, -- 第22列
|
||||
d.update_time AS updateTime, -- 第23列
|
||||
d.on_company AS companyId, -- 第24列
|
||||
sd.dept_name AS companyName, -- 第25列
|
||||
c.operate_address AS operateAddress -- 第26列
|
||||
FROM
|
||||
ma_dev_info d
|
||||
ma_dev_info d
|
||||
LEFT JOIN sys_dept sd ON d.on_company = sd.dept_id
|
||||
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
|
||||
INNER JOIN ma_type_view mtv ON mtv.typeId = d.type_id
|
||||
LEFT JOIN bm_file_info bfi on d.ma_id = bfi.model_id and bfi.file_type = '0' and bfi.task_type = '17'
|
||||
LEFT JOIN ma_dev_file mdf on d.ma_id = mdf.ma_id and mdf.file_type = '1' and mdf.is_active = '1'
|
||||
LEFT JOIN bm_file_info bfi ON d.ma_id = bfi.model_id AND bfi.file_type = '0' AND bfi.task_type = '17'
|
||||
LEFT JOIN ma_dev_file mdf ON d.ma_id = mdf.ma_id AND mdf.file_type = '1' AND mdf.is_active = '1'
|
||||
<where>
|
||||
<if test="maId != null "> and d.ma_id = #{maId}</if>
|
||||
<if test="code != null and code != ''"> and d.code = #{code}</if>
|
||||
<if test="maId != null ">and d.ma_id = #{maId}</if>
|
||||
<if test="code != null and code != ''">and d.code = #{code}</if>
|
||||
<if test="deviceName != null and deviceName != ''">
|
||||
and d.device_name like concat('%',#{deviceName},'%')
|
||||
</if>
|
||||
<if test="maStatus != null"> and (d.ma_status = 1 or d.ma_status = 2 or d.ma_status = 3)</if>
|
||||
<if test="leaseScope != null "> and d.lease_scope = #{leaseScope}</if>
|
||||
<if test="location != null and location != ''"> and d.location = #{location}</if>
|
||||
<if test="provinceId != null and provinceId != ''"> and d.province_id = #{provinceId}</if>
|
||||
<if test="cityId != null and cityId != ''"> and d.city_id = #{cityId}</if>
|
||||
<if test="areaId != null and areaId != ''"> and d.area_id = #{areaId}</if>
|
||||
<if test="brand != null and brand != ''"> and d.brand = #{brand}</if>
|
||||
<if test="maStatus != null">and (d.ma_status = 1 or d.ma_status = 2 or d.ma_status = 3)</if>
|
||||
<if test="leaseScope != null ">and d.lease_scope = #{leaseScope}</if>
|
||||
<if test="location != null and location != ''">and d.location = #{location}</if>
|
||||
<if test="provinceId != null and provinceId != ''">and d.province_id = #{provinceId}</if>
|
||||
<if test="cityId != null and cityId != ''">and d.city_id = #{cityId}</if>
|
||||
<if test="areaId != null and areaId != ''">and d.area_id = #{areaId}</if>
|
||||
<if test="brand != null and brand != ''">and d.brand = #{brand}</if>
|
||||
<if test="ageMin != null and ageMax != null">
|
||||
and TIMESTAMPDIFF(YEAR, d.production_date, NOW()) >= #{ageMin}
|
||||
and TIMESTAMPDIFF(YEAR, d.production_date, NOW()) <= #{ageMax}
|
||||
</if>
|
||||
<if test="ageMin == null and ageMax != null">
|
||||
and TIMESTAMPDIFF(YEAR, d.production_date, NOW()) >= #{ageMax}
|
||||
<!-- 原逻辑可能有误:ageMax 应该是“小于等于”?如果是“大于等于”请保留,否则改为 <= -->
|
||||
and TIMESTAMPDIFF(YEAR, d.production_date, NOW()) <= #{ageMax}
|
||||
</if>
|
||||
<if test="workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != ''">
|
||||
and d.working_hours >= #{workingHoursMin} and d.working_hours <= #{workingHoursMax}
|
||||
</if>
|
||||
<if test="description != null and description != ''"> and d.description = #{description}</if>
|
||||
<if test="gpsCode != null and gpsCode != ''"> and d.gps_code = #{gpsCode}</if>
|
||||
<if test="companyId != null and companyId != ''"> and d.on_company = #{companyId}</if>
|
||||
<if test="specification != null "> and d.specification = #{specification}</if>
|
||||
<if test="deposit != null "> and d.deposit = #{deposit}</if>
|
||||
<if test="description != null and description != ''">and d.description = #{description}</if>
|
||||
<if test="gpsCode != null and gpsCode != ''">and d.gps_code = #{gpsCode}</if>
|
||||
<if test="companyId != null and companyId != ''">and d.on_company = #{companyId}</if>
|
||||
<if test="specification != null ">and d.specification = #{specification}</if>
|
||||
<if test="deposit != null ">and d.deposit = #{deposit}</if>
|
||||
<if test="startTime != null and endTime != null">
|
||||
and d.update_time between #{startTime} and #{endTime}
|
||||
</if>
|
||||
|
|
@ -130,11 +135,67 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
order by
|
||||
d.is_active
|
||||
<if test="updateTimeOrderBy != null and updateTimeOrderBy == 'ASC'">
|
||||
,d.create_time
|
||||
,d.create_time ASC
|
||||
</if>
|
||||
<if test="updateTimeOrderBy != null and updateTimeOrderBy == 'DESC'">
|
||||
,d.create_time DESC
|
||||
</if>
|
||||
-- 子查询加 limit 避免 order by 失效(MySQL 特性)
|
||||
LIMIT 1000000 -- 根据实际数据量调整,确保覆盖所有符合条件的数据
|
||||
)
|
||||
UNION ALL
|
||||
(
|
||||
SELECT
|
||||
tl.fileList AS picUrl, -- 1. 对应第一部分 picUrl
|
||||
'' AS proType, -- 2. 对应 proType
|
||||
'' AS mainGx, -- 3. 对应 mainGx
|
||||
'' AS childGx, -- 4. 对应 childGx
|
||||
'' AS devCategory, -- 5. 对应 devCategory
|
||||
'' AS devSubcategory, -- 6. 对应 devSubcategory
|
||||
tt.type_name AS devName, -- 7. 对应 devName
|
||||
'1' AS devType, -- 8. 对应 devType
|
||||
tl.manage_mode AS manageMode, -- 9. 对应 manageMode(与第一部分位置一致!)
|
||||
tl.id AS maId, -- 10. 对应 maId
|
||||
tl.tool_code AS `code`, -- 11. 对应 code
|
||||
tl.identify_code AS identifyCode, -- 12. 对应 identifyCode
|
||||
tt1.type_name AS deviceName, -- 13. 对应 deviceName
|
||||
tl.available_num AS deviceCount, -- 14. 对应 deviceCount
|
||||
tl.type_id AS typeId, -- 15. 对应 typeId
|
||||
tl.STATUS AS maStatus, -- 16. 对应 maStatus
|
||||
'' AS brand, -- 17. 对应 brand
|
||||
tl.production_date AS productionDate, -- 18. 对应 productionDate
|
||||
0 AS workingHours, -- 19. 对应 workingHours
|
||||
sd.leader AS person, -- 20. 对应 person
|
||||
sd.phone AS personPhone, -- 21. 对应 personPhone
|
||||
tl.create_time AS createTime, -- 22. 对应 createTime
|
||||
tl.update_time AS updateTime, -- 23. 对应 updateTime
|
||||
tl.company_id AS companyId, -- 24. 对应 companyId
|
||||
sd.dept_name AS companyName, -- 25. 对应 companyName
|
||||
c.operate_address AS operateAddress -- 26. 对应 operateAddress(列数对齐!)
|
||||
FROM
|
||||
tool_ledger tl
|
||||
LEFT JOIN sys_dept sd ON tl.company_id = sd.dept_id
|
||||
INNER JOIN tool_type tt ON tt.type_id = tl.type_id
|
||||
INNER JOIN tool_type tt1 ON tt.parent_id = tt1.type_id -- 确保 tt 有 parent_id,否则可能查不到数据
|
||||
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
|
||||
WHERE
|
||||
tl.up_down_status = '1'
|
||||
-- 工具表也可添加动态筛选条件(如需),示例:
|
||||
<if test="companyId != null and companyId != ''">
|
||||
and tl.company_id = #{companyId}
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (
|
||||
locate(#{keyWord}, tt.type_name) > 0
|
||||
or locate(#{keyWord}, tt1.type_name) > 0
|
||||
or locate(#{keyWord}, tl.identify_code) > 0
|
||||
or locate(#{keyWord}, sd.dept_name) > 0
|
||||
)
|
||||
</if>
|
||||
-- 子查询加 limit 避免 order by 问题(如果工具表也需要排序,可在这里加)
|
||||
LIMIT 1000000
|
||||
)
|
||||
-- 可选:整体排序(如果需要合并后统一排序,取消下面注释)
|
||||
</select>
|
||||
|
||||
<select id="selectDevInfoHotList" parameterType="com.bonus.material.device.domain.vo.DevInfoVo" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
|
||||
|
|
@ -1404,13 +1465,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select count(1) from ma_dev_info where is_active ='1' and change_status = #{changeStatus}
|
||||
</select>
|
||||
<select id="getChangeNum" resultType="java.lang.Integer">
|
||||
select SUM(dev_num) from cs_device_change where del_flag ='0'
|
||||
AND create_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH);
|
||||
select SUM(num)
|
||||
from cs_device_change_details
|
||||
where del_flag = '0'
|
||||
and use_time is not null
|
||||
and is_finished = '1'
|
||||
and dev_type = '1'
|
||||
AND create_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH);
|
||||
</select>
|
||||
<select id="getTurnoverRate" resultType="java.lang.Integer">
|
||||
select count(1) from cs_device_change_details cdcd
|
||||
left join cs_device_change cdc on cdcd.change_id = cdc.id
|
||||
left join ma_dev_info mdi on mdi.ma_id = cdcd.dev_id
|
||||
select count(1)
|
||||
from cs_device_change_details cdcd
|
||||
left join cs_device_change cdc on cdcd.change_id = cdc.id
|
||||
left join ma_dev_info mdi on mdi.code = cdcd.dev_code
|
||||
where cdcd.del_flag = '0'
|
||||
AND cdc.create_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH);
|
||||
</select>
|
||||
|
|
@ -1531,4 +1598,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
SELECT COUNT(1)
|
||||
from jj_sing_project
|
||||
</select>
|
||||
<select id="selectToolByMaId" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
|
||||
SELECT tl.fileList AS picUrl, -- 1. 对应第一部分 picUrl
|
||||
'' AS proType, -- 2. 对应 proType
|
||||
'' AS mainGx, -- 3. 对应 mainGx
|
||||
'' AS childGx, -- 4. 对应 childGx
|
||||
'' AS devCategory, -- 5. 对应 devCategory
|
||||
'' AS devSubcategory, -- 6. 对应 devSubcategory
|
||||
tt.type_name AS typeName, -- 7. 对应 devName
|
||||
'1' AS devType, -- 8. 对应 devType
|
||||
tl.manage_mode AS manageMode, -- 9. 对应 manageMode(与第一部分位置一致!)
|
||||
tl.id AS maId, -- 10. 对应 maId
|
||||
tl.tool_code AS `code`, -- 11. 对应 code
|
||||
tl.identify_code AS identifyCode, -- 12. 对应 identifyCode
|
||||
tt1.type_name AS deviceName, -- 13. 对应 deviceName
|
||||
tl.available_num AS deviceCount, -- 14. 对应 deviceCount
|
||||
tl.type_id AS typeId, -- 15. 对应 typeId
|
||||
tl.STATUS AS maStatus, -- 16. 对应 maStatus
|
||||
'' AS brand, -- 17. 对应 brand
|
||||
tl.production_date AS productionDate, -- 18. 对应 productionDate
|
||||
0 AS workingHours, -- 19. 对应 workingHours
|
||||
sd.leader AS person, -- 20. 对应 person
|
||||
sd.phone AS personPhone, -- 21. 对应 personPhone
|
||||
tl.create_time AS createTime, -- 22. 对应 createTime
|
||||
tl.update_time AS updateTime, -- 23. 对应 updateTime
|
||||
tl.company_id AS companyId, -- 24. 对应 companyId
|
||||
sd.dept_name AS companyName, -- 25. 对应 companyName
|
||||
c.operate_address AS operateAddress, -- 26. 对应 operateAddress(列数对齐!)
|
||||
tt.create_time AS companyCreateTime
|
||||
|
||||
FROM tool_ledger tl
|
||||
LEFT JOIN sys_dept sd ON tl.company_id = sd.dept_id
|
||||
INNER JOIN tool_type tt ON tt.type_id = tl.type_id
|
||||
INNER JOIN tool_type tt1 ON tt.parent_id = tt1.type_id -- 确保 tt 有 parent_id,否则可能查不到数据
|
||||
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
|
||||
WHERE tl.up_down_status = '1'
|
||||
and tl.id = #{maId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
SUM(CASE WHEN mdi.entry_status = 1 THEN 1 ELSE 0 END) AS agree,
|
||||
SUM(CASE WHEN mdi.entry_status = 2 THEN 1 ELSE 0 END) AS reject
|
||||
FROM
|
||||
cs_device_status aaa
|
||||
LEFT JOIN cs_device_real_dev bbb ON aaa.id = bbb.cs_id
|
||||
ma_apply aaa
|
||||
LEFT JOIN ma_apply_details bbb ON aaa.id = bbb.cs_id
|
||||
LEFT JOIN ma_dev_info mdi ON bbb.dev_id = mdi.ma_id AND mdi.is_active = '1'
|
||||
where aaa.is_active = 1
|
||||
<if test="status != null and status != ''">
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
and aaa.create_user like concat('%', #{createUser}, '%')
|
||||
</if>
|
||||
<if test="startCreateTime != null and endCreateTime != null ">
|
||||
and DATE_FORMAT(aaa.create_time,'%Y-%m-%d') between #{startCreateTime} and #{endCreateTime}
|
||||
and aaa.create_time between #{startCreateTime} and #{endCreateTime}
|
||||
</if>
|
||||
GROUP BY
|
||||
aaa.id
|
||||
|
|
@ -63,9 +63,9 @@
|
|||
c.operate_address as operateAddress,
|
||||
d.entry_status AS entryStatus,
|
||||
d.buy_price AS buyPrice
|
||||
FROM cs_device_real_dev cdrd
|
||||
FROM ma_apply_details cdrd
|
||||
LEFT JOIN ma_dev_info d ON cdrd.dev_id = d.ma_id AND d.is_active = '1'
|
||||
LEFT JOIN cs_device_status cds ON cdrd.cs_id = cds.id
|
||||
LEFT JOIN ma_apply cds ON cdrd.cs_id = cds.id
|
||||
LEFT JOIN sys_dept sd ON d.on_company = sd.dept_id
|
||||
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
|
||||
INNER JOIN ma_type_view mtv ON mtv.typeId = d.type_id
|
||||
|
|
@ -77,12 +77,12 @@
|
|||
</select>
|
||||
|
||||
<insert id="addOrder" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO cs_device_status (create_user, order_number)
|
||||
INSERT INTO ma_apply (create_user, order_number)
|
||||
VALUES (#{createUser}, #{orderNumber})
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrderDevReal">
|
||||
INSERT INTO cs_device_real_dev (cs_id, dev_id)
|
||||
INSERT INTO ma_apply_details (cs_id, dev_id)
|
||||
VALUES (#{orderId}, #{maId})
|
||||
</insert>
|
||||
<insert parameterType="com.bonus.material.devchange.domain.MaDevInfo" id="interDevice" useGeneratedKeys="true"
|
||||
|
|
@ -156,7 +156,7 @@
|
|||
</insert>
|
||||
|
||||
<update id="submitOrder">
|
||||
UPDATE cs_device_status
|
||||
UPDATE ma_apply
|
||||
SET status = #{status}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
|
@ -165,12 +165,12 @@
|
|||
UPDATE ma_dev_info
|
||||
SET entry_status = 0
|
||||
WHERE ma_id IN (select dev_id
|
||||
from cs_device_real_dev
|
||||
from ma_apply_details
|
||||
where cs_id = #{id})
|
||||
</update>
|
||||
|
||||
<delete id="delOrder">
|
||||
update cs_device_status
|
||||
update ma_apply
|
||||
set is_active = 0
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
|
@ -236,7 +236,7 @@
|
|||
select count(1)
|
||||
from ma_dev_info
|
||||
where ma_id IN (select dev_id
|
||||
from cs_device_real_dev
|
||||
from ma_apply_details
|
||||
where cs_id = #{id})
|
||||
and is_active = 1
|
||||
and entry_status = 0
|
||||
|
|
@ -284,10 +284,10 @@
|
|||
</select>
|
||||
<select id="getSecondToFifthLevelTypes" resultType="java.util.Map">
|
||||
-- MySQL 5.x兼容版本:查询二至五级类型
|
||||
SELECT t.type_id AS value,
|
||||
t.level,
|
||||
t.type_name AS label,
|
||||
t.parent_id AS parentId
|
||||
SELECT t1.type_id AS value,
|
||||
t1.level,
|
||||
t1.type_name AS label,
|
||||
t1.parent_id AS parentId
|
||||
FROM ma_type t1
|
||||
-- 二级:直接子节点
|
||||
LEFT JOIN ma_type t2 ON t1.type_id = t2.parent_id AND t2.del_flag = '0'
|
||||
|
|
@ -323,14 +323,14 @@
|
|||
JOIN ma_type t5 ON t4.type_id = t5.parent_id
|
||||
WHERE t2.parent_id = #{firstLevelId}
|
||||
AND t5.del_flag = '0' -- 五级
|
||||
) AS all_levels ON t.type_id = all_levels.type_id
|
||||
) AS all_levels ON t1.type_id = all_levels.type_id
|
||||
WHERE t1.type_id = #{firstLevelId}
|
||||
AND t1.parent_id = '0' -- 确保是一级类型
|
||||
AND t.del_flag = '0'
|
||||
AND t1.del_flag = '0'
|
||||
</select>
|
||||
<select id="selectTodayOrderCount" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM cs_device_status
|
||||
FROM ma_apply
|
||||
WHERE DATE(create_time) = CURDATE()
|
||||
AND order_number IS NOT NULL
|
||||
</select>
|
||||
|
|
@ -376,8 +376,8 @@
|
|||
mdq.next_check_time AS nextMaintenanceDate,
|
||||
mdi.max_working_hours AS maxServiceLifeYears,
|
||||
sc.name AS province
|
||||
from cs_device_status cds
|
||||
LEFT JOIN cs_device_real_dev cdrd ON cdrd.cs_id = cds.id
|
||||
from ma_apply cds
|
||||
LEFT JOIN ma_apply_details cdrd ON cdrd.cs_id = cds.id
|
||||
LEFT JOIN ma_dev_info mdi ON cdrd.dev_id = mdi.ma_id
|
||||
INNER JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
|
||||
LEFT JOIN jj_sing_project jsp ON mdi.on_project = jsp.pro_code
|
||||
|
|
@ -477,8 +477,8 @@
|
|||
mdi.max_working_hours AS maxServiceLifeYears,
|
||||
mdi.entry_status AS entryStatus,
|
||||
sc.name AS province
|
||||
from cs_device_status cds
|
||||
LEFT JOIN cs_device_real_dev cdrd ON cdrd.cs_id = cds.id
|
||||
from ma_apply cds
|
||||
LEFT JOIN ma_apply_details cdrd ON cdrd.cs_id = cds.id
|
||||
LEFT JOIN ma_dev_info mdi ON cdrd.dev_id = mdi.ma_id
|
||||
INNER JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
|
||||
LEFT JOIN jj_sing_project jsp ON mdi.on_project = jsp.pro_code
|
||||
|
|
|
|||
|
|
@ -662,11 +662,11 @@
|
|||
COUNT(*) AS monthly_outbound_count -- 当月出库次数(小类内所有设备)
|
||||
FROM cs_device_change_details cdcd
|
||||
-- 关联设备信息表,筛选有效设备
|
||||
LEFT JOIN ma_dev_info mdi ON mdi.ma_id = cdcd.dev_id
|
||||
LEFT JOIN ma_dev_info mdi ON mdi.code = cdcd.dev_code
|
||||
-- 关联类型视图,限定小类和大类
|
||||
INNER JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
|
||||
WHERE
|
||||
cdcd.`use_time` is not null -- 出库状态
|
||||
cdcd.`use_time` is not null and cdcd.is_finished='1' -- 出库状态
|
||||
AND mdi.is_active = '1'
|
||||
AND cdcd.use_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) -- 近12个月
|
||||
<if test="type != null and type != 0">
|
||||
|
|
@ -837,60 +837,54 @@
|
|||
ORDER BY inUser DESC
|
||||
</select>
|
||||
<select id="getDeptEquipment">
|
||||
SELECT
|
||||
sd_all.dept_id AS deptId, -- 字段1:单位ID
|
||||
sd_all.dept_name AS name, -- 字段2:单位名称
|
||||
IFNULL(ur.use_rate_percent, 0) AS proportion, -- 字段3:设备在用率(无数据显示0)
|
||||
IFNULL(oc.total_outbound_count, 0) AS turnoverRate -- 字段4:近12个月总出库次数(无数据显示0)
|
||||
SELECT sd_all.dept_id AS deptId, -- 字段1:单位ID
|
||||
sd_all.dept_name AS name, -- 字段2:单位名称
|
||||
IFNULL(ur.use_rate_percent, 0) AS proportion, -- 字段3:设备在用率(无数据显示0)
|
||||
IFNULL(oc.total_outbound_count, 0) AS turnoverRate -- 字段4:近12个月总出库次数(无数据显示0)
|
||||
FROM
|
||||
-- 全量单位表(确保无数据单位不丢失)
|
||||
sys_dept sd_all
|
||||
-- 左连接:单位在用率统计(1单位1行)
|
||||
LEFT JOIN (
|
||||
-- 子查询1:按单位统计设备在用率(MySQL 5 兼容)
|
||||
SELECT
|
||||
sd.dept_id,
|
||||
ROUND(
|
||||
IF(
|
||||
COUNT(DISTINCT CONCAT(mdi.ma_id, '_', DATE(mddu.create_time))) = 0,
|
||||
0,
|
||||
COUNT(DISTINCT CASE
|
||||
WHEN mddu.`status` = 1 THEN CONCAT(mdi.ma_id, '_', DATE(mddu.create_time))
|
||||
END)
|
||||
/ COUNT(DISTINCT CONCAT(mdi.ma_id, '_', DATE(mddu.create_time))) * 100
|
||||
),
|
||||
2
|
||||
) AS use_rate_percent
|
||||
SELECT sd.dept_id,
|
||||
ROUND(
|
||||
IF(
|
||||
COUNT(DISTINCT CONCAT(mdi.ma_id, '_', DATE(mddu.create_time))) = 0,
|
||||
0,
|
||||
COUNT(DISTINCT CASE
|
||||
WHEN mddu.`status` = 1
|
||||
THEN CONCAT(mdi.ma_id, '_', DATE(mddu.create_time))
|
||||
END)
|
||||
/ COUNT(DISTINCT CONCAT(mdi.ma_id, '_', DATE(mddu.create_time))) * 100
|
||||
),
|
||||
2
|
||||
) AS use_rate_percent
|
||||
FROM ma_dev_info mdi
|
||||
LEFT JOIN ma_dev_daily_use mddu ON mddu.ma_id = mdi.ma_id
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.on_company
|
||||
WHERE
|
||||
mdi.is_active = '1'
|
||||
WHERE mdi.is_active = '1'
|
||||
AND mdi.change_status != '4'
|
||||
AND mdi.entry_status = '1'
|
||||
GROUP BY sd.dept_id
|
||||
) AS ur ON sd_all.dept_id = ur.dept_id
|
||||
GROUP BY sd.dept_id) AS ur ON sd_all.dept_id = ur.dept_id
|
||||
-- 左连接:单位近12个月总出库次数(1单位1行,无重复)
|
||||
LEFT JOIN (
|
||||
-- 子查询2:按单位统计近12个月总出库次数
|
||||
SELECT
|
||||
sd.dept_id,
|
||||
COUNT(*) AS total_outbound_count
|
||||
SELECT sd.dept_id,
|
||||
COUNT(*) AS total_outbound_count
|
||||
FROM cs_device_change_details cdcd
|
||||
-- 关联设备表过滤有效设备
|
||||
INNER JOIN ma_dev_info mdi
|
||||
ON mdi.ma_id = cdcd.dev_id
|
||||
ON mdi.code = cdcd.dev_code
|
||||
AND mdi.is_active = '1'
|
||||
AND mdi.change_status != '4'
|
||||
AND mdi.entry_status = '1'
|
||||
-- 关联单位表获取所属单位
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.on_company
|
||||
WHERE
|
||||
cdcd.`status` = 2 -- 出库状态(按实际业务调整)
|
||||
WHERE cdcd.is_finished = '1' -- 出库状态(按实际业务调整)
|
||||
AND cdcd.use_time IS NOT NULL
|
||||
AND cdcd.use_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH)
|
||||
GROUP BY sd.dept_id
|
||||
) AS oc ON sd_all.dept_id = oc.dept_id
|
||||
GROUP BY sd.dept_id) AS oc ON sd_all.dept_id = oc.dept_id
|
||||
-- 按在用率降序排序(无数据单位排最后)
|
||||
ORDER BY proportion DESC;
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -5,34 +5,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<mapper namespace="com.bonus.material.order.mapper.OrderMapper">
|
||||
|
||||
<insert id="insertOrderInfo" parameterType="com.bonus.material.order.domain.OrderInfoDto" useGeneratedKeys="true" keyProperty="orderId">
|
||||
insert into ma_order_info (code, order_time, cost, buyer_id, address, creater, create_time, buyer_company)
|
||||
values
|
||||
(#{code}, now(), #{cost}, #{buyerId}, #{address}, #{creater}, now(), #{buyerCompany})
|
||||
insert into ma_order_info (code, order_time, cost, buyer_id, address, creater, create_time, buyer_company,
|
||||
use_unit, pro_code, pro_name, pro_type, voltage_level, pro_province, pro_city,
|
||||
pro_county)
|
||||
values (#{code}, now(), #{cost}, #{buyerId}, #{address}, #{creater}, now(), #{buyerCompany}, #{useUnit},
|
||||
#{proCode}, #{proName}, #{proType}, #{voltageLevel}, #{proProvince}, #{proCity}, #{proCounty})
|
||||
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrderDetail">
|
||||
INSERT INTO `ma_order_details` (
|
||||
`order_id`,
|
||||
`ma_id`,
|
||||
`rent_begin_time`,
|
||||
`rent_end_time`,
|
||||
`days`,
|
||||
`num`,
|
||||
`costs`,
|
||||
`order_status`,
|
||||
`create_time`,
|
||||
`update_time`
|
||||
) VALUES (
|
||||
#{orderId},
|
||||
#{maId},
|
||||
#{rentBeginTime},
|
||||
#{rentEndTime},
|
||||
#{days},
|
||||
#{num},
|
||||
#{costs},
|
||||
1,
|
||||
now(),
|
||||
#{updateTime})
|
||||
INSERT INTO `ma_order_details` (`order_id`,
|
||||
`ma_id`,
|
||||
`rent_begin_time`,
|
||||
`rent_end_time`,
|
||||
`days`,
|
||||
`num`,
|
||||
`costs`,
|
||||
`order_status`,
|
||||
`create_time`,
|
||||
`update_time`,
|
||||
devType)
|
||||
VALUES (#{orderId},
|
||||
#{maId},
|
||||
#{rentBeginTime},
|
||||
#{rentEndTime},
|
||||
#{days},
|
||||
#{num},
|
||||
#{costs},
|
||||
1,
|
||||
now(),
|
||||
#{updateTime},
|
||||
#{devType})
|
||||
</insert>
|
||||
|
||||
<update id="updateDeviceStatus">
|
||||
|
|
|
|||
|
|
@ -70,11 +70,12 @@
|
|||
tt2.type_name AS grandparentTypeName, -- 2级父节点名称
|
||||
tt3.type_name AS greatGrandparentName, -- 3级父节点名称
|
||||
tt4.type_name AS fourthParentName, -- 4级父节点名称
|
||||
SUM(COALESCE ( tl.available_num, 0 )) AS availableNum,
|
||||
SUM(COALESCE ( tl.in_num, 0 )) AS inNum,
|
||||
SUM(COALESCE ( tl.scrap_num, 0 )) AS scrapNum,
|
||||
SUM(COALESCE ( tl.repair_num, 0 )) AS repairNum,
|
||||
SUM(COALESCE ( tl.total_num, 0 )) AS totalNum
|
||||
SUM(COALESCE ( tl.available_num, 0 )) AS availableNum, -- 在库
|
||||
SUM(COALESCE ( tl.in_num, 0 )) AS inNum, -- 自用
|
||||
SUM(COALESCE ( tl.share_num, 0 )) AS shareNum, -- 共享
|
||||
SUM(COALESCE ( tl.repair_num, 0 )) AS repairNum, -- 维修
|
||||
SUM(COALESCE ( tl.scrap_num, 0 )) AS scrapNum, -- 报废
|
||||
SUM(COALESCE ( tl.total_num, 0 )) AS totalNum -- 总数
|
||||
FROM
|
||||
tool_type tt
|
||||
LEFT JOIN tool_ledger tl ON tl.type_id = tt.type_id
|
||||
|
|
@ -268,6 +269,47 @@
|
|||
FROM tool_properties
|
||||
WHERE tool_id = #{toolId}
|
||||
</select>
|
||||
<select id="getToolByTypeId" resultType="com.bonus.material.toolLedger.domain.ToolLedgerEntity">
|
||||
SELECT tl.tool_code AS toolCode,
|
||||
tl.available_num AS totalNum,
|
||||
tt.type_name AS typeName,
|
||||
tt1.type_name AS parentTypeName
|
||||
FROM tool_ledger tl
|
||||
INNER JOIN tool_type tt ON tt.type_id = tl.type_id
|
||||
INNER JOIN tool_type tt1 ON tt1.type_id = tt.parent_id
|
||||
WHERE tl.status = #{status}
|
||||
AND tl.type_id = #{typeId}
|
||||
</select>
|
||||
<select id="getToolByPro" resultType="com.bonus.material.toolLedger.domain.ToolLedgerEntity">
|
||||
SELECT cdc.pro_name AS proName, -- 工程名称
|
||||
cdcd.dev_code AS toolCode, -- 工具编码
|
||||
tt.type_name AS typeName, -- 工具类型名称
|
||||
tt1.type_name AS parentTypeName,
|
||||
IFNULL(
|
||||
SUM(CASE
|
||||
WHEN cdc.type = '2' AND cdcd.is_finished = '1' THEN IFNULL(cdcd.real_num, 0)
|
||||
ELSE 0 END),
|
||||
0
|
||||
) - IFNULL(SUM(CASE WHEN cdc.type = '1' THEN IFNULL(cdcd.real_num, 0) ELSE 0 END), 0) -
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '1' THEN IFNULL(cdcd.num, 0) ELSE 0 END), 0) AS totalNum
|
||||
FROM cs_device_change_details cdcd
|
||||
INNER JOIN cs_device_change cdc
|
||||
ON cdcd.change_id = cdc.id
|
||||
AND cdc.del_flag = '0'
|
||||
|
||||
LEFT JOIN tool_type tt
|
||||
ON cdcd.dev_type_id = tt.type_id
|
||||
LEFT JOIN tool_type tt1
|
||||
ON tt1.type_id = tt.parent_id
|
||||
WHERE cdcd.dev_type = '2'
|
||||
AND cdcd.del_flag = '0'
|
||||
AND cdc.type IN ('1', '2')
|
||||
AND cdcd.dev_type_id = #{typeId}
|
||||
AND cdc.lease_type = #{status}
|
||||
GROUP BY cdc.pro_name, cdc.pro_code, cdcd.dev_code, cdcd.dev_type_id, tt.type_name
|
||||
HAVING totalNum > 0
|
||||
ORDER BY cdc.pro_name ASC, cdcd.dev_code ASC
|
||||
</select>
|
||||
<insert id="insertDevInfoProperties">
|
||||
insert into
|
||||
tool_properties(tool_id, property_name, property_value, create_time)
|
||||
|
|
|
|||
|
|
@ -20,34 +20,26 @@
|
|||
</insert>
|
||||
<insert id="addDetail" parameterType="java.util.List">
|
||||
INSERT INTO tool_apply_details (
|
||||
<!-- 批量插入时,字段列表只需拼接一次(所有实体共用同一组非空字段) -->
|
||||
<trim suffixOverrides=","> <!-- 去除最后一个多余的逗号 -->
|
||||
<if test="list != null and list.size() > 0">
|
||||
<!-- 取 List 中第一个非空实体的字段作为基准(避免字段列表为空) -->
|
||||
<if test="list[0].applyId != null">apply_id,</if>
|
||||
<if test="list[0].typeId != null">type_id,</if>
|
||||
<if test="list[0].supplierId != null">supplier_id,</if>
|
||||
<if test="list[0].applyNum != null">apply_num,</if>
|
||||
<if test="list[0].toolPrice != null">tool_price,</if>
|
||||
<if test="list[0].productionDate != null">production_date,</if>
|
||||
<if test="list[0].code != null">code,</if>
|
||||
<if test="list[0].identifyCode != null">identify_code,</if>
|
||||
</if>
|
||||
</trim>
|
||||
) VALUES
|
||||
<!-- 遍历 List,为每个实体拼接 VALUES 子句 -->
|
||||
apply_id,
|
||||
type_id,
|
||||
supplier_id,
|
||||
apply_num,
|
||||
tool_price,
|
||||
production_date,
|
||||
code,
|
||||
identify_code
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
<trim suffixOverrides=","> <!-- 去除每个 VALUES 后多余的逗号 -->
|
||||
<if test="item.applyId != null">#{item.applyId},</if>
|
||||
<if test="item.typeId != null">#{item.typeId},</if>
|
||||
<if test="item.supplierId != null">#{item.supplierId},</if>
|
||||
<if test="item.applyNum != null">#{item.applyNum},</if>
|
||||
<if test="item.toolPrice != null">#{item.toolPrice},</if>
|
||||
<if test="item.productionDate != null">#{item.productionDate},</if>
|
||||
<if test="item.code != null">#{item.code},</if>
|
||||
<if test="item.identifyCode != null">#{item.identifyCode},</if>
|
||||
</trim>
|
||||
#{item.applyId},
|
||||
#{item.typeId},
|
||||
#{item.supplierId},
|
||||
#{item.applyNum},
|
||||
#{item.toolPrice},
|
||||
#{item.productionDate},
|
||||
#{item.code},
|
||||
#{item.identifyCode}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
|
|
|||
Loading…
Reference in New Issue