Compare commits

...

2 Commits

Author SHA1 Message Date
dingjie b57fd54e9e 文件上传接口 2023-12-15 21:07:49 +08:00
dingjie 5906f6cc50 新购验收部分 2023-12-15 21:07:27 +08:00
24 changed files with 1496 additions and 16 deletions

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.base.api.domain;
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
@ -22,6 +23,14 @@ public class MaType extends BaseEntity {
@ApiModelProperty(value = "类型名称")
private String typeName;
/** 类型ID */
@ApiModelProperty(value = "类型ID,用作组织树筛选")
private Long id;
/** 类型名称 */
@ApiModelProperty(value = "类型名称,用作组织树筛选")
private String label;
/** 上级ID */
@ApiModelProperty(value = "上级ID")
private Long parentId;
@ -157,6 +166,8 @@ public class MaType extends BaseEntity {
@ApiModelProperty(value = "资产属性名称")
private String propName;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<MaType> children = new ArrayList<>();
@ -465,4 +476,20 @@ public class MaType extends BaseEntity {
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}

View File

@ -324,6 +324,7 @@ public class MaTypeServiceImpl implements ITypeService {
Long pid = maType.getParentId();
if (parentId.equals(pid)) {
List<MaType> childLists = getChild(list, typeId);
maType.setChildren(childLists);
childList.add(maType);
}

View File

@ -154,7 +154,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl,
mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId,
su.user_name keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id
m.remark, m.company_id ,m.type_id id , m.type_name label
from ma_type m
left join ma_prop_set mps on m.type_id = mps.type_id
left join ma_prop_info mpi on mps.prop_id = mpi.prop_id

View File

@ -45,7 +45,6 @@ public class PurchaseCheckDetailsController extends BaseController
@GetMapping("/list")
public TableDataInfo list(PurchaseCheckDetails purchaseCheckDetails)
{
startPage();
List<PurchaseCheckDetails> list = purchaseCheckDetailsService.selectPurchaseCheckDetailsList(purchaseCheckDetails);
return getDataTable(list);
}

View File

@ -0,0 +1,105 @@
package com.bonus.sgzb.material.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.sgzb.material.domain.ScrapApplyDetails;
import com.bonus.sgzb.material.service.IScrapApplyDetailsService;
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 com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.common.security.annotation.RequiresPermissions;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
/**
* 报废任务详细scrap_apply_detailsController
*
* @author bonus
* @date 2023-12-15
*/
@RestController
@RequestMapping("/details")
public class ScrapApplyDetailsController extends BaseController
{
@Autowired
private IScrapApplyDetailsService scrapApplyDetailsService;
/**
* 查询报废任务详细scrap_apply_details列表
*/
@RequiresPermissions("system:details:list")
@GetMapping("/list")
public TableDataInfo list(ScrapApplyDetails scrapApplyDetails)
{
startPage();
List<ScrapApplyDetails> list = scrapApplyDetailsService.selectScrapApplyDetailsList(scrapApplyDetails);
return getDataTable(list);
}
/**
* 导出报废任务详细scrap_apply_details列表
*/
@RequiresPermissions("system:details:export")
@Log(title = "报废任务详细scrap_apply_details", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScrapApplyDetails scrapApplyDetails)
{
List<ScrapApplyDetails> list = scrapApplyDetailsService.selectScrapApplyDetailsList(scrapApplyDetails);
ExcelUtil<ScrapApplyDetails> util = new ExcelUtil<ScrapApplyDetails>(ScrapApplyDetails.class);
util.exportExcel(response, list, "报废任务详细scrap_apply_details数据");
}
/**
* 获取报废任务详细scrap_apply_details详细信息
*/
@RequiresPermissions("system:details:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(scrapApplyDetailsService.selectScrapApplyDetailsById(id));
}
/**
* 新增报废任务详细scrap_apply_details
*/
@RequiresPermissions("system:details:add")
@Log(title = "报废任务详细scrap_apply_details", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScrapApplyDetails scrapApplyDetails)
{
return toAjax(scrapApplyDetailsService.insertScrapApplyDetails(scrapApplyDetails));
}
/**
* 修改报废任务详细scrap_apply_details
*/
@RequiresPermissions("system:details:edit")
@Log(title = "报废任务详细scrap_apply_details", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScrapApplyDetails scrapApplyDetails)
{
return toAjax(scrapApplyDetailsService.updateScrapApplyDetails(scrapApplyDetails));
}
/**
* 删除报废任务详细scrap_apply_details
*/
@RequiresPermissions("system:details:remove")
@Log(title = "报废任务详细scrap_apply_details", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(scrapApplyDetailsService.deleteScrapApplyDetailsByIds(ids));
}
}

View File

@ -0,0 +1,112 @@
package com.bonus.sgzb.material.domain;
import com.bonus.sgzb.common.core.annotation.Excel;
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 二维码管理bm_qrcode_info对象 bm_qrcode_info
*
* @author bonus
* @date 2023-12-15
*/
public class BmQrcodeInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 二维码ID */
private Long qrId;
/** 二维码 */
@Excel(name = "二维码")
private String qrCode;
/** 类型ID */
@Excel(name = "类型ID")
private Long typeId;
/** 二维码类型 */
@Excel(name = "二维码类型")
private String qrType;
/** 任务ID */
@Excel(name = "任务ID")
private Long taskId;
/** 数据所属组织 */
@Excel(name = "数据所属组织")
private Long companyId;
public void setQrId(Long qrId)
{
this.qrId = qrId;
}
public Long getQrId()
{
return qrId;
}
public void setQrCode(String qrCode)
{
this.qrCode = qrCode;
}
public String getQrCode()
{
return qrCode;
}
public void setTypeId(Long typeId)
{
this.typeId = typeId;
}
public Long getTypeId()
{
return typeId;
}
public void setQrType(String qrType)
{
this.qrType = qrType;
}
public String getQrType()
{
return qrType;
}
public void setTaskId(Long taskId)
{
this.taskId = taskId;
}
public Long getTaskId()
{
return taskId;
}
public void setCompanyId(Long companyId)
{
this.companyId = companyId;
}
public Long getCompanyId()
{
return companyId;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("qrId", getQrId())
.append("qrCode", getQrCode())
.append("typeId", getTypeId())
.append("qrType", getQrType())
.append("taskId", getTaskId())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("companyId", getCompanyId())
.toString();
}
}

View File

@ -63,6 +63,10 @@ public class PurchaseCheckDetails extends BaseEntity
@ApiModelProperty(value = "出厂日期")
private Date productionTime;
/** 入库数量 */
@ApiModelProperty(value = "入库数量")
private double inputNum;
/** 验收图片 */
@ApiModelProperty(value = "验收图片")
private String checkUrlName;
@ -90,7 +94,7 @@ public class PurchaseCheckDetails extends BaseEntity
private String specificationType;
@ApiModelProperty(value = "机具类型名称")
private String typeName;
private String machineTypeName;
public void setTaskId(Long taskId)
{
@ -172,14 +176,6 @@ public class PurchaseCheckDetails extends BaseEntity
this.specificationType = specificationType;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public String getSupplier() {
return supplier;
}
@ -244,6 +240,22 @@ public class PurchaseCheckDetails extends BaseEntity
this.status = status;
}
public String getMachineTypeName() {
return machineTypeName;
}
public void setMachineTypeName(String machineTypeName) {
this.machineTypeName = machineTypeName;
}
public double getInputNum() {
return inputNum;
}
public void setInputNum(double inputNum) {
this.inputNum = inputNum;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

View File

@ -0,0 +1,243 @@
package com.bonus.sgzb.material.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.bonus.sgzb.common.core.annotation.Excel;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 报废任务详细scrap_apply_details对象 scrap_apply_details
*
* @author bonus
* @date 2023-12-15
*/
public class ScrapApplyDetails extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 任务ID */
@Excel(name = "任务ID")
private Long taskId;
/** 上级ID */
@Excel(name = "上级ID")
private Long parentId;
/** 机具ID */
@Excel(name = "机具ID")
private Long maId;
/** 规格ID */
@Excel(name = "规格ID")
private Long typeId;
/** 报废数量 */
@Excel(name = "报废数量")
private BigDecimal scrapNum;
/** (1退料2,维修审核3盘点) */
@Excel(name = "(1退料2,维修审核3盘点)")
private String scrapSource;
/** 0自然1人为 */
@Excel(name = "", readConverterExp = "0=自然1人为")
private String scrapType;
/** 状态0进行中1已审核2驳回 */
@Excel(name = "状态", readConverterExp = "0=进行中1已审核2驳回")
private String status;
/** 审核人 */
@Excel(name = "审核人")
private Long auditBy;
/** 审核时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date auditTime;
/** 审核备注 */
@Excel(name = "审核备注")
private String auditRemark;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String fileUrl;
/** 数据所属组织 */
@Excel(name = "数据所属组织")
private Long companyId;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String fileName;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setTaskId(Long taskId)
{
this.taskId = taskId;
}
public Long getTaskId()
{
return taskId;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
public Long getParentId()
{
return parentId;
}
public void setMaId(Long maId)
{
this.maId = maId;
}
public Long getMaId()
{
return maId;
}
public void setTypeId(Long typeId)
{
this.typeId = typeId;
}
public Long getTypeId()
{
return typeId;
}
public void setScrapNum(BigDecimal scrapNum)
{
this.scrapNum = scrapNum;
}
public BigDecimal getScrapNum()
{
return scrapNum;
}
public void setScrapSource(String scrapSource)
{
this.scrapSource = scrapSource;
}
public String getScrapSource()
{
return scrapSource;
}
public void setScrapType(String scrapType)
{
this.scrapType = scrapType;
}
public String getScrapType()
{
return scrapType;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setAuditBy(Long auditBy)
{
this.auditBy = auditBy;
}
public Long getAuditBy()
{
return auditBy;
}
public void setAuditTime(Date auditTime)
{
this.auditTime = auditTime;
}
public Date getAuditTime()
{
return auditTime;
}
public void setAuditRemark(String auditRemark)
{
this.auditRemark = auditRemark;
}
public String getAuditRemark()
{
return auditRemark;
}
public void setFileUrl(String fileUrl)
{
this.fileUrl = fileUrl;
}
public String getFileUrl()
{
return fileUrl;
}
public void setCompanyId(Long companyId)
{
this.companyId = companyId;
}
public Long getCompanyId()
{
return companyId;
}
public void setFileName(String fileName)
{
this.fileName = fileName;
}
public String getFileName()
{
return fileName;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("taskId", getTaskId())
.append("parentId", getParentId())
.append("maId", getMaId())
.append("typeId", getTypeId())
.append("scrapNum", getScrapNum())
.append("scrapSource", getScrapSource())
.append("scrapType", getScrapType())
.append("status", getStatus())
.append("auditBy", getAuditBy())
.append("auditTime", getAuditTime())
.append("auditRemark", getAuditRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("fileUrl", getFileUrl())
.append("companyId", getCompanyId())
.append("fileName", getFileName())
.toString();
}
}

View File

@ -0,0 +1,64 @@
package com.bonus.sgzb.material.mapper;
import com.bonus.sgzb.material.domain.BmQrcodeInfo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 二维码管理bm_qrcode_infoMapper接口
*
* @author bonus
* @date 2023-12-15
*/
@Mapper
public interface BmQrcodeInfoMapper
{
/**
* 查询二维码管理bm_qrcode_info
*
* @param qrId 二维码管理bm_qrcode_info主键
* @return 二维码管理bm_qrcode_info
*/
public BmQrcodeInfo selectBmQrcodeInfoByQrId(Long qrId);
/**
* 查询二维码管理bm_qrcode_info列表
*
* @param bmQrcodeInfo 二维码管理bm_qrcode_info
* @return 二维码管理bm_qrcode_info集合
*/
public List<BmQrcodeInfo> selectBmQrcodeInfoList(BmQrcodeInfo bmQrcodeInfo);
/**
* 新增二维码管理bm_qrcode_info
*
* @param bmQrcodeInfo 二维码管理bm_qrcode_info
* @return 结果
*/
public int insertBmQrcodeInfo(BmQrcodeInfo bmQrcodeInfo);
/**
* 修改二维码管理bm_qrcode_info
*
* @param bmQrcodeInfo 二维码管理bm_qrcode_info
* @return 结果
*/
public int updateBmQrcodeInfo(BmQrcodeInfo bmQrcodeInfo);
/**
* 删除二维码管理bm_qrcode_info
*
* @param qrId 二维码管理bm_qrcode_info主键
* @return 结果
*/
public int deleteBmQrcodeInfoByQrId(Long qrId);
/**
* 批量删除二维码管理bm_qrcode_info
*
* @param qrIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteBmQrcodeInfoByQrIds(Long[] qrIds);
}

View File

@ -0,0 +1,64 @@
package com.bonus.sgzb.material.mapper;
import com.bonus.sgzb.material.domain.ScrapApplyDetails;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 报废任务详细scrap_apply_detailsMapper接口
*
* @author bonus
* @date 2023-12-15
*/
@Mapper
public interface ScrapApplyDetailsMapper
{
/**
* 查询报废任务详细scrap_apply_details
*
* @param id 报废任务详细scrap_apply_details主键
* @return 报废任务详细scrap_apply_details
*/
public ScrapApplyDetails selectScrapApplyDetailsById(Long id);
/**
* 查询报废任务详细scrap_apply_details列表
*
* @param scrapApplyDetails 报废任务详细scrap_apply_details
* @return 报废任务详细scrap_apply_details集合
*/
public List<ScrapApplyDetails> selectScrapApplyDetailsList(ScrapApplyDetails scrapApplyDetails);
/**
* 新增报废任务详细scrap_apply_details
*
* @param scrapApplyDetails 报废任务详细scrap_apply_details
* @return 结果
*/
public int insertScrapApplyDetails(ScrapApplyDetails scrapApplyDetails);
/**
* 修改报废任务详细scrap_apply_details
*
* @param scrapApplyDetails 报废任务详细scrap_apply_details
* @return 结果
*/
public int updateScrapApplyDetails(ScrapApplyDetails scrapApplyDetails);
/**
* 删除报废任务详细scrap_apply_details
*
* @param id 报废任务详细scrap_apply_details主键
* @return 结果
*/
public int deleteScrapApplyDetailsById(Long id);
/**
* 批量删除报废任务详细scrap_apply_details
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScrapApplyDetailsByIds(Long[] ids);
}

View File

@ -0,0 +1,62 @@
package com.bonus.sgzb.material.service;
import com.bonus.sgzb.material.domain.ScrapApplyDetails;
import java.util.List;
/**
* 报废任务详细scrap_apply_detailsService接口
*
* @author bonus
* @date 2023-12-15
*/
public interface IScrapApplyDetailsService
{
/**
* 查询报废任务详细scrap_apply_details
*
* @param id 报废任务详细scrap_apply_details主键
* @return 报废任务详细scrap_apply_details
*/
public ScrapApplyDetails selectScrapApplyDetailsById(Long id);
/**
* 查询报废任务详细scrap_apply_details列表
*
* @param scrapApplyDetails 报废任务详细scrap_apply_details
* @return 报废任务详细scrap_apply_details集合
*/
public List<ScrapApplyDetails> selectScrapApplyDetailsList(ScrapApplyDetails scrapApplyDetails);
/**
* 新增报废任务详细scrap_apply_details
*
* @param scrapApplyDetails 报废任务详细scrap_apply_details
* @return 结果
*/
public int insertScrapApplyDetails(ScrapApplyDetails scrapApplyDetails);
/**
* 修改报废任务详细scrap_apply_details
*
* @param scrapApplyDetails 报废任务详细scrap_apply_details
* @return 结果
*/
public int updateScrapApplyDetails(ScrapApplyDetails scrapApplyDetails);
/**
* 批量删除报废任务详细scrap_apply_details
*
* @param ids 需要删除的报废任务详细scrap_apply_details主键集合
* @return 结果
*/
public int deleteScrapApplyDetailsByIds(Long[] ids);
/**
* 删除报废任务详细scrap_apply_details信息
*
* @param id 报废任务详细scrap_apply_details主键
* @return 结果
*/
public int deleteScrapApplyDetailsById(Long id);
}

View File

@ -51,7 +51,12 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService
@Override
public PurchaseCheckInfo selectPurchaseCheckInfoByTaskId(Long taskId)
{
return purchaseCheckInfoMapper.selectPurchaseCheckInfoByTaskId(taskId);
PurchaseCheckInfo purchaseCheckInfo = purchaseCheckInfoMapper.selectPurchaseCheckInfoByTaskId(taskId);
PurchaseCheckDetails purchaseCheckDetails = new PurchaseCheckDetails();
purchaseCheckDetails.setTaskId(purchaseCheckInfo.getTaskId());
List<PurchaseCheckDetails> purchaseCheckDetailsList = purchaseCheckDetailsMapper.selectPurchaseCheckDetailsList(purchaseCheckDetails);
purchaseCheckInfo.setCheckDetailsList(purchaseCheckDetailsList);
return purchaseCheckInfo;
}
/**
@ -100,7 +105,7 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService
{
TmTask task = new TmTask();
// 暂定的状态字典表
task.setTaskType(14);
task.setTaskType(23);
task.setTaskStatus(24);
// 采购单号
task.setCode(purchaseCodeRule());

View File

@ -8,8 +8,10 @@ import java.util.List;
import com.alibaba.fastjson.JSONObject;
import com.bonus.sgzb.base.api.domain.MaMachine;
import com.bonus.sgzb.base.api.domain.TmTask;
import com.bonus.sgzb.material.domain.BmQrcodeInfo;
import com.bonus.sgzb.material.domain.MaInputRecord;
import com.bonus.sgzb.material.domain.PurchaseMacodeInfo;
import com.bonus.sgzb.material.mapper.BmQrcodeInfoMapper;
import com.bonus.sgzb.material.mapper.PurchaseMacodeInfoMapper;
import com.bonus.sgzb.material.mapper.TaskMapper;
import com.bonus.sgzb.material.service.IPurchaseMacodeInfoService;
@ -34,6 +36,9 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService
@Resource
private TaskMapper taskMapper;
@Resource
private BmQrcodeInfoMapper qrcodeInfoMapper;
/**
@ -82,9 +87,10 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService
for (PurchaseMacodeInfo purchaseMacodeInfo : purchaseMacodeInfoList) {
MaMachine maMachine = new MaMachine();
maMachine.setTypeId(purchaseMacodeInfo.getTypeId());
Long typeId = purchaseMacodeInfo.getTypeId();
maMachine.setTypeId(typeId);
// 查询机具类型前三级名称
JSONObject jsonObject = purchaseMacodeInfoMapper.getTypeNameByTypeId(purchaseMacodeInfo.getTypeId());
JSONObject jsonObject = purchaseMacodeInfoMapper.getTypeNameByTypeId(typeId);
String specsName = jsonObject.getString("specsName");
String typeName = jsonObject.getString("typeName");
String itemTypeName = jsonObject.getString("itemTypeName");
@ -105,6 +111,14 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService
maMachine.setMaCode(purchaseMacodeInfo.getMaCode());
purchaseMacodeInfoMapper.maMachineAdd(maMachine);
// 二维码存储
BmQrcodeInfo bmQrcodeInfo = new BmQrcodeInfo();
bmQrcodeInfo.setTypeId(typeId);
bmQrcodeInfo.setQrCode(purchaseMacodeInfo.getQrCode());
bmQrcodeInfo.setTaskId(purchaseMacodeInfo.getTaskId());
bmQrcodeInfo.setCreateTime(new Date());
qrcodeInfoMapper.insertBmQrcodeInfo(bmQrcodeInfo);
// 修改新购机具编码
purchaseMacodeInfo.setUpdateTime(DateUtils.getNowDate());
purchaseMacodeInfoMapper.updatePurchaseMacodeInfo(purchaseMacodeInfo);
@ -157,6 +171,8 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService
int i1 = count + i;
// 编码规则
String codingRule = "NXJJ" + typeCode + format + specsCode + "-000" + i1;
// 二维码
String code = format + "000" + i1;
list.add(codingRule);
}

View File

@ -0,0 +1,96 @@
package com.bonus.sgzb.material.service.impl;
import java.util.List;
import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.material.domain.ScrapApplyDetails;
import com.bonus.sgzb.material.mapper.ScrapApplyDetailsMapper;
import com.bonus.sgzb.material.service.IScrapApplyDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 报废任务详细scrap_apply_detailsService业务层处理
*
* @author bonus
* @date 2023-12-15
*/
@Service
public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService
{
@Autowired
private ScrapApplyDetailsMapper scrapApplyDetailsMapper;
/**
* 查询报废任务详细scrap_apply_details
*
* @param id 报废任务详细scrap_apply_details主键
* @return 报废任务详细scrap_apply_details
*/
@Override
public ScrapApplyDetails selectScrapApplyDetailsById(Long id)
{
return scrapApplyDetailsMapper.selectScrapApplyDetailsById(id);
}
/**
* 查询报废任务详细scrap_apply_details列表
*
* @param scrapApplyDetails 报废任务详细scrap_apply_details
* @return 报废任务详细scrap_apply_details
*/
@Override
public List<ScrapApplyDetails> selectScrapApplyDetailsList(ScrapApplyDetails scrapApplyDetails)
{
return scrapApplyDetailsMapper.selectScrapApplyDetailsList(scrapApplyDetails);
}
/**
* 新增报废任务详细scrap_apply_details
*
* @param scrapApplyDetails 报废任务详细scrap_apply_details
* @return 结果
*/
@Override
public int insertScrapApplyDetails(ScrapApplyDetails scrapApplyDetails)
{
scrapApplyDetails.setCreateTime(DateUtils.getNowDate());
return scrapApplyDetailsMapper.insertScrapApplyDetails(scrapApplyDetails);
}
/**
* 修改报废任务详细scrap_apply_details
*
* @param scrapApplyDetails 报废任务详细scrap_apply_details
* @return 结果
*/
@Override
public int updateScrapApplyDetails(ScrapApplyDetails scrapApplyDetails)
{
scrapApplyDetails.setUpdateTime(DateUtils.getNowDate());
return scrapApplyDetailsMapper.updateScrapApplyDetails(scrapApplyDetails);
}
/**
* 批量删除报废任务详细scrap_apply_details
*
* @param ids 需要删除的报废任务详细scrap_apply_details主键
* @return 结果
*/
@Override
public int deleteScrapApplyDetailsByIds(Long[] ids)
{
return scrapApplyDetailsMapper.deleteScrapApplyDetailsByIds(ids);
}
/**
* 删除报废任务详细scrap_apply_details信息
*
* @param id 报废任务详细scrap_apply_details主键
* @return 结果
*/
@Override
public int deleteScrapApplyDetailsById(Long id)
{
return scrapApplyDetailsMapper.deleteScrapApplyDetailsById(id);
}
}

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.sgzb.material.mapper.BmQrcodeInfoMapper">
<resultMap type="com.bonus.sgzb.material.domain.BmQrcodeInfo" id="BmQrcodeInfoResult">
<result property="qrId" column="qr_id" />
<result property="qrCode" column="qr_code" />
<result property="typeId" column="type_id" />
<result property="qrType" column="qr_type" />
<result property="taskId" column="task_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="companyId" column="company_id" />
</resultMap>
<sql id="selectBmQrcodeInfoVo">
select qr_id, qr_code, type_id, qr_type, task_id, create_by, create_time, update_by, update_time, remark, company_id from bm_qrcode_info
</sql>
<select id="selectBmQrcodeInfoList" parameterType="com.bonus.sgzb.material.domain.BmQrcodeInfo" resultMap="BmQrcodeInfoResult">
<include refid="selectBmQrcodeInfoVo"/>
<where>
<if test="qrCode != null and qrCode != ''"> and qr_code = #{qrCode}</if>
<if test="typeId != null "> and type_id = #{typeId}</if>
<if test="qrType != null and qrType != ''"> and qr_type = #{qrType}</if>
<if test="taskId != null "> and task_id = #{taskId}</if>
<if test="companyId != null "> and company_id = #{companyId}</if>
</where>
</select>
<select id="selectBmQrcodeInfoByQrId" parameterType="Long" resultMap="BmQrcodeInfoResult">
<include refid="selectBmQrcodeInfoVo"/>
where qr_id = #{qrId}
</select>
<insert id="insertBmQrcodeInfo" parameterType="com.bonus.sgzb.material.domain.BmQrcodeInfo" useGeneratedKeys="true" keyProperty="qrId">
insert into bm_qrcode_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="qrCode != null">qr_code,</if>
<if test="typeId != null">type_id,</if>
<if test="qrType != null">qr_type,</if>
<if test="taskId != null">task_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="companyId != null">company_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="qrCode != null">#{qrCode},</if>
<if test="typeId != null">#{typeId},</if>
<if test="qrType != null">#{qrType},</if>
<if test="taskId != null">#{taskId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="companyId != null">#{companyId},</if>
</trim>
</insert>
<update id="updateBmQrcodeInfo" parameterType="com.bonus.sgzb.material.domain.BmQrcodeInfo">
update bm_qrcode_info
<trim prefix="SET" suffixOverrides=",">
<if test="qrCode != null">qr_code = #{qrCode},</if>
<if test="typeId != null">type_id = #{typeId},</if>
<if test="qrType != null">qr_type = #{qrType},</if>
<if test="taskId != null">task_id = #{taskId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="companyId != null">company_id = #{companyId},</if>
</trim>
where qr_id = #{qrId}
</update>
<delete id="deleteBmQrcodeInfoByQrId" parameterType="Long">
delete from bm_qrcode_info where qr_id = #{qrId}
</delete>
<delete id="deleteBmQrcodeInfoByQrIds" parameterType="String">
delete from bm_qrcode_info where qr_id in
<foreach item="qrId" collection="array" open="(" separator="," close=")">
#{qrId}
</foreach>
</delete>
</mapper>

View File

@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select pcd.id,pcd.task_id, pcd.type_id, pcd.purchase_price, pcd.purchase_num, pcd.check_num, pcd.check_result,
pcd.supplier_id, pcd.status, msi.supplier, pcd.create_by, pcd.production_time, pcd.create_time, pcd.check_url_name,
pcd.check_url, pcd.file_name, pcd.file_url,pcd.update_by, pcd.update_time, pcd.remark, pcd.company_id,
mt1.type_name typeName,mt.type_name specificationType
mt1.type_name machineTypeName,mt.type_name specificationType
from purchase_check_details pcd
left join ma_type mt on pcd.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id

View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.sgzb.material.mapper.ScrapApplyDetailsMapper">
<resultMap type="com.bonus.sgzb.material.domain.ScrapApplyDetails" id="ScrapApplyDetailsResult">
<result property="id" column="id" />
<result property="taskId" column="task_id" />
<result property="parentId" column="parent_id" />
<result property="maId" column="ma_id" />
<result property="typeId" column="type_id" />
<result property="scrapNum" column="scrap_num" />
<result property="scrapSource" column="scrap_source" />
<result property="scrapType" column="scrap_type" />
<result property="status" column="status" />
<result property="auditBy" column="audit_by" />
<result property="auditTime" column="audit_time" />
<result property="auditRemark" column="audit_remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="fileUrl" column="file_url" />
<result property="companyId" column="company_id" />
<result property="fileName" column="file_name" />
</resultMap>
<sql id="selectScrapApplyDetailsVo">
select id, task_id, parent_id, ma_id, type_id, scrap_num, scrap_source, scrap_type, status, audit_by, audit_time, audit_remark, create_by, create_time, update_by, update_time, remark, file_url, company_id, file_name from scrap_apply_details
</sql>
<select id="selectScrapApplyDetailsList" parameterType="com.bonus.sgzb.material.domain.ScrapApplyDetails" resultMap="ScrapApplyDetailsResult">
<include refid="selectScrapApplyDetailsVo"/>
<where>
<if test="taskId != null "> and task_id = #{taskId}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="maId != null "> and ma_id = #{maId}</if>
<if test="typeId != null "> and type_id = #{typeId}</if>
<if test="scrapNum != null "> and scrap_num = #{scrapNum}</if>
<if test="scrapSource != null and scrapSource != ''"> and scrap_source = #{scrapSource}</if>
<if test="scrapType != null and scrapType != ''"> and scrap_type = #{scrapType}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="auditBy != null "> and audit_by = #{auditBy}</if>
<if test="auditTime != null "> and audit_time = #{auditTime}</if>
<if test="auditRemark != null and auditRemark != ''"> and audit_remark = #{auditRemark}</if>
<if test="fileUrl != null and fileUrl != ''"> and file_url = #{fileUrl}</if>
<if test="companyId != null "> and company_id = #{companyId}</if>
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
</where>
</select>
<select id="selectScrapApplyDetailsById" parameterType="Long" resultMap="ScrapApplyDetailsResult">
<include refid="selectScrapApplyDetailsVo"/>
where id = #{id}
</select>
<insert id="insertScrapApplyDetails" parameterType="com.bonus.sgzb.material.domain.ScrapApplyDetails">
insert into scrap_apply_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="taskId != null">task_id,</if>
<if test="parentId != null">parent_id,</if>
<if test="maId != null">ma_id,</if>
<if test="typeId != null">type_id,</if>
<if test="scrapNum != null">scrap_num,</if>
<if test="scrapSource != null">scrap_source,</if>
<if test="scrapType != null">scrap_type,</if>
<if test="status != null">status,</if>
<if test="auditBy != null">audit_by,</if>
<if test="auditTime != null">audit_time,</if>
<if test="auditRemark != null">audit_remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="fileUrl != null">file_url,</if>
<if test="companyId != null">company_id,</if>
<if test="fileName != null">file_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="taskId != null">#{taskId},</if>
<if test="parentId != null">#{parentId},</if>
<if test="maId != null">#{maId},</if>
<if test="typeId != null">#{typeId},</if>
<if test="scrapNum != null">#{scrapNum},</if>
<if test="scrapSource != null">#{scrapSource},</if>
<if test="scrapType != null">#{scrapType},</if>
<if test="status != null">#{status},</if>
<if test="auditBy != null">#{auditBy},</if>
<if test="auditTime != null">#{auditTime},</if>
<if test="auditRemark != null">#{auditRemark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="fileUrl != null">#{fileUrl},</if>
<if test="companyId != null">#{companyId},</if>
<if test="fileName != null">#{fileName},</if>
</trim>
</insert>
<update id="updateScrapApplyDetails" parameterType="com.bonus.sgzb.material.domain.ScrapApplyDetails">
update scrap_apply_details
<trim prefix="SET" suffixOverrides=",">
<if test="taskId != null">task_id = #{taskId},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="maId != null">ma_id = #{maId},</if>
<if test="typeId != null">type_id = #{typeId},</if>
<if test="scrapNum != null">scrap_num = #{scrapNum},</if>
<if test="scrapSource != null">scrap_source = #{scrapSource},</if>
<if test="scrapType != null">scrap_type = #{scrapType},</if>
<if test="status != null">status = #{status},</if>
<if test="auditBy != null">audit_by = #{auditBy},</if>
<if test="auditTime != null">audit_time = #{auditTime},</if>
<if test="auditRemark != null">audit_remark = #{auditRemark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="fileUrl != null">file_url = #{fileUrl},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="fileName != null">file_name = #{fileName},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScrapApplyDetailsById" parameterType="Long">
delete from scrap_apply_details where id = #{id}
</delete>
<delete id="deleteScrapApplyDetailsByIds" parameterType="String">
delete from scrap_apply_details where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -99,6 +99,11 @@
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.1</version>
</dependency>
</dependencies>

View File

@ -0,0 +1,92 @@
package com.bonus.sgzb.system.controller;
import com.bonus.sgzb.common.core.utils.StringHelper;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.system.domain.FileInfo;
import com.bonus.sgzb.system.service.SysFileService;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.util.IOUtils;
import org.springframework.core.io.ResourceLoader;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@RestController
@RequestMapping("/sys/file")
public class SysFileController {
@Resource
private SysFileService service;
@Resource
private ResourceLoader resourceLoader;
@PostMapping("/upload")
@ApiOperation(value = "文件上传")
public AjaxResult upload(HttpServletRequest request) {
String limitWords = request.getParameter("limitWords");
FileInfo file = new FileInfo();
try {
file = service.uploadFile(request);
if (limitWords != null && file.getWords() > Integer.parseInt(limitWords)){
return AjaxResult.error("上传文件字数超出限制字数!");
}
}catch (Exception e){
e.printStackTrace();
}
if (file != null && file.getId() != 0){
return AjaxResult.success(file);
}else {
return AjaxResult.error("文件上传失败!");
}
}
@ApiOperation(value = "模板", httpMethod = "GET")
@GetMapping("download")
public void download(HttpServletRequest request, HttpServletResponse response, String filename) {
InputStream inputStream = null;
ServletOutputStream servletOutputStream = null;
try {
String path = "download/" + filename;
org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:" + path);
response.setContentType("application/vnd.ms-excel");
response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.addHeader("charset", "utf-8");
response.addHeader("Pragma", "no-cache");
String encodeName = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString());
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName);
inputStream = resource.getInputStream();
servletOutputStream = response.getOutputStream();
IOUtils.copy(inputStream, servletOutputStream);
response.flushBuffer();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (servletOutputStream != null) {
servletOutputStream.close();
}
if (inputStream != null) {
inputStream.close();
}
// 召唤jvm的垃圾回收器
System.gc();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,40 @@
package com.bonus.sgzb.system.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class FileInfo {
/** $column.columnComment */
private Long id;
/** 模块id */
private Long modelId;
/** 文件名称 */
@ApiModelProperty(value = "文件名称")
private String fileName;
/** 文件路径 */
@ApiModelProperty(value = "文件路径")
private String fileUrl;
/** 数据字典 */
@ApiModelProperty(value = "数据字典")
private Long dicId;
/** 创建者 */
private String createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String size;
private String type;
private int words;
private String creator;
}

View File

@ -0,0 +1,17 @@
package com.bonus.sgzb.system.mapper;
import com.bonus.sgzb.system.domain.FileInfo;
/**
* <p>
* Mapper 接口
* </p>
*
* @author laker
* @since 2021-08-05
*/
public interface FileInfoMapper {
int insertFileInfo(FileInfo o);
}

View File

@ -0,0 +1,23 @@
package com.bonus.sgzb.system.service;
import com.bonus.sgzb.system.domain.FileInfo;
import javax.servlet.http.HttpServletRequest;
/**
* 文件上传接口
*
* @author zys
*/
public interface SysFileService
{
/**
* 文件上传接口
*
* @return
* @throws Exception
*/
FileInfo uploadFile(HttpServletRequest request) throws Exception;
}

View File

@ -0,0 +1,179 @@
package com.bonus.sgzb.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.bonus.sgzb.common.core.utils.DateTimeHelper;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.system.api.model.LoginUser;
import com.bonus.sgzb.system.domain.FileInfo;
import com.bonus.sgzb.system.mapper.FileInfoMapper;
import com.bonus.sgzb.system.service.SysFileService;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.Security;
import java.util.*;
/**
* 本地文件存储
*
* @author zys
*/
@Primary
@Service("SysFileService")
public class SysFileServiceImpl implements SysFileService {
@Resource
private FileInfoMapper dao;
/**
* 本地文件上传接口
*
* @return 访问地址
* @throws Exception
*/
@Override
public FileInfo uploadFile(HttpServletRequest request) throws Exception {
FileInfo file = new FileInfo();
StandardMultipartHttpServletRequest req = (StandardMultipartHttpServletRequest) request;
String photoType = req.getParameter("fileType");
String userId = req.getParameter("userId");
HashMap<String, Object> map = getFile(req);
List<MultipartFile> items = (List<MultipartFile>) map.get("filePath");
MultipartFile item = items.get(0);
try {
String url = saveFile(request, item, photoType);
if(url != null){
int words = getFileText(item);
String fileName = item.getOriginalFilename();
String type = fileName.substring(fileName.lastIndexOf(".") + 1);
long size = item.getSize()/1024/1024;
file.setFileName(fileName);
file.setFileUrl(url);
file.setCreator(userId);
file.setType(type);
file.setSize(size + "M");
file.setWords(words);
file.setCreateBy(SecurityUtils.getUserId().toString());
file.setCreateTime(new Date());
dao.insertFileInfo(file);
}
} catch (Exception e) {
e.printStackTrace();
}
return file;
}
public HashMap<String, Object> getFile(StandardMultipartHttpServletRequest request) {
MultipartFile multipartFile;
HashMap<String, Object> map = new HashMap<String, Object>();
try {
List<MultipartFile> tmps = new ArrayList<MultipartFile>();
Iterator<String> itr = request.getFileNames();
while (itr.hasNext()) {
multipartFile = request.getFile(itr.next());
tmps.add(multipartFile);
}
map.put("filePath",tmps);
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
public String saveFile(HttpServletRequest request, MultipartFile multipartFile, String fileType) throws Exception {
String url = "";
String tmpName = multipartFile.getOriginalFilename();// 完整路径 IE
tmpName = tmpName.substring(tmpName.lastIndexOf("\\") + 1);
tmpName = IdUtil.fastSimpleUUID() + tmpName;
String imageFiles="/data/sz/zstp/" + fileType + "/";
String os = System.getProperty("os.name");
if(os.toLowerCase().startsWith("win")){
imageFiles="D://files/" + fileType + "/";
}
String year = DateTimeHelper.getNowYear();
String month = DateTimeHelper.getNowMonths();
String day = DateTimeHelper.getNowDay();
String specfile = imageFiles + year +"/" + month +"/"+ day;
File file = new File(specfile + "/" + tmpName);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
url = "/" + fileType + "/" + year +"/" + month +"/"+ day + "/" + tmpName;
if (!multipartFile.isEmpty()) {
try {
FileOutputStream fos = new FileOutputStream(file);
InputStream in = multipartFile.getInputStream();
byte[] bytes = new byte[1024];
int len = 0;
while ((len = in.read(bytes)) != -1) {
fos.write(bytes, 0, len);
}
fos.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return url;
}
private int getFileText(MultipartFile file) throws IOException {
int length = 0;
String fileName = file.getOriginalFilename();
InputStream fileInputStream = file.getInputStream();
try {
ZipSecureFile.setMinInflateRatio(-1.0d);
//获取文件后缀名
String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
//定义word内容
String content = "";
switch (suffix) {
case "doc":
WordExtractor wordExtractor = new WordExtractor(fileInputStream);
content = wordExtractor.getText();
break;
case "docx":
XWPFDocument document = new XWPFDocument(fileInputStream);
XWPFWordExtractor extractor = new XWPFWordExtractor(document);
content = extractor.getText();
break;
default:
break;
}
//中文单词
String cnWords = content.replaceAll("[^(\\u4e00-\\u9fa5。《》“”【】、……¥·)]", "");
int cnWordsCount = cnWords.length();
//非中文单词
String noCnWords = content.replaceAll("[^(a-zA-Z0-9`\\-=\';.,/~!@#$%^&*()_+|}{\":><?\\[\\])]", " ");
int noCnWordsCount = 0;
String[] ss = noCnWords.split(" ");
for (String s : ss) {
if (s.trim().length() != 0) {
noCnWordsCount++;
}
}
length = cnWordsCount + noCnWordsCount;
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fileInputStream != null) {
fileInputStream.close();
}
}
return length;
}
}

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.sgzb.system.mapper.FileInfoMapper">
<resultMap type="com.bonus.sgzb.system.domain.FileInfo" id="SysFileInfoResult">
<result property="id" column="id" />
<result property="modelId" column="model_id" />
<result property="fileName" column="file_name" />
<result property="fileUrl" column="file_url" />
<result property="dicId" column="dic_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectSysFileInfoVo">
select id, model_id, file_name, file_url, dic_id, create_by, create_time from sys_file_info
</sql>
<select id="selectSysFileInfoList" parameterType="com.bonus.sgzb.system.domain.FileInfo" resultMap="SysFileInfoResult">
<include refid="selectSysFileInfoVo"/>
<where>
<if test="modelId != null "> and model_id = #{modelId}</if>
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
<if test="fileUrl != null and fileUrl != ''"> and file_url = #{fileUrl}</if>
<if test="dicId != null "> and dic_id = #{dicId}</if>
</where>
</select>
<select id="selectSysFileInfoById" parameterType="Long" resultMap="SysFileInfoResult">
<include refid="selectSysFileInfoVo"/>
where id = #{id}
</select>
<insert id="insertFileInfo" parameterType="com.bonus.sgzb.system.domain.FileInfo" useGeneratedKeys="true" keyProperty="id">
insert into sys_file_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="modelId != null">model_id,</if>
<if test="fileName != null">file_name,</if>
<if test="fileUrl != null">file_url,</if>
<if test="dicId != null">dic_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="modelId != null">#{modelId},</if>
<if test="fileName != null">#{fileName},</if>
<if test="fileUrl != null">#{fileUrl},</if>
<if test="dicId != null">#{dicId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateSysFileInfo" parameterType="com.bonus.sgzb.system.domain.FileInfo">
update sys_file_info
<trim prefix="SET" suffixOverrides=",">
<if test="modelId != null">model_id = #{modelId},</if>
<if test="fileName != null">file_name = #{fileName},</if>
<if test="fileUrl != null">file_url = #{fileUrl},</if>
<if test="dicId != null">dic_id = #{dicId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysFileInfoById" parameterType="Long">
delete from sys_file_info where id = #{id}
</delete>
<delete id="deleteSysFileInfoByIds" parameterType="String">
delete from sys_file_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>