已重命名1个文件
已修改32个文件
已添加9个文件
| | |
| | | @Autowired |
| | | private SysUserService userService; |
| | | |
| | | @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')") |
| | | @PreAuthorize("hasAnyAuthority('hazmat:manage:common')") |
| | | @ApiOperation(value = "重置密码") |
| | | @PutMapping(value = "/resetPwd") |
| | | public CommonResult restPwd(@RequestBody SysUser user){ |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | } |
| | | |
| | | |
| | | @RepeatSubmit |
| | | @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')") |
| | | @ApiOperation(value = "危化品基础数据Excel导入") |
| | | @PostMapping("/importExcel") |
| | | public CommonResult importExcel(MultipartFile file) throws IOException { |
| | | return CommonResult.success(hazmatBasicService.importExcel(file)); |
| | | } |
| | | |
| | | } |
| | |
| | | return CommonResult.success(); |
| | | } |
| | | |
| | | @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')") |
| | | @RepeatSubmit |
| | | @ApiOperation(value = "零头修改") |
| | | @PostMapping(value = { "/changeRemaining" }) |
| | | public CommonResult changeRemaining(@RequestBody HzHazmat hazmat){ |
| | | hazmatService.changeRemaining(hazmat); |
| | | return CommonResult.success(); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')") |
| | | @RepeatSubmit |
| | | @ApiOperation(value = "修改状态") |
| | | @PostMapping(value = { "/changeState" }) |
| | | public CommonResult changeState(HzHazmat hazmat){ |
| | | public CommonResult changeState(@RequestBody HzHazmat hazmat){ |
| | | hazmatService.changeState(hazmat); |
| | | return CommonResult.success(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | } |
| | | |
| | | |
| | | @RepeatSubmit |
| | | @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')") |
| | | @ApiOperation(value = "危化品基础数据Excel导入") |
| | | @PostMapping("/importExcel") |
| | | public CommonResult importExcel( MultipartFile file) throws IOException { |
| | | return CommonResult.success(productBasicService.importExcel(file)); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | ALTER TABLE `hazmat_manage`.`sys_company` |
| | | ADD COLUMN `code` varchar(2) NULL COMMENT '公司唯一编码(2位)' AFTER `version`; |
对比新文件 |
| | |
| | | ALTER TABLE `hazmat_manage`.`hz_hazmat_basic` |
| | | ADD COLUMN `max_entry` int NOT NULL DEFAULT 150 COMMENT '单次入库最大数量' AFTER `version`; |
| | | |
| | | ALTER TABLE `hazmat_manage`.`hz_product_basic` |
| | | ADD COLUMN `max_entry` int NOT NULL DEFAULT 150 COMMENT '单次入库最大数量' AFTER `version`; |
| | |
| | | System.out.println("hhhhhh"); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void testList(){ |
| | | List<Integer> tmpList=new ArrayList<>(); |
| | | tmpList.add(1); |
| | | tmpList.add(2); |
| | | tmpList.add(3); |
| | | tmpList.add(4); |
| | | tmpList.add(5); |
| | | tmpList.add(6); |
| | | tmpList.add(7); |
| | | tmpList.add(8); |
| | | tmpList.add(9); |
| | | Integer pageSize=3; |
| | | while(true){ |
| | | List<Integer> subLIst=tmpList.subList(0,tmpList.size()>pageSize?pageSize:tmpList.size()); |
| | | System.out.println("subSize="+subLIst.size()); |
| | | if(subLIst.size()<pageSize){ |
| | | break; |
| | | } |
| | | tmpList=tmpList.subList(pageSize,tmpList.size()); |
| | | System.out.println("size="+tmpList.size()); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | <artifactId>jaudiotagger</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | { |
| | | PageDomain pageDomain = new PageDomain(); |
| | | pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1)); |
| | | pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10)); |
| | | Integer pageSize=Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); |
| | | if(pageSize>100){ |
| | | pageSize=100; |
| | | } |
| | | pageDomain.setPageSize(pageSize); |
| | | pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN)); |
| | | pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC)); |
| | | pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE)); |
对比新文件 |
| | |
| | | package com.gkhy.hazmat.common.enums; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 危化品最小包装 |
| | | * |
| | | */ |
| | | public enum HazmatKindEnum |
| | | { |
| | | REAGENT(0, "试剂"), |
| | | STOCK(1, "原料"), |
| | | SIMIGOOD(2, "半成品"), |
| | | GOOD(3, "成品"), |
| | | OTHER(4, "其他"); |
| | | |
| | | private final Integer code; |
| | | private final String info; |
| | | |
| | | HazmatKindEnum(Integer code, String info) |
| | | { |
| | | this.code = code; |
| | | this.info = info; |
| | | } |
| | | |
| | | public Integer getCode() |
| | | { |
| | | return code; |
| | | } |
| | | |
| | | public String getInfo() |
| | | { |
| | | return info; |
| | | } |
| | | |
| | | |
| | | public static String getInfoByCode(Integer code){ |
| | | for(HazmatKindEnum hazmatKindEnum:HazmatKindEnum.values()){ |
| | | if(Objects.equals(hazmatKindEnum.getCode(), code)){ |
| | | return hazmatKindEnum.getInfo(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | public static Integer getCodeByInfo(String info){ |
| | | for(HazmatKindEnum hazmatKindEnum:HazmatKindEnum.values()){ |
| | | if(info.equals(hazmatKindEnum.getInfo())){ |
| | | return hazmatKindEnum.getCode(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.gkhy.hazmat.common.enums; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 危化品最小包装 |
| | | * |
| | | */ |
| | | public enum HazmatPackageEnum |
| | | { |
| | | PING(0, "瓶"), |
| | | DAI(1, "袋"), |
| | | TONG(2, "桶"), |
| | | HE(3, "盒"), |
| | | XIANG(4, "箱"), |
| | | OTHER(5,"其他"); |
| | | |
| | | private final Integer code; |
| | | private final String info; |
| | | |
| | | HazmatPackageEnum(Integer code, String info) |
| | | { |
| | | this.code = code; |
| | | this.info = info; |
| | | } |
| | | |
| | | public Integer getCode() |
| | | { |
| | | return code; |
| | | } |
| | | |
| | | public String getInfo() |
| | | { |
| | | return info; |
| | | } |
| | | |
| | | |
| | | public static String getInfoByCode(Integer code){ |
| | | for(HazmatPackageEnum hazmatPackageEnum: HazmatPackageEnum.values()){ |
| | | if(Objects.equals(hazmatPackageEnum.getCode(), code)){ |
| | | return hazmatPackageEnum.getInfo(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | public static Integer getCodeByInfo(String info){ |
| | | for(HazmatPackageEnum hazmatPackageEnum:HazmatPackageEnum.values()){ |
| | | if(info.equals(hazmatPackageEnum.getInfo())){ |
| | | return hazmatPackageEnum.getCode(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | RETURN(2, "归还"), |
| | | DISCARD(3, "标签作废"), |
| | | USE_UP(4, "用尽登记"), |
| | | SOLD(5,"销售"); |
| | | SOLD(5,"销售"), |
| | | REMNANT(6,"零头入库"); |
| | | |
| | | private final Integer code; |
| | | private final String info; |
对比新文件 |
| | |
| | | package com.gkhy.hazmat.common.excel; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Getter |
| | | @Setter |
| | | public class HazmatBasicExcelData { |
| | | @ExcelProperty("序号") |
| | | private Integer index; |
| | | |
| | | @ExcelProperty("名称") |
| | | private String name; |
| | | |
| | | @ExcelProperty("产品编号") |
| | | private String productSn; |
| | | |
| | | @ExcelProperty("种类") |
| | | private String kind; |
| | | |
| | | @ExcelProperty("CAS") |
| | | private String cas; |
| | | |
| | | @ExcelProperty("试剂类型") |
| | | private String hazmatType; |
| | | |
| | | @ExcelProperty("危险性质") |
| | | private String hazmatCharacter; |
| | | |
| | | @ExcelProperty("供应商") |
| | | private String supplier; |
| | | |
| | | @ExcelProperty("厂家") |
| | | private String manufacturer; |
| | | |
| | | @ExcelProperty("规格") |
| | | private String hazmatFormat; |
| | | |
| | | |
| | | @ExcelProperty("包装数量") |
| | | private BigDecimal metering; |
| | | |
| | | @ExcelProperty("包装单位") |
| | | private String unit; |
| | | |
| | | @ExcelProperty("含税价格") |
| | | private BigDecimal price; |
| | | |
| | | @ExcelProperty("每箱数量") |
| | | private Integer perBox; |
| | | |
| | | |
| | | @ExcelProperty("最小包装类型") |
| | | private String minPackage; |
| | | |
| | | |
| | | @ExcelProperty("安全库存") |
| | | private Integer safeNum; |
| | | |
| | | |
| | | @ExcelProperty("超期阀值(小时)") |
| | | private Integer threshold; |
| | | |
| | | |
| | | @ExcelProperty("单次入库最大数量") |
| | | private Integer maxEntry; |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.gkhy.hazmat.common.excel; |
| | | |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | |
| | | public class HazmatBasicExcelDataListener extends AnalysisEventListener<HazmatBasicExcelData> { |
| | | @Override |
| | | public void invoke(HazmatBasicExcelData hazmatBasicExcelData, AnalysisContext analysisContext) { |
| | | System.out.println("invoke"); |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
| | | //所有数据解析完成后的操作 |
| | | System.out.println("doAfterAllAnalysed"); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.gkhy.hazmat.common.excel; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Getter |
| | | @Setter |
| | | public class ProductBasicExcelData { |
| | | @ExcelProperty("序号") |
| | | private Integer index; |
| | | |
| | | @ExcelProperty("名称") |
| | | private String name; |
| | | |
| | | @ExcelProperty("产品编号") |
| | | private String productSn; |
| | | |
| | | @ExcelProperty("种类") |
| | | private String kind; |
| | | |
| | | @ExcelProperty("CAS") |
| | | private String cas; |
| | | |
| | | @ExcelProperty("试剂类型") |
| | | private String productType; |
| | | |
| | | @ExcelProperty("危险性质") |
| | | private String productCharacter; |
| | | |
| | | @ExcelProperty("供应商") |
| | | private String supplier; |
| | | |
| | | @ExcelProperty("厂家") |
| | | private String manufacturer; |
| | | |
| | | @ExcelProperty("规格") |
| | | private String productFormat; |
| | | |
| | | |
| | | @ExcelProperty("包装数量") |
| | | private BigDecimal metering; |
| | | |
| | | @ExcelProperty("包装单位") |
| | | private String unit; |
| | | |
| | | @ExcelProperty("含税价格") |
| | | private BigDecimal price; |
| | | |
| | | @ExcelProperty("每箱数量") |
| | | private Integer perBox; |
| | | |
| | | |
| | | @ExcelProperty("最小包装类型") |
| | | private String minPackage; |
| | | |
| | | @ExcelProperty("单次入库最大数量") |
| | | private Integer maxEntry; |
| | | } |
对比新文件 |
| | |
| | | package com.gkhy.hazmat.common.excel; |
| | | |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | |
| | | public class ProductBasicExcelDataListener extends AnalysisEventListener<ProductBasicExcelData> { |
| | | @Override |
| | | public void invoke(ProductBasicExcelData productBasicExcelData, AnalysisContext analysisContext) { |
| | | System.out.println("invoke"); |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
| | | //所有数据解析完成后的操作 |
| | | System.out.println("doAfterAllAnalysed"); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.gkhy.hazmat.framework.interceptor; |
| | | |
| | | import cn.hutool.extra.servlet.ServletUtil; |
| | | import com.gkhy.hazmat.common.utils.SecurityUtils; |
| | | import org.slf4j.MDC; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @ClassName LogInterceptor |
| | | * @Description TODO |
| | | **/ |
| | | @Component |
| | | public class LogInterceptor implements HandlerInterceptor { |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | String requestId = UUID.randomUUID().toString(); |
| | | String ip = ServletUtil.getClientIP(request,null); |
| | | String url=request.getRequestURI(); |
| | | |
| | | MDC.put("requestId", requestId); |
| | | MDC.put("clientIP", ip); |
| | | MDC.put("url", url); |
| | | String userId= SecurityUtils.getLoginUserWithoutError()!=null?String.valueOf(SecurityUtils.getLoginUserWithoutError().getUser().getId()):""; |
| | | MDC.put("userId", userId); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { |
| | | MDC.clear(); |
| | | } |
| | | } |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @Accessors(chain = true) |
| | | @TableName("hz_hazmat_basic") |
| | | @ApiModel(value = "HzHazmatBasic对象", description = "危化品基础数据表") |
| | | @JsonInclude(NON_NULL) |
| | |
| | | @TableField("price") |
| | | private BigDecimal price; |
| | | |
| | | @NotNull(message = "每箱数量不能为空") |
| | | // @NotNull(message = "每箱数量不能为空") |
| | | @ApiModelProperty(value = "每箱数量",required = true) |
| | | @TableField("per_box") |
| | | private Integer perBox; |
| | |
| | | @TableField("remark") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("单次入库最大数量") |
| | | @TableField("max_entry") |
| | | private Integer maxEntry; |
| | | |
| | | @Version |
| | | @TableField("version") |
| | | private Integer version; |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.Serializable; |
| | |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @Accessors(chain = true) |
| | | @TableName("hz_product_basic") |
| | | @ApiModel(value = "HzProductBasic对象", description = "成品基础数据表") |
| | | @JsonInclude(NON_NULL) |
| | |
| | | @TableField("remark") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("单次入库最大数量") |
| | | @TableField("max_entry") |
| | | private Integer maxEntry; |
| | | |
| | | @Version |
| | | @TableField("version") |
| | | private Integer version; |
| | |
| | | package com.gkhy.hazmat.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.gkhy.hazmat.common.domain.BaseEntity; |
| | | import io.swagger.annotations.ApiModel; |
| | |
| | | @TableField("company_id") |
| | | private Long companyId; |
| | | |
| | | @Version |
| | | @TableField("version") |
| | | private Integer version; |
| | | |
| | |
| | | @TableField("del_flag") |
| | | private Integer delFlag; |
| | | |
| | | @NotBlank(message = "公司唯一编码为空") |
| | | @Length(min = 2, max = 2, message = "公司唯一编码只能为2位") |
| | | @ApiModelProperty("公司唯一编码(2位)") |
| | | @TableField("code") |
| | | private String code; |
| | | |
| | | @Version |
| | | @ApiModelProperty("乐观锁") |
| | | @TableField("version") |
| | |
| | | * @return |
| | | */ |
| | | HzHazmatFlow selectLastFlow(@Param("slice") Integer slice,@Param("hazmatId") Long hazmatId, @Param("state")Integer state); |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | SysCompany checkNameUnique(String name); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 校验公司编码是否唯一 |
| | | * @param code |
| | | * @return |
| | | */ |
| | | SysCompany checkCodeUnique(String code); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.gkhy.hazmat.common.api.CommonPage; |
| | | import com.gkhy.hazmat.system.domain.HzHazmatBasic; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public boolean checkProductSnUnique(HzHazmatBasic hazmatBasic); |
| | | |
| | | /** |
| | | * excel导入 |
| | | * @param file |
| | | */ |
| | | Integer importExcel(MultipartFile file) throws IOException; |
| | | } |
| | |
| | | * @param hazmat |
| | | */ |
| | | void changeState(HzHazmat hazmat); |
| | | |
| | | /** |
| | | * 零头数据处理(修改在库余量) |
| | | * @param hazmat |
| | | */ |
| | | void changeRemaining(HzHazmat hazmat); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.gkhy.hazmat.common.api.CommonPage; |
| | | import com.gkhy.hazmat.system.domain.HzProductBasic; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @return boolean |
| | | */ |
| | | public boolean checkProductSnUnique(HzProductBasic productBasic); |
| | | |
| | | |
| | | /** |
| | | * excel导入 |
| | | * @param file |
| | | */ |
| | | Integer importExcel(MultipartFile file) throws IOException; |
| | | } |
| | |
| | | import com.gkhy.hazmat.common.utils.PageUtils; |
| | | import com.gkhy.hazmat.common.utils.SecurityUtils; |
| | | import com.gkhy.hazmat.common.utils.StringUtils; |
| | | import com.gkhy.hazmat.system.domain.HzEntryRecord; |
| | | import com.gkhy.hazmat.system.domain.HzHazmat; |
| | | import com.gkhy.hazmat.system.domain.HzHazmatBasic; |
| | | import com.gkhy.hazmat.system.domain.HzWarehouseRecord; |
| | | import com.gkhy.hazmat.system.mapper.HzEntryRecordMapper; |
| | | import com.gkhy.hazmat.system.mapper.HzHazmatBasicMapper; |
| | | import com.gkhy.hazmat.system.mapper.HzHazmatMapper; |
| | | import com.gkhy.hazmat.system.mapper.HzWarehouseRecordMapper; |
| | | import com.gkhy.hazmat.system.domain.*; |
| | | import com.gkhy.hazmat.system.mapper.*; |
| | | import com.gkhy.hazmat.system.service.HzEntryRecordService; |
| | | import com.gkhy.hazmat.system.service.HzHazmatService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private HzWarehouseRecordMapper warehouseRecordMapper; |
| | | @Autowired |
| | | private CustomEventPublisher customEventPublisher; |
| | | @Autowired |
| | | private SysCompanyMapper companyMapper; |
| | | |
| | | @Override |
| | | public CommonPage selectEntryRecordList(HzEntryRecord entryRecord) { |
| | |
| | | if(hazmatBasic==null){ |
| | | throw new ApiException("危化品基础数据不存在"); |
| | | } |
| | | if(entryRecord.getNum()>hazmatBasic.getMaxEntry()){ |
| | | throw new ApiException("数量超过单次入库最大数量<"+hazmatBasic.getMaxEntry()+">"); |
| | | } |
| | | entryRecord.setCompanyId(currentUser.getCompanyId()); |
| | | entryRecord.setCreateBy(currentUser.getUsername()); |
| | | checkUserAllowed(null,currentUser); |
| | |
| | | } |
| | | |
| | | public void generateCode(HzEntryRecord entryRecord){ |
| | | SysCompany company=companyMapper.selectById(entryRecord.getCompanyId()); |
| | | String code=company.getCode(); |
| | | if(StringUtils.isBlank(code)){ |
| | | throw new ApiException("公司两位编码为空"); |
| | | } |
| | | String currentDate= DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT); |
| | | StringBuilder prefixBuilder=new StringBuilder().append(CodePrexEnum.MATERIAL.getCode()) |
| | | .append(code) |
| | | .append(currentDate); |
| | | |
| | | HzEntryRecord er=baseMapper.selectLastEntryRecord(prefixBuilder.toString(),entryRecord.getCompanyId()); |
| | | int startCode=0; |
| | | int startCode=1; |
| | | int endCode=startCode+entryRecord.getNum()-1; |
| | | if(er!=null){ |
| | | startCode=er.getEndCode()+1; |
| | |
| | | public int updateEntryRecord(HzEntryRecord entryRecord) { |
| | | SysUser currentUser = SecurityUtils.getLoginUser().getUser(); |
| | | checkUserAllowed(entryRecord,currentUser); |
| | | HzHazmatBasic hazmatBasic=hazmatBasicMapper.selectById(entryRecord.getBasicId()); |
| | | if(hazmatBasic==null){ |
| | | throw new ApiException("危化品基础数据不存在"); |
| | | } |
| | | HzEntryRecord existEr=baseMapper.selectById(entryRecord.getId()); |
| | | if(existEr.getState().equals(EntryStateEnum.ENTER.getCode())){ |
| | | throw new ApiException("已经入库,不能再修改"); |
| | | } |
| | | if(entryRecord.getNum()>hazmatBasic.getMaxEntry()){ |
| | | throw new ApiException("数量超过单次入库最大数量<"+hazmatBasic.getMaxEntry()+">"); |
| | | } |
| | | entryRecord.setUpdateBy(currentUser.getUsername()); |
| | | int row=baseMapper.updateById(entryRecord); |
| | | if(row<1){ |
| | |
| | | package com.gkhy.hazmat.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.hazmat.common.api.CommonPage; |
| | | import com.gkhy.hazmat.common.constant.UserConstant; |
| | | import com.gkhy.hazmat.common.domain.entity.SysUser; |
| | | import com.gkhy.hazmat.common.enums.HazmatKindEnum; |
| | | import com.gkhy.hazmat.common.enums.HazmatPackageEnum; |
| | | import com.gkhy.hazmat.common.enums.UserTypeEnum; |
| | | import com.gkhy.hazmat.common.excel.HazmatBasicExcelData; |
| | | import com.gkhy.hazmat.common.excel.HazmatBasicExcelDataListener; |
| | | import com.gkhy.hazmat.common.exception.ApiException; |
| | | import com.gkhy.hazmat.common.utils.PageUtils; |
| | | import com.gkhy.hazmat.common.utils.SecurityUtils; |
| | | import com.gkhy.hazmat.common.utils.StringUtils; |
| | | import com.gkhy.hazmat.system.domain.HzHazmatBasic; |
| | | import com.gkhy.hazmat.system.mapper.HzHazmatBasicMapper; |
| | | import com.gkhy.hazmat.system.service.HzHazmatBasicService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | throw new ApiException("产品编号已存在"); |
| | | } |
| | | checkUserAllowed(null,currentUser); |
| | | |
| | | int row = baseMapper.insert(hazmatBasic); |
| | | if (row < 1) { |
| | | throw new ApiException("新增危化品基础信息失败"); |
| | |
| | | } |
| | | return UserConstant.UNIQUE; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = RuntimeException.class) |
| | | public Integer importExcel(MultipartFile file) throws IOException { |
| | | if(ObjectUtil.isEmpty(file)){ |
| | | throw new ApiException("上传对象不能为空"); |
| | | } |
| | | SysUser currentUser=SecurityUtils.getLoginUser().getUser(); |
| | | checkUserAllowed(null,currentUser); |
| | | List<HazmatBasicExcelData> hazmatExcelDataList = EasyExcel.read(file.getInputStream(), HazmatBasicExcelData.class, new HazmatBasicExcelDataListener()).sheet().doReadSync(); |
| | | List<HzHazmatBasic> hazmatBasicList=new ArrayList<>(); |
| | | |
| | | for(HazmatBasicExcelData hazmatBasicExcelData:hazmatExcelDataList){ |
| | | validateData(hazmatBasicExcelData); |
| | | if (!checkProductSnUnique(new HzHazmatBasic().setProductSn(hazmatBasicExcelData.getProductSn()).setCompanyId(currentUser.getCompanyId()))) { |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"产品编号已存在"); |
| | | } |
| | | HzHazmatBasic hazmatBasic=new HzHazmatBasic(); |
| | | BeanUtils.copyProperties(hazmatBasicExcelData,hazmatBasic,new String[]{"kind","minPackage"}); |
| | | Integer kind= HazmatKindEnum.getCodeByInfo(hazmatBasicExcelData.getKind()); |
| | | if(kind==null){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"种类填写不正确"); |
| | | } |
| | | Integer minPackage= HazmatPackageEnum.getCodeByInfo(hazmatBasicExcelData.getMinPackage()); |
| | | if(minPackage==null){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"最小包装类型填写不正确"); |
| | | } |
| | | hazmatBasic.setKind(kind); |
| | | hazmatBasic.setMinPackage(minPackage); |
| | | hazmatBasic.setCompanyId(currentUser.getCompanyId()); |
| | | hazmatBasic.setCreateBy(currentUser.getUsername()); |
| | | hazmatBasicList.add(hazmatBasic); |
| | | } |
| | | if(!hazmatBasicList.isEmpty()){ |
| | | if(hazmatBasicList.size()>100){ |
| | | int pageSize=100; |
| | | while (true){ |
| | | List<HzHazmatBasic> hazmatBasics=hazmatBasicList.subList(0, Math.min(hazmatBasicList.size(), pageSize)); |
| | | saveBatch(hazmatBasics); |
| | | if(hazmatBasics.size()<pageSize){ |
| | | break; |
| | | } |
| | | hazmatBasicList=hazmatBasicList.subList(pageSize,hazmatBasicList.size()); |
| | | if(hazmatBasicList.isEmpty()){ |
| | | break; |
| | | } |
| | | } |
| | | }else{ |
| | | saveBatch(hazmatBasicList); |
| | | } |
| | | } |
| | | return hazmatBasicList.size(); |
| | | } |
| | | |
| | | |
| | | public void validateData(HazmatBasicExcelData hazmatBasicExcelData){ |
| | | if(StringUtils.isBlank(hazmatBasicExcelData.getName())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"名称为空"); |
| | | } |
| | | if(StringUtils.isBlank(hazmatBasicExcelData.getProductSn())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"产品编码为空"); |
| | | } |
| | | if(StringUtils.isBlank(hazmatBasicExcelData.getKind())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"种类为空"); |
| | | } |
| | | if(StringUtils.isBlank(hazmatBasicExcelData.getCas())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"CAS为空"); |
| | | } |
| | | if(StringUtils.isBlank(hazmatBasicExcelData.getHazmatType())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"试剂类型为空"); |
| | | } |
| | | if(StringUtils.isBlank(hazmatBasicExcelData.getHazmatCharacter())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"危险性质为空"); |
| | | } |
| | | if(StringUtils.isBlank(hazmatBasicExcelData.getSupplier())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"供应商为空"); |
| | | } |
| | | if(StringUtils.isBlank(hazmatBasicExcelData.getManufacturer())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"厂家为空"); |
| | | } |
| | | if(StringUtils.isBlank(hazmatBasicExcelData.getHazmatFormat())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"规格为空"); |
| | | } |
| | | if(ObjectUtil.isEmpty(hazmatBasicExcelData.getMetering())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"包装数量为空"); |
| | | } |
| | | if(StringUtils.isBlank(hazmatBasicExcelData.getUnit())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"包装单位为空"); |
| | | } |
| | | if(ObjectUtil.isEmpty(hazmatBasicExcelData.getPrice())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"含税价格为空"); |
| | | } |
| | | if(ObjectUtil.isEmpty(hazmatBasicExcelData.getMinPackage())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"最小包装类型为空"); |
| | | } |
| | | if(ObjectUtil.isEmpty(hazmatBasicExcelData.getSafeNum())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"安全库存为空"); |
| | | } |
| | | if(ObjectUtil.isEmpty(hazmatBasicExcelData.getThreshold())){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"超期阀值为空"); |
| | | } |
| | | |
| | | if(ObjectUtil.isEmpty(hazmatBasicExcelData.getMaxEntry())||hazmatBasicExcelData.getMaxEntry()<1){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"单次录入最大数量为空或者小于0"); |
| | | } |
| | | |
| | | if(hazmatBasicExcelData.getMetering().compareTo(BigDecimal.ZERO)<=0){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"包装数量小于0"); |
| | | } |
| | | |
| | | if(hazmatBasicExcelData.getPrice().compareTo(BigDecimal.ZERO)<=0){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"含税价格小于0"); |
| | | } |
| | | |
| | | if(ObjectUtil.isNotEmpty(hazmatBasicExcelData.getPerBox()) && hazmatBasicExcelData.getPerBox()<=0){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"每箱数量小于0"); |
| | | } |
| | | |
| | | if(hazmatBasicExcelData.getSafeNum()<0){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"安全库存小于0"); |
| | | } |
| | | |
| | | if(hazmatBasicExcelData.getThreshold()<0){ |
| | | throw new ApiException("序号"+hazmatBasicExcelData.getIndex()+"超期阀值小于0"); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | //设置分表id |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | HzHazmatFlow hazmatFlow = baseMapper.selectById(hazmatFlowId); |
| | | IdTableNameHandler.removeCurrentId(); |
| | | if (!hazmatFlow.getCompanyId().equals(currentUser.getCompanyId())) { |
| | | throw new ApiException("无权限查看其它企业数据"); |
| | | } |
| | |
| | | //设置分表id |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | int row = baseMapper.insert(hazmatFlow); |
| | | IdTableNameHandler.removeCurrentId(); |
| | | if (row < 1) { |
| | | throw new ApiException("新增危化品流向失败"); |
| | | } |
| | |
| | | //设置分表id |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | HzHazmatFlow hazmatFlow=baseMapper.selectById(hazmatFlowId); |
| | | IdTableNameHandler.removeCurrentId(); |
| | | if(hazmatFlow==null){ |
| | | throw new ApiException("流向信息不存在"); |
| | | } |
| | |
| | | package com.gkhy.hazmat.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.hazmat.common.api.CommonPage; |
| | | import com.gkhy.hazmat.common.config.IdTableNameHandler; |
| | |
| | | IdTableNameHandler.removeCurrentId(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = RuntimeException.class) |
| | | public void changeRemaining(HzHazmat hazmat) { |
| | | if(hazmat.getId()==null||hazmat.getRemaining()==null){ |
| | | throw new ApiException("参数不正确"); |
| | | } |
| | | SysUser currentUser=SecurityUtils.getLoginUser().getUser(); |
| | | checkUserAllowed(null,currentUser); |
| | | //设置分表id |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | HzHazmat dbHazmat=getById(hazmat.getId()); |
| | | checkUserAllowed(dbHazmat,currentUser); |
| | | if(hazmat.getRemaining().compareTo(dbHazmat.getRemaining())>=0){ |
| | | throw new ApiException("修改值不能大于等于在库容量"); |
| | | } |
| | | //校验是否产生流向 |
| | | Long flowCount=hazmatFlowMapper.selectCount(Wrappers.<HzHazmatFlow>lambdaQuery().eq(HzHazmatFlow::getHazmatId,hazmat.getId()) |
| | | .ne(HzHazmatFlow::getState,OperateStatusEnum.ENTRY.getCode())); |
| | | if(flowCount>0){ |
| | | throw new ApiException("该危化品已流转,不能修改!"); |
| | | } |
| | | HzHazmat newHazmat=new HzHazmat().setId(hazmat.getId()).setRemaining(hazmat.getRemaining()); |
| | | newHazmat.setUpdateBy(currentUser.getUsername()); |
| | | updateById(newHazmat); |
| | | //生成流向 |
| | | HzHazmatFlow hazmatFlow=new HzHazmatFlow(); |
| | | hazmatFlow.setHazmatId(hazmat.getId()); |
| | | hazmatFlow.setBasicId(dbHazmat.getBasicId()); |
| | | hazmatFlow.setState(OperateStatusEnum.REMNANT.getCode()); |
| | | hazmatFlow.setCompanyId(currentUser.getCompanyId()); |
| | | hazmatFlow.setNum(hazmat.getRemaining()); |
| | | hazmatFlow.setCreateId(currentUser.getId()); |
| | | hazmatFlowMapper.insert(hazmatFlow); |
| | | IdTableNameHandler.removeCurrentId(); |
| | | } |
| | | |
| | | public void checkUserAllowed(HzHazmat hazmat,SysUser user) { |
| | | if (user.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())) { |
| | | throw new ApiException("管理员不能操作"); |
| | |
| | | package com.gkhy.hazmat.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.hazmat.common.api.CommonPage; |
| | | import com.gkhy.hazmat.common.constant.UserConstant; |
| | | import com.gkhy.hazmat.common.domain.entity.SysUser; |
| | | import com.gkhy.hazmat.common.enums.HazmatKindEnum; |
| | | import com.gkhy.hazmat.common.enums.HazmatPackageEnum; |
| | | import com.gkhy.hazmat.common.enums.UserTypeEnum; |
| | | import com.gkhy.hazmat.common.excel.ProductBasicExcelData; |
| | | import com.gkhy.hazmat.common.excel.ProductBasicExcelDataListener; |
| | | import com.gkhy.hazmat.common.exception.ApiException; |
| | | import com.gkhy.hazmat.common.utils.PageUtils; |
| | | import com.gkhy.hazmat.common.utils.SecurityUtils; |
| | | import com.gkhy.hazmat.common.utils.StringUtils; |
| | | import com.gkhy.hazmat.system.domain.HzProductBasic; |
| | | import com.gkhy.hazmat.system.mapper.HzProductBasicMapper; |
| | | import com.gkhy.hazmat.system.service.HzProductBasicService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | } |
| | | return UserConstant.UNIQUE; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = RuntimeException.class) |
| | | public Integer importExcel(MultipartFile file) throws IOException { |
| | | if(ObjectUtil.isEmpty(file)){ |
| | | throw new ApiException("上传对象不能为空"); |
| | | } |
| | | SysUser currentUser=SecurityUtils.getLoginUser().getUser(); |
| | | checkUserAllowed(null,currentUser); |
| | | List<ProductBasicExcelData> productExcelDataList = EasyExcel.read(file.getInputStream(), ProductBasicExcelData.class, new ProductBasicExcelDataListener()).sheet().doReadSync(); |
| | | List<HzProductBasic> productBasicList=new ArrayList<>(); |
| | | |
| | | for(ProductBasicExcelData productBasicExcelData:productExcelDataList){ |
| | | validateData(productBasicExcelData); |
| | | if (!checkProductSnUnique(new HzProductBasic().setProductSn(productBasicExcelData.getProductSn()).setCompanyId(currentUser.getCompanyId()))) { |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"产品编号已存在"); |
| | | } |
| | | HzProductBasic productBasic=new HzProductBasic(); |
| | | BeanUtils.copyProperties(productBasicExcelData,productBasic,new String[]{"kind","minPackage"}); |
| | | Integer kind= HazmatKindEnum.getCodeByInfo(productBasicExcelData.getKind()); |
| | | if(kind==null){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"种类填写不正确"); |
| | | } |
| | | Integer minPackage= HazmatPackageEnum.getCodeByInfo(productBasicExcelData.getMinPackage()); |
| | | if(minPackage==null){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"最小包装类型填写不正确"); |
| | | } |
| | | productBasic.setKind(kind); |
| | | productBasic.setMinPackage(minPackage); |
| | | productBasic.setCompanyId(currentUser.getCompanyId()); |
| | | productBasic.setCreateBy(currentUser.getUsername()); |
| | | productBasicList.add(productBasic); |
| | | } |
| | | if(!productBasicList.isEmpty()){ |
| | | if(productBasicList.size()>100){ |
| | | int pageSize=100; |
| | | while (true){ |
| | | List<HzProductBasic> hazmatBasics=productBasicList.subList(0, Math.min(productBasicList.size(), pageSize)); |
| | | saveBatch(hazmatBasics); |
| | | if(hazmatBasics.size()<pageSize){ |
| | | break; |
| | | } |
| | | productBasicList=productBasicList.subList(pageSize,productBasicList.size()); |
| | | if(productBasicList.isEmpty()){ |
| | | break; |
| | | } |
| | | } |
| | | }else{ |
| | | saveBatch(productBasicList); |
| | | } |
| | | } |
| | | return productBasicList.size(); |
| | | } |
| | | |
| | | |
| | | public void validateData(ProductBasicExcelData productBasicExcelData){ |
| | | if(StringUtils.isBlank(productBasicExcelData.getName())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"名称为空"); |
| | | } |
| | | if(StringUtils.isBlank(productBasicExcelData.getProductSn())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"产品编码为空"); |
| | | } |
| | | if(StringUtils.isBlank(productBasicExcelData.getKind())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"种类为空"); |
| | | } |
| | | if(StringUtils.isBlank(productBasicExcelData.getCas())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"CAS为空"); |
| | | } |
| | | if(StringUtils.isBlank(productBasicExcelData.getProductType())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"试剂类型为空"); |
| | | } |
| | | if(StringUtils.isBlank(productBasicExcelData.getProductCharacter())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"危险性质为空"); |
| | | } |
| | | if(StringUtils.isBlank(productBasicExcelData.getSupplier())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"供应商为空"); |
| | | } |
| | | if(StringUtils.isBlank(productBasicExcelData.getManufacturer())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"厂家为空"); |
| | | } |
| | | if(StringUtils.isBlank(productBasicExcelData.getProductFormat())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"规格为空"); |
| | | } |
| | | if(ObjectUtil.isEmpty(productBasicExcelData.getMetering())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"包装数量为空"); |
| | | } |
| | | if(StringUtils.isBlank(productBasicExcelData.getUnit())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"包装单位为空"); |
| | | } |
| | | if(ObjectUtil.isEmpty(productBasicExcelData.getPrice())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"含税价格为空"); |
| | | } |
| | | if(ObjectUtil.isEmpty(productBasicExcelData.getMinPackage())){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"最小包装类型为空"); |
| | | } |
| | | |
| | | if(ObjectUtil.isEmpty(productBasicExcelData.getMaxEntry())||productBasicExcelData.getMaxEntry()<1){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"单次录入最大数量为空或者小于0"); |
| | | } |
| | | |
| | | if(productBasicExcelData.getMetering().compareTo(BigDecimal.ZERO)<=0){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"包装数量小于0"); |
| | | } |
| | | |
| | | if(productBasicExcelData.getPrice().compareTo(BigDecimal.ZERO)<=0){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"含税价格小于0"); |
| | | } |
| | | |
| | | if(ObjectUtil.isNotEmpty(productBasicExcelData.getPerBox()) && productBasicExcelData.getPerBox()<=0){ |
| | | throw new ApiException("序号"+productBasicExcelData.getIndex()+"每箱数量小于0"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | import com.gkhy.hazmat.common.utils.PageUtils; |
| | | import com.gkhy.hazmat.common.utils.SecurityUtils; |
| | | import com.gkhy.hazmat.common.utils.StringUtils; |
| | | import com.gkhy.hazmat.system.domain.HzProduct; |
| | | import com.gkhy.hazmat.system.domain.HzProductBasic; |
| | | import com.gkhy.hazmat.system.domain.HzProductEntryRecord; |
| | | import com.gkhy.hazmat.system.domain.HzProductWarehouseRecord; |
| | | import com.gkhy.hazmat.system.mapper.HzProductBasicMapper; |
| | | import com.gkhy.hazmat.system.mapper.HzProductEntryRecordMapper; |
| | | import com.gkhy.hazmat.system.mapper.HzProductMapper; |
| | | import com.gkhy.hazmat.system.mapper.HzProductWarehouseRecordMapper; |
| | | import com.gkhy.hazmat.system.domain.*; |
| | | import com.gkhy.hazmat.system.mapper.*; |
| | | import com.gkhy.hazmat.system.service.HzProductEntryRecordService; |
| | | import com.gkhy.hazmat.system.service.HzProductService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private HzProductWarehouseRecordMapper productWarehouseRecordMapper; |
| | | @Autowired |
| | | private CustomEventPublisher customEventPublisher; |
| | | @Autowired |
| | | private SysCompanyMapper companyMapper; |
| | | |
| | | @Override |
| | | public CommonPage selectEntryRecordList(HzProductEntryRecord entryRecord) { |
| | |
| | | if(productBasic==null){ |
| | | throw new ApiException("成品基础数据不存在"); |
| | | } |
| | | if(entryRecord.getNum()>productBasic.getMaxEntry()){ |
| | | throw new ApiException("数量超过单次入库最大数量<"+productBasic.getMaxEntry()+">"); |
| | | } |
| | | entryRecord.setCompanyId(currentUser.getCompanyId()); |
| | | entryRecord.setCreateBy(currentUser.getUsername()); |
| | | checkUserAllowed(null,currentUser); |
| | |
| | | } |
| | | |
| | | public void generateCode(HzProductEntryRecord entryRecord){ |
| | | SysCompany company=companyMapper.selectById(entryRecord.getCompanyId()); |
| | | String code=company.getCode(); |
| | | if(StringUtils.isBlank(code)){ |
| | | throw new ApiException("公司两位编码为空"); |
| | | } |
| | | String currentDate= DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT); |
| | | StringBuilder prefixBuilder=new StringBuilder().append(CodePrexEnum.GOOD.getCode()) |
| | | .append(code) |
| | | .append(currentDate); |
| | | HzProductEntryRecord per=baseMapper.selectLastEntryRecord(prefixBuilder.toString(),entryRecord.getCompanyId()); |
| | | int startCode=0; |
| | | int startCode=1; |
| | | int endCode=startCode+entryRecord.getNum()-1; |
| | | if(per!=null){ |
| | | startCode=per.getEndCode()+1; |
| | |
| | | public int updateEntryRecord(HzProductEntryRecord entryRecord) { |
| | | SysUser currentUser = SecurityUtils.getLoginUser().getUser(); |
| | | checkUserAllowed(entryRecord,currentUser); |
| | | HzProductBasic productBasic=productBasicMapper.selectById(entryRecord.getBasicId()); |
| | | if(productBasic==null){ |
| | | throw new ApiException("成品基础数据不存在"); |
| | | } |
| | | if(entryRecord.getNum()>productBasic.getMaxEntry()){ |
| | | throw new ApiException("数量超过单次入库最大数量<"+productBasic.getMaxEntry()+">"); |
| | | } |
| | | HzProductEntryRecord existEr=baseMapper.selectById(entryRecord.getId()); |
| | | if(existEr.getState().equals(EntryStateEnum.ENTER.getCode())){ |
| | | throw new ApiException("已经入库,不能再修改"); |
| | | } |
| | | |
| | | entryRecord.setUpdateBy(currentUser.getUsername()); |
| | | int row=baseMapper.updateById(entryRecord); |
| | | if(row<1){ |
| | |
| | | if(!checkNameUnique(company)){ |
| | | throw new ApiException("公司名称已存在"); |
| | | } |
| | | if(!checkCodeUnique(company)){ |
| | | throw new ApiException("公司编码已存在"); |
| | | } |
| | | company.setCode(company.getCode().toUpperCase()); |
| | | company.setCreateBy(SecurityUtils.getUsername()); |
| | | int row= baseMapper.insert(company); |
| | | if(row<1){ |
| | | throw new ApiException("新增公司失败"); |
| | | } |
| | | |
| | | return row; |
| | | } |
| | | |
| | |
| | | if(!checkNameUnique(company)){ |
| | | throw new ApiException("公司名称已存在"); |
| | | } |
| | | if(!checkCodeUnique(company)){ |
| | | throw new ApiException("公司编码已存在"); |
| | | } |
| | | company.setCode(company.getCode().toUpperCase()); |
| | | company.setUpdateBy(SecurityUtils.getUsername()); |
| | | return baseMapper.updateById(company); |
| | | } |
| | |
| | | } |
| | | return UserConstant.UNIQUE; |
| | | } |
| | | |
| | | |
| | | public boolean checkCodeUnique(SysCompany company){ |
| | | Long companyId=company.getId()==null?-1L:company.getId(); |
| | | SysCompany com= baseMapper.checkCodeUnique(company.getCode()); |
| | | if(com!=null&&com.getId().longValue()!=companyId.longValue()){ |
| | | return UserConstant.NOT_UNIQUE; |
| | | } |
| | | return UserConstant.UNIQUE; |
| | | } |
| | | } |
| | |
| | | <result property="metering" column="basic_metering" /> |
| | | <result property="unit" column="basic_unit" /> |
| | | <result property="productSn" column="product_sn" /> |
| | | <result property="maxEntry" column="max_entry" /> |
| | | </resultMap> |
| | | |
| | | <resultMap id="wareResult" type="com.gkhy.hazmat.system.domain.HzWarehouse"> |
| | |
| | | select a.id, a.warehouse_id, a.num,a.batch_no,a.state,a.basic_id,a.company_id,a.start_code,a.end_code,a.code_prex,a.version, a.create_by, |
| | | a.create_time, a.update_by, a.update_time, a.remark, |
| | | b.id as basic_id,b.name as basic_name,b.cas as basic_cas,b.hazmat_type as basic_hazmat_type,b.hazmat_character as basic_hazmat_character, |
| | | b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package, |
| | | b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package,b.max_entry, |
| | | c.id as warehouse_id,c.name as warehouse_name |
| | | from hz_entry_record a |
| | | left join hz_hazmat_basic b on b.id=a.basic_id |
| | |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="remark" column="remark" /> |
| | | <result property="maxEntry" column="max_entry" /> |
| | | <result property="companyName" column="company_name" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectHazmatBasicVo"> |
| | | select a.id, a.name, a.cas, a.hazmat_type,a.min_package, a.kind,a.hazmat_character,a.supplier,a.manufacturer,a.hazmat_format,a.metering, |
| | | a.unit,a.price,a.per_box,a.safe_num,a.threshold,a.product_sn,a.company_id,a.version, a.create_by, a.create_time, |
| | | a.update_by, a.update_time, a.remark,b.name as company_name |
| | | a.update_by, a.update_time, a.remark,a.max_entry,b.name as company_name |
| | | from hz_hazmat_basic a |
| | | left join sys_company b on b.id=a.company_id |
| | | </sql> |
| | |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="remark" column="remark" /> |
| | | <result property="maxEntry" column="max_entry" /> |
| | | <result property="companyName" column="company_name" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectProductBasicVo"> |
| | | select a.id, a.name, a.cas, a.product_type, a.min_package,a.kind,a.product_character,a.supplier,a.manufacturer,a.product_format,a.metering, |
| | | a.unit,a.price,a.per_box,a.product_sn,a.company_id,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as company_name |
| | | a.unit,a.price,a.per_box,a.product_sn,a.company_id,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,a.max_entry,b.name as company_name |
| | | from hz_product_basic a |
| | | left join sys_company b on b.id=a.company_id |
| | | </sql> |
| | |
| | | <result property="metering" column="basic_metering" /> |
| | | <result property="unit" column="basic_unit" /> |
| | | <result property="productSn" column="product_sn" /> |
| | | <result property="maxEntry" column="max_entry" /> |
| | | </resultMap> |
| | | |
| | | <resultMap id="wareResult" type="com.gkhy.hazmat.system.domain.HzWarehouse"> |
| | |
| | | select a.id, a.warehouse_id, a.num,a.batch_no,a.state,a.basic_id,a.company_id,a.start_code,a.end_code,a.code_prex,a.version, a.create_by, |
| | | a.create_time, a.update_by, a.update_time, a.remark, |
| | | b.id as basic_id,b.name as basic_name,b.cas as basic_cas,b.product_type as basic_product_type,b.product_character as basic_product_character, |
| | | b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package, |
| | | b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package,b.max_entry, |
| | | c.id as warehouse_id,c.name as warehouse_name |
| | | from hz_product_entry_record a |
| | | left join hz_product_basic b on b.id=a.basic_id |
| | |
| | | <result property="creditCode" column="credit_code" /> |
| | | <result property="major" column="major" /> |
| | | <result property="phone" column="phone" /> |
| | | <result property="code" column="code" /> |
| | | <result property="delFlag" column="del_flag" /> |
| | | <result property="version" column="version" /> |
| | | <result property="createBy" column="create_by" /> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="selectCompanyVo"> |
| | | select id, name, credit_code, major, phone,version, create_by, create_time, update_by, update_time, remark |
| | | select id, name, credit_code, major,code, phone,version, create_by, create_time, update_by, update_time, remark |
| | | from sys_company |
| | | </sql> |
| | | |
| | |
| | | select id,name from sys_company where name=#{name} and del_flag=0 limit 1 |
| | | </select> |
| | | |
| | | <select id="checkCodeUnique" resultType="com.gkhy.hazmat.system.domain.SysCompany" |
| | | parameterType="java.lang.String"> |
| | | select id,code from sys_company where code=#{code} and del_flag=0 limit 1 |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | |
| | | |
| | | <update id="updateDeptStatusNormal" parameterType="Long"> |
| | | update sys_dept set status = '0' where id in |
| | | update sys_dept set status = 0 where id in |
| | | <foreach collection="array" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | |
| | | |
| | | <select id="getUserByUsername" resultMap="SysUserResult"> |
| | | select id,username,name,password,user_type,company_id,status,del_flag from sys_user |
| | | where username=#{username} limit 1 |
| | | where username=#{username} and del_flag=0 limit 1 |
| | | </select> |
| | | |
| | | <select id="userList" resultMap="SysUserResult"> |
| | | select u.id,u.username,u.name,u.user_type,u.phone,u.company_id,u.depart_id,u.sex,u.status,u.del_flag, |
| | | select u.id,u.username,u.name,u.user_type,u.phone,u.company_id,u.depart_id,u.sex,u.status,u.del_flag,u.version, |
| | | u.login_ip,u.login_date,u.create_by,u.create_time,u.remark,c.name as company_name,d.name as depart_name |
| | | from sys_user u |
| | | left join sys_company c on c.id=u.company_id |
| | |
| | | |
| | | <select id="getUserByPhone" resultMap="SysUserResult"> |
| | | select id,username,name,password,company_id,phone,status,del_flag from sys_user |
| | | where phone=#{phone} and del_flag=0 |
| | | where phone=#{phone} and del_flag=0 limit 1 |
| | | </select> |
| | | |
| | | <select id="getUserById" resultMap="SysUserResult"> |
| | | select u.id,u.username,u.user_type,u.name,u.phone,u.company_id,u.depart_id,u.status,u.sex,u.del_flag,c.name as company_name,d.name as depart_name |
| | | select u.id,u.username,u.user_type,u.name,u.phone,u.company_id,u.depart_id,u.status,u.sex,u.del_flag,u.version,c.name as company_name,d.name as depart_name |
| | | from sys_user u |
| | | left join sys_company c on c.id=u.company_id |
| | | left join sys_dept d on d.id=u.depart_id |
| | |
| | | <poi.version>5.2.3</poi.version> |
| | | <pdfbox.version>2.0.27</pdfbox.version> |
| | | <jaudiotagger.version>2.0.1</jaudiotagger.version> |
| | | <easyexcel.version>4.0.2</easyexcel.version> |
| | | </properties> |
| | | <dependencyManagement> |
| | | <dependencies> |
| | |
| | | <version>${jaudiotagger.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | <version>${easyexcel.version}</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | </dependencyManagement> |
| | | |