|
|
@ -15,17 +15,29 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.energy.modules.spares.controller; |
|
|
|
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.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.validation.Valid; |
|
|
|
import javax.validation.Valid; |
|
|
|
|
|
|
|
|
|
|
|
import com.dayu.daf.core.mp.support.Condition; |
|
|
|
import com.dayu.daf.core.mp.support.Condition; |
|
|
|
import com.dayu.daf.core.mp.support.Query; |
|
|
|
import com.dayu.daf.core.mp.support.Query; |
|
|
|
import com.dayu.daf.core.tool.api.R; |
|
|
|
import com.dayu.daf.core.tool.api.R; |
|
|
|
import com.dayu.daf.core.tool.utils.Func; |
|
|
|
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.*; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
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.vo.MaterialVO; |
|
|
|
import org.energy.modules.spares.service.IMaterialService; |
|
|
|
import org.energy.modules.spares.service.IMaterialService; |
|
|
|
import com.dayu.daf.core.boot.ctrl.DafController; |
|
|
|
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) |
|
|
|
@ApiOperationSupport(order = 2) |
|
|
|
@ApiOperation(value = "分页", notes = "传入material") |
|
|
|
@ApiOperation(value = "分页", notes = "传入material") |
|
|
|
public R<IPage<Material>> list(Material material, Query query) { |
|
|
|
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); |
|
|
|
return R.data(pages); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -108,6 +152,18 @@ public class MaterialController extends DafController { |
|
|
|
@ApiOperationSupport(order = 6) |
|
|
|
@ApiOperationSupport(order = 6) |
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入material") |
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入material") |
|
|
|
public R submit(@Valid @RequestBody Material 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)); |
|
|
|
return R.status(materialService.saveOrUpdate(material)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -122,5 +178,51 @@ public class MaterialController extends DafController { |
|
|
|
return R.status(materialService.deleteLogic(Func.toLongList(ids))); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|