diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/Price.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/Price.java index 40f1592..b5ecd16 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/Price.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/Price.java @@ -1,22 +1,22 @@ package com.ruoyi.yh.price.domain; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Date; - import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.constant.DictType; -import com.ruoyi.common.core.validate.ValidGroup; +import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.interfaces.LogBizParam; +import com.ruoyi.common.core.validate.ValidGroup; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.poi.ss.usermodel.IndexedColors; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.Date; /** * 单价对象 bst_price @@ -30,14 +30,14 @@ public class Price extends BaseEntity implements LogBizParam { private static final long serialVersionUID = 1L; - @Excel(name = "ID") + @Excel(name = "ID", prompt = "必填", headerColor = IndexedColors.RED) private Long priceId; @ApiModelProperty("部门ID") @NotNull(message = "部门不存在", groups = ValidGroup.Create.class) private Long deptId; - @Excel(name = "状态", dictType = DictType.PRICE_STATUS, comboReadDict = true) + @Excel(name = "状态", type = Excel.Type.EXPORT, dictType = DictType.PRICE_STATUS, comboReadDict = true, prompt = "必填", headerColor = IndexedColors.RED) @ApiModelProperty("状态") private String status; @@ -51,7 +51,7 @@ public class Price extends BaseEntity implements LogBizParam @Size(max = 200, message = "大小不允许超过200个字符") private String size; - @Excel(name = "工序名称") + @Excel(name = "工序名称", prompt = "必填", headerColor = IndexedColors.RED) @ApiModelProperty("工序名称") @NotNull(message = "工序名称不允许为空", groups = ValidGroup.Create.class) @Size(max = 200, message = "工序名称不允许超过200个字符") @@ -72,7 +72,7 @@ public class Price extends BaseEntity implements LogBizParam @Size(max = 200, message = "规格不允许超过200个字符") private String spec; - @Excel(name = "单价(元)", cellType = Excel.ColumnType.NUMERIC) + @Excel(name = "单价(元)", cellType = Excel.ColumnType.NUMERIC, prompt = "必填", headerColor = IndexedColors.RED) @ApiModelProperty("单价") @NotNull(message = "单价不允许为空", groups = ValidGroup.Create.class) @Min(value = 0, message = "单价不允许小于0元") @@ -106,7 +106,7 @@ public class Price extends BaseEntity implements LogBizParam @ApiModelProperty("更新人ID") private Long updateId; - @Excel(name = "是否禁用", combo = {"是", "否"}, readConverterExp = "true=是,false=否") + @Excel(name = "是否禁用", combo = {"是", "否"}, readConverterExp = "true=是,false=否", prompt = "必填", headerColor = IndexedColors.RED) @ApiModelProperty("是否禁用") private Boolean disabled; @@ -115,12 +115,12 @@ public class Price extends BaseEntity implements LogBizParam @ApiModelProperty("禁用时间") private LocalDateTime disabledTime; - @Excel(name = "生产数量倍数分子(个)") + @Excel(name = "生产数量倍数分子(个)", prompt = "必填", headerColor = IndexedColors.RED) @ApiModelProperty("生产数量倍数分子(个)") @Min(value = 0, message = "生产数量倍数分子不允许小于0") private BigDecimal quantityNumerator; - @Excel(name = "生产数量倍数分母(个)") + @Excel(name = "生产数量倍数分母(个)", prompt = "必填", headerColor = IndexedColors.RED) @ApiModelProperty("生产数量倍数分母(个)") @Min(value = 1, message = "生产数量倍数分母不允许小于1") private BigDecimal quantityDenominator; diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceVO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceVO.java index 741f2a7..78f07e1 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceVO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceVO.java @@ -1,10 +1,10 @@ package com.ruoyi.yh.price.domain; import com.ruoyi.common.annotation.Excel; -import com.ruoyi.yh.logImportDetail.domain.interfaces.ImportContent; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import org.apache.poi.ss.usermodel.IndexedColors; /** * @author wjh @@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) public class PriceVO extends Price { - @Excel(name = "部门名称", prompt = "必填") + @Excel(name = "部门名称", prompt = "必填", headerColor = IndexedColors.RED) @ApiModelProperty("部门名称") private String deptName; diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/dto/PriceImportParams.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/dto/PriceImportParams.java new file mode 100644 index 0000000..79bf654 --- /dev/null +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/dto/PriceImportParams.java @@ -0,0 +1,19 @@ +package com.ruoyi.yh.price.domain.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author wjh + * 2024/12/19 + */ +@Data +public class PriceImportParams { + + @ApiModelProperty("覆盖更新") + private Boolean updateSupport; + + @ApiModelProperty("直接审核通过") + private Boolean verified; + +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/enums/PriceStatus.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/enums/PriceStatus.java index 87f38bb..66486bf 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/enums/PriceStatus.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/enums/PriceStatus.java @@ -3,7 +3,6 @@ package com.ruoyi.yh.price.domain.enums; import lombok.AllArgsConstructor; import lombok.Getter; -import java.nio.charset.Charset; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -76,4 +75,11 @@ public enum PriceStatus { public static List canCheckToReport() { return asList(PASS); } + + /** + * 允许删除的状态 + */ + public static List canDel() { + return asList(WAIT_SUBMIT, REJECT); + } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml index dfbc1f5..85ed94a 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml @@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bp.disabled_time, bp.quantity_numerator, bp.quantity_denominator, + bp.deleted, sd.dept_name as dept_name from bst_price bp left join sys_dept sd on sd.dept_id = bp.dept_id @@ -60,6 +61,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bp.update_id = #{query.updateId} and bp.update_by like concat('%', #{query.updateBy}, '%') and bp.disabled = #{query.disabled} + and bp.deleted = #{query.deleted} + and bp.deleted = false and bp.status in @@ -123,6 +126,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" disabled_time, quantity_numerator, quantity_denominator, + deleted, #{priceId}, @@ -151,6 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{disabledTime}, #{quantityNumerator}, #{quantityDenominator}, + #{deleted}, @@ -198,6 +203,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bp.disabled_time = #{data.disabledTime}, quantity_numerator = #{data.quantityNumerator}, quantity_denominator = #{data.quantityDenominator}, + deleted = #{data.deleted}, diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceService.java index 09505fd..44c3f6c 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/PriceService.java @@ -1,11 +1,13 @@ package com.ruoyi.yh.price.service; -import java.util.List; import com.ruoyi.yh.price.domain.Price; -import com.ruoyi.yh.price.domain.PriceVO; import com.ruoyi.yh.price.domain.PriceQuery; +import com.ruoyi.yh.price.domain.PriceVO; +import com.ruoyi.yh.price.domain.dto.PriceImportParams; import com.ruoyi.yh.price.domain.dto.PriceVerifyDTO; +import java.util.List; + /** * 单价Service接口 * @@ -102,11 +104,11 @@ public interface PriceService /** * 导入单价列表 * - * @param priceList 单价列表 - * @param updateSupport 是否覆盖已存在数据 - * @param operaId 操作人ID + * @param priceList 单价列表 + * @param params + * @param operaId 操作人ID */ - int importPrice(List priceList, boolean updateSupport, Long operaId); + int importPrice(List priceList, PriceImportParams params, Long operaId); /** * 根据ID列表查询 @@ -115,4 +117,8 @@ public interface PriceService */ List selectPriceListByIds(List priceIds); + /** + * 逻辑删除 + */ + int logicDel(Long id); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceServiceImpl.java index 0e3aa70..7eb4db8 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/service/impl/PriceServiceImpl.java @@ -1,13 +1,5 @@ package com.ruoyi.yh.price.service.impl; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.validate.ValidGroup; @@ -16,28 +8,36 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.bean.BeanValidators; import com.ruoyi.common.utils.collection.CollectionUtils; -import com.ruoyi.system.user.domain.SysUserVO; import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysUserService; +import com.ruoyi.system.user.domain.SysUserVO; import com.ruoyi.yh.logImport.domain.LogImportVO; import com.ruoyi.yh.logImport.domain.enums.LogImportBizType; import com.ruoyi.yh.logImport.domain.enums.LogImportType; import com.ruoyi.yh.logImport.service.LogImportService; import com.ruoyi.yh.logImportDetail.domain.enums.LogImportDetailType; import com.ruoyi.yh.logImportDetail.service.ILogImportDetailService; +import com.ruoyi.yh.price.domain.Price; +import com.ruoyi.yh.price.domain.PriceQuery; +import com.ruoyi.yh.price.domain.PriceVO; +import com.ruoyi.yh.price.domain.dto.PriceImportParams; import com.ruoyi.yh.price.domain.dto.PriceVerifyDTO; import com.ruoyi.yh.price.domain.enums.PriceStatus; +import com.ruoyi.yh.price.mapper.PriceMapper; +import com.ruoyi.yh.price.service.PriceService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.ruoyi.yh.price.mapper.PriceMapper; -import com.ruoyi.yh.price.domain.Price; -import com.ruoyi.yh.price.domain.PriceVO; -import com.ruoyi.yh.price.domain.PriceQuery; -import com.ruoyi.yh.price.service.PriceService; import org.springframework.transaction.support.TransactionTemplate; import javax.validation.Validator; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * 单价Service业务层处理 @@ -298,10 +298,13 @@ public class PriceServiceImpl implements PriceService } @Override - public int importPrice(List priceList, boolean updateSupport, Long operaId) { + public int importPrice(List priceList, PriceImportParams params, Long operaId) { if (CollectionUtils.isEmptyElement(priceList)) { throw new ServiceException("导入数据不允许为空"); } + boolean updateSupport = params.getUpdateSupport() != null && params.getUpdateSupport(); + boolean verified = params.getVerified() != null && params.getVerified(); + SysUser user = userService.selectUserById(operaId); ServiceUtil.assertion(user == null, "操作人不存在"); @@ -311,7 +314,7 @@ public class PriceServiceImpl implements PriceService // 开始异步导入 scheduledExecutorService.schedule(() -> { - // 查询关联表 + // 转换数据 // 部门 List deptList = deptService.selectDeptListByNames(CollectionUtils.map(priceList, PriceVO::getDeptName)); // 创建人 @@ -339,6 +342,11 @@ public class PriceServiceImpl implements PriceService price.setCreateId(userList.stream().filter(u -> u.getNickName().equals(price.getCreateBy())).findFirst().orElse(defaultUser).getUserId()); price.setUpdateId(userList.stream().filter(u -> u.getNickName().equals(price.getUpdateBy())).findFirst().orElse(defaultUser).getUserId()); price.setVerifyId(userList.stream().filter(u -> u.getNickName().equals(price.getVerifyBy())).findFirst().orElse(defaultUser).getUserId()); + if (verified) { + price.setStatus(PriceStatus.PASS.getStatus()); + } else { + price.setStatus(PriceStatus.WAIT_VERIFY.getStatus()); + } // 操作数据库 transactionTemplate.execute(status -> { @@ -393,4 +401,22 @@ public class PriceServiceImpl implements PriceService query.setPriceIds(priceIds); return priceMapper.selectPriceList(query); } + + @Override + public int logicDel(Long id) { + if (id == null) { + return 0; + } + PriceVO old = this.selectPriceByPriceId(id); + ServiceUtil.assertion(old == null, "待删除的单价不存在"); + ServiceUtil.assertion(!PriceStatus.canDel().contains(old.getStatus()), "当前单价状态不允许被删除"); + + Price data = new Price(); + data.setDeleted(true); + PriceQuery query = new PriceQuery(); + query.setPriceId(id); + query.setStatusList(PriceStatus.canDel()); + query.setDeleted(false); + return this.updateByQuery(data, query); + } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdQuery.java index 419ad76..88cf044 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdQuery.java @@ -2,7 +2,9 @@ package com.ruoyi.yh.reportProd.domain; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDate; import java.util.List; /** @@ -15,4 +17,7 @@ public class ReportProdQuery extends ReportProdVO { @ApiModelProperty("报表ID列表") private List reportIds; + @DateTimeFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("报表日期范围") + private List reportDateRange; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java index 85e1720..fe5de2a 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java @@ -31,6 +31,9 @@ public class ReportProdVO extends ReportProd { @ApiModelProperty("工序部门ID") private Long priceDeptId; + @ApiModelProperty("工序部门名称") + private String priceDeptName; + @ApiModelProperty("总价") private BigDecimal totalAmount; diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml index a6af076..a9403bc 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml @@ -31,10 +31,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" brp.remark, brp.price_price * brp.num as total_amount, bp.dept_id as price_dept_id, - br.status as report_status + br.status as report_status, + sd.dept_name as price_dept_name from bst_report_prod brp left join bst_report br on br.report_id = brp.report_id left join bst_price bp on bp.price_id = brp.price_id + left join sys_dept sd on sd.dept_id = bp.dept_id @@ -59,6 +61,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item} + + and date(br.report_date) >= #{query.reportDateRange[0]} + and date(br.report_date) <= #{query.reportDateRange[1]} + ${query.params.dataScope} @@ -368,6 +374,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + WHEN #{item.id} THEN #{item.defectNum} + + + WHEN #{item.id} THEN `defect_num` + + + where id in diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/PriceController.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/PriceController.java index 6941278..c43171a 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/PriceController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/PriceController.java @@ -11,9 +11,11 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.LogBizType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.framework.web.service.PermissionService; import com.ruoyi.yh.price.domain.Price; import com.ruoyi.yh.price.domain.PriceQuery; import com.ruoyi.yh.price.domain.PriceVO; +import com.ruoyi.yh.price.domain.dto.PriceImportParams; import com.ruoyi.yh.price.domain.dto.PriceVerifyDTO; import com.ruoyi.yh.price.service.PriceConverter; import com.ruoyi.yh.price.service.PriceService; @@ -46,6 +48,9 @@ public class PriceController extends BaseController @Autowired private ScheduledExecutorService scheduledExecutorService; + @Autowired + private PermissionService permissionService; + @PreAuthorize("@ss.hasPermi('yh:price:list')") @GetMapping("/list") @DataScope(deptAlias = "sd") @@ -105,6 +110,14 @@ public class PriceController extends BaseController return toAjax(priceService.updatePrice(po)); } + + @PreAuthorize("@ss.hasPermi('yh:price:delete')") + @Log(title = LogTitle.PRICE, businessType = BusinessType.DELETE, bizType = LogBizType.PRICE, bizIdName = "arg0") + @DeleteMapping("/{id}") + public AjaxResult delete(@PathVariable Long id) { + return toAjax(priceService.logicDel(id)); + } + @PreAuthorize("@ss.hasPermi('yh:price:submit')") @Log(title = LogTitle.PRICE, businessType = BusinessType.SUBMIT, bizType = LogBizType.PRICE, bizIdName = "arg0") @PutMapping("/{priceId}/submit") @@ -151,10 +164,12 @@ public class PriceController extends BaseController @Log(title = "单价导入", businessType = BusinessType.IMPORT, bizType = LogBizType.PRICE) @PreAuthorize("@ss.hasPermi('yh:price:import')") @PostMapping("/importData") - public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception - { + public AjaxResult importData(MultipartFile file, PriceImportParams params) throws Exception { + if (params.getVerified() != null && params.getVerified() && !permissionService.hasPermi("yh:price:verify")) { + return error("您无权直接审核通过"); + } ExcelUtil util = new ExcelUtil(PriceVO.class); List priceList = util.importExcel(file.getInputStream()); - return success(priceService.importPrice(priceList, updateSupport, getUserId())); + return success(priceService.importPrice(priceList, params, getUserId())); } } diff --git a/ruoyi-web/src/main/resources/application.yml b/ruoyi-web/src/main/resources/application.yml index 9db1681..03c5eb8 100644 --- a/ruoyi-web/src/main/resources/application.yml +++ b/ruoyi-web/src/main/resources/application.yml @@ -54,7 +54,7 @@ spring: profiles: active: - dev - - druid-prod + - druid # 文件上传 servlet: multipart: