Merge remote-tracking branch 'origin/main'

main
zhen 12 months ago
commit 49d65e418d
  1. 34
      src/main/java/org/energy/modules/spares/controller/InboundController.java
  2. 104
      src/main/java/org/energy/modules/spares/controller/MaterialController.java
  3. 14
      src/main/java/org/energy/modules/spares/controller/OutboundController.java
  4. 4
      src/main/java/org/energy/modules/spares/entity/Material.java
  5. 61
      src/main/java/org/energy/modules/spares/excel/MaterialExcel.java
  6. 5
      src/main/java/org/energy/modules/spares/mapper/InboundMapper.java
  7. 4
      src/main/java/org/energy/modules/spares/mapper/InboundMapper.xml
  8. 27
      src/main/java/org/energy/modules/spares/mapper/MaterialMapper.java
  9. 35
      src/main/java/org/energy/modules/spares/mapper/MaterialMapper.xml
  10. 5
      src/main/java/org/energy/modules/spares/service/IInboundService.java
  11. 25
      src/main/java/org/energy/modules/spares/service/IMaterialService.java
  12. 6
      src/main/java/org/energy/modules/spares/service/impl/InboundServiceImpl.java
  13. 30
      src/main/java/org/energy/modules/spares/service/impl/MaterialServiceImpl.java
  14. 11
      src/main/java/org/energy/modules/spares/vo/MaterialVO.java
  15. 12
      src/main/java/org/energy/modules/system/controller/UserController.java
  16. 55
      src/main/java/org/energy/modules/system/util/DataUtils.java

@ -15,6 +15,7 @@
*/
package org.energy.modules.spares.controller;
import com.xkcoding.http.util.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -26,6 +27,8 @@ import com.dayu.daf.core.mp.support.Condition;
import com.dayu.daf.core.mp.support.Query;
import com.dayu.daf.core.tool.api.R;
import com.dayu.daf.core.tool.utils.Func;
import lombok.Data;
import org.energy.modules.leger.entity.TechParameters;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -34,6 +37,10 @@ import org.energy.modules.spares.vo.InboundVO;
import org.energy.modules.spares.service.IInboundService;
import com.dayu.daf.core.boot.ctrl.DafController;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* 入库 控制器
*
@ -108,6 +115,22 @@ public class InboundController extends DafController {
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入inbound")
public R submit(@Valid @RequestBody Inbound inbound) {
String maxNo = inboundService.getMaxNo("'%" + inbound.getMaterialNo() + "%'");
int number;
if (StringUtil.isNotEmpty(maxNo)){
number = Integer.parseInt(maxNo.substring(10));
number++;
}else{
number = 1;
}
String numFormat = String.format("%06d", number);
String no = inbound.getMaterialNo() + "IN" + numFormat;
inbound.setInboundNo(no);
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String time = sdf.format(date);
inbound.setInboundTime(time);
inbound.setIstatus(1L);
return R.status(inboundService.saveOrUpdate(inbound));
}
@ -122,5 +145,16 @@ public class InboundController extends DafController {
return R.status(inboundService.deleteLogic(Func.toLongList(ids)));
}
/**
* 列表 入库详细
*/
@GetMapping("/getList")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "列表", notes = "传入inbound")
public R<List<Inbound>> getList(Inbound inbound) {
List<Inbound> list = inboundService.list(Condition.getQueryWrapper(inbound));
return R.data(list);
}
}

@ -15,17 +15,29 @@
*/
package org.energy.modules.spares.controller;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dayu.daf.core.log.annotation.ApiLog;
import com.dayu.daf.core.tool.constant.DafConstant;
import com.xkcoding.http.util.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import com.dayu.daf.core.mp.support.Condition;
import com.dayu.daf.core.mp.support.Query;
import com.dayu.daf.core.tool.api.R;
import com.dayu.daf.core.tool.utils.Func;
import lombok.SneakyThrows;
import org.apache.commons.codec.Charsets;
import org.energy.modules.inspection.entity.InspectionRoute;
import org.energy.modules.inspection.excel.InspectionRouteExcel;
import org.energy.modules.spares.excel.MaterialExcel;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -33,6 +45,11 @@ import org.energy.modules.spares.entity.Material;
import org.energy.modules.spares.vo.MaterialVO;
import org.energy.modules.spares.service.IMaterialService;
import com.dayu.daf.core.boot.ctrl.DafController;
import springfox.documentation.annotations.ApiIgnore;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
/**
* 物资 控制器
@ -66,7 +83,34 @@ public class MaterialController extends DafController {
@ApiOperationSupport(order = 2)
@ApiOperation(value = "分页", notes = "传入material")
public R<IPage<Material>> list(Material material, Query query) {
IPage<Material> pages = materialService.page(Condition.getPage(query), Condition.getQueryWrapper(material));
QueryWrapper<Material> qw = new QueryWrapper<>();
qw.orderByAsc("material_no");
// 物资编号
if (StringUtil.isNotEmpty(material.getMaterialNo())) {
qw.lambda().like(Material::getMaterialNo, material.getMaterialNo());
}
// 物资名称
if (StringUtil.isNotEmpty(material.getMaterialName())) {
qw.lambda().like(Material::getMaterialName, material.getMaterialName());
}
// 规格型号
if (StringUtil.isNotEmpty(material.getModel())) {
qw.lambda().like(Material::getModel, material.getModel());
}
// 场站
if (null != material.getStation()) {
qw.lambda().eq(Material::getStation, material.getStation());
}
// 库存数量
if (null != material.getInventoryCount()) {
qw.lambda().eq(Material::getInventoryCount, material.getInventoryCount());
}
IPage<Material> pages = materialService.page(Condition.getPage(query), qw);
return R.data(pages);
}
@ -108,6 +152,18 @@ public class MaterialController extends DafController {
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入material")
public R submit(@Valid @RequestBody Material material) {
material.setIstatus(2L);
String maxNo = materialService.getMaxNo();
int number;
if (StringUtil.isNotEmpty(maxNo)){
number = Integer.parseInt(maxNo.substring(2));
number++;
}else{
number = 1;
}
String numFormat = String.format("%06d", number);
String no = "WZ" + numFormat;
material.setMaterialNo(no);
return R.status(materialService.saveOrUpdate(material));
}
@ -122,5 +178,51 @@ public class MaterialController extends DafController {
return R.status(materialService.deleteLogic(Func.toLongList(ids)));
}
/**
* 获取物资编号
*/
@GetMapping("/getNoList")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "获取物资编号", notes = "获取物资编号")
public R<List<Material>> getNoList() {
List<Material> noList = materialService.getNoList();
return R.data(noList);
}
/**
* 获取物资信息
*/
@GetMapping("/getDetailList")
@ApiOperationSupport(order = 9)
@ApiOperation(value = "获取物资信息", notes = "获取物资信息")
public R<Material> getDetailList(String materialNo) {
Material DetailList = materialService.getDetailList("'" + materialNo + "'");
return R.data(DetailList);
}
/**
* 导出
*/
@SneakyThrows
@GetMapping("export")
@ApiOperationSupport(order = 10)
@ApiOperation(value = "导出", notes = "传入")
@ApiLog
public void exportMaterial(@ApiIgnore @RequestParam Map<String, Object> entity, HttpServletResponse response) {
if (entity.containsKey("station_equal")) {
entity.put("station_equal", Integer.parseInt((String) entity.get("station_equal")));
}
QueryWrapper<Material> queryWrapper = Condition.getQueryWrapper(entity, Material.class);
queryWrapper.lambda().eq(Material::getIsDeleted, DafConstant.DB_NOT_DELETED);
queryWrapper.orderByAsc("material_no");
List<MaterialExcel> list = materialService.exportData(queryWrapper);
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding(Charsets.UTF_8.name());
String fileName = URLEncoder.encode("物资数据导出", Charsets.UTF_8.name());
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), MaterialExcel.class).sheet("物资").doWrite(list);
}
}

@ -26,6 +26,7 @@ import com.dayu.daf.core.mp.support.Condition;
import com.dayu.daf.core.mp.support.Query;
import com.dayu.daf.core.tool.api.R;
import com.dayu.daf.core.tool.utils.Func;
import org.energy.modules.spares.entity.Inbound;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -34,6 +35,8 @@ import org.energy.modules.spares.vo.OutboundVO;
import org.energy.modules.spares.service.IOutboundService;
import com.dayu.daf.core.boot.ctrl.DafController;
import java.util.List;
/**
* 出库 控制器
*
@ -122,5 +125,16 @@ public class OutboundController extends DafController {
return R.status(outboundService.deleteLogic(Func.toLongList(ids)));
}
/**
* 列表 出库详细
*/
@GetMapping("/getList")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "列表", notes = "传入outbound")
public R<List<Outbound>> getList(Outbound outbound) {
List<Outbound> list = outboundService.list(Condition.getQueryWrapper(outbound));
return R.data(list);
}
}

@ -3,6 +3,9 @@ package org.energy.modules.spares.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dayu.daf.core.mp.base.BaseEntity;
import java.io.Serializable;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
@ -25,6 +28,7 @@ public class Material extends BaseEntity {
/**
* 主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "主键")
private Long id;
/**

@ -0,0 +1,61 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.energy.modules.spares.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.io.Serializable;
/**
* EquipmentLedge model export
* @author edwong
*/
@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(16)
public class MaterialExcel implements Serializable {
private static final long serialVersionUID = 1L;
@ColumnWidth(20)
@ExcelProperty(value = "物资编号")
private String materialNo;
@ColumnWidth(15)
@ExcelProperty(value = "场站")
private String stationExt;
@ColumnWidth(15)
@ExcelProperty(value = "物资名称")
private String materialName;
@ColumnWidth(15)
@ExcelProperty(value = "规格型号")
private String model;
@ColumnWidth(15)
@ExcelProperty(value = "库存数量")
private Long inventoryCount;
@ColumnWidth(20)
@ExcelProperty(value = "物资描述")
private String materialDescription;
}

@ -23,4 +23,9 @@ public interface InboundMapper extends BaseMapper<Inbound> {
*/
List<InboundVO> selectInboundPage(IPage page, InboundVO inbound);
/**
* 获取最大编号
*/
String getMaxNo(String materialNo);
}

@ -25,4 +25,8 @@
select * from s_inbound where is_deleted = 0
</select>
<select id="getMaxNo" resultType="java.lang.String">
select max(inbound_no) from s_inbound where is_deleted = 0 and inbound_no like ${materialNo}
</select>
</mapper>

@ -1,6 +1,13 @@
package org.energy.modules.spares.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.apache.ibatis.annotations.Param;
import org.energy.modules.inspection.entity.InspectionRoute;
import org.energy.modules.inspection.entity.InspectionTasks;
import org.energy.modules.inspection.excel.InspectionRouteExcel;
import org.energy.modules.inspection.excel.InspectionTasksExcel;
import org.energy.modules.spares.entity.Material;
import org.energy.modules.spares.excel.MaterialExcel;
import org.energy.modules.spares.vo.MaterialVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -23,4 +30,24 @@ public interface MaterialMapper extends BaseMapper<Material> {
*/
List<MaterialVO> selectMaterialPage(IPage page, MaterialVO material);
/**
* 导出
*/
List<MaterialExcel> exportData(@Param("ew") Wrapper<Material> queryWrapper);
/**
* 获取物资编号
*/
List<Material> getNoList();
/**
* 获取最大编号
*/
String getMaxNo();
/**
* 获取物资的信息
*/
Material getDetailList(String materialNo);
}

@ -29,4 +29,39 @@
select * from s_material where is_deleted = 0
</select>
<select id="getMaxNo" resultType="java.lang.String">
select max(material_no) from s_material
</select>
<select id="getNoList" resultMap="materialResultMap">
select material_no from s_material where is_deleted = 0
</select>
<select id="getDetailList" resultMap="materialResultMap">
select material_name, model
-- ,b.warehouse_name
from s_material
-- inner join (
-- select warehouse_name
-- ,warehouse
-- from warehouse
-- where warehouse in (select warehouse from s_material where material_no = ${materialNo} and is_deleted = 0)
-- ) as b
-- on b.warehouse = s_material.warehouse
where material_no = ${materialNo} and is_deleted = 0
</select>
<select id="exportData" resultType="org.energy.modules.spares.excel.MaterialExcel">
SELECT material_no
,CASE
WHEN station = '1' THEN '景和光伏'
WHEN station = '2' THEN '北沙一光伏'
WHEN station = '3' THEN '北沙二光伏'
WHEN station = '4' THEN '达坂城风电一场'
ELSE ''
END AS station_ext
,material_name, model, inventory_count, material_description
FROM s_material ${ew.customSqlSegment}
</select>
</mapper>

@ -22,4 +22,9 @@ public interface IInboundService extends BaseService<Inbound> {
*/
IPage<InboundVO> selectInboundPage(IPage<InboundVO> page, InboundVO inbound);
/**
* 获取最大编号
*/
String getMaxNo(String materialNo);
}

@ -1,10 +1,15 @@
package org.energy.modules.spares.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.apache.ibatis.annotations.Param;
import org.energy.modules.spares.entity.Material;
import org.energy.modules.spares.excel.MaterialExcel;
import org.energy.modules.spares.vo.MaterialVO;
import com.dayu.daf.core.mp.base.BaseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
* 物资 服务类
*
@ -22,4 +27,24 @@ public interface IMaterialService extends BaseService<Material> {
*/
IPage<MaterialVO> selectMaterialPage(IPage<MaterialVO> page, MaterialVO material);
/**
* 导出
*/
List<MaterialExcel> exportData(Wrapper<Material> queryWrapper);
/**
* 获取物资编号
*/
List<Material> getNoList();
/**
* 获取最大编号
*/
String getMaxNo();
/**
* 获取物资的信息
*/
Material getDetailList(String materialNo);
}

@ -22,4 +22,10 @@ public class InboundServiceImpl extends BaseServiceImpl<InboundMapper, Inbound>
return page.setRecords(baseMapper.selectInboundPage(page, inbound));
}
@Override
public String getMaxNo(String materialNo){
String maxNo = baseMapper.getMaxNo(materialNo);
return maxNo;
}
}

@ -1,6 +1,10 @@
package org.energy.modules.spares.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.energy.modules.inspection.entity.InspectionRoute;
import org.energy.modules.inspection.excel.InspectionRouteExcel;
import org.energy.modules.spares.entity.Material;
import org.energy.modules.spares.excel.MaterialExcel;
import org.energy.modules.spares.vo.MaterialVO;
import org.energy.modules.spares.mapper.MaterialMapper;
import org.energy.modules.spares.service.IMaterialService;
@ -8,6 +12,8 @@ import com.dayu.daf.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
* 物资 服务实现类
*
@ -22,4 +28,28 @@ public class MaterialServiceImpl extends BaseServiceImpl<MaterialMapper, Materia
return page.setRecords(baseMapper.selectMaterialPage(page, material));
}
@Override
public List<MaterialExcel> exportData(Wrapper<Material> queryWrapper) {
List<MaterialExcel> list = baseMapper.exportData(queryWrapper);
return list;
}
@Override
public List<Material> getNoList() {
List<Material> list = baseMapper.getNoList();
return list;
}
@Override
public String getMaxNo(){
String maxNo = baseMapper.getMaxNo();
return maxNo;
}
@Override
public Material getDetailList(String materialNo) {
Material DetailList = baseMapper.getDetailList(materialNo);
return DetailList;
}
}

@ -17,4 +17,15 @@ import io.swagger.annotations.ApiModel;
public class MaterialVO extends Material {
private static final long serialVersionUID = 1L;
// 物资名称
private static final String materialName = "";
// 规格模型
private static final String model = "";
// 仓库名
private static final String warehouseName = "";
}

@ -300,13 +300,17 @@ public class UserController {
* 远程搜索
*/
@GetMapping("/listBySearch")
@ApiOperationSupport(order = 2)
@ApiOperationSupport(order = 16)
@ApiOperation(value = "远程搜索", notes = "传入")
public R<List<User>> listBySearch(String search) {
public R<List<User>> listBySearch(@RequestParam Map<String, Object> map) {
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
if (io.micrometer.core.instrument.util.StringUtils.isNotEmpty(search)) {
queryWrapper.lambda().like(User::getName, search).or().like(User::getCode, search);
if (map != null && map.containsKey("search")) {
queryWrapper.lambda().like(User::getName, map.get("search")).or().like(User::getCode, map.get("search"));
if (map.get("search").toString().matches("\\d+")) {
queryWrapper.lambda().or().eq(User::getId, Long.parseLong(map.get("search").toString()));
}
}
queryWrapper.lambda().eq(User::getIsDeleted, DafConstant.DB_NOT_DELETED);
queryWrapper.lambda().orderByAsc(User::getCreateTime);
queryWrapper.lambda().last(" LIMIT 50");
List<User> list = userService.list(queryWrapper);

@ -1,5 +1,6 @@
package org.energy.modules.system.util;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.function.Supplier;
@ -7,16 +8,64 @@ public class DataUtils {
public static <T> T mapToEntity(Map<String, Object> map, Supplier<T> supplier) {
T entity = supplier.get();
Class<?> clazz = entity.getClass();
map.forEach((key, value) -> {
try {
entity.getClass().getDeclaredField(key).setAccessible(true);
entity.getClass().getDeclaredField(key).set(entity, value);
} catch (NoSuchFieldException | IllegalAccessException e) {
Field field = findField(clazz, key);
if (field != null) {
field.setAccessible(true);
Object castedValue = castValue(field.getType(), value);
field.set(entity, castedValue);
} else {
System.err.println("Field not found: " + key);
}
} catch (IllegalAccessException e) {
System.err.println("IllegalAccessException for field: " + key);
e.printStackTrace();
} catch (Exception e) {
System.err.println("Unexpected exception for field: " + key);
e.printStackTrace();
}
});
return entity;
}
private static Field findField(Class<?> clazz, String fieldName) {
while (clazz != null) {
try {
return clazz.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
clazz = clazz.getSuperclass();
}
}
return null; // Field not found
}
private static Object castValue(Class<?> fieldType, Object value) {
if (value == null) {
return null;
}
if (fieldType.isAssignableFrom(value.getClass())) {
return value;
}
if (fieldType == int.class || fieldType == Integer.class) {
return Integer.parseInt(value.toString());
}
if (fieldType == long.class || fieldType == Long.class) {
return Long.parseLong(value.toString());
}
if (fieldType == float.class || fieldType == Float.class) {
return Float.parseFloat(value.toString());
}
if (fieldType == double.class || fieldType == Double.class) {
return Double.parseDouble(value.toString());
}
if (fieldType == boolean.class || fieldType == Boolean.class) {
return Boolean.parseBoolean(value.toString());
}
// Add more type conversions as needed
return value;
}
}

Loading…
Cancel
Save