diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesBoxController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesBoxController.java index 0fead3bd8..10b60dde0 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesBoxController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesBoxController.java @@ -1,5 +1,6 @@ package com.op.mes.controller; +import java.io.IOException; import java.util.List; import javax.servlet.http.HttpServletResponse; @@ -24,6 +25,7 @@ import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.utils.poi.ExcelUtil; import com.op.common.core.web.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; /** * 箱体类型Controller @@ -59,7 +61,25 @@ public class MesBoxController extends BaseController { ExcelUtil util = new ExcelUtil(MesBox.class); util.exportExcel(response, list, "箱体类型数据"); } + /** + * 导入箱体类型列表 + */ + @PostMapping("/importTemplate") + public void importTemplate(HttpServletResponse response) throws IOException { + ExcelUtil util = new ExcelUtil(MesBox.class); + util.importTemplateExcel(response, "箱体类型导入模板"); + } + @Log(title = "箱体类型导入", businessType = BusinessType.IMPORT) + @RequiresPermissions("mes:mesBox:import") + @PostMapping("/importData") + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { + ExcelUtil util = new ExcelUtil(MesBox.class); + List mesBoxList = util.importExcel(file.getInputStream()); + String operName = SecurityUtils.getUsername(); + String message = mesBoxService.importMesBoxTypes(mesBoxList, updateSupport, operName); + return success(message); + } /** * 获取箱体类型详细信息 */ diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesBox.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesBox.java index 5fa0f862e..90ab56937 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesBox.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesBox.java @@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle; import com.op.common.core.annotation.Excel; import com.op.common.core.web.domain.BaseEntity; +import java.math.BigDecimal; + /** * 箱体类型对象 mes_box * @@ -18,17 +20,58 @@ private static final long serialVersionUID=1L; private Long boxId; /** 字典名称 */ - @Excel(name = "字典名称") + @Excel(name = "箱体名称") private String boxName; /** 字典类型 */ - @Excel(name = "字典类型") + @Excel(name = "箱体类型(1-F)") private String boxType; /** 状态(0正常 */ - @Excel(name = "状态", readConverterExp = "状态(0正常") + //@Excel(name = "状态", readConverterExp = "状态(0正常") private String status; + @Excel(name = "长") + private BigDecimal length; + @Excel(name = "宽") + private BigDecimal width; + @Excel(name = "高") + private BigDecimal height; + + private String delFlag; + + public String getDelFlag() { + return delFlag; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public BigDecimal getLength() { + return length; + } + + public void setLength(BigDecimal length) { + this.length = length; + } + + public BigDecimal getWidth() { + return width; + } + + public void setWidth(BigDecimal width) { + this.width = width; + } + + public BigDecimal getHeight() { + return height; + } + + public void setHeight(BigDecimal height) { + this.height = height; + } + public void setBoxId(Long boxId){ this.boxId = boxId; } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/vo/MesDailyReportVo.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/vo/MesDailyReportVo.java index 2df111241..dbde8a7ab 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/domain/vo/MesDailyReportVo.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/vo/MesDailyReportVo.java @@ -67,15 +67,15 @@ public class MesDailyReportVo extends BaseEntity { private String teamDesc; //计划产量 - // 标准用人 - @Excel(name = "标准用人") + // 实际用人 + @Excel(name = "实际用人") private BigDecimal useMan; private String workorderName; private String quantity;//计划产量(箱) @Excel(name = "标准用人") - private String manStandard;//实际用人 + private String manStandard;//标准用人 @Excel(name = "标准工时") private String workTimeStandard;//工时-标准 @Excel(name = "实际工时") diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesBoxMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesBoxMapper.java index 00aab9cce..2473f7910 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesBoxMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesBoxMapper.java @@ -64,4 +64,6 @@ public interface MesBoxMapper { MesBox checkBoxTypeUnique(String boxType); int countBoxDataByType(String boxType); + + MesBox selectBoxByBoxType(String boxType); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesBoxService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesBoxService.java index b3d3d6a59..0704d4adf 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesBoxService.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesBoxService.java @@ -62,4 +62,6 @@ public interface IMesBoxService { List selectDictTypeAll(); boolean checkBoxTypeUnique(MesBox mesBox); + + String importMesBoxTypes(List mesBoxList, boolean updateSupport, String operName); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesBoxServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesBoxServiceImpl.java index 0fd4bb215..ec8882c40 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesBoxServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesBoxServiceImpl.java @@ -7,15 +7,20 @@ import com.op.common.core.constant.UserConstants; import com.op.common.core.exception.ServiceException; import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.StringUtils; +import com.op.common.core.utils.bean.BeanValidators; import com.op.common.security.utils.DictUtils; import com.op.common.security.utils.SecurityUtils; import com.op.system.api.domain.SysDictType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.op.mes.mapper.MesBoxMapper; import com.op.mes.domain.MesBox; import com.op.mes.service.IMesBoxService; +import javax.validation.Validator; + /** * 箱体类型Service业务层处理 * @@ -24,9 +29,13 @@ import com.op.mes.service.IMesBoxService; */ @Service public class MesBoxServiceImpl implements IMesBoxService { + private static final Logger log = LoggerFactory.getLogger(MesBoxServiceImpl.class); @Autowired private MesBoxMapper mesBoxMapper; + @Autowired + protected Validator validator; + /** * 查询箱体类型 * @@ -128,4 +137,54 @@ public class MesBoxServiceImpl implements IMesBoxService { } return UserConstants.UNIQUE; } + + @Override + @DS("#header.poolName") + public String importMesBoxTypes(List mesBoxList, boolean updateSupport, String operName) { + if (StringUtils.isNull(mesBoxList) || mesBoxList.size() == 0) { + throw new ServiceException("导入箱型数据不能为空!"); + } + int successNum = 0; + int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + for (MesBox mesBox : mesBoxList) { + try { + // 验证是否存在这个箱型 + MesBox u = mesBoxMapper.selectBoxByBoxType(mesBox.getBoxType()); + if (StringUtils.isNull(u)) { + BeanValidators.validateWithException(validator, mesBox); + mesBox.setStatus("0"); + mesBox.setDelFlag("0"); + mesBox.setCreateTime(DateUtils.getNowDate()); + mesBox.setCreateBy(operName); + mesBoxMapper.insertMesBox(mesBox); + successNum++; + successMsg.append("
" + successNum + "、箱型 " + mesBox.getBoxName() + " 导入成功"); + } else if (updateSupport) { + BeanValidators.validateWithException(validator, mesBox); + mesBox.setUpdateTime(DateUtils.getNowDate()); + mesBox.setUpdateBy(operName); + mesBoxMapper.updateMesBox(mesBox); + successNum++; + successMsg.append("
" + successNum + "、箱型 " + mesBox.getBoxName() + " 更新成功"); + } else { + failureNum++; + failureMsg.append("
" + failureNum + "、箱型 " + mesBox.getBoxName() + " 已存在"); + } + } catch (Exception e) { + failureNum++; + String msg = "
" + failureNum + "、箱型 " + mesBox.getBoxName() + " 导入失败:"; + failureMsg.append(msg + e.getMessage()); + log.error(msg, e); + } + } + if (failureNum > 0) { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMsg.toString()); + } else { + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + } + return successMsg.toString(); + } } diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesBoxMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesBoxMapper.xml index d8cbb010e..944123028 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesBoxMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesBoxMapper.xml @@ -14,10 +14,13 @@ + + + - select box_id, box_name, box_type, status, create_by, create_time, update_by, update_time, remark from mes_box + select box_id, box_name, box_type, status,length, width, height, create_by, create_time, update_by, update_time, remark from mes_box + + + diff --git a/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseProductController.java b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseProductController.java index 20b348295..99e63541d 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseProductController.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseProductController.java @@ -1,5 +1,6 @@ package com.op.wms.controller; +import java.io.IOException; import java.util.List; import javax.servlet.http.HttpServletResponse; @@ -57,7 +58,6 @@ public class BaseProductController extends BaseController { ExcelUtil util = new ExcelUtil(BaseProduct.class); util.exportExcel(response, list, "物料信息数据"); } - /** * 获取物料信息详细信息 */ diff --git a/op-modules/op-wms/src/main/java/com/op/wms/domain/BaseProduct.java b/op-modules/op-wms/src/main/java/com/op/wms/domain/BaseProduct.java index f4573c4e1..c4c1bf83a 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/domain/BaseProduct.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/domain/BaseProduct.java @@ -89,6 +89,8 @@ public class BaseProduct extends BaseEntity { @Excel(name = "高") private BigDecimal height; + private String boxType; + /** * 毛重 */ @@ -361,6 +363,14 @@ public class BaseProduct extends BaseEntity { private String warehouseCycle; private String packType; + public String getBoxType() { + return boxType; + } + + public void setBoxType(String boxType) { + this.boxType = boxType; + } + public String getCpkType() { return cpkType; } diff --git a/op-modules/op-wms/src/main/resources/mapper/wms/BaseProductMapper.xml b/op-modules/op-wms/src/main/resources/mapper/wms/BaseProductMapper.xml index da6017374..5bd939acb 100644 --- a/op-modules/op-wms/src/main/resources/mapper/wms/BaseProductMapper.xml +++ b/op-modules/op-wms/src/main/resources/mapper/wms/BaseProductMapper.xml @@ -17,6 +17,7 @@ + @@ -171,6 +172,7 @@ bp.length, bp.width, bp.height, + bp.box_type, bp.gross_weight, bp.net_weight, bp.tare_weight, @@ -243,6 +245,7 @@ length, width, height, + box_type, gross_weight, net_weight, tare_weight, @@ -290,6 +293,7 @@ #{length}, #{width}, #{height}, + #{boxType}, #{grossWeight}, #{netWeight}, #{tareWeight}, @@ -340,6 +344,7 @@ length = #{length}, width = #{width}, height = #{height}, + box_type = #{boxType}, gross_weight = #{grossWeight}, net_weight = #{netWeight}, tare_weight = #{tareWeight},