Commit c7dc6680 by yangll

合并1.60.0分支到主干

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@35443 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 48023f41
Showing 71 changed files with 2764 additions and 485 deletions
......@@ -68,6 +68,11 @@
<version>1.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.9.3</version>
......@@ -78,6 +83,7 @@
<artifactId>ore-jms</artifactId>
<version>2.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
......
......@@ -9,6 +9,7 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
......@@ -27,6 +28,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@EnableFeignClients(basePackages = {"com.glsx.common.feign.client"})
@MapperScan(basePackages={"com.glsx.ordercenter.mapper"})
@EnableScheduling
public class Application extends SpringBootServletInitializer {
/**
......
package com.glsx.ordercenter.common;
import java.lang.annotation.*;
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface PermissionControl {
/**
* 要关联的表名
* @return String
*/
String tableName() default "" ;
/**
* 表的别名
* @return String
*/
String tableAlias() default "";
/**
* 关联的字段名
* @return String
*/
String columnName() default "id";
/**
* 权限控制条件字段参数名称
* @return String
*/
String fieldName() default "id";
/**
* 参数的下标,从2开始,一般的分页查询查询条件都是从第二个开始的(多个参数时使用)
* @return int
*/
int paramIndex() default 2;
}
......@@ -115,6 +115,7 @@ public enum ResultCodeEnum {
DEVICE_NOT_STOCK_IN_EDUN(5009, "未在虎哥e盾入库"),
DEVICE_NOT_REPLACED(5010, "更换或者重新安装设备,设备号与故障设备号不能相同"),
DEVICE_GPS_VERIFY_FAIL(5011, "设备GPS定位验证失败"),
DEVICE_OWNERSHIP_FAIL(5012, "部分设备归属修改失败"),
/**
* 订货单相关
......@@ -129,6 +130,13 @@ public enum ResultCodeEnum {
INDENT_NOT_MATCH(5107, "不是当前用户的订货单,不能确认收货"),
INDENT_LOGISTICS_NOT_EXIST(5108, "订货单物流信息不存在"),
INDENT_CAN_NOT_CANCEL(5109, "订货单已发货,不允许取消"),
INDENT_DEVICE_NOT_EXIST(5110, "订货单导入的设备为空"),
DEVICE_NOT_EXIST(5111, "设备不存在"),
SECONDMENT_NOT_EXIST(5112, "借调单不存在"),
INDENT_DEVICE_ERROR_EXIST(5113, "收货失败,请联系运营人员"),
/**
* 库存相关
*/
......@@ -148,6 +156,11 @@ public enum ResultCodeEnum {
RECONCILIATION_AUDIT(5401, "有对账详单被运营审核,不支持重新生成"),
/**
* 借调单相关
*/
SECONDMENT_DEVICE_NOT_EXIST(5500, "借调单导入的设备为空"),
/**
* 大搜车相关
*/
SOUCHE_SIGN_ERROR(1, "签名错误"),
......
package com.glsx.ordercenter.constants;
public enum SecondmentStatusEnum {
SECONDMENT_UNCHECKED(10, "待审核"),
SECONDMENT_WAITDELIVER(20, "待发货"),
SECONDMENT_DELIVERED(30, "待收货"),
SECONDMENT_COMPLETE(40, "已完成"),
SECONDMENT_CANCEL(50, "已取消"),
;
/**
* 借调单状态
*/
private int secondmentStatus;
/**
* 状态对应的信息
*/
private String msg;
private SecondmentStatusEnum(int secondmentStatus, String msg) {
this.secondmentStatus = secondmentStatus;
this.msg = msg;
}
public int getSecondmentStatus() {
return secondmentStatus;
}
public void setSecondmentStatus(int secondmentStatus) {
this.secondmentStatus = secondmentStatus;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
......@@ -70,8 +70,28 @@ public class DeviceController {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
/**
* 订货单批量添加设备以及相关验证
*/
@RequestMapping(value = "/indentNoBatchInsertDevice", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject indentNoBatchInsertDevice(HttpServletRequest request,String indentNo) {
if (StringUtils.isEmpty(indentNo)) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
return deviceService.indentNoBatchInsertDevice(indentNo,request);
}
/**
* 订货单批量添加设备以及相关验证
*/
@RequestMapping(value = "/secondmentBatchInsertDevice", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject secondmentBatchInsertDevice(HttpServletRequest request,String secondmentNo) {
if (StringUtils.isEmpty(secondmentNo)) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
int userId=UserUtils.getUserId(request);
return deviceService.secondmentBatchInsertDevice(secondmentNo,userId);
}
}
package com.glsx.ordercenter.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.glsx.common.utils.PropertiesUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -142,7 +144,42 @@ public class DeviceRepertoryController {
page.setTotalCount((int) pages.getTotal());
result.put("page", page);
result.put("items", list);
result.put("deviceNumWarn", checkRepertoryStockNum((list.size())));
int count = 0;
int stockDayWarn = Integer.parseInt(PropertiesUtil.getProperty("repertory.stock.day.warn"));
Date now = new Date();
for (SysDevice device : list) {
long subTime = (now.getTime() - device.getStockTime().getTime())/(24 * 60 * 60 * 1000);
if (subTime > stockDayWarn) {
count++;
}
}
result.put("deviceDayWarn", checkRepertoryStockDayNum(count));
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
/*
检查服务商库存/下属技工库存是否小于阈值,小于则提醒
*/
public String checkRepertoryStockNum(Integer deviceNum) {
if (deviceNum == null) {
deviceNum = 0;
}
int stockNumWarn = Integer.parseInt(PropertiesUtil.getProperty("repertory.stock.num.warn"));
if (deviceNum < stockNumWarn) {
return "库存<" + stockNumWarn;
}
return null;
}
/*
检查服务商库存/下属技工库存入库时间是否大于阈值,大于则提醒
*/
public String checkRepertoryStockDayNum(Integer deviceNum) {
if (deviceNum <= 0) {
return null;
}
int stockDayWarn = Integer.parseInt(PropertiesUtil.getProperty("repertory.stock.day.warn"));
return "库龄>" + stockDayWarn + "天:" + deviceNum + "台";
}
}
......@@ -8,15 +8,15 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.groups.Default;
import com.glsx.ordercenter.dto.IndentImportDeviceReq;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.annotation.AuthCheck;
......@@ -31,6 +31,7 @@ import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.pojo.SysIndentLog;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
import com.glsx.ordercenter.service.IndentService;
import org.springframework.web.multipart.MultipartFile;
/**
*
......@@ -108,6 +109,9 @@ public class IndentController extends BaseController{
Map<String, String> errorMap = getErrors(bindingResult);
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg(), errorMap);
}
if (indent.getIndentType() != null && indent.getIndentType() == 2 && CollectionUtils.isEmpty(indent.getDeviceNoList())) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
ResultObject result = indentService.add(request, indent);
return result;
}
......@@ -183,6 +187,7 @@ public class IndentController extends BaseController{
* @param indentId
* @return
*/
@AuthCheck
@RequestMapping(value = "/listIndentLog", method = RequestMethod.GET)
public ResultObject listIndentLog(String indentId) {
List<SysIndentLog> list=indentService.listIndentLog(indentId);
......@@ -329,7 +334,60 @@ public class IndentController extends BaseController{
if (id == null) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
ResultObject result = indentService.confirmReceipt(request, id);
ResultObject result = indentService.confirmReceipt(request, id, null);
return result;
}
/**
*
* @author zhangzc
* @Title: getImportDeviceDetail
* @Description: 订货单批量导入设备详情列表(PC)
* @param request
* @param indentId 订货单id
* @param deviceNo 设备号
* @return
* ResultObject
*
*/
@AuthCheck
@RequestMapping(value = "/getImportDeviceDetail", method = RequestMethod.GET)
public ResultObject getImportDeviceDetail(HttpServletRequest request, @RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize, Integer indentId, String deviceNo) {
Map<String, Object> result = new HashMap<String, Object>();
Page page = new Page(pageIndex, pageSize);
List<IndentImportDeviceReq> list = indentService.getImportDeviceDetail(page, indentId, deviceNo);
com.github.pagehelper.Page<IndentImportDeviceReq> pages = (com.github.pagehelper.Page<IndentImportDeviceReq>) list;
page.setTotalCount((int) pages.getTotal());
result.put("page", page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
/**
*
* @author zhangzc
* @Title: getImportDeviceDetail
* @Description: 删除批量导入的订货单设备(PC)
* @param id 订货单设备id
* @return
* ResultObject
*
*/
@AuthCheck
@RequestMapping(value = "/deleteImportDevice", method = RequestMethod.GET)
public ResultObject deleteImportDevice(Integer id) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), indentService.deleteIndentImportDeviceById(id));
}
@AuthCheck
@RequestMapping(value = "/importDeviceExcel", method = RequestMethod.POST)
public ResultObject checkImportIndentDevice(@RequestParam("file") MultipartFile file) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), indentService.checkImportIndentDevice(file));
}
@InitBinder
public void initListBinder(WebDataBinder binder) {
// 设置需要包裹的元素个数,默认为256
binder.setAutoGrowCollectionLimit(5500);
}
}
......@@ -22,6 +22,7 @@ import com.glsx.ordercenter.dto.req.*;
import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.pojo.*;
import com.glsx.ordercenter.service.*;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
......@@ -1259,4 +1260,19 @@ public class OrderController extends BaseController {
logger.info("==== /getDeviceReuse result: {}", JSON.toJSONString(deviceReuseFlag));
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), deviceReuseFlag);
}
/**
* 工单完成时校验车架号和设备号
*/
@RequestMapping(value = "/checkVinAndSn", method = {RequestMethod.POST, RequestMethod.GET})
public R checkVinAndSn(Integer orderId, Integer serviceItemId) {
super.logInfo("==== /order/checkVinAndSn param:orderId:{};serviceItemId:{}", orderId, serviceItemId);
Map<String, Object> resultMap = orderService.checkVinAndSn(orderId,serviceItemId);
R result = R.ok().data(resultMap);
super.logInfo("==== /order/checkVinAndSn result", result);
return result;
}
}
......@@ -20,33 +20,13 @@ import com.glsx.common.utils.StringUtils;
import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.constants.*;
import com.glsx.ordercenter.dto.*;
import com.glsx.ordercenter.dto.req.AuditOrderQueryReq;
import com.glsx.ordercenter.dto.req.CarOrderQueryReq;
import com.glsx.ordercenter.dto.req.DeliveryQueryReq;
import com.glsx.ordercenter.dto.req.InsuranceReq;
import com.glsx.ordercenter.dto.req.OrderReportReq;
import com.glsx.ordercenter.dto.req.ReconciliationListQuery;
import com.glsx.ordercenter.dto.req.*;
import com.glsx.ordercenter.dto.resp.ExportReconciliationVo;
import com.glsx.ordercenter.dto.resp.InsuranceResp;
import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.exception.SysException;
import com.glsx.ordercenter.pojo.*;
import com.glsx.ordercenter.service.AuditOrderService;
import com.glsx.ordercenter.service.CarOrderService;
import com.glsx.ordercenter.service.DeliveryService;
import com.glsx.ordercenter.service.DeviceRepertoryService;
import com.glsx.ordercenter.service.IAreaService;
import com.glsx.ordercenter.service.IDictionaryDataService;
import com.glsx.ordercenter.service.IOrderBiddingService;
import com.glsx.ordercenter.service.IOrderExceptionService;
import com.glsx.ordercenter.service.IOrderService;
import com.glsx.ordercenter.service.IUnknownOrderService;
import com.glsx.ordercenter.service.IndentService;
import com.glsx.ordercenter.service.InsuranceService;
import com.glsx.ordercenter.service.OperationAdvanceService;
import com.glsx.ordercenter.service.OrderReportService;
import com.glsx.ordercenter.service.ReconciliationDetailService;
import com.glsx.ordercenter.service.ReconciliationService;
import com.glsx.ordercenter.service.*;
import com.glsx.ordercenter.utils.OrderUtil;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
......@@ -113,6 +93,9 @@ public class ReportController extends BaseReportController {
@Autowired
private OrderUtil orderUtil;
@Autowired
private SysSecondmentService secondmentService;
@RequestMapping(value = "/exportUnknownOrder", method = {RequestMethod.GET, RequestMethod.POST})
public void exportUnknownOrder(HttpServletRequest request, HttpServletResponse response,
SysOrder order) {
......@@ -408,6 +391,41 @@ public class ReportController extends BaseReportController {
}
}
@RequestMapping(value = "/exportServiceRepertoryDetail", method = {RequestMethod.GET, RequestMethod.POST})
public void exportServiceRepertoryDetail(HttpServletRequest request, HttpServletResponse response,
String deviceType, String deviceNo, Integer userId) {
List<SysDevice> list = deviceRepertoryService.getServiceRepertoryDetail(userId, deviceType, deviceNo);
if (list.size() > 10000) {
throw SysException.create(ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getCode(),
ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getMsg());
}
try {
this.exportObject(response, list, "导出服务商库存详情");
} catch (IOException e) {
this.logger.info("导出服务商库存详情异常");
}
}
@RequestMapping(value = "/exportMechanicRepertoryDetail", method = {RequestMethod.GET, RequestMethod.POST})
public void exportMechanicRepertoryDetail(HttpServletRequest request, HttpServletResponse response,
String deviceType, String deviceNo, Integer serviceId, Integer mechanicId) {
List<SysDevice> list = deviceRepertoryService.getMechanicRepertoryDetail(serviceId, deviceType, deviceNo, mechanicId);
if (list.size() > 10000) {
throw SysException.create(ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getCode(),
ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getMsg());
}
List<MechanicRepertoryDeviceExport> exportList = new ArrayList<>();
for (SysDevice device : list) {
MechanicRepertoryDeviceExport export = new MechanicRepertoryDeviceExport();
BeanUtils.copyProperties(device, export);
exportList.add(export);
}
try {
this.exportObject(response, exportList, "导出下属技工库存详情");
} catch (IOException e) {
this.logger.info("导出下属技工库存详情异常");
}
}
@RequestMapping(value = "/exportIndent", method = {RequestMethod.GET, RequestMethod.POST})
public void exporRepertoryList(HttpServletRequest request, HttpServletResponse response,
......@@ -422,6 +440,7 @@ public class ReportController extends BaseReportController {
IndentExport indentExport = new IndentExport();
BeanUtils.copyProperties(sysIndent, indentExport);
indentExport.setIndentStatus(this.tranceIndentStatu(sysIndent.getIndentStatus()));
indentExport.setUsername(this.tranceIndentUsername(sysIndent));
exports.add(indentExport);
}
try {
......@@ -432,6 +451,39 @@ public class ReportController extends BaseReportController {
}
@RequestMapping(value = "/exportSecondment", method = {RequestMethod.GET, RequestMethod.POST})
public void exportSecondmentList(HttpServletRequest request, HttpServletResponse response,
SecondmentQueryReq req) {
List<SecondmentExport> exports = new ArrayList<>();
Integer secondmentStatus = req.getSecondmentStatus();
/**
* 50定义为取消
*/
if (secondmentStatus != null && 50 == secondmentStatus) {
req.setIsCanceled(1);
req.setSecondmentStatus(null);
} else if (secondmentStatus != null) {
req.setIsCanceled(0);
}
List<SecondmentDto> list = this.secondmentService.getListByPage(null, req);
if (list.size() > 10000) {
throw SysException.create(ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getCode(),
ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getMsg());
}
for (SecondmentDto dto : list) {
SecondmentExport secondmentExport = new SecondmentExport();
BeanUtils.copyProperties(dto, secondmentExport);
secondmentExport.setSecondmentStatus(tranceIndentStatu(dto.getSecondmentStatus()));
secondmentExport.setUsername(tranceSecondmentUsername(dto));
exports.add(secondmentExport);
}
try {
this.exportObject(response, exports, "导出借调单列表");
} catch (IOException e) {
this.logger.info("导出借调单列表异常");
}
}
private String tranceIndentStatu(Integer indentStatu) {
if (indentStatu == 10) {
return "待审核订单";
......@@ -451,6 +503,29 @@ public class ReportController extends BaseReportController {
return "";
}
private String tranceIndentUsername(SysIndent indent) {
if (indent.getUser() != null) {
if (indent.getUser().getUserType() == BizConstants.USER_TYPE_MECHANIC) {
return indent.getUser().getName();
} else {
return indent.getUsername();
}
}
return "";
}
private String tranceSecondmentUsername(SecondmentDto secondmentDto) {
if (secondmentDto != null) {
if (secondmentDto.getUserType() == BizConstants.USER_TYPE_MECHANIC) {
return secondmentDto.getName();
} else {
return secondmentDto.getUsername();
}
}
return "";
}
@Autowired
private IOrderBiddingService biddingOrderService;
......
package com.glsx.ordercenter.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.glsx.common.annotation.AuthCheck;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.feign.client.CommonClient;
import com.glsx.common.feign.client.UserClient;
import com.glsx.common.utils.Page;
import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.SecondmentDto;
import com.glsx.ordercenter.dto.req.InsertSecondmentReq;
import com.glsx.ordercenter.dto.req.SecondmentImportDeviceReq;
import com.glsx.ordercenter.dto.req.SecondmentQueryReq;
import com.glsx.ordercenter.dto.req.UpdateSecondmentReq;
import com.glsx.ordercenter.pojo.*;
import com.glsx.ordercenter.service.SysSecondmentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value="/secondment")
public class SysSecondmentController extends BaseController{
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private SysSecondmentService secondmentService;
@Autowired
private CommonClient commonClient;
@Autowired
private UserClient userClient;
@AuthCheck
@RequestMapping(value="/getListByPage", method=RequestMethod.GET)
public ResultObject getListByPage(@RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize, SecondmentQueryReq req) {
Map<String, Object> result = new HashMap<String, Object>();
if (req != null) {
logger.info("借调单列表搜索传递的参数:" + JSONObject.toJSONString(req));
}
Integer secondmentStatus = req.getSecondmentStatus();
/**
* 50定义为取消
*/
if (secondmentStatus != null && 50 == secondmentStatus) {
req.setIsCanceled(1);
req.setSecondmentStatus(null);
} else if (secondmentStatus != null) {
req.setIsCanceled(0);
}
Page page = new Page(pageIndex, pageSize);
if (req.getPageSize() != null) {
page = new Page(req.getPageIndex(), req.getPageSize());
}
List<SecondmentDto> list = secondmentService.getListByPage(page, req);
com.github.pagehelper.Page<SecondmentDto> pages = (com.github.pagehelper.Page<SecondmentDto>) list;
page.setTotalCount((int) pages.getTotal());
result.put("page", page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
@AuthCheck
@RequestMapping(value="/getDetail", method=RequestMethod.GET)
public ResultObject getDetail(Integer id) {
SecondmentDto secondmentDto = secondmentService.getDetail(id);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), secondmentDto);
}
@AuthCheck
@RequestMapping(value="/getDeviceBySecondmentNo", method=RequestMethod.GET)
public ResultObject getDeviceBySecondmentNo(Page page,SysSecondmentImportDevice secondmentImportDevice) {
Map<String, Object> result = new HashMap<String, Object>(16);
PageHelper.startPage(page.getPageIndex(), page.getPageSize(), true);
List<SysSecondmentImportDevice> list = secondmentService.getDeviceBySecondmentNo(secondmentImportDevice);
com.github.pagehelper.Page<SysSecondmentImportDevice> pages = (com.github.pagehelper.Page<SysSecondmentImportDevice>) list;
page.setTotalCount((int) pages.getTotal());
result.put("page", page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
@AuthCheck
@RequestMapping(value="/getListByUserId", method=RequestMethod.GET)
public ResultObject getListByUserId(@RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize, SecondmentQueryReq req) {
Map<String, Object> result = new HashMap<String, Object>();
if (req != null) {
logger.info("小程序端借调单列表搜索传递的参数:" + JSONObject.toJSONString(req));
}
Integer secondmentStatus = req.getSecondmentStatus();
/**
* 50定义为取消
*/
if (secondmentStatus != null && 50 == secondmentStatus) {
req.setIsCanceled(1);
req.setSecondmentStatus(null);
} else if (secondmentStatus != null) {
req.setIsCanceled(0);
}
Page page = new Page(pageIndex, pageSize);
if (req.getPageSize() != null) {
page = new Page(req.getPageIndex(), req.getPageSize());
}
List<SecondmentDto> list = secondmentService.getListByUserId(page, req);
com.github.pagehelper.Page<SecondmentDto> pages = (com.github.pagehelper.Page<SecondmentDto>) list;
page.setTotalCount((int) pages.getTotal());
result.put("page", page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
@AuthCheck
@RequestMapping(value = "/importSecondmentDevice", method = RequestMethod.POST)
public ResultObject checkImportSecondmentDevice(HttpServletRequest request, @Validated SecondmentImportDeviceReq importDeviceReq) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), secondmentService.checkImportSecondmentDevice(request, importDeviceReq));
}
@AuthCheck
@RequestMapping(value = "/addSecondment", method = RequestMethod.POST)
public ResultObject addSecondment(HttpServletRequest request, @Validated InsertSecondmentReq secondmentReq) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), secondmentService.addSecondment(request, secondmentReq));
}
@AuthCheck
@RequestMapping(value = "/updateSecondment", method = RequestMethod.POST)
public ResultObject updateSecondment(HttpServletRequest request, @Validated UpdateSecondmentReq secondmentReq) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), secondmentService.updateSecondment(request, secondmentReq));
}
@AuthCheck
@RequestMapping(value = "/deleteSecondmentDevice", method = RequestMethod.GET)
public ResultObject deleteSecondmentDevice(Integer id) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), secondmentService.deleteSecondmentDeviceById(id));
}
@AuthCheck
@RequestMapping(value = "/dispatchSecondment", method = RequestMethod.POST)
public ResultObject dispatchSecondment(HttpServletRequest request, SysIndentLogistics sysIndentLogistics) {
sysIndentLogistics.setOrderType(2);
Integer result = secondmentService.dispatchSecondment(request, sysIndentLogistics);
//发送短信提示已发货(发给提单的人)
if(result != null ){
SecondmentDto secondmentDto = secondmentService.getDetail(sysIndentLogistics.getIndentId());
JSONObject userObj = userClient.getUserById(secondmentDto.getSecondedId());
JSONObject data = userObj.getJSONObject("data");
String phone = data.getString("phoneNumber");
JSONObject obj = commonClient.sendDeviceSms(phone, secondmentDto.getSecondmentNo());
if (obj != null && obj.getIntValue("code") != com.glsx.common.constants.ResultCodeEnum.SUCCESS.getCode()) {
return new ResultObject(obj.getIntValue("code"), obj.getString("message"));
}
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
@AuthCheck
@RequestMapping(value = "/listSecondmentLog", method = RequestMethod.GET)
public ResultObject getSecondmentLogList(Integer secondmentId) {
List<SysSecondmentLog> list = secondmentService.getSecondmentLogList(secondmentId);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), list);
}
@InitBinder
public void initListBinder(WebDataBinder binder) {
// 设置需要包裹的元素个数,默认为256
binder.setAutoGrowCollectionLimit(5500);
}
}
......@@ -2,6 +2,7 @@ package com.glsx.ordercenter.dto;
import com.glsx.excel.poi.annotation.ExcelColumn;
import com.glsx.excel.poi.annotation.ExcelExport;
import lombok.Data;
/**
* @author duanht
......@@ -11,6 +12,7 @@ import com.glsx.excel.poi.annotation.ExcelExport;
* @Description $库存列表
* @date 2019/6/3 15:13
*/
@Data
@ExcelExport
public class DeviceRepertoryReq {
......@@ -39,67 +41,19 @@ public class DeviceRepertoryReq {
private String deviceType;
public String getUsername() {
return username;
}
// 服务商库存数量阈值警告
private String serviceDeviceNumWarn;
public void setUsername(String username) {
this.username = username;
}
// 服务商库存入库时间阈值警告
private String serviceDeviceDayWarn;
public String getDeviceType() {
return deviceType;
}
// 下属技工存数量阈值警告
private String mechanicDeviceNumWarn;
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
// 下属技工库存入库时间阈值警告
private String mechanicDeviceDayWarn;
public Integer getUserId() {
return userId;
}
private Integer userType;
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public Integer getServiceDeviceNum() {
return serviceDeviceNum;
}
public void setServiceDeviceNum(Integer serviceDeviceNum) {
this.serviceDeviceNum = serviceDeviceNum;
}
public Integer getSendDeviceNum() {
return sendDeviceNum;
}
public void setSendDeviceNum(Integer sendDeviceNum) {
this.sendDeviceNum = sendDeviceNum;
}
public Integer getMechanicDeviceNum() {
return mechanicDeviceNum;
}
public void setMechanicDeviceNum(Integer mechanicDeviceNum) {
this.mechanicDeviceNum = mechanicDeviceNum;
}
}
package com.glsx.ordercenter.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @title IndentImportDeviceDataExportModel
* @Author zhangzc
* @Description 订货单批量导入设备
* @Date 2024/4/10 15:15
**/
@Data
public class IndentImportDeviceDataExportModel implements Serializable {
private static final long serialVersionUID = -5449399709572310476L;
@ExcelProperty(value = "设备号")
private String deviceNo;
}
package com.glsx.ordercenter.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.glsx.excel.poi.annotation.ExcelExport;
import lombok.Data;
import java.io.Serializable;
/**
* @title IndentImportDeviceDataExportModelImport
* @Author zhangzc
* @Description 订货单批量导入设备错误信息
* @Date 2024/4/10 16:19
**/
@Data
@ExcelExport
public class IndentImportDeviceDataExportModelImport implements Serializable {
private static final long serialVersionUID = 4156527327982218042L;
@ExcelProperty(value = "错误内容")
private String deviceNo;
@ExcelProperty(value = "备注")
private String importFailReason;
}
package com.glsx.ordercenter.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @title IndentImportDeviceReq
* @Author zhangzc
* @Description 订货单批量导入设备详情
* @Date 2024/4/9 16:15
**/
@Data
public class IndentImportDeviceReq implements Serializable {
private static final long serialVersionUID = -2161602390043604984L;
@ApiModelProperty(notes = "id")
private Integer id;
@ApiModelProperty(notes = "设备类型")
private String deviceType;
@ApiModelProperty(notes = "设备类型名称")
private String deviceName;
@ApiModelProperty(notes = "设备号")
private String deviceNo;
@ApiModelProperty(notes = "导入时间")
private Date importTime;
}
package com.glsx.ordercenter.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @title IndentImportDeviceResponse
* @Author zhangzc
* @Description 订货单批量导入设备返回信息
* @Date 2024/4/10 15:08
**/
@Data
public class IndentImportDeviceResponse implements Serializable {
private static final long serialVersionUID = 5333124670903207609L;
@ApiModelProperty(notes = "匹配成功总条数")
private Integer successCount;
@ApiModelProperty(notes = "匹配失败总条数")
private Integer errorCount;
@ApiModelProperty(notes = "匹配失败的url")
private String errUrl;
@ApiModelProperty(notes = "设备号列表")
private List<String> deviceNoList;
}
package com.glsx.ordercenter.dto;
import com.glsx.excel.poi.annotation.ExcelColumn;
import com.glsx.excel.poi.annotation.ExcelExport;
import lombok.Data;
import java.util.Date;
/**
* @title MechanicRepertoryDeviceExport
* @Author zhangzc
* @Description 下属技工库存详情
* @Date 2024/4/3 16:49
**/
@ExcelExport
@Data
public class MechanicRepertoryDeviceExport {
@ExcelColumn(value = "服务商名称",index = 0)
private String serviceName;
@ExcelColumn(value = "所属技工",index = 1)
private String name;
@ExcelColumn(value = "设备名称",index = 2)
private String deviceName;
@ExcelColumn(value = "设备号",index = 3)
private String deviceNo;
@ExcelColumn(value = "入库时间", index = 4, pattern = "yyyy-MM-dd HH:mm:ss")
private Date stockTime;
@ExcelColumn(value = "备注",index = 5)
private String remark;
}
package com.glsx.ordercenter.dto;
import lombok.Data;
import java.io.Serializable;
/**
......@@ -10,6 +12,7 @@ import java.io.Serializable;
* @Description $技工库存
* @date 2019/6/5 10:25
*/
@Data
public class MechanicRepertoryReq implements Serializable {
/**
......@@ -25,35 +28,10 @@ public class MechanicRepertoryReq implements Serializable {
private Integer deviceNum;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
// 技工存数量阈值警告
private String deviceNumWarn;
public Integer getDeviceNum() {
return deviceNum;
}
// 技工库存入库时间阈值警告
private String deviceDayWarn;
public void setDeviceNum(Integer deviceNum) {
this.deviceNum = deviceNum;
}
}
package com.glsx.ordercenter.dto;
import com.glsx.ordercenter.pojo.SysArea;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
import com.glsx.ordercenter.pojo.SysSecondment;
import com.glsx.ordercenter.pojo.SysSecondmentImportDevice;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class SecondmentDto extends SysSecondment {
private static final long serialVersionUID = 5960250385455923520L;
private String username;
private String deviceName;
private SysIndentLogistics sysIndentLogistics;
private SysArea sysArea;
/**
* 物流轨迹
*/
private Traces traces;
private String cancelOperatorName;
private String name;
private Integer userType;
@ApiModelProperty(notes = "借调单设备列表")
private List<SysSecondmentImportDevice> importDevices;
}
package com.glsx.ordercenter.dto;
import com.glsx.excel.poi.annotation.ExcelColumn;
import com.glsx.excel.poi.annotation.ExcelExport;
import lombok.Data;
import java.util.Date;
/**
* @title SecondmentExport
* @Author zhangzc
* @Description
* @Date 2024/4/11 15:45
**/
@Data
@ExcelExport
public class SecondmentExport {
@ExcelColumn(index = 0,value = "借调单号")
private String secondmentNo;
@ExcelColumn(index = 1,value = "借调时间",pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ExcelColumn(index = 2,value = "借调用户名称")
private String username;
@ExcelColumn(index = 3,value = "设备名称")
private String deviceName;
@ExcelColumn(index = 4,value = "数量")
private Integer secondmentAmount;
@ExcelColumn(index = 5,value = "借调单状态")
private String secondmentStatus;
}
package com.glsx.ordercenter.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.glsx.excel.poi.annotation.ExcelExport;
import lombok.Data;
import java.io.Serializable;
/**
* @title SecondmentImportDeviceDataExportModelImport
* @Author zhangzc
* @Description 借调单批量导入设备错误信息
* @Date 2024/4/15 15:08
**/
@Data
@ExcelExport
public class SecondmentImportDeviceDataExportModelImport implements Serializable {
private static final long serialVersionUID = -5809347814892878445L;
@ExcelProperty(value = "错误内容")
private String deviceNo;
@ExcelProperty(value = "备注")
private String importFailReason;
}
package com.glsx.ordercenter.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @title SecondmentImportDeviceResponse
* @Author zhangzc
* @Description 借调单批量导入设备返回信息
* @Date 2024/4/15 15:14
**/
@Data
public class SecondmentImportDeviceResponse implements Serializable {
private static final long serialVersionUID = -3734323326892100449L;
@ApiModelProperty(notes = "匹配成功总条数")
private Integer successCount;
@ApiModelProperty(notes = "匹配失败总条数")
private Integer errorCount;
@ApiModelProperty(notes = "匹配失败的url")
private String errUrl;
@ApiModelProperty(notes = "设备号列表")
private List<String> deviceNoList;
}
package com.glsx.ordercenter.dto.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @title InsertSecondmentReq
* @Author zhangzc
* @Description
* @Date 2024/4/15 20:11
**/
@Data
public class InsertSecondmentReq implements Serializable {
private static final long serialVersionUID = 7337327051887026997L;
@NotNull(message = "借调人id不能为空")
@ApiModelProperty(notes = "借调人id")
private Integer secondmentUserId;
@NotBlank(message = "设备类型不能为空")
@ApiModelProperty(notes = "设备类型")
private String deviceType;
@NotNull
@ApiModelProperty(notes = "设备号列表")
private List<String> deviceNoList;
@NotNull(message = "收货地址id不能为空")
@ApiModelProperty(notes = "收货地址id")
private Integer receiveAddressId;
@ApiModelProperty(notes = "备注")
private String remark;
}
package com.glsx.ordercenter.dto.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @title SecondmentImportDeviceReq
* @Author zhangzc
* @Description
* @Date 2024/4/15 15:17
**/
@Data
public class SecondmentImportDeviceReq implements Serializable {
private static final long serialVersionUID = -2378594680227605725L;
@NotNull(message = "导入类型不能为空")
@ApiModelProperty(notes = "导入类型: 1-手动录入;2-文件导入")
private Integer exportType;
@NotNull(message = "借调人id不能为空")
@ApiModelProperty(notes = "借调人id")
private Integer secondmentUserId;
@NotBlank(message = "设备类型不能为空")
@ApiModelProperty(notes = "设备类型")
private String deviceType;
@ApiModelProperty(notes = "文件(exportType=2必传)")
private MultipartFile file;
@ApiModelProperty(notes = "设备号列表(exportType=1必传)")
private List<String> deviceNoList;
}
package com.glsx.ordercenter.dto.req;
import com.glsx.common.pojo.PagedReq;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class SecondmentQueryReq extends PagedReq {
private static final long serialVersionUID = -6148990754937464349L;
/**
* 查询:开始时间
*/
private String beginDate;
/**
* 查询:结束时间
*/
private String endDate;
/**
* 订单状态10:待审核;20:待发货;30:待收货;40:已完成;
*/
private Integer secondmentStatus;
private Integer isCanceled;
private String username;
private Integer userId;
private String secondmentNo;
}
package com.glsx.ordercenter.dto.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @title UpdateSecondmentReq
* @Author zhangzc
* @Description
* @Date 2024/4/16 15:28
**/
@Data
public class UpdateSecondmentReq implements Serializable {
private static final long serialVersionUID = -3086503071645105621L;
@NotNull(message = "借调单id不能为空")
@ApiModelProperty(notes = "借调单id")
private Integer id;
@NotNull(message = "借调人id不能为空")
@ApiModelProperty(notes = "借调人id")
private Integer secondmentUserId;
@NotBlank(message = "设备类型不能为空")
@ApiModelProperty(notes = "设备类型")
private String deviceType;
@NotNull
@ApiModelProperty(notes = "设备号列表")
private List<String> deviceNoList;
@ApiModelProperty(notes = "收货地址id")
private Integer receiveAddressId;
@ApiModelProperty(notes = "备注")
private String remark;
}
package com.glsx.ordercenter.listener;
import com.glsx.ordercenter.interceptor.PermissionControlInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 此类为了控制mybatis Interceptor执行的顺序,Interceptor调用顺序为后加入的先执行
*/
@Slf4j
@Order
@Component
public class DataCommandLineRunner implements CommandLineRunner {
@Autowired
private List<SqlSessionFactory> sqlSessionFactoryList;
@Override
public void run(String... args) throws Exception {
log.info("CommandLineRunner DataPermissionInterceptor init...");
//先加的后执行
for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
sqlSessionFactory.getConfiguration().addInterceptor(new PermissionControlInterceptor());
List<Interceptor> interceptorList = sqlSessionFactory.getConfiguration().getInterceptors();
interceptorList.forEach(interceptor -> {
log.info(interceptor.getClass().getSimpleName());
});
}
}
}
package com.glsx.ordercenter.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.util.ConverterUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.ordercenter.dto.IndentImportDeviceDataExportModel;
import com.glsx.ordercenter.dto.IndentImportDeviceDataExportModelImport;
import com.glsx.ordercenter.dto.IndentImportDeviceResponse;
import com.glsx.ordercenter.mapper.SysDeviceMapper;
import com.glsx.ordercenter.mapper.SysIndentImportDeviceMapper;
import com.glsx.ordercenter.utils.EasyExcelUtils;
import com.glsx.ordercenter.utils.FileUploadServerData;
import com.glsx.ordercenter.utils.FileUtils;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @title IndentImportDeviceDataListener
* @Author zhangzc
* @Description
* @Date 2024/4/10 15:15
**/
@Slf4j
@NoArgsConstructor
public class IndentImportDeviceDataListener extends AnalysisEventListener<IndentImportDeviceDataExportModel> {
IndentImportDeviceResponse importDeviceResponse = new IndentImportDeviceResponse();
public List<IndentImportDeviceDataExportModel> modelList = new ArrayList<>();
public List<IndentImportDeviceDataExportModelImport> errorList = new ArrayList<>();
List<String> deviceNoList = new ArrayList<>();
private Logger logger = LoggerFactory.getLogger(getClass());
HttpUtils httpUtils = new HttpUtils();
private SysIndentImportDeviceMapper importDeviceMapper;
private SysDeviceMapper sysDeviceMapper;
public IndentImportDeviceDataListener(SysIndentImportDeviceMapper importDeviceMapper, SysDeviceMapper sysDeviceMapper) {
this.importDeviceMapper = importDeviceMapper;
this.sysDeviceMapper = sysDeviceMapper;
}
@Override
public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
Map<Integer, String> headerMap = ConverterUtils.convertToStringMap(headMap, context);
if (headerMap.isEmpty()) {
throw new RuntimeException("导入的excel表头错误,请检查后重试!");
}
String deviceNo = headerMap.get(0);
if (!"设备号".equals(deviceNo)) {
throw new RuntimeException("导入文件与指定模板不匹配,请检查后重试!");
}
super.invokeHead(headMap, context);
}
@Override
public void invoke(IndentImportDeviceDataExportModel indentImportDeviceDataExportModel, AnalysisContext analysisContext) {
IndentImportDeviceDataExportModelImport error = new IndentImportDeviceDataExportModelImport();
if (indentImportDeviceDataExportModel == null) {
error.setImportFailReason("设备号为空");
errorList.add(error);
return;
}
String deviceNo = indentImportDeviceDataExportModel.getDeviceNo();
error.setDeviceNo(deviceNo);
if (StringUtils.isEmpty(deviceNo)) {
error.setImportFailReason("设备号为空");
errorList.add(error);
return;
}
if (deviceNoList.contains(deviceNo)) {
error.setImportFailReason("设备号重复");
errorList.add(error);
return;
}
String deviceUrl = PropertiesUtil.getProperty("bhg.device.verify.sn") + deviceNo;
String result = null;
try {
result = httpUtils.get(deviceUrl, null, 60);
logger.info("设备No:{}获取设备验证信息响应数据:{}", deviceNo, result);
JSONObject jsonObject = JSON.parseObject(result);
if (!returnMessageHandler(jsonObject)) {
error.setImportFailReason("设备未入库");
errorList.add(error);
return;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
if (importDeviceMapper.countImportDeviceByDeviceNo(deviceNo) > 0) {
error.setImportFailReason("设备已归属");
errorList.add(error);
return;
}
if (sysDeviceMapper.countDeviceByDeviceNo(deviceNo) > 0) {
error.setImportFailReason("设备已归属");
errorList.add(error);
return;
}
modelList.add(indentImportDeviceDataExportModel);
deviceNoList.add(indentImportDeviceDataExportModel.getDeviceNo());
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
importDeviceResponse.setSuccessCount(modelList.size());
importDeviceResponse.setErrorCount(errorList.size());
importDeviceResponse.setDeviceNoList(deviceNoList);
importDeviceResponse.setErrUrl(buildFailFile("批量导出设备错误列表", errorList));
}
public String buildFailFile(String filename, List<IndentImportDeviceDataExportModelImport> errorList) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
EasyExcelUtils.writeExcel(outputStream, errorList, filename, IndentImportDeviceDataExportModelImport.class);
byte[] bytes = outputStream.toByteArray();
FileUploadServerData fileUploadServerData = FileUtils.uploadToFileSystem(filename, bytes, "xlsx");
return fileUploadServerData.getSecureUrl();
}
public IndentImportDeviceResponse getImportDeviceResponse() {
return importDeviceResponse;
}
private Boolean returnMessageHandler(JSONObject jsonObject) {
if (!"0".equals(jsonObject.getString("returnCode"))) {
return false;
}
JSONObject data = jsonObject.getJSONObject("data");
return data != null;
}
}
package com.glsx.ordercenter.listener;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.ApplicationContextEvent;
public class SqlSessionEvent extends ApplicationContextEvent {
/**
* Create a new ContextStartedEvent.
*
* @param source the {@code ApplicationContext} that the event is raised for
* (must not be {@code null})
*/
public SqlSessionEvent(ApplicationContext source) {
super(source);
}
}
package com.glsx.ordercenter.listener;
import com.glsx.ordercenter.interceptor.PermissionControlInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import java.util.List;
@Slf4j
//@Component
public class SqlSessionListener implements ApplicationListener<SqlSessionEvent> {
@Autowired
private List<SqlSessionFactory> sqlSessionFactoryList;
@Override
public void onApplicationEvent(SqlSessionEvent event) {
log.info("SqlSessionListener DataPermissionInterceptor init...");
//先加的后执行
for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
sqlSessionFactory.getConfiguration().addInterceptor(new PermissionControlInterceptor());
}
}
}
......@@ -51,4 +51,14 @@ public interface SysDeviceMapper {
int updateDevicesByIndentNo(String indentNo);
List<SysDevice> getByIndentNo(String indentNo);
int countDeviceByDeviceNo(@Param("deviceNo")String deviceNo);
int updateUserByDeviceNo(@Param("beSecondedId")Integer beSecondedId, @Param("secondedId") Integer secondedId, @Param("deviceNo")String deviceNo, @Param("updateBy")int updateBy);
SysDevice selectByDeviceNo(@Param("deviceNo")String deviceNo);
int updateUserByDeviceNoList(@Param("beSecondedId")Integer beSecondedId, @Param("secondedId") Integer secondedId, @Param("deviceNoList") List<String> deviceNoList, @Param("updateBy") int updateBy);
int countByIndentNo(String indentNo);
}
\ No newline at end of file
package com.glsx.ordercenter.mapper;
import com.glsx.ordercenter.common.PermissionControl;
import com.glsx.ordercenter.dto.DeviceRepertoryReq;
import com.glsx.ordercenter.dto.MechanicRepertoryReq;
import com.glsx.ordercenter.pojo.SysDevice;
......@@ -31,6 +32,7 @@ public interface SysDeviceRepertoryMapper {
int updateByPrimaryKey(SysDeviceRepertory record);
@PermissionControl(tableAlias = "sdr",columnName = "user_id")
List<DeviceRepertoryReq> getDeviceRepertoryList(Map<String, Object> params);
int updateSelective(SysDeviceRepertory deviceRepertory);
......@@ -42,4 +44,10 @@ public interface SysDeviceRepertoryMapper {
List<SysDevice> getRepertoryDetailByUserId(Map<String, Object> params);
List<MechanicRepertoryReq> getMechanicRepertoryList(Map<String, Object> params);
Integer countServiceRepertoryDetail(Map<String, Object> params);
Integer countMechanicRepertoryDetail(Map<String, Object> params);
Integer countMechanicRepertoryStock(Map<String, Object> params);
}
\ No newline at end of file
package com.glsx.ordercenter.mapper;
import com.glsx.ordercenter.dto.IndentImportDeviceReq;
import com.glsx.ordercenter.pojo.SysIndentImportDevice;
import com.glsx.ordercenter.pojo.SysOrderDeviceSupplier;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SysIndentImportDeviceMapper {
int insertBatchSelective(List<SysIndentImportDevice> list);
int deleteByPrimaryKey(Integer id);
List<IndentImportDeviceReq> selectImportDeviceList(@Param("indentId")Integer indentId, @Param("deviceNo")String deviceNo);
int countImportDeviceByDeviceNo(@Param("deviceNo")String deviceNo);
String selectIndentNoById(Integer id);
String selectDeviceNoById(Integer id);
List<String> getDeviceNoListByIndentNo(@Param("indentNo")String indentNo);
int deleteByIndentNo(@Param("indentNo")String indentNo);
}
\ No newline at end of file
......@@ -28,5 +28,5 @@ public interface SysIndentLogisticsMapper {
int updateByPrimaryKey(SysIndentLogistics record);
SysIndentLogistics getByIndentId(Integer indentId);
SysIndentLogistics getByIndentId(Integer indentId, Integer orderType);
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.glsx.ordercenter.mapper;
import java.util.List;
import com.glsx.ordercenter.common.PermissionControl;
import com.glsx.ordercenter.pojo.SysIndent;
import org.apache.ibatis.annotations.Param;
......@@ -34,6 +35,7 @@ public interface SysIndentMapper {
* List<SysIndent>
*
*/
@PermissionControl(tableAlias = "si",columnName = "user_id")
List<SysIndent> getIndentListByPage(SysIndent indent);
SysIndent getByIndentNo(String indentNo);
......@@ -96,4 +98,10 @@ public interface SysIndentMapper {
*
*/
List<SysIndent> getMechanicIndentListByPage(SysIndent indent);
List<Integer> selectUnReceivedIndentIds();
Integer updateIndentStatusByIds(List<Integer> ids);
SysIndent selectByIndentNo(String indentNo);
}
\ No newline at end of file
package com.glsx.ordercenter.mapper;
import com.glsx.ordercenter.pojo.SysSecondmentImportDevice;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SysSecondmentImportDeviceMapper {
List<SysSecondmentImportDevice> getDeviceBySecondmentNo(SysSecondmentImportDevice secondmentImportDevice);
List<SysSecondmentImportDevice> getListBySecondmentNo(@Param("secondmentNo") String secondmentNo);
String selectSecondmentNoById(Integer id);
String selectDeviceNoById(Integer id);
int deleteByPrimaryKey(Integer id);
int insertBatchSelective(List<SysSecondmentImportDevice> list);
int countImportDeviceByDeviceNo(@Param("deviceNo")String deviceNo);
int deleteBySecondmentNo(@Param("secondmentNo") String secondmentNo);
}
\ No newline at end of file
package com.glsx.ordercenter.mapper;
import com.glsx.ordercenter.pojo.SysSecondmentLog;
import java.util.List;
public interface SysSecondmentLogMapper {
int insertSelective(SysSecondmentLog secondmentLog);
SysSecondmentLog get(SysSecondmentLog secondmentLog);
List<SysSecondmentLog> selectSecondmentLogList(Integer secondmentId);
}
\ No newline at end of file
package com.glsx.ordercenter.mapper;
import com.glsx.ordercenter.common.PermissionControl;
import com.glsx.ordercenter.dto.SecondmentDto;
import com.glsx.ordercenter.dto.req.SecondmentQueryReq;
import com.glsx.ordercenter.pojo.SysSecondment;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SysSecondmentMapper {
List<Integer> selectUnReceivedSecondmentIds();
Integer updateSecondmentStatusByIds(List<Integer> ids);
@PermissionControl(tableAlias = "ss",columnName = "seconded_id")
List<SecondmentDto> getListByPage(SecondmentQueryReq req);
SecondmentDto getDetail(Integer id);
List<SecondmentDto> getListByUserId(SecondmentQueryReq req);
SysSecondment getBySecondmentNo(@Param("secondmentNo") String secondmentNo);
SysSecondment selectByPrimaryKey(Integer id);
void updateSecondmentStatusById(@Param("secondmentStatus")int secondmentStatus, @Param("userId")int userId, @Param("id")Integer id);
SysSecondment selectBySecondmentNo(String secondmentNo);
int insertSelective(SysSecondment record);
int countSecondment(String beginDate, String endDate);
int updateByPrimaryKeySelective(SysSecondment record);
String selectSecondmentNoById(Integer id);
}
\ No newline at end of file
package com.glsx.ordercenter.pojo;
import com.glsx.excel.poi.annotation.ExcelColumn;
import com.glsx.excel.poi.annotation.ExcelExport;
import lombok.Data;
import java.util.Date;
@Data
@ExcelExport
public class SysDevice {
private Integer id;
private String deviceType;
@ExcelColumn(value = "设备号",index = 3)
private String deviceNo;
private Integer deviceStatus;
@ExcelColumn(value = "用户ID",index = 0)
private Integer userId;
@ExcelColumn(value = "用户名称",index = 1)
private String userName;
private String loginName;
private String indentNo;
@ExcelColumn(value = "入库时间", index = 4, pattern = "yyyy-MM-dd HH:mm:ss")
private Date stockTime;
@ExcelColumn(value = "备注",index = 5)
private String remark;
private Date createTime;
......@@ -27,129 +42,13 @@ public class SysDevice {
private Integer updateBy;
@ExcelColumn(value = "设备名称",index = 2)
private String deviceName;
private String name;
private Integer deviceSource;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType == null ? null : deviceType.trim();
}
public String getDeviceNo() {
return deviceNo;
}
public void setDeviceNo(String deviceNo) {
this.deviceNo = deviceNo == null ? null : deviceNo.trim();
}
public Integer getDeviceStatus() {
return deviceStatus;
}
public void setDeviceStatus(Integer deviceStatus) {
this.deviceStatus = deviceStatus;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getIndentNo() {
return indentNo;
}
public void setIndentNo(String indentNo) {
this.indentNo = indentNo == null ? null : indentNo.trim();
}
public Date getStockTime() {
return stockTime;
}
public void setStockTime(Date stockTime) {
this.stockTime = stockTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getCreateBy() {
return createBy;
}
public void setCreateBy(Integer createBy) {
this.createBy = createBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getUpdateBy() {
return updateBy;
}
public void setUpdateBy(Integer updateBy) {
this.updateBy = updateBy;
}
public Integer getDeviceSource() {
return deviceSource;
}
private String serviceName;
public void setDeviceSource(Integer deviceSource) {
this.deviceSource = deviceSource;
}
}
\ No newline at end of file
......@@ -7,9 +7,22 @@ import javax.validation.groups.Default;
import com.glsx.ordercenter.dto.Traces;
import com.glsx.ordercenter.pojo.user.SysUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class SysIndent extends BaseModel implements Serializable {
private static final long serialVersionUID = 30305831970774368L;
public class SysIndent extends BaseModel{
@NotNull(message="{param.not.null}", groups={GroupA.class})
private Integer id;
......@@ -88,210 +101,14 @@ public class SysIndent extends BaseModel{
private SysUser user;
private String cancelOperatorName;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getIndentNo() {
return indentNo;
}
public void setIndentNo(String indentNo) {
this.indentNo = indentNo == null ? null : indentNo.trim();
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType == null ? null : deviceType.trim();
}
public Integer getDeviceAmount() {
return deviceAmount;
}
public void setDeviceAmount(Integer deviceAmount) {
this.deviceAmount = deviceAmount;
}
public Integer getIndentStatus() {
return indentStatus;
}
public void setIndentStatus(Integer indentStatus) {
this.indentStatus = indentStatus;
}
public Integer getIsCanceled() {
return isCanceled;
}
public void setIsCanceled(Integer isCanceled) {
this.isCanceled = isCanceled;
}
public Integer getDistrictCode() {
return districtCode;
}
public void setDistrictCode(Integer districtCode) {
this.districtCode = districtCode;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
public String getBeginDate() {
return beginDate;
}
public void setBeginDate(String beginDate) {
this.beginDate = beginDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getReceiverName() {
return receiverName;
}
public void setReceiverName(String receiverName) {
this.receiverName = receiverName;
}
public Integer getSendType() {
return sendType;
}
public void setSendType(Integer sendType) {
this.sendType = sendType;
}
public Integer getReceiveAddressId() {
return receiveAddressId;
}
public void setReceiveAddressId(Integer receiveAddressId) {
this.receiveAddressId = receiveAddressId;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public SysIndentLogistics getSysIndentLogistics() {
return sysIndentLogistics;
}
public void setSysIndentLogistics(SysIndentLogistics sysIndentLogistics) {
this.sysIndentLogistics = sysIndentLogistics;
}
public SysArea getSysArea() {
return sysArea;
}
public void setSysArea(SysArea sysArea) {
this.sysArea = sysArea;
}
public Integer getTerminalType() {
return terminalType;
}
public void setTerminalType(Integer terminalType) {
this.terminalType = terminalType;
}
public String getQueryContent() {
return queryContent;
}
public void setQueryContent(String queryContent) {
this.queryContent = queryContent;
}
public Traces getTraces() {
return traces;
}
public void setTraces(Traces traces) {
this.traces = traces;
}
public SysUser getUser() {
return user;
}
public void setUser(SysUser user) {
this.user = user;
}
public String getCancelOperatorName() {
return cancelOperatorName;
}
public void setCancelOperatorName(String cancelOperatorName) {
this.cancelOperatorName = cancelOperatorName;
}
/**
* 订货方式 1.新增 2.批量导入
*/
private Integer indentType;
@Override
public String toString() {
return "SysIndent [id=" + id + ", indentNo=" + indentNo + ", sendType="
+ sendType + ", userId=" + userId + ", username=" + username
+ ", deviceType=" + deviceType + ", deviceName=" + deviceName
+ ", deviceAmount=" + deviceAmount + ", indentStatus="
+ indentStatus + ", isCanceled=" + isCanceled
+ ", districtCode=" + districtCode + ", address=" + address
+ ", receiveAddressId=" + receiveAddressId + ", phone=" + phone
+ ", receiverName=" + receiverName + ", beginDate=" + beginDate
+ ", endDate=" + endDate + "]";
}
/**
* 设备号列表 (indentType =2 时使用)
*/
private List<String> deviceNoList;
}
\ No newline at end of file
package com.glsx.ordercenter.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
@Table(name = "sys_indent_import_device")
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class SysIndentImportDevice implements Serializable {
@Id
private Integer id;
/**
* 订货单号
*/
@Column(name = "indent_no")
private String indentNo;
/**
* 设备号
*/
@Column(name = "device_no")
private String deviceNo;
/**
* 批量导入时间
*/
@Column(name = "batch_import_time")
private Date batchImportTime;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 创建人
*/
@Column(name = "create_by")
private Integer createBy;
/**
* 更新时间
*/
@Column(name = "update_time")
private Date updateTime;
/**
* 更新人
*/
@Column(name = "update_by")
private Integer updateBy;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ public class SysIndentLogistics {
@NotNull(message="{param.not.null}", groups={Default.class})
private Integer indentId;
private Integer orderType;
private String logisticsNo;
private String logisticsUnicode;
......@@ -119,5 +120,12 @@ public class SysIndentLogistics {
public void setExpressCompany(String expressCompany) {
this.expressCompany = expressCompany;
}
public Integer getOrderType() {
return orderType;
}
public void setOrderType(Integer orderType) {
this.orderType = orderType;
}
}
\ No newline at end of file
package com.glsx.ordercenter.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
@Table(name = "sys_secondment")
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class SysSecondment implements Serializable {
/**
* id
*/
@Id
private Integer id;
/**
* 借调单号
*/
@Column(name = "secondment_no")
private String secondmentNo;
/**
* 发货方式(1:服务商发货;2:广联发货)
*/
@Column(name = "send_type")
private Byte sendType;
/**
* 借调人用户id
*/
@Column(name = "seconded_id")
private Integer secondedId;
/**
* 设备类型,从字典中获取,如有线GPS:sys_order_service_item_gps,无线GPS:sys_order_service_item_gps_wireless。。。
*/
@Column(name = "device_type")
private String deviceType;
/**
* 借调数量
*/
@Column(name = "secondment_amount")
private Integer secondmentAmount;
/**
* 订单状态10:待审核;20:待发货;30:待收货;40:已完成;
*/
@Column(name = "secondment_status")
private Integer secondmentStatus;
/**
* 0:未取消,1:已取消
*/
@Column(name = "is_canceled")
private Byte isCanceled;
/**
* 收货地址的电话
*/
private String phone;
/**
* 收货地址的姓名
*/
@Column(name = "receiver_name")
private String receiverName;
/**
* 收货地址区编码
*/
@Column(name = "district_code")
private Integer districtCode;
/**
* 收货详细地址
*/
private String address;
/**
* 备注
*/
private String remark;
/**
* 创建人
*/
@Column(name = "create_by")
private Integer createBy;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 更新人
*/
@Column(name = "update_by")
private Integer updateBy;
/**
* 更新时间
*/
@Column(name = "update_time")
private Date updateTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.glsx.ordercenter.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
@Table(name = "sys_secondment_import_device")
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class SysSecondmentImportDevice implements Serializable {
@Id
private Integer id;
/**
* 借调单号
*/
@Column(name = "secondment_no")
private String secondmentNo;
/**
* 设备号
*/
@Column(name = "device_no")
private String deviceNo;
/**
* 借调人id
*/
@Column(name = "seconded_id")
private Integer secondedId;
/**
* 被借调人id
*/
@Column(name = "be_seconded_id")
private Integer beSecondedId;
/**
* 批量导入时间
*/
@Column(name = "batch_import_time")
private Date batchImportTime;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 创建人
*/
@Column(name = "create_by")
private Integer createBy;
/**
* 更新时间
*/
@Column(name = "update_time")
private Date updateTime;
/**
* 更新人
*/
@Column(name = "update_by")
private Integer updateBy;
//借调人
private String username;
private String name;
private Integer userType;
//被借调人
private String beUsername;
private String beName;
private Integer beUserType;
//设备名称
private String deviceName;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.glsx.ordercenter.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
@Table(name = "sys_secondment_log")
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class SysSecondmentLog implements Serializable {
/**
* id
*/
@Id
private Integer id;
/**
* 借调单id
*/
@Column(name = "secondment_id")
private Integer secondmentId;
/**
* 订单状态10:待审核;20:待发货;30:待收货;40:已完成;50:已取消
*/
@Column(name = "secondment_status")
private Integer secondmentStatus;
/**
* 备注
*/
private String remark;
/**
* 创建人
*/
@Column(name = "create_by")
private Integer createBy;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
private String operatorName;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -5,6 +5,8 @@ import java.util.List;
import com.glsx.common.constants.ResultObject;
import com.glsx.ordercenter.pojo.SysDevice;
import javax.servlet.http.HttpServletRequest;
public interface DeviceService {
List<SysDevice> catIndentDevices(String indentNo);
......@@ -41,4 +43,14 @@ public interface DeviceService {
* @return
*/
int updateServiceDeviceStatu(String indentNo);
ResultObject indentNoBatchInsertDevice(String indentNo, HttpServletRequest request);
ResultObject secondmentBatchInsertDevice(String secondmentNo, int userId);
int updateUserByDeviceNo(Integer beSecondedId, Integer secondedId, String deviceNo, int updateBy);
SysDevice selectByDeviceNo(String deviceNo);
int updateUserByDeviceNoList(Integer beSecondedId, Integer secondedId, List<String> deviceNoList, int updateBy);
}
......@@ -403,4 +403,6 @@ public interface IOrderService {
void pushSxjOrderData(Byte pushType, Integer id, Integer status);
void syncDismantleOrder(Integer orderId);
Map<String, Object> checkVinAndSn(Integer orderId, Integer serviceItemId);
}
......@@ -17,6 +17,6 @@ public interface IndentLogisticsService {
int addOrUpdateIndentLogistics(HttpServletRequest request, SysIndentLogistics indentLogistics);
SysIndentLogistics getByIndentId(Integer indentId);
SysIndentLogistics getByIndentId(Integer indentId, Integer orderType);
}
......@@ -6,9 +6,12 @@ import javax.servlet.http.HttpServletRequest;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.dto.IndentImportDeviceReq;
import com.glsx.ordercenter.dto.IndentImportDeviceResponse;
import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.pojo.SysIndentLog;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
import org.springframework.web.multipart.MultipartFile;
/**
......@@ -155,7 +158,7 @@ public interface IndentService {
* ResultObject
*
*/
ResultObject confirmReceipt(HttpServletRequest request, Integer id);
ResultObject confirmReceipt(HttpServletRequest request, Integer id, Integer currentUserId);
/**
*
......@@ -171,4 +174,14 @@ public interface IndentService {
*/
List<SysIndent> getMechanicIndentListByPage(HttpServletRequest request,
Page page, SysIndent indent);
List<IndentImportDeviceReq> getImportDeviceDetail(Page page, Integer indentId, String deviceNo);
Boolean deleteIndentImportDeviceById(Integer id);
IndentImportDeviceResponse checkImportIndentDevice(MultipartFile file);
List<String> getDeviceNoList(String indentNo);
void addIndentDeviceLog(Integer id, Integer indentStatus, String remark, Integer createBy);
}
package com.glsx.ordercenter.service;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.dto.SecondmentDto;
import com.glsx.ordercenter.dto.SecondmentImportDeviceResponse;
import com.glsx.ordercenter.dto.req.InsertSecondmentReq;
import com.glsx.ordercenter.dto.req.SecondmentImportDeviceReq;
import com.glsx.ordercenter.dto.req.SecondmentQueryReq;
import com.glsx.ordercenter.dto.req.UpdateSecondmentReq;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
import com.glsx.ordercenter.pojo.SysSecondment;
import com.glsx.ordercenter.pojo.SysSecondmentImportDevice;
import com.glsx.ordercenter.pojo.SysSecondmentLog;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @title SysSecondmentService
* @Author zhangzc
* @Description
* @Date 2024/4/10 14:25
**/
public interface SysSecondmentService {
List<SecondmentDto> getListByPage(Page page, SecondmentQueryReq req);
SecondmentDto getDetail(Integer id);
List<SysSecondmentImportDevice> getDeviceBySecondmentNo(SysSecondmentImportDevice secondmentImportDevice);
List<SecondmentDto> getListByUserId(Page page, SecondmentQueryReq req);
ResultObject confirmReceipt(String secondmentNo, int userId);
SecondmentImportDeviceResponse checkImportSecondmentDevice(HttpServletRequest request, SecondmentImportDeviceReq importDeviceReq);
Boolean addSecondment(HttpServletRequest request, InsertSecondmentReq secondmentReq);
Boolean updateSecondment(HttpServletRequest request, UpdateSecondmentReq secondmentReq);
Boolean deleteSecondmentDeviceById(Integer id);
Integer dispatchSecondment(HttpServletRequest request, SysIndentLogistics sysIndentLogistics);
List<SysSecondmentLog> getSecondmentLogList(Integer secondmentId);
}
......@@ -5,7 +5,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.ordercenter.mapper.SysManagerMapper;
import com.glsx.ordercenter.pojo.user.SysManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.glsx.common.constants.ResultObject;
......@@ -36,6 +40,9 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
@Autowired
private SysIndentMapper sysIndentMapper;
@Autowired
private SysManagerMapper sysManagerMapper;
@Override
public List<DeviceRepertoryReq> getRepertoryList(Integer sortType, String username, String deviceType) {
Map<String, Object> params = new HashMap<>();
......@@ -47,6 +54,7 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
if (!deviceRepertoryReqs.isEmpty()) {
for (DeviceRepertoryReq deviceRepertoryReq : deviceRepertoryReqs) {
Integer stockDayWarn = Integer.valueOf(PropertiesUtil.getProperty("repertory.stock.day.warn"));
Integer userId = deviceRepertoryReq.getUserId();
//在途库存
Integer sendDeviceNum = 0;
......@@ -60,6 +68,7 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
int mechanicDeviceCount = 0;
Map<String, Object> param = new HashMap<>(16);
param.put("userId", userId);
param.put("deviceType", deviceRepertoryReq.getDeviceType());
List<MechanicRepertoryReq> mechanicRepertoryReqs = sysDeviceRepertoryMapper.getMechanicRepertoryList(param);
if(!mechanicRepertoryReqs.isEmpty()){
for(MechanicRepertoryReq mechanicRepertoryReq : mechanicRepertoryReqs){
......@@ -67,6 +76,20 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
}
}
deviceRepertoryReq.setMechanicDeviceNum(mechanicDeviceCount);
deviceRepertoryReq.setServiceDeviceNumWarn(checkRepertoryStockNum(deviceRepertoryReq.getServiceDeviceNum()));
Map<String, Object> countMap = new HashMap<>();
countMap.put("userId", userId);
countMap.put("day", stockDayWarn);
countMap.put("deviceType", deviceRepertoryReq.getDeviceType());
Integer count = sysDeviceRepertoryMapper.countServiceRepertoryDetail(countMap);
deviceRepertoryReq.setServiceDeviceDayWarn(checkRepertoryStockDayNum(count));
deviceRepertoryReq.setMechanicDeviceNumWarn(checkRepertoryStockNum((deviceRepertoryReq.getMechanicDeviceNum())));
countMap.clear();
countMap.put("serviceId", userId);
countMap.put("day", stockDayWarn);
countMap.put("deviceType", deviceRepertoryReq.getDeviceType());
count = sysDeviceRepertoryMapper.countMechanicRepertoryDetail(countMap);
deviceRepertoryReq.setMechanicDeviceDayWarn(checkRepertoryStockDayNum(count));
}
}
return deviceRepertoryReqs;
......@@ -92,6 +115,13 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
params.put("mechanicId", mechanicId);
List<SysDevice> sysDeviceList = sysDeviceRepertoryMapper.getMechanicRepertoryDetail(params);
SysManager manager = sysManagerMapper.selectByUserId(serviceId);
if (manager == null) {
return sysDeviceList;
}
for (SysDevice device : sysDeviceList) {
device.setServiceName(manager.getProviderName());
}
return sysDeviceList;
}
......@@ -116,6 +146,14 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
params.put("name", name);
params.put("userId", userId);
List<MechanicRepertoryReq> sysDeviceList = sysDeviceRepertoryMapper.getMechanicRepertoryList(params);
Map<String, Object> mechanicParams = new HashMap<>();
mechanicParams.put("day", Integer.parseInt(PropertiesUtil.getProperty("repertory.stock.day.warn")));
mechanicParams.put("deviceType", deviceType);
for (MechanicRepertoryReq repertoryReq : sysDeviceList) {
repertoryReq.setDeviceNumWarn(checkRepertoryStockNum(repertoryReq.getDeviceNum()));
mechanicParams.put("userId", repertoryReq.getId());
repertoryReq.setDeviceDayWarn(checkRepertoryStockDayNum(sysDeviceRepertoryMapper.countMechanicRepertoryStock(mechanicParams)));
}
return sysDeviceList;
}
......@@ -192,4 +230,31 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
}
return num;
}
/*
检查服务商库存/下属技工库存是否小于阈值,小于则提醒
*/
public String checkRepertoryStockNum(Integer deviceNum) {
if (deviceNum == null) {
deviceNum = 0;
}
int stockNumWarn = Integer.parseInt(PropertiesUtil.getProperty("repertory.stock.num.warn"));
if (deviceNum < stockNumWarn) {
return "库存<" + stockNumWarn;
}
return null;
}
/*
检查服务商库存/下属技工库存入库时间是否大于阈值,大于则提醒
*/
public String checkRepertoryStockDayNum(Integer deviceNum) {
if (deviceNum <= 0) {
return null;
}
int stockDayWarn = Integer.parseInt(PropertiesUtil.getProperty("repertory.stock.day.warn"));
return "库龄>" + stockDayWarn + "天:" + deviceNum + "台";
}
}
......@@ -6,7 +6,14 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.utils.StringUtils;
import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.service.SysSecondmentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -28,6 +35,9 @@ import com.glsx.ordercenter.pojo.SysDeviceExample;
import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.service.DeviceService;
import com.glsx.ordercenter.service.IndentService;
import javax.servlet.http.HttpServletRequest;
@Service
public class DeviceServiceImpl implements DeviceService{
......@@ -37,6 +47,9 @@ public class DeviceServiceImpl implements DeviceService{
@Autowired
private IndentService indentService;
@Autowired
private SysSecondmentService secondmentService;
@Override
public List<SysDevice> catIndentDevices(String indentNo) {
List<SysDevice> list=sysDeviceMapper.catIndentDevices(indentNo);
......@@ -45,6 +58,26 @@ public class DeviceServiceImpl implements DeviceService{
@Override
public void updateDeviceNo(Integer id, String deviceNo) {
if (StringUtils.isBlank(deviceNo)) {
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(), "设备号不能为空!");
}
SysDevice device = sysDeviceMapper.selectByDeviceNo(deviceNo);
if (device != null && device.getId().intValue() != id) {
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(), "设备已归属!");
}
String deviceUrl = PropertiesUtil.getProperty("bhg.device.verify.sn") + deviceNo;
String result = null;
HttpUtils httpUtils = new HttpUtils();
try {
result = httpUtils.get(deviceUrl, null, 60);
logger.info("设备No:{}获取设备验证信息响应数据:{}", deviceNo, result);
JSONObject jsonObject = JSON.parseObject(result);
if (!returnMessageHandler(jsonObject)) {
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(), "设备未入库!");
}
} catch (Exception e) {
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(), e.getMessage());
}
SysDevice sysDevice = new SysDevice();
sysDevice.setId(id);
sysDevice.setDeviceNo(deviceNo);
......@@ -101,18 +134,33 @@ public class DeviceServiceImpl implements DeviceService{
*/
String deviceType = sysIndent.getDeviceType();
if (BizConstants.SYS_ORDER_SERVICE_ITEM_GPS.equals(deviceType) || BizConstants.SYS_ORDER_SERVICE_ITEM_GPS_WIRELESS.equals(deviceType)
|| BizConstants.SYS_ORDER_SERVICE_ITEM_GPS_GT700F.equals(deviceType)) {
ResultObject result = checkDeviceTypeFromEdun(deviceType, deviceNoList, errorDevices);
if (result != null) {
return result;
}
|| BizConstants.SYS_ORDER_SERVICE_ITEM_GPS_GT700F.equals(deviceType)) {
//数据大于500 请求url参数过长 切割后再请求
int limit = 500;
if (deviceNos.size() > limit) {
List<List<String>> splitData = splitData(deviceNos,limit);
for (List<String> stringList : splitData) {
String dataStr = StringUtils.join(stringList, ",");
ResultObject result = checkDeviceTypeFromEdun(deviceType, dataStr, errorDevices);
if (result != null) {
return result;
}
}
} else {
ResultObject result = checkDeviceTypeFromEdun(deviceType, deviceNoList, errorDevices);
if (result != null) {
return result;
}
}
}
if (sysDeviceMapper.countByIndentNo(sysIndent.getIndentNo()) > 0) {
//1.清除用户的订货单设备
SysDevice device = new SysDevice();
device.setUserId(userId);
device.setIndentNo(sysIndent.getIndentNo());
sysDeviceMapper.deleteDevices(device);
}
//1.清除用户的订货单设备
SysDevice device=new SysDevice();
device.setUserId(userId);
device.setIndentNo(sysIndent.getIndentNo());
sysDeviceMapper.deleteDevices(device);
if (sysIndent.getSendType() == 2) {
for (int i = 0; i < deviceNos.size(); i++) {
......@@ -284,4 +332,96 @@ public class DeviceServiceImpl implements DeviceService{
List<SysDevice> list=sysDeviceMapper.getByIndentNo(indentNo);
return sysDeviceMapper.updates(list);
}
@Override
@Transactional
public ResultObject indentNoBatchInsertDevice(String indentNo, HttpServletRequest request) {
SysIndent indent = indentService.getByIndentNo(indentNo);
if (indent == null) {
return new ResultObject(ResultCodeEnum.INDENT_NOT_EXIST.getCode(), ResultCodeEnum.INDENT_NOT_EXIST.getMsg());
}
int userId= UserUtils.getUserId(request);
List<String> deviceNoList = indentService.getDeviceNoList(indentNo);
if (deviceNoList.isEmpty()){
return new ResultObject(ResultCodeEnum.INDENT_DEVICE_NOT_EXIST.getCode(), ResultCodeEnum.INDENT_DEVICE_NOT_EXIST.getMsg());
}
String deviceNoListStr = StringUtils.join(deviceNoList, ",");
ResultObject resultObject = checkAndInserts(deviceNoListStr, indentNo, userId);
if (resultObject.getCode() != ResultCodeEnum.SUCCESS.getCode()) {
String remark = "订货单收货失败:" + resultObject.getMessage();
indentService.addIndentDeviceLog(indent.getId(), null, remark, userId);
logger.error("订货单:" + indentNo + "收货失败原因===:" + resultObject.getMessage());
return resultObject;
}
if (resultObject.getData() != null) {
String remark = "收货失败,请联系运营人员";
indentService.addIndentDeviceLog(indent.getId(), null, remark, userId);
StringBuilder stb = new StringBuilder();
List<ErrorDevice> errorDeviceList = (List<ErrorDevice>) resultObject.getData();
for (ErrorDevice errorDevice : errorDeviceList) {
stb.append("设备号:").append(errorDevice.getDeviceNo()).append("--").append(errorDevice.getError());
stb.append("\n");
}
logger.error("订货单:" + indentNo + "收货失败原因===:" + stb);
return new ResultObject(ResultCodeEnum.INDENT_DEVICE_ERROR_EXIST.getCode(), ResultCodeEnum.INDENT_DEVICE_ERROR_EXIST.getMsg());
}
ResultObject object = indentService.confirmReceipt(request,indent.getId(),null);
if (object.getCode() != ResultCodeEnum.SUCCESS.getCode()) {
String remark = "订货单收货失败:" + object.getMessage();
indentService.addIndentDeviceLog(indent.getId(), null, remark, userId);
logger.error("订货单:" + indentNo + "收货失败原因===:" + object.getMessage());
return object;
}
return object;
}
private List<List<String>> splitData(List<String> deviceNoList, int limit) {
// 使用流来平均分割List
List<List<String>> chunkedLists = IntStream.range(0, deviceNoList.size())
.boxed() // 将int流转换为Integer流
.collect(Collectors.groupingBy(
i -> i / limit, // 分组函数,计算每个元素属于哪个子List
Collectors.mapping(deviceNoList::get, Collectors.toList()) // 收集器,将每个子List的元素收集起来
))
.values() // 获取分组后的值(即子List)
.stream() // 将值的集合转换为流
.collect(Collectors.toList()); // 收集最终的子List到新的List中
return chunkedLists;
}
@Override
@Transactional
public ResultObject secondmentBatchInsertDevice(String secondmentNo, int userId) {
//主要逻辑都在借调单service
return secondmentService.confirmReceipt(secondmentNo,userId);
}
@Override
@Transactional
public int updateUserByDeviceNo(Integer beSecondedId, Integer secondedId, String deviceNo, int updateBy) {
//更新设备归属人
return sysDeviceMapper.updateUserByDeviceNo(beSecondedId,secondedId,deviceNo,updateBy);
}
public SysDevice selectByDeviceNo(String deviceNo) {
return sysDeviceMapper.selectByDeviceNo(deviceNo);
}
@Override
@Transactional
public int updateUserByDeviceNoList(Integer beSecondedId, Integer secondedId, List<String> deviceNoList, int updateBy) {
//批量更新设备归属人
return sysDeviceMapper.updateUserByDeviceNoList(beSecondedId,secondedId,deviceNoList,updateBy);
}
private Boolean returnMessageHandler(JSONObject jsonObject) {
if (!"0".equals(jsonObject.getString("returnCode"))) {
return false;
}
JSONObject data = jsonObject.getJSONObject("data");
return data != null;
}
}
......@@ -32,7 +32,10 @@ public class IndentLogisticsServiceImpl implements IndentLogisticsService{
// TODO Auto-generated method stub
Integer userId = UserUtils.getUserId(request);
Integer indentId = indentLogistics.getIndentId();
SysIndentLogistics sysIndentLogistics = indentLogisticsDao.getByIndentId(indentId);
if (indentLogistics.getOrderType() == null) {
indentLogistics.setOrderType(1);
}
SysIndentLogistics sysIndentLogistics = indentLogisticsDao.getByIndentId(indentId, indentLogistics.getOrderType());
Date now = new Date();
int num = 0;
if (sysIndentLogistics == null) {
......@@ -50,8 +53,8 @@ public class IndentLogisticsServiceImpl implements IndentLogisticsService{
}
@Override
public SysIndentLogistics getByIndentId(Integer indentId) {
return indentLogisticsDao.getByIndentId(indentId);
public SysIndentLogistics getByIndentId(Integer indentId, Integer orderType) {
return indentLogisticsDao.getByIndentId(indentId, orderType);
}
}
......@@ -36,7 +36,7 @@ public class LogisticsServiceImpl implements LogisticsService{
@Override
public ResultObject catLogisticsTrail(Integer indentId) {
//查询订单物流详情
SysIndentLogistics sysIndentLogistics=indentLogisticsDao.getByIndentId(indentId);
SysIndentLogistics sysIndentLogistics=indentLogisticsDao.getByIndentId(indentId, 1);
if (org.springframework.util.StringUtils.isEmpty(sysIndentLogistics)) {
return new ResultObject(ResultCodeEnum.INDENT_NOT_EXIST.getCode(), ResultCodeEnum.INDENT_NOT_EXIST.getMsg());
}
......
......@@ -17,10 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
......@@ -44,20 +41,24 @@ public class OcrResultServiceImpl implements OcrResultService {
SysOrderOcrSnResult snResult = snResultList.get(0);
String[] split = snResult.getDbSn().split(",");
List<String> sns = Arrays.asList(split);
List<SysOrderOcrSnResult> resultList = snResultList.stream().filter(i -> StringUtils.isNotBlank(i.getOcrSn()) && sns.contains(i.getOcrSn())).collect(Collectors.toList());
//ocr识别出来的结果去重
Set<String> ocrSns = snResultList.stream().map(SysOrderOcrSnResult::getOcrSn).collect(Collectors.toSet());
if (sns.size() == ocrSns.size()) {
List<String> resultList = ocrSns.stream().filter(i -> StringUtils.isNotBlank(i) && sns.contains(i)).collect(Collectors.toList());
boolean a = sns.size() == resultList.size();
map.put("snResult", a);
} else {
map.put("snResult", false);
}
boolean a = sns.size() == resultList.size();
map.put("snResult", a);
}
List<SysOrderOcrVinResult> vinResultList = sysOrderOcrVinResultMapper.selectByOrderId(orderId);
if (CollectionUtils.isEmpty(vinResultList)) {
map.put("vinResult", null);
} else {
SysOrderOcrVinResult vinResult = vinResultList.get(0);
boolean b = vinResult.getDbVin().equals(vinResult.getOcrVin());
map.put("vinResult", b);
}
......@@ -84,5 +85,4 @@ public class OcrResultServiceImpl implements OcrResultService {
log.info("manualOcrRecognition ===>send Kafka info:" + jsonString);
}
}
......@@ -65,6 +65,7 @@ import java.util.concurrent.Executors;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author Zheng Xiajun
* @ClassName: OrderServiceImpl
......@@ -4310,6 +4311,9 @@ public class OrderServiceImpl implements IOrderService {
if (!verifyStockMap.isEmpty()) {
return new ResultObject(ResultCodeEnum.DEVICE_BELONG_USER.getCode(), ResultCodeEnum.DEVICE_BELONG_USER.getMsg());
}
//扣减库存
reduceStock(orderDeviceList,userId);
//保存数据
boolean isAudit = (item.getIsAudit() == 1 || order.getAuditStatus() != -1);
byte auditStatus = this.saveOrderData(deviceReq, order, userId, isAudit);
......@@ -4324,6 +4328,39 @@ public class OrderServiceImpl implements IOrderService {
return resultObject;
}
private void reduceStock(List<SysOrderDevice> orderDeviceList, int userId){
try {
List<String> list = orderDeviceList.stream().map(SysOrderDevice::getDeviceNo).collect(Collectors.toList());
SysDeviceExample deviceExample = new SysDeviceExample();
deviceExample.createCriteria().andUserIdEqualTo(userId).andDeviceStatusEqualTo(Constants.DEVICE_STATUS_NO_ACTIVE).andDeviceNoIn(list);
List<SysDevice> sysDevices = deviceMapper.selectByExample(deviceExample);
if (sysDevices.isEmpty()){
return;
}
for (SysDevice device : sysDevices) {
//设备关联的订单未确认收货不允许激活(通过拆除或者检修入库的设备没有订货单,单号可以为空)
SysIndent sysIndent = indentMapper.getByUserIdAndDeviceNo(userId, device.getDeviceNo());
if (sysIndent == null){
continue;
}
if (sysIndent.getIndentStatus() != IndentStatusEnum.INDENT_COMPLETE.getIndentStatus()) {
continue;
}
//技工设备库存减一
deviceRepertoryService.reduceDeviceRepertory(userId, device.getDeviceType(), 1);
//设备状态改为已激活
SysDevice sysDevice = new SysDevice();
sysDevice.setDeviceStatus(Constants.DEVICE_STATUS_ISACTIVE);
sysDevice.setId(device.getId());
deviceMapper.updateByPrimaryKeySelective(sysDevice);
//添加设备消耗记录
addDeviceConsumeLog(userId, device.getDeviceNo(), device.getDeviceType(), 1);
}
} catch (Exception e) {
logger.error("安装设备扣减库存异常 error:" + e.getMessage(), e);
}
}
/**
* 安装单保存数据封装
*
......@@ -5362,4 +5399,36 @@ public class OrderServiceImpl implements IOrderService {
}
logger.info("同步拆机数据结束===" + orderId);
}
@Override
public Map<String, Object> checkVinAndSn(Integer orderId, Integer serviceItemId) {
SysOrder sysOrder = orderMapper.selectByPrimaryKey(orderId);
if (sysOrder == null) {
throw BusinessException.create(ResultCodeEnum.ORDER_NOT_EXIST.getCode(), ResultCodeEnum.ORDER_NOT_EXIST.getMsg());
}
String checkVin = sysOrder.getVinNoDecode().toUpperCase();
if (StringUtils.isBlank(checkVin) || StringUtils.isBlank(sysOrder.getVinHash())) {
throw BusinessException.create(ResultCodeEnum.VIN_CHECK_ERROR.getCode(), ResultCodeEnum.VIN_CHECK_ERROR.getMsg());
}
SysServiceItem item = serviceItemMapper.selectByPrimaryKey(serviceItemId);
if (item == null || StringUtils.isBlank(sysOrder.getServiceCode())) {
throw BusinessException.create(ResultCodeEnum.SERVICE_ITEM_CODE_NOT_EXIST.getCode(), ResultCodeEnum.SERVICE_ITEM_CODE_NOT_EXIST.getMsg());
}
Map<String, Object> resMap = new HashMap<>();
resMap.put("vinCheckResult", true);
resMap.put("snCheckResult", true);
//将车架号加密变成密文和数据库的vinHash密文进行校验
if (!sysOrder.getVinHash().equals(DigestUtils.md5DigestAsHex(checkVin.getBytes()))) {
resMap.put("vinCheckResult", false);
}
//校验订单的ServiceCode和入参进来的服务项的ServiceCode是否相同
if (!sysOrder.getServiceCode().equals(item.getServiceCode())) {
resMap.put("snCheckResult", false);
}
return resMap;
}
}
package com.glsx.ordercenter.utils;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import org.apache.commons.io.IOUtils;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;
/**
* @title EasyExcelUtils
* @Author zhangzc
* @Description
* @Date 2024/4/10 19:57
**/
public class EasyExcelUtils {
/**
* 导出
*
* @param response
* @param data
* @param fileName
* @param sheetName
* @param clazz
* @throws Exception
*/
public static void writeExcel(HttpServletResponse response, List<? extends Object> data, String fileName, String sheetName, Class clazz) throws Exception {
//表头样式
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
//设置表头居中对齐
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
WriteFont writeFont = new WriteFont();
writeFont.setFontHeightInPoints((short) 12);
headWriteCellStyle.setWriteFont(writeFont);
//内容样式
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
//设置内容靠左对齐
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
EasyExcel.write(getOutputStream(fileName, response), clazz).excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
response.getOutputStream().flush();
IOUtils.closeQuietly(response.getOutputStream());
}
/**
* 导出
*
* @param os
* @param data
* @param sheetName
* @param clazz
*/
public static void writeExcel(OutputStream os, List<? extends Object> data, String sheetName, Class clazz) {
//表头样式
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
//设置表头居中对齐
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
WriteFont writeFont = new WriteFont();
writeFont.setFontHeightInPoints((short) 12);
headWriteCellStyle.setWriteFont(writeFont);
//内容样式
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
//设置内容靠左对齐
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
EasyExcel.write(os).head(clazz).excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
}
/**
* 导出
*
* @param response
* @param data
* @param fileName
* @param sheetName
* @param head
* @throws Exception
*/
public static void writeExcel(HttpServletResponse response, List<? extends Object> data, String fileName, String sheetName, List<List<String>> head) throws Exception {
//表头样式
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
//设置表头居中对齐
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
WriteFont writeFont = new WriteFont();
writeFont.setFontHeightInPoints((short) 12);
headWriteCellStyle.setWriteFont(writeFont);
//内容样式
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
//设置内容靠左对齐
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
EasyExcel.write(getOutputStream(fileName, response)).head(head).excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
response.getOutputStream().flush();
IOUtils.closeQuietly(response.getOutputStream());
}
/**
* 导出
*
* @param os
* @param data
* @param sheetName
* @param head
*/
public static void writeExcel(OutputStream os, List<? extends Object> data, String sheetName, List<List<String>> head) {
//表头样式
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
//设置表头居中对齐
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
WriteFont writeFont = new WriteFont();
writeFont.setFontHeightInPoints((short) 12);
headWriteCellStyle.setWriteFont(writeFont);
//内容样式
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
//设置内容靠左对齐
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
EasyExcel.write(os).head(head).excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
}
private static OutputStream getOutputStream(String fileName, HttpServletResponse response) throws Exception {
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ExcelTypeEnum.XLSX.getValue());
response.setContentType("application/msexcel;charset=UTF-8");//设置类型
response.setHeader("Pragma", "No-cache");//设置头
response.setHeader("Cache-Control", "no-cache");//设置头
response.setDateHeader("Expires", 0);//设置日期头
return response.getOutputStream();
}
}
package com.glsx.ordercenter.utils;
import lombok.Data;
import java.io.Serializable;
/**
* @title FileUploadServerData
* @Author zhangzc
* @Description
* @Date 2024/4/10 19:45
**/
@Data
public class FileUploadServerData implements Serializable {
private static final long serialVersionUID = -5236956344360089868L;
private Integer status = 0;
private String message = "";
private String url = "";
private String systemSign;
private String filePath;
private String param1;
private String param2;
private String param3;
private String secureUrl;
}
package com.glsx.ordercenter.utils;
import org.apache.commons.codec.binary.Base64;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
/**
* @title FileUtils
* @Author zhangzc
* @Description
* @Date 2024/4/10 17:24
**/
public class FileUtils {
public static final String FILE_UPLOAD_URL = "http://gfs.glsx.com.cn/file/upstring";
// blib 供应链
// biz 业务
private static final String dir_content = "biz";
public static InputStream getInputStreamFromUrl(String urlStr) {
InputStream inputStream = null;
try {
//url解码
URL url = new URL(java.net.URLDecoder.decode(urlStr, "UTF-8"));
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//设置超时间为3秒
conn.setConnectTimeout(3 * 1000);
//防止屏蔽程序抓取而返回403错误
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
//得到输入流
inputStream = conn.getInputStream();
} catch (IOException e) {
e.getStackTrace();
}
return inputStream;
}
/**
* 将文件上传至文件服务器
* @param uploadData
* @param fileType
* @return
*/
public static FileUploadServerData uploadToFileSystem(String fileName, byte[] uploadData, String fileType) {
RestTemplate restTemplate = new RestTemplate();
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
form.add("systemSign", dir_content);
form.add("param1", fileName);
form.add("files", fileType + "@" + Base64.encodeBase64String(uploadData));
// return restTemplate.postForObject(FILE_UPLOAD_URL, form, FileUploadServerData.class);
return restTemplate.postForObject(FILE_UPLOAD_URL, form, FileUploadServerData.class);
}
}
......@@ -398,8 +398,46 @@
UPDATE sys_device SET stock_time=now() where indent_no=#{indentNo}
</update>
<update id="updateUserByDeviceNo">
UPDATE sys_device
SET user_id = #{secondedId}
update_time = now(),
update_by = #{updateBy}, where user_id=#{beSecondedId} and device_no = #{deviceNo}
</update>
<update id="updateUserByDeviceNoList">
UPDATE sys_device
SET user_id = #{secondedId},
update_time = now(),
update_by = #{updateBy}
where user_id=#{beSecondedId} and device_status!=2
<if test="deviceNoList != null and deviceNoList.size() != 0">
and device_no in
<foreach collection="deviceNoList" item="item" open="(" separator="," close=")">
#{item,jdbcType=VARCHAR}
</foreach>
</if>
</update>
<select id="getByIndentNo" resultMap="BaseResultMap">
SELECT * from sys_device where indent_no=#{indentNo}
</select>
<select id="countDeviceByDeviceNo" resultType="java.lang.Integer">
select count(*)
from sys_device d
where d.device_status = 1 and d.device_no = #{deviceNo}
</select>
<select id="selectByDeviceNo" resultMap="BaseResultMap">
select *
from sys_device
where device_status = 1 and device_no = #{deviceNo}
order by id desc
limit 1
</select>
<select id="countByIndentNo" resultType="java.lang.Integer">
SELECT count(*) from sys_device where indent_no=#{indentNo}
</select>
</mapper>
\ No newline at end of file
......@@ -277,14 +277,15 @@
sdr.device_type deviceType,
su.name name,
su.username username,
su.user_type userType,
sdd.data_value deviceName
FROM
sys_device_repertory sdr
LEFT JOIN sys_user su ON sdr.user_id = su.id
LEFT JOIN sys_dict_data sdd ON sdr.device_type = sdd.data_key
WHERE su.user_type=1
<if test="username != null">
and su.username LIKE "%"#{username}"%"
<if test="username != null and username != ''">
and su.username LIKE concat('%',#{username},'%')
</if>
<if test="deviceType != null and deviceType != ''">
and sdr.device_type = #{deviceType}
......@@ -306,11 +307,15 @@
sdd.data_value deviceName,
sd.device_no deviceNo,
sd.stock_time stockTime,
sd.remark remark
sd.remark remark,
su.id userId,
su.name userName,
su.username loginName
FROM
sys_device sd
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_user su ON su.id = sd.user_id
WHERE si.indent_status = 40
AND sd.device_status = 1
AND sd.user_id = #{userId}
......@@ -331,6 +336,7 @@
sdd.data_value deviceName,
sd.device_no deviceNo,
sd.stock_time stockTime,
sd.remark remark,
su.name name
FROM
sys_device sd
......@@ -349,8 +355,8 @@
<if test="mechanicId != null">
and sd.user_id = #{mechanicId}
</if>
<if test="deviceNo != null">
and sd.device_no LIKE "%"#{deviceNo}"%"
<if test="deviceNo != null and deviceNo != ''">
and sd.device_no LIKE concat('%',#{deviceNo},'%')
</if>
<if test="deviceType != null and deviceType != ''">
and sd.device_type = #{deviceType}
......@@ -420,4 +426,58 @@
</otherwise>
</choose>
</select>
<select id="countServiceRepertoryDetail" parameterType="java.util.Map"
resultType="java.lang.Integer">
SELECT count(*)
FROM sys_device sd
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
WHERE si.indent_status = 40
AND sd.device_status = 1
AND sd.user_id = #{userId}
<if test="day != null">
AND TIMESTAMPDIFF(DAY, sd.stock_time, NOW()) > #{day}
</if>
<if test="deviceType != null and deviceType != '' ">
AND sd.device_type = #{deviceType}
</if>
</select>
<select id="countMechanicRepertoryDetail" parameterType="java.util.Map"
resultType="java.lang.Integer">
SELECT count(*)
FROM sys_device sd
LEFT JOIN sys_user su ON sd.user_id = su.id
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
WHERE ( (si.indent_status = 40 AND sd.device_source = 1) OR sd.device_source IN (2,3))
AND sd.device_status = 1
AND
sd.user_id IN (
select
ssm.mechanic_id
from sys_service_mechanic ssm
where ssm.service_id = #{serviceId}
)
<if test="day != null">
AND TIMESTAMPDIFF(DAY, sd.stock_time, NOW()) > #{day}
</if>
<if test="deviceType != null and deviceType != ''">
and sd.device_type = #{deviceType}
</if>
</select>
<select id="countMechanicRepertoryStock" parameterType="java.util.Map"
resultType="java.lang.Integer">
SELECT count(*)
FROM sys_device sd
where sd.device_status = 1 and sd.user_id = #{userId}
<if test="day != null">
AND TIMESTAMPDIFF(DAY, sd.stock_time, NOW()) > #{day}
</if>
<if test="deviceType != null and deviceType != ''">
and sd.device_type = #{deviceType}
</if>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glsx.ordercenter.mapper.SysIndentImportDeviceMapper">
<resultMap id="BaseResultMap" type="com.glsx.ordercenter.pojo.SysIndentImportDevice">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="indent_no" jdbcType="VARCHAR" property="indentNo" />
<result column="device_no" jdbcType="VARCHAR" property="deviceNo" />
<result column="batch_import_time" jdbcType="TIMESTAMP" property="batchImportTime" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="create_by" jdbcType="INTEGER" property="createBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="update_by" jdbcType="INTEGER" property="updateBy" />
</resultMap>
<resultMap id="IndentImportDeviceMap" type="com.glsx.ordercenter.dto.IndentImportDeviceReq">
<result column="id" jdbcType="INTEGER" property="id" />
<result column="device_type" jdbcType="VARCHAR" property="deviceType" />
<result column="data_value" jdbcType="VARCHAR" property="deviceName" />
<result column="device_no" jdbcType="VARCHAR" property="deviceNo" />
<result column="batch_import_time" jdbcType="TIMESTAMP" property="importTime" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, indent_no, device_no, batch_import_time, create_time, create_by, update_time,
update_by
</sql>
<insert id="insertBatchSelective" parameterType="java.util.List">
insert into sys_indent_import_device(indent_no , device_no ,batch_import_time ,create_time ,create_by)
values
<foreach collection="list" item="item" separator=",">
(#{item.indentNo}, #{item.deviceNo},#{item.batchImportTime},#{item.createTime},#{item.createBy})
</foreach>
</insert>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_indent_import_device
where id = #{id,jdbcType=INTEGER}
</delete>
<select id="selectImportDeviceList" resultMap="IndentImportDeviceMap">
select iid.id, iid.device_no, iid.batch_import_time,
si.device_type,
sdd.data_value
from sys_indent_import_device iid
left join sys_indent si on iid.indent_no = si.indent_no
left join sys_dict_data sdd on si.device_type = sdd.data_key
where si.id = #{indentId}
<if test="deviceNo != null and deviceNo != ''">
and iid.device_no like concat('%',#{deviceNo},'%')
</if>
</select>
<select id="countImportDeviceByDeviceNo" resultType="java.lang.Integer">
select count(*)
from sys_indent_import_device iid
left join sys_indent si on iid.indent_no = si.indent_no
where iid.device_no = #{deviceNo}
</select>
<select id="selectIndentNoById" resultType="java.lang.String">
select indent_no
from sys_indent_import_device
where id = #{id}
</select>
<select id="selectDeviceNoById" resultType="java.lang.String">
select device_no
from sys_indent_import_device
where id = #{id}
</select>
<select id="getDeviceNoListByIndentNo" resultType="java.lang.String">
select device_no
from sys_indent_import_device
where indent_no = #{indentNo}
</select>
<delete id="deleteByIndentNo" parameterType="java.lang.String">
delete from sys_indent_import_device
where indent_no = #{indentNo}
</delete>
</mapper>
\ No newline at end of file
......@@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="com.glsx.ordercenter.pojo.SysIndentLogistics">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="indent_id" jdbcType="INTEGER" property="indentId" />
<result column="order_type" jdbcType="INTEGER" property="orderType" />
<result column="logistics_no" jdbcType="VARCHAR" property="logisticsNo" />
<result column="logistics_unicode" jdbcType="VARCHAR" property="logisticsUnicode" />
<result column="logistics_time" jdbcType="TIMESTAMP" property="logisticsTime" />
......@@ -128,6 +129,9 @@
<if test="indentId != null">
indent_id,
</if>
<if test="orderType != null">
order_type,
</if>
<if test="logisticsNo != null">
logistics_no,
</if>
......@@ -157,6 +161,9 @@
<if test="indentId != null">
#{indentId,jdbcType=INTEGER},
</if>
<if test="orderType != null">
#{orderType,jdbcType=INTEGER},
</if>
<if test="logisticsNo != null">
#{logisticsNo,jdbcType=VARCHAR},
</if>
......@@ -307,6 +314,7 @@
FROM
sys_indent_logistics sil
LEFT JOIN sys_logistics sl ON sil.logistics_unicode = sl.unicode
WHERE sil.indent_id=#{indentId} LIMIT 1
WHERE sil.indent_id=#{indentId} and sil.order_type=#{orderType}
LIMIT 1
</select>
</mapper>
\ No newline at end of file
......@@ -15,6 +15,7 @@
<result column="district_code" jdbcType="INTEGER" property="districtCode" />
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="indent_type" jdbcType="INTEGER" property="indentType" />
<result column="create_by" jdbcType="INTEGER" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="INTEGER" property="updateBy" />
......@@ -23,6 +24,7 @@
<result column="deviceName" jdbcType="VARCHAR" property="deviceName" />
<association property="user" javaType="com.glsx.ordercenter.pojo.user.SysUser">
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="user_type" jdbcType="INTEGER" property="userType" />
<result column="phone_number" jdbcType="VARCHAR" property="phoneNumber" />
</association>
</resultMap>
......@@ -99,6 +101,9 @@
<if test="remark != null">
remark,
</if>
<if test="indentType != null">
indent_type,
</if>
<if test="createBy != null">
create_by,
</if>
......@@ -149,6 +154,9 @@
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="indentType != null">
#{indentType,jdbcType=INTEGER},
</if>
<if test="createBy != null">
#{createBy,jdbcType=INTEGER},
</if>
......@@ -276,9 +284,9 @@
select
si.id, si.indent_no, si.send_type, si.user_id, si.device_type,
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.indent_type,
si.create_by, si.create_time, si.update_by, si.update_time,
su.username,
su.username,su.name,su.user_type,
sdd.data_value as deviceName
FROM
sys_indent si
......@@ -298,8 +306,8 @@
<if test="endDate != null and endDate != ''">
and si.create_time &lt;= #{endDate}
</if>
<if test="username != null">
and su.username like #{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}))
</if>
</where>
ORDER BY si.create_time desc, si.id DESC
......@@ -328,6 +336,7 @@
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="username" jdbcType="VARCHAR" property="username" />
<result column="deviceName" jdbcType="VARCHAR" property="deviceName" />
<result column="indent_type" jdbcType="INTEGER" property="indentType" />
<association property="sysIndentLogistics" javaType="com.glsx.ordercenter.pojo.SysIndentLogistics">
<id property="id" column="logisticsId" />
<result property="indentId" column="indent_id"/>
......@@ -337,14 +346,19 @@
<result property="remark" column="logisticsRemark"/>
<result property="expressCompany" column="express_company"/>
</association>
<association property="user" javaType="com.glsx.ordercenter.pojo.user.SysUser">
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="user_type" jdbcType="INTEGER" property="userType" />
<result column="phone_number" jdbcType="VARCHAR" property="phoneNumber" />
</association>
</resultMap>
<select id="getDetail" parameterType="java.lang.Integer" resultMap="detailResultMap">
select
si.id, si.indent_no, si.send_type, si.user_id, si.device_type,
si.device_amount, si.indent_status, si.is_canceled, si.phone,
si.receiver_name, si.district_code, si.address, si.remark,
si.create_by, si.create_time, si.update_by, si.update_time,
su.username,
si.create_by, si.create_time, si.update_by, si.update_time,si.indent_type,
su.username,su.name,su.user_type,
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,
sl.express_company,
......@@ -379,7 +393,7 @@
si.id, si.indent_no, si.send_type, si.user_id, si.device_type,
si.device_amount, si.indent_status, si.is_canceled, si.phone,
si.receiver_name, si.district_code, si.address, si.remark,
si.create_by, si.create_time, si.update_by, si.update_time,
si.create_by, si.create_time, si.update_by, si.update_time,si.indent_type,
su.username,
sdd.data_value as deviceName
FROM
......@@ -414,7 +428,7 @@
si.id, si.indent_no, si.send_type, si.user_id, si.device_type,
si.device_amount, si.indent_status, si.is_canceled, si.phone,
si.receiver_name, si.district_code, si.address, si.remark,
si.create_by, si.create_time, si.update_by, si.update_time,
si.create_by, si.create_time, si.update_by, si.update_time,si.indent_type,
su.username,
sdd.data_value as deviceName
FROM
......@@ -478,5 +492,27 @@
</where>
ORDER BY si.create_time DESC, si.id DESC
</select>
<select id="selectUnReceivedIndentIds" resultType="java.lang.Integer">
select il.indent_id
from sys_indent_logistics il
left join sys_indent i on il.indent_id = i.id
where il.order_type = 1 and i.indent_type = 2 and i.indent_status = 30 and TIMESTAMPDIFF(DAY, il.logistics_time, NOW()) > 7
</select>
<update id="updateIndentStatusByIds">
update sys_indent
set indent_status = 40, update_time = now()
where id in
<foreach collection="ids" item="item" open="(" close=")" separator="," >
#{item}
</foreach>
</update>
<select id="selectByIndentNo" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_indent
where indent_no = #{indentNo}
</select>
</mapper>
\ No newline at end of file
......@@ -1064,13 +1064,18 @@
update sys_order
set
active_status = #{activeStatus,jdbcType=TINYINT},
shop_id = #{shopId,jdbcType=INTEGER},
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
district = #{district,jdbcType=INTEGER},
address = #{address,jdbcType=VARCHAR},
contact = #{contact,jdbcType=VARCHAR},
phone_number = #{phoneNumber,jdbcType=VARCHAR},
car_type = #{carType,jdbcType=VARCHAR},
vin_no = #{vinNo,jdbcType=VARCHAR},
<if test="vinHash != null and vinHash != ''">
vin_hash = #{vinHash,jdbcType=VARCHAR},
</if>
car_color = #{carColor,jdbcType=VARCHAR},
expect_install_time = #{expectInstallTime,jdbcType=TIMESTAMP},
<if test="serviceType != null and serviceType != ''">
......@@ -1078,8 +1083,12 @@
</if>
car_owner = #{carOwner,jdbcType=VARCHAR},
car_owner_phone = #{carOwnerPhone,jdbcType=VARCHAR},
merchant_id = #{merchantId,jdbcType=INTEGER},
mechanic_id = #{mechanicId,jdbcType=INTEGER},
<if test="merchantId != null">
merchant_id = #{merchantId,jdbcType=INTEGER},
</if>
<if test="mechanicId != null">
mechanic_id = #{mechanicId,jdbcType=INTEGER},
</if>
remark = #{remark,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=INTEGER},
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glsx.ordercenter.mapper.SysSecondmentImportDeviceMapper">
<resultMap id="BaseResultMap" type="com.glsx.ordercenter.pojo.SysSecondmentImportDevice">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="secondment_no" jdbcType="VARCHAR" property="secondmentNo" />
<result column="device_no" jdbcType="VARCHAR" property="deviceNo" />
<result column="seconded_id" jdbcType="INTEGER" property="secondedId" />
<result column="be_seconded_id" jdbcType="INTEGER" property="beSecondedId" />
<result column="batch_import_time" jdbcType="TIMESTAMP" property="batchImportTime" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="create_by" jdbcType="INTEGER" property="createBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="update_by" jdbcType="INTEGER" property="updateBy" />
<result column="username" jdbcType="VARCHAR" property="username" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="user_type" jdbcType="INTEGER" property="userType"/>
<result column="beUsername" jdbcType="VARCHAR" property="beUsername" />
<result column="beName" jdbcType="VARCHAR" property="beName" />
<result column="beUserType" jdbcType="INTEGER" property="beUserType"/>
<result column="deviceName" jdbcType="VARCHAR" property="deviceName" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, secondment_no, device_no, seconded_id, be_seconded_id, batch_import_time, create_time,
create_by, update_time, update_by
</sql>
<select id="getDeviceBySecondmentNo" resultMap="BaseResultMap">
select
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,
su1.username,su1.name,su1.user_type,
su2.username as beUsername,su2.name as beName,su2.user_type as beUserType,
sdd.data_value as deviceName
FROM
sys_secondment_import_device ssid
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 su2 ON ssid.be_seconded_id = su2.id
LEFT JOIN sys_dict_data sdd ON ss.device_type = sdd.data_key
where ssid.secondment_no=#{secondmentNo}
<if test="deviceNo != null and deviceNo != ''">
and ssid.device_no=#{deviceNo}
</if>
</select>
<select id="getListBySecondmentNo" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
FROM
sys_secondment_import_device
where secondment_no=#{secondmentNo}
</select>
<select id="selectSecondmentNoById" resultType="java.lang.String">
select secondment_no
from sys_secondment_import_device
where id = #{id}
</select>
<select id="selectDeviceNoById" resultType="java.lang.String">
select device_no
from sys_secondment_import_device
where id = #{id}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_secondment_import_device
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insertBatchSelective" parameterType="java.util.List">
insert into sys_secondment_import_device(secondment_no , device_no ,seconded_id ,be_seconded_id, batch_import_time ,create_time ,create_by)
values
<foreach collection="list" item="item" separator=",">
(#{item.secondmentNo}, #{item.deviceNo}, #{item.secondedId}, #{item.beSecondedId},#{item.batchImportTime},#{item.createTime},#{item.createBy})
</foreach>
</insert>
<select id="countImportDeviceByDeviceNo" resultType="java.lang.Integer">
select count(*)
from sys_secondment_import_device sid
left join sys_secondment s on s.secondment_no = sid.secondment_no
where s.secondment_status != 40 and sid.device_no = #{deviceNo}
</select>
<delete id="deleteBySecondmentNo" parameterType="java.lang.String">
delete from sys_secondment_import_device
where secondment_no = #{secondmentNo}
</delete>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glsx.ordercenter.mapper.SysSecondmentLogMapper">
<resultMap id="BaseResultMap" type="com.glsx.ordercenter.pojo.SysSecondmentLog">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="secondment_id" jdbcType="INTEGER" property="secondmentId" />
<result column="secondment_status" jdbcType="INTEGER" property="secondmentStatus" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_by" jdbcType="INTEGER" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, secondment_id, secondment_status, remark, create_by, create_time
</sql>
<insert id="insertSelective" parameterType="com.glsx.ordercenter.pojo.SysSecondmentLog">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_secondment_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="secondmentId != null">
secondment_id,
</if>
<if test="secondmentStatus != null">
secondment_status,
</if>
<if test="remark != null">
remark,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="secondmentId != null">
#{secondmentId,jdbcType=INTEGER},
</if>
<if test="secondmentStatus != null">
#{secondmentStatus,jdbcType=INTEGER},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="get" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_secondment_log
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="secondmentId != null">
and secondment_id = #{secondmentId}
</if>
<if test="secondmentStatus != null">
and secondment_status = #{secondmentStatus}
</if>
</where>
</select>
<select id="selectSecondmentLogList" resultMap="BaseResultMap">
select
sl.id, sl.secondment_id, sl.secondment_status, sl.remark, sl.create_by, sl.create_time,
su.name operatorName
from sys_secondment_log sl
LEFT JOIN sys_user su ON sl.create_by = su.id
where sl.secondment_id = #{secondmentId}
order by sl.id desc
</select>
</mapper>
\ 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!