初始代码
This commit is contained in:
94
yawei-mes/yjh-mes/pom.xml
Normal file
94
yawei-mes/yjh-mes/pom.xml
Normal file
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>mes</artifactId>
|
||||
<groupId>cn.sourceplan</groupId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yjh-mes</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>cn.sourceplan</groupId>
|
||||
<artifactId>mes-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.jimureport</groupId>
|
||||
<artifactId>jimureport-spring-boot-starter</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- 积木BI依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.jimureport</groupId>
|
||||
<artifactId>jimubi-spring-boot-starter</artifactId>
|
||||
<version>2.1.4</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- 显式引入 fastjson 1.x(积木报表需要)-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.sourceplan</groupId>
|
||||
<artifactId>mes-system</artifactId>
|
||||
</dependency>
|
||||
<!--MQTT依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-stream</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-integration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-mqtt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>2.0.29</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,109 @@
|
||||
package cn.sourceplan.barcode.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.sourceplan.common.annotation.Log;
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.enums.BusinessType;
|
||||
import cn.sourceplan.barcode.domain.BarcodeRecord;
|
||||
import cn.sourceplan.barcode.service.IBarcodeRecordService;
|
||||
import cn.sourceplan.common.utils.poi.ExcelUtil;
|
||||
import cn.sourceplan.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 条码生成记录Controller
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-04-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/barcode/barcodeRecord")
|
||||
public class BarcodeRecordController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IBarcodeRecordService barcodeRecordService;
|
||||
|
||||
/**
|
||||
* 查询条码生成记录列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(BarcodeRecord barcodeRecord)
|
||||
{
|
||||
startPage();
|
||||
List<BarcodeRecord> list = barcodeRecordService.selectBarcodeRecordList(barcodeRecord);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出条码生成记录列表
|
||||
*/
|
||||
@Log(title = "条码生成记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, BarcodeRecord barcodeRecord)
|
||||
{
|
||||
List<BarcodeRecord> list = barcodeRecordService.selectBarcodeRecordList(barcodeRecord);
|
||||
ExcelUtil<BarcodeRecord> util = new ExcelUtil<BarcodeRecord>(BarcodeRecord.class);
|
||||
util.exportExcel(response, list, "条码生成记录数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取条码生成记录详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(barcodeRecordService.selectBarcodeRecordById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成条码
|
||||
*/
|
||||
@Log(title = "条码生成记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody BarcodeRecord barcodeRecord)
|
||||
{
|
||||
return toAjax(barcodeRecordService.insertBarcodeRecord(barcodeRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改条码生成记录
|
||||
*/
|
||||
@Log(title = "条码生成记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody BarcodeRecord barcodeRecord)
|
||||
{
|
||||
return toAjax(barcodeRecordService.updateBarcodeRecord(barcodeRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除条码生成记录
|
||||
*/
|
||||
@Log(title = "条码生成记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(barcodeRecordService.deleteBarcodeRecordByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印成功后次数加1
|
||||
*/
|
||||
@PostMapping(value = "/printAdd")
|
||||
public void callback(@RequestBody JSONObject json) {
|
||||
System.out.println("===================记录打印次数====================");
|
||||
System.out.println(json.toJSONString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package cn.sourceplan.barcode.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.sourceplan.common.annotation.Log;
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.enums.BusinessType;
|
||||
import cn.sourceplan.barcode.domain.MaterialSn;
|
||||
import cn.sourceplan.barcode.service.IMaterialSnService;
|
||||
import cn.sourceplan.common.utils.poi.ExcelUtil;
|
||||
import cn.sourceplan.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 物料SN码Controller
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-04-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/barcode/materialSn")
|
||||
public class MaterialSnController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IMaterialSnService materialSnService;
|
||||
|
||||
/**
|
||||
* 查询物料SN码列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(MaterialSn materialSn)
|
||||
{
|
||||
startPage();
|
||||
List<MaterialSn> list = materialSnService.selectMaterialSnList(materialSn);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出物料SN码列表
|
||||
*/
|
||||
@Log(title = "物料SN码", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, MaterialSn materialSn)
|
||||
{
|
||||
List<MaterialSn> list = materialSnService.selectMaterialSnList(materialSn);
|
||||
ExcelUtil<MaterialSn> util = new ExcelUtil<MaterialSn>(MaterialSn.class);
|
||||
util.exportExcel(response, list, "物料SN码数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物料SN码详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(materialSnService.selectMaterialSnById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物料SN码
|
||||
*/
|
||||
@Log(title = "物料SN码", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody MaterialSn materialSn)
|
||||
{
|
||||
return toAjax(materialSnService.insertMaterialSn(materialSn));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物料SN码
|
||||
*/
|
||||
@Log(title = "物料SN码", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody MaterialSn materialSn)
|
||||
{
|
||||
return toAjax(materialSnService.updateMaterialSn(materialSn));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除物料SN码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('barcode:materialSn:remove')")
|
||||
@Log(title = "物料SN码", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(materialSnService.deleteMaterialSnByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package cn.sourceplan.barcode.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import cn.sourceplan.common.annotation.Excel;
|
||||
import cn.sourceplan.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 条码生成记录对象 wm_barcode_record
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-04-15
|
||||
*/
|
||||
@Data
|
||||
@TableName("wm_barcode_record")
|
||||
public class BarcodeRecord extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
@TableId(type= IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 条码格式 */
|
||||
private String format;
|
||||
|
||||
/** 条码类型 */
|
||||
@Excel(name = "条码类型")
|
||||
private String type;
|
||||
|
||||
/** 类型ID */
|
||||
private Long typeId;
|
||||
|
||||
/** 类型编号 */
|
||||
@Excel(name = "类型编号")
|
||||
private String typeNumber;
|
||||
|
||||
/** 类型名称 */
|
||||
@Excel(name = "类型名称")
|
||||
private String typeName;
|
||||
|
||||
/** 编码规则ID */
|
||||
private Long codeRuleId;
|
||||
|
||||
/** 生成数量 */
|
||||
@Excel(name = "生成数量")
|
||||
private Long quantity;
|
||||
|
||||
/** 条码区间 */
|
||||
@Excel(name = "条码区间")
|
||||
@TableField("`INTERVAL`")
|
||||
private String interval;
|
||||
|
||||
/** 参数 */
|
||||
private String parameter;
|
||||
|
||||
/** 打印次数 */
|
||||
private Integer printCount;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.sourceplan.barcode.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import cn.sourceplan.common.annotation.Excel;
|
||||
import cn.sourceplan.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 物料SN码对象 wm_material_sn
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-04-15
|
||||
*/
|
||||
@Data
|
||||
@TableName("wm_material_sn")
|
||||
public class MaterialSn extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
@TableId(type= IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 条码生成ID */
|
||||
private Long mainId;
|
||||
|
||||
/** SN码 */
|
||||
@Excel(name = "SN码")
|
||||
private String snCode;
|
||||
|
||||
/** 物料ID */
|
||||
private Long materialId;
|
||||
|
||||
/** 物料编号 */
|
||||
@Excel(name = "物料编号")
|
||||
private String materialNumber;
|
||||
|
||||
/** 物料名称 */
|
||||
@Excel(name = "物料名称")
|
||||
private String materialName;
|
||||
|
||||
/** 规格型号 */
|
||||
private String specification;
|
||||
|
||||
/** 单位名称 */
|
||||
@Excel(name = "单位名称")
|
||||
private String materialUnitName;
|
||||
|
||||
/** 批次编号 */
|
||||
@Excel(name = "批次编号")
|
||||
private String batchNumber;
|
||||
|
||||
/** 条码内容 */
|
||||
@Excel(name = "条码内容")
|
||||
private String content;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.sourceplan.barcode.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.sourceplan.barcode.domain.BarcodeRecord;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 条码生成记录Mapper接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-04-15
|
||||
*/
|
||||
@Repository
|
||||
public interface BarcodeRecordMapper extends BaseMapper<BarcodeRecord>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.sourceplan.barcode.mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.sourceplan.barcode.domain.MaterialSn;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 物料SN码Mapper接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-04-15
|
||||
*/
|
||||
@Repository
|
||||
public interface MaterialSnMapper extends BaseMapper<MaterialSn>
|
||||
{
|
||||
/**
|
||||
* 批量插入 仅适用于mysql
|
||||
* @param entityList 实体列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
Integer insertBatchSomeColumn(Collection<MaterialSn> entityList);
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新
|
||||
* @param map 参数
|
||||
* @return 影响行数
|
||||
*/
|
||||
Integer updateBatchSomeColumn(@Param("map") Map<String,Object> map);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.sourceplan.barcode.service;
|
||||
|
||||
import java.util.List;
|
||||
import cn.sourceplan.barcode.domain.BarcodeRecord;
|
||||
|
||||
/**
|
||||
* 条码生成记录Service接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-04-15
|
||||
*/
|
||||
public interface IBarcodeRecordService
|
||||
{
|
||||
/**
|
||||
* 查询条码生成记录
|
||||
*
|
||||
* @param id 条码生成记录主键
|
||||
* @return 条码生成记录
|
||||
*/
|
||||
public BarcodeRecord selectBarcodeRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 查询条码生成记录列表
|
||||
*
|
||||
* @param barcodeRecord 条码生成记录
|
||||
* @return 条码生成记录集合
|
||||
*/
|
||||
public List<BarcodeRecord> selectBarcodeRecordList(BarcodeRecord barcodeRecord);
|
||||
|
||||
/**
|
||||
* 新增条码生成记录
|
||||
*
|
||||
* @param barcodeRecord 条码生成记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertBarcodeRecord(BarcodeRecord barcodeRecord);
|
||||
|
||||
/**
|
||||
* 修改条码生成记录
|
||||
*
|
||||
* @param barcodeRecord 条码生成记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateBarcodeRecord(BarcodeRecord barcodeRecord);
|
||||
|
||||
/**
|
||||
* 批量删除条码生成记录
|
||||
*
|
||||
* @param ids 需要删除的条码生成记录主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBarcodeRecordByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除条码生成记录信息
|
||||
*
|
||||
* @param id 条码生成记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBarcodeRecordById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.sourceplan.barcode.service;
|
||||
|
||||
import java.util.List;
|
||||
import cn.sourceplan.barcode.domain.MaterialSn;
|
||||
|
||||
/**
|
||||
* 物料SN码Service接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-04-15
|
||||
*/
|
||||
public interface IMaterialSnService
|
||||
{
|
||||
/**
|
||||
* 查询物料SN码
|
||||
*
|
||||
* @param id 物料SN码主键
|
||||
* @return 物料SN码
|
||||
*/
|
||||
public MaterialSn selectMaterialSnById(Long id);
|
||||
|
||||
/**
|
||||
* 查询物料SN码列表
|
||||
*
|
||||
* @param materialSn 物料SN码
|
||||
* @return 物料SN码集合
|
||||
*/
|
||||
public List<MaterialSn> selectMaterialSnList(MaterialSn materialSn);
|
||||
|
||||
/**
|
||||
* 新增物料SN码
|
||||
*
|
||||
* @param materialSn 物料SN码
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMaterialSn(MaterialSn materialSn);
|
||||
|
||||
/**
|
||||
* 修改物料SN码
|
||||
*
|
||||
* @param materialSn 物料SN码
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMaterialSn(MaterialSn materialSn);
|
||||
|
||||
/**
|
||||
* 批量删除物料SN码
|
||||
*
|
||||
* @param ids 需要删除的物料SN码主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMaterialSnByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除物料SN码信息
|
||||
*
|
||||
* @param id 物料SN码主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMaterialSnById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package cn.sourceplan.barcode.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.sourceplan.barcode.domain.MaterialSn;
|
||||
import cn.sourceplan.barcode.mapper.MaterialSnMapper;
|
||||
import cn.sourceplan.common.domain.SysCodeRule;
|
||||
import cn.sourceplan.common.service.ISysCodeRuleService;
|
||||
import cn.sourceplan.masterdata.domain.Material;
|
||||
import cn.sourceplan.masterdata.domain.Unit;
|
||||
import cn.sourceplan.masterdata.mapper.MaterialMapper;
|
||||
import cn.sourceplan.masterdata.mapper.UnitMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.sourceplan.barcode.mapper.BarcodeRecordMapper;
|
||||
import cn.sourceplan.barcode.domain.BarcodeRecord;
|
||||
import cn.sourceplan.barcode.service.IBarcodeRecordService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 条码生成记录Service业务层处理
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-04-15
|
||||
*/
|
||||
@Service
|
||||
public class BarcodeRecordServiceImpl implements IBarcodeRecordService
|
||||
{
|
||||
@Autowired
|
||||
private BarcodeRecordMapper barcodeRecordMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysCodeRuleService sysCodeRuleService;
|
||||
|
||||
@Autowired
|
||||
private MaterialSnMapper materialSnMapper;
|
||||
|
||||
@Autowired
|
||||
private MaterialMapper materialMapper;
|
||||
|
||||
@Autowired
|
||||
private UnitMapper unitMapper;
|
||||
|
||||
/**
|
||||
* 查询条码生成记录
|
||||
*
|
||||
* @param id 条码生成记录主键
|
||||
* @return 条码生成记录
|
||||
*/
|
||||
@Override
|
||||
public BarcodeRecord selectBarcodeRecordById(Long id)
|
||||
{
|
||||
|
||||
return barcodeRecordMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询条码生成记录列表
|
||||
*
|
||||
* @param barcodeRecord 条码生成记录
|
||||
* @return 条码生成记录
|
||||
*/
|
||||
@Override
|
||||
public List<BarcodeRecord> selectBarcodeRecordList(BarcodeRecord barcodeRecord)
|
||||
{
|
||||
QueryWrapper<BarcodeRecord> qw = new QueryWrapper<>(barcodeRecord);
|
||||
return barcodeRecordMapper.selectList(qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增条码生成记录
|
||||
*
|
||||
* @param barcodeRecord 条码生成记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertBarcodeRecord(BarcodeRecord barcodeRecord)
|
||||
{
|
||||
int insert=0;
|
||||
if("materialSN".equals(barcodeRecord.getType())){
|
||||
//封装List
|
||||
List<MaterialSn> materialList = new ArrayList<>();
|
||||
//批量生成物理SN码
|
||||
Long qSize = barcodeRecord.getQuantity();
|
||||
SysCodeRule queryDomain = new SysCodeRule();
|
||||
queryDomain.setBasicDomain("materialSN");
|
||||
List<SysCodeRule> sysCodeRules = sysCodeRuleService.selectSysCodeRuleList(queryDomain);
|
||||
MaterialSn materialSn = new MaterialSn();
|
||||
Material material = materialMapper.selectById(barcodeRecord.getTypeId());
|
||||
materialSn.setMaterialId(material.getId());
|
||||
materialSn.setMaterialName(material.getName());
|
||||
materialSn.setMaterialNumber(material.getNumber());
|
||||
Unit unit = unitMapper.selectById(material.getUnitId());
|
||||
materialSn.setMaterialUnitName(unit.getName());
|
||||
//拿到条码生成参数中的 批次号
|
||||
String parameter = barcodeRecord.getParameter();
|
||||
JSONObject jsonObject = JSONObject.parseObject(parameter);
|
||||
if(jsonObject!=null){
|
||||
String batchNumber = (String) jsonObject.get("batchNumber");
|
||||
materialSn.setBatchNumber(batchNumber);
|
||||
}
|
||||
insert = barcodeRecordMapper.insert(barcodeRecord);
|
||||
materialSn.setMainId( barcodeRecord.getId() );
|
||||
String interval = "";
|
||||
for (int i = 0; i < qSize; i++) {
|
||||
MaterialSn materialSnTmp = new MaterialSn();
|
||||
BeanUtils.copyProperties(materialSn,materialSnTmp);
|
||||
String number = sysCodeRuleService.queryNewCodeById(sysCodeRules.get(0).getId(),true,barcodeRecord.getTypeId());
|
||||
materialSnTmp.setSnCode(number);
|
||||
//获取本次SN码区间
|
||||
if(i==0){
|
||||
interval+=number+" 至 ";
|
||||
}
|
||||
if(i==qSize-1){
|
||||
interval+=number;
|
||||
}
|
||||
materialList.add(materialSnTmp);
|
||||
}
|
||||
//批量插入
|
||||
materialSnMapper.insertBatchSomeColumn(materialList);
|
||||
barcodeRecord.setInterval(interval);
|
||||
}
|
||||
return insert;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改条码生成记录
|
||||
*
|
||||
* @param barcodeRecord 条码生成记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateBarcodeRecord(BarcodeRecord barcodeRecord)
|
||||
{
|
||||
return barcodeRecordMapper.updateById(barcodeRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除条码生成记录
|
||||
*
|
||||
* @param ids 需要删除的条码生成记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteBarcodeRecordByIds(Long[] ids)
|
||||
{
|
||||
|
||||
return barcodeRecordMapper.deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除条码生成记录信息
|
||||
*
|
||||
* @param id 条码生成记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteBarcodeRecordById(Long id)
|
||||
{
|
||||
return barcodeRecordMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package cn.sourceplan.barcode.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.sourceplan.barcode.mapper.MaterialSnMapper;
|
||||
import cn.sourceplan.barcode.domain.MaterialSn;
|
||||
import cn.sourceplan.barcode.service.IMaterialSnService;
|
||||
|
||||
/**
|
||||
* 物料SN码Service业务层处理
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-04-15
|
||||
*/
|
||||
@Service
|
||||
public class MaterialSnServiceImpl implements IMaterialSnService
|
||||
{
|
||||
@Autowired
|
||||
private MaterialSnMapper materialSnMapper;
|
||||
|
||||
/**
|
||||
* 查询物料SN码
|
||||
*
|
||||
* @param id 物料SN码主键
|
||||
* @return 物料SN码
|
||||
*/
|
||||
@Override
|
||||
public MaterialSn selectMaterialSnById(Long id)
|
||||
{
|
||||
return materialSnMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物料SN码列表
|
||||
*
|
||||
* @param materialSn 物料SN码
|
||||
* @return 物料SN码
|
||||
*/
|
||||
@Override
|
||||
public List<MaterialSn> selectMaterialSnList(MaterialSn materialSn)
|
||||
{
|
||||
QueryWrapper<MaterialSn> qw = new QueryWrapper<>(materialSn);
|
||||
return materialSnMapper.selectList(qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物料SN码
|
||||
*
|
||||
* @param materialSn 物料SN码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertMaterialSn(MaterialSn materialSn)
|
||||
{
|
||||
return materialSnMapper.insert(materialSn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物料SN码
|
||||
*
|
||||
* @param materialSn 物料SN码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMaterialSn(MaterialSn materialSn)
|
||||
{
|
||||
return materialSnMapper.updateById(materialSn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除物料SN码
|
||||
*
|
||||
* @param ids 需要删除的物料SN码主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMaterialSnByIds(Long[] ids)
|
||||
{
|
||||
return materialSnMapper.deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除物料SN码信息
|
||||
*
|
||||
* @param id 物料SN码主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMaterialSnById(Long id)
|
||||
{
|
||||
return materialSnMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.sourceplan.bean;
|
||||
//解析请求标识格式
|
||||
public class analysisIdentification {
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
private String identification;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getIdentification() {
|
||||
return identification;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setIdentification(String identification) {
|
||||
this.identification = identification;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package cn.sourceplan.bean;
|
||||
|
||||
import java.util.List;
|
||||
//更新请求数据格式
|
||||
public class identificationInfo {
|
||||
/**
|
||||
* prefix : 88.175.985
|
||||
* handle : 88.175.985/YAV712AD00020220920175819148000000000
|
||||
* templateVersion : YAV_FII
|
||||
* id : 1111
|
||||
* value : [{"data":{"format":"string","value":"10000000,1,姝︽眽浜氫负,20220920175819148,88.175.985/YAV712AD00020220920175819148000002326"},"index":"2000","type":"attribute"},{"data":{"format":"string","value":"2022骞?9鏈?1鏃?13:22:19.148,0.000000,0.000610,1,1,0,0"},"index":"2001","type":"yavData"},{"data":{"format":"string","value":"wangyaoqin,yavii123@,88.175.985,30"},"index":"2002","type":"param"}]
|
||||
*/
|
||||
private String prefix;
|
||||
private String handle;
|
||||
private String templateVersion;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
private String id;
|
||||
private List<ValueBean> value;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
public void setHandle(String handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public String getTemplateVersion() {
|
||||
return templateVersion;
|
||||
}
|
||||
|
||||
public void setTemplateVersion(String templateVersion) {
|
||||
this.templateVersion = templateVersion;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<ValueBean> getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(List<ValueBean> value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static class ValueBean {
|
||||
/**
|
||||
* data : {"format":"string","value":"10000000,1,姝︽眽浜氫负,20220920175819148,88.175.985/YAV712AD00020220920175819148000002326"}
|
||||
* index : 2000
|
||||
* type : attribute
|
||||
*/
|
||||
|
||||
private DataBean data;
|
||||
private String index;
|
||||
private String type;
|
||||
|
||||
public DataBean getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(DataBean data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(String index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static class DataBean {
|
||||
/**
|
||||
* format : string
|
||||
* value : 10000000,1,姝︽眽浜氫负,20220920175819148,88.175.985/YAV712AD00020220920175819148000002326
|
||||
*/
|
||||
|
||||
private String format;
|
||||
private String value;
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package cn.sourceplan.bean;
|
||||
|
||||
//import com.example.identification.bean.identificationInfo.ValueBean;
|
||||
|
||||
import java.util.List;
|
||||
//原标识格式
|
||||
public class oneIdentification {
|
||||
/**
|
||||
* prefix : 88.175.985
|
||||
* handle : 88.175.985/YAV712AD00020220920175819148000000000
|
||||
* templateVersion : YAV_FII
|
||||
* id : 1111
|
||||
* value : [{"data":{"format":"string","value":"10000000,1,姝︽眽浜氫负,20220920175819148,88.175.985/YAV712AD00020220920175819148000002326"},"index":"2000","type":"attribute"},{"data":{"format":"string","value":"2022骞?9鏈?1鏃?13:22:19.148,0.000000,0.000610,1,1,0,0"},"index":"2001","type":"yavData"},{"data":{"format":"string","value":"wangyaoqin,yavii123@,88.175.985,30"},"index":"2002","type":"param"}]
|
||||
*/
|
||||
private String prefix;
|
||||
private String handle;
|
||||
private String templateVersion;
|
||||
|
||||
private String id;
|
||||
private List<identificationInfo.ValueBean> value;
|
||||
|
||||
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
public void setHandle(String handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public String getTemplateVersion() {
|
||||
return templateVersion;
|
||||
}
|
||||
|
||||
public void setTemplateVersion(String templateVersion) {
|
||||
this.templateVersion = templateVersion;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<identificationInfo.ValueBean> getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(List<identificationInfo.ValueBean> value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package cn.sourceplan.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//解析返回全部数据格式
|
||||
public class returnAnalysisIdentification {
|
||||
|
||||
|
||||
/**
|
||||
* message : success
|
||||
* status : 1
|
||||
* data : {"prefix":"88.175.985","handle":"88.175.985/YAV712AD00020220920175819148000000000","templateVersion":"YAV_FII","value":[{"data":{"value":"88.175.000000/6tcuPPo8FMZ5nyHd9oeDDSW7ahLdPyjkggjKbyEyg18fhYcaf6prRoGvPv7X75Km"},"index":1000,"type":"TEMPLATE_ID"},{"data":{"value":"YAV_FII"},"index":1001,"type":"TEMPLATE"},{"data":{"value":"10000000,1,??????,20220920175819148,88.175.985/YAV712AD00020220920175819148000002326"},"index":2000,"type":"attribute"},{"data":{"value":"2022??9??1??13:22:19.148,0.000000,0.000610,1,1,0,0"},"index":2001,"type":"yavData"},{"data":{"value":"wangyaoqin,yavii123@,88.175.985,30"},"index":2002,"type":"param"}]}
|
||||
*/
|
||||
|
||||
private String message;
|
||||
private int status;
|
||||
private DataBeanX data;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public DataBeanX getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(DataBeanX data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static class DataBeanX {
|
||||
/**
|
||||
* prefix : 88.175.985
|
||||
* handle : 88.175.985/YAV712AD00020220920175819148000000000
|
||||
* templateVersion : YAV_FII
|
||||
* value : [{"data":{"value":"88.175.000000/6tcuPPo8FMZ5nyHd9oeDDSW7ahLdPyjkggjKbyEyg18fhYcaf6prRoGvPv7X75Km"},"index":1000,"type":"TEMPLATE_ID"},{"data":{"value":"YAV_FII"},"index":1001,"type":"TEMPLATE"},{"data":{"value":"10000000,1,??????,20220920175819148,88.175.985/YAV712AD00020220920175819148000002326"},"index":2000,"type":"attribute"},{"data":{"value":"2022??9??1??13:22:19.148,0.000000,0.000610,1,1,0,0"},"index":2001,"type":"yavData"},{"data":{"value":"wangyaoqin,yavii123@,88.175.985,30"},"index":2002,"type":"param"}]
|
||||
*/
|
||||
|
||||
private String prefix;
|
||||
private String handle;
|
||||
private String templateVersion;
|
||||
private List<ValueBean> value;
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
public void setHandle(String handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public String getTemplateVersion() {
|
||||
return templateVersion;
|
||||
}
|
||||
|
||||
public void setTemplateVersion(String templateVersion) {
|
||||
this.templateVersion = templateVersion;
|
||||
}
|
||||
|
||||
public List<ValueBean> getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(List<ValueBean> value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static class ValueBean {
|
||||
/**
|
||||
* data : {"value":"88.175.000000/6tcuPPo8FMZ5nyHd9oeDDSW7ahLdPyjkggjKbyEyg18fhYcaf6prRoGvPv7X75Km"}
|
||||
* index : 1000
|
||||
* type : TEMPLATE_ID
|
||||
*/
|
||||
|
||||
private DataBean data;
|
||||
private int index;
|
||||
private String type;
|
||||
|
||||
public DataBean getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(DataBean data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static class DataBean {
|
||||
/**
|
||||
* value : 88.175.000000/6tcuPPo8FMZ5nyHd9oeDDSW7ahLdPyjkggjKbyEyg18fhYcaf6prRoGvPv7X75Km
|
||||
*/
|
||||
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.sourceplan.bean;
|
||||
|
||||
public class status {
|
||||
|
||||
/**
|
||||
* message : success
|
||||
* status : 1
|
||||
* data : true
|
||||
*/
|
||||
|
||||
private String message;
|
||||
private int status;
|
||||
private Object data;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package cn.sourceplan.buy.controller;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.sourceplan.yavIdentfication.YAVIdentfication;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.sourceplan.common.annotation.Log;
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.enums.BusinessType;
|
||||
import cn.sourceplan.buy.domain.BuyOrder;
|
||||
import cn.sourceplan.buy.service.IBuyOrderService;
|
||||
import cn.sourceplan.common.utils.poi.ExcelUtil;
|
||||
import cn.sourceplan.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 采购订单Controller
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-08-30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/buy/buyOrder")
|
||||
public class BuyOrderController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IBuyOrderService buyOrderService;
|
||||
|
||||
/**
|
||||
* 查询采购订单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('buy:buyOrder:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(BuyOrder buyOrder)
|
||||
{
|
||||
startPage();
|
||||
List<BuyOrder> list = buyOrderService.selectBuyOrderList(buyOrder);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出采购订单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('buy:buyOrder:export')")
|
||||
@Log(title = "采购订单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, BuyOrder buyOrder)
|
||||
{
|
||||
List<BuyOrder> list = buyOrderService.selectBuyOrderList(buyOrder);
|
||||
ExcelUtil<BuyOrder> util = new ExcelUtil<BuyOrder>(BuyOrder.class);
|
||||
util.exportExcel(response, list, "采购订单数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取采购订单详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('buy:buyOrder:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(buyOrderService.selectBuyOrderById(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
|
||||
/**
|
||||
* 新增采购订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('buy:buyOrder:add')")
|
||||
@Log(title = "采购订单", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody BuyOrder buyOrder)
|
||||
{
|
||||
buyOrder.setCreateBy(getUsername());
|
||||
Map map = objectMapper.convertValue(buyOrder, Map.class);
|
||||
Map<Object, Object> objectObjectMap = new HashMap(map);
|
||||
YAVIdentfication.fatherAndSonIdentification(objectObjectMap);
|
||||
return toAjax(buyOrderService.insertBuyOrder(buyOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改采购订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('buy:buyOrder:edit')")
|
||||
@Log(title = "采购订单", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody BuyOrder buyOrder)
|
||||
{
|
||||
return toAjax(buyOrderService.updateBuyOrder(buyOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除采购订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('buy:buyOrder:remove')")
|
||||
@Log(title = "采购订单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(buyOrderService.deleteBuyOrderByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package cn.sourceplan.buy.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import cn.sourceplan.common.annotation.Excel;
|
||||
import cn.sourceplan.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 采购订单对象 buy_order
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-08-30
|
||||
*/
|
||||
@TableName("buy_order")
|
||||
@Data
|
||||
public class BuyOrder extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
@TableId(type= IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 单号 */
|
||||
@Excel(name = "单号")
|
||||
private String number;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
private String status;
|
||||
|
||||
/** 采购部门id */
|
||||
@Excel(name = "采购部门id")
|
||||
private Long deptId;
|
||||
|
||||
/** 采购部门 */
|
||||
@Excel(name = "采购部门")
|
||||
private String deptName;
|
||||
|
||||
/** 采购员id */
|
||||
@Excel(name = "采购员id")
|
||||
private Long userId;
|
||||
|
||||
/** 采购员 */
|
||||
@Excel(name = "采购员")
|
||||
private String userName;
|
||||
|
||||
/** 采购日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "采购日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date buyDate;
|
||||
|
||||
/** 供应商ID */
|
||||
@Excel(name = "供应商ID")
|
||||
private Long supplierId;
|
||||
|
||||
/** 供应商 */
|
||||
@Excel(name = "供应商")
|
||||
private String supplierName;
|
||||
|
||||
/** 审核人 */
|
||||
@Excel(name = "审核人")
|
||||
private String checker;
|
||||
|
||||
/** 金额 */
|
||||
@Excel(name = "金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
/** 采购订单明细信息 */
|
||||
private List<BuyOrderEntry> buyOrderEntryList;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package cn.sourceplan.buy.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import cn.sourceplan.common.annotation.Excel;
|
||||
import cn.sourceplan.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 采购订单明细对象 buy_order_entry
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-08-30
|
||||
*/
|
||||
@TableName("buy_order_entry")
|
||||
@Data
|
||||
public class BuyOrderEntry extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
@TableId(type= IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 排序 */
|
||||
@Excel(name = "排序")
|
||||
private Long sort;
|
||||
|
||||
|
||||
/** 紧急度 */
|
||||
@Excel(name = "紧急度")
|
||||
private Integer urgency;
|
||||
|
||||
/** 主表id */
|
||||
@Excel(name = "主表id")
|
||||
private Long mainId;
|
||||
|
||||
/** 物料id */
|
||||
@Excel(name = "物料id")
|
||||
private Long materialId;
|
||||
|
||||
/** 物料编号 */
|
||||
@Excel(name = "物料编号")
|
||||
private String materialNumber;
|
||||
|
||||
/** 物料名称 */
|
||||
@Excel(name = "物料名称")
|
||||
private String materialName;
|
||||
|
||||
/** 规格型号 */
|
||||
@Excel(name = "规格型号")
|
||||
private String materialSpecification;
|
||||
|
||||
/** 单位id */
|
||||
@Excel(name = "单位id")
|
||||
private Long unitId;
|
||||
|
||||
/** 单位名称 */
|
||||
@Excel(name = "单位名称")
|
||||
private String unitName;
|
||||
|
||||
/** 数量 */
|
||||
@Excel(name = "数量")
|
||||
private BigDecimal quantity;
|
||||
|
||||
/** 单价 */
|
||||
@Excel(name = "单价")
|
||||
private BigDecimal price;
|
||||
|
||||
/** 含税单价 */
|
||||
@Excel(name = "含税单价")
|
||||
private BigDecimal taxPrice;
|
||||
|
||||
/** 是否赠品 */
|
||||
@Excel(name = "是否赠品")
|
||||
private String isGift;
|
||||
|
||||
/** 税率 */
|
||||
@Excel(name = "税率")
|
||||
private Long taxRate;
|
||||
|
||||
/** 税额 */
|
||||
@Excel(name = "税额")
|
||||
private BigDecimal totalTax;
|
||||
|
||||
/** 金额 */
|
||||
@Excel(name = "金额")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
/** 价税合计 */
|
||||
@Excel(name = "价税合计")
|
||||
private BigDecimal totalTaxPrice;
|
||||
|
||||
/** 要货日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "要货日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date needDate;
|
||||
|
||||
/** 状态 */
|
||||
private String status;
|
||||
|
||||
/** 扩展字段 */
|
||||
@Excel(name = "扩展字段")
|
||||
private String extendField;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package cn.sourceplan.buy.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import cn.sourceplan.buy.domain.BuyOrder;
|
||||
import cn.sourceplan.buy.domain.BuyOrderEntry;
|
||||
|
||||
/**
|
||||
* 采购订单Mapper接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-08-30
|
||||
*/
|
||||
public interface BuyOrderMapper
|
||||
{
|
||||
/**
|
||||
* 查询采购订单
|
||||
*
|
||||
* @param id 采购订单主键
|
||||
* @return 采购订单
|
||||
*/
|
||||
public BuyOrder selectBuyOrderById(Long id);
|
||||
|
||||
/**
|
||||
* 查询采购订单列表
|
||||
*
|
||||
* @param buyOrder 采购订单
|
||||
* @return 采购订单集合
|
||||
*/
|
||||
public List<BuyOrder> selectBuyOrderList(BuyOrder buyOrder);
|
||||
|
||||
/**
|
||||
* 新增采购订单
|
||||
*
|
||||
* @param buyOrder 采购订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertBuyOrder(BuyOrder buyOrder);
|
||||
|
||||
/**
|
||||
* 修改采购订单
|
||||
*
|
||||
* @param buyOrder 采购订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateBuyOrder(BuyOrder buyOrder);
|
||||
|
||||
/**
|
||||
* 删除采购订单
|
||||
*
|
||||
* @param id 采购订单主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBuyOrderById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除采购订单
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBuyOrderByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 批量删除采购订单明细
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBuyOrderEntryByMainIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 批量新增采购订单明细
|
||||
*
|
||||
* @param buyOrderEntryList 采购订单明细列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchBuyOrderEntry(List<BuyOrderEntry> buyOrderEntryList);
|
||||
|
||||
|
||||
/**
|
||||
* 通过采购订单主键删除采购订单明细信息
|
||||
*
|
||||
* @param id 采购订单ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBuyOrderEntryByMainId(Long id);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.sourceplan.buy.service;
|
||||
|
||||
import java.util.List;
|
||||
import cn.sourceplan.buy.domain.BuyOrder;
|
||||
|
||||
/**
|
||||
* 采购订单Service接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-08-30
|
||||
*/
|
||||
public interface IBuyOrderService
|
||||
{
|
||||
/**
|
||||
* 查询采购订单
|
||||
*
|
||||
* @param id 采购订单主键
|
||||
* @return 采购订单
|
||||
*/
|
||||
public BuyOrder selectBuyOrderById(Long id);
|
||||
|
||||
/**
|
||||
* 查询采购订单列表
|
||||
*
|
||||
* @param buyOrder 采购订单
|
||||
* @return 采购订单集合
|
||||
*/
|
||||
public List<BuyOrder> selectBuyOrderList(BuyOrder buyOrder);
|
||||
|
||||
/**
|
||||
* 新增采购订单
|
||||
*
|
||||
* @param buyOrder 采购订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertBuyOrder(BuyOrder buyOrder);
|
||||
|
||||
/**
|
||||
* 修改采购订单
|
||||
*
|
||||
* @param buyOrder 采购订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateBuyOrder(BuyOrder buyOrder);
|
||||
|
||||
/**
|
||||
* 批量删除采购订单
|
||||
*
|
||||
* @param ids 需要删除的采购订单主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBuyOrderByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除采购订单信息
|
||||
*
|
||||
* @param id 采购订单主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBuyOrderById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package cn.sourceplan.buy.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import cn.sourceplan.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import cn.sourceplan.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import cn.sourceplan.buy.domain.BuyOrderEntry;
|
||||
import cn.sourceplan.buy.mapper.BuyOrderMapper;
|
||||
import cn.sourceplan.buy.domain.BuyOrder;
|
||||
import cn.sourceplan.buy.service.IBuyOrderService;
|
||||
|
||||
/**
|
||||
* 采购订单Service业务层处理
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-08-30
|
||||
*/
|
||||
@Service
|
||||
public class BuyOrderServiceImpl implements IBuyOrderService
|
||||
{
|
||||
@Autowired
|
||||
private BuyOrderMapper buyOrderMapper;
|
||||
|
||||
/**
|
||||
* 查询采购订单
|
||||
*
|
||||
* @param id 采购订单主键
|
||||
* @return 采购订单
|
||||
*/
|
||||
@Override
|
||||
public BuyOrder selectBuyOrderById(Long id)
|
||||
{
|
||||
return buyOrderMapper.selectBuyOrderById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询采购订单列表
|
||||
*
|
||||
* @param buyOrder 采购订单
|
||||
* @return 采购订单
|
||||
*/
|
||||
@Override
|
||||
public List<BuyOrder> selectBuyOrderList(BuyOrder buyOrder)
|
||||
{
|
||||
return buyOrderMapper.selectBuyOrderList(buyOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增采购订单
|
||||
*
|
||||
* @param buyOrder 采购订单
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int insertBuyOrder(BuyOrder buyOrder)
|
||||
{
|
||||
buyOrder.setCreateTime(DateUtils.getNowDate());
|
||||
int rows = buyOrderMapper.insertBuyOrder(buyOrder);
|
||||
insertBuyOrderEntry(buyOrder);
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改采购订单
|
||||
*
|
||||
* @param buyOrder 采购订单
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int updateBuyOrder(BuyOrder buyOrder)
|
||||
{
|
||||
buyOrder.setUpdateTime(DateUtils.getNowDate());
|
||||
buyOrderMapper.deleteBuyOrderEntryByMainId(buyOrder.getId());
|
||||
insertBuyOrderEntry(buyOrder);
|
||||
return buyOrderMapper.updateBuyOrder(buyOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除采购订单
|
||||
*
|
||||
* @param ids 需要删除的采购订单主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteBuyOrderByIds(Long[] ids)
|
||||
{
|
||||
buyOrderMapper.deleteBuyOrderEntryByMainIds(ids);
|
||||
return buyOrderMapper.deleteBuyOrderByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除采购订单信息
|
||||
*
|
||||
* @param id 采购订单主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteBuyOrderById(Long id)
|
||||
{
|
||||
buyOrderMapper.deleteBuyOrderEntryByMainId(id);
|
||||
return buyOrderMapper.deleteBuyOrderById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增采购订单明细信息
|
||||
*
|
||||
* @param buyOrder 采购订单对象
|
||||
*/
|
||||
public void insertBuyOrderEntry(BuyOrder buyOrder)
|
||||
{
|
||||
List<BuyOrderEntry> buyOrderEntryList = buyOrder.getBuyOrderEntryList();
|
||||
Long id = buyOrder.getId();
|
||||
if (StringUtils.isNotNull(buyOrderEntryList))
|
||||
{
|
||||
List<BuyOrderEntry> list = new ArrayList<BuyOrderEntry>();
|
||||
for (BuyOrderEntry buyOrderEntry : buyOrderEntryList)
|
||||
{
|
||||
buyOrderEntry.setMainId(id);
|
||||
buyOrderEntry.setCreateBy(buyOrder.getCreateBy());
|
||||
buyOrderEntry.setCreateTime(DateUtils.getNowDate());
|
||||
list.add(buyOrderEntry);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
buyOrderMapper.batchBuyOrderEntry(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package cn.sourceplan.collection.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.sourceplan.common.annotation.Log;
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.enums.BusinessType;
|
||||
import cn.sourceplan.collection.domain.CollectionData;
|
||||
import cn.sourceplan.collection.service.ICollectionDataService;
|
||||
import cn.sourceplan.common.utils.poi.ExcelUtil;
|
||||
import cn.sourceplan.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 收集数据Controller
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/collection/data")
|
||||
public class CollectionDataController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICollectionDataService collectionDataService;
|
||||
|
||||
/**
|
||||
* 查询收集数据列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('collection:data:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CollectionData collectionData)
|
||||
{
|
||||
startPage();
|
||||
List<CollectionData> list = collectionDataService.selectCollectionDataList(collectionData);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出收集数据列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('collection:data:export')")
|
||||
@Log(title = "收集数据", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CollectionData collectionData)
|
||||
{
|
||||
List<CollectionData> list = collectionDataService.selectCollectionDataList(collectionData);
|
||||
ExcelUtil<CollectionData> util = new ExcelUtil<CollectionData>(CollectionData.class);
|
||||
util.exportExcel(response, list, "收集数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收集数据详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('collection:data:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(collectionDataService.selectCollectionDataById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增收集数据
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('collection:data:add')")
|
||||
@Log(title = "收集数据", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CollectionData collectionData)
|
||||
{
|
||||
return toAjax(collectionDataService.insertCollectionData(collectionData));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改收集数据
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('collection:data:edit')")
|
||||
@Log(title = "收集数据", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CollectionData collectionData)
|
||||
{
|
||||
return toAjax(collectionDataService.updateCollectionData(collectionData));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除收集数据
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('collection:data:remove')")
|
||||
@Log(title = "收集数据", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(collectionDataService.deleteCollectionDataByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package cn.sourceplan.collection.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import cn.sourceplan.common.annotation.Excel;
|
||||
import cn.sourceplan.common.core.domain.BaseEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 收集数据对象 mes_collection_data
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "mes_collection_data")
|
||||
public class CollectionData extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 收集数据ID */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 设备编号 */
|
||||
@Excel(name = "设备编号")
|
||||
@TableField(value = "device_code", condition = SqlCondition.LIKE)
|
||||
private String deviceCode;
|
||||
|
||||
/** 收集时间 */
|
||||
@Excel(name = "收集时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date collectTime;
|
||||
|
||||
/** 重量 */
|
||||
@Excel(name = "重量")
|
||||
private BigDecimal weight;
|
||||
|
||||
/** 物品ID */
|
||||
@Excel(name = "物品ID")
|
||||
private Long productId;
|
||||
|
||||
/** 物品名称 */
|
||||
@Excel(name = "物品名称")
|
||||
@TableField(value = "product_name", condition = SqlCondition.LIKE)
|
||||
private String productName;
|
||||
|
||||
/** 物品编码 */
|
||||
@Excel(name = "物品编码")
|
||||
@TableField(value = "product_code", condition = SqlCondition.LIKE)
|
||||
private String productCode;
|
||||
|
||||
/** 去皮重量 */
|
||||
@Excel(name = "去皮重量")
|
||||
private BigDecimal tareWeight;
|
||||
|
||||
/** 净重(重量-去皮) */
|
||||
@Excel(name = "净重")
|
||||
private BigDecimal netWeight;
|
||||
|
||||
/** 累计重量 */
|
||||
@Excel(name = "累计重量")
|
||||
private BigDecimal cumulativeWeight;
|
||||
|
||||
/** 累计次数 */
|
||||
@Excel(name = "累计次数")
|
||||
private Long cumulativeCount;
|
||||
|
||||
/** 订单号 */
|
||||
@Excel(name = "订单号")
|
||||
@TableField(value = "order_no", condition = SqlCondition.LIKE)
|
||||
private String orderNo;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package cn.sourceplan.collection.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.sourceplan.collection.domain.CollectionData;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收集数据Mapper接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Repository
|
||||
public interface CollectionDataMapper extends BaseMapper<CollectionData>
|
||||
{
|
||||
/**
|
||||
* 查询收集数据列表
|
||||
*
|
||||
* @param collectionData 收集数据
|
||||
* @return 收集数据集合
|
||||
*/
|
||||
List<CollectionData> selectCollectionDataList(CollectionData collectionData);
|
||||
|
||||
/**
|
||||
* 删除收集数据
|
||||
*
|
||||
* @param id 收集数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteCollectionDataById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除收集数据
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteCollectionDataByIds(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.sourceplan.collection.service;
|
||||
|
||||
import java.util.List;
|
||||
import cn.sourceplan.collection.domain.CollectionData;
|
||||
|
||||
/**
|
||||
* 收集数据Service接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface ICollectionDataService
|
||||
{
|
||||
/**
|
||||
* 查询收集数据
|
||||
*
|
||||
* @param id 收集数据主键
|
||||
* @return 收集数据
|
||||
*/
|
||||
CollectionData selectCollectionDataById(Long id);
|
||||
|
||||
/**
|
||||
* 查询收集数据列表
|
||||
*
|
||||
* @param collectionData 收集数据
|
||||
* @return 收集数据集合
|
||||
*/
|
||||
List<CollectionData> selectCollectionDataList(CollectionData collectionData);
|
||||
|
||||
/**
|
||||
* 新增收集数据
|
||||
*
|
||||
* @param collectionData 收集数据
|
||||
* @return 结果
|
||||
*/
|
||||
int insertCollectionData(CollectionData collectionData);
|
||||
|
||||
/**
|
||||
* 修改收集数据
|
||||
*
|
||||
* @param collectionData 收集数据
|
||||
* @return 结果
|
||||
*/
|
||||
int updateCollectionData(CollectionData collectionData);
|
||||
|
||||
/**
|
||||
* 批量删除收集数据
|
||||
*
|
||||
* @param ids 需要删除的收集数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteCollectionDataByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除收集数据信息
|
||||
*
|
||||
* @param id 收集数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteCollectionDataById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package cn.sourceplan.collection.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.sourceplan.common.utils.SecurityUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.sourceplan.collection.mapper.CollectionDataMapper;
|
||||
import cn.sourceplan.collection.domain.CollectionData;
|
||||
import cn.sourceplan.collection.service.ICollectionDataService;
|
||||
|
||||
/**
|
||||
* 收集数据Service业务层处理
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Service
|
||||
public class CollectionDataServiceImpl implements ICollectionDataService
|
||||
{
|
||||
@Autowired
|
||||
private CollectionDataMapper collectionDataMapper;
|
||||
|
||||
/**
|
||||
* 查询收集数据
|
||||
*
|
||||
* @param id 收集数据主键
|
||||
* @return 收集数据
|
||||
*/
|
||||
@Override
|
||||
public CollectionData selectCollectionDataById(Long id)
|
||||
{
|
||||
return collectionDataMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询收集数据列表
|
||||
*
|
||||
* @param collectionData 收集数据
|
||||
* @return 收集数据
|
||||
*/
|
||||
@Override
|
||||
public List<CollectionData> selectCollectionDataList(CollectionData collectionData)
|
||||
{
|
||||
return collectionDataMapper.selectCollectionDataList(collectionData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增收集数据
|
||||
*
|
||||
* @param collectionData 收集数据
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCollectionData(CollectionData collectionData)
|
||||
{
|
||||
// 自动计算净重
|
||||
if (collectionData.getWeight() != null) {
|
||||
BigDecimal tareWeight = collectionData.getTareWeight() != null ? collectionData.getTareWeight() : BigDecimal.ZERO;
|
||||
collectionData.setNetWeight(collectionData.getWeight().subtract(tareWeight));
|
||||
}
|
||||
|
||||
// 设置创建信息
|
||||
collectionData.setCreateTime(new Date());
|
||||
collectionData.setCreateBy(SecurityUtils.getUsername());
|
||||
|
||||
return collectionDataMapper.insert(collectionData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改收集数据
|
||||
*
|
||||
* @param collectionData 收集数据
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCollectionData(CollectionData collectionData)
|
||||
{
|
||||
// 自动计算净重
|
||||
if (collectionData.getWeight() != null) {
|
||||
BigDecimal tareWeight = collectionData.getTareWeight() != null ? collectionData.getTareWeight() : BigDecimal.ZERO;
|
||||
collectionData.setNetWeight(collectionData.getWeight().subtract(tareWeight));
|
||||
}
|
||||
|
||||
// 设置更新信息
|
||||
collectionData.setUpdateTime(new Date());
|
||||
collectionData.setUpdateBy(SecurityUtils.getUsername());
|
||||
|
||||
return collectionDataMapper.updateById(collectionData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除收集数据
|
||||
*
|
||||
* @param ids 需要删除的收集数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCollectionDataByIds(Long[] ids)
|
||||
{
|
||||
return collectionDataMapper.deleteCollectionDataByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除收集数据信息
|
||||
*
|
||||
* @param id 收集数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCollectionDataById(Long id)
|
||||
{
|
||||
return collectionDataMapper.deleteCollectionDataById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.sourceplan.common.config;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.*;
|
||||
import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
|
||||
import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 将 null 值序列化为空字符串的配置
|
||||
* 仅对指定的VO类生效
|
||||
*/
|
||||
@Configuration
|
||||
public class NullToEmptyStringSerializer {
|
||||
|
||||
// 需要将null转为空字符串的类
|
||||
private static final Set<String> TARGET_CLASSES = new HashSet<>();
|
||||
|
||||
static {
|
||||
// 销售订单执行情况相关
|
||||
TARGET_CLASSES.add("cn.sourceplan.statement.domain.vo.WorkOrderWithProcessVO");
|
||||
TARGET_CLASSES.add("cn.sourceplan.statement.domain.vo.ReportVO");
|
||||
TARGET_CLASSES.add("cn.sourceplan.statement.domain.vo.ProcessExecutionVO");
|
||||
// 工单详情(LabVIEW对接)
|
||||
TARGET_CLASSES.add("cn.sourceplan.statement.domain.vo.WorkOrderDetailVO");
|
||||
TARGET_CLASSES.add("cn.sourceplan.statement.domain.vo.WorkOrderDetailVO$ProcessDetailVO");
|
||||
TARGET_CLASSES.add("cn.sourceplan.statement.domain.vo.WorkOrderDetailVO$StationUserVO");
|
||||
// 报工质检单相关
|
||||
TARGET_CLASSES.add("cn.sourceplan.quality.domain.ReportQuality");
|
||||
TARGET_CLASSES.add("cn.sourceplan.quality.domain.ReportQualityEntry");
|
||||
TARGET_CLASSES.add("cn.sourceplan.quality.domain.ReportQualityReason");
|
||||
// 销售订单ID查询
|
||||
TARGET_CLASSES.add("cn.sourceplan.sale.domain.vo.SaleOrderIdsVO");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer nullToEmptyStringCustomizer() {
|
||||
return builder -> builder.postConfigurer(objectMapper -> {
|
||||
objectMapper.setSerializerFactory(
|
||||
objectMapper.getSerializerFactory()
|
||||
.withSerializerModifier(new NullToEmptyBeanSerializerModifier())
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private static class NullToEmptyBeanSerializerModifier extends BeanSerializerModifier {
|
||||
@Override
|
||||
public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
|
||||
BeanDescription beanDesc,
|
||||
List<BeanPropertyWriter> beanProperties) {
|
||||
String className = beanDesc.getBeanClass().getName();
|
||||
|
||||
// 只对目标类处理
|
||||
if (TARGET_CLASSES.contains(className)) {
|
||||
for (int i = 0; i < beanProperties.size(); i++) {
|
||||
BeanPropertyWriter writer = beanProperties.get(i);
|
||||
// 只对String类型的字段处理
|
||||
if (writer.getType().getRawClass() == String.class) {
|
||||
beanProperties.set(i, new NullToEmptyStringWriter(writer));
|
||||
}
|
||||
}
|
||||
}
|
||||
return beanProperties;
|
||||
}
|
||||
}
|
||||
|
||||
private static class NullToEmptyStringWriter extends BeanPropertyWriter {
|
||||
private final BeanPropertyWriter delegate;
|
||||
|
||||
public NullToEmptyStringWriter(BeanPropertyWriter delegate) {
|
||||
super(delegate);
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeAsField(Object bean, JsonGenerator gen, SerializerProvider prov) throws Exception {
|
||||
Object value = delegate.get(bean);
|
||||
if (value == null) {
|
||||
gen.writeStringField(delegate.getName(), "");
|
||||
} else {
|
||||
delegate.serializeAsField(bean, gen, prov);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.sourceplan.common.controller;
|
||||
|
||||
import cn.sourceplan.common.annotation.Log;
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.core.page.TableDataInfo;
|
||||
import cn.sourceplan.common.domain.SysCodeRule;
|
||||
import cn.sourceplan.common.enums.BusinessType;
|
||||
import cn.sourceplan.common.mapper.AppVersionMapper;
|
||||
import cn.sourceplan.common.service.ISysCodeRuleService;
|
||||
import cn.sourceplan.common.utils.poi.ExcelUtil;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP版本号
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-01-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/common/appVersion")
|
||||
public class AppVersionController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private AppVersionMapper appVersionMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询app当前版本号
|
||||
*/
|
||||
@GetMapping(value="/query")
|
||||
public AjaxResult query()
|
||||
{
|
||||
Double query = appVersionMapper.query();
|
||||
return AjaxResult.success(query);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package cn.sourceplan.common.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import cn.sourceplan.common.annotation.Log;
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.enums.BusinessType;
|
||||
import cn.sourceplan.common.identification.IdentificationConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 标识注册与解析配置Controller
|
||||
*
|
||||
* @author AI Assistant
|
||||
* @date 2026-04-01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/identification/config")
|
||||
public class IdentificationConfigController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IdentificationConfig identificationConfig;
|
||||
|
||||
/**
|
||||
* 获取崇仁二级节点配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:identification:config')")
|
||||
@GetMapping("/cr")
|
||||
public AjaxResult getCrConfig() {
|
||||
return AjaxResult.success(identificationConfig.getCrConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取萍乡二级节点配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:identification:config')")
|
||||
@GetMapping("/px")
|
||||
public AjaxResult getPxConfig() {
|
||||
return AjaxResult.success(identificationConfig.getPxConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存崇仁二级节点配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:identification:config')")
|
||||
@Log(title = "标识配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/cr")
|
||||
public AjaxResult saveCrConfig(@RequestBody JSONObject config) {
|
||||
// 目前只返回成功,实际保存逻辑需要根据系统架构调整
|
||||
return AjaxResult.success("保存成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存萍乡二级节点配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:identification:config')")
|
||||
@Log(title = "标识配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/px")
|
||||
public AjaxResult savePxConfig(@RequestBody JSONObject config) {
|
||||
// 目前只返回成功,实际保存逻辑需要根据系统架构调整
|
||||
return AjaxResult.success("保存成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package cn.sourceplan.common.controller;
|
||||
|
||||
import cn.sourceplan.common.annotation.Log;
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.enums.BusinessType;
|
||||
import cn.sourceplan.common.identification.IdentificationService;
|
||||
import cn.sourceplan.common.identification.bean.RequestInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 标识序列控制器
|
||||
* 用于创建新的子序列并在二级节点标识中查询序列信息
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/identification/sequence")
|
||||
public class IdentificationSequenceController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IdentificationService identificationService;
|
||||
|
||||
/**
|
||||
* 创建新的子序列(通用方法)
|
||||
* @param nodeType 节点类型(cr:崇仁,px:萍乡)
|
||||
* @param appCode 应用标识码(如P3-MES、P3-ATS、P3-IDS)
|
||||
* @param data 要写入的数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:identification:config')")
|
||||
@Log(title = "标识序列", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public AjaxResult createSubSequence(
|
||||
@RequestParam("nodeType") String nodeType,
|
||||
@RequestParam("appCode") String appCode,
|
||||
@RequestParam("data") String data) {
|
||||
try {
|
||||
// 直接调用Service的方法,传入三个参数
|
||||
identificationService.createSubSequence(nodeType, appCode, data);
|
||||
return AjaxResult.success("子序列创建成功");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("子序列创建失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建崇仁二级节点子序列
|
||||
* @param appCode 应用标识码(如P3-MES、P3-ATS、P3-IDS)
|
||||
* @param data 要写入的数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:identification:config')")
|
||||
@Log(title = "标识序列", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create/cr")
|
||||
public AjaxResult createCrSubSequence(
|
||||
@RequestParam("appCode") String appCode,
|
||||
@RequestParam("data") String data) {
|
||||
try {
|
||||
// 直接调用Service的方法,传入appCode和data
|
||||
identificationService.createCrSubSequence(appCode, data);
|
||||
return AjaxResult.success("崇仁二级节点子序列创建成功");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("崇仁二级节点子序列创建失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建萍乡二级节点子序列
|
||||
* @param appCode 应用标识码(如P3-MES、P3-ATS、P3-IDS)
|
||||
* @param data 要写入的数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:identification:config')")
|
||||
@Log(title = "标识序列", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create/px")
|
||||
public AjaxResult createPxSubSequence(
|
||||
@RequestParam("appCode") String appCode,
|
||||
@RequestParam("data") String data) {
|
||||
try {
|
||||
// 直接调用Service的方法,传入appCode和data
|
||||
identificationService.createPxSubSequence(appCode, data);
|
||||
return AjaxResult.success("萍乡二级节点子序列创建成功");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("萍乡二级节点子序列创建失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package cn.sourceplan.common.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.sourceplan.common.annotation.Log;
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.enums.BusinessType;
|
||||
import cn.sourceplan.common.domain.SysCodeRule;
|
||||
import cn.sourceplan.common.service.ISysCodeRuleService;
|
||||
import cn.sourceplan.common.utils.poi.ExcelUtil;
|
||||
import cn.sourceplan.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 编码规则Controller
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-01-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/common/sysCodeRule")
|
||||
public class SysCodeRuleController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysCodeRuleService sysCodeRuleService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询编码规则列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysCodeRule sysCodeRule)
|
||||
{
|
||||
startPage();
|
||||
List<SysCodeRule> list = sysCodeRuleService.selectSysCodeRuleList(sysCodeRule);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取/更新编码
|
||||
*/
|
||||
@GetMapping("/queryNewCodeById")
|
||||
public AjaxResult queryNewCodeById(Long codeRuleId,Boolean isUpdate){
|
||||
|
||||
String s = sysCodeRuleService.queryNewCodeById(codeRuleId, isUpdate);
|
||||
|
||||
return AjaxResult.success(s);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出编码规则列表
|
||||
*/
|
||||
@Log(title = "编码规则", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysCodeRule sysCodeRule)
|
||||
{
|
||||
List<SysCodeRule> list = sysCodeRuleService.selectSysCodeRuleList(sysCodeRule);
|
||||
ExcelUtil<SysCodeRule> util = new ExcelUtil<SysCodeRule>(SysCodeRule.class);
|
||||
util.exportExcel(response, list, "编码规则数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编码规则详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(sysCodeRuleService.selectSysCodeRuleById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增编码规则
|
||||
*/
|
||||
@Log(title = "编码规则", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysCodeRule sysCodeRule)
|
||||
{
|
||||
return toAjax(sysCodeRuleService.insertSysCodeRule(sysCodeRule));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改编码规则
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('common:sysCodeRule:edit')")
|
||||
@Log(title = "编码规则", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysCodeRule sysCodeRule)
|
||||
{
|
||||
return toAjax(sysCodeRuleService.updateSysCodeRule(sysCodeRule));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除编码规则
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('common:sysCodeRule:remove')")
|
||||
@Log(title = "编码规则", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(sysCodeRuleService.deleteSysCodeRuleByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package cn.sourceplan.common.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.sourceplan.common.utils.SecurityUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.sourceplan.common.annotation.Log;
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.enums.BusinessType;
|
||||
import cn.sourceplan.common.domain.SysUserStation;
|
||||
import cn.sourceplan.common.service.ISysUserStationService;
|
||||
import cn.sourceplan.common.utils.poi.ExcelUtil;
|
||||
import cn.sourceplan.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 用户工位绑定Controller
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-02-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/common/sysUserStation")
|
||||
public class SysUserStationController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysUserStationService sysUserStationService;
|
||||
|
||||
/**
|
||||
* 查询用户工位绑定列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysUserStation sysUserStation)
|
||||
{
|
||||
startPage();
|
||||
List<SysUserStation> list = sysUserStationService.selectSysUserStationList(sysUserStation);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前登录用户ID查询工位绑定信息
|
||||
*/
|
||||
@GetMapping("/getInfoByUserId")
|
||||
public AjaxResult getInfoByUserId()
|
||||
{
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
SysUserStation data = sysUserStationService.getInfoByUserId(userId);
|
||||
return AjaxResult.success(data) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出用户工位绑定列表
|
||||
*/
|
||||
@Log(title = "用户工位绑定", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysUserStation sysUserStation)
|
||||
{
|
||||
List<SysUserStation> list = sysUserStationService.selectSysUserStationList(sysUserStation);
|
||||
ExcelUtil<SysUserStation> util = new ExcelUtil<SysUserStation>(SysUserStation.class);
|
||||
util.exportExcel(response, list, "用户工位绑定数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户工位绑定详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{userId}")
|
||||
public AjaxResult getInfo(@PathVariable("userId") Long id)
|
||||
{
|
||||
return success(sysUserStationService.selectSysUserStationById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户工位绑定
|
||||
*/
|
||||
@Log(title = "用户工位绑定", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysUserStation sysUserStation)
|
||||
{
|
||||
return toAjax(sysUserStationService.insertSysUserStation(sysUserStation));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户工位绑定
|
||||
*/
|
||||
@Log(title = "用户工位绑定", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysUserStation sysUserStation)
|
||||
{
|
||||
return toAjax(sysUserStationService.updateSysUserStation(sysUserStation));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户工位绑定
|
||||
*/
|
||||
@Log(title = "用户工位绑定", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(sysUserStationService.deleteSysUserStationByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动端扫码绑定用户工位
|
||||
*/
|
||||
@Log(title = "移动端扫码绑定用户工位", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/mobileBind")
|
||||
public AjaxResult mobileBindUserStation(@RequestBody SysUserStation sysUserStation)
|
||||
{
|
||||
return toAjax(sysUserStationService.mobileBindUserStation(sysUserStation));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据工位ID查询绑定的用户列表
|
||||
*/
|
||||
@GetMapping("/listByStationId/{stationId}")
|
||||
public AjaxResult listByStationId(@PathVariable("stationId") Long stationId)
|
||||
{
|
||||
List<SysUserStation> list = sysUserStationService.getUsersByStationId(stationId);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.sourceplan.common.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import cn.sourceplan.common.annotation.Excel;
|
||||
import cn.sourceplan.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 编码规则对象 sys_code_rule
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-01-17
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_code_rule")
|
||||
public class SysCodeRule extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
@TableId(type= IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 编号 */
|
||||
@Excel(name = "编号")
|
||||
private String number;
|
||||
|
||||
/** 名称 */
|
||||
@Excel(name = "名称")
|
||||
private String name;
|
||||
|
||||
/** 基础元素 */
|
||||
@Excel(name = "基础元素")
|
||||
private String basicDomain;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
private String status;
|
||||
|
||||
/** 编码规则子信息 */
|
||||
@TableField(exist = false)
|
||||
private List<SysCodeRuleEntry> sysCodeRuleEntryList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package cn.sourceplan.common.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import cn.sourceplan.common.annotation.Excel;
|
||||
import cn.sourceplan.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 编码规则子对象 sys_code_rule_entry
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-01-17
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_code_rule_entry")
|
||||
public class SysCodeRuleEntry
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
@TableId(type= IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 主表ID */
|
||||
@Excel(name = "主表ID")
|
||||
private Long ruleId;
|
||||
|
||||
/** 排序 */
|
||||
@Excel(name = "排序")
|
||||
private Long sort;
|
||||
|
||||
/** 类型ID */
|
||||
@Excel(name = "类型ID")
|
||||
private String typeId;
|
||||
|
||||
/** 流水长度 */
|
||||
@Excel(name = "流水长度")
|
||||
private Integer lengthFlow;
|
||||
|
||||
/** 流水号 */
|
||||
@Excel(name = "流水号")
|
||||
private Integer maxFlow;
|
||||
|
||||
/** 补位符 */
|
||||
@Excel(name = "补位符")
|
||||
private String codeCover;
|
||||
|
||||
/** 日期格式 */
|
||||
@Excel(name = "日期格式")
|
||||
private String dateFormat;
|
||||
|
||||
/** 常量 */
|
||||
@Excel(name = "常量")
|
||||
private String constantChar;
|
||||
|
||||
/** 元素键值 */
|
||||
@Excel(name = "元素键值")
|
||||
private String elementSourceTable;
|
||||
|
||||
/** 元素属性 */
|
||||
@Excel(name = "元素属性")
|
||||
private String sourceAttribute;
|
||||
|
||||
/** 元素ID */
|
||||
@Excel(name = "元素ID")
|
||||
private Long sourceValue;
|
||||
|
||||
/** 当前日期 */
|
||||
private String maxDate;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.sourceplan.common.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import cn.sourceplan.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author jinzhong
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_file_info")
|
||||
public class SysFileInfo {
|
||||
|
||||
@TableId(type= IdType.AUTO)
|
||||
private Long fileId ;
|
||||
private String filePath;
|
||||
private String fileName;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package cn.sourceplan.common.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import cn.sourceplan.common.annotation.Excel;
|
||||
import cn.sourceplan.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户工位绑定对象 sys_user_station
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-02-07
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "sys_user_station")
|
||||
public class SysUserStation
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
@TableId(type= IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 用户ID */
|
||||
@Excel(name = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
/** 用户名称 */
|
||||
@Excel(name = "用户名称")
|
||||
@TableField(condition = SqlCondition.LIKE)
|
||||
private String userName;
|
||||
|
||||
/** 用户昵称 */
|
||||
@Excel(name = "用户昵称")
|
||||
@TableField(condition = SqlCondition.LIKE)
|
||||
private String nickName;
|
||||
|
||||
/** 工位ID */
|
||||
@Excel(name = "工位ID")
|
||||
private Long stationId;
|
||||
|
||||
/** 工位名称 */
|
||||
@Excel(name = "工位名称")
|
||||
private String stationName;
|
||||
|
||||
/** 创建者 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/** 更新者 */
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/** 所属车间名称 */
|
||||
@Excel(name = "所属车间名称")
|
||||
@TableField(exist = false)
|
||||
private String workshopName;
|
||||
|
||||
/** 设备ID */
|
||||
private Long equipmentId;
|
||||
|
||||
/** 设备 */
|
||||
@Excel(name = "设备")
|
||||
private String equipmentName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.sourceplan.common.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author jinzhong
|
||||
*/
|
||||
@Repository
|
||||
public interface AppVersionMapper {
|
||||
|
||||
/**
|
||||
*
|
||||
* 查询当前app版本号
|
||||
* @return
|
||||
*/
|
||||
@Select("select version from sys_app_version")
|
||||
Double query();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.sourceplan.common.mapper;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author jinzhong
|
||||
*/
|
||||
@Repository
|
||||
public interface SqlCheckMapper {
|
||||
/**
|
||||
* 自定义查询语句
|
||||
* @param field 字段
|
||||
* @param tableName 数据库表名
|
||||
* @param whereSql 过滤条件
|
||||
* @return 是否有数据 true 校验通过 false 校验失败
|
||||
*/
|
||||
List<Map<String,String>> selectCheckField(@Param("field") String field, @Param("tableName") String tableName, @Param("whereSql") String whereSql);
|
||||
|
||||
/**
|
||||
* 自定义查询语句
|
||||
* @param tableName 数据库表名
|
||||
* @param whereSql 过滤条件
|
||||
* @return 是否有数据 true 校验通过 false 校验失败
|
||||
*/
|
||||
int selectCheckCount(@Param("tableName") String tableName, @Param("whereSql") String whereSql);
|
||||
|
||||
/**
|
||||
* 查询该表所有字段信息
|
||||
* 包括字段名,字段类型,字段说明
|
||||
* @param tableName 数据库名
|
||||
* @return 是否有数据 true 校验通过 false 校验失败
|
||||
*/
|
||||
List<Map<String,String>> getTableAllFiled(@Param("tableName")String tableName);
|
||||
|
||||
/**
|
||||
* 执行任意自定义sql
|
||||
* @param sql sql语句
|
||||
* @return
|
||||
*/
|
||||
Object executeCustomSql(@Param("sql")String sql);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.sourceplan.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.sourceplan.common.domain.SysCodeRuleEntry;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author jinzhong
|
||||
*/
|
||||
@Repository
|
||||
public interface SysCodeRuleEntryMapper extends BaseMapper<SysCodeRuleEntry> {
|
||||
|
||||
/**
|
||||
* 批量插入 仅适用于mysql
|
||||
* @param entityList 实体列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
Integer insertBatchSomeColumn(Collection<SysCodeRuleEntry> entityList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.sourceplan.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.sourceplan.common.domain.SysCodeRule;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 编码规则Mapper接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-01-17
|
||||
*/
|
||||
@Repository
|
||||
public interface SysCodeRuleMapper extends BaseMapper<SysCodeRule>
|
||||
{
|
||||
/**
|
||||
* 查询编码规则
|
||||
*
|
||||
* @param id 编码规则主键
|
||||
* @return 编码规则
|
||||
*/
|
||||
SysCodeRule selectSysCodeRuleById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除编码规则子
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysCodeRuleEntryByRuleIds(Long[] ids);
|
||||
|
||||
|
||||
/**
|
||||
* 通过编码规则主键删除编码规则子信息
|
||||
*
|
||||
* @param id 编码规则ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysCodeRuleEntryByRuleId(Long id);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.sourceplan.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.sourceplan.common.domain.SysFileInfo;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author jinzhong
|
||||
*/
|
||||
@Repository
|
||||
public interface SysFileInfoMapper extends BaseMapper<SysFileInfo> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.sourceplan.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.sourceplan.common.domain.SysUserStation;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户工位绑定Mapper接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-02-07
|
||||
*/
|
||||
@Repository
|
||||
public interface SysUserStationMapper extends BaseMapper<SysUserStation>
|
||||
{
|
||||
|
||||
/**
|
||||
* 批量删除用户工位绑定
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysUserStationByIds(Long[] ids);
|
||||
|
||||
|
||||
/**
|
||||
* 根据当前登录用户ID查询工位绑定信息
|
||||
*
|
||||
* @param userId userId
|
||||
* @return 结果
|
||||
*/
|
||||
SysUserStation getInfoByUserId(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 根据工位ID查询绑定的用户列表
|
||||
*
|
||||
* @param stationId 工位ID
|
||||
* @return 用户列表
|
||||
*/
|
||||
List<SysUserStation> getUsersByStationId(@Param("stationId") Long stationId);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package cn.sourceplan.common.mqtt;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.sourceplan.common.utils.StringUtils;
|
||||
import cn.sourceplan.equipment.domain.Equipment;
|
||||
import cn.sourceplan.equipment.mapper.EquipmentMapper;
|
||||
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
||||
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author jinzhong
|
||||
*/
|
||||
@Component
|
||||
public class MqttConsumerCallBack implements MqttCallback{
|
||||
|
||||
private static EquipmentMapper equipmentMapper;
|
||||
|
||||
@Autowired
|
||||
public void setEquipmentMapper(EquipmentMapper equipmentMapper) {
|
||||
MqttConsumerCallBack.equipmentMapper = equipmentMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户端断开连接的回调
|
||||
*/
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
System.out.println("与服务器断开连接,可重连");
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息到达的回调
|
||||
*/
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage message) {
|
||||
//返回的数据
|
||||
String s = String.format(new String( message.getPayload()));
|
||||
if(s.contains("cqs")){
|
||||
return;
|
||||
}
|
||||
System.out.println(String.format("接收消息主题 : %s",topic));
|
||||
//通过接收到的消息主题,查找对应的设备,修改对应设备的状态
|
||||
QueryWrapper<Equipment> qw = new QueryWrapper<>();
|
||||
qw.eq("iot_sn",topic);
|
||||
qw.orderByDesc("create_time","update_time");
|
||||
List<Equipment> equipmentList = equipmentMapper.selectList(qw);
|
||||
//找到符合条件的第一个
|
||||
Equipment equipment = equipmentList.get(0);
|
||||
//修改他的状态
|
||||
int iA = s.indexOf(":");
|
||||
String sA = s.substring(iA);
|
||||
int iB = sA.indexOf("}");
|
||||
s = sA.substring(1, iB);
|
||||
if("0".equals(s)){
|
||||
//灭灯
|
||||
equipment.setEquipmentStatus("A");
|
||||
}
|
||||
if("1".equals(s)){
|
||||
//红灯
|
||||
equipment.setEquipmentStatus("D");
|
||||
}
|
||||
if("2".equals(s)){
|
||||
//黄灯
|
||||
equipment.setEquipmentStatus("B");
|
||||
}
|
||||
if("3".equals(s)){
|
||||
//绿灯
|
||||
equipment.setEquipmentStatus("C");
|
||||
}
|
||||
equipmentMapper.updateById(equipment);
|
||||
//保存该记录
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("equipmentId",equipment.getId());
|
||||
String oldStatus= equipmentMapper.selectStatusRecord(map);
|
||||
//状态改变时再保存
|
||||
if(StringUtils.isBlank(oldStatus) || !oldStatus.equals(equipment.getEquipmentStatus())){
|
||||
map.put("equipmentNumber",equipment.getNumber());
|
||||
map.put("equipmentName",equipment.getName());
|
||||
map.put("stationName",equipment.getStationName());
|
||||
map.put("equipmentStatus",equipment.getEquipmentStatus());
|
||||
equipmentMapper.insertStatusRecord(map);
|
||||
}
|
||||
System.out.println(DateUtil.now()+" :"+s);
|
||||
// System.out.println(String.format("接收消息retained : %b",message.isRetained()));
|
||||
// System.out.println(String.format("接收消息Qos : %d",message.getQos()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息发布成功的回调
|
||||
*/
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
package cn.sourceplan.common.mqtt;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.sourceplan.equipment.domain.Equipment;
|
||||
import cn.sourceplan.equipment.mapper.EquipmentMapper;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jinzhong
|
||||
*/
|
||||
@Configuration
|
||||
public class MqttConsumerConfig {
|
||||
@Value("${spring.mqtt.username}")
|
||||
private String username;
|
||||
|
||||
@Value("${spring.mqtt.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.mqtt.url}")
|
||||
private String hostUrl;
|
||||
|
||||
@Value("${spring.mqtt.client.id}")
|
||||
private String clientId;
|
||||
|
||||
@Value("${spring.mqtt.default.topic}")
|
||||
private String defaultTopic;
|
||||
|
||||
@Autowired
|
||||
private EquipmentMapper equipmentMapper;
|
||||
|
||||
/**
|
||||
* 客户端对象
|
||||
*/
|
||||
private MqttClient client;
|
||||
|
||||
/**
|
||||
* 在bean初始化后连接到服务器
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户端连接服务端
|
||||
*/
|
||||
public void connect(){
|
||||
try {
|
||||
//创建MQTT客户端对象
|
||||
client = new MqttClient(hostUrl,clientId,new MemoryPersistence());
|
||||
//连接设置
|
||||
MqttConnectOptions options = new MqttConnectOptions();
|
||||
//是否清空session,设置为false表示服务器会保留客户端的连接记录,客户端重连之后能获取到服务器在客户端断开连接期间推送的消息
|
||||
//设置为true表示每次连接到服务端都是以新的身份
|
||||
options.setCleanSession(true);
|
||||
//设置连接用户名
|
||||
options.setUserName(username);
|
||||
//设置连接密码
|
||||
options.setPassword(password.toCharArray());
|
||||
//设置超时时间,单位为秒
|
||||
options.setConnectionTimeout(100);
|
||||
//设置心跳时间 单位为秒,表示服务器每隔1.5*20秒的时间向客户端发送心跳判断客户端是否在线
|
||||
options.setKeepAliveInterval(20);
|
||||
//设置遗嘱消息的话题,若客户端和服务器之间的连接意外断开,服务器将发布客户端的遗嘱信息
|
||||
options.setWill("willTopic",(clientId + "与服务器断开连接").getBytes(),0,false);
|
||||
//设置回调
|
||||
client.setCallback(new MqttConsumerCallBack());
|
||||
client.connect(options);
|
||||
//订阅主题
|
||||
//主题
|
||||
//查询设备列表中(启用状态)的所有序列号,进行订阅
|
||||
QueryWrapper<Equipment> qw = new QueryWrapper<>();
|
||||
qw.eq("status","0");
|
||||
qw.isNotNull("iot_sn");
|
||||
List<Equipment> equipmentList = equipmentMapper.selectList(qw);
|
||||
//消息等级,和主题数组一一对应,服务端将按照指定等级给订阅了主题的客户端推送消息
|
||||
int[] qos = new int[equipmentList.size()];
|
||||
String[] topics = new String[equipmentList.size()];
|
||||
for (int i = 0; i < equipmentList.size(); i++) {
|
||||
Equipment equipment = equipmentList.get(i);
|
||||
qos[i]=1;
|
||||
topics[i]=equipment.getIotSn();
|
||||
}
|
||||
//订阅主题
|
||||
//老款三色灯
|
||||
//client.subscribe(topics,qos);
|
||||
//新款三色灯
|
||||
// String[] topicsB = new String[1];
|
||||
// int[] qosB = new int[1];
|
||||
// topicsB[0]="/898604C4192290890384/dp";
|
||||
// qosB[0]=1;
|
||||
// client.subscribe(topicsB,qosB);
|
||||
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 断开连接
|
||||
*/
|
||||
public void disConnect(){
|
||||
try {
|
||||
client.disconnect();
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订阅主题
|
||||
*/
|
||||
public void subscribe(String topic,int qos){
|
||||
try {
|
||||
client.subscribe(topic,qos);
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.sourceplan.common.mqtt;
|
||||
|
||||
import org.eclipse.paho.client.mqttv3.IMqttAsyncClient;
|
||||
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
||||
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MqttProviderCallBack implements MqttCallback{
|
||||
|
||||
@Value("${spring.mqtt.client.id}")
|
||||
private String clientId;
|
||||
/**
|
||||
* 与服务器断开的回调
|
||||
*/
|
||||
@Override
|
||||
public void connectionLost(Throwable cause) {
|
||||
System.out.println(clientId+"与服务器断开连接");
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息到达的回调
|
||||
*/
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage message) throws Exception {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息发布成功的回调
|
||||
*/
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken token) {
|
||||
IMqttAsyncClient client = token.getClient();
|
||||
System.out.println(client.getClientId()+"发布消息成功!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package cn.sourceplan.common.mqtt;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class MqttProviderConfig {
|
||||
@Value("${spring.mqtt.username}")
|
||||
private String username;
|
||||
|
||||
@Value("${spring.mqtt.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.mqtt.url}")
|
||||
private String hostUrl;
|
||||
|
||||
@Value("${spring.mqtt.client.id}")
|
||||
private String clientId;
|
||||
|
||||
@Value("${spring.mqtt.default.topic}")
|
||||
private String defaultTopic;
|
||||
|
||||
/**
|
||||
* 客户端对象
|
||||
*/
|
||||
private MqttClient client;
|
||||
|
||||
/**
|
||||
* 在bean初始化后连接到服务器
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户端连接服务端
|
||||
*/
|
||||
public void connect(){
|
||||
try{
|
||||
//创建MQTT客户端对象
|
||||
client = new MqttClient(hostUrl,clientId,new MemoryPersistence());
|
||||
//连接设置
|
||||
MqttConnectOptions options = new MqttConnectOptions();
|
||||
//是否清空session,设置false表示服务器会保留客户端的连接记录(订阅主题,qos),客户端重连之后能获取到服务器在客户端断开连接期间推送的消息
|
||||
//设置为true表示每次连接服务器都是以新的身份
|
||||
options.setCleanSession(true);
|
||||
//设置连接用户名
|
||||
options.setUserName(username);
|
||||
//设置连接密码
|
||||
options.setPassword(password.toCharArray());
|
||||
//设置超时时间,单位为秒
|
||||
options.setConnectionTimeout(100);
|
||||
//设置心跳时间 单位为秒,表示服务器每隔 1.5*20秒的时间向客户端发送心跳判断客户端是否在线
|
||||
options.setKeepAliveInterval(20);
|
||||
//设置遗嘱消息的话题,若客户端和服务器之间的连接意外断开,服务器将发布客户端的遗嘱信息
|
||||
options.setWill("willTopic",(clientId + "与服务器断开连接").getBytes(),0,false);
|
||||
//设置回调
|
||||
client.setCallback(new MqttProviderCallBack());
|
||||
client.connect(options);
|
||||
} catch(MqttException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
public void publish(int qos,boolean retained,String topic,String message){
|
||||
MqttMessage mqttMessage = new MqttMessage();
|
||||
mqttMessage.setQos(qos);
|
||||
mqttMessage.setRetained(retained);
|
||||
mqttMessage.setPayload(message.getBytes());
|
||||
//主题的目的地,用于发布/订阅信息
|
||||
MqttTopic mqttTopic = client.getTopic(topic);
|
||||
//提供一种机制来跟踪消息的传递进度
|
||||
//用于在以非阻塞方式(在后台运行)执行发布是跟踪消息的传递进度
|
||||
MqttDeliveryToken token;
|
||||
/*try {
|
||||
//将指定消息发布到主题,但不等待消息传递完成,返回的token可用于跟踪消息的传递状态
|
||||
//一旦此方法干净地返回,消息就已被客户端接受发布,当连接可用,将在后台完成消息传递。
|
||||
token = mqttTopic.publish(mqttMessage);
|
||||
token.waitForCompletion();
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.sourceplan.common.mybatisplus;
|
||||
|
||||
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jinzhong
|
||||
*/
|
||||
public class EasySqlInjector extends DefaultSqlInjector {
|
||||
@Override
|
||||
public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
|
||||
List<AbstractMethod> methodList=super.getMethodList(mapperClass);
|
||||
//添加批量插入方法
|
||||
methodList.add(new InsertBatchSomeColumn());
|
||||
return methodList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.sourceplan.common.mybatisplus;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import cn.sourceplan.common.utils.SecurityUtils;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 填充器
|
||||
*
|
||||
* @author nieqiurong 2018-08-10 22:59:23.
|
||||
*/
|
||||
@Component
|
||||
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
private String currentUsername() {
|
||||
try {
|
||||
return SecurityUtils.getUsername();
|
||||
} catch (Exception e) {
|
||||
return "system";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
this.strictInsertFill(metaObject, "createBy", this::currentUsername, String.class);
|
||||
this.strictInsertFill(metaObject, "createTime", () -> DateUtil.date(System.currentTimeMillis()), Date.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
this.strictUpdateFill(metaObject, "updateBy", this::currentUsername, String.class);
|
||||
this.strictUpdateFill(metaObject, "updateTime", () -> DateUtil.date(System.currentTimeMillis()), Date.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.sourceplan.common.service;
|
||||
|
||||
import java.util.List;
|
||||
import cn.sourceplan.common.domain.SysCodeRule;
|
||||
|
||||
/**
|
||||
* 编码规则Service接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-01-17
|
||||
*/
|
||||
public interface ISysCodeRuleService
|
||||
{
|
||||
/**
|
||||
* 查询编码规则
|
||||
*
|
||||
* @param id 编码规则主键
|
||||
* @return 编码规则
|
||||
*/
|
||||
SysCodeRule selectSysCodeRuleById(Long id);
|
||||
|
||||
/**
|
||||
* 查询编码规则列表
|
||||
*
|
||||
* @param sysCodeRule 编码规则
|
||||
* @return 编码规则集合
|
||||
*/
|
||||
List<SysCodeRule> selectSysCodeRuleList(SysCodeRule sysCodeRule);
|
||||
|
||||
/**
|
||||
* 新增编码规则
|
||||
*
|
||||
* @param sysCodeRule 编码规则
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSysCodeRule(SysCodeRule sysCodeRule);
|
||||
|
||||
/**
|
||||
* 修改编码规则
|
||||
*
|
||||
* @param sysCodeRule 编码规则
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSysCodeRule(SysCodeRule sysCodeRule);
|
||||
|
||||
/**
|
||||
* 批量删除编码规则
|
||||
*
|
||||
* @param ids 需要删除的编码规则主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysCodeRuleByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 获取/更新编码
|
||||
* 编码规则有基础资料时调用
|
||||
* @param id codeRule 编码规则的ID
|
||||
* @param isUpdate 是否更新
|
||||
* @param sourceValueId 基础元素ID,不需要则传null
|
||||
* @return 结果
|
||||
*/
|
||||
String queryNewCodeById(Long id, Boolean isUpdate,Long sourceValueId);
|
||||
|
||||
/**
|
||||
* 获取/更新编码
|
||||
* 编码规则无基础资料时调用
|
||||
*
|
||||
* @param id codeRule 编码规则的ID
|
||||
* @param isUpdate 是否更新
|
||||
* @return 结果
|
||||
*/
|
||||
String queryNewCodeById(Long id, Boolean isUpdate);
|
||||
|
||||
/**
|
||||
* 获取/更新编码(支持自定义日期)
|
||||
* 编码规则无基础资料时调用,使用指定日期生成编号
|
||||
*
|
||||
* @param id codeRule 编码规则的ID
|
||||
* @param isUpdate 是否更新
|
||||
* @param customDate 自定义日期(用于编号中的日期部分,如果为null则使用当前日期)
|
||||
* @return 结果
|
||||
*/
|
||||
String queryNewCodeByIdWithDate(Long id, Boolean isUpdate, java.util.Date customDate);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package cn.sourceplan.common.service;
|
||||
|
||||
import java.util.List;
|
||||
import cn.sourceplan.common.domain.SysUserStation;
|
||||
|
||||
/**
|
||||
* 用户工位绑定Service接口
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-02-07
|
||||
*/
|
||||
public interface ISysUserStationService
|
||||
{
|
||||
/**
|
||||
* 查询用户工位绑定
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 用户工位绑定
|
||||
*/
|
||||
SysUserStation selectSysUserStationById(Long id);
|
||||
|
||||
/**
|
||||
* 查询用户工位绑定列表
|
||||
*
|
||||
* @param sysUserStation 用户工位绑定
|
||||
* @return 用户工位绑定集合
|
||||
*/
|
||||
List<SysUserStation> selectSysUserStationList(SysUserStation sysUserStation);
|
||||
|
||||
/**
|
||||
* 新增用户工位绑定
|
||||
*
|
||||
* @param sysUserStation 用户工位绑定
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSysUserStation(SysUserStation sysUserStation);
|
||||
|
||||
/**
|
||||
* 修改用户工位绑定
|
||||
*
|
||||
* @param sysUserStation 用户工位绑定
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSysUserStation(SysUserStation sysUserStation);
|
||||
|
||||
/**
|
||||
* 批量删除用户工位绑定
|
||||
*
|
||||
* @param userIds 需要删除的用户工位绑定主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysUserStationByIds(Long[] userIds);
|
||||
|
||||
|
||||
/**
|
||||
* 移动端扫码绑定
|
||||
*
|
||||
* @param sysUserStation 用户工位绑定
|
||||
* @return 结果
|
||||
*/
|
||||
int mobileBindUserStation(SysUserStation sysUserStation);
|
||||
|
||||
|
||||
/**
|
||||
* 根据当前登录用户ID查询工位绑定信息
|
||||
*
|
||||
* @param userId userId
|
||||
* @return 结果
|
||||
*/
|
||||
SysUserStation getInfoByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据工位ID查询绑定的用户列表
|
||||
*
|
||||
* @param stationId 工位ID
|
||||
* @return 用户列表
|
||||
*/
|
||||
List<SysUserStation> getUsersByStationId(Long stationId);
|
||||
}
|
||||
@@ -0,0 +1,456 @@
|
||||
package cn.sourceplan.common.service.impl;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.sourceplan.common.mapper.SysCodeRuleEntryMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import cn.sourceplan.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import cn.sourceplan.common.domain.SysCodeRuleEntry;
|
||||
import cn.sourceplan.common.mapper.SysCodeRuleMapper;
|
||||
import cn.sourceplan.common.domain.SysCodeRule;
|
||||
import cn.sourceplan.common.service.ISysCodeRuleService;
|
||||
|
||||
|
||||
/**
|
||||
* 编码规则Service业务层处理
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-01-17
|
||||
*/
|
||||
@Service
|
||||
public class SysCodeRuleServiceImpl implements ISysCodeRuleService
|
||||
{
|
||||
@Autowired
|
||||
private SysCodeRuleMapper sysCodeRuleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysCodeRuleEntryMapper sysCodeRuleEntryMapper;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
/**
|
||||
* 查询编码规则
|
||||
*
|
||||
* @param id 编码规则主键
|
||||
* @return 编码规则
|
||||
*/
|
||||
@Override
|
||||
public SysCodeRule selectSysCodeRuleById(Long id)
|
||||
{
|
||||
return sysCodeRuleMapper.selectSysCodeRuleById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询编码规则列表
|
||||
*
|
||||
* @param sysCodeRule 编码规则
|
||||
* @return 编码规则
|
||||
*/
|
||||
@Override
|
||||
public List<SysCodeRule> selectSysCodeRuleList(SysCodeRule sysCodeRule)
|
||||
{
|
||||
QueryWrapper<SysCodeRule> qw = new QueryWrapper<>(sysCodeRule);
|
||||
return sysCodeRuleMapper.selectList(qw) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增编码规则
|
||||
*
|
||||
* @param sysCodeRule 编码规则
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int insertSysCodeRule(SysCodeRule sysCodeRule)
|
||||
{
|
||||
int rows = sysCodeRuleMapper.insert(sysCodeRule);
|
||||
insertSysCodeRuleEntry(sysCodeRule);
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改编码规则
|
||||
*
|
||||
* @param sysCodeRule 编码规则
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int updateSysCodeRule(SysCodeRule sysCodeRule)
|
||||
{
|
||||
sysCodeRuleMapper.deleteSysCodeRuleEntryByRuleId(sysCodeRule.getId());
|
||||
insertSysCodeRuleEntry(sysCodeRule);
|
||||
return sysCodeRuleMapper.updateById(sysCodeRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除编码规则
|
||||
*
|
||||
* @param ids 需要删除的编码规则主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int deleteSysCodeRuleByIds(Long[] ids)
|
||||
{
|
||||
sysCodeRuleMapper.deleteSysCodeRuleEntryByRuleIds(ids);
|
||||
return sysCodeRuleMapper.deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class, propagation = org.springframework.transaction.annotation.Propagation.REQUIRES_NEW)
|
||||
public synchronized String queryNewCodeById(Long id, Boolean isUpdate,Long sourceValueId) {
|
||||
System.out.println("[编号生成] 开始生成编号(带源值ID),规则ID: " + id + ", 源值ID: " + sourceValueId);
|
||||
SysCodeRule codeRule = sysCodeRuleMapper.selectSysCodeRuleById(id);
|
||||
//将编码规则中的每行分录,拼接成一个字符
|
||||
List<SysCodeRuleEntry> subList = codeRule.getSysCodeRuleEntryList();
|
||||
StringBuilder newCodeStr = new StringBuilder();
|
||||
Long codeRuleId = codeRule.getId();
|
||||
//遍历编码规则所有子项
|
||||
for (int i = 0; i < subList.size(); i++) {
|
||||
SysCodeRuleEntry codeRuleSub = subList.get(i);
|
||||
//类型ID
|
||||
String typeId = codeRuleSub.getTypeId();
|
||||
//子项ID
|
||||
Long subId = codeRuleSub.getId();
|
||||
//当前日期
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
Date date = new Date();
|
||||
String today =format.format(date);
|
||||
//流水号
|
||||
if("A".equals(typeId)){
|
||||
int subSer =0;
|
||||
// 缓存中没有日期,流水号用缓存的
|
||||
// 缓存中有日期,不等于当前日期,流水号重置
|
||||
// 缓存中有日期,等于当前日期,流水号用缓存的
|
||||
// 缓存中没有流水号,流水号重置
|
||||
// 其余情况用缓存中的流水号,流水号+1
|
||||
|
||||
//缓存中有存最新日期,并且不等于当前日期
|
||||
if(org.apache.commons.lang3.StringUtils.isNotBlank(codeRuleSub.getMaxDate())) {
|
||||
String redisDate= codeRuleSub.getMaxDate();
|
||||
if(!redisDate.equals(today)){
|
||||
//不等于当前日期,流水号重置,日期也重置
|
||||
codeRuleSub.setMaxDate(today);
|
||||
//isUpdate=true,更新流水号
|
||||
if(isUpdate){
|
||||
codeRuleSub.setMaxFlow(2);
|
||||
}
|
||||
subSer=1;
|
||||
}
|
||||
}
|
||||
|
||||
//通过缓存获取当前最新流水号
|
||||
if(codeRuleSub.getMaxFlow()==null||codeRuleSub.getMaxFlow()<2){
|
||||
//不存在,流水号重置
|
||||
//isUpdate=true,更新流水号
|
||||
if(isUpdate){
|
||||
codeRuleSub.setMaxFlow(2);
|
||||
}
|
||||
subSer=1;
|
||||
}
|
||||
if(subSer==0){
|
||||
//其他情况下用缓存中的流水号,并将流水号+1
|
||||
subSer= codeRuleSub.getMaxFlow();
|
||||
if(isUpdate){
|
||||
codeRuleSub.setMaxFlow(subSer+1);
|
||||
}
|
||||
|
||||
}
|
||||
//补位符
|
||||
String codeCover = codeRuleSub.getCodeCover();
|
||||
//长度
|
||||
Integer codeLength = codeRuleSub.getLengthFlow();
|
||||
String serialStr = getSerial(codeCover, Long.valueOf(codeLength), String.valueOf(subSer));
|
||||
newCodeStr.append(serialStr);
|
||||
}
|
||||
//常量
|
||||
if("B".equals(typeId)){
|
||||
newCodeStr.append(codeRuleSub.getConstantChar()==null?"":codeRuleSub.getConstantChar());
|
||||
}
|
||||
//日期
|
||||
if("C".equals(typeId)){
|
||||
String dateFormat = codeRuleSub.getDateFormat();
|
||||
format = new SimpleDateFormat(dateFormat);
|
||||
codeRuleSub.setMaxDate(today);
|
||||
String str = format.format(date);
|
||||
newCodeStr.append(str);
|
||||
}
|
||||
//基础资料
|
||||
if("D".equals(typeId)){
|
||||
//3种方案,1.通过类名反射拿到对象(用这个) 2.通过DyMethodUtil工具类直接执行String语句 3.每个基础资料都单独调用
|
||||
codeRuleSub.setSourceValue(sourceValueId);
|
||||
String basicValue = getBasicValue(codeRuleSub);
|
||||
newCodeStr.append(basicValue);
|
||||
}
|
||||
sysCodeRuleEntryMapper.updateById(codeRuleSub);
|
||||
}
|
||||
return newCodeStr.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class, propagation = org.springframework.transaction.annotation.Propagation.REQUIRES_NEW)
|
||||
public synchronized String queryNewCodeById(Long id, Boolean isUpdate) {
|
||||
System.out.println("[编号生成] 开始生成编号(无自定义日期),规则ID: " + id);
|
||||
SysCodeRule codeRule = sysCodeRuleMapper.selectSysCodeRuleById(id);
|
||||
//将编码规则中的每行分录,拼接成一个字符
|
||||
List<SysCodeRuleEntry> subList = codeRule.getSysCodeRuleEntryList();
|
||||
StringBuilder newCodeStr = new StringBuilder();
|
||||
Long codeRuleId = codeRule.getId();
|
||||
//遍历编码规则所有子项
|
||||
for (int i = 0; i < subList.size(); i++) {
|
||||
SysCodeRuleEntry codeRuleSub = subList.get(i);
|
||||
//类型ID
|
||||
String typeId = codeRuleSub.getTypeId();
|
||||
//子项ID
|
||||
Long subId = codeRuleSub.getId();
|
||||
//当前日期
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
Date date = new Date();
|
||||
String today =format.format(date);
|
||||
//流水号
|
||||
if("A".equals(typeId)){
|
||||
int subSer =0;
|
||||
// 缓存中没有日期,流水号用缓存的
|
||||
// 缓存中有日期,不等于当前日期,流水号重置
|
||||
// 缓存中有日期,等于当前日期,流水号用缓存的
|
||||
// 缓存中没有流水号,流水号重置
|
||||
// 其余情况用缓存中的流水号,流水号+1
|
||||
|
||||
//缓存中有存最新日期,并且不等于当前日期
|
||||
if(org.apache.commons.lang3.StringUtils.isNotBlank(codeRuleSub.getMaxDate())) {
|
||||
String redisDate= codeRuleSub.getMaxDate();
|
||||
if(!redisDate.equals(today)){
|
||||
//不等于当前日期,流水号重置,日期也重置
|
||||
codeRuleSub.setMaxDate(today);
|
||||
//isUpdate=true,更新流水号
|
||||
if(isUpdate){
|
||||
codeRuleSub.setMaxFlow(2);
|
||||
}
|
||||
subSer=1;
|
||||
}
|
||||
}
|
||||
|
||||
//通过缓存获取当前最新流水号
|
||||
if(codeRuleSub.getMaxFlow()==null||codeRuleSub.getMaxFlow()<2){
|
||||
//不存在,流水号重置
|
||||
//isUpdate=true,更新流水号
|
||||
if(isUpdate){
|
||||
codeRuleSub.setMaxFlow(2);
|
||||
}
|
||||
subSer=1;
|
||||
}
|
||||
if(subSer==0){
|
||||
//其他情况下用缓存中的流水号,并将流水号+1
|
||||
subSer= codeRuleSub.getMaxFlow();
|
||||
if(isUpdate){
|
||||
codeRuleSub.setMaxFlow(subSer+1);
|
||||
}
|
||||
|
||||
}
|
||||
//补位符
|
||||
String codeCover = codeRuleSub.getCodeCover();
|
||||
//长度
|
||||
Integer codeLength = codeRuleSub.getLengthFlow();
|
||||
String serialStr = getSerial(codeCover, Long.valueOf(codeLength), String.valueOf(subSer));
|
||||
newCodeStr.append(serialStr);
|
||||
}
|
||||
//常量
|
||||
if("B".equals(typeId)){
|
||||
newCodeStr.append(codeRuleSub.getConstantChar()==null?"":codeRuleSub.getConstantChar());
|
||||
}
|
||||
//日期
|
||||
if("C".equals(typeId)){
|
||||
String dateFormat = codeRuleSub.getDateFormat();
|
||||
format = new SimpleDateFormat(dateFormat);
|
||||
codeRuleSub.setMaxDate(today);
|
||||
String str = format.format(date);
|
||||
newCodeStr.append(str);
|
||||
}
|
||||
sysCodeRuleEntryMapper.updateById(codeRuleSub);
|
||||
}
|
||||
return newCodeStr.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class, propagation = org.springframework.transaction.annotation.Propagation.REQUIRES_NEW)
|
||||
public synchronized String queryNewCodeByIdWithDate(Long id, Boolean isUpdate, Date customDate) {
|
||||
// 如果没有传入自定义日期,使用当前日期
|
||||
Date dateToUse = customDate != null ? customDate : new Date();
|
||||
|
||||
System.out.println("[编号生成] 开始生成编号,规则ID: " + id + ", 日期: " + new java.text.SimpleDateFormat("yyyyMMdd").format(dateToUse));
|
||||
|
||||
SysCodeRule codeRule = sysCodeRuleMapper.selectSysCodeRuleById(id);
|
||||
//将编码规则中的每行分录,拼接成一个字符
|
||||
List<SysCodeRuleEntry> subList = codeRule.getSysCodeRuleEntryList();
|
||||
StringBuilder newCodeStr = new StringBuilder();
|
||||
Long codeRuleId = codeRule.getId();
|
||||
//遍历编码规则所有子项
|
||||
for (int i = 0; i < subList.size(); i++) {
|
||||
SysCodeRuleEntry codeRuleSub = subList.get(i);
|
||||
//类型ID
|
||||
String typeId = codeRuleSub.getTypeId();
|
||||
//子项ID
|
||||
Long subId = codeRuleSub.getId();
|
||||
//使用自定义日期
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
String today = format.format(dateToUse); // 使用传入的日期
|
||||
//流水号
|
||||
if("A".equals(typeId)){
|
||||
int subSer =0;
|
||||
System.out.println(" [流水号] 当前maxDate: " + codeRuleSub.getMaxDate() + ", 当前maxFlow: " + codeRuleSub.getMaxFlow() + ", 目标日期: " + today);
|
||||
// 缓存中没有日期,流水号用缓存的
|
||||
// 缓存中有日期,不等于当前日期,流水号重置
|
||||
// 缓存中有日期,等于当前日期,流水号用缓存的
|
||||
// 缓存中没有流水号,流水号重置
|
||||
// 其余情况用缓存中的流水号,流水号+1
|
||||
|
||||
//缓存中有存最新日期,并且不等于当前日期
|
||||
if(org.apache.commons.lang3.StringUtils.isNotBlank(codeRuleSub.getMaxDate())) {
|
||||
String redisDate= codeRuleSub.getMaxDate();
|
||||
if(!redisDate.equals(today)){
|
||||
//不等于当前日期,流水号重置,日期也重置
|
||||
System.out.println(" [流水号] 日期变化,重置流水号为1");
|
||||
codeRuleSub.setMaxDate(today);
|
||||
//isUpdate=true,更新流水号
|
||||
if(isUpdate){
|
||||
codeRuleSub.setMaxFlow(2);
|
||||
}
|
||||
subSer=1;
|
||||
}
|
||||
}
|
||||
|
||||
//通过缓存获取当前最新流水号
|
||||
if(codeRuleSub.getMaxFlow()==null||codeRuleSub.getMaxFlow()<2){
|
||||
//不存在,流水号重置
|
||||
System.out.println(" [流水号] maxFlow为空或<2,重置流水号为1");
|
||||
//isUpdate=true,更新流水号
|
||||
if(isUpdate){
|
||||
codeRuleSub.setMaxFlow(2);
|
||||
}
|
||||
subSer=1;
|
||||
}
|
||||
if(subSer==0){
|
||||
//其他情况下用缓存中的流水号,并将流水号+1
|
||||
subSer= codeRuleSub.getMaxFlow();
|
||||
System.out.println(" [流水号] 使用当前流水号: " + subSer + ", 更新为: " + (subSer+1));
|
||||
if(isUpdate){
|
||||
codeRuleSub.setMaxFlow(subSer+1);
|
||||
}
|
||||
|
||||
}
|
||||
System.out.println(" [流水号] 最终使用流水号: " + subSer + ", 即将更新maxFlow为: " + codeRuleSub.getMaxFlow());
|
||||
//补位符
|
||||
String codeCover = codeRuleSub.getCodeCover();
|
||||
//长度
|
||||
Integer codeLength = codeRuleSub.getLengthFlow();
|
||||
String serialStr = getSerial(codeCover, Long.valueOf(codeLength), String.valueOf(subSer));
|
||||
newCodeStr.append(serialStr);
|
||||
}
|
||||
//常量
|
||||
if("B".equals(typeId)){
|
||||
newCodeStr.append(codeRuleSub.getConstantChar()==null?"":codeRuleSub.getConstantChar());
|
||||
}
|
||||
//日期
|
||||
if("C".equals(typeId)){
|
||||
String dateFormat = codeRuleSub.getDateFormat();
|
||||
format = new SimpleDateFormat(dateFormat);
|
||||
codeRuleSub.setMaxDate(today);
|
||||
String str = format.format(dateToUse); // 使用传入的日期
|
||||
newCodeStr.append(str);
|
||||
}
|
||||
sysCodeRuleEntryMapper.updateById(codeRuleSub);
|
||||
}
|
||||
String generatedCode = newCodeStr.toString();
|
||||
System.out.println("[编号生成] 生成完成,编号: " + generatedCode);
|
||||
return generatedCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增编码规则子信息
|
||||
*
|
||||
* @param sysCodeRule 编码规则对象
|
||||
*/
|
||||
public void insertSysCodeRuleEntry(SysCodeRule sysCodeRule)
|
||||
{
|
||||
List<SysCodeRuleEntry> sysCodeRuleEntryList = sysCodeRule.getSysCodeRuleEntryList();
|
||||
Long id = sysCodeRule.getId();
|
||||
if (StringUtils.isNotNull(sysCodeRuleEntryList))
|
||||
{
|
||||
List<SysCodeRuleEntry> list = new ArrayList<SysCodeRuleEntry>();
|
||||
for (SysCodeRuleEntry sysCodeRuleEntry : sysCodeRuleEntryList)
|
||||
{
|
||||
sysCodeRuleEntry.setRuleId(id);
|
||||
list.add(sysCodeRuleEntry);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
sysCodeRuleEntryMapper.insertBatchSomeColumn(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getBasicValue(SysCodeRuleEntry codeRuleSub){
|
||||
//获取实体/表名 ,这里举例用产品的基础资料 elementSourceTable 为”Material“
|
||||
String elementSourceTable = codeRuleSub.getElementSourceTable();
|
||||
//获取Service类
|
||||
//获取来源值,例如来源实体为material产品,来源值就是具体的哪个产品的id
|
||||
Long id = Long.valueOf(codeRuleSub.getSourceValue());
|
||||
//获取来源属性,就是具体的字段,例如编号 sourceAttribute为"Number"
|
||||
String sourceAttribute = codeRuleSub.getSourceAttribute();
|
||||
//根据实体名material 获取该实体对应的service方法名称
|
||||
String serviceName = elementSourceTable.substring(0,1).toLowerCase()+elementSourceTable.substring(1)+"ServiceImpl";
|
||||
//获取service方法的Object对象
|
||||
Object serviceObj = applicationContext.getBean(serviceName);
|
||||
try {
|
||||
//获取Material实体Class
|
||||
Class<?> domainClass = Class.forName("cn.sourceplan.masterdata.domain."+elementSourceTable);
|
||||
//实例化
|
||||
Object domainObj=domainClass.newInstance();
|
||||
//获取Material的 setId方法
|
||||
Method setId = domainClass.getDeclaredMethod("setId", Long.class);
|
||||
//给id赋值
|
||||
setId.invoke(domainObj,id);
|
||||
//在service类中找到selectMaterialById方法
|
||||
Method selectNbyId = serviceObj.getClass().getDeclaredMethod("select" + elementSourceTable + "ById", Long.class);
|
||||
//放入已经赋值id的Material对象,并执行,获得Material结果Object
|
||||
Object resultObj = selectNbyId.invoke(serviceObj,id);
|
||||
//调用material中的get***方法,获取相应的值,比如sourceAttribute为 "Number",
|
||||
Method getAttribute = resultObj.getClass().getMethod("get" + sourceAttribute.substring(0,1).toUpperCase()+sourceAttribute.substring(1));
|
||||
//执行getNumber方法,将值转为String返回
|
||||
Object attribute = getAttribute.invoke(resultObj,new Object[0]);
|
||||
return String.valueOf(attribute);
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getSerial(String codeCover,Long codeLength,String subSer){
|
||||
StringBuilder serial = new StringBuilder();
|
||||
//获取末尾流水号的长度
|
||||
int subSerL = subSer.length();
|
||||
//需要补的位数
|
||||
int coverL = codeLength - subSerL<0?0:Math.toIntExact(codeLength - subSerL);
|
||||
int codeCoverL = codeCover.length();
|
||||
//拼接补位符
|
||||
for (int i = 0; i < coverL/codeCoverL; i++) {
|
||||
serial.append(codeCover);
|
||||
}
|
||||
//取余
|
||||
serial.append(codeCover, 0, coverL%codeCoverL);
|
||||
serial.append(subSer);
|
||||
return serial.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package cn.sourceplan.common.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.sourceplan.common.utils.SecurityUtils;
|
||||
import cn.sourceplan.masterdata.domain.Station;
|
||||
import cn.sourceplan.masterdata.mapper.StationMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.sourceplan.common.mapper.SysUserStationMapper;
|
||||
import cn.sourceplan.common.domain.SysUserStation;
|
||||
import cn.sourceplan.common.service.ISysUserStationService;
|
||||
|
||||
/**
|
||||
* 用户工位绑定Service业务层处理
|
||||
*
|
||||
* @author jinzhong
|
||||
* @date 2023-02-07
|
||||
*/
|
||||
@Service
|
||||
public class SysUserStationServiceImpl implements ISysUserStationService
|
||||
{
|
||||
@Autowired
|
||||
private SysUserStationMapper sysUserStationMapper;
|
||||
|
||||
@Autowired
|
||||
private StationMapper stationMapper;
|
||||
|
||||
/**
|
||||
* 查询用户工位绑定
|
||||
*
|
||||
* @param id 用户工位绑定主键
|
||||
* @return 用户工位绑定
|
||||
*/
|
||||
@Override
|
||||
public SysUserStation selectSysUserStationById(Long id)
|
||||
{
|
||||
SysUserStation sysUserStation = sysUserStationMapper.selectById(id);
|
||||
if(sysUserStation != null) {
|
||||
Station station = stationMapper.selectById(sysUserStation.getStationId());
|
||||
if(station != null){
|
||||
sysUserStation.setWorkshopName(station.getWorkshopName());
|
||||
} else {
|
||||
sysUserStation.setWorkshopName("工位已删除");
|
||||
}
|
||||
}
|
||||
|
||||
return sysUserStation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户工位绑定列表
|
||||
*
|
||||
* @param sysUserStation 用户工位绑定
|
||||
* @return 用户工位绑定
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserStation> selectSysUserStationList(SysUserStation sysUserStation)
|
||||
{
|
||||
QueryWrapper<SysUserStation> qw = new QueryWrapper<>(sysUserStation);
|
||||
qw.orderByDesc("update_time");
|
||||
|
||||
List<SysUserStation> sysUserStations = sysUserStationMapper.selectList(qw);
|
||||
for (int i = 0; i < sysUserStations.size(); i++) {
|
||||
SysUserStation temp = sysUserStations.get(i);
|
||||
Station station = stationMapper.selectById(temp.getStationId());
|
||||
if(station != null){
|
||||
temp.setWorkshopName(station.getWorkshopName());
|
||||
} else {
|
||||
temp.setWorkshopName("工位已删除");
|
||||
}
|
||||
}
|
||||
|
||||
return sysUserStations;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户工位绑定
|
||||
*
|
||||
* @param sysUserStation 用户工位绑定
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysUserStation(SysUserStation sysUserStation)
|
||||
{
|
||||
sysUserStation.setUpdateTime(new Date());
|
||||
sysUserStation.setUpdateBy(SecurityUtils.getUsername());
|
||||
return sysUserStationMapper.insert(sysUserStation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户工位绑定
|
||||
*
|
||||
* @param sysUserStation 用户工位绑定
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysUserStation(SysUserStation sysUserStation)
|
||||
{
|
||||
// 如果前端没有传updateTime,则使用当前时间
|
||||
if (sysUserStation.getUpdateTime() == null) {
|
||||
sysUserStation.setUpdateTime(new Date());
|
||||
}
|
||||
// 如果前端没有传updateBy,则使用当前登录用户
|
||||
if (sysUserStation.getUpdateBy() == null) {
|
||||
sysUserStation.setUpdateBy(SecurityUtils.getUsername());
|
||||
}
|
||||
return sysUserStationMapper.updateById(sysUserStation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除用户工位绑定
|
||||
*
|
||||
* @param ids 需要删除的用户工位绑定主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysUserStationByIds(Long[] ids)
|
||||
{
|
||||
return sysUserStationMapper.deleteSysUserStationByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mobileBindUserStation(SysUserStation sysUserStation) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
SysUserStation s =sysUserStationMapper.getInfoByUserId(userId);
|
||||
if(s==null){
|
||||
//新增
|
||||
sysUserStation.setUserId(userId);
|
||||
sysUserStation.setUserName(SecurityUtils.getUsername());
|
||||
return insertSysUserStation(sysUserStation);
|
||||
}else{
|
||||
//修改
|
||||
sysUserStation.setId(s.getId());
|
||||
return updateSysUserStation(sysUserStation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserStation getInfoByUserId(Long userId) {
|
||||
|
||||
|
||||
SysUserStation s = sysUserStationMapper.getInfoByUserId(userId);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据工位ID查询绑定的用户列表
|
||||
*
|
||||
* @param stationId 工位ID
|
||||
* @return 用户列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserStation> getUsersByStationId(Long stationId) {
|
||||
return sysUserStationMapper.getUsersByStationId(stationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package cn.sourceplan.common.utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* AES加密工具类
|
||||
* 用于加密敏感数据(数据库账号密码)
|
||||
*
|
||||
* @author sourceplan
|
||||
* @date 2025-10-18
|
||||
*/
|
||||
public class AESUtil {
|
||||
|
||||
/**
|
||||
* AES密钥(16字节 = 128位)
|
||||
* 密钥:YaviiMESpassword
|
||||
*/
|
||||
private static final String AES_KEY = "YaviiMESpassword";
|
||||
|
||||
/**
|
||||
* 算法名称
|
||||
*/
|
||||
private static final String ALGORITHM = "AES";
|
||||
|
||||
/**
|
||||
* 加密模式
|
||||
* ECB模式:简单,适合小数据量
|
||||
*/
|
||||
private static final String TRANSFORMATION = "AES/ECB/PKCS5Padding";
|
||||
|
||||
/**
|
||||
* AES加密
|
||||
*
|
||||
* @param data 待加密的明文
|
||||
* @return Base64编码的密文
|
||||
*/
|
||||
public static String encrypt(String data) {
|
||||
try {
|
||||
// 创建密钥
|
||||
SecretKeySpec keySpec = new SecretKeySpec(AES_KEY.getBytes("UTF-8"), ALGORITHM);
|
||||
|
||||
// 创建加密器
|
||||
Cipher cipher = Cipher.getInstance(TRANSFORMATION);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec);
|
||||
|
||||
// 加密
|
||||
byte[] encrypted = cipher.doFinal(data.getBytes("UTF-8"));
|
||||
|
||||
// Base64编码
|
||||
return Base64.getEncoder().encodeToString(encrypted);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("AES加密失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AES解密
|
||||
*
|
||||
* @param encryptedData Base64编码的密文
|
||||
* @return 解密后的明文
|
||||
*/
|
||||
public static String decrypt(String encryptedData) {
|
||||
try {
|
||||
// 创建密钥
|
||||
SecretKeySpec keySpec = new SecretKeySpec(AES_KEY.getBytes("UTF-8"), ALGORITHM);
|
||||
|
||||
// 创建解密器
|
||||
Cipher cipher = Cipher.getInstance(TRANSFORMATION);
|
||||
cipher.init(Cipher.DECRYPT_MODE, keySpec);
|
||||
|
||||
// Base64解码
|
||||
byte[] encryptedBytes = Base64.getDecoder().decode(encryptedData);
|
||||
|
||||
// 解密
|
||||
byte[] decrypted = cipher.doFinal(encryptedBytes);
|
||||
|
||||
return new String(decrypted, "UTF-8");
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("AES解密失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试方法
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String original = "{\"Object\":\"root\",\"Class\":\"password123\"}";
|
||||
System.out.println("原文: " + original);
|
||||
|
||||
String encrypted = encrypt(original);
|
||||
System.out.println("AES加密: " + encrypted);
|
||||
|
||||
String decrypted = decrypt(encrypted);
|
||||
System.out.println("AES解密: " + decrypted);
|
||||
|
||||
System.out.println("验证: " + original.equals(decrypted));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
package cn.sourceplan.common.utils;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import cn.hutool.poi.excel.StyleSet;
|
||||
import cn.sourceplan.common.mapper.SqlCheckMapper;
|
||||
import cn.sourceplan.system.domain.FieldExtend;
|
||||
import cn.sourceplan.system.mapper.FieldExtendMapper;
|
||||
import cn.sourceplan.system.service.IFieldExtendService;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 自定义字段工具类
|
||||
* @author jinzhong
|
||||
*/
|
||||
@Component
|
||||
public class FieldExtendUtil
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private IFieldExtendService fieldExtendServiceT;
|
||||
|
||||
private static IFieldExtendService fieldExtendService;
|
||||
|
||||
@PostConstruct
|
||||
public void init (){
|
||||
fieldExtendService=fieldExtendServiceT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据json进行excel导出
|
||||
*/
|
||||
public static JSONObject exportExcelByJson(String sourceBill, JSONArray jsonArray, HttpServletResponse response) throws IOException {
|
||||
FieldExtend fieldExtendQW = new FieldExtend();
|
||||
fieldExtendQW.setSourceBill(sourceBill);
|
||||
List<FieldExtend> fieldExtendList = fieldExtendService.selectFieldExtendList(fieldExtendQW);
|
||||
|
||||
// 通过工具类创建writer
|
||||
ExcelWriter writer = ExcelUtil.getWriter(true);
|
||||
|
||||
//自定义标题别名
|
||||
for (int i = 0; i < fieldExtendList.size(); i++) {
|
||||
FieldExtend fieldExtend = fieldExtendList.get(i);
|
||||
writer.addHeaderAlias(fieldExtend.getField(), fieldExtend.getFieldName());
|
||||
String field = fieldExtend.getField();
|
||||
String[] split = field.split("\\.");
|
||||
//整理json数据格式
|
||||
for (int j = 0; j < jsonArray.size(); j++) {
|
||||
JSONObject jb = jsonArray.getJSONObject(j);
|
||||
//如果为扩展字段,则去fieldExtend字段中取值
|
||||
if(!"Y".equals(fieldExtend.getIsSystem())){
|
||||
//如saleOrder
|
||||
JSONObject feJb = jb.getJSONObject("extendField");
|
||||
//如number
|
||||
if(feJb!=null){
|
||||
Object o = feJb.get(field);
|
||||
jb.put(field,o);
|
||||
}
|
||||
}else{
|
||||
//为系统自带字段,并且具有子属性,例如saleOrder.number
|
||||
if(split.length>1){
|
||||
jsonArray.set(j,setSonAttributes(field,jb,split));
|
||||
}
|
||||
}
|
||||
}
|
||||
// 合并单元格后的标题行,使用默认标题样式,包含客户名称customer的进行合并
|
||||
//writer.merge()
|
||||
}
|
||||
// 默认的,未添加alias的属性也会写出,如果想只写出加了别名的字段,可以调用此方法排除之
|
||||
writer.setOnlyAlias(true);
|
||||
// 一次性写出内容,使用默认样式,强制输出标题
|
||||
writer.write(jsonArray, true);
|
||||
//日期格式化
|
||||
DataFormat dataFormat = writer.getWorkbook().createDataFormat();
|
||||
//部分格式可参考org.apache.poi.ss.usermodel.BuiltinFormats
|
||||
short format = dataFormat.getFormat("yyyy-mm-dd");
|
||||
StyleSet styleSet = writer.getStyleSet();
|
||||
styleSet.getCellStyleForDate()
|
||||
.setDataFormat(format);
|
||||
//列宽自适应
|
||||
setSizeColumn(writer.getSheet(),fieldExtendList.size()-1);
|
||||
|
||||
// number type
|
||||
CellStyle numberCellStyle = styleSet.getCellStyleForNumber(); //获取单元格的数值样式
|
||||
|
||||
numberCellStyle.setDataFormat(dataFormat.getFormat("0")); //设置小数样式
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
response.setHeader("Content-Disposition","attachment;filename="+sourceBill+".xlsx");
|
||||
ServletOutputStream out=response.getOutputStream();
|
||||
writer.flush(out, true);
|
||||
// 关闭writer,释放内存
|
||||
writer.close();
|
||||
IoUtil.close(out);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自适应宽度(中文支持)
|
||||
* @param sheet
|
||||
* @param size 因为for循环从0开始,size值为 列数-1
|
||||
*/
|
||||
public static void setSizeColumn(Sheet sheet, int size) {
|
||||
for (int columnNum = 0; columnNum <= size; columnNum++) {
|
||||
int columnWidth = sheet.getColumnWidth(columnNum) / 256;
|
||||
for (int rowNum = 0; rowNum <= sheet.getLastRowNum(); rowNum++) {
|
||||
Row currentRow;
|
||||
//当前行未被使用过
|
||||
if (sheet.getRow(rowNum) == null) {
|
||||
currentRow = sheet.createRow(rowNum);
|
||||
} else {
|
||||
currentRow = sheet.getRow(rowNum);
|
||||
}
|
||||
|
||||
if (currentRow.getCell(columnNum) != null) {
|
||||
Cell currentCell = currentRow.getCell(columnNum);
|
||||
if (currentCell.getCellType() == CellType.STRING) {
|
||||
int length = currentCell.getStringCellValue().getBytes().length;
|
||||
if (columnWidth < length) {
|
||||
columnWidth = length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sheet.setColumnWidth(columnNum, columnWidth * 256);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置子属性
|
||||
* @param field
|
||||
* @param jb
|
||||
* @param split
|
||||
*/
|
||||
public static JSONObject setSonAttributes( String field,JSONObject jb,String[] split){
|
||||
//如saleOrder
|
||||
JSONObject sonJb = jb.getJSONObject(split[0]);
|
||||
//如number
|
||||
jb.put(field,sonJb.get(split[1]));
|
||||
return jb;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package cn.sourceplan.common.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 计划分析JSON序列化和反序列化工具类
|
||||
* <p>
|
||||
* 该工具类提供计划分析数据的JSON序列化和反序列化功能,
|
||||
* 支持6个分析维度的结构化数据处理。
|
||||
* </p>
|
||||
*
|
||||
* @author kiro
|
||||
* @date 2026-02-09
|
||||
*/
|
||||
public class PlanAnalysisJsonUtil {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PlanAnalysisJsonUtil.class);
|
||||
|
||||
/**
|
||||
* 6个分析维度的名称常量
|
||||
*/
|
||||
private static final String[] DIMENSION_NAMES = {
|
||||
"物料/产品库存分析",
|
||||
"交期分析",
|
||||
"此产线待生产的订单分析",
|
||||
"订单优先级分析",
|
||||
"设备分析",
|
||||
"产能分析"
|
||||
};
|
||||
|
||||
/**
|
||||
* 将计划分析对象序列化为JSON字符串
|
||||
* <p>
|
||||
* 将计划分析的结构化数据(包含多个分析维度)转换为JSON字符串格式,
|
||||
* 用于存储到数据库的plan_analysis字段中。
|
||||
* </p>
|
||||
*
|
||||
* @param analysisData 计划分析数据对象(Map格式)
|
||||
* @return JSON字符串,如果输入为null则返回null
|
||||
*/
|
||||
public static String serialize(Map<String, Object> analysisData) {
|
||||
try {
|
||||
if (analysisData == null) {
|
||||
log.debug("计划分析数据为null,返回null");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 使用Fastjson2将Map转换为JSON字符串
|
||||
String jsonString = JSONObject.toJSONString(analysisData);
|
||||
log.debug("计划分析数据序列化成功,长度: {}", jsonString.length());
|
||||
return jsonString;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("计划分析数据序列化失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("计划分析数据序列化失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将JSON字符串反序列化为计划分析对象
|
||||
* <p>
|
||||
* 将数据库中存储的JSON字符串转换为结构化的计划分析数据对象。
|
||||
* 如果JSON字符串为null、空字符串或格式错误,则返回默认的空结构。
|
||||
* </p>
|
||||
*
|
||||
* @param jsonString JSON字符串
|
||||
* @return 计划分析数据对象(Map格式),如果输入无效则返回默认空结构
|
||||
*/
|
||||
public static Map<String, Object> deserialize(String jsonString) {
|
||||
try {
|
||||
// 处理null或空字符串的情况
|
||||
if (jsonString == null || jsonString.trim().isEmpty()) {
|
||||
log.debug("计划分析JSON为空,返回默认结构");
|
||||
return getDefaultStructure();
|
||||
}
|
||||
|
||||
// 尝试解析JSON字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
||||
|
||||
// 验证JSON结构是否包含必要的字段
|
||||
if (jsonObject == null || !jsonObject.containsKey("dimensions")) {
|
||||
log.warn("计划分析JSON格式不正确,缺少dimensions字段,返回默认结构");
|
||||
return getDefaultStructure();
|
||||
}
|
||||
|
||||
// 转换为Map并返回
|
||||
Map<String, Object> result = jsonObject.toJavaObject(Map.class);
|
||||
log.debug("计划分析JSON反序列化成功");
|
||||
return result;
|
||||
|
||||
} catch (Exception e) {
|
||||
// 解析失败时返回默认结构,不抛出异常
|
||||
log.error("计划分析JSON解析失败,返回默认结构: {}", e.getMessage());
|
||||
return getDefaultStructure();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取计划分析的默认空结构
|
||||
* <p>
|
||||
* 返回包含6个分析维度的默认空结构,每个维度都没有问题且内容为空。
|
||||
* 用于初始化新计划或处理无效JSON数据时的降级处理。
|
||||
* </p>
|
||||
*
|
||||
* @return 默认的计划分析结构(Map格式)
|
||||
*/
|
||||
public static Map<String, Object> getDefaultStructure() {
|
||||
Map<String, Object> defaultStructure = new HashMap<>();
|
||||
|
||||
// 创建6个分析维度的默认结构
|
||||
List<Map<String, Object>> dimensions = new ArrayList<>();
|
||||
|
||||
for (String dimensionName : DIMENSION_NAMES) {
|
||||
dimensions.add(createDefaultDimension(dimensionName));
|
||||
}
|
||||
|
||||
defaultStructure.put("dimensions", dimensions);
|
||||
|
||||
log.debug("创建默认计划分析结构,包含{}个维度", DIMENSION_NAMES.length);
|
||||
return defaultStructure;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建单个维度的默认结构
|
||||
*
|
||||
* @param dimensionName 维度名称
|
||||
* @return 维度的默认结构
|
||||
*/
|
||||
private static Map<String, Object> createDefaultDimension(String dimensionName) {
|
||||
Map<String, Object> dimension = new HashMap<>();
|
||||
dimension.put("name", dimensionName);
|
||||
dimension.put("hasIssue", false);
|
||||
dimension.put("content", new ArrayList<>());
|
||||
return dimension;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
package cn.sourceplan.common.utils;
|
||||
|
||||
import cn.sourceplan.common.core.domain.entity.SysDictData;
|
||||
import cn.sourceplan.common.utils.spring.SpringUtils;
|
||||
import cn.sourceplan.system.service.ISysConfigService;
|
||||
import cn.sourceplan.system.service.ISysDictDataService;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 班次时间工具类
|
||||
* 优先级:sys_dict_data.remark(班次类型字典) > sys_config > 硬编码默认值
|
||||
* remark 格式:HH:mm-HH:mm,如 08:00-16:00
|
||||
*/
|
||||
public class ShiftTimeUtil {
|
||||
|
||||
/** 班次字典类型 */
|
||||
private static final String SHIFT_DICT_TYPE = "sys_shift_type";
|
||||
|
||||
/** 早班键值 */
|
||||
public static final String SHIFT_MORNING = "A";
|
||||
/** 中班键值 */
|
||||
public static final String SHIFT_AFTERNOON = "B";
|
||||
/** 晚班键值 */
|
||||
public static final String SHIFT_NIGHT = "C";
|
||||
|
||||
/** 默认早班时间范围:08:00-16:00 */
|
||||
private static final String DEFAULT_MORNING = "08:00-16:00";
|
||||
/** 默认中班时间范围:16:00-00:00 */
|
||||
private static final String DEFAULT_AFTERNOON = "16:00-00:00";
|
||||
/** 默认晚班时间范围:00:00-08:00 */
|
||||
private static final String DEFAULT_NIGHT = "00:00-08:00";
|
||||
|
||||
/**
|
||||
* 根据报工时间获取班次名称
|
||||
*
|
||||
* @param reportTime 报工时间(java.util.Date 或 java.time.LocalDateTime)
|
||||
* @return 班次名称(早班/中班/晚班)
|
||||
*/
|
||||
public static String getShiftNameByTime(Object reportTime) {
|
||||
if (reportTime == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int hour;
|
||||
if (reportTime instanceof java.util.Date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime((java.util.Date) reportTime);
|
||||
hour = cal.get(Calendar.HOUR_OF_DAY);
|
||||
} else if (reportTime instanceof java.time.LocalDateTime) {
|
||||
hour = ((java.time.LocalDateTime) reportTime).getHour();
|
||||
} else if (reportTime instanceof java.sql.Timestamp) {
|
||||
hour = ((java.sql.Timestamp) reportTime).toLocalDateTime().getHour();
|
||||
} else if (reportTime instanceof Long) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis((Long) reportTime);
|
||||
hour = cal.get(Calendar.HOUR_OF_DAY);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getShiftNameByHour(hour);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据小时数获取班次名称
|
||||
*
|
||||
* @param hour 小时数(0-23)
|
||||
* @return 班次名称
|
||||
*/
|
||||
public static String getShiftNameByHour(int hour) {
|
||||
try {
|
||||
Map<String, String> shiftMap = loadShiftTimeMap();
|
||||
if (shiftMap.isEmpty()) {
|
||||
return defaultGetShiftName(hour);
|
||||
}
|
||||
|
||||
// 只遍历一次找到匹配的班次键值
|
||||
String matchedKey = findMatchingShift(hour, shiftMap);
|
||||
if (SHIFT_MORNING.equals(matchedKey)) {
|
||||
return "早班";
|
||||
} else if (SHIFT_AFTERNOON.equals(matchedKey)) {
|
||||
return "中班";
|
||||
} else if (SHIFT_NIGHT.equals(matchedKey)) {
|
||||
return "晚班";
|
||||
}
|
||||
return null;
|
||||
|
||||
} catch (Exception e) {
|
||||
return defaultGetShiftName(hour);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取班次时间范围的描述
|
||||
*
|
||||
* @param shiftName 班次名称
|
||||
* @return 时间范围描述,如 "08:00-16:00"
|
||||
*/
|
||||
public static String getShiftTimeRange(String shiftName) {
|
||||
if (shiftName == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
Map<String, String> shiftMap = loadShiftTimeMap();
|
||||
if (shiftMap.isEmpty()) {
|
||||
return defaultGetShiftTimeRange(shiftName);
|
||||
}
|
||||
|
||||
String key;
|
||||
switch (shiftName) {
|
||||
case "早班":
|
||||
key = SHIFT_MORNING;
|
||||
break;
|
||||
case "中班":
|
||||
key = SHIFT_AFTERNOON;
|
||||
break;
|
||||
case "晚班":
|
||||
key = SHIFT_NIGHT;
|
||||
break;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
||||
String range = shiftMap.get(key);
|
||||
return range != null ? range : defaultGetShiftTimeRange(shiftName);
|
||||
|
||||
} catch (Exception e) {
|
||||
return defaultGetShiftTimeRange(shiftName);
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 私有方法 ====================
|
||||
|
||||
/**
|
||||
* 加载班次时间配置:先从字典 remark 取,fallback sys_config
|
||||
* 结果缓存(map: dictValue -> HH:mm-HH:mm)
|
||||
*/
|
||||
private static Map<String, String> loadShiftTimeMap() {
|
||||
Map<String, String> result = new ConcurrentHashMap<>();
|
||||
|
||||
// 1. 优先从 sys_dict_data 读取(班次类型字典的 remark 字段)
|
||||
try {
|
||||
ISysDictDataService dictService = SpringUtils.getBean(ISysDictDataService.class);
|
||||
SysDictData query = new SysDictData();
|
||||
query.setDictType(SHIFT_DICT_TYPE);
|
||||
List<SysDictData> list = dictService.selectDictDataList(query);
|
||||
for (SysDictData item : list) {
|
||||
String remark = item.getRemark();
|
||||
if (remark != null && remark.contains("-")) {
|
||||
result.put(item.getDictValue(), remark.trim());
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
// 如果字典remark有数据,直接返回
|
||||
if (!result.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 2. Fallback:读 sys_config(原有逻辑)
|
||||
try {
|
||||
ISysConfigService configService = SpringUtils.getBean(ISysConfigService.class);
|
||||
|
||||
String morningStart = configService.selectConfigByKey("shift.morning.start");
|
||||
String morningEnd = configService.selectConfigByKey("shift.morning.end");
|
||||
String noonStart = configService.selectConfigByKey("shift.afternoon.start");
|
||||
String noonEnd = configService.selectConfigByKey("shift.afternoon.end");
|
||||
String nightStart = configService.selectConfigByKey("shift.night.start");
|
||||
String nightEnd = configService.selectConfigByKey("shift.night.end");
|
||||
|
||||
if (morningStart != null && morningEnd != null) {
|
||||
result.put(SHIFT_MORNING, morningStart + "-" + morningEnd);
|
||||
}
|
||||
if (noonStart != null && noonEnd != null) {
|
||||
result.put(SHIFT_AFTERNOON, noonStart + "-" + noonEnd);
|
||||
}
|
||||
if (nightStart != null && nightEnd != null) {
|
||||
result.put(SHIFT_NIGHT, nightStart + "-" + nightEnd);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在班次时间配置中查找匹配当前小时数的班次键值
|
||||
*/
|
||||
private static String findMatchingShift(int hour, Map<String, String> shiftMap) {
|
||||
for (Map.Entry<String, String> entry : shiftMap.entrySet()) {
|
||||
if (isInShiftRange(hour, entry.getValue())) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断小时数是否在班次时间范围内,支持跨天(如 16:00-00:00)
|
||||
*/
|
||||
private static boolean isInShiftRange(int hour, String range) {
|
||||
if (range == null || !range.contains("-")) return false;
|
||||
try {
|
||||
String[] parts = range.split("-");
|
||||
int start = parseHour(parts[0].trim());
|
||||
int end = parseHour(parts[1].trim());
|
||||
if (start <= end) {
|
||||
return hour >= start && hour < end;
|
||||
} else {
|
||||
return hour >= start || hour < end;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static int parseHour(String timeStr) {
|
||||
if (timeStr == null || timeStr.isEmpty()) return 0;
|
||||
try {
|
||||
return Integer.parseInt(timeStr.split(":")[0]);
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** 默认逻辑(兜底) */
|
||||
private static String defaultGetShiftName(int hour) {
|
||||
if (hour >= 8 && hour < 16) {
|
||||
return "早班";
|
||||
} else if (hour >= 16) {
|
||||
return "中班";
|
||||
} else {
|
||||
return "晚班";
|
||||
}
|
||||
}
|
||||
|
||||
/** 默认时间范围(兜底) */
|
||||
private static String defaultGetShiftTimeRange(String shiftName) {
|
||||
switch (shiftName) {
|
||||
case "早班": return DEFAULT_MORNING;
|
||||
case "中班": return DEFAULT_AFTERNOON;
|
||||
case "晚班": return DEFAULT_NIGHT;
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package cn.sourceplan.common.utils;
|
||||
|
||||
import cn.sourceplan.common.mapper.SqlCheckMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 自定义SQL查询/校验工具类
|
||||
* @author jinzhong
|
||||
*/
|
||||
@Component
|
||||
public class SqlCheckUtil {
|
||||
|
||||
@Autowired
|
||||
private SqlCheckMapper sqlCheckMapperT;
|
||||
|
||||
private static SqlCheckMapper sqlCheckMapper;
|
||||
|
||||
@PostConstruct
|
||||
public void init (){
|
||||
sqlCheckMapper=sqlCheckMapperT;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 编辑和删除A时查询其所关联的B表是否已存在A数据,存在则不让其操作,
|
||||
* 返回所关联表B的数据编号
|
||||
*
|
||||
*/
|
||||
public static String sqlCheck(String field, String tableName, String whereSql) {
|
||||
List<Map<String,String>> l = sqlCheckMapper.selectCheckField(field,tableName, whereSql);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(l!=null&&l.size()>0){
|
||||
for (int i = 0; i <l.size() ; i++) {
|
||||
Map<String, String> m = l.get(i);
|
||||
if(m==null){
|
||||
continue;
|
||||
}
|
||||
String s = m.get(field);
|
||||
sb.append(s);
|
||||
if(i!=l.size()-1){
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int sqlCheck( String tableName, String whereSql) {
|
||||
int i = sqlCheckMapper.selectCheckCount(tableName, whereSql);
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 查询该表所有字段信息
|
||||
* 包括字段名,字段类型,字段说明
|
||||
*
|
||||
*/
|
||||
public static List<Map<String, String>> getTableAllFiled(String tableName){
|
||||
return sqlCheckMapper.getTableAllFiled(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 执行任意自定义sql
|
||||
*
|
||||
*/
|
||||
public static Object executeCustomSql( String customSql) {
|
||||
Object i = sqlCheckMapper.executeCustomSql(customSql);
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 封装过滤条件
|
||||
* 例如 传递 12
|
||||
* 查询 "sourceInfo": "{\"saleOrderEntryId\":[12,13]}" 这种格式的数据书
|
||||
* @param fieldName 例如 saleOrderEntryId
|
||||
*/
|
||||
public static String querySourceInfo(String fieldName,Long[] ids) {
|
||||
|
||||
|
||||
String sql="";
|
||||
sql+=" and (";
|
||||
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
|
||||
//处于中间
|
||||
sql+="source_info like concat('%,',"+ids[i]+",',%' ) or ";
|
||||
//处于末尾
|
||||
sql+="source_info like concat('%,',"+ids[i]+",']}')or ";
|
||||
//处于开头
|
||||
sql+="source_info like concat('{\""+fieldName+"\":[',"+ids[i]+",',%' ) or ";
|
||||
//只有一个
|
||||
sql+="source_info = concat('{\""+fieldName+"\":[',"+ids[i]+",']}')";
|
||||
|
||||
//不是最后一个
|
||||
if(i!=ids.length-1){
|
||||
sql+=" or ";
|
||||
}
|
||||
|
||||
}
|
||||
sql+=")";
|
||||
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal;
|
||||
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.energy.controller.admin.coal.vo.CoalConsumptionChartRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.coal.vo.CoalConsumptionDeviceChartRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.coal.vo.CoalConsumptionDeviceRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.coal.vo.CoalConsumptionDeviceTrendItemRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.coal.vo.CoalConsumptionDeviceTrendRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.coal.vo.CoalConsumptionHistoryRespVO;
|
||||
import cn.sourceplan.energy.service.coal.CoalConsumptionService;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/energy/coal-consumption")
|
||||
public class CoalConsumptionController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private CoalConsumptionService coalConsumptionService;
|
||||
|
||||
/**
|
||||
* @author 周
|
||||
* 获得煤炭消耗图表数据
|
||||
*/
|
||||
@GetMapping("/chart")
|
||||
public AjaxResult getCoalConsumptionChart(@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<CoalConsumptionChartRespVO> list = coalConsumptionService.getCoalConsumptionChart(type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/device-chart")
|
||||
public AjaxResult getDeviceChart(@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<CoalConsumptionDeviceChartRespVO> list = coalConsumptionService.getDeviceChart(type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/device-trend")
|
||||
public AjaxResult getDeviceTrend(@RequestParam("deviceCode") String deviceCode,
|
||||
@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<CoalConsumptionDeviceTrendRespVO> list = coalConsumptionService.getDeviceTrendChart(deviceCode, type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/device-trend-all")
|
||||
public AjaxResult getAllDeviceTrend(@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<CoalConsumptionDeviceTrendItemRespVO> list = coalConsumptionService.getAllDeviceTrendChart(type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/devices")
|
||||
public AjaxResult getDeviceList() {
|
||||
List<CoalConsumptionDeviceRespVO> list = coalConsumptionService.getDeviceList();
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author 周
|
||||
* 获得煤炭消耗历史记录
|
||||
*/
|
||||
@GetMapping("/history")
|
||||
public AjaxResult getCoalConsumptionHistory(@RequestParam(value = "deviceCode", required = false) String deviceCode,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<CoalConsumptionHistoryRespVO> list = coalConsumptionService.getCoalConsumptionHistory(deviceCode, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal;
|
||||
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.core.page.TableDataInfo;
|
||||
import cn.sourceplan.energy.controller.admin.coal.vo.CoalMonitoringCreateReqVO;
|
||||
import cn.sourceplan.energy.controller.admin.coal.vo.CoalMonitoringPageReqVO;
|
||||
import cn.sourceplan.energy.controller.admin.coal.vo.CoalMonitoringUpdateReqVO;
|
||||
import cn.sourceplan.energy.dal.dataobject.coal.CoalMonitoringDO;
|
||||
import cn.sourceplan.energy.service.coal.CoalMonitoringService;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/energy/coal-monitoring")
|
||||
public class CoalMonitoringController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private CoalMonitoringService coalMonitoringService;
|
||||
|
||||
/**
|
||||
* 获得煤炭监测分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public TableDataInfo getCoalMonitoringPage(@Valid CoalMonitoringPageReqVO pageVO) {
|
||||
startPage();
|
||||
List<CoalMonitoringDO> list = coalMonitoringService.selectCoalMonitoringList(pageVO);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建煤炭监测
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public AjaxResult createCoalMonitoring(@Valid @RequestBody CoalMonitoringCreateReqVO createReqVO) {
|
||||
return success(coalMonitoringService.createCoalMonitoring(createReqVO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新煤炭监测
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public AjaxResult updateCoalMonitoring(@Valid @RequestBody CoalMonitoringUpdateReqVO updateReqVO) {
|
||||
return toAjax(coalMonitoringService.updateCoalMonitoring(updateReqVO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除煤炭监测
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
public AjaxResult deleteCoalMonitoring(@RequestParam("id") Long id) {
|
||||
return toAjax(coalMonitoringService.deleteCoalMonitoring(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 煤炭消耗图表 Response VO
|
||||
*
|
||||
* @author 周
|
||||
*/
|
||||
@Data
|
||||
public class CoalConsumptionChartRespVO {
|
||||
|
||||
private String date;
|
||||
|
||||
private Double value;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalConsumptionDeviceChartRespVO {
|
||||
private String deviceCode;
|
||||
private String deviceName;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalConsumptionDeviceRespVO {
|
||||
private String deviceCode;
|
||||
private String deviceName;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalConsumptionDeviceTrendItemRespVO {
|
||||
private String deviceCode;
|
||||
private String deviceName;
|
||||
private String date;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalConsumptionDeviceTrendRespVO {
|
||||
private String date;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 煤炭消耗历史记录 Response VO
|
||||
*
|
||||
* @author 周
|
||||
*/
|
||||
@Data
|
||||
public class CoalConsumptionHistoryRespVO {
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
private BigDecimal currentConsumption;
|
||||
|
||||
private BigDecimal lastConsumption;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 煤炭监测创建 Request VO
|
||||
*
|
||||
* @author 周
|
||||
*/
|
||||
@Data
|
||||
public class CoalMonitoringCreateReqVO {
|
||||
|
||||
@NotNull(message = "设备编号不能为空")
|
||||
private String deviceCode;
|
||||
|
||||
@NotNull(message = "设备名称不能为空")
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
@NotNull(message = "当前消耗量不能为空")
|
||||
private BigDecimal currentConsumption;
|
||||
|
||||
private BigDecimal lastConsumption;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@org.springframework.format.annotation.DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastRecordTime;
|
||||
|
||||
private String coalType;
|
||||
|
||||
@NotNull(message = "状态不能为空")
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String text1;
|
||||
|
||||
private String text2;
|
||||
|
||||
private String text3;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 煤炭监测分页 Request VO
|
||||
*
|
||||
* @author 周
|
||||
*/
|
||||
@Data
|
||||
public class CoalMonitoringPageReqVO {
|
||||
|
||||
private String deviceCode;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
private String coalType;
|
||||
|
||||
private String status;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date[] createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 煤炭监测 Response VO
|
||||
*
|
||||
* @author 周
|
||||
*/
|
||||
@Data
|
||||
public class CoalMonitoringRespVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String deviceCode;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
private BigDecimal currentConsumption;
|
||||
|
||||
private BigDecimal lastConsumption;
|
||||
|
||||
private LocalDateTime lastRecordTime;
|
||||
|
||||
private String coalType;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String text1;
|
||||
|
||||
private String text2;
|
||||
|
||||
private String text3;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.sourceplan.energy.controller.admin.coal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 煤炭监测更新 Request VO
|
||||
*
|
||||
* @author 周
|
||||
*/
|
||||
@Data
|
||||
public class CoalMonitoringUpdateReqVO {
|
||||
|
||||
@NotNull(message = "主键ID不能为空")
|
||||
private Long id;
|
||||
|
||||
@NotNull(message = "设备编号不能为空")
|
||||
private String deviceCode;
|
||||
|
||||
@NotNull(message = "设备名称不能为空")
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
@NotNull(message = "当前消耗量不能为空")
|
||||
private BigDecimal currentConsumption;
|
||||
|
||||
private BigDecimal lastConsumption;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@org.springframework.format.annotation.DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastRecordTime;
|
||||
|
||||
private String coalType;
|
||||
|
||||
@NotNull(message = "状态不能为空")
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String text1;
|
||||
|
||||
private String text2;
|
||||
|
||||
private String text3;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity;
|
||||
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.energy.controller.admin.electricity.vo.ElectricityConsumptionChartRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.electricity.vo.ElectricityConsumptionDeviceChartRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.electricity.vo.ElectricityConsumptionDeviceRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.electricity.vo.ElectricityConsumptionDeviceTrendItemRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.electricity.vo.ElectricityConsumptionDeviceTrendRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.electricity.vo.ElectricityConsumptionHistoryRespVO;
|
||||
import cn.sourceplan.energy.service.electricity.ElectricityConsumptionService;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/energy/electricity-consumption")
|
||||
public class ElectricityConsumptionController extends BaseController {
|
||||
@Resource
|
||||
private ElectricityConsumptionService electricityConsumptionService;
|
||||
|
||||
/**
|
||||
* author:周
|
||||
*/
|
||||
@GetMapping("/chart")
|
||||
public AjaxResult getChart(@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<ElectricityConsumptionChartRespVO> list = electricityConsumptionService.getChart(type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/device-chart")
|
||||
public AjaxResult getDeviceChart(@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<ElectricityConsumptionDeviceChartRespVO> list = electricityConsumptionService.getDeviceChart(type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/device-trend")
|
||||
public AjaxResult getDeviceTrend(@RequestParam("deviceCode") String deviceCode,
|
||||
@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<ElectricityConsumptionDeviceTrendRespVO> list = electricityConsumptionService.getDeviceTrendChart(deviceCode, type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/device-trend-all")
|
||||
public AjaxResult getAllDeviceTrend(@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<ElectricityConsumptionDeviceTrendItemRespVO> list = electricityConsumptionService.getAllDeviceTrendChart(type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/devices")
|
||||
public AjaxResult getDeviceList() {
|
||||
List<ElectricityConsumptionDeviceRespVO> list = electricityConsumptionService.getDeviceList();
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* author:周
|
||||
*/
|
||||
@GetMapping("/history")
|
||||
public AjaxResult getHistory(@RequestParam(value = "deviceCode", required = false) String deviceCode,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<ElectricityConsumptionHistoryRespVO> list = electricityConsumptionService.getHistory(deviceCode, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity;
|
||||
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.core.page.TableDataInfo;
|
||||
import cn.sourceplan.energy.controller.admin.electricity.vo.ElectricityMonitoringPageReqVO;
|
||||
import cn.sourceplan.energy.controller.admin.electricity.vo.ElectricityMonitoringSaveReqVO;
|
||||
import cn.sourceplan.energy.dal.dataobject.electricity.ElectricityMonitoringDO;
|
||||
import cn.sourceplan.energy.service.electricity.ElectricityMonitoringService;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/energy/electricity-monitoring")
|
||||
public class ElectricityMonitoringController extends BaseController {
|
||||
@Resource
|
||||
private ElectricityMonitoringService electricityMonitoringService;
|
||||
|
||||
@PostMapping("/create")
|
||||
public AjaxResult create(@Valid @RequestBody ElectricityMonitoringSaveReqVO createReqVO) {
|
||||
return success(electricityMonitoringService.createElectricityMonitoring(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
public AjaxResult update(@Valid @RequestBody ElectricityMonitoringSaveReqVO updateReqVO) {
|
||||
return toAjax(electricityMonitoringService.updateElectricityMonitoring(updateReqVO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
public AjaxResult delete(@RequestParam("id") Long id) {
|
||||
return toAjax(electricityMonitoringService.deleteElectricityMonitoring(id));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
public TableDataInfo getPage(@Valid ElectricityMonitoringPageReqVO pageReqVO) {
|
||||
startPage();
|
||||
List<ElectricityMonitoringDO> list = electricityMonitoringService.getElectricityMonitoringList(pageReqVO);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
public AjaxResult get(@RequestParam("id") Long id) {
|
||||
return success(electricityMonitoringService.getElectricityMonitoring(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ElectricityConsumptionChartRespVO {
|
||||
private String date;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ElectricityConsumptionDeviceChartRespVO {
|
||||
private String deviceCode;
|
||||
private String deviceName;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ElectricityConsumptionDeviceRespVO {
|
||||
private String deviceCode;
|
||||
private String deviceName;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ElectricityConsumptionDeviceTrendItemRespVO {
|
||||
private String deviceCode;
|
||||
private String deviceName;
|
||||
private String date;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ElectricityConsumptionDeviceTrendRespVO {
|
||||
private String date;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class ElectricityConsumptionHistoryRespVO {
|
||||
private Date updateTime;
|
||||
private String deviceName;
|
||||
private String location;
|
||||
private BigDecimal currentKWh;
|
||||
private BigDecimal lastKWh;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ElectricityMonitoringPageReqVO {
|
||||
|
||||
private String deviceCode;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class ElectricityMonitoringRespVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String deviceCode;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
private BigDecimal currentKWh;
|
||||
|
||||
private BigDecimal lastKWh;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastDate;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String text1;
|
||||
|
||||
private String text2;
|
||||
|
||||
private String text3;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
private String creator;
|
||||
|
||||
private String updater;
|
||||
|
||||
private Boolean deleted;
|
||||
|
||||
private Integer tenantId;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.sourceplan.energy.controller.admin.electricity.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class ElectricityMonitoringSaveReqVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
// @NotBlank(message = "设备编号不能为空")
|
||||
private String deviceCode;
|
||||
|
||||
@NotBlank(message = "设备名称不能为空")
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
@NotNull(message = "当前读数不能为空")
|
||||
@DecimalMin(value = "0.0", message = "当前读数不能小于0")
|
||||
private BigDecimal currentKWh;
|
||||
|
||||
@DecimalMin(value = "0.0", message = "上次读数不能小于0")
|
||||
private BigDecimal lastKWh;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date lastDate;
|
||||
|
||||
@NotBlank(message = "状态不能为空")
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String text1;
|
||||
|
||||
private String text2;
|
||||
|
||||
private String text3;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.sourceplan.energy.controller.admin.summary;
|
||||
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.energy.service.summary.EnergyConsumptionSummaryService;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/energy/consumption")
|
||||
public class EnergyConsumptionSummaryController extends BaseController {
|
||||
@Resource
|
||||
private EnergyConsumptionSummaryService energyConsumptionSummaryService;
|
||||
|
||||
@GetMapping("/summary")
|
||||
public AjaxResult getSummary(
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime
|
||||
) {
|
||||
return success(energyConsumptionSummaryService.getSummary(startTime, endTime));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.sourceplan.energy.controller.admin.summary.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class EnergyConsumptionSummaryRespVO {
|
||||
private BigDecimal electricity;
|
||||
private BigDecimal water;
|
||||
private BigDecimal coal;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.sourceplan.energy.controller.admin.water;
|
||||
|
||||
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.energy.controller.admin.water.vo.WaterConsumptionChartRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.water.vo.WaterConsumptionDeviceChartRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.water.vo.WaterConsumptionDeviceRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.water.vo.WaterConsumptionDeviceTrendRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.water.vo.WaterConsumptionDeviceTrendItemRespVO;
|
||||
import cn.sourceplan.energy.controller.admin.water.vo.WaterConsumptionHistoryRespVO;
|
||||
import cn.sourceplan.energy.service.water.WaterConsumptionService;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/energy/water-consumption")
|
||||
public class WaterConsumptionController extends BaseController {
|
||||
@Resource
|
||||
private WaterConsumptionService waterConsumptionService;
|
||||
|
||||
/**
|
||||
* author:周
|
||||
*/
|
||||
@GetMapping("/chart")
|
||||
public AjaxResult getChart(@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<WaterConsumptionChartRespVO> list = waterConsumptionService.getChart(type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/device-chart")
|
||||
public AjaxResult getDeviceChart(@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<WaterConsumptionDeviceChartRespVO> list = waterConsumptionService.getDeviceChart(type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/device-trend")
|
||||
public AjaxResult getDeviceTrend(@RequestParam("deviceCode") String deviceCode,
|
||||
@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<WaterConsumptionDeviceTrendRespVO> list = waterConsumptionService.getDeviceTrendChart(deviceCode, type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/device-trend-all")
|
||||
public AjaxResult getAllDeviceTrend(@RequestParam("type") String type,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<WaterConsumptionDeviceTrendItemRespVO> list = waterConsumptionService.getAllDeviceTrendChart(type, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/devices")
|
||||
public AjaxResult getDeviceList() {
|
||||
List<WaterConsumptionDeviceRespVO> list = waterConsumptionService.getDeviceList();
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* author:周
|
||||
*/
|
||||
@GetMapping("/history")
|
||||
public AjaxResult getHistory(@RequestParam(value = "deviceCode", required = false) String deviceCode,
|
||||
@RequestParam(value = "startTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(value = "endTime", required = false)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<WaterConsumptionHistoryRespVO> list = waterConsumptionService.getHistory(deviceCode, startTime, endTime);
|
||||
return success(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package cn.sourceplan.energy.controller.admin.water;
|
||||
|
||||
import cn.sourceplan.common.core.controller.BaseController;
|
||||
import cn.sourceplan.common.core.domain.AjaxResult;
|
||||
import cn.sourceplan.common.core.page.TableDataInfo;
|
||||
import cn.sourceplan.energy.controller.admin.water.vo.WaterMonitoringPageReqVO;
|
||||
import cn.sourceplan.energy.controller.admin.water.vo.WaterMonitoringSaveReqVO;
|
||||
import cn.sourceplan.energy.dal.dataobject.water.WaterMonitoringDO;
|
||||
import cn.sourceplan.energy.service.water.WaterMonitoringService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/energy/water-monitoring")
|
||||
public class WaterMonitoringController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private WaterMonitoringService waterMonitoringService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@PreAuthorize("@ss.hasPermi('energy:water-monitoring:create')")
|
||||
public AjaxResult createWaterMonitoring(@RequestBody WaterMonitoringSaveReqVO createReqVO) {
|
||||
return success(waterMonitoringService.createWaterMonitoring(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@PreAuthorize("@ss.hasPermi('energy:water-monitoring:update')")
|
||||
public AjaxResult updateWaterMonitoring(@Valid @RequestBody WaterMonitoringSaveReqVO updateReqVO) {
|
||||
return toAjax(waterMonitoringService.updateWaterMonitoring(updateReqVO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@PreAuthorize("@ss.hasPermi('energy:water-monitoring:delete')")
|
||||
public AjaxResult deleteWaterMonitoring(@RequestParam("id") Long id) {
|
||||
return toAjax(waterMonitoringService.deleteWaterMonitoring(id));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@PreAuthorize("@ss.hasPermi('energy:water-monitoring:query')")
|
||||
public AjaxResult getWaterMonitoring(@RequestParam("id") Long id) {
|
||||
return success(waterMonitoringService.getWaterMonitoring(id));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermi('energy:water-monitoring:query')")
|
||||
public TableDataInfo getWaterMonitoringPage(@Valid WaterMonitoringPageReqVO pageReqVO) {
|
||||
startPage();
|
||||
List<WaterMonitoringDO> list = waterMonitoringService.getWaterMonitoringList(pageReqVO);
|
||||
return getDataTable(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.sourceplan.energy.controller.admin.water.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WaterConsumptionChartRespVO {
|
||||
private String date;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.sourceplan.energy.controller.admin.water.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WaterConsumptionDeviceChartRespVO {
|
||||
private String deviceCode;
|
||||
private String deviceName;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.sourceplan.energy.controller.admin.water.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WaterConsumptionDeviceRespVO {
|
||||
private String deviceCode;
|
||||
private String deviceName;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.sourceplan.energy.controller.admin.water.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WaterConsumptionDeviceTrendItemRespVO {
|
||||
private String deviceCode;
|
||||
private String deviceName;
|
||||
private String date;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.sourceplan.energy.controller.admin.water.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WaterConsumptionDeviceTrendRespVO {
|
||||
private String date;
|
||||
private Double value;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.sourceplan.energy.controller.admin.water.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class WaterConsumptionHistoryRespVO {
|
||||
private Date updateTime;
|
||||
private String deviceName;
|
||||
private String location;
|
||||
private Double currentValue;
|
||||
private Double lastTonnage;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.sourceplan.energy.controller.admin.water.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WaterMonitoringPageReqVO {
|
||||
|
||||
private String deviceCode;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
private String status;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.sourceplan.energy.controller.admin.water.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class WaterMonitoringRespVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String deviceCode;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
private BigDecimal currentValue;
|
||||
|
||||
private BigDecimal lastTonnage;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastDate;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.sourceplan.energy.controller.admin.water.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class WaterMonitoringSaveReqVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
// @NotBlank(message = "设备编号不能为空")
|
||||
private String deviceCode;
|
||||
|
||||
@NotBlank(message = "设备名称不能为空")
|
||||
private String deviceName;
|
||||
|
||||
private String location;
|
||||
|
||||
@NotNull(message = "当前读数不能为空")
|
||||
@DecimalMin(value = "0.0", message = "当前读数不能小于0")
|
||||
private BigDecimal currentValue;
|
||||
|
||||
@NotNull(message = "当前读数不能为空")
|
||||
@DecimalMin(value = "0.0", message = "上次读数不能小于0")
|
||||
private BigDecimal lastTonnage;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date lastDate;
|
||||
|
||||
@NotBlank(message = "状态不能为空")
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package cn.sourceplan.energy.dal.dataobject.coal;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 煤炭监测 DO
|
||||
*
|
||||
* @author 周
|
||||
*/
|
||||
@TableName("ene_coal_monitoring")
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CoalMonitoringDO {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 设备编号
|
||||
*/
|
||||
private String deviceCode;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String deviceName;
|
||||
/**
|
||||
* 位置
|
||||
*/
|
||||
private String location;
|
||||
/**
|
||||
* 当前消耗量(吨)
|
||||
*/
|
||||
private BigDecimal currentConsumption;
|
||||
/**
|
||||
* 上次消耗量(吨)
|
||||
*/
|
||||
private BigDecimal lastConsumption;
|
||||
/**
|
||||
* 上次记录时间
|
||||
*/
|
||||
private LocalDateTime lastRecordTime;
|
||||
/**
|
||||
* 煤炭类型
|
||||
*/
|
||||
private String coalType;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
private String text1;
|
||||
/**
|
||||
* 扩展
|
||||
*/
|
||||
private String text2;
|
||||
/**
|
||||
* 附加信息
|
||||
*/
|
||||
private String text3;
|
||||
|
||||
/** 是否删除 */
|
||||
@TableField("deleted")
|
||||
private Integer deleted;
|
||||
|
||||
/** 创建时间 */
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package cn.sourceplan.energy.dal.dataobject.electricity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 电表监测 DO
|
||||
*/
|
||||
@TableName("ene_electricity_monitoring")
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ElectricityMonitoringDO {
|
||||
|
||||
/** 主键 */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/** 设备编号 */
|
||||
@TableField("device_code")
|
||||
private String deviceCode;
|
||||
/** 设备名称 */
|
||||
@TableField("device_name")
|
||||
private String deviceName;
|
||||
/** 位置 */
|
||||
@TableField("location")
|
||||
private String location;
|
||||
/** 当前读数(KWh) */
|
||||
@TableField("current_KWh")
|
||||
private BigDecimal currentKWh;
|
||||
/** 上次读数(KWh) */
|
||||
@TableField("last_KWh")
|
||||
private BigDecimal lastKWh;
|
||||
/** 上次抄表时间 */
|
||||
@TableField("last_date")
|
||||
private Date lastDate;
|
||||
/** 状态 */
|
||||
@TableField("status")
|
||||
private String status;
|
||||
/** 备注 */
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
/** 备用字段1 */
|
||||
@TableField("text1")
|
||||
private String text1;
|
||||
/** 备用字段2 */
|
||||
@TableField("text2")
|
||||
private String text2;
|
||||
/** 备用字段3 */
|
||||
@TableField("text3")
|
||||
private String text3;
|
||||
/** 创建人 */
|
||||
@TableField("creator")
|
||||
private String creator;
|
||||
/** 更新人 */
|
||||
@TableField("updater")
|
||||
private String updater;
|
||||
/** 是否删除 */
|
||||
@TableField("deleted")
|
||||
private Integer deleted;
|
||||
/** 租户ID */
|
||||
@TableField("tenant_id")
|
||||
private Integer tenantId;
|
||||
|
||||
/** 创建时间 */
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package cn.sourceplan.energy.dal.dataobject.water;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 水表监测 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("ene_water_monitoring")
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WaterMonitoringDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 设备编号
|
||||
*/
|
||||
@TableField("device_code")
|
||||
private String deviceCode;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@TableField("device_name")
|
||||
private String deviceName;
|
||||
/**
|
||||
* 位置
|
||||
*/
|
||||
@TableField("location")
|
||||
private String location;
|
||||
/**
|
||||
* 当前读数
|
||||
*/
|
||||
@TableField("current_value")
|
||||
private BigDecimal currentValue;
|
||||
/**
|
||||
* 上次读数
|
||||
*/
|
||||
@TableField("last_tonnage")
|
||||
private BigDecimal lastTonnage;
|
||||
/**
|
||||
* 上次抄表时间
|
||||
*/
|
||||
@TableField("last_date")
|
||||
private Date lastDate;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@TableField("status")
|
||||
private String status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
/** 是否删除 */
|
||||
@TableField("deleted")
|
||||
private Integer deleted;
|
||||
|
||||
/** 创建时间 */
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.sourceplan.energy.enums;
|
||||
|
||||
/**
|
||||
* 能源模块错误码枚举类
|
||||
*
|
||||
* 能源模块,使用 1-010-000-000 段
|
||||
*/
|
||||
public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 水表监测相关 1-010-001-000 ==========
|
||||
String WATER_MONITORING_NOT_EXISTS = "水表监测不存在";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package cn.sourceplan.energy.mapper.coal;
|
||||
|
||||
import cn.sourceplan.energy.dal.dataobject.coal.CoalMonitoringDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 煤炭消耗 Mapper
|
||||
*
|
||||
* @author 周
|
||||
*/
|
||||
@Mapper
|
||||
public interface CoalConsumptionMapper {
|
||||
|
||||
/**
|
||||
* @author 周
|
||||
* 获取图表数据
|
||||
*
|
||||
* @param type 类型:week|month|year
|
||||
* @return 图表数据
|
||||
*/
|
||||
List<Map<String, Object>> YVZselectChartData(@Param("type") String type,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
|
||||
/**
|
||||
* @author 周
|
||||
* 获取历史记录列表
|
||||
*
|
||||
* @return 历史记录列表
|
||||
*/
|
||||
List<CoalMonitoringDO> YVZselectHistoryList(@Param("deviceCode") String deviceCode,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
|
||||
// 设备煤耗对比数据
|
||||
List<Map<String, Object>> YVZselectDeviceChartData(@Param("type") String type,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
|
||||
// 设备煤耗趋势数据
|
||||
List<Map<String, Object>> YVZselectDeviceTrendData(@Param("deviceCode") String deviceCode,
|
||||
@Param("type") String type,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
|
||||
// 全部设备煤耗趋势数据
|
||||
List<Map<String, Object>> YVZselectAllDeviceTrendData(@Param("type") String type,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
|
||||
// 设备列表
|
||||
List<Map<String, Object>> YVZselectDeviceList();
|
||||
|
||||
// 按时间范围汇总煤炭消耗
|
||||
BigDecimal YVHsumConsumptionByTimeRange(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.sourceplan.energy.mapper.coal;
|
||||
|
||||
import cn.sourceplan.energy.dal.dataobject.coal.CoalMonitoringDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 煤炭监测 Mapper
|
||||
*
|
||||
* @author 周
|
||||
*/
|
||||
@Mapper
|
||||
public interface CoalMonitoringMapper extends BaseMapper<CoalMonitoringDO> {
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user