mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
添加磅房管理
This commit is contained in:
@@ -10,6 +10,7 @@ import cn.lihongjie.coal.acDeviceData.repository.AcDeviceDataRepository;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.common.JpaUtils;
|
||||
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
@@ -29,9 +30,6 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -84,17 +82,7 @@ public class AcDeviceDataService extends BaseService<AcDeviceDataEntity, AcDevic
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
public static List<Map<String, Object>> convertTuplesToMap(List<Tuple> tuples) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (Tuple single : tuples) {
|
||||
Map<String, Object> tempMap = new HashMap<>();
|
||||
for (TupleElement<?> key : single.getElements()) {
|
||||
tempMap.put(key.getAlias(), single.get(key));
|
||||
}
|
||||
result.add(tempMap);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@PersistenceContext private EntityManager em;
|
||||
|
||||
public Page report(AcDeviceDataReportRequest request) {
|
||||
@@ -201,7 +189,7 @@ public class AcDeviceDataService extends BaseService<AcDeviceDataEntity, AcDevic
|
||||
countQuery.setParameter("directionName", request.getDirectionName());
|
||||
}
|
||||
|
||||
var resultList = convertTuplesToMap(selectQuery.getResultList());
|
||||
var resultList = JpaUtils.convertTuplesToMap(selectQuery.getResultList());
|
||||
|
||||
var ans =
|
||||
resultList.stream()
|
||||
|
||||
20
src/main/java/cn/lihongjie/coal/common/JpaUtils.java
Normal file
20
src/main/java/cn/lihongjie/coal/common/JpaUtils.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package cn.lihongjie.coal.common;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.TupleElement;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class JpaUtils {
|
||||
public static List<Map<String, Object>> convertTuplesToMap(List<Tuple> tuples) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (Tuple single : tuples) {
|
||||
Map<String, Object> tempMap = new HashMap<>();
|
||||
for (TupleElement<?> key : single.getElements()) {
|
||||
tempMap.put(key.getAlias(), single.get(key));
|
||||
}
|
||||
result.add(tempMap);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
58
src/main/java/cn/lihongjie/coal/common/MessageSignUtils.java
Normal file
58
src/main/java/cn/lihongjie/coal/common/MessageSignUtils.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package cn.lihongjie.coal.common;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.codec.digest.HmacAlgorithms;
|
||||
import org.apache.commons.codec.digest.HmacUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.amqp.core.Message;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
@UtilityClass
|
||||
@Slf4j
|
||||
public class MessageSignUtils {
|
||||
|
||||
public static boolean isValid(Message message, Function<String, String> appSecretProvider) {
|
||||
|
||||
var body = new String(message.getBody(), StandardCharsets.UTF_8);
|
||||
|
||||
Map<String, Object> headers = message.getMessageProperties().getHeaders();
|
||||
|
||||
Object key = headers.get("appKey");
|
||||
|
||||
if (key == null || StringUtils.isEmpty(key.toString())) {
|
||||
log.error("appKey is null");
|
||||
return false;
|
||||
}
|
||||
String appSecret;
|
||||
|
||||
try {
|
||||
|
||||
appSecret = appSecretProvider.apply(key.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("appSecretProvider error", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(appSecret)) {
|
||||
|
||||
log.error("appSecret is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
var sign =
|
||||
new HmacUtils(HmacAlgorithms.HMAC_SHA_256, appSecret)
|
||||
.hmacHex(body.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
if (!StringUtils.equals(sign, headers.get("sign").toString())) {
|
||||
log.error("sign not match {} {}", sign, headers.get("sign"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
package cn.lihongjie.coal.dataCollector.listener;
|
||||
|
||||
import cn.lihongjie.coal.acDevice.entity.AcDeviceEntity;
|
||||
import cn.lihongjie.coal.acDevice.service.AcDeviceService;
|
||||
import cn.lihongjie.coal.acDeviceData.service.AcDeviceDataService;
|
||||
import cn.lihongjie.coal.dataCollector.entity.DataCollectorEntity;
|
||||
import cn.lihongjie.coal.dataCollector.service.DataCollectorService;
|
||||
import cn.lihongjie.coal.dataCollectorLog.entity.DataCollectorLogEntity;
|
||||
import cn.lihongjie.coal.dataCollectorLog.service.DataCollectorLogService;
|
||||
import cn.lihongjie.coal.rabbitmq.RabbitMQConfiguration;
|
||||
import cn.lihongjie.coal.weightDeviceData.entity.WeightDeviceDataEntity;
|
||||
import cn.lihongjie.coal.weightDeviceData.service.WeightDeviceDataService;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.codec.digest.HmacAlgorithms;
|
||||
import org.apache.commons.codec.digest.HmacUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WeightListener {
|
||||
|
||||
@Autowired DataCollectorService dataCollectorService;
|
||||
|
||||
@Autowired DataCollectorLogService dataCollectorLogService;
|
||||
|
||||
@Autowired ObjectMapper objectMapper;
|
||||
|
||||
@Autowired AcDeviceDataService acDeviceDataService;
|
||||
|
||||
@Autowired AcDeviceService acDeviceService;
|
||||
|
||||
@Autowired WeightDeviceDataService weightDeviceDataService;
|
||||
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@RabbitListener(
|
||||
bindings = {
|
||||
@QueueBinding(
|
||||
value =
|
||||
@org.springframework.amqp.rabbit.annotation.Queue(
|
||||
value = "weight20.data",
|
||||
durable = "true"),
|
||||
exchange =
|
||||
@Exchange(
|
||||
value = RabbitMQConfiguration.SYS_EXCHANGE,
|
||||
declare = Exchange.FALSE),
|
||||
key = "weight20.*")
|
||||
})
|
||||
@Transactional
|
||||
public void handleWeightMessage(Message message) {
|
||||
|
||||
var body = new String(message.getBody(), StandardCharsets.UTF_8);
|
||||
|
||||
Map<String, Object> headers = message.getMessageProperties().getHeaders();
|
||||
|
||||
Object key = headers.get("appKey");
|
||||
|
||||
if (key == null) {
|
||||
log.error("appKey is null");
|
||||
return;
|
||||
}
|
||||
|
||||
DataCollectorEntity dataCollector = dataCollectorService.findByAppKey(key.toString());
|
||||
|
||||
var sign =
|
||||
new HmacUtils(HmacAlgorithms.HMAC_SHA_256, dataCollector.getAppSecret())
|
||||
.hmacHex(body.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
if (!StringUtils.equals(sign, headers.get("sign").toString())) {
|
||||
log.error("sign not match {} {}", sign, headers.get("sign"));
|
||||
return;
|
||||
}
|
||||
|
||||
List<AcDeviceEntity> devices =
|
||||
acDeviceService.findAll(
|
||||
new Specification<AcDeviceEntity>() {
|
||||
@Override
|
||||
public Predicate toPredicate(
|
||||
Root<AcDeviceEntity> root,
|
||||
CriteriaQuery<?> query,
|
||||
CriteriaBuilder criteriaBuilder) {
|
||||
return criteriaBuilder.and(
|
||||
criteriaBuilder.equal(
|
||||
root.get("dataCollector").get("id"),
|
||||
dataCollector.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
if (devices.isEmpty()) {
|
||||
log.error("no device found for data collector: {}", dataCollector.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
var device = devices.get(0);
|
||||
|
||||
JsonNode jsonNode = objectMapper.readTree(body);
|
||||
|
||||
DataCollectorLogEntity logEntity = new DataCollectorLogEntity();
|
||||
logEntity.setOrganizationId(dataCollector.getOrganizationId());
|
||||
logEntity.setDataCollector(dataCollector);
|
||||
|
||||
Object rk = message.getMessageProperties().getReceivedRoutingKey();
|
||||
|
||||
logEntity.setLogTime(LocalDateTime.now());
|
||||
logEntity.setType(rk.toString());
|
||||
|
||||
switch (rk.toString()) {
|
||||
case "weight20.weightinfo" -> {
|
||||
ArrayNode nodes = (ArrayNode) jsonNode;
|
||||
var flowNumbers =
|
||||
StreamSupport.stream(nodes.spliterator(), false)
|
||||
.map(x -> x.get("流水号").asText())
|
||||
.toList();
|
||||
logEntity.setContent(StringUtils.join(flowNumbers, ","));
|
||||
|
||||
Map<String, WeightDeviceDataEntity> flowNumberMap =
|
||||
weightDeviceDataService
|
||||
.findAll(
|
||||
(Specification<WeightDeviceDataEntity>)
|
||||
(root, query, criteriaBuilder) ->
|
||||
criteriaBuilder.and(
|
||||
criteriaBuilder.equal(
|
||||
root.get("device")
|
||||
.get("id"),
|
||||
device.getId()),
|
||||
root.get("flowNumber").in(flowNumbers)))
|
||||
.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
WeightDeviceDataEntity::getFlowNumber, e -> e));
|
||||
|
||||
nodes.forEach(
|
||||
x -> {
|
||||
var flowNumber = x.get("流水号").asText();
|
||||
if (flowNumberMap.containsKey(flowNumber)) {
|
||||
log.info("data already exists: {} {}", flowNumber, device.getId());
|
||||
return;
|
||||
}
|
||||
// log.info(x.toPrettyString());
|
||||
|
||||
WeightDeviceDataEntity deviceData = new WeightDeviceDataEntity();
|
||||
|
||||
deviceData.setSequenceNumber(toInteger(x.get("序号")));
|
||||
deviceData.setFlowNumber(toString(x.get("流水号")));
|
||||
deviceData.setPlateNo(toString(x.get("车号")));
|
||||
deviceData.setWeighType(toString(x.get("过磅类型")));
|
||||
deviceData.setSendOrganization(toString(x.get("发货单位")));
|
||||
deviceData.setReceiveOrganization(toString(x.get("收货单位")));
|
||||
deviceData.setGoods(toString(x.get("货名")));
|
||||
deviceData.setSpecification(toString(x.get("规格")));
|
||||
deviceData.setMz(toDouble(x.get("毛重")));
|
||||
deviceData.setPz(toDouble(x.get("皮重")));
|
||||
deviceData.setJz(toDouble(x.get("净重")));
|
||||
deviceData.setKz(toDouble(x.get("扣重")));
|
||||
deviceData.setSz(toDouble(x.get("实重")));
|
||||
deviceData.setPrice(toDouble(x.get("单价")));
|
||||
deviceData.setAmount(toDouble(x.get("金额")));
|
||||
deviceData.setZfxs(toDouble(x.get("折方系数")));
|
||||
deviceData.setFl(toDouble(x.get("方量")));
|
||||
deviceData.setWeightFee(toDouble(x.get("过磅费")));
|
||||
deviceData.setMzUser(toString(x.get("毛重司磅员")));
|
||||
deviceData.setPzUser(toString(x.get("皮重司磅员")));
|
||||
deviceData.setMzbh(toString(x.get("毛重磅号")));
|
||||
deviceData.setPzbh(toString(x.get("皮重磅号")));
|
||||
deviceData.setMzTime(toLocalDateTime(x.get("毛重时间")));
|
||||
deviceData.setPzTime(toLocalDateTime(x.get("皮重时间")));
|
||||
deviceData.setYcgbTIme(toLocalDateTime(x.get("一次过磅时间")));
|
||||
deviceData.setEcgbTime(toLocalDateTime(x.get("二次过磅时间")));
|
||||
deviceData.setUpdateUser(toString(x.get("更新人")));
|
||||
deviceData.setUpdateTime(toLocalDateTime(x.get("更新时间")));
|
||||
deviceData.setRemark(toString(x.get("备注")));
|
||||
deviceData.setPrintCount(toInteger(x.get("打印次数")));
|
||||
deviceData.setUpload(toBoolean(x.get("上传否")));
|
||||
deviceData.setReserve1(toString(x.get("备用1")));
|
||||
deviceData.setReserve2(toString(x.get("备用2")));
|
||||
deviceData.setReserve3(toString(x.get("备用3")));
|
||||
deviceData.setReserve4(toString(x.get("备用4")));
|
||||
deviceData.setReserve5(toString(x.get("备用5")));
|
||||
deviceData.setReserve6(toDouble(x.get("备用6")));
|
||||
deviceData.setReserve7(toDouble(x.get("备用7")));
|
||||
deviceData.setReserve8(toDouble(x.get("备用8")));
|
||||
deviceData.setReserve9(toDouble(x.get("备用9")));
|
||||
deviceData.setReserve10(toString(x.get("备用10")));
|
||||
deviceData.setReserve11(toString(x.get("备用11")));
|
||||
deviceData.setReserve12(toString(x.get("备用12")));
|
||||
deviceData.setReserve13(toString(x.get("备用13")));
|
||||
deviceData.setReserve14(toString(x.get("备用14")));
|
||||
deviceData.setReserve15(toDouble(x.get("备用15")));
|
||||
deviceData.setReserve16(toDouble(x.get("备用16")));
|
||||
deviceData.setReserve17(toDouble(x.get("备用17")));
|
||||
deviceData.setReserve18(toDouble(x.get("备用18")));
|
||||
deviceData.setClientType(toInteger(x.get("客户类型")));
|
||||
deviceData.setYcgbWeight(toDouble(x.get("一次过磅重")));
|
||||
deviceData.setEcgbWeight(toDouble(x.get("二次过磅重")));
|
||||
deviceData.setB0(toString(x.get("b0")));
|
||||
deviceData.setAguid(toString(x.get("aguid")));
|
||||
deviceData.setPlanNumber(toString(x.get("PlanNumber")));
|
||||
deviceData.setRecordCreateMode(toInteger(x.get("RecordCreateMode")));
|
||||
deviceData.setRecordFinish(toInteger(x.get("RecordFinish")));
|
||||
deviceData.setNetPriceSyncTime(toLocalDateTime(x.get("网价同步时间")));
|
||||
deviceData.setNetPriceModifyUser(toString(x.get("网价修改人")));
|
||||
deviceData.setCTime(toLocalDateTime(x.get("CTime")));
|
||||
deviceData.setModifyOnnet(toString(x.get("modify_onnet")));
|
||||
deviceData.setModifyTime(toLocalDateTime(x.get("modify_time")));
|
||||
deviceData.setModifyBy(toString(x.get("modify_by")));
|
||||
deviceData.setAuditFlag(toString(x.get("audit_flag")));
|
||||
deviceData.setAuditTime(toLocalDateTime(x.get("audit_time")));
|
||||
deviceData.setAuditBy(toString(x.get("audit_by")));
|
||||
deviceData.setEUpimg(toString(x.get("e_upimg")));
|
||||
deviceData.setReserve19(toString(x.get("备用19")));
|
||||
deviceData.setReserve20(toString(x.get("备用20")));
|
||||
deviceData.setReserve21(toString(x.get("备用21")));
|
||||
deviceData.setReserve22(toString(x.get("备用22")));
|
||||
deviceData.setReserve23(toString(x.get("备用23")));
|
||||
deviceData.setReserve24(toString(x.get("备用24")));
|
||||
deviceData.setReserve25(toString(x.get("备用25")));
|
||||
deviceData.setReserve26(toString(x.get("备用26")));
|
||||
deviceData.setReserve27(toString(x.get("备用27")));
|
||||
deviceData.setReserve28(toString(x.get("备用28")));
|
||||
deviceData.setDriverInfo(toString(x.get("driver_info")));
|
||||
deviceData.setHqbUpImgG1(toInteger(x.get("HQB_UpImg_G1")));
|
||||
deviceData.setHqbUpImgG2(toInteger(x.get("HQB_UpImg_G2")));
|
||||
deviceData.setHqbUpImgG3(toInteger(x.get("HQB_UpImg_G3")));
|
||||
deviceData.setHqbUpImgG4(toInteger(x.get("HQB_UpImg_G4")));
|
||||
deviceData.setHqbUpImgT1(toInteger(x.get("HQB_UpImg_T1")));
|
||||
deviceData.setHqbUpImgT2(toInteger(x.get("HQB_UpImg_T2")));
|
||||
deviceData.setHqbUpImgT3(toInteger(x.get("HQB_UpImg_T3")));
|
||||
deviceData.setHqbUpImgT4(toInteger(x.get("HQB_UpImg_T4")));
|
||||
|
||||
weightDeviceDataService.save(deviceData);
|
||||
});
|
||||
}
|
||||
default -> {
|
||||
log.warn("unknown message type: {}", rk);
|
||||
}
|
||||
}
|
||||
|
||||
dataCollectorLogService.save(logEntity);
|
||||
|
||||
// log.info("new message from pms: {}", body);
|
||||
}
|
||||
|
||||
private Integer toBoolean(JsonNode node) {
|
||||
|
||||
|
||||
if (node== null || node.isNull()){
|
||||
return null;
|
||||
}
|
||||
|
||||
if (node.isIntegralNumber()){
|
||||
return node.asInt();
|
||||
}
|
||||
|
||||
if (node.isBoolean()){
|
||||
return node.asBoolean() ? 1 : 0;
|
||||
}
|
||||
|
||||
return Integer.parseInt(node.asText());
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String toString(JsonNode node) {
|
||||
|
||||
if (node== null || node.isNull()){
|
||||
return null;
|
||||
}
|
||||
|
||||
return node.asText();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Integer toInteger(JsonNode node) {
|
||||
|
||||
if (node== null || node.isNull()){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (node.isFloatingPointNumber()){
|
||||
return node.asInt();
|
||||
}
|
||||
|
||||
if (node.isIntegralNumber()){
|
||||
return node.asInt();
|
||||
}
|
||||
|
||||
String text = node.asText();
|
||||
|
||||
|
||||
if (StringUtils.isBlank(text)){
|
||||
return null;
|
||||
}
|
||||
|
||||
return Integer.parseInt(text);
|
||||
}
|
||||
|
||||
private Double toDouble(JsonNode node) {
|
||||
|
||||
if (node== null || node.isNull()){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (node.isFloatingPointNumber()){
|
||||
return node.asDouble();
|
||||
}
|
||||
|
||||
if (node.isIntegralNumber()){
|
||||
return node.asDouble();
|
||||
}
|
||||
|
||||
String text = node.asText();
|
||||
|
||||
|
||||
if (StringUtils.isBlank(text)){
|
||||
return null;
|
||||
}
|
||||
|
||||
return Double.parseDouble(text);
|
||||
}
|
||||
|
||||
|
||||
private LocalDateTime toLocalDateTime(JsonNode node) {
|
||||
|
||||
if (node== null || node.isNull()){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
String text = node.asText();
|
||||
|
||||
|
||||
if (StringUtils.isBlank(text)){
|
||||
return null;
|
||||
}
|
||||
|
||||
return LocalDateTime.parse(text, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.amqp.core.AmqpAdmin;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -44,12 +45,14 @@ public class DataCollectorService
|
||||
|
||||
@Autowired AmqpAdmin amqpAdmin;
|
||||
|
||||
@Autowired RabbitTemplate rabbitTemplate;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
||||
// findAll().stream()
|
||||
// .filter(x -> StringUtils.isNotEmpty(x.getAppKey()))
|
||||
// .forEach(this::createQueue);
|
||||
// findAll().stream()
|
||||
// .filter(x -> StringUtils.isNotEmpty(x.getAppKey()))
|
||||
// .forEach(this::createQueue);
|
||||
}
|
||||
|
||||
public DataCollectorDto create(CreateDataCollectorDto request) {
|
||||
@@ -64,10 +67,24 @@ public class DataCollectorService
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
|
||||
public Object getLocalStatus(String appKey){
|
||||
//
|
||||
// rabbitTemplate.convertSendAndReceive(
|
||||
// "dataCollector." + appKey,
|
||||
// (Object) "getLocalStatus",
|
||||
// new CorrelationData(UUID.randomUUID().toString()));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String createQueue(DataCollectorEntity entity) {
|
||||
return amqpAdmin.declareQueue(
|
||||
private void createQueue(DataCollectorEntity entity) {
|
||||
amqpAdmin.declareQueue(
|
||||
new Queue("pms.client." + entity.getAppKey(), true, false, false, new HashMap<>()));
|
||||
|
||||
amqpAdmin.declareQueue(
|
||||
new Queue("weight20.client." + entity.getAppKey(), true, false, false, new HashMap<>()));
|
||||
|
||||
}
|
||||
|
||||
public DataCollectorDto update(UpdateDataCollectorDto request) {
|
||||
@@ -110,4 +127,6 @@ public class DataCollectorService
|
||||
return repository.findByAppKey(appKey);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.weightDevice.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.OrgScope;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.weightDevice.dto.CreateWeightDeviceDto;
|
||||
import cn.lihongjie.coal.weightDevice.dto.UpdateWeightDeviceDto;
|
||||
import cn.lihongjie.coal.weightDevice.dto.WeightDeviceDto;
|
||||
import cn.lihongjie.coal.weightDevice.service.WeightDeviceService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/weightDevice")
|
||||
@SysLog(module = "地磅设备")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class WeightDeviceController {
|
||||
@Autowired private WeightDeviceService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public WeightDeviceDto create(@RequestBody CreateWeightDeviceDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public WeightDeviceDto update(@RequestBody UpdateWeightDeviceDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public WeightDeviceDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<WeightDeviceDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.lihongjie.coal.weightDevice.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateWeightDeviceDto extends OrgCommonDto {
|
||||
@ManyToOne
|
||||
String supplier;
|
||||
|
||||
@ManyToOne
|
||||
String dataCollector;
|
||||
|
||||
|
||||
|
||||
private String location;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.lihongjie.coal.weightDevice.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateWeightDeviceDto extends OrgCommonDto {
|
||||
|
||||
@ManyToOne
|
||||
String supplier;
|
||||
|
||||
@ManyToOne
|
||||
String dataCollector;
|
||||
|
||||
|
||||
|
||||
private String location;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.weightDevice.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.dataCollector.dto.DataCollectorDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WeightDeviceDto extends OrgCommonDto {
|
||||
|
||||
@ManyToOne
|
||||
DataCollectorDto supplier;
|
||||
|
||||
@ManyToOne
|
||||
DataCollectorDto dataCollector;
|
||||
|
||||
|
||||
|
||||
private String location;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.lihongjie.coal.weightDevice.entity;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Embeddable
|
||||
public class ReserveFieldConfig {
|
||||
|
||||
@Comment("字段名称")
|
||||
private String name;
|
||||
|
||||
@Comment("字段编码")
|
||||
private String code;
|
||||
|
||||
@Comment("字段显示名称")
|
||||
private String displayName;
|
||||
|
||||
@Comment("字段排序值")
|
||||
private Integer columnSortKey;
|
||||
|
||||
@Comment("是否启用")
|
||||
private Boolean enable;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.lihongjie.coal.weightDevice.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.dataCollector.entity.DataCollectorEntity;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.entity.WeightDeviceSupplierEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class WeightDeviceEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
WeightDeviceSupplierEntity supplier;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
DataCollectorEntity dataCollector;
|
||||
|
||||
|
||||
|
||||
private String location;
|
||||
|
||||
|
||||
@ElementCollection
|
||||
private List<ReserveFieldConfig> reserveFieldConfigList;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.weightDevice.mapper;
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonEntityMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.weightDevice.dto.CreateWeightDeviceDto;
|
||||
import cn.lihongjie.coal.weightDevice.dto.UpdateWeightDeviceDto;
|
||||
import cn.lihongjie.coal.weightDevice.dto.WeightDeviceDto;
|
||||
import cn.lihongjie.coal.weightDevice.entity.WeightDeviceEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class, CommonEntityMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface WeightDeviceMapper
|
||||
extends BaseMapper<
|
||||
WeightDeviceEntity,
|
||||
WeightDeviceDto,
|
||||
CreateWeightDeviceDto,
|
||||
UpdateWeightDeviceDto> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.lihongjie.coal.weightDevice.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.weightDevice.entity.WeightDeviceEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WeightDeviceRepository extends BaseRepository<WeightDeviceEntity> {}
|
||||
@@ -0,0 +1,73 @@
|
||||
package cn.lihongjie.coal.weightDevice.service;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
|
||||
import cn.lihongjie.coal.weightDevice.dto.CreateWeightDeviceDto;
|
||||
import cn.lihongjie.coal.weightDevice.dto.UpdateWeightDeviceDto;
|
||||
import cn.lihongjie.coal.weightDevice.dto.WeightDeviceDto;
|
||||
import cn.lihongjie.coal.weightDevice.entity.WeightDeviceEntity;
|
||||
import cn.lihongjie.coal.weightDevice.mapper.WeightDeviceMapper;
|
||||
import cn.lihongjie.coal.weightDevice.repository.WeightDeviceRepository;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
public class WeightDeviceService extends BaseService<WeightDeviceEntity, WeightDeviceRepository> {
|
||||
@Autowired private WeightDeviceRepository repository;
|
||||
|
||||
@Autowired private WeightDeviceMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public WeightDeviceDto create(CreateWeightDeviceDto request) {
|
||||
WeightDeviceEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public WeightDeviceDto update(UpdateWeightDeviceDto request) {
|
||||
WeightDeviceEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public WeightDeviceDto getById(String id) {
|
||||
WeightDeviceEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<WeightDeviceDto> list(CommonQuery query) {
|
||||
Page<WeightDeviceEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.lihongjie.coal.weightDeviceData.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.OrgScope;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.weightDeviceData.dto.CreateWeightDeviceDataDto;
|
||||
import cn.lihongjie.coal.weightDeviceData.dto.UpdateWeightDeviceDataDto;
|
||||
import cn.lihongjie.coal.weightDeviceData.dto.WeightDeviceDataDto;
|
||||
import cn.lihongjie.coal.weightDeviceData.service.WeightDeviceDataService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/weightDeviceData")
|
||||
@SysLog(module = "地磅数据")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class WeightDeviceDataController {
|
||||
@Autowired private WeightDeviceDataService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public WeightDeviceDataDto create(@RequestBody CreateWeightDeviceDataDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public WeightDeviceDataDto update(@RequestBody UpdateWeightDeviceDataDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public WeightDeviceDataDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<WeightDeviceDataDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
|
||||
@PostMapping("/archive")
|
||||
public Object archive(@RequestBody IdRequest request) {
|
||||
this.service.archive(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/unarchive")
|
||||
public Object unarchive(@RequestBody IdRequest request) {
|
||||
this.service.unarchive(request);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.weightDeviceData.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateWeightDeviceDataDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.weightDeviceData.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateWeightDeviceDataDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.lihongjie.coal.weightDeviceData.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WeightDeviceDataDto extends OrgCommonDto {
|
||||
private String archiveStatus;
|
||||
|
||||
private String archiveStatusName;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package cn.lihongjie.coal.weightDeviceData.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class WeightDeviceDataReportRequest extends CommonQuery {
|
||||
|
||||
@Comment("""
|
||||
时间维度
|
||||
year
|
||||
month
|
||||
week
|
||||
day
|
||||
hour
|
||||
""")
|
||||
private String timeDimension;
|
||||
@Comment("""
|
||||
统计字段
|
||||
|
||||
|
||||
""")
|
||||
private List<String> reportFields;
|
||||
private List<FieldInfo> fieldInfos;
|
||||
private LocalDateTime startTime;
|
||||
private LocalDateTime endTime;
|
||||
/**
|
||||
* 过滤条件
|
||||
*/
|
||||
|
||||
private String plateNo;
|
||||
private String sendOrganization;
|
||||
private String receiveOrganization;
|
||||
private String goods;
|
||||
private String specification;
|
||||
private String mzUser;
|
||||
private String pzUser;
|
||||
|
||||
@Data
|
||||
public static class FieldInfo {
|
||||
private String fieldName;
|
||||
@Comment("sum avg count max min")
|
||||
private String function;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,471 @@
|
||||
package cn.lihongjie.coal.weightDeviceData.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.weightDevice.entity.WeightDeviceEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* create table dbo.称重信息 ( <br>
|
||||
* <br>
|
||||
* 序号 Integer identity (10) identity, <br>
|
||||
* <br>
|
||||
* 流水号 String(50) not null primary key nonclustered, <br>
|
||||
* <br>
|
||||
* 车号 String(50), <br>
|
||||
* <br>
|
||||
* 过磅类型 String(5), <br>
|
||||
* <br>
|
||||
* 发货单位 String(50), <br>
|
||||
* <br>
|
||||
* 收货单位 String(50), <br>
|
||||
* <br>
|
||||
* 货名 String(50), <br>
|
||||
* <br>
|
||||
* 规格 String(50), <br>
|
||||
* <br>
|
||||
* 毛重 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 皮重 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 净重 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 扣重 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 实重 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 单价 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 金额 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 折方系数 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 方量 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 过磅费 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 毛重司磅员 String(50), <br>
|
||||
* <br>
|
||||
* 皮重司磅员 String(50), <br>
|
||||
* <br>
|
||||
* 毛重磅号 String(10), <br>
|
||||
* <br>
|
||||
* 皮重磅号 String(10), <br>
|
||||
* <br>
|
||||
* 毛重时间 java.time.LocalDateTime(23, 3), <br>
|
||||
* <br>
|
||||
* 皮重时间 java.time.LocalDateTime(23, 3), <br>
|
||||
* <br>
|
||||
* 一次过磅时间 java.time.LocalDateTime(23, 3), <br>
|
||||
* <br>
|
||||
* 二次过磅时间 java.time.LocalDateTime(23, 3), <br>
|
||||
* <br>
|
||||
* 更新人 String(50), <br>
|
||||
* <br>
|
||||
* 更新时间 java.time.LocalDateTime(23, 3), <br>
|
||||
* <br>
|
||||
* 备注 String(50), <br>
|
||||
* <br>
|
||||
* 打印次数 Integer, <br>
|
||||
* <br>
|
||||
* 上传否 bit not null, <br>
|
||||
* <br>
|
||||
* 备用1 String(50), <br>
|
||||
* <br>
|
||||
* 备用2 String(50), <br>
|
||||
* <br>
|
||||
* 备用3 String(50), <br>
|
||||
* <br>
|
||||
* 备用4 String(50), <br>
|
||||
* <br>
|
||||
* 备用5 String(50), <br>
|
||||
* <br>
|
||||
* 备用6 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 备用7 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 备用8 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 备用9 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 备用10 String(50), <br>
|
||||
* <br>
|
||||
* 备用11 String(50), <br>
|
||||
* <br>
|
||||
* 备用12 String(50), <br>
|
||||
* <br>
|
||||
* 备用13 String(50), <br>
|
||||
* <br>
|
||||
* 备用14 String(50), <br>
|
||||
* <br>
|
||||
* 备用15 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 备用16 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 备用17 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 备用18 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 客户类型 Integer, <br>
|
||||
* <br>
|
||||
* 一次过磅重 Double(18, 3), <br>
|
||||
* <br>
|
||||
* 二次过磅重 Double(18, 3), <br>
|
||||
* <br>
|
||||
* b0 String, <br>
|
||||
* <br>
|
||||
* aguid String(36), <br>
|
||||
* <br>
|
||||
* PlanNumber String(50), <br>
|
||||
* <br>
|
||||
* RecordCreateMode Integer default (0), <br>
|
||||
* <br>
|
||||
* RecordFinish Integer default (0), <br>
|
||||
* <br>
|
||||
* 网价同步时间 java.time.LocalDateTime(23, 3), <br>
|
||||
* <br>
|
||||
* 网价修改人 String(50), <br>
|
||||
* <br>
|
||||
* CTime java.time.LocalDateTime(23, 3), <br>
|
||||
* <br>
|
||||
* modify_onnet String, <br>
|
||||
* <br>
|
||||
* modify_time java.time.LocalDateTime(23, 3), <br>
|
||||
* <br>
|
||||
* modify_by String(50), <br>
|
||||
* <br>
|
||||
* audit_flag String, <br>
|
||||
* <br>
|
||||
* audit_time java.time.LocalDateTime(23, 3), <br>
|
||||
* <br>
|
||||
* audit_by String(50), <br>
|
||||
* <br>
|
||||
* e_upimg String(8), <br>
|
||||
* <br>
|
||||
* 备用19 String(50), <br>
|
||||
* <br>
|
||||
* 备用20 String(50), <br>
|
||||
* <br>
|
||||
* 备用21 String(50), <br>
|
||||
* <br>
|
||||
* 备用22 String(50), <br>
|
||||
* <br>
|
||||
* 备用23 String(50), <br>
|
||||
* <br>
|
||||
* 备用24 String(50), <br>
|
||||
* <br>
|
||||
* 备用25 String(50), <br>
|
||||
* <br>
|
||||
* 备用26 String(50), <br>
|
||||
* <br>
|
||||
* 备用27 String(50), <br>
|
||||
* <br>
|
||||
* 备用28 String(50), <br>
|
||||
* <br>
|
||||
* driver_info String(36), <br>
|
||||
* <br>
|
||||
* HQB_UpImg_G1 Integer default (0), <br>
|
||||
* <br>
|
||||
* HQB_UpImg_G2 Integer default (0), <br>
|
||||
* <br>
|
||||
* HQB_UpImg_G3 Integer default (0), <br>
|
||||
* <br>
|
||||
* HQB_UpImg_G4 Integer default (0), <br>
|
||||
* <br>
|
||||
* HQB_UpImg_T1 Integer default (0), <br>
|
||||
* <br>
|
||||
* HQB_UpImg_T2 Integer default (0), <br>
|
||||
* <br>
|
||||
* HQB_UpImg_T3 Integer default (0), <br>
|
||||
* <br>
|
||||
* HQB_UpImg_T4 Integer default (0) )
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
public class WeightDeviceDataEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private WeightDeviceEntity device;
|
||||
|
||||
@Comment("序号")
|
||||
private Integer sequenceNumber;
|
||||
|
||||
@Comment("流水号")
|
||||
private String flowNumber;
|
||||
|
||||
@Comment("车号")
|
||||
private String plateNo;
|
||||
|
||||
@Comment("过磅类型")
|
||||
private String weighType;
|
||||
|
||||
@Comment("发货单位")
|
||||
private String sendOrganization;
|
||||
|
||||
@Comment("收货单位")
|
||||
private String receiveOrganization;
|
||||
|
||||
@Comment("货名")
|
||||
private String goods;
|
||||
|
||||
@Comment("规格")
|
||||
private String specification;
|
||||
|
||||
@Comment("毛重")
|
||||
private Double mz;
|
||||
|
||||
@Comment("皮重")
|
||||
private Double pz;
|
||||
|
||||
@Comment("净重")
|
||||
private Double jz;
|
||||
|
||||
@Comment("扣重")
|
||||
private Double kz;
|
||||
|
||||
@Comment("实重")
|
||||
private Double sz;
|
||||
|
||||
@Comment("单价")
|
||||
private Double price;
|
||||
|
||||
@Comment("金额")
|
||||
private Double amount;
|
||||
|
||||
@Comment("折方系数")
|
||||
private Double zfxs;
|
||||
|
||||
@Comment("方量")
|
||||
private Double fl;
|
||||
|
||||
@Comment("过磅费")
|
||||
private Double weightFee;
|
||||
|
||||
@Comment("毛重司磅员")
|
||||
private String mzUser;
|
||||
|
||||
@Comment("皮重司磅员")
|
||||
private String pzUser;
|
||||
|
||||
@Comment("毛重磅号")
|
||||
private String mzbh;
|
||||
|
||||
@Comment("皮重磅号")
|
||||
private String pzbh;
|
||||
|
||||
@Comment("毛重时间")
|
||||
private LocalDateTime mzTime;
|
||||
|
||||
@Comment("皮重时间")
|
||||
private LocalDateTime pzTime;
|
||||
|
||||
@Comment("一次过磅时间")
|
||||
private LocalDateTime ycgbTIme;
|
||||
|
||||
@Comment("二次过磅时间")
|
||||
private LocalDateTime ecgbTime;
|
||||
|
||||
@Comment("更新人")
|
||||
private String updateUser;
|
||||
|
||||
@Comment("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Comment("备注")
|
||||
private String remark;
|
||||
|
||||
@Comment("打印次数")
|
||||
private Integer printCount;
|
||||
|
||||
@Comment("上传否")
|
||||
private Integer upload;
|
||||
|
||||
@Comment("备用1")
|
||||
private String reserve1;
|
||||
|
||||
@Comment("备用2")
|
||||
private String reserve2;
|
||||
|
||||
@Comment("备用3")
|
||||
private String reserve3;
|
||||
|
||||
@Comment("备用4")
|
||||
private String reserve4;
|
||||
|
||||
@Comment("备用5")
|
||||
private String reserve5;
|
||||
|
||||
@Comment("备用6")
|
||||
private Double reserve6;
|
||||
|
||||
@Comment("备用7")
|
||||
private Double reserve7;
|
||||
|
||||
@Comment("备用8")
|
||||
private Double reserve8;
|
||||
|
||||
@Comment("备用9")
|
||||
private Double reserve9;
|
||||
|
||||
@Comment("备用10")
|
||||
private String reserve10;
|
||||
|
||||
@Comment("备用11")
|
||||
private String reserve11;
|
||||
|
||||
@Comment("备用12")
|
||||
private String reserve12;
|
||||
|
||||
@Comment("备用13")
|
||||
private String reserve13;
|
||||
|
||||
@Comment("备用14")
|
||||
private String reserve14;
|
||||
|
||||
@Comment("备用15")
|
||||
private Double reserve15;
|
||||
|
||||
@Comment("备用16")
|
||||
private Double reserve16;
|
||||
|
||||
@Comment("备用17")
|
||||
private Double reserve17;
|
||||
|
||||
@Comment("备用18")
|
||||
private Double reserve18;
|
||||
|
||||
@Comment("客户类型")
|
||||
private Integer clientType;
|
||||
|
||||
@Comment("一次过磅重")
|
||||
private Double ycgbWeight;
|
||||
|
||||
@Comment("二次过磅重")
|
||||
private Double ecgbWeight;
|
||||
|
||||
@Comment("b0")
|
||||
private String b0;
|
||||
|
||||
@Comment("aguid")
|
||||
private String aguid;
|
||||
|
||||
@Comment("PlanNumber")
|
||||
private String planNumber;
|
||||
|
||||
@Comment("RecordCreateMode")
|
||||
private Integer recordCreateMode;
|
||||
|
||||
@Comment("RecordFinish")
|
||||
private Integer recordFinish;
|
||||
|
||||
@Comment("网价同步时间")
|
||||
private LocalDateTime netPriceSyncTime;
|
||||
|
||||
@Comment("网价修改人")
|
||||
private String netPriceModifyUser;
|
||||
|
||||
@Comment("CTime")
|
||||
private LocalDateTime cTime;
|
||||
|
||||
@Comment("modify_onnet")
|
||||
private String modifyOnnet;
|
||||
|
||||
@Comment("modify_time")
|
||||
private LocalDateTime modifyTime;
|
||||
|
||||
@Comment("modify_by")
|
||||
private String modifyBy;
|
||||
|
||||
@Comment("audit_flag")
|
||||
private String auditFlag;
|
||||
|
||||
@Comment("audit_time")
|
||||
private LocalDateTime auditTime;
|
||||
|
||||
@Comment("audit_by")
|
||||
private String auditBy;
|
||||
|
||||
@Comment("e_upimg")
|
||||
private String eUpimg;
|
||||
|
||||
@Comment("备用19")
|
||||
private String reserve19;
|
||||
|
||||
@Comment("备用20")
|
||||
private String reserve20;
|
||||
|
||||
@Comment("备用21")
|
||||
private String reserve21;
|
||||
|
||||
@Comment("备用22")
|
||||
private String reserve22;
|
||||
|
||||
@Comment("备用23")
|
||||
private String reserve23;
|
||||
|
||||
@Comment("备用24")
|
||||
private String reserve24;
|
||||
|
||||
@Comment("备用25")
|
||||
private String reserve25;
|
||||
|
||||
@Comment("备用26")
|
||||
private String reserve26;
|
||||
|
||||
@Comment("备用27")
|
||||
private String reserve27;
|
||||
|
||||
@Comment("备用28")
|
||||
private String reserve28;
|
||||
|
||||
@Comment("driver_info")
|
||||
private String driverInfo;
|
||||
|
||||
@Comment("HQB_UpImg_G1")
|
||||
private Integer hqbUpImgG1;
|
||||
|
||||
@Comment("HQB_UpImg_G2")
|
||||
private Integer hqbUpImgG2;
|
||||
|
||||
@Comment("HQB_UpImg_G3")
|
||||
private Integer hqbUpImgG3;
|
||||
|
||||
@Comment("HQB_UpImg_G4")
|
||||
private Integer hqbUpImgG4;
|
||||
|
||||
@Comment("HQB_UpImg_T1")
|
||||
private Integer hqbUpImgT1;
|
||||
|
||||
@Comment("HQB_UpImg_T2")
|
||||
private Integer hqbUpImgT2;
|
||||
|
||||
@Comment("HQB_UpImg_T3")
|
||||
private Integer hqbUpImgT3;
|
||||
|
||||
@Comment("HQB_UpImg_T4")
|
||||
private Integer hqbUpImgT4;
|
||||
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
|
||||
@Formula(
|
||||
"(select i.name\n"
|
||||
+ "from t_dictionary d,\n"
|
||||
+ " t_dictionary_item i\n"
|
||||
+ "where d.id = i.dictionary_id\n"
|
||||
+ " and d.code = 'archiveStatus'\n"
|
||||
+ " and i.code = archive_status)")
|
||||
private String archiveStatusName;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.weightDeviceData.mapper;
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonEntityMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.weightDeviceData.dto.CreateWeightDeviceDataDto;
|
||||
import cn.lihongjie.coal.weightDeviceData.dto.UpdateWeightDeviceDataDto;
|
||||
import cn.lihongjie.coal.weightDeviceData.dto.WeightDeviceDataDto;
|
||||
import cn.lihongjie.coal.weightDeviceData.entity.WeightDeviceDataEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class, CommonEntityMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface WeightDeviceDataMapper
|
||||
extends BaseMapper<
|
||||
WeightDeviceDataEntity,
|
||||
WeightDeviceDataDto,
|
||||
CreateWeightDeviceDataDto,
|
||||
UpdateWeightDeviceDataDto> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.lihongjie.coal.weightDeviceData.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.weightDeviceData.entity.WeightDeviceDataEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WeightDeviceDataRepository extends BaseRepository<WeightDeviceDataEntity> {}
|
||||
@@ -0,0 +1,288 @@
|
||||
package cn.lihongjie.coal.weightDeviceData.service;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.common.ArchiveUtils;
|
||||
import cn.lihongjie.coal.common.JpaUtils;
|
||||
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import cn.lihongjie.coal.weightDeviceData.dto.CreateWeightDeviceDataDto;
|
||||
import cn.lihongjie.coal.weightDeviceData.dto.UpdateWeightDeviceDataDto;
|
||||
import cn.lihongjie.coal.weightDeviceData.dto.WeightDeviceDataDto;
|
||||
import cn.lihongjie.coal.weightDeviceData.dto.WeightDeviceDataReportRequest;
|
||||
import cn.lihongjie.coal.weightDeviceData.entity.WeightDeviceDataEntity;
|
||||
import cn.lihongjie.coal.weightDeviceData.mapper.WeightDeviceDataMapper;
|
||||
import cn.lihongjie.coal.weightDeviceData.repository.WeightDeviceDataRepository;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.persistence.Query;
|
||||
import jakarta.persistence.Tuple;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
public class WeightDeviceDataService
|
||||
extends BaseService<WeightDeviceDataEntity, WeightDeviceDataRepository> {
|
||||
@Autowired private WeightDeviceDataRepository repository;
|
||||
|
||||
@Autowired private WeightDeviceDataMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
public WeightDeviceDataDto create(CreateWeightDeviceDataDto request) {
|
||||
WeightDeviceDataEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public WeightDeviceDataDto update(UpdateWeightDeviceDataDto request) {
|
||||
WeightDeviceDataEntity entity = this.repository.get(request.getId());
|
||||
ArchiveUtils.checkArchiveStatus(
|
||||
entity,
|
||||
WeightDeviceDataEntity::getArchiveStatus,
|
||||
x -> "0",
|
||||
(e, actual, expected) -> {
|
||||
throw new BizException("数据 " + "已归档,无法编辑");
|
||||
});
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
ArchiveUtils.checkArchiveStatus(
|
||||
this.repository::findAllById,
|
||||
request.getIds(),
|
||||
WeightDeviceDataEntity::getArchiveStatus,
|
||||
x -> "0",
|
||||
(e, actual, expected) -> {
|
||||
throw new BizException("数据 " + "已归档,无法删除");
|
||||
});
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public WeightDeviceDataDto getById(String id) {
|
||||
WeightDeviceDataEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<WeightDeviceDataDto> list(CommonQuery query) {
|
||||
Page<WeightDeviceDataEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
public void archive(IdRequest dto) {
|
||||
this.repository.findAllById(dto.getIds()).stream()
|
||||
.peek(
|
||||
x ->
|
||||
ArchiveUtils.checkArchiveStatus(
|
||||
x,
|
||||
WeightDeviceDataEntity::getArchiveStatus,
|
||||
y -> "0",
|
||||
(e, actual, expected) -> {
|
||||
throw new BizException("数据 " + "已归档,无法再次归档");
|
||||
}))
|
||||
.peek(x -> x.setArchiveStatus("1"))
|
||||
.forEach(this.repository::save);
|
||||
}
|
||||
|
||||
public void unarchive(IdRequest dto) {
|
||||
this.repository.findAllById(dto.getIds()).stream()
|
||||
.peek(
|
||||
x ->
|
||||
ArchiveUtils.checkArchiveStatus(
|
||||
x,
|
||||
WeightDeviceDataEntity::getArchiveStatus,
|
||||
y -> "1",
|
||||
(e, actual, expected) -> {
|
||||
throw new BizException("数据" + "未归档,无法取消归档");
|
||||
}))
|
||||
.peek(x -> x.setArchiveStatus("0"))
|
||||
.forEach(this.repository::save);
|
||||
}
|
||||
|
||||
public Page report(WeightDeviceDataReportRequest request) {
|
||||
|
||||
if (StringUtils.isEmpty(request.getTimeDimension())){
|
||||
request.setTimeDimension("day");
|
||||
}
|
||||
|
||||
String groupSql =
|
||||
CollectionUtils.isEmpty(request.getReportFields())
|
||||
? " 1 "
|
||||
: request.getReportFields().stream()
|
||||
.map(x -> CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, x))
|
||||
.map(s -> "d." + s)
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
String fieldSql =
|
||||
CollectionUtils.isEmpty(request.getFieldInfos())
|
||||
? " "
|
||||
: request.getFieldInfos().stream()
|
||||
.map(
|
||||
x ->
|
||||
x.getFunction()
|
||||
+ "( d."
|
||||
+ CaseFormat.UPPER_CAMEL.to(
|
||||
CaseFormat.LOWER_UNDERSCORE,
|
||||
x.getFieldName())
|
||||
+ ") "
|
||||
+ " as "
|
||||
+ x.getFieldName())
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
String where = "where 1 = 1 ";
|
||||
|
||||
if (request.getStartTime() != null) {
|
||||
where += " and d.mz_time >= :startTime ";
|
||||
}
|
||||
|
||||
if (request.getEndTime() != null) {
|
||||
where += " and d.mz_time <= :endTime ";
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(request.getPlateNo())) {
|
||||
where += " and d.plate_no like :plateNo ";
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(request.getSendOrganization())) {
|
||||
where += " and d.send_organization like :sendOrganization ";
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(request.getReceiveOrganization())) {
|
||||
where += " and d.receive_organization like :receiveOrganization ";
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(request.getGoods())) {
|
||||
where += " and d.goods like :goods ";
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(request.getSpecification())) {
|
||||
where += " and d.specification = :specification ";
|
||||
}
|
||||
|
||||
var sql =
|
||||
"select DATE_TRUNC('"
|
||||
+ request.getTimeDimension()
|
||||
+ "', d.pass_time) as time,\n"
|
||||
+ groupSql
|
||||
+ ",\n"
|
||||
+ fieldSql
|
||||
+ "\n from t_weight_device_data d\n"
|
||||
+ " "
|
||||
+ where
|
||||
+ " "
|
||||
+ "\n"
|
||||
+ "group by DATE_TRUNC('"
|
||||
+ request.getTimeDimension()
|
||||
+ "', d.pass_time), "
|
||||
+ groupSql
|
||||
+ "\n"
|
||||
+ "order by time desc , cnt desc";
|
||||
|
||||
var countSql = "select count(1) from (" + sql + ") as t";
|
||||
|
||||
var selectSql = "select * from (" + sql + ") as t limit " + request.getPageSize() + " offset " + request.getPageNo() * request.getPageSize();
|
||||
|
||||
Query selectQuery = em.createNativeQuery(selectSql, Tuple.class);
|
||||
Query countQuery = em.createNativeQuery(countSql, Integer.class);
|
||||
|
||||
if (request.getStartTime() != null) {
|
||||
selectQuery.setParameter("startTime", request.getStartTime());
|
||||
countQuery.setParameter("startTime", request.getStartTime());
|
||||
}
|
||||
|
||||
if (request.getEndTime() != null) {
|
||||
selectQuery.setParameter("endTime", request.getEndTime());
|
||||
countQuery.setParameter("endTime", request.getEndTime());
|
||||
}
|
||||
|
||||
|
||||
if (StringUtils.isNotEmpty(request.getPlateNo())) {
|
||||
selectQuery.setParameter("plateNo", "%" + request.getPlateNo() + "%");
|
||||
countQuery.setParameter("plateNo", "%" + request.getPlateNo() + "%");
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(request.getSendOrganization())) {
|
||||
selectQuery.setParameter("sendOrganization", "%" + request.getSendOrganization() + "%");
|
||||
countQuery.setParameter("sendOrganization", "%" + request.getSendOrganization() + "%");
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(request.getReceiveOrganization())) {
|
||||
selectQuery.setParameter("receiveOrganization", "%" + request.getReceiveOrganization() + "%");
|
||||
countQuery.setParameter("receiveOrganization", "%" + request.getReceiveOrganization() + "%");
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(request.getGoods())) {
|
||||
|
||||
selectQuery.setParameter("goods", "%" + request.getGoods() + "%");
|
||||
countQuery.setParameter("goods", "%" + request.getGoods() + "%");
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(request.getSpecification())) {
|
||||
selectQuery.setParameter("specification", "%" + request.getSpecification() + "%");
|
||||
countQuery.setParameter("specification", "%" + request.getSpecification() + "%");
|
||||
}
|
||||
|
||||
|
||||
var resultList = JpaUtils.convertTuplesToMap(selectQuery.getResultList());
|
||||
|
||||
var ans =
|
||||
resultList.stream()
|
||||
.map(
|
||||
x ->
|
||||
((Map) x)
|
||||
.entrySet().stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
(Map.Entry e) ->
|
||||
CaseFormat
|
||||
.LOWER_UNDERSCORE
|
||||
.to(
|
||||
CaseFormat
|
||||
.LOWER_CAMEL,
|
||||
e.getKey()
|
||||
.toString()),
|
||||
e -> e.getValue())))
|
||||
.toList();
|
||||
|
||||
|
||||
|
||||
return new PageImpl<>(ans, PageRequest.of(0, request.getPageSize()), Integer.parseInt(countQuery.getSingleResult().toString()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.weightDeviceSupplier.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.OrgScope;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.dto.CreateWeightDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.dto.UpdateWeightDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.dto.WeightDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.service.WeightDeviceSupplierService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/weightDeviceSupplier")
|
||||
@SysLog(module = "地磅厂家")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class WeightDeviceSupplierController {
|
||||
@Autowired private WeightDeviceSupplierService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public WeightDeviceSupplierDto create(@RequestBody CreateWeightDeviceSupplierDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public WeightDeviceSupplierDto update(@RequestBody UpdateWeightDeviceSupplierDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public WeightDeviceSupplierDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<WeightDeviceSupplierDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.lihongjie.coal.weightDeviceSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateWeightDeviceSupplierDto extends OrgCommonDto {
|
||||
private String contact;
|
||||
|
||||
private String contactPhone;
|
||||
|
||||
private String address;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.lihongjie.coal.weightDeviceSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateWeightDeviceSupplierDto extends OrgCommonDto {
|
||||
private String contact;
|
||||
|
||||
private String contactPhone;
|
||||
|
||||
private String address;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.lihongjie.coal.weightDeviceSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WeightDeviceSupplierDto extends OrgCommonDto {
|
||||
|
||||
private String contact;
|
||||
|
||||
private String contactPhone;
|
||||
|
||||
private String address;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.lihongjie.coal.weightDeviceSupplier.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class WeightDeviceSupplierEntity extends OrgCommonEntity {
|
||||
|
||||
private String contact;
|
||||
|
||||
private String contactPhone;
|
||||
|
||||
private String address;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.weightDeviceSupplier.mapper;
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonEntityMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.dto.CreateWeightDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.dto.UpdateWeightDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.dto.WeightDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.entity.WeightDeviceSupplierEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class, CommonEntityMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface WeightDeviceSupplierMapper
|
||||
extends BaseMapper<
|
||||
WeightDeviceSupplierEntity,
|
||||
WeightDeviceSupplierDto,
|
||||
CreateWeightDeviceSupplierDto,
|
||||
UpdateWeightDeviceSupplierDto> {}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.lihongjie.coal.weightDeviceSupplier.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.entity.WeightDeviceSupplierEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WeightDeviceSupplierRepository
|
||||
extends BaseRepository<WeightDeviceSupplierEntity> {}
|
||||
@@ -0,0 +1,74 @@
|
||||
package cn.lihongjie.coal.weightDeviceSupplier.service;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.dto.CreateWeightDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.dto.UpdateWeightDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.dto.WeightDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.entity.WeightDeviceSupplierEntity;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.mapper.WeightDeviceSupplierMapper;
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.repository.WeightDeviceSupplierRepository;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
public class WeightDeviceSupplierService
|
||||
extends BaseService<WeightDeviceSupplierEntity, WeightDeviceSupplierRepository> {
|
||||
@Autowired private WeightDeviceSupplierRepository repository;
|
||||
|
||||
@Autowired private WeightDeviceSupplierMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public WeightDeviceSupplierDto create(CreateWeightDeviceSupplierDto request) {
|
||||
WeightDeviceSupplierEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public WeightDeviceSupplierDto update(UpdateWeightDeviceSupplierDto request) {
|
||||
WeightDeviceSupplierEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public WeightDeviceSupplierDto getById(String id) {
|
||||
WeightDeviceSupplierEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<WeightDeviceSupplierDto> list(CommonQuery query) {
|
||||
Page<WeightDeviceSupplierEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.weightDeviceData.controller.WeightDeviceDataController
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(WeightDeviceDataController.class)
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(new CommonQuery())
|
||||
|
||||
|
||||
17
src/main/resources/scripts/dict/enum/weightDeviceDict.groovy
Normal file
17
src/main/resources/scripts/dict/enum/weightDeviceDict.groovy
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.weightDevice.controller.WeightDeviceController
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(WeightDeviceController.class)
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(new CommonQuery())
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.weightDeviceSupplier.controller.WeightDeviceSupplierController
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(WeightDeviceSupplierController.class)
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(new CommonQuery())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user