Commit 015fb2d7 by xiehx

合并1.71.0版本代码到主干

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@35554 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent f954948c
Showing 22 changed files with 547 additions and 58 deletions
...@@ -78,6 +78,9 @@ public enum ResultCodeEnum { ...@@ -78,6 +78,9 @@ public enum ResultCodeEnum {
PHONE_NUMBER_NOT_EXIST(30046, "手机号不能为空"), PHONE_NUMBER_NOT_EXIST(30046, "手机号不能为空"),
NOT_PINGAN_WORKORDER(30047, "不是平安的工单"), NOT_PINGAN_WORKORDER(30047, "不是平安的工单"),
ORDER_IS_EXIST(30048, "该订单已经存在"), ORDER_IS_EXIST(30048, "该订单已经存在"),
EXPORT_OEDER_OUTOF_NUMBER2(30049, "导出超过30000条请修改搜索条件"),
ORDER_FINISHED(30050, "该工单已处理,请勿重复提交"),
/** /**
* 快递单相关 * 快递单相关
......
...@@ -96,6 +96,9 @@ public class ReportController extends BaseReportController { ...@@ -96,6 +96,9 @@ public class ReportController extends BaseReportController {
@Autowired @Autowired
private SysSecondmentService secondmentService; private SysSecondmentService secondmentService;
@Autowired
private DeviceService deviceService;
@RequestMapping(value = "/exportUnknownOrder", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/exportUnknownOrder", method = {RequestMethod.GET, RequestMethod.POST})
public void exportUnknownOrder(HttpServletRequest request, HttpServletResponse response, public void exportUnknownOrder(HttpServletRequest request, HttpServletResponse response,
SysOrder order) { SysOrder order) {
...@@ -377,17 +380,16 @@ public class ReportController extends BaseReportController { ...@@ -377,17 +380,16 @@ public class ReportController extends BaseReportController {
@RequestMapping(value = "/exporRepertoryList", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/exporRepertoryList", method = {RequestMethod.GET, RequestMethod.POST})
public void exportIndent(HttpServletRequest request, HttpServletResponse response, public void exportIndent(HttpServletRequest request, HttpServletResponse response,
Integer sortType, String name, String deviceType) { Integer sortType, String username, String deviceType) {
List<DeviceRepertoryReq> list = this.deviceRepertoryService List<DeviceRepertoryVO> list = deviceService.listExportDevice(sortType, username, deviceType);
.getRepertoryList(sortType, name, deviceType); if (list.size() > 30000) {
if (list.size() > 10000) { throw SysException.create(ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER2.getCode(),
throw SysException.create(ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getCode(), ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER2.getMsg());
ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getMsg());
} }
try { try {
this.exportObject(response, list, "导出库存列表"); this.exportObject(response, list, "导出全部库存详情");
} catch (IOException e) { } catch (IOException e) {
this.logger.info("导出库存列表异常"); this.logger.info("导出全部库存异常");
} }
} }
...@@ -440,7 +442,7 @@ public class ReportController extends BaseReportController { ...@@ -440,7 +442,7 @@ public class ReportController extends BaseReportController {
IndentExport indentExport = new IndentExport(); IndentExport indentExport = new IndentExport();
BeanUtils.copyProperties(sysIndent, indentExport); BeanUtils.copyProperties(sysIndent, indentExport);
indentExport.setIndentStatus(this.tranceIndentStatu(sysIndent.getIndentStatus())); indentExport.setIndentStatus(this.tranceIndentStatu(sysIndent.getIndentStatus()));
indentExport.setUsername(this.tranceIndentUsername(sysIndent)); indentExport.setUsername(sysIndent.getUser().getName());
exports.add(indentExport); exports.add(indentExport);
} }
try { try {
...@@ -474,7 +476,7 @@ public class ReportController extends BaseReportController { ...@@ -474,7 +476,7 @@ public class ReportController extends BaseReportController {
SecondmentExport secondmentExport = new SecondmentExport(); SecondmentExport secondmentExport = new SecondmentExport();
BeanUtils.copyProperties(dto, secondmentExport); BeanUtils.copyProperties(dto, secondmentExport);
secondmentExport.setSecondmentStatus(tranceIndentStatu(dto.getSecondmentStatus())); secondmentExport.setSecondmentStatus(tranceIndentStatu(dto.getSecondmentStatus()));
secondmentExport.setUsername(tranceSecondmentUsername(dto)); secondmentExport.setUsername(dto.getName());
exports.add(secondmentExport); exports.add(secondmentExport);
} }
try { try {
......
package com.glsx.ordercenter.dto;
import com.glsx.excel.poi.annotation.ExcelColumn;
import com.glsx.excel.poi.annotation.ExcelExport;
import lombok.Data;
import java.io.Serializable;
/**
* @author duanht
* @version 1.0.0
* @Title DeviceRepertoryReq
* @Package com.glsx.ordercenter.dto
* @Description $全部库存列表
* @date 2024/6/3 15:13
*/
@Data
@ExcelExport
public class DeviceRepertoryVO implements Serializable {
private static final long serialVersionUID = -8260162714319471827L;
@ExcelColumn(value = "服务商名称",index = 0)
private String serviceName;
@ExcelColumn(value = "技工姓名",index = 1)
private String mechanicName;
@ExcelColumn(value = "设备名称",index = 2)
private String deviceName;
@ExcelColumn(value = "设备号",index = 3)
private String deviceNo;
/**
* 服务商库存
*/
@ExcelColumn(value = "入库时间",index = 4)
private String stockTime;
@ExcelColumn(value = "备注",index = 5)
private String remark;
}
...@@ -36,4 +36,9 @@ public class SecondmentDto extends SysSecondment { ...@@ -36,4 +36,9 @@ public class SecondmentDto extends SysSecondment {
@ApiModelProperty(notes = "借调单设备列表") @ApiModelProperty(notes = "借调单设备列表")
private List<SysSecondmentImportDevice> importDevices; private List<SysSecondmentImportDevice> importDevices;
/**
* 设备号
*/
private String deviceNo;
} }
package com.glsx.ordercenter.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @author chenxi
* @date 2024/6/03 15:30
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SysDeviceExportDto implements Serializable {
private static final long serialVersionUID = -6140644476298728636L;
/**
* 设备号
*/
private String deviceNo;
/**
* 设备类型
*/
private String deviceType;
/**
* 入库时间
*/
private Date stockTime;
/**
* 设备关联用户id
*/
private Integer userId;
/**
* 设备关联订货单号
*/
private String indentNo;
/**
* 订货单备注
*/
private String indentRemark;
/**
* 借调单号
*/
private String secondmentNo;
/**
* 借调单状态10:待审核;20:待发货;30:待收货;40:已完成;
*/
private Integer secondmentStatus;
/**
* 借调单备注
*/
private String secondmentRemark;
/**
* 技工名称
*/
private String mechanicName;
/**
* 用户类型(0:系统管理员,1:服务商,2:门店,3:技工)
*/
private Byte userType;
}
package com.glsx.ordercenter.mapper; package com.glsx.ordercenter.mapper;
import java.util.List; import java.util.List;
import java.util.Map;
import com.glsx.ordercenter.common.PermissionControl;
import com.glsx.ordercenter.dto.SysDeviceExportDto;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.glsx.ordercenter.pojo.SysDevice; import com.glsx.ordercenter.pojo.SysDevice;
...@@ -61,4 +64,7 @@ public interface SysDeviceMapper { ...@@ -61,4 +64,7 @@ public interface SysDeviceMapper {
int updateUserByDeviceNoList(@Param("beSecondedId")Integer beSecondedId, @Param("secondedId") Integer secondedId, @Param("deviceNoList") List<String> deviceNoList, @Param("updateBy") int updateBy); int updateUserByDeviceNoList(@Param("beSecondedId")Integer beSecondedId, @Param("secondedId") Integer secondedId, @Param("deviceNoList") List<String> deviceNoList, @Param("updateBy") int updateBy);
int countByIndentNo(String indentNo); int countByIndentNo(String indentNo);
@PermissionControl(tableAlias = "a",columnName = "user_id")
List<SysDeviceExportDto> getExportDeviceList(Map<String, Object> params);
} }
\ No newline at end of file \ No newline at end of file
...@@ -63,6 +63,17 @@ public interface SysIndentMapper { ...@@ -63,6 +63,17 @@ public interface SysIndentMapper {
*/ */
SysIndent getByUserIdAndDeviceNo(@Param("userId")int userId, @Param("deviceNo")String deviceNo); SysIndent getByUserIdAndDeviceNo(@Param("userId")int userId, @Param("deviceNo")String deviceNo);
/**
*
* @author chenxi
* @Title: getByDeviceNo
* @Description: 通过设备号获取订单信息
* @return
* SysIndent
*
*/
SysIndent getByDeviceNo(@Param("deviceNo")String deviceNo);
/** /**
* *
* @author zhanghj * @author zhanghj
......
package com.glsx.ordercenter.mapper; package com.glsx.ordercenter.mapper;
import com.glsx.ordercenter.pojo.user.SysManager; import com.glsx.ordercenter.pojo.user.SysManager;
import com.glsx.ordercenter.pojo.user.SysUser;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
public interface SysManagerMapper { public interface SysManagerMapper {
int deleteByPrimaryKey(Integer id); int deleteByPrimaryKey(Integer id);
...@@ -25,4 +29,12 @@ public interface SysManagerMapper { ...@@ -25,4 +29,12 @@ public interface SysManagerMapper {
* @return 服务商 * @return 服务商
*/ */
SysManager selectByProviderName(@Param("providerName") String providerName); SysManager selectByProviderName(@Param("providerName") String providerName);
/**
* 根据UserId获取用户列表
*
* @param userIdList userId列表
* @return
*/
List<SysManager> selectByUserIdList(@Param("userIdList") Set<Integer> userIdList);
} }
\ No newline at end of file \ No newline at end of file
...@@ -21,4 +21,6 @@ public interface SysSecondmentImportDeviceMapper { ...@@ -21,4 +21,6 @@ public interface SysSecondmentImportDeviceMapper {
int countImportDeviceByDeviceNo(@Param("deviceNo")String deviceNo); int countImportDeviceByDeviceNo(@Param("deviceNo")String deviceNo);
int deleteBySecondmentNo(@Param("secondmentNo") String secondmentNo); int deleteBySecondmentNo(@Param("secondmentNo") String secondmentNo);
void deleteDeviceNoBySecondmentNo(@Param("secondmentNo")String secondmentNo, @Param("deviceNo")String deviceNo);
} }
\ No newline at end of file \ No newline at end of file
...@@ -36,4 +36,13 @@ public interface SysSecondmentMapper { ...@@ -36,4 +36,13 @@ public interface SysSecondmentMapper {
int updateByPrimaryKeySelective(SysSecondment record); int updateByPrimaryKeySelective(SysSecondment record);
String selectSecondmentNoById(Integer id); String selectSecondmentNoById(Integer id);
SecondmentDto getSecondmentByDeviceNo(@Param("deviceNo")String deviceNo);
/**
* 更新借调单借调数量
* @param secondmentNo 借调单
* @param updateUserId 更新人
*/
void updateSecondmentAmount(@Param("secondmentNo") String secondmentNo, @Param("updateUserId") int updateUserId);
} }
\ No newline at end of file \ No newline at end of file
...@@ -10,4 +10,8 @@ import java.util.List; ...@@ -10,4 +10,8 @@ import java.util.List;
public interface SysServiceMechanicMapper { public interface SysServiceMechanicMapper {
List<SysServiceMechanic> listByServiceId(@Param("serviceId") Integer serviceId); List<SysServiceMechanic> listByServiceId(@Param("serviceId") Integer serviceId);
List<SysServiceMechanic> listAll();
List<Integer> getServiceIdAndMechanicIdByServiceName(@Param("serviceName")String serviceName);
} }
\ No newline at end of file \ No newline at end of file
...@@ -3,6 +3,7 @@ package com.glsx.ordercenter.service; ...@@ -3,6 +3,7 @@ package com.glsx.ordercenter.service;
import java.util.List; import java.util.List;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.ordercenter.dto.DeviceRepertoryVO;
import com.glsx.ordercenter.pojo.SysDevice; import com.glsx.ordercenter.pojo.SysDevice;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -53,4 +54,6 @@ public interface DeviceService { ...@@ -53,4 +54,6 @@ public interface DeviceService {
SysDevice selectByDeviceNo(String deviceNo); SysDevice selectByDeviceNo(String deviceNo);
int updateUserByDeviceNoList(Integer beSecondedId, Integer secondedId, List<String> deviceNoList, int updateBy); int updateUserByDeviceNoList(Integer beSecondedId, Integer secondedId, List<String> deviceNoList, int updateBy);
List<DeviceRepertoryVO> listExportDevice(Integer sortType, String username, String deviceType);
} }
...@@ -3,17 +3,32 @@ package com.glsx.ordercenter.service.impl; ...@@ -3,17 +3,32 @@ package com.glsx.ordercenter.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.StringUtils; import com.glsx.common.utils.StringUtils;
import com.glsx.common.utils.UserUtils; import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.constants.SecondmentStatusEnum;
import com.glsx.ordercenter.dto.DeviceRepertoryVO;
import com.glsx.ordercenter.dto.SysDeviceExportDto;
import com.glsx.ordercenter.exception.BusinessException; import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.mapper.SysManagerMapper;
import com.glsx.ordercenter.mapper.SysServiceMechanicMapper;
import com.glsx.ordercenter.pojo.DictionaryData;
import com.glsx.ordercenter.pojo.SysServiceMechanic;
import com.glsx.ordercenter.pojo.user.SysManager;
import com.glsx.ordercenter.service.IDictionaryDataService;
import com.glsx.ordercenter.service.SysSecondmentService; import com.glsx.ordercenter.service.SysSecondmentService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -49,6 +64,13 @@ public class DeviceServiceImpl implements DeviceService{ ...@@ -49,6 +64,13 @@ public class DeviceServiceImpl implements DeviceService{
@Autowired @Autowired
private SysSecondmentService secondmentService; private SysSecondmentService secondmentService;
@Autowired
private IDictionaryDataService iDictionaryDataService;
@Autowired
private SysManagerMapper sysManagerMapper;
@Autowired
private SysServiceMechanicMapper sysServiceMechanicMapper;
@Override @Override
public List<SysDevice> catIndentDevices(String indentNo) { public List<SysDevice> catIndentDevices(String indentNo) {
...@@ -424,4 +446,111 @@ public class DeviceServiceImpl implements DeviceService{ ...@@ -424,4 +446,111 @@ public class DeviceServiceImpl implements DeviceService{
JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("data");
return data != null; return data != null;
} }
@Override
public List<DeviceRepertoryVO> listExportDevice(Integer sortType, String username, String deviceType) {
Map<String, Object> params = new HashMap<>();
params.put("deviceType", deviceType);
//根据username查询相关服务商以及服务商下属技工
if (StringUtils.isNotEmpty(username)) {
List<Integer> serviceIdAndMechanicIdList = sysServiceMechanicMapper.getServiceIdAndMechanicIdByServiceName(username);
if (CollectionUtils.isNotEmpty(serviceIdAndMechanicIdList)) {
params.put("serviceIdAndMechanicIdList", serviceIdAndMechanicIdList);
}
}
List<SysDeviceExportDto> exportDeviceList = sysDeviceMapper.getExportDeviceList(params);
if (CollectionUtils.isEmpty(exportDeviceList)) {
return Lists.newArrayList();
}
//查询设备名称信息
DictionaryData dictionaryData = new DictionaryData();
dictionaryData.setDictType(Constants.SYS_ORDER_SERVICE_ITEM);
List<DictionaryData> dictionaryDataList = iDictionaryDataService.getList(dictionaryData);
Map<String, String> serviceItemMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(dictionaryDataList)) {
serviceItemMap = dictionaryDataList.stream().collect(Collectors.toMap(DictionaryData::getDataKey, DictionaryData::getDataValue, (o1, o2) -> o2));
}
//服务商id列表
Set<Integer> serviceUserIdList = exportDeviceList.stream()
.filter(item -> Objects.equals(item.getUserType(), BizConstants.USER_TYPE_MERCHANT))
.map(SysDeviceExportDto::getUserId).collect(Collectors.toSet());
//技工userId列表
Set<Integer> mechanicUserIdList = exportDeviceList.stream()
.filter(item -> Objects.equals(item.getUserType(), BizConstants.USER_TYPE_MECHANIC))
.map(SysDeviceExportDto::getUserId).collect(Collectors.toSet());
//查询技工和服务商关联关系
List<SysServiceMechanic> sysServiceMechanicsList = sysServiceMechanicMapper.listAll();
//技工关联的服务商
List<Integer> mechanicRelatedServiceUserId = sysServiceMechanicsList.stream()
.filter(x -> mechanicUserIdList.contains(x.getMechanicId()))
.map(SysServiceMechanic::getServiceId)
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(sysServiceMechanicsList)) {
serviceUserIdList.addAll(mechanicRelatedServiceUserId);
}
//技工关联服务商
Map<Integer, Integer> mechanicServiceMap = sysServiceMechanicsList.stream()
.filter(x -> mechanicUserIdList.contains(x.getMechanicId()))
.collect(Collectors.toMap(SysServiceMechanic::getMechanicId, SysServiceMechanic::getServiceId, (o1, o2) -> o2));
//服务商userId、name的map
Map<Integer, String> providerUserIdNameMap = new HashMap<>(100);
List<SysManager> sysManagers = sysManagerMapper.selectByUserIdList(serviceUserIdList);
if (CollectionUtils.isNotEmpty(sysManagers)) {
providerUserIdNameMap = sysManagers.stream().collect(Collectors.toMap(SysManager::getUserId, SysManager::getProviderName, (o1, o2) -> o2));
}
List<DeviceRepertoryVO> exportList = Lists.newArrayList();
for (SysDeviceExportDto sysDeviceExportDto : exportDeviceList) {
DeviceRepertoryVO deviceRepertoryVO = new DeviceRepertoryVO();
Integer userId = sysDeviceExportDto.getUserId();
deviceRepertoryVO.setDeviceNo(sysDeviceExportDto.getDeviceNo());
Date stockTime = sysDeviceExportDto.getStockTime();
if (Objects.nonNull(stockTime)) {
deviceRepertoryVO.setStockTime(DateUtil.formatDate(stockTime));
}
String currentDeviceType = sysDeviceExportDto.getDeviceType();
if (StringUtils.isNotEmpty(currentDeviceType)) {
deviceRepertoryVO.setDeviceName(serviceItemMap.get(currentDeviceType));
}
if (Objects.equals(sysDeviceExportDto.getUserType(), BizConstants.USER_TYPE_MERCHANT)) {
String providerName = providerUserIdNameMap.get(userId);
deviceRepertoryVO.setServiceName(providerName);
} else {
Integer serviceUserId = mechanicServiceMap.get(userId);
if (Objects.nonNull(serviceUserId)) {
deviceRepertoryVO.setServiceName(providerUserIdNameMap.get(serviceUserId));
}
deviceRepertoryVO.setMechanicName(sysDeviceExportDto.getMechanicName());
}
//备注,对于借调途中的设备,备注为"在途借调";
// 对于借调已完成的设备,备注为借调单的备注;
// 对于其他设备,备注为订货单备注
Integer secondmentStatus = sysDeviceExportDto.getSecondmentStatus();
if (Objects.isNull(secondmentStatus)) {
deviceRepertoryVO.setRemark(sysDeviceExportDto.getIndentRemark());
}
if (Objects.equals(secondmentStatus, SecondmentStatusEnum.SECONDMENT_UNCHECKED.getSecondmentStatus()) ||
Objects.equals(secondmentStatus, SecondmentStatusEnum.SECONDMENT_WAITDELIVER.getSecondmentStatus()) ||
Objects.equals(secondmentStatus, SecondmentStatusEnum.SECONDMENT_DELIVERED.getSecondmentStatus())) {
deviceRepertoryVO.setRemark("在途借调");
}
if (Objects.equals(secondmentStatus, SecondmentStatusEnum.SECONDMENT_COMPLETE.getSecondmentStatus())) {
deviceRepertoryVO.setRemark(sysDeviceExportDto.getSecondmentRemark());
}
exportList.add(deviceRepertoryVO);
}
return exportList;
}
} }
...@@ -226,6 +226,14 @@ public class OrderServiceImpl implements IOrderService { ...@@ -226,6 +226,14 @@ public class OrderServiceImpl implements IOrderService {
@Autowired @Autowired
private OcrComponent ocrComponent; private OcrComponent ocrComponent;
@Autowired
private SysSecondmentMapper sysSecondmentMapper;
@Autowired
private SysSecondmentImportDeviceMapper sysSecondmentImportDeviceMapper;
@Autowired
private SysSecondmentLogMapper sysSecondmentLogMapper;
@Autowired
private SysSecondmentMapper secondmentMapper;
private ExecutorService carOrderThreadPool = Executors.newFixedThreadPool(10); private ExecutorService carOrderThreadPool = Executors.newFixedThreadPool(10);
...@@ -4334,25 +4342,27 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4334,25 +4342,27 @@ public class OrderServiceImpl implements IOrderService {
return resultObject; return resultObject;
} }
private void reduceStock(List<SysOrderDevice> orderDeviceList, int userId) { private void reduceStock(List<SysOrderDevice> orderDeviceList, int updateUserId) {
try { try {
List<String> list = orderDeviceList.stream().map(SysOrderDevice::getDeviceNo).collect(Collectors.toList()); List<String> list = orderDeviceList.stream().map(SysOrderDevice::getDeviceNo).collect(Collectors.toList());
SysDeviceExample deviceExample = new SysDeviceExample(); SysDeviceExample deviceExample = new SysDeviceExample();
deviceExample.createCriteria().andUserIdEqualTo(userId).andDeviceStatusEqualTo(Constants.DEVICE_STATUS_NO_ACTIVE).andDeviceNoIn(list); deviceExample.createCriteria().andDeviceStatusEqualTo(Constants.DEVICE_STATUS_NO_ACTIVE).andDeviceNoIn(list);
List<SysDevice> sysDevices = deviceMapper.selectByExample(deviceExample); List<SysDevice> sysDevices = deviceMapper.selectByExample(deviceExample);
if (sysDevices.isEmpty()) { if (sysDevices.isEmpty()) {
return; return;
} }
for (SysDevice device : sysDevices) { for (SysDevice device : sysDevices) {
//设备关联的订单未确认收货不允许激活(通过拆除或者检修入库的设备没有订货单,单号可以为空) //设备关联的订单未确认收货不允许激活(通过拆除或者检修入库的设备没有订货单,单号可以为空)
SysIndent sysIndent = indentMapper.getByUserIdAndDeviceNo(userId, device.getDeviceNo()); String deviceNo = device.getDeviceNo();
SysIndent sysIndent = indentMapper.getByDeviceNo(deviceNo);
if (sysIndent == null) { if (sysIndent == null) {
continue; continue;
} }
if (sysIndent.getIndentStatus() != IndentStatusEnum.INDENT_COMPLETE.getIndentStatus()) { if (sysIndent.getIndentStatus() != IndentStatusEnum.INDENT_COMPLETE.getIndentStatus()) {
continue; continue;
} }
//技工设备库存减一 Integer userId = device.getUserId();
//技工或者服务商设备库存减一
deviceRepertoryService.reduceDeviceRepertory(userId, device.getDeviceType(), 1); deviceRepertoryService.reduceDeviceRepertory(userId, device.getDeviceType(), 1);
//设备状态改为已激活 //设备状态改为已激活
SysDevice sysDevice = new SysDevice(); SysDevice sysDevice = new SysDevice();
...@@ -4360,13 +4370,35 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4360,13 +4370,35 @@ public class OrderServiceImpl implements IOrderService {
sysDevice.setId(device.getId()); sysDevice.setId(device.getId());
deviceMapper.updateByPrimaryKeySelective(sysDevice); deviceMapper.updateByPrimaryKeySelective(sysDevice);
//添加设备消耗记录 //添加设备消耗记录
addDeviceConsumeLog(userId, device.getDeviceNo(), device.getDeviceType(), 1); addDeviceConsumeLog(userId, deviceNo, device.getDeviceType(), 1);
//对于未收货的借调单,删除其设备记录
SecondmentDto secondmentDto = sysSecondmentMapper.getSecondmentByDeviceNo(deviceNo);
if (Objects.nonNull(secondmentDto) && StringUtils.isNotEmpty(secondmentDto.getDeviceNo())) {
String secondmentNo = secondmentDto.getSecondmentNo();
sysSecondmentImportDeviceMapper.deleteDeviceNoBySecondmentNo(secondmentNo, deviceNo);
sysSecondmentMapper.updateSecondmentAmount(secondmentNo, updateUserId);
addSecondmentLog(secondmentDto.getId(), updateUserId, secondmentDto.getDeviceNo() + "设备已激活");
}
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("安装设备扣减库存异常 error:" + e.getMessage(), e); logger.error("安装设备扣减库存异常 error:" + e.getMessage(), e);
} }
} }
private int addSecondmentLog(Integer id, Integer updatedUserId, String remark) {
SysSecondment secondment = secondmentMapper.selectByPrimaryKey(id);
SysSecondmentLog secondmentLog = new SysSecondmentLog();
secondmentLog.setSecondmentId(id);
secondmentLog.setSecondmentStatus(secondment.getSecondmentStatus());
secondmentLog.setRemark(remark);
secondmentLog.setCreateBy(updatedUserId);
secondmentLog.setCreateTime(new Date());
return sysSecondmentLogMapper.insertSelective(secondmentLog);
}
/** /**
* 安装单保存数据封装 * 安装单保存数据封装
* *
...@@ -4378,13 +4410,23 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4378,13 +4410,23 @@ public class OrderServiceImpl implements IOrderService {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public byte saveOrderData(OrderDeviceReq deviceReq, SysOrder order, int userId, boolean isAudit) { public byte saveOrderData(OrderDeviceReq deviceReq, SysOrder order, int userId, boolean isAudit) {
Integer id = order.getId();
SysOrder oldSysOrder = orderMapper.selectByPrimaryKey(id);
if (Objects.isNull(oldSysOrder)) {
throw BusinessException.create(ResultCodeEnum.ORDER_NOT_EXIST);
}
if (OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_CANCEL.getActiveStatus() == oldSysOrder.getCanceled()) {
throw BusinessException.create(ResultCodeEnum.ORDER_CANCELED);
}
byte auditStatus = -1; //默认不需要审核 byte auditStatus = -1; //默认不需要审核
Date date = new Date(); Date date = new Date();
boolean statusFlag = order.getActiveStatus() != OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus(); //订单此时是否是已完成 boolean statusFlag = order.getActiveStatus() != OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus(); //订单此时是否是已完成
//订单照片 //订单照片
List<SysOrderFile> orderFileList = deviceReq.getOrderFileList(); List<SysOrderFile> orderFileList = deviceReq.getOrderFileList();
if (orderFileList != null && orderFileList.size() > 0) { if (orderFileList != null && orderFileList.size() > 0) {
orderFileMapper.deleteByOrderId(order.getId()); //审核的时候会更新,先删除已有后插入 orderFileMapper.deleteByOrderId(id); //审核的时候会更新,先删除已有后插入
orderFileMapper.addOrderFileList(orderFileList); //插入订单照片 orderFileMapper.addOrderFileList(orderFileList); //插入订单照片
if ((byte) BizConstants.ORDER_TYPE_INSTALL == order.getOrderType()) { // 安装单 ---开起任务线程,图像识别 if ((byte) BizConstants.ORDER_TYPE_INSTALL == order.getOrderType()) { // 安装单 ---开起任务线程,图像识别
deviceReq.setOrderSn(order.getOrderSn()); deviceReq.setOrderSn(order.getOrderSn());
...@@ -4396,7 +4438,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4396,7 +4438,7 @@ public class OrderServiceImpl implements IOrderService {
this.updateOrderDeviceSupplier(order, deviceReq.getOrderDeviceList()); this.updateOrderDeviceSupplier(order, deviceReq.getOrderDeviceList());
// 更新订单状态 // 更新订单状态
SysOrder sysOrder = new SysOrder(); SysOrder sysOrder = new SysOrder();
sysOrder.setId(order.getId()); sysOrder.setId(id);
if (isAudit) { //需要审核 if (isAudit) { //需要审核
auditStatus = deviceReq.getAuditStatus() == null ? AuditStatusEnum.NOT_AUDIT.getCode() : deviceReq.getAuditStatus(); auditStatus = deviceReq.getAuditStatus() == null ? AuditStatusEnum.NOT_AUDIT.getCode() : deviceReq.getAuditStatus();
if (auditStatus == AuditStatusEnum.NOT_AUDIT.getCode()) { if (auditStatus == AuditStatusEnum.NOT_AUDIT.getCode()) {
...@@ -4405,6 +4447,12 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4405,6 +4447,12 @@ public class OrderServiceImpl implements IOrderService {
if (auditStatus == AuditStatusEnum.REJECTED.getCode() || auditStatus == AuditStatusEnum.ABNORMALLY_PASSED.getCode()) { if (auditStatus == AuditStatusEnum.REJECTED.getCode() || auditStatus == AuditStatusEnum.ABNORMALLY_PASSED.getCode()) {
sysOrder.setAuditCount((byte) (order.getAuditCount() + 1)); //已退回||已通过(退回通过)次数+1 sysOrder.setAuditCount((byte) (order.getAuditCount() + 1)); //已退回||已通过(退回通过)次数+1
} }
if (auditStatus == AuditStatusEnum.REJECTED.getCode() || auditStatus == AuditStatusEnum.ABNORMALLY_PASSED.getCode() ||
auditStatus == AuditStatusEnum.NORMALLY_PASSED.getCode()) {
if (!Objects.equals(oldSysOrder.getAuditStatus(), AuditStatusEnum.NOT_AUDIT.getCode())) {
throw BusinessException.create(ResultCodeEnum.ORDER_FINISHED);
}
}
} }
if (statusFlag) { if (statusFlag) {
sysOrder.setActiveStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus()); sysOrder.setActiveStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus());
...@@ -4419,7 +4467,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4419,7 +4467,7 @@ public class OrderServiceImpl implements IOrderService {
if (i > 0) { if (i > 0) {
if (statusFlag) { //新增订单进度 if (statusFlag) { //新增订单进度
SysOrderStatus sysOrderStatus = new SysOrderStatus(); SysOrderStatus sysOrderStatus = new SysOrderStatus();
sysOrderStatus.setOrderId(order.getId()); sysOrderStatus.setOrderId(id);
sysOrderStatus.setIsShow(BizConstants.ORDER_PROGRESS_SHOW); sysOrderStatus.setIsShow(BizConstants.ORDER_PROGRESS_SHOW);
sysOrderStatus.setActiveStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus()); sysOrderStatus.setActiveStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus());
sysOrderStatus.setUpdateTime(date); sysOrderStatus.setUpdateTime(date);
...@@ -4449,7 +4497,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4449,7 +4497,7 @@ public class OrderServiceImpl implements IOrderService {
sendPubMessageToRedis(order); sendPubMessageToRedis(order);
} }
SysOrderAuditStatus record = new SysOrderAuditStatus(); SysOrderAuditStatus record = new SysOrderAuditStatus();
record.setOrderId(order.getId()); record.setOrderId(id);
record.setAuditStatus(auditStatus); record.setAuditStatus(auditStatus);
record.setReason(deviceReq.getReason()); record.setReason(deviceReq.getReason());
record.setCreateBy(userId); record.setCreateBy(userId);
...@@ -4462,7 +4510,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4462,7 +4510,7 @@ public class OrderServiceImpl implements IOrderService {
} }
} }
//推送Kafka进行ocr识别 //推送Kafka进行ocr识别
pushOcrInfo(order.getId()); pushOcrInfo(id);
return auditStatus; return auditStatus;
} }
......
...@@ -229,34 +229,33 @@ public class SysSecondmentServiceImpl implements SysSecondmentService { ...@@ -229,34 +229,33 @@ public class SysSecondmentServiceImpl implements SysSecondmentService {
} }
List<SysSecondmentImportDevice> list = secondmentImportDeviceMapper.getListBySecondmentNo(secondmentNo); List<SysSecondmentImportDevice> list = secondmentImportDeviceMapper.getListBySecondmentNo(secondmentNo);
if (list.isEmpty()) { if (CollectionUtils.isNotEmpty(list)) {
return new ResultObject(ResultCodeEnum.SECONDMENT_DEVICE_NOT_EXIST.getCode(), ResultCodeEnum.SECONDMENT_DEVICE_NOT_EXIST.getMsg()); //同一个借调单借调人相同 被借调人可能不同 根据被借调人来分组
} Map<Integer, List<SysSecondmentImportDevice>> listMap = list.stream().collect(Collectors.groupingBy(SysSecondmentImportDevice::getBeSecondedId));
//同一个借调单借调人相同 被借调人可能不同 根据被借调人来分组
Map<Integer, List<SysSecondmentImportDevice>> listMap = list.stream().collect(Collectors.groupingBy(SysSecondmentImportDevice::getBeSecondedId)); //更新设备归属人、更新库存
Integer finalServiceId = serviceId;
//更新设备归属人、更新库存 listMap.values().forEach(deviceList -> {
Integer finalServiceId = serviceId; if (!deviceList.isEmpty()) {
listMap.values().forEach(deviceList -> { SysSecondmentImportDevice item = deviceList.get(0);
if (!deviceList.isEmpty()) { List<String> deviceNoList = deviceList.stream().map(SysSecondmentImportDevice::getDeviceNo).collect(Collectors.toList());
SysSecondmentImportDevice item = deviceList.get(0); int a = deviceService.updateUserByDeviceNoList(item.getBeSecondedId(), item.getSecondedId(), deviceNoList, userId);
List<String> deviceNoList = deviceList.stream().map(SysSecondmentImportDevice::getDeviceNo).collect(Collectors.toList()); if (a != deviceNoList.size()) {
int a = deviceService.updateUserByDeviceNoList(item.getBeSecondedId(), item.getSecondedId(), deviceNoList, userId); logger.error("借调单号:{},被借调人id:{},借调设备列表数量:{},更新归属人成功数量:{}", item.getSecondmentNo(), item.getBeSecondedId(), deviceList.size(), a);
if (a != deviceNoList.size()) { }
logger.error("借调单号:{},被借调人id:{},借调设备列表数量:{},更新归属人成功数量:{}", item.getSecondmentNo(), item.getBeSecondedId(), deviceList.size(), a);
}
deviceRepertoryService.addDeviceRepertory(item.getSecondedId(), secondment.getDeviceType(), deviceList.size()); deviceRepertoryService.addDeviceRepertory(item.getSecondedId(), secondment.getDeviceType(), deviceList.size());
ResultObject result = deviceRepertoryService.reduceDeviceRepertory(item.getBeSecondedId(), secondment.getDeviceType(), deviceList.size()); ResultObject result = deviceRepertoryService.reduceDeviceRepertory(item.getBeSecondedId(), secondment.getDeviceType(), deviceList.size());
if (result != null) { if (result != null) {
throw BusinessException.create(result.getCode(), result.getMessage()); throw BusinessException.create(result.getCode(), result.getMessage());
} }
//如果借调人为技工 需要更新对应服务商的库存 //如果借调人为技工 需要更新对应服务商的库存
if (userType == Constants.USER_TYPE_MECHANIC) { if (userType == Constants.USER_TYPE_MECHANIC) {
deviceRepertoryService.addDeviceRepertory(finalServiceId, secondment.getDeviceType(), 0); deviceRepertoryService.addDeviceRepertory(finalServiceId, secondment.getDeviceType(), 0);
}
} }
} });
}); }
secondmentMapper.updateSecondmentStatusById(SecondmentStatusEnum.SECONDMENT_COMPLETE.getSecondmentStatus(), userId, secondment.getId()); secondmentMapper.updateSecondmentStatusById(SecondmentStatusEnum.SECONDMENT_COMPLETE.getSecondmentStatus(), userId, secondment.getId());
......
...@@ -440,4 +440,37 @@ ...@@ -440,4 +440,37 @@
SELECT count(*) from sys_device where indent_no=#{indentNo} SELECT count(*) from sys_device where indent_no=#{indentNo}
</select> </select>
<select id="getExportDeviceList" resultType="com.glsx.ordercenter.dto.SysDeviceExportDto">
select a.device_no as deviceNo,
a.device_type as deviceType,
a.stock_time as stockTime,
a.user_id as userId,
b.indent_no as indentNo,
b.remark as indentRemark,
d.secondment_no as secondmentNo,
d.secondment_status as secondmentStatus,
d.remark as secondmentRemark,
f.name as mechanicName,
f.user_type as userType
from sys_device a
left join sys_indent b on a.indent_no = b.indent_no
left join sys_secondment_import_device c on c.device_no = a.device_no
left join sys_secondment d on c.secondment_no = d.secondment_no and d.is_canceled = 0
left join sys_user f on f.id = a.user_id
<where>
a.device_status = 1
<if test="deviceType != null and deviceType != '' ">
and a.device_type = #{deviceType}
</if>
<if test="serviceIdAndMechanicIdList != null and serviceIdAndMechanicIdList.size() != 0">
and a.user_id in
<foreach collection="serviceIdAndMechanicIdList" item="item" open="(" separator="," close=")">
#{item,jdbcType=INTEGER}
</foreach>
</if>
</where>
order by a.create_time desc
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -275,7 +275,7 @@ ...@@ -275,7 +275,7 @@
sdr.user_id userId, sdr.user_id userId,
sdr.device_num serviceDeviceNum, sdr.device_num serviceDeviceNum,
sdr.device_type deviceType, sdr.device_type deviceType,
su.name name, case su.user_type when 1 then sm.provider_name else su.name end as name,
su.username username, su.username username,
su.user_type userType, su.user_type userType,
sdd.data_value deviceName sdd.data_value deviceName
...@@ -283,9 +283,14 @@ ...@@ -283,9 +283,14 @@
sys_device_repertory sdr sys_device_repertory sdr
LEFT JOIN sys_user su ON sdr.user_id = su.id LEFT JOIN sys_user su ON sdr.user_id = su.id
LEFT JOIN sys_dict_data sdd ON sdr.device_type = sdd.data_key LEFT JOIN sys_dict_data sdd ON sdr.device_type = sdd.data_key
LEFT JOIN sys_manager sm on sdr.user_id = sm.user_id and su.user_type = 1
WHERE su.user_type=1 WHERE su.user_type=1
<if test="username != null and username != ''"> <if test="username != null and username != ''">
and su.username LIKE concat('%',#{username},'%') and (
(su.name LIKE concat('%',#{username},'%') and su.user_type != 1)
or
(sm.provider_name LIKE concat('%',#{username},'%') and su.user_type = 1)
)
</if> </if>
<if test="deviceType != null and deviceType != ''"> <if test="deviceType != null and deviceType != ''">
and sdr.device_type = #{deviceType} and sdr.device_type = #{deviceType}
...@@ -309,13 +314,14 @@ ...@@ -309,13 +314,14 @@
sd.stock_time stockTime, sd.stock_time stockTime,
sd.remark remark, sd.remark remark,
su.id userId, su.id userId,
su.name userName, case su.user_type when 1 then sm.provider_name else su.name end as username,
su.username loginName su.username loginName
FROM FROM
sys_device sd sys_device sd
LEFT JOIN sys_dict_data sdd ON sd.device_type = sdd.data_key LEFT JOIN sys_dict_data sdd ON sd.device_type = sdd.data_key
LEFT JOIN sys_indent si ON sd.indent_no = si.indent_no LEFT JOIN sys_indent si ON sd.indent_no = si.indent_no
LEFT JOIN sys_user su ON su.id = sd.user_id LEFT JOIN sys_user su ON su.id = sd.user_id
LEFT JOIN sys_manager sm on su.id = sm.user_id and su.user_type = 1
WHERE si.indent_status = 40 WHERE si.indent_status = 40
AND sd.device_status = 1 AND sd.device_status = 1
AND sd.user_id = #{userId} AND sd.user_id = #{userId}
......
...@@ -286,12 +286,15 @@ ...@@ -286,12 +286,15 @@
si.device_amount, si.indent_status, si.is_canceled, si.phone, si.device_amount, si.indent_status, si.is_canceled, si.phone,
si.receiver_name, si.district_code, si.address, si.remark, si.indent_type, si.receiver_name, si.district_code, si.address, si.remark, si.indent_type,
si.create_by, si.create_time, si.update_by, si.update_time, si.create_by, si.create_time, si.update_by, si.update_time,
su.username,su.name,su.user_type, su.username,
case su.user_type when 1 then sm.provider_name else su.name end as name,
su.user_type,
sdd.data_value as deviceName sdd.data_value as deviceName
FROM FROM
sys_indent si sys_indent si
LEFT JOIN sys_user su ON si.user_id = su.id LEFT JOIN sys_user su ON si.user_id = su.id
LEFT JOIN sys_dict_data sdd ON si.device_type = sdd.data_key LEFT JOIN sys_dict_data sdd ON si.device_type = sdd.data_key
LEFT JOIN sys_manager sm on su.id = sm.user_id and su.user_type = 1
<where> <where>
si.send_type = 2 si.send_type = 2
<if test="indentStatus != null"> <if test="indentStatus != null">
...@@ -307,7 +310,7 @@ ...@@ -307,7 +310,7 @@
and si.create_time &lt;= #{endDate} and si.create_time &lt;= #{endDate}
</if> </if>
<if test="username != null and username != ''"> <if test="username != null and username != ''">
and ((su.user_type=1 and su.username like #{username}) or (su.user_type=3 and su.name like #{username})) and ( (su.user_type=1 and sm.provider_name like #{username}) or (su.user_type != 1 and su.name like #{username}))
</if> </if>
</where> </where>
ORDER BY si.create_time desc, si.id DESC ORDER BY si.create_time desc, si.id DESC
...@@ -358,7 +361,9 @@ ...@@ -358,7 +361,9 @@
si.device_amount, si.indent_status, si.is_canceled, si.phone, si.device_amount, si.indent_status, si.is_canceled, si.phone,
si.receiver_name, si.district_code, si.address, si.remark, si.receiver_name, si.district_code, si.address, si.remark,
si.create_by, si.create_time, si.update_by, si.update_time,si.indent_type, si.create_by, si.create_time, si.update_by, si.update_time,si.indent_type,
su.username,su.name,su.user_type, su.username,
case su.user_type when 1 then sm.provider_name else su.name end as name,
su.user_type,
sdd.data_value as deviceName, sdd.data_value as deviceName,
sil.id as logisticsId, sil.indent_id, sil.logistics_no, sil.logistics_time, sil.logistics_unicode, sil.remark as logisticsRemark, sil.id as logisticsId, sil.indent_id, sil.logistics_no, sil.logistics_time, sil.logistics_unicode, sil.remark as logisticsRemark,
sl.express_company, sl.express_company,
...@@ -374,6 +379,7 @@ ...@@ -374,6 +379,7 @@
LEFT JOIN sys_area sa1 ON si.district_code = sa1.id LEFT JOIN sys_area sa1 ON si.district_code = sa1.id
LEFT JOIN sys_area sa2 ON sa1.parent_id = sa2.id LEFT JOIN sys_area sa2 ON sa1.parent_id = sa2.id
LEFT JOIN sys_area sa3 ON sa2.parent_id = sa3.id LEFT JOIN sys_area sa3 ON sa2.parent_id = sa3.id
LEFT JOIN sys_manager sm on su.id = sm.user_id and su.user_type = 1
where si.id = #{id} where si.id = #{id}
</select> </select>
...@@ -385,6 +391,14 @@ ...@@ -385,6 +391,14 @@
where sd.user_id = #{userId} AND sd.device_no = #{deviceNo} where sd.user_id = #{userId} AND sd.device_no = #{deviceNo}
</select> </select>
<select id="getByDeviceNo" resultMap="BaseResultMap">
select
s.*
from sys_indent s
LEFT JOIN sys_device sd ON s.indent_no = sd.indent_no
where sd.device_no = #{deviceNo}
</select>
<select id="getMechanicIndentList" parameterType="com.glsx.ordercenter.pojo.SysIndent" resultMap="BaseResultMap"> <select id="getMechanicIndentList" parameterType="com.glsx.ordercenter.pojo.SysIndent" resultMap="BaseResultMap">
<if test="queryContent != null and queryContent != ''"> <if test="queryContent != null and queryContent != ''">
<bind name="queryContent" value="'%' + queryContent + '%'"/> <bind name="queryContent" value="'%' + queryContent + '%'"/>
......
...@@ -173,4 +173,19 @@ ...@@ -173,4 +173,19 @@
generate_check_sheet = #{generateCheckSheet,jdbcType=INTEGER} generate_check_sheet = #{generateCheckSheet,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<select id="selectByUserIdList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from
sys_manager
<where>
<if test="userIdList != null and userIdList.size()>0">
and user_id in
<foreach collection="userIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -34,14 +34,23 @@ ...@@ -34,14 +34,23 @@
select select
ssid.id, ssid.secondment_no, ssid.seconded_id, ssid.be_seconded_id, ssid.id, ssid.secondment_no, ssid.seconded_id, ssid.be_seconded_id,
ssid.device_no, ss.create_by, ss.create_time, ss.update_by, ss.update_time, ssid.device_no, ss.create_by, ss.create_time, ss.update_by, ss.update_time,
su1.username,su1.name,su1.user_type, su1.username,
su2.username as beUsername,su2.name as beName,su2.user_type as beUserType, <!--su1.name,-->
case su1.user_type when 1 then sm1.provider_name else su1.name end as name,
su1.user_type,
su2.username as beUsername,
<!-- su2.name as beName,-->
case su2.user_type when 1 then sm2.provider_name else su2.name end as beName,
su2.user_type as beUserType,
sdd.data_value as deviceName sdd.data_value as deviceName
FROM FROM
sys_secondment_import_device ssid sys_secondment_import_device ssid
LEFT JOIN sys_secondment ss ON ssid.secondment_no = ss.secondment_no LEFT JOIN sys_secondment ss ON ssid.secondment_no = ss.secondment_no
LEFT JOIN sys_user su1 ON ssid.seconded_id = su1.id LEFT JOIN sys_user su1 ON ssid.seconded_id = su1.id
LEFT JOIN sys_manager sm1 on su1.id = sm1.user_id and su1.user_type = 1
LEFT JOIN sys_user su2 ON ssid.be_seconded_id = su2.id LEFT JOIN sys_user su2 ON ssid.be_seconded_id = su2.id
LEFT JOIN sys_manager sm2 on su2.id = sm2.user_id and su2.user_type = 1
LEFT JOIN sys_dict_data sdd ON ss.device_type = sdd.data_key LEFT JOIN sys_dict_data sdd ON ss.device_type = sdd.data_key
where ssid.secondment_no=#{secondmentNo} where ssid.secondment_no=#{secondmentNo}
<if test="deviceNo != null and deviceNo != ''"> <if test="deviceNo != null and deviceNo != ''">
...@@ -93,4 +102,9 @@ ...@@ -93,4 +102,9 @@
where secondment_no = #{secondmentNo} where secondment_no = #{secondmentNo}
</delete> </delete>
<delete id="deleteDeviceNoBySecondmentNo">
delete from sys_secondment_import_device
where secondment_no = #{secondmentNo} and device_no = #{deviceNo}
</delete>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -38,6 +38,11 @@ ...@@ -38,6 +38,11 @@
<result property="expressCompany" column="express_company"/> <result property="expressCompany" column="express_company"/>
</association> </association>
</resultMap> </resultMap>
<resultMap id="getSecondmentByDeviceNoResultMap" type="com.glsx.ordercenter.dto.SecondmentDto" extends="BaseResultMap">
<result column="deviceNo" jdbcType="VARCHAR" property="deviceNo"/>
</resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
...@@ -68,6 +73,14 @@ ...@@ -68,6 +73,14 @@
where id = #{id} where id = #{id}
</update> </update>
<update id="updateSecondmentAmount">
update sys_secondment
set secondment_amount = secondment_amount - 1,
update_by = #{updateUserId}
where secondment_no = #{secondmentNo} and secondment_amount > 0
</update>
<select id="getListByPage" resultMap="DTOResultMap"> <select id="getListByPage" resultMap="DTOResultMap">
<if test="username != null and username != ''"> <if test="username != null and username != ''">
<bind name="username" value="'%' + username + '%'"/> <bind name="username" value="'%' + username + '%'"/>
...@@ -81,13 +94,17 @@ ...@@ -81,13 +94,17 @@
select select
ss.id, ss.secondment_no, ss.send_type, ss.seconded_id, ss.device_type, ss.id, ss.secondment_no, ss.send_type, ss.seconded_id, ss.device_type,
ss.secondment_amount, ss.secondment_status, ss.is_canceled, ss.phone, ss.secondment_amount, ss.secondment_status, ss.is_canceled, ss.phone,
ss.receiver_name, ss.district_code, ss.address, ss.remark, ss.receiver_name,
ss.district_code, ss.address, ss.remark,
ss.create_by, ss.create_time, ss.update_by, ss.update_time, ss.create_by, ss.create_time, ss.update_by, ss.update_time,
su.username,su.name,su.user_type, su.username,
case su.user_type when 1 then sm.provider_name else su.name end as name,
su.user_type,
sdd.data_value as deviceName sdd.data_value as deviceName
FROM FROM
sys_secondment ss sys_secondment ss
LEFT JOIN sys_user su ON ss.seconded_id = su.id LEFT JOIN sys_user su ON ss.seconded_id = su.id
LEFT JOIN sys_manager sm on su.id = sm.user_id and su.user_type = 1
LEFT JOIN sys_dict_data sdd ON ss.device_type = sdd.data_key LEFT JOIN sys_dict_data sdd ON ss.device_type = sdd.data_key
<where> <where>
ss.send_type = 2 ss.send_type = 2
...@@ -104,7 +121,7 @@ ...@@ -104,7 +121,7 @@
and ss.create_time &lt;= #{endDate} and ss.create_time &lt;= #{endDate}
</if> </if>
<if test="username != null and username != ''"> <if test="username != null and username != ''">
and ((su.user_type=1 and su.username like #{username}) or (su.user_type=3 and su.name like #{username})) and ((su.user_type=1 and sm.provider_name like #{username}) or (su.user_type != 1 and su.name like #{username}))
</if> </if>
</where> </where>
ORDER BY ss.create_time desc, ss.id DESC ORDER BY ss.create_time desc, ss.id DESC
...@@ -116,13 +133,16 @@ ...@@ -116,13 +133,16 @@
ss.secondment_amount, ss.secondment_status, ss.is_canceled, ss.phone, ss.secondment_amount, ss.secondment_status, ss.is_canceled, ss.phone,
ss.receiver_name, ss.district_code, ss.address, ss.remark, ss.receiver_name, ss.district_code, ss.address, ss.remark,
ss.create_by, ss.create_time, ss.update_by, ss.update_time, ss.create_by, ss.create_time, ss.update_by, ss.update_time,
su.username,su.name,su.user_type, su.username,
case su.user_type when 1 then sm.provider_name else su.name end as name,
su.user_type,
sdd.data_value as deviceName, sdd.data_value as deviceName,
sil.id as logisticsId, sil.indent_id, sil.logistics_no, sil.logistics_time, sil.logistics_unicode, sil.remark as logisticsRemark, sil.id as logisticsId, sil.indent_id, sil.logistics_no, sil.logistics_time, sil.logistics_unicode, sil.remark as logisticsRemark,
sl.express_company sl.express_company
FROM FROM
sys_secondment ss sys_secondment ss
LEFT JOIN sys_user su ON ss.seconded_id = su.id LEFT JOIN sys_user su ON ss.seconded_id = su.id
LEFT JOIN sys_manager sm on su.id = sm.user_id and su.user_type = 1
LEFT JOIN sys_dict_data sdd ON ss.device_type = sdd.data_key LEFT JOIN sys_dict_data sdd ON ss.device_type = sdd.data_key
LEFT JOIN sys_indent_logistics sil ON ss.id = sil.indent_id LEFT JOIN sys_indent_logistics sil ON ss.id = sil.indent_id
LEFT JOIN sys_logistics sl ON sil.logistics_unicode = sl.unicode LEFT JOIN sys_logistics sl ON sil.logistics_unicode = sl.unicode
...@@ -361,4 +381,13 @@ ...@@ -361,4 +381,13 @@
from sys_secondment from sys_secondment
where id = #{id} where id = #{id}
</select> </select>
<select id="getSecondmentByDeviceNo" resultMap="getSecondmentByDeviceNoResultMap">
select a.*,b.device_no as deviceNo
from sys_secondment a
left join sys_secondment_import_device b on a.secondment_no = b.secondment_no
where a.is_canceled = 0
and a.secondment_status != 40
and b.device_no = #{deviceNo}
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -21,4 +21,26 @@ ...@@ -21,4 +21,26 @@
sys_service_mechanic sys_service_mechanic
where service_id = #{serviceId} where service_id = #{serviceId}
</select> </select>
<select id="listAll" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from
sys_service_mechanic
</select>
<select id="getServiceIdAndMechanicIdByServiceName" resultType="java.lang.Integer">
select mechanic_id
from sys_service_mechanic
where service_id in (select user_id
from sys_manager
where provider_name like concat('%',#{serviceName},'%'))
union
select service_id
from sys_service_mechanic
where service_id in (select user_id
from sys_manager
where provider_name like concat('%',#{serviceName},'%'))
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!