Browse Source

#检修导入修改

zhongwei
yang_shj 10 months ago
parent
commit
eceb5b74fc
  1. 2
      hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClient.java
  2. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessLibraryEntity.java
  3. 4
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/feign/SpareClient.java
  4. 3
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.java
  5. 8
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.xml
  6. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java
  7. 1
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java
  8. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java
  9. 102
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java
  10. 0
      hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx
  11. 4
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml

2
hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClient.java

@ -37,6 +37,6 @@ public interface ISpareClient {
@PostMapping(EXCEED_LIMIT) @PostMapping(EXCEED_LIMIT)
List<AreaTimelyVo> exceedLimit(@RequestParam("deptId") Long deptId); List<AreaTimelyVo> exceedLimit(@RequestParam("deptId") Long deptId);
@GetMapping(EXCEED_LIMIT) @PostMapping(SPARE_PART)
List<SparePartVO> sparePart(@RequestParam("basics") List<Long> basics); List<SparePartVO> sparePart(@RequestParam("basics") List<Long> basics);
} }

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessLibraryEntity.java

@ -34,6 +34,12 @@ public class OperAccessLibraryEntity extends TenantEntity {
private String emCode; private String emCode;
/** /**
* 设备编码
*/
@ApiModelProperty(value = "设备名称")
private String emName;
/**
* 检修等级 * 检修等级
*/ */
@ApiModelProperty(value = "检修等级") @ApiModelProperty(value = "检修等级")

4
hzims-service/assets/src/main/java/com/hnac/hzims/spare/feign/SpareClient.java

@ -14,6 +14,9 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
@ -137,6 +140,7 @@ public class SpareClient implements ISpareClient{
* @return * @return
*/ */
@Override @Override
@PostMapping(SPARE_PART)
public List<SparePartVO> sparePart(List<Long> basics) { public List<SparePartVO> sparePart(List<Long> basics) {
return wtSpBasicService.sparePart(basics); return wtSpBasicService.sparePart(basics);
} }

3
hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.java

@ -4,6 +4,7 @@ import com.hnac.hzims.spare.entity.SpTemporaryStockDetailEntity;
import com.hnac.hzims.spare.entity.WtSpBasicEntity; import com.hnac.hzims.spare.entity.WtSpBasicEntity;
import com.hnac.hzims.spare.vo.SparePartVO; import com.hnac.hzims.spare.vo.SparePartVO;
import com.hnac.hzims.spare.vo.WtSpBasicVO; import com.hnac.hzims.spare.vo.WtSpBasicVO;
import org.apache.ibatis.annotations.Param;
import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.annotation.UserDataAuth;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@ -48,5 +49,5 @@ public interface WtSpBasicMapper extends UserDataScopeBaseMapper<WtSpBasicEntity
@UserDataAuth @UserDataAuth
List<SpTemporaryStockDetailEntity> getInList(Long spBasicId); List<SpTemporaryStockDetailEntity> getInList(Long spBasicId);
List<SparePartVO> sparePart(@RequestParam("basics") List<Long> basics); List<SparePartVO> sparePart(@Param("basicIds") List<Long> basics);
} }

8
hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.xml

@ -101,10 +101,10 @@
LEFT JOIN WT_SP_WAREHOUSE house ON total.WAREHOUSE_ID = house.id LEFT JOIN WT_SP_WAREHOUSE house ON total.WAREHOUSE_ID = house.id
<where> <where>
1 = 2 OR 1 = 2 OR
<if test="basics != null"> <if test="basicIds != null">
and basic.ID in basic.ID in
<foreach collection="basics" item="basic" index="index" open="(" close=")" separator=","> <foreach collection="basicIds" item="item" index="index" open="(" close=")" separator=",">
#{basic} #{item}
</foreach> </foreach>
</if> </if>
</where> </where>

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java

@ -98,4 +98,11 @@ public class OperAccessLibraryController extends BladeController {
public void downLoad() { public void downLoad() {
service.downLoad(); service.downLoad();
} }
@ApiOperation(value = "检修库导入")
@ApiOperationSupport(order = 7)
@PostMapping(value = "/import")
public void libraryImport(@RequestParam("library") MultipartFile multipartFile) {
service.libraryImport(multipartFile);
}
} }

1
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java

@ -101,6 +101,7 @@ public class OperAccessTaskController extends BladeController {
public R<IPage<OperAccessTaskVO>> list(OperAccessTaskDTO req, Query query) { public R<IPage<OperAccessTaskVO>> list(OperAccessTaskDTO req, Query query) {
return service.list(req, query); return service.list(req, query);
} }
/** /**
* 分页 * 分页
*/ */

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java

@ -10,6 +10,8 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
/** /**
* 服务类 * 服务类
* *
@ -27,4 +29,6 @@ public interface IOperAccessLibraryService extends BaseService<OperAccessLibrary
R<IPage<OperAccessLibraryVO>> list(OperAccessLibraryListDTO req, Query query); R<IPage<OperAccessLibraryVO>> list(OperAccessLibraryListDTO req, Query query);
void downLoad(); void downLoad();
void libraryImport(MultipartFile multipartFile);
} }

102
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java

@ -17,25 +17,37 @@ import com.hnac.hzims.operational.access.service.IOperAccessLibraryDetailService
import com.hnac.hzims.operational.access.service.IOperAccessLibraryService; import com.hnac.hzims.operational.access.service.IOperAccessLibraryService;
import com.hnac.hzims.operational.access.vo.OperAccessLibraryVO; import com.hnac.hzims.operational.access.vo.OperAccessLibraryVO;
import com.hnac.hzims.operational.access.wrapper.OperAccessLibraryWrapper; import com.hnac.hzims.operational.access.wrapper.OperAccessLibraryWrapper;
import com.hnac.hzims.operational.util.ExcelUtil;
import com.hnac.hzims.operational.util.PdfUtils;
import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; import com.hnac.hzims.safeproduct.feign.IDangerSourceClient;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.jfree.chart.util.ExportUtils; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.system.cache.DictCache;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.net.URLEncoder;
import java.util.List; import java.nio.file.Files;
import java.util.Set; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -102,7 +114,89 @@ public class OperAccessLibraryServiceImpl extends BaseServiceImpl<OperAccessLibr
public void downLoad(){ public void downLoad(){
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletResponse response = servletRequestAttributes.getResponse(); HttpServletResponse response = servletRequestAttributes.getResponse();
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
InputStream inputStream = null;
// 获取输入流,原始模板位置
try {
Resource[] resources = resolver.getResources("template/excel/access_import_template.xlsx");
inputStream = resources[0].getInputStream();
//假如以中文名下载的话,设置下载文件名称
String filename = "检修导入模板.xlsx";
//转码,免得文件名中文乱码
filename = URLEncoder.encode(filename,"UTF-8");
//设置文件下载头
response.addHeader("Content-Disposition", "attachment;filename=" + filename);
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
int len = 0;
while((len = inputStream.read()) != -1){
out.write(len);
out.flush();
}
out.close();
}catch (Exception e){
throw new ServiceException("检修导入模板下载失败!");
}
}
/**
* 检修库导入
* @param multipartFile
*/
@Override
public void libraryImport(MultipartFile multipartFile){
// 文件名检查
String fileName = multipartFile.getOriginalFilename();
if(!fileName.endsWith(PdfUtils.XLS_SUFFIX) && !fileName.endsWith(PdfUtils.XLSX_SUFFIX)){
throw new ServiceException("导入文件类型错误!");
}
Workbook workbook = null ;
try{
workbook = new HSSFWorkbook(multipartFile.getInputStream());
}catch (IOException ioException){
throw new ServiceException("导入文件读取失败!");
}
// 读取sheet页
Sheet sheet = workbook.getSheet("Sheet1");
// 获取行数
int rows = sheet.getLastRowNum();
if(rows==0){
throw new ServiceException("请填写导入检修库数据!");
}
List<OperAccessLibraryDetailEntity> details = new ArrayList<>();
Long libraryId = null;
for (int i = 2; i <= rows + 1; i++) {
// 读取左上端单元格
Row row = sheet.getRow(i);
// 行不为空
if (row == null) {
continue;
}
if( (i - 1) % 4 == 1){
if(StringUtils.isEmpty(row.getCell(1).getStringCellValue())){
continue;
}
OperAccessLibraryEntity library = new OperAccessLibraryEntity();
library.setEmName(row.getCell(1).getStringCellValue());
library.setGradeCode(DictCache.getValue("gradeCode",row.getCell(2).getStringCellValue()));
library.setLastServiceTime(row.getCell(3).getDateCellValue());
library.setPeriod((int)row.getCell(4).getNumericCellValue());
library.setStopHours((int)row.getCell(5).getNumericCellValue());
this.save(library);
libraryId = library.getId();
}
if(StringUtils.isNotEmpty(row.getCell(6).getStringCellValue())){
OperAccessLibraryDetailEntity detail = new OperAccessLibraryDetailEntity();
detail.setName(row.getCell(6).getStringCellValue());
detail.setContent(row.getCell(7).getStringCellValue());
detail.setPid(libraryId);
details.add(detail);
}
}
this.libraryDetailService.saveBatch(details);
} }
/** /**

0
hzims-service/operational/src/main/resources/template/excel/access_import_template.xls → hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx

4
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml

@ -100,10 +100,10 @@
</foreach> </foreach>
</if> </if>
<if test="startTime != null"> <if test="startTime != null">
and info.make_date_time &gt;= #{startTime} and info.plan_start_time &gt;= #{startTime}
</if> </if>
<if test="endTime != null"> <if test="endTime != null">
and info.make_date_time &lt;= #{endTime} and info.plan_start_time &lt;= #{endTime}
</if> </if>
</where> </where>
GROUP BY info.EM_CODE,info.`type` GROUP BY info.EM_CODE,info.`type`

Loading…
Cancel
Save