提交 b42e0d47 authored 作者: zhoushaopan's avatar zhoushaopan

feat[一期二期对接设备]: 新增接口

[一期二期对接设备]
上级 f527d121
...@@ -26,6 +26,7 @@ import com.tykj.dev.device.task.service.TaskService; ...@@ -26,6 +26,7 @@ import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto; import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.domin.Task; import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.user.cache.UnitsCache; import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.cache.UserCache;
import com.tykj.dev.device.user.read.service.MessageService; import com.tykj.dev.device.user.read.service.MessageService;
import com.tykj.dev.device.user.read.subject.bto.MessageBto; import com.tykj.dev.device.user.read.subject.bto.MessageBto;
import com.tykj.dev.device.user.subject.dao.UserDao; import com.tykj.dev.device.user.subject.dao.UserDao;
...@@ -47,12 +48,16 @@ import lombok.extern.slf4j.Slf4j; ...@@ -47,12 +48,16 @@ import lombok.extern.slf4j.Slf4j;
import lombok.val; import lombok.val;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -135,9 +140,18 @@ public class AllotBillController { ...@@ -135,9 +140,18 @@ public class AllotBillController {
@Resource @Resource
private UnitsCache unitsCache; private UnitsCache unitsCache;
@Resource
private RestTemplate restTemplate;
@Resource @Resource
private VerificationService verificationService; private VerificationService verificationService;
@Resource
private UserCache userCache;
@Value("${carrier.url}")
private String carrierUrl;
@ApiOperation(value = "导入二维码获取配发装备", notes = "可以通过这个接口导入二维码获取配发装备") @ApiOperation(value = "导入二维码获取配发装备", notes = "可以通过这个接口导入二维码获取配发装备")
@PostMapping(value = "/load") @PostMapping(value = "/load")
public ResponseEntity loadDevice(@RequestBody RfidVo rfidVo) { public ResponseEntity loadDevice(@RequestBody RfidVo rfidVo) {
...@@ -830,9 +844,60 @@ public class AllotBillController { ...@@ -830,9 +844,60 @@ public class AllotBillController {
message+MessageFormatUtil.spellTwoWicket(allotBill.getSendUnit(),allotBill.getReceiveUnit()) message+MessageFormatUtil.spellTwoWicket(allotBill.getSendUnit(),allotBill.getReceiveUnit())
+MessageFormatUtil.spellModelAndCount(collect,allotBill.getAllotedCount()), ids, 1); +MessageFormatUtil.spellModelAndCount(collect,allotBill.getAllotedCount()), ids, 1);
messageService.add(messageBto); messageService.add(messageBto);
//调用载体
if ("21".equals(allotBill.getReceiveUnitId()+"")){
log.info("接收单位:{}",allotBill.getReceiveUnitId());
List<DeviceVo> deviceVoList = getDeviceVoList(scriptSaveVos);
if(deviceVoList.size() >0){
log.info("开始调用载体接口");
ConfigUration configUration = ConfigUration.builder()
//出库时间
.outboundTime(DateUtil.getLocalDateTime(allotBill.getCreateTime()))
//收方a
.debitMemberThatAName(userCache.findById(allotBill.getReceiveUseraId()).getName())
//收方b
.debitMemberThatBName(userCache.findById(allotBill.getReceiveUserbId()).getName())
//发起单位
.initiateUnit(unitsCache.findById(allotBill.getSendUnitId()).getName())
//接收单位
.receiveUnit(unitsCache.findById(allotBill.getReceiveUnitId()).getName())
//state 状态 zjm说默认传1
.state(1)
.deviceVos(deviceVoList)
// senderMemberThatAName 发方A
.senderMemberThatAName(userCache.findById(allotBill.getSendUseraId()).getName())
// senderMemberThatAName senderMemberThatBName
.senderMemberThatBName(userCache.findById(allotBill.getSendUserbId()).getName())
.signatureStatus(0)
.build();
restTemplate.postForEntity(carrierUrl, configUration,String.class);
}
}
return ResponseEntity.ok("上传成功"); return ResponseEntity.ok("上传成功");
} }
private List<DeviceVo> getDeviceVoList(List<ScriptSaveVo> scriptSaveVos) {
List<DeviceVo> deviceVoList = new ArrayList<>();
scriptSaveVos.forEach(scriptSaveVo -> {
if (scriptSaveVo.getName().contains("分割盘")){
DeviceVo deviceVo = new DeviceVo();
deviceVo.setModel(scriptSaveVo.getModel());
deviceVo.setParts(scriptSaveVo.getName());
deviceVo.setRemark(scriptSaveVo.getRemark());
deviceVo.setNum(scriptSaveVo.getSeqNumber());
deviceVo.setVisible(scriptSaveVo.getInvisibleRange());
deviceVo.setWith(scriptSaveVo.getAllotType());
deviceVo.setSecurityClassification(scriptSaveVo.getSecretLevel());
deviceVo.setCount(scriptSaveVo.getNum()+"");
deviceVoList.add(deviceVo);
}
});
return deviceVoList;
}
@ApiOperation(value = "上传发送方配发单", notes = "上传配发单") @ApiOperation(value = "上传发送方配发单", notes = "上传配发单")
@PostMapping(value = "/uploadFile") @PostMapping(value = "/uploadFile")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -937,6 +1002,36 @@ public class AllotBillController { ...@@ -937,6 +1002,36 @@ public class AllotBillController {
content+MessageFormatUtil.spellTwoWicket(allotBill.getSendUnit(),allotBill.getReceiveUnit()) content+MessageFormatUtil.spellTwoWicket(allotBill.getSendUnit(),allotBill.getReceiveUnit())
+MessageFormatUtil.spellModelAndCount(collect,allotBill.getAllotedCount()), ids, 1); +MessageFormatUtil.spellModelAndCount(collect,allotBill.getAllotedCount()), ids, 1);
messageService.add(messageBto); messageService.add(messageBto);
if ("21".equals(allotBill.getReceiveUnitId()+"")){
log.info("接收单位:{}",allotBill.getReceiveUnitId());
List<DeviceVo> deviceVoList = getDeviceVoList(scriptSaveVos);
if (deviceVoList.size() >0){
log.info("开始调用载体接口");
ConfigUration configUration = ConfigUration.builder()
//出库时间
.outboundTime(DateUtil.getLocalDateTime(allotBill.getCreateTime()))
//收方a
.debitMemberThatAName(userCache.findById(allotBill.getReceiveUseraId()).getName())
//收方b
.debitMemberThatBName(userCache.findById(allotBill.getReceiveUserbId()).getName())
//发起单位
.initiateUnit(unitsCache.findById(allotBill.getSendUnitId()).getName())
//接收单位
.receiveUnit(unitsCache.findById(allotBill.getReceiveUnitId()).getName())
//state 状态 zjm说默认传1
.state(1)
.deviceVos(deviceVoList)
// senderMemberThatAName 发方A
.senderMemberThatAName(userCache.findById(allotBill.getSendUseraId()).getName())
// senderMemberThatAName senderMemberThatBName
.senderMemberThatBName(userCache.findById(allotBill.getSendUserbId()).getName())
.signatureStatus(0)
.build();
restTemplate.postForEntity(carrierUrl, configUration,String.class);
}
}
return ResponseEntity.ok("OK"); return ResponseEntity.ok("OK");
} }
...@@ -1041,7 +1136,6 @@ public class AllotBillController { ...@@ -1041,7 +1136,6 @@ public class AllotBillController {
} }
//递归取出最大目录 //递归取出最大目录
public PackingLibrary getPackingLibrary(PackingLibrary packingLibrary) { public PackingLibrary getPackingLibrary(PackingLibrary packingLibrary) {
Integer partParentId = packingLibrary.getPartParentId(); Integer partParentId = packingLibrary.getPartParentId();
......
package com.tykj.dev.device.allot.subject.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Transient;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName ConfigUration.java
* @Description TODO
* @createTime 2022年08月01日 09:52:00
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("配置业务出库实体")
@Builder
public class ConfigUration {
/**
* 出库时间
*/
@ApiModelProperty(value = "出库时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private LocalDateTime outboundTime;
/**
* 发起单位
*/
@ApiModelProperty(value = "发起单位")
private String initiateUnit;
/**
* 发往单位
*/
@ApiModelProperty(value = "发往单位")
private String receiveUnit;
/**
* 状态
*/
@ApiModelProperty(value = "状态")
private Integer state;
/**
* 签名情况 1.待完成 2.已完成
*/
@ApiModelProperty(value = "签名情况 1.待完成 2.已完成")
private Integer signatureStatus = 0;
/**
* 配置装备列表
*/
@ApiModelProperty(value = "配置装备列表json")
private String deviceJson;
@Transient
@ApiModelProperty(value = "配置装备列表集合")
private List<DeviceVo> deviceVos;
/**
* 收方人员
*/
/**
* 发方人员A
*/
private String senderMemberThatAName;
/**
* 发方人员A
*/
private String senderMemberThatBName;
/**
* 收方a
*/
private String debitMemberThatAName;
/**
* 收方B
*/
private String debitMemberThatBName;
}
package com.tykj.dev.device.allot.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author zjm
* @version 1.0.0
* @ClassName DeviceVO.java
* @Description TODO
* @createTime 2022年08月01日 12:49:00
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "配置状态实体")
public class DeviceVo {
@ApiModelProperty(value = "型号")
private String model;
@ApiModelProperty(value = "部件")
private String parts;
@ApiModelProperty(value = "密级")
private String securityClassification;
@ApiModelProperty(value = "可见范围")
private String visible;
@ApiModelProperty(value = "配用范围")
private String with;
@ApiModelProperty(value = "数量")
private String count;
@ApiModelProperty(value = "状态序号")
private String num;
@ApiModelProperty(value = "备注")
private String remark;
}
package com.tykj.dev.config;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
/**
* @author zsp@mail.com
* @date 2022/11/1
*/
@Component
public class RestTemplateConfig {
@Bean
private RestTemplate getRestTemplate(){
return new RestTemplate();
}
}
package com.tykj.dev.misc.utils; package com.tykj.dev.misc.utils;
import java.time.Instant; import java.time.*;
import java.time.LocalDate; import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
/** /**
...@@ -12,11 +10,9 @@ import java.util.Date; ...@@ -12,11 +10,9 @@ import java.util.Date;
*/ */
public class DateUtil { public class DateUtil {
public static LocalDateTime getLocalDateTime(Date date){ public static LocalDateTime getLocalDateTime(Date date){
Instant instant = date.toInstant(); Instant instant = date.toInstant();
ZoneId zoneId = ZoneId.systemDefault(); return instant.atZone(ZoneOffset.of("+8")).toLocalDateTime();
return instant.atZone(zoneId).toLocalDateTime();
} }
public static LocalDate getLocalDate(Date date){ public static LocalDate getLocalDate(Date date){
...@@ -25,4 +21,5 @@ public class DateUtil { ...@@ -25,4 +21,5 @@ public class DateUtil {
LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime(); LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
return localDateTime.toLocalDate(); return localDateTime.toLocalDate();
} }
} }
spring.application.name=device-dev spring.application.name=device-dev
spring.datasource.url=jdbc:mysql://192.168.100.249:3306/device_master?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false spring.datasource.url=jdbc:mysql://192.168.0.232:3307/device_master?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=root spring.datasource.password=tykj@2022
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
#spring.datasource.url=jdbc:mysql://localhost:3306/device_master?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false #spring.datasource.url=jdbc:mysql://localhost:3306/device_master?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver #spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
...@@ -19,3 +19,5 @@ block.flag=true ...@@ -19,3 +19,5 @@ block.flag=true
readMachine.ip=192.168.101.201 readMachine.ip=192.168.101.201
qrcode.path = C:/Users/zsp/Desktop/qrcode/ qrcode.path = C:/Users/zsp/Desktop/qrcode/
qrcode.preview.path=http://192.168.101.133:8087/code/ qrcode.preview.path=http://192.168.101.133:8087/code/
carrier.url = http://192.168.0.101:8087/configuration/saveConfiguration
...@@ -7,4 +7,6 @@ spring.jpa.database-platform=org.hibernate.dialect.OscarDialect ...@@ -7,4 +7,6 @@ spring.jpa.database-platform=org.hibernate.dialect.OscarDialect
file.path=/opt/zb/ file.path=/opt/zb/
preview.path=http://10.153.4.11:8088/equip/file/ preview.path=http://10.153.4.11:8088/equip/file/
#preview.path=http://192.168.0.80:8088/equip/file/ #preview.path=http://192.168.0.80:8088/equip/file/
block.flag=true block.flag=true
\ No newline at end of file
carrier.url = http://10.153.4.11:8088/carrier/configuration/saveConfiguration
\ No newline at end of file
...@@ -10,3 +10,4 @@ spring.jmx.enabled=false ...@@ -10,3 +10,4 @@ spring.jmx.enabled=false
block.flag=false block.flag=false
qrcode.path = /opt/qrcode/ qrcode.path = /opt/qrcode/
qrcode.preview.path=http://10.153.4.11:8088/equipTest/code/ qrcode.preview.path=http://10.153.4.11:8088/equipTest/code/
carrier.url = http://10.153.4.11:8088/carrierTest/configuration/saveConfiguration
\ No newline at end of file
...@@ -13,4 +13,6 @@ block.flag=true ...@@ -13,4 +13,6 @@ block.flag=true
readMachine.ip=192.168.101.202 readMachine.ip=192.168.101.202
qrcode.path = /opt/qrcode/ qrcode.path = /opt/qrcode/
qrcode.preview.path=http://192.168.0.80/equip/code/ qrcode.preview.path=http://192.168.0.80/equip/code/
\ No newline at end of file
carrier.url = http://192.168.0.80:8088/carrier/configuration/saveConfiguration
\ No newline at end of file
...@@ -25,8 +25,13 @@ public class UserCache { ...@@ -25,8 +25,13 @@ public class UserCache {
} }
public User findById(Integer id) { public User findById(Integer id) {
User user=idMap.get(id); User user;
user.setUnits(unitsService.findById(user.getUnitsId())); if (idMap.containsKey(id)){
user = idMap.get(id);
user.setUnits(unitsService.findById(user.getUnitsId()));
}else {
return new User();
}
return user; return user;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论