| | |
| | | // æ¼ç¤ºä¾åï¼æ§è¡ main æ¹æ³æ§å¶å°è¾å
¥æ¨¡å表åå车èªå¨çæå¯¹åºé¡¹ç®ç®å½ä¸ |
| | | public class CodeGenerator { |
| | | |
| | | public static String database_url = "jdbc:mysql://127.0.0.1:3306/product-inventory-management-new"; |
| | | public static String database_url = "jdbc:mysql://1.15.17.182:9999/product-inventory-management-new"; |
| | | public static String database_username = "root"; |
| | | public static String database_password= "123456"; |
| | | public static String database_password= "xd@123456.."; |
| | | public static String author = "è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸"; |
| | | public static String model = "account"; // 模å |
| | | public static String model = "stock"; // 模å |
| | | public static String setParent = "com.ruoyi."+ model; // å
è·¯å¾ |
| | | public static String tablePrefix = ""; // è®¾ç½®è¿æ»¤è¡¨åç¼ |
| | | public static void main(String[] args) { |
| | |
| | | /** |
| | | * ç¥è¯ç±»å |
| | | */ |
| | | @Excel(name = "ç¥è¯ç±»å",readConverterExp = "contract=ååç¹æ¹,approval=å®¡æ¹æ¡ä¾,solution=è§£å³æ¹æ¡,experience=ç»éªæ»ç»,guide=æä½æå") |
| | | @Excel(name = "ç¥è¯ç±»å") |
| | | private String type; |
| | | /** |
| | | * éç¨åºæ¯ |
| | |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.mapper.SalesQuotationMapper; |
| | | import com.ruoyi.sales.mapper.SalesQuotationProductMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.pojo.SalesQuotation; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Autowired |
| | | private SalesQuotationMapper salesQuotationMapper; |
| | | |
| | | @Autowired |
| | | private ShippingInfoMapper shippingInfoMapper; |
| | | |
| | | |
| | | |
| | |
| | | }else if(status.equals(1) && salesQuote != null){ |
| | | salesQuote.setStatus("å®¡æ ¸ä¸"); |
| | | } |
| | | |
| | | salesQuotationMapper.updateById(salesQuote); |
| | | } |
| | | // åºåºå®¡æ¹ä¿®æ¹ |
| | | if(approveProcess.getApproveType().equals(7)){ |
| | | String[] split = approveProcess.getApproveReason().split(":"); |
| | | ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getShippingNo, split[1]) |
| | | .orderByDesc(ShippingInfo::getCreateTime) |
| | | .last("limit 1")); |
| | | if(shippingInfo != null){ |
| | | if(status.equals(2)){ |
| | | shippingInfo.setStatus("å®¡æ ¸éè¿"); |
| | | }else if(status.equals(3)){ |
| | | shippingInfo.setType("å®¡æ ¸æç»"); |
| | | }else if(status.equals(1)){ |
| | | shippingInfo.setStatus("å®¡æ ¸ä¸"); |
| | | } |
| | | shippingInfoMapper.updateById(shippingInfo); |
| | | } |
| | | |
| | | } |
| | | // ç»å®éä»¶ |
| | | if(!CollectionUtils.isEmpty(approveNode.getTempFileIds()) && approveNode.getApproveNodeStatus() == 1){ |
| | |
| | | sysNoticeService.simpleNoticeByUser(approveProcessType(approveProcess.getApproveType()), |
| | | approveNode.getApproveProcessId()+"æµç¨ç¼å·ç审æ¹éè¦æ¨å®¡æ ¸!!!!!", |
| | | Arrays.asList(Long.valueOf(id)), |
| | | approveNode.getTenantId(), |
| | | "/collaborativeApproval/approvalProcess?approveType="+approveProcess.getApproveType()+"&approveId="+approveNode.getApproveProcessId()); |
| | | } |
| | | break; |
| | |
| | | sysNoticeService.simpleNoticeByUser(approveProcessType(approveProcessVO.getApproveType()), |
| | | approveID + "æµç¨ç¼å·ç审æ¹éè¦æ¨å®¡æ ¸!!!!!", |
| | | Arrays.asList(Long.valueOf(id)), |
| | | approveProcessVO.getApproveDeptId(), |
| | | "/collaborativeApproval/approvalProcess?approveType=" + approveProcessVO.getApproveType() + "&approveId=" + approveID); |
| | | } |
| | | |
| | |
| | | sysNoticeService.simpleNoticeByUser(approveProcessType(approveProcess.getApproveType()), |
| | | approveProcess.getApproveId() + "æµç¨ç¼å·ç审æ¹éè¦æ¨å®¡æ ¸!!!!!", |
| | | Arrays.asList(Long.valueOf(id)), |
| | | approveProcess.getApproveDeptId(), |
| | | "/collaborativeApproval/approvalProcess?approveType=" + approveProcess.getApproveType() + "&approveId=" + approveProcess.getApproveId()); |
| | | } |
| | | |
| | |
| | | sysNoticeService.simpleNoticeByUser(approveProcessType(approve.getApproveType()), |
| | | approve.getApproveId() + "æµç¨ç¼å·ç审æ¹éè¦æ¨å®¡æ ¸!!!!!", |
| | | Arrays.asList(Long.valueOf(id)), |
| | | approve.getApproveDeptId(), |
| | | "/collaborativeApproval/approvalProcess?approveType=" + approve.getApproveType() + "&approveId=" + approve.getApproveId()); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.controller; |
| | | |
| | | import com.ruoyi.basic.utils.EnumUtils; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.EnumUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Anonymous; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @RestController |
| | | @Api(tags = "æä¸¾æ¥å£") |
| | | @RequestMapping("/basic/enum") |
| | | public class EnumController { |
| | | |
| | | |
| | | //è·ååºåæä¸¾ |
| | | @GetMapping("/stockRecordType") |
| | | @Anonymous |
| | | public R getStockRecordTypeEnum(){ |
| | | List<Map<String, Object>> list = EnumUtil.toList(StockQualifiedRecordTypeEnum.class); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/{className}") |
| | | @Anonymous |
| | | public R test(@PathVariable String className){ |
| | | return R.ok(EnumUtils.getOptions("com.ruoyi.common.enums." + className)); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class SelectOptionDTO<T> { |
| | | private T value; |
| | | private String label; |
| | | |
| | | public SelectOptionDTO(T code, String value) { |
| | | this.value = code; |
| | | this.label = value; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.procurementrecord.dto.ProcurementPageDto; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * ã请填ååè½åç§°ãMapperæ¥å£ |
| | |
| | | |
| | | ProductModel selectLatestRecord(); |
| | | |
| | | List<Map<String, Object>> getProductAndModelList(); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.utils; |
| | | |
| | | import com.ruoyi.basic.dto.SelectOptionDTO; |
| | | import com.ruoyi.common.enums.BaseEnum; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class EnumUtils { |
| | | public static List<SelectOptionDTO<?>> getOptions(String className) { |
| | | try { |
| | | Class<?> clazz = Class.forName(className); |
| | | return getOptionsByClass(clazz); |
| | | } catch (ClassNotFoundException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | private static List<SelectOptionDTO<?>> getOptionsByClass(Class<?> clazz) { |
| | | if (!clazz.isEnum()) { |
| | | throw new RuntimeException("䏿¯æä¸¾ï¼" + clazz.getName()); |
| | | } |
| | | if (!BaseEnum.class.isAssignableFrom(clazz)) { |
| | | throw new RuntimeException("æªå®ç° BaseEnumï¼" + clazz.getName()); |
| | | } |
| | | return (List<SelectOptionDTO<?>>) getOptionsInternal((Class) clazz); |
| | | } |
| | | |
| | | private static <T> List<SelectOptionDTO<T>> getOptionsInternal( |
| | | Class<? extends BaseEnum<T>> clazz) { |
| | | |
| | | Enum<?>[] enums = (Enum<?>[]) clazz.getEnumConstants(); |
| | | List<SelectOptionDTO<T>> list = new ArrayList<>(); |
| | | |
| | | for (Enum<?> e : enums) { |
| | | BaseEnum<T> option = (BaseEnum<T>) e; |
| | | list.add(new SelectOptionDTO<>( |
| | | option.getCode(), |
| | | option.getValue() |
| | | )); |
| | | } |
| | | return list; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.collaborativeApproval.dto.NoticeDTO; |
| | | import com.ruoyi.collaborativeApproval.pojo.Notice; |
| | | import com.ruoyi.collaborativeApproval.service.NoticeService; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.security.Security; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | |
| | | //æ£å¼åå¸éç¥ææäººçæ¶æ¯éç¥ |
| | | sysNoticeService.simpleNoticeAll("éç¥å
Œ", |
| | | noticeDTO.getTitle(), |
| | | noticeDTO.getTenantId(), |
| | | "/collaborativeApproval/noticeManagement?type="+noticeDTO.getType()); |
| | | } |
| | | return AjaxResult.success(noticeService.save(noticeDTO)); |
| | |
| | | //æ£å¼åå¸éç¥ææäººçæ¶æ¯éç¥ |
| | | sysNoticeService.simpleNoticeAll("éç¥å
Œ", |
| | | notice.getTitle(), |
| | | notice.getTenantId(), |
| | | "/collaborativeApproval/noticeManagement?type="+notice.getType()); |
| | | } |
| | | return AjaxResult.success(noticeService.updateById(noticeDTO)); |
| | |
| | | import com.ruoyi.approve.pojo.KnowledgeBase; |
| | | import com.ruoyi.collaborativeApproval.pojo.SealApplicationManagement; |
| | | import com.ruoyi.collaborativeApproval.service.SealApplicationManagementService; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | |
| | | "ç³è¯·ç¼å·ï¼"+sealApplicationManagement.getApplicationNum()+"\n" |
| | | +"ç³è¯·æ é¢ï¼"+sealApplicationManagement.getTitle(), |
| | | Arrays.asList(sealApplicationManagement.getApproveUserId()), |
| | | sealApplicationManagement.getTenantId(), |
| | | "/collaborativeApproval/sealManagement?applicationNum="+sealApplicationManagement.getApplicationNum()); |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | "ä¼è®®æ¶é´ï¼" + application.getStartTime() + "-" + application.getEndTime() + "\n" + |
| | | "å起人ï¼" + application.getApplicant(), |
| | | userIds, |
| | | application.getTenantId(), |
| | | "" |
| | | ); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonCreator; |
| | | import com.fasterxml.jackson.annotation.JsonValue; |
| | | |
| | | public interface BaseEnum<T> { |
| | | @JsonValue |
| | | T getCode(); |
| | | |
| | | String getValue(); |
| | | |
| | | /** |
| | | * éç¨éæå·¥å
·æ¹æ³ï¼å¯è¢«æææä¸¾è°ç¨ï¼ |
| | | */ |
| | | /** |
| | | * éç¨éæå·¥å
·æ¹æ³ï¼æ¯æä» Integer æ String ç±»åç Code è¿è¡ååºåå |
| | | */ |
| | | @JsonCreator(mode = JsonCreator.Mode.DELEGATING) |
| | | static <E extends Enum<E> & BaseEnum<?>> E fromCode(Class<E> enumClass, Object code) { |
| | | if (code == null) { |
| | | return null; |
| | | } |
| | | |
| | | // ç®æ Code çæ´æ°å¼ |
| | | Integer targetCode = null; |
| | | |
| | | if (code instanceof Integer) { |
| | | // 1. å¦æä¼ å
¥çæ¯æ°å (Integer) |
| | | targetCode = (Integer) code; |
| | | } else if (code instanceof String) { |
| | | // 2. å¦æä¼ å
¥çæ¯å符串 ("1") |
| | | try { |
| | | // å°è¯å°å符串转æ¢ä¸ºæ´æ° |
| | | targetCode = Integer.valueOf((String) code); |
| | | } catch (NumberFormatException e) { |
| | | // 妿åç¬¦ä¸²ä¸æ¯ææçæ°åï¼ä¾å¦ "Unknown"ï¼ï¼å targetCode ä¿æä¸º null |
| | | // æ¨ä¹å¯ä»¥å¨è¿éè®°å½æ¥å¿ææ§è¡å
¶ä»é误å¤ç |
| | | // System.err.println("æ æ³å°å符串 Code 转æ¢ä¸ºæ°å: " + code); |
| | | return null; // æè
卿¾ä¸å°å¹é
çæ
åµä¸è¿å null |
| | | } |
| | | } |
| | | // else if (code instanceof Long) { ... æ¨ä¹å¯ä»¥æ·»å 对 Long ç±»åçæ¯æ } |
| | | |
| | | if (targetCode == null) { |
| | | return null; |
| | | } |
| | | |
| | | // 使ç¨è·åå°çæ´æ°å¼è¿è¡æ¥æ¾ |
| | | for (E e : enumClass.getEnumConstants()) { |
| | | if (e.getCode().equals(targetCode)) { |
| | | return e; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import com.ruoyi.approve.pojo.ApproveProcess; |
| | | |
| | | public enum FileNameType { |
| | | |
| | |
| | | MEASURING(5), //计éå¨å
·å°è´¦ |
| | | MEASURINGRecord(6),//计éå¨å
·å°è´¦è®°å½ |
| | | ApproveNode(7), //åå审æ¹èç¹å®¡æ ¸ |
| | | ApproveProcess(8); //åå审æ¹ä¸»æ°æ® |
| | | ApproveProcess(8),//åå审æ¹ä¸»æ°æ® |
| | | SHIP(9),//åè´§å°è´¦ |
| | | INSPECTION_PRODUCTION_BEFORE(10), |
| | | INSPECTION_PRODUCTION_AFTER(11), |
| | | INSPECTION(12);//å·¡æ£ ç产å |
| | | |
| | | private final int value; |
| | | |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | |
| | | public enum SalesLedgerType { |
| | | public enum SalesLedgerType implements BaseEnum<Integer>{ |
| | | SALES_LEDGER_TYPE_SALES_LEDGER(1, "éå®å°è´¦"), |
| | | SALES_LEDGER_TYPE_PURCHASE_LEDGER(2, "éè´å°è´¦"); |
| | | |
| | |
| | | this.label = label; |
| | | } |
| | | |
| | | public Integer getValue() { |
| | | public Integer getCode() { |
| | | return value; |
| | | } |
| | | |
| | | public String getLabel() { |
| | | public String getValue() { |
| | | return label; |
| | | } |
| | | |
| | |
| | | * |
| | | */ |
| | | @AllArgsConstructor |
| | | public enum StaffLeaveReason { |
| | | public enum StaffLeaveReason implements BaseEnum<String> { |
| | | StaffLeaveReasonSalary("salary","èªèµå¾
é"), |
| | | StaffLeaveReasonCareerDevelopment("career_development","èä¸åå±"), |
| | | StaffLeaveReasonWorkEnvironment("work_environment","å·¥ä½ç¯å¢"), |
| | |
| | | return code; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return info; |
| | | } |
| | | |
| | | public String getInfo() { |
| | | return info; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | |
| | | @Getter |
| | | public enum StockQualifiedRecordTypeEnum implements BaseEnum<String> { |
| | | CUSTOMIZATION_STOCK_IN("0", "åæ ¼èªå®ä¹å
¥åº"), |
| | | CUSTOMIZATION_STOCK_OUT("1", "åæ ¼èªå®ä¹åºåº"), |
| | | PRODUCTION_REPORT_STOCK_IN("2", "ç产æ¥å·¥-å
¥åº"), |
| | | PRODUCTION_REPORT_STOCK_OUT("3", "ç产æ¥å·¥-åºåº"), |
| | | DEFECTIVE_PASS("6", "ä¸åæ ¼å¤ç-è®©æ¥æ¾è¡"), |
| | | PURCHASE_STOCK_IN("7", "éè´-å
¥åº"), |
| | | SALE_STOCK_OUT("8", "éå®-åºåº"), |
| | | QUALITYINSPECT_STOCK_IN("11", "è´¨æ£-åæ ¼å
¥åº"); |
| | | |
| | | private final String code; |
| | | private final String value; |
| | | |
| | | StockQualifiedRecordTypeEnum(String code, String value) { |
| | | this.code = code; |
| | | this.value = value; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | |
| | | @Getter |
| | | public enum StockUnQualifiedRecordTypeEnum implements BaseEnum<String> { |
| | | |
| | | |
| | | PRODUCTION_SCRAP("4", "ç产æ¥å·¥-æ¥åº"), |
| | | DEFECTIVE_SCRAP("5", "ä¸åæ ¼å¤ç-æ¥åº"), |
| | | CUSTOMIZATION_UNSTOCK_IN("9", "ä¸åæ ¼èªå®ä¹å
¥åº"), |
| | | CUSTOMIZATION_UNSTOCK_OUT("10", "ä¸åæ ¼èªå®ä¹åºåº"), |
| | | QUALITYINSPECT_UNSTOCK_IN("12", "è´¨æ£-ä¸åæ ¼å
¥åº"); |
| | | |
| | | |
| | | private final String code; |
| | | private final String value; |
| | | |
| | | StockUnQualifiedRecordTypeEnum(String code, String value) { |
| | | this.code = code; |
| | | this.value = value; |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | */ |
| | | @AllArgsConstructor |
| | | public enum StorageAttachmentRecordType { |
| | | public enum StorageAttachmentRecordType implements BaseEnum<String> { |
| | | // ä¾å å®é
å¼å请å é¤ |
| | | Template("Template","èä¾"), |
| | | Archives("Archives","ææ¡£ç®¡ç"), |
| | |
| | | return code; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return info; |
| | | } |
| | | |
| | | public String getInfo() { |
| | | return info; |
| | | } |
| | |
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | | public enum UserStatus
|
| | | public enum UserStatus implements BaseEnum<String>
|
| | | {
|
| | | OK("0", "æ£å¸¸"), DISABLE("1", "åç¨"), DELETED("2", "å é¤");
|
| | |
|
| | |
| | | return code;
|
| | | }
|
| | |
|
| | | public String getValue() {
|
| | | return info;
|
| | | }
|
| | |
|
| | | public String getInfo()
|
| | | {
|
| | | return info;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | return new Date();
|
| | | }
|
| | |
|
| | | public static LocalDate toLocalDate(Date date){
|
| | | if(date == null) return LocalDate.now();
|
| | | // 2. æå®åºå®æ¶åºè½¬æ¢ï¼å¦ä¸å
«åºUTC+8ãUTCé¶æ¶åºï¼
|
| | | return date.toInstant()
|
| | | .atZone(ZoneId.of("Asia/Shanghai")) // ä¸å
«åºï¼å京/䏿µ·æ¶åºï¼
|
| | | // .atZone(ZoneId.of("UTC")) // å¯éï¼UTCé¶æ¶åº
|
| | | .toLocalDate();
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åå½åæ¥æ, é»è®¤æ ¼å¼ä¸ºyyyy-MM-dd
|
| | | *
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | |
| | | import com.ruoyi.common.enums.BaseEnum; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * éç¨æä¸¾å·¥å
·ç±» |
| | | * éç¨äºææå®ç° BaseEnum æ¥å£çæä¸¾ |
| | | * |
| | | * @author Bu |
| | | */ |
| | | public class EnumUtil { |
| | | |
| | | /** |
| | | * æ ¹æ® code è·åæä¸¾å®ä¾ |
| | | */ |
| | | public static <E extends Enum<E> & BaseEnum> E fromCode(Class<E> enumClass, int code) { |
| | | for (E e : enumClass.getEnumConstants()) { |
| | | if (Integer.parseInt(String.valueOf(e.getCode())) == code) { |
| | | return e; |
| | | } |
| | | } |
| | | throw new IllegalArgumentException("æªç¥ç code: " + code + " å¯¹äºæä¸¾ " + enumClass.getSimpleName()); |
| | | } |
| | | |
| | | public static <E extends Enum<E> & BaseEnum> E fromCodeHasNull(Class<E> enumClass, int code) { |
| | | for (E e : enumClass.getEnumConstants()) { |
| | | if (Integer.parseInt(String.valueOf(e.getCode())) == code) { |
| | | return e; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static <E extends Enum<E> & BaseEnum> E fromCodeHasDefault(Class<E> enumClass, int code,E defaultE) { |
| | | for (E e : enumClass.getEnumConstants()) { |
| | | if (Integer.parseInt(String.valueOf(e.getCode())) == code) { |
| | | return e; |
| | | } |
| | | } |
| | | return defaultE; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ® value è·åæä¸¾å®ä¾ |
| | | */ |
| | | public static <E extends Enum<E> & BaseEnum> E fromValue(Class<E> enumClass, String value) { |
| | | for (E e : enumClass.getEnumConstants()) { |
| | | if (Objects.equals(e.getValue(), value)) { |
| | | return e; |
| | | } |
| | | } |
| | | throw new IllegalArgumentException("æªç¥ç value: " + value + " å¯¹äºæä¸¾ " + enumClass.getSimpleName()); |
| | | } |
| | | |
| | | /** |
| | | * è·åæææä¸¾é¡¹å表 |
| | | */ |
| | | public static <E extends Enum<E> & BaseEnum> List<E> listAll(Class<E> enumClass) { |
| | | return Arrays.asList(enumClass.getEnumConstants()); |
| | | } |
| | | |
| | | /** |
| | | * 转为 List<Map>ï¼éåè¿åç»åç«¯ï¼ |
| | | * æ ¼å¼: [{ "code": 1, "value": "ç»çº¿" }, ...] |
| | | */ |
| | | public static <E extends Enum<E> & BaseEnum> List<Map<String, Object>> toList(Class<E> enumClass) { |
| | | return Arrays.stream(enumClass.getEnumConstants()) |
| | | .map(e -> { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("key", e.getCode().toString()); |
| | | map.put("value", e.getValue()); |
| | | return map; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | // /** |
| | | // * 转为 Map<Integer, String> |
| | | // * æ ¼å¼: { 1: "ç»çº¿", 0: "æä¸" } |
| | | // */ |
| | | // public static <E extends Enum<E> & BaseEnum> Map<Integer, String> toMap(Class<E> enumClass) { |
| | | // return Arrays.stream(enumClass.getEnumConstants()) |
| | | // .collect(Collectors.toMap((BaseEnum::getCode, BaseEnum::getValue)); |
| | | // } |
| | | // |
| | | // |
| | | // public static void main(String[] args) { |
| | | // // â
1. æ ¹æ® code è·åæä¸¾ |
| | | // StockRecordTypeEnum status = EnumUtil.fromCode(StockRecordTypeEnum.class, 1); |
| | | // System.out.println(status.getValue()); // ç»çº¿ |
| | | // |
| | | // // â
2. 转æ list (éåå端) |
| | | // System.out.println(EnumUtil.toList(StockRecordTypeEnum.class)); |
| | | // // è¾åº: [{code=1, value=ç»çº¿}, {code=0, value=æä¸}] |
| | | // |
| | | // // â
3. 转æ map |
| | | // System.out.println(EnumUtil.toMap(StockRecordTypeEnum.class)); |
| | | // // è¾åº: {1=ç»çº¿, 0=æä¸} |
| | | // } |
| | | } |
| | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("é¨é¨id") |
| | | private Long deptId; |
| | | |
| | | @ApiModelProperty("å®è£
ä½ç½®") |
| | | private String instationLocation; |
| | | |
| | | private String cycle; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.procurementrecord.utils; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | | import com.ruoyi.stock.service.StockInventoryService; |
| | | import com.ruoyi.stock.service.StockUninventoryService; |
| | | import com.ruoyi.stock.service.impl.StockInRecordServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | |
| | | public class StockUtils { |
| | | private final ProcurementRecordOutMapper procurementRecordOutMapper; |
| | | private final ProcurementRecordMapper procurementRecordMapper; |
| | | private final StockUninventoryService stockUninventoryService; |
| | | private final StockInventoryService stockInventoryService; |
| | | private final StockInRecordService stockInRecordService; |
| | | |
| | | // è·åååå
¥åºæ°é,åºåºæ°é,å©ä½åºå |
| | | public Map<String, BigDecimal> getStockQuantity(Long productModelId) { |
| | |
| | | stockMap.put("stockQuantity", stockQuantity); |
| | | return stockMap; |
| | | } |
| | | |
| | | /** |
| | | * ä¸åæ ¼å
¥åº |
| | | * @param productModelId |
| | | * @param quantity |
| | | * @param recordType |
| | | * @param recordId |
| | | */ |
| | | public void addUnStock(Long productModelId, BigDecimal quantity, String recordType,Long recordId) { |
| | | StockUninventoryDto stockUninventoryDto = new StockUninventoryDto(); |
| | | stockUninventoryDto.setRecordId(recordId); |
| | | stockUninventoryDto.setRecordType(String.valueOf(recordType)); |
| | | stockUninventoryDto.setQualitity(quantity); |
| | | stockUninventoryDto.setProductModelId(productModelId); |
| | | stockUninventoryService.addStockUninventory(stockUninventoryDto); |
| | | } |
| | | |
| | | /** |
| | | * ä¸åæ ¼åºåº |
| | | * @param productModelId |
| | | * @param quantity |
| | | * @param recordType |
| | | * @param recordId |
| | | */ |
| | | public void subtractUnStock(Long productModelId, BigDecimal quantity, Integer recordType,Long recordId) { |
| | | StockUninventoryDto stockUninventoryDto = new StockUninventoryDto(); |
| | | stockUninventoryDto.setRecordId(recordId); |
| | | stockUninventoryDto.setRecordType(String.valueOf(recordType)); |
| | | stockUninventoryDto.setQualitity(quantity); |
| | | stockUninventoryDto.setProductModelId(productModelId); |
| | | stockUninventoryService.subtractStockUninventory(stockUninventoryDto); |
| | | } |
| | | |
| | | /** |
| | | * åæ ¼å
¥åº |
| | | * @param productModelId |
| | | * @param quantity |
| | | * @param recordType |
| | | * @param recordId |
| | | */ |
| | | public void addStock(Long productModelId, BigDecimal quantity, String recordType,Long recordId) { |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setRecordId(recordId); |
| | | stockInventoryDto.setRecordType(String.valueOf(recordType)); |
| | | stockInventoryDto.setQualitity(quantity); |
| | | stockInventoryDto.setProductModelId(productModelId); |
| | | stockInventoryService.addstockInventory(stockInventoryDto); |
| | | } |
| | | |
| | | /** |
| | | * åæ ¼åºåº |
| | | * @param productModelId |
| | | * @param quantity |
| | | * @param recordType |
| | | * @param recordId |
| | | */ |
| | | public void substractStock(Long productModelId, BigDecimal quantity, String recordType,Long recordId) { |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setRecordId(recordId); |
| | | stockInventoryDto.setRecordType(String.valueOf(recordType)); |
| | | stockInventoryDto.setQualitity(quantity); |
| | | stockInventoryDto.setProductModelId(productModelId); |
| | | stockInventoryService.subtractStockInventory(stockInventoryDto); |
| | | } |
| | | |
| | | //ä¸åæ ¼åºåå é¤ |
| | | public void deleteStockRecord(Long recordId, String recordType) { |
| | | StockInRecord one = stockInRecordService.getOne(new QueryWrapper<StockInRecord>() |
| | | .lambda().eq(StockInRecord::getRecordId, recordId) |
| | | .eq(StockInRecord::getRecordType, recordType)); |
| | | |
| | | stockInRecordService.batchDelete(Collections.singletonList(one.getId())); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.production.dto.ProductBomDto; |
| | | import com.ruoyi.production.dto.ProductProcessDto; |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | import com.ruoyi.production.pojo.ProductBom; |
| | | import com.ruoyi.production.pojo.ProductProcess; |
| | | import com.ruoyi.production.pojo.ProductProcessRoute; |
| | | import com.ruoyi.production.service.ProcessRouteService; |
| | | import com.ruoyi.production.service.ProductBomService; |
| | | import com.ruoyi.production.service.ProductProcessRouteService; |
| | | import com.ruoyi.production.service.ProductProcessService; |
| | | import com.ruoyi.production.pojo.*; |
| | | import com.ruoyi.production.service.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @Autowired |
| | | private ProductProcessRouteService productProcessRouteService; |
| | | |
| | | @Autowired |
| | | private ProductStructureService productStructureService; |
| | | |
| | | @GetMapping("/listPage") |
| | | @Log(title = "BOM-å页æ¥è¯¢", businessType = BusinessType.OTHER) |
| | |
| | | if(CollectionUtils.isEmpty(ids)){ |
| | | return AjaxResult.error("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | } |
| | | //å é¤bomå表 |
| | | productStructureService.remove(Wrappers.<ProductStructure>lambdaQuery().in(ProductStructure::getBomId,ids)); |
| | | return AjaxResult.success(productBomService.removeBatchByIds(ids)); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.production.pojo.ProductStructure; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class ProductStructureDto extends ProductStructure { |
| | | |
| | | @ApiModelProperty(value = "å·¥èºåç§°") |
| | | private String processName; |
| | | |
| | | @ApiModelProperty(value = "产ååç§°") |
| | | private String productName; |
| | | |
| | | @ApiModelProperty(value = "产åid") |
| | | private Long productId; |
| | | |
| | | private String model; |
| | | |
| | | private List<ProductStructure> productStructureList; |
| | | @TableField(exist = false) |
| | | private String tempId; |
| | | |
| | | @TableField(exist = false) |
| | | private String parentTempId; |
| | | |
| | | @TableField(exist = false) |
| | | private List<ProductStructureDto> children; |
| | | } |
| | |
| | | */ |
| | | private Long bomId; |
| | | |
| | | |
| | | /** |
| | | * ç¶èç¹ID |
| | | */ |
| | | private Long parentId; |
| | | } |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.service.IProductModelService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.production.dto.ProductBomDto; |
| | | import com.ruoyi.production.dto.ProductProcessDto; |
| | | import com.ruoyi.production.pojo.ProductBom; |
| | | import com.ruoyi.production.mapper.ProductBomMapper; |
| | | import com.ruoyi.production.pojo.ProductProcess; |
| | | import com.ruoyi.production.mapper.ProductStructureMapper; |
| | | import com.ruoyi.production.pojo.ProductBom; |
| | | import com.ruoyi.production.pojo.ProductStructure; |
| | | import com.ruoyi.production.service.ProductBomService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Autowired |
| | | private ProductBomMapper productBomMapper; |
| | | |
| | | @Autowired |
| | | private IProductModelService productModelService; |
| | | |
| | | @Autowired |
| | | private ProductStructureMapper productStructureMapper; |
| | | |
| | | @Override |
| | | public IPage<ProductBomDto> listPage(Page page, ProductBomDto productBomDto) { |
| | | return productBomMapper.listPage(page,productBomDto); |
| | | return productBomMapper.listPage(page, productBomDto); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult add(ProductBom productBom) { |
| | | boolean save = productBomMapper.insert(productBom) > 0; |
| | | if (save) { |
| | |
| | | String no = "BM." + String.format("%05d", productBom.getId()); |
| | | productBom.setBomNo(no); |
| | | productBomMapper.updateById(productBom); |
| | | |
| | | // æ¥è¯¢åºäº§å模åä¿¡æ¯ |
| | | if (productBom.getProductModelId() == null) { |
| | | throw new ServiceException("è¯·éæ©äº§åæ¨¡å"); |
| | | } |
| | | |
| | | ProductModel productModel = productModelService.getById(productBom.getProductModelId()); |
| | | if (productModel == null) { |
| | | throw new ServiceException("éæ©çäº§åæ¨¡åä¸åå¨"); |
| | | } |
| | | |
| | | // æ·»å åå§ç产åç»æ |
| | | ProductStructure productStructure = new ProductStructure(); |
| | | productStructure.setProductModelId(productBom.getProductModelId()); |
| | | productStructure.setUnit(productModel.getUnit()); |
| | | productStructure.setUnitQuantity(BigDecimal.valueOf(1)); |
| | | productStructure.setBomId(Long.valueOf(productBom.getId())); |
| | | |
| | | productStructureMapper.insert(productStructure); |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error(); |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.ProductModelDto; |
| | | import com.ruoyi.basic.dto.ProductTreeDto; |
| | | import com.ruoyi.basic.mapper.ProductMapper; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.pojo.Product; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.ProductBomMapper; |
| | | import com.ruoyi.production.mapper.ProductStructureMapper; |
| | | import com.ruoyi.production.pojo.ProductStructure; |
| | | import com.ruoyi.production.service.ProductStructureService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | @Slf4j |
| | | @Service |
| | | public class ProductStructureServiceImpl extends ServiceImpl<ProductStructureMapper, ProductStructure> implements ProductStructureService { |
| | | |
| | | @Autowired |
| | | private ProductStructureMapper productStructureMapper; |
| | | |
| | | private ProductStructureMapper productStructureMapper; |
| | | |
| | | |
| | | @Override |
| | | public Boolean addProductStructureDto(ProductStructureDto productStructureDto) { |
| | | this.remove(new QueryWrapper<ProductStructure>().lambda().eq(ProductStructure::getBomId, productStructureDto.getBomId())); |
| | | productStructureDto.getProductStructureList().forEach(productStructure -> { |
| | | productStructure.setBomId(productStructureDto.getBomId()); |
| | | }); |
| | | return this.saveBatch(productStructureDto.getProductStructureList()); |
| | | @Transactional |
| | | public Boolean addProductStructureDto(ProductStructureDto dto) { |
| | | |
| | | Long bomId = dto.getBomId(); |
| | | |
| | | // å°æ æå¹³å |
| | | List<ProductStructureDto> flatDtoList = new ArrayList<>(); |
| | | flattenTree(dto.getChildren(), flatDtoList); |
| | | |
| | | // æ¥è¯¢æ°æ®åºä¸å·²æç BOM æ°æ® |
| | | List<ProductStructure> dbList = this.list(new LambdaQueryWrapper<ProductStructure>().eq(ProductStructure::getBomId, bomId)); |
| | | |
| | | // æ¥æ¾å·²åå¨çèç¹ - ID |
| | | Set<Long> frontendIds = flatDtoList.stream() |
| | | .map(ProductStructureDto::getId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | // éè¦å é¤çèç¹ - ID |
| | | Set<Long> deleteIds = dbList.stream() |
| | | .map(ProductStructure::getId) |
| | | .filter(id -> !frontendIds.contains(id)) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | if (!deleteIds.isEmpty()) { |
| | | this.removeByIds(deleteIds); |
| | | } |
| | | |
| | | // æ°å¢ / æ´æ° |
| | | List<ProductStructure> insertList = new ArrayList<>(); |
| | | List<ProductStructure> updateList = new ArrayList<>(); |
| | | |
| | | // ç¨äºåå parentId |
| | | Map<String, ProductStructure> tempEntityMap = new HashMap<>(); |
| | | |
| | | for (ProductStructureDto psDto : flatDtoList) { |
| | | ProductStructure entity = new ProductStructure(); |
| | | BeanUtils.copyProperties(psDto, entity); |
| | | entity.setBomId(bomId); |
| | | |
| | | if (psDto.getId() == null) { |
| | | // æ°å¢ |
| | | entity.setId(null); |
| | | entity.setParentId(null); |
| | | insertList.add(entity); |
| | | tempEntityMap.put(psDto.getTempId(), entity); |
| | | } else { |
| | | // æ´æ° |
| | | updateList.add(entity); |
| | | } |
| | | } |
| | | |
| | | // æå
¥æ°èç¹ |
| | | if (!insertList.isEmpty()) { |
| | | this.saveBatch(insertList); |
| | | } |
| | | |
| | | // ååæ°å¢èç¹ parentId |
| | | List<ProductStructure> parentFixList = new ArrayList<>(); |
| | | // çå®çç¶èç¹ ID |
| | | Long realParentId; |
| | | for (ProductStructureDto psDto : flatDtoList) { |
| | | if (psDto.getId() == null && psDto.getParentTempId() != null) { |
| | | ProductStructure child = tempEntityMap.get(psDto.getTempId()); |
| | | if (tempEntityMap.containsKey(psDto.getParentTempId())) { |
| | | // ç¶èç¹æ¯æ°èç¹ |
| | | realParentId = tempEntityMap.get(psDto.getParentTempId()).getId(); |
| | | } else { |
| | | // ç¶èç¹æ¯èèç¹ |
| | | realParentId = Long.valueOf(psDto.getParentTempId()); |
| | | } |
| | | |
| | | child.setParentId(realParentId); |
| | | parentFixList.add(child); |
| | | } |
| | | } |
| | | |
| | | if (!parentFixList.isEmpty()) { |
| | | this.updateBatchById(parentFixList); |
| | | } |
| | | |
| | | if (!updateList.isEmpty()) { |
| | | this.updateBatchById(updateList); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * å°åç«¯ä¼ å
¥çæ è¿è¡æå¹³å |
| | | * |
| | | * @param source æ°æ®æ |
| | | * @param result æå¹³åæ°æ® |
| | | */ |
| | | private void flattenTree(List<ProductStructureDto> source, List<ProductStructureDto> result) { |
| | | if (source == null) { |
| | | return; |
| | | } |
| | | for (ProductStructureDto node : source) { |
| | | result.add(node); |
| | | flattenTree(node.getChildren(), result); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<ProductStructureDto> listBybomId(Long bomId) { |
| | | List<ProductStructureDto> tree = productStructureMapper.listBybomId(bomId); |
| | | return tree; |
| | | List<ProductStructureDto> list = productStructureMapper.listBybomId(bomId); |
| | | |
| | | Map<Long, ProductStructureDto> map = new HashMap<>(); |
| | | for (ProductStructureDto node : list) { |
| | | node.setChildren(new ArrayList<>()); |
| | | map.put(node.getId(), node); |
| | | } |
| | | |
| | | List<ProductStructureDto> tree = new ArrayList<>(); |
| | | for (ProductStructureDto node : list) { |
| | | Long parentId = node.getParentId(); |
| | | if (parentId == null || parentId == 0) { |
| | | tree.add(node); |
| | | } else { |
| | | ProductStructureDto parent = map.get(parentId); |
| | | if (parent != null) { |
| | | parent.getChildren().add(node); |
| | | } |
| | | } |
| | | } |
| | | return tree; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.pojo.Product; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut; |
| | |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.quality.mapper.*; |
| | | import com.ruoyi.quality.pojo.*; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import oshi.driver.mac.net.NetStat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | salesLedgerProductionAccountingMapper.insert(salesLedgerProductionAccounting); |
| | | } |
| | | //妿æ¥åºæ°é>0,éè¦è¿å
¥æ¥åºçåºå |
| | | if (dto.getScrapQty().compareTo(BigDecimal.ZERO) > 0) { |
| | | stockUtils.addUnStock(productModel.getId(), dto.getScrapQty(), StockUnQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode(), productionProductMain.getId()); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | |
| | | .eq(ProcurementRecordOut::getSalesLedgerProductId, productionProductMain.getId())); |
| | | productionProductInputMapper.delete(new LambdaQueryWrapper<ProductionProductInput>() |
| | | .eq(ProductionProductInput::getProductMainId, productionProductMain.getId())); |
| | | //å 餿¥åºçå
¥åºè®°å½ |
| | | stockUtils.deleteStockRecord(productionProductMain.getId(), StockUnQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode()); |
| | | // å é¤ä¸»è¡¨ |
| | | productionProductMainMapper.deleteById(productionProductMain.getId()); |
| | | return true; |
| | |
| | | * éè¿æå®äººåéæé
|
| | | * @param title æ é¢
|
| | | * @param message æ¶æ¯
|
| | | * @param tenantId ç§æ·id
|
| | | * @param jumpPath 跳转å°å
|
| | | */
|
| | | void simpleNoticeByUser(final String title, final String message, final List<Long> consigneeId, final Long tenantId, final String jumpPath);
|
| | | void simpleNoticeByUser(final String title, final String message, final List<Long> consigneeId, final String jumpPath);
|
| | |
|
| | | /**
|
| | | * éè¿ææäºº åéæé
|
| | |
| | | * @param message æ¶æ¯
|
| | | * @param jumpPath 跳转å°å
|
| | | */
|
| | | void simpleNoticeAll(final String title, final String message,final Long tenantId,final String jumpPath);
|
| | | void simpleNoticeAll(final String title, final String message,final String jumpPath);
|
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void simpleNoticeByUser(String title, String message, List<Long> consigneeId, Long tenantId,
|
| | | String jumpPath) {
|
| | | public void simpleNoticeByUser(String title, String message, List<Long> consigneeId, String jumpPath) {
|
| | | Long userId = SecurityUtils.getLoginUser().getUserId();
|
| | | Long tenantId = SecurityUtils.getLoginUser().getTenantId();
|
| | | List<SysNotice> sysNotices = consigneeId.stream().map(it -> convertSysNotice(title, message, it,tenantId, jumpPath, userId)).collect(Collectors.toList());
|
| | | sysNoticeService.saveBatch(sysNotices);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void simpleNoticeAll(String title, String message, Long rootDeptId, String jumpPath) {
|
| | | public void simpleNoticeAll(String title, String message, String jumpPath) {
|
| | | Long userId = SecurityUtils.getLoginUser().getUserId();
|
| | | if (userId == null) {
|
| | | return;
|
| | | }
|
| | |
|
| | | Long rootDeptId = SecurityUtils.getLoginUser().getTenantId();
|
| | | // æ¥ææåé¨é¨
|
| | | List<SysDept> childrenDepts = deptMapper.selectChildrenDeptById(rootDeptId);
|
| | |
|
| | |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.pojo.InvoiceRegistrationProduct; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.service.ISalesLedgerProductService; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | BeanUtils.copyProperties(purchaseLedger, purchaseLedgerDto); |
| | | SalesLedgerProduct salesLedgerProduct = new SalesLedgerProduct(); |
| | | salesLedgerProduct.setSalesLedgerId(id); |
| | | salesLedgerProduct.setType(SalesLedgerType.SALES_LEDGER_TYPE_SALES_LEDGER.getValue()); |
| | | salesLedgerProduct.setType(SalesLedgerType.SALES_LEDGER_TYPE_SALES_LEDGER.getCode()); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct); |
| | | purchaseLedgerDto.setProductData(salesLedgerProducts); |
| | | List<CommonFile> commonFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>() |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.procurementrecord.dto.Details; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementAddDto; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordService; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.quality.dto.QualityInspectDto; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.mapper.QualityTestStandardMapper; |
| | |
| | | import com.ruoyi.quality.service.IQualityInspectParamService; |
| | | import com.ruoyi.quality.service.IQualityInspectService; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | @AllArgsConstructor |
| | | @Service |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class QualityInspectServiceImpl extends ServiceImpl<QualityInspectMapper, QualityInspect> implements IQualityInspectService { |
| | | public class QualityInspectServiceImpl extends ServiceImpl<QualityInspectMapper, QualityInspect> implements IQualityInspectService { |
| | | |
| | | private final StockUtils stockUtils; |
| | | private QualityInspectMapper qualityInspectMapper; |
| | | |
| | | private IQualityInspectParamService qualityInspectParamService; |
| | |
| | | @Override |
| | | public int add(QualityInspectDto qualityInspectDto) { |
| | | QualityInspect qualityInspect = new QualityInspect(); |
| | | BeanUtils.copyProperties(qualityInspectDto,qualityInspect); |
| | | BeanUtils.copyProperties(qualityInspectDto, qualityInspect); |
| | | qualityInspect.setInspectState(0);//é»è®¤æªæäº¤ |
| | | qualityInspectMapper.insert(qualityInspect); |
| | | for (QualityInspectParam qualityInspectParam : qualityInspectDto.getQualityInspectParams()) { |
| | |
| | | QualityInspect qualityInspect = qualityInspectMapper.selectById(id); |
| | | List<QualityInspectParam> qualityInspectParams = qualityInspectParamService.list(Wrappers.<QualityInspectParam>lambdaQuery().eq(QualityInspectParam::getInspectId, id)); |
| | | QualityInspectDto qualityInspectDto = new QualityInspectDto(); |
| | | BeanUtils.copyProperties(qualityInspect,qualityInspectDto); |
| | | BeanUtils.copyProperties(qualityInspect, qualityInspectDto); |
| | | qualityInspectDto.setQualityInspectParams(qualityInspectParams); |
| | | return qualityInspectDto; |
| | | } |
| | |
| | | public int submit(QualityInspect inspect) { |
| | | QualityInspect qualityInspect = qualityInspectMapper.selectById(inspect.getId()); |
| | | /*夿ä¸åæ ¼*/ |
| | | if (ObjectUtils.isNotNull(qualityInspect.getCheckResult()) && qualityInspect.getCheckResult().equals("ä¸åæ ¼")){ |
| | | if (ObjectUtils.isNotNull(qualityInspect.getCheckResult()) && qualityInspect.getCheckResult().equals("ä¸åæ ¼")) { |
| | | QualityUnqualified qualityUnqualified = new QualityUnqualified(); |
| | | BeanUtils.copyProperties(qualityInspect,qualityUnqualified); |
| | | BeanUtils.copyProperties(qualityInspect, qualityUnqualified); |
| | | qualityUnqualified.setInspectState(0);//å¾
å¤ç |
| | | List<QualityInspectParam> inspectParams = qualityInspectParamService.list(Wrappers.<QualityInspectParam>lambdaQuery().eq(QualityInspectParam::getInspectId, inspect.getId())); |
| | | String text = inspectParams.stream().map(QualityInspectParam::getParameterItem).collect(Collectors.joining(",")); |
| | | qualityUnqualified.setDefectivePhenomena(text+"è¿äºææ ä¸åå¨ä¸åæ ¼");//ä¸åæ ¼ç°è±¡ |
| | | qualityUnqualified.setDefectivePhenomena(text + "è¿äºææ ä¸åå¨ä¸åæ ¼");//ä¸åæ ¼ç°è±¡ |
| | | qualityUnqualified.setInspectId(qualityInspect.getId()); |
| | | qualityUnqualifiedMapper.insert(qualityUnqualified); |
| | | } |
| | | |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | if (qualityInspect.getInspectType() == 0) { |
| | | if ("åæ ¼".equals(qualityInspect.getCheckResult())) { |
| | | ProcurementAddDto procurementRecordOutAdd = new ProcurementAddDto(); |
| | | procurementRecordOutAdd.setType(1); |
| | | procurementRecordOutAdd.setTypeName("éè´åæææ£éªåæ ¼å
¥åº"); |
| | | procurementRecordOutAdd.setNickName(loginUser.getNickName()); |
| | | procurementRecordOutAdd.setPurchaseLedgerId(Math.toIntExact(qualityInspect.getPurchaseLedgerId())); |
| | | if (qualityInspect.getPurchaseLedgerId() == null) { |
| | | throw new BaseException("è¯·éæ©éè´å"); |
| | | } |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(qualityInspect.getProductId()); |
| | | |
| | | ArrayList<Details> detailss = new ArrayList<>(); |
| | | Details details = new Details(); |
| | | details.setId(Math.toIntExact(salesLedgerProduct.getId())); |
| | | details.setInboundQuantity(qualityInspect.getQuantity()); |
| | | details.setWarnNum(salesLedgerProduct.getWarnNum()); |
| | | details.setUnitPrice(salesLedgerProduct.getTaxInclusiveUnitPrice()); |
| | | details.setTotalPrice(salesLedgerProduct.getTaxInclusiveTotalPrice()); |
| | | details.setProductModelId(qualityInspect.getProductModelId()); |
| | | detailss.add( details); |
| | | procurementRecordOutAdd.setDetails(detailss); |
| | | procurementRecordOutAdd.setQualityInspectId(qualityInspect.getId()); |
| | | procurementRecordService.add(procurementRecordOutAdd); |
| | | } |
| | | }else if (qualityInspect.getInspectType() == 1) { |
| | | //æ¥è¯¢UnitPrice/TotalPrice |
| | | ProcurementAddDto procurementRecordOutAdd = new ProcurementAddDto(); |
| | | procurementRecordOutAdd.setType(2); |
| | | procurementRecordOutAdd.setTypeName("ç产è¿ç¨æ£éªåæ ¼å
¥åº"); |
| | | procurementRecordOutAdd.setNickName(loginUser.getNickName()); |
| | | List<Details> details = new ArrayList<>(); |
| | | Details details1 = new Details(); |
| | | details1.setInboundQuantity(qualityInspect.getQuantity()); |
| | | details1.setProductModelId(qualityInspect.getProductModelId()); |
| | | procurementRecordOutAdd.setDetails(details); |
| | | |
| | | ProcurementRecordStorage.ProcurementRecordStorageBuilder procurementRecordBuilder = ProcurementRecordStorage.builder() |
| | | .salesLedgerProductId(0) |
| | | .inboundBatches( "ç产åæåå
¥åº") |
| | | .inboundNum(details1.getInboundQuantity()) |
| | | .type(2) |
| | | .warnNum(new BigDecimal(0)) |
| | | .unitPrice(new BigDecimal(0)) |
| | | .totalPrice(new BigDecimal(0)) |
| | | .createTime(LocalDateTime.now()) |
| | | .createUser(loginUser.getUserId()) |
| | | .updateTime(LocalDateTime.now()) |
| | | .updateUser(loginUser.getUserId()) |
| | | .createBy(procurementRecordOutAdd.getNickName()) |
| | | .productModelId(details1.getProductModelId()) |
| | | .qualityInspectId(qualityInspect.getId()); |
| | | procurementRecordService.save(procurementRecordBuilder.build()); |
| | | |
| | | |
| | | |
| | | }else if (qualityInspect.getInspectType() == 2) { |
| | | //æ¥è¯¢UnitPrice/TotalPrice |
| | | if (ObjectUtils.isNull(qualityInspect.getProductMainId())){ |
| | | //å¦ææ¯æå¨æ°å¢çåºåæ£ |
| | | }else { |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectSalesLedgerProductByMainId(qualityInspect.getProductMainId()); |
| | | ProcurementAddDto procurementRecordOutAdd = new ProcurementAddDto(); |
| | | procurementRecordOutAdd.setType(2); |
| | | procurementRecordOutAdd.setTypeName("ç产åºåæ£éªåæ ¼å
¥åº"); |
| | | procurementRecordOutAdd.setNickName(loginUser.getNickName()); |
| | | List<Details> details = new ArrayList<>(); |
| | | Details details1 = new Details(); |
| | | details1.setInboundQuantity(qualityInspect.getQuantity()); |
| | | details1.setId(Math.toIntExact(salesLedgerProduct.getId())); |
| | | details1.setUnitPrice(salesLedgerProduct.getTaxInclusiveUnitPrice()); |
| | | details1.setTotalPrice(salesLedgerProduct.getTaxInclusiveTotalPrice()); |
| | | details1.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | details.add(details1); |
| | | procurementRecordOutAdd.setDetails(details); |
| | | procurementRecordOutAdd.setQualityInspectId(qualityInspect.getId()); |
| | | procurementRecordService.add(procurementRecordOutAdd); |
| | | } |
| | | } else { |
| | | //åæ ¼ç´æ¥å
¥åº |
| | | stockUtils.addStock(inspect.getProductModelId(), inspect.getQuantity(), StockQualifiedRecordTypeEnum.QUALITYINSPECT_STOCK_IN.getCode(), inspect.getId()); |
| | | } |
| | | qualityInspect.setInspectState(1);//å·²æäº¤ |
| | | return qualityInspectMapper.updateById(qualityInspect); |
| | |
| | | @Override |
| | | public void down(HttpServletResponse response, QualityInspect qualityInspect) { |
| | | QualityInspect inspect = qualityInspectMapper.selectById(qualityInspect.getId()); |
| | | String inspectType=""; |
| | | switch (inspect.getInspectType()){ |
| | | String inspectType = ""; |
| | | switch (inspect.getInspectType()) { |
| | | case 0: |
| | | inspectType="åæææ£éª"; |
| | | inspectType = "åæææ£éª"; |
| | | break; |
| | | case 1: |
| | | inspectType="è¿ç¨æ£éª"; |
| | | inspectType = "è¿ç¨æ£éª"; |
| | | break; |
| | | case 2: |
| | | inspectType="åºåæ£éª"; |
| | | inspectType = "åºåæ£éª"; |
| | | break; |
| | | } |
| | | List<QualityInspectParam> paramList = qualityInspectParamService.list(Wrappers.<QualityInspectParam>lambdaQuery().eq(QualityInspectParam::getInspectId, inspect.getId())); |
| | |
| | | @Override |
| | | public int updateQualityInspect(QualityInspectDto qualityInspectDto) { |
| | | if (ObjectUtils.isNotNull(qualityInspectDto.getQualityInspectParams())) { |
| | | qualityInspectParamService.remove(Wrappers.<QualityInspectParam>lambdaQuery().eq(QualityInspectParam::getInspectId,qualityInspectDto.getId())); |
| | | qualityInspectParamService.remove(Wrappers.<QualityInspectParam>lambdaQuery().eq(QualityInspectParam::getInspectId, qualityInspectDto.getId())); |
| | | for (QualityInspectParam qualityInspectParam : qualityInspectDto.getQualityInspectParams()) { |
| | | qualityInspectParam.setInspectId(qualityInspectDto.getId()); |
| | | } |
| | | qualityInspectParamService.saveBatch(qualityInspectDto.getQualityInspectParams()); |
| | | } |
| | | QualityInspect qualityInspect = new QualityInspect(); |
| | | BeanUtils.copyProperties(qualityInspectDto,qualityInspect); |
| | | BeanUtils.copyProperties(qualityInspectDto, qualityInspect); |
| | | return qualityInspectMapper.updateById(qualityInspect); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<QualityInspect> qualityInspectListPage(Page page, QualityInspect qualityInspect) { |
| | | return qualityInspectMapper.qualityInspectListPage(page,qualityInspect); |
| | | return qualityInspectMapper.qualityInspectListPage(page, qualityInspect); |
| | | } |
| | | |
| | | @Override |
| | | public void qualityInspectExport(HttpServletResponse response, QualityInspect qualityInspect) { |
| | | List<QualityInspect> qualityInspects =qualityInspectMapper.qualityInspectExport(qualityInspect); |
| | | List<QualityInspect> qualityInspects = qualityInspectMapper.qualityInspectExport(qualityInspect); |
| | | ExcelUtil<QualityInspect> util = new ExcelUtil<QualityInspect>(QualityInspect.class); |
| | | switch (qualityInspect.getInspectType()){ |
| | | switch (qualityInspect.getInspectType()) { |
| | | case 0: |
| | | util.exportExcel(response, qualityInspects, "åæææ£éªå¯¼åº"); |
| | | break; |
| | | case 1: |
| | | case 1: |
| | | util.exportExcel(response, qualityInspects, "è¿ç¨æ£éªå¯¼åº"); |
| | | break; |
| | | case 2: |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.production.mapper.ProductProcessRouteItemMapper; |
| | | import com.ruoyi.production.mapper.ProductProcessRouteMapper; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.pojo.*; |
| | | import com.ruoyi.production.service.ProductOrderService; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.mapper.QualityUnqualifiedMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | | import com.ruoyi.quality.pojo.QualityTestStandard; |
| | | import com.ruoyi.quality.pojo.QualityUnqualified; |
| | | import com.ruoyi.quality.service.IQualityInspectService; |
| | | import com.ruoyi.quality.service.IQualityUnqualifiedService; |
| | | import com.ruoyi.stock.service.StockUninventoryService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | @AllArgsConstructor |
| | | @Service |
| | | public class QualityUnqualifiedServiceImpl extends ServiceImpl<QualityUnqualifiedMapper, QualityUnqualified> implements IQualityUnqualifiedService { |
| | | public class QualityUnqualifiedServiceImpl extends ServiceImpl<QualityUnqualifiedMapper, QualityUnqualified> implements IQualityUnqualifiedService { |
| | | |
| | | private final StockUtils stockUtils; |
| | | private QualityUnqualifiedMapper qualityUnqualifiedMapper; |
| | | private IQualityInspectService qualityInspectService; |
| | | private ProductOrderService productOrderService; |
| | |
| | | private ProductProcessRouteMapper productProcessRouteMapper; |
| | | private ProductProcessRouteItemMapper productProcessRouteItemMapper; |
| | | private ProductWorkOrderMapper productWorkOrderMapper; |
| | | |
| | | private StockUninventoryService stockUninventoryService; |
| | | |
| | | @Override |
| | | public IPage<QualityUnqualified> qualityUnqualifiedListPage(Page page, QualityUnqualified qualityUnqualified) { |
| | | return qualityUnqualifiedMapper.qualityUnqualifiedListPage(page,qualityUnqualified); |
| | | return qualityUnqualifiedMapper.qualityUnqualifiedListPage(page, qualityUnqualified); |
| | | } |
| | | |
| | | @Override |
| | | public void qualityUnqualifiedExport(HttpServletResponse response, QualityUnqualified qualityUnqualified) { |
| | | List<QualityUnqualified> qualityUnqualifieds =qualityUnqualifiedMapper.qualityUnqualifiedExport(qualityUnqualified); |
| | | List<QualityUnqualified> qualityUnqualifieds = qualityUnqualifiedMapper.qualityUnqualifiedExport(qualityUnqualified); |
| | | ExcelUtil<QualityUnqualified> util = new ExcelUtil<QualityUnqualified>(QualityUnqualified.class); |
| | | util.exportExcel(response, qualityUnqualifieds, "ä¸åæ ¼ç®¡ç导åº"); |
| | | } |
| | |
| | | case "è¿ä¿®": |
| | | case "è¿å·¥": |
| | | //å¤æè´¨æ£è¡¨æ¯å¦æç¸å
³çæ¥å·¥id,å¦æææ¥å·¥id,é£ä¹è¿å·¥éè¦éæ°å建ç产订åéæ°ç产 |
| | | if (ObjectUtils.isNotNull(qualityInspect.getProductMainId())){ |
| | | if (ObjectUtils.isNotNull(qualityInspect.getProductMainId())) { |
| | | //è¿å·¥éè¦éæ°å建ç产订åéæ°ç产 |
| | | ProductOrder productOrder = productionProductMainMapper.getOrderByMainId(qualityInspect.getProductMainId()); |
| | | ProductOrder order = new ProductOrder(); |
| | |
| | | order.setEndTime(null); |
| | | productOrderService.save(order); |
| | | //æ°å¢ç产订åä¸çå·¥èºè·¯çº¿ä¸»è¡¨ |
| | | ProductProcessRoute productProcessRoute = productProcessRouteMapper.selectList(Wrappers.<ProductProcessRoute>lambdaQuery().eq(ProductProcessRoute::getProductOrderId,productOrder.getId()).orderByDesc(ProductProcessRoute::getId)).get(0); |
| | | ProductProcessRoute productProcessRoute = productProcessRouteMapper.selectList(Wrappers.<ProductProcessRoute>lambdaQuery().eq(ProductProcessRoute::getProductOrderId, productOrder.getId()).orderByDesc(ProductProcessRoute::getId)).get(0); |
| | | ProductProcessRoute newProcessRoute = new ProductProcessRoute(); |
| | | BeanUtils.copyProperties(productProcessRoute, newProcessRoute); |
| | | newProcessRoute.setId(null); |
| | |
| | | } |
| | | break; |
| | | case "æ¥åº": |
| | | //è°ç¨ä¸åæ ¼åºåæ¥å£ å
¥ä¸åæ ¼åº |
| | | stockUtils.addUnStock(qualityInspect.getProductModelId(), unqualified.getQuantity(), StockUnQualifiedRecordTypeEnum.DEFECTIVE_SCRAP.getCode(),unqualified.getId()); |
| | | break; |
| | | case "è®©æ¥æ¾è¡": |
| | | //è°ç¨æäº¤åæ ¼çæ¥å£ |
| | | stockUtils.addStock(qualityInspect.getProductModelId(), unqualified.getQuantity(), StockQualifiedRecordTypeEnum.DEFECTIVE_PASS.getCode(),unqualified.getId()); |
| | | qualityInspect.setCheckResult("åæ ¼"); |
| | | qualityInspectService.submit(qualityInspect); |
| | | break; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | |
| | | @RequestMapping("/sales/ledger") |
| | | @AllArgsConstructor |
| | | @Api(tags = "éå®å°è´¦") |
| | | @Slf4j |
| | | public class SalesLedgerController extends BaseController { |
| | | |
| | | private ISalesLedgerService salesLedgerService; |
| | |
| | | return salesLedgerService.importData(file); |
| | | } |
| | | |
| | | @ApiOperation("导åºéå®å°è´¦æ¨¡æ¿") |
| | | @PostMapping("/exportTemplate") |
| | | public void exportTemplate(HttpServletResponse response) { |
| | | // 1. æ¨¡æ¿æä»¶å¨resources/staticä¸çè·¯å¾ |
| | | String templatePath = "static/éå®å°è´¦å¯¼å
¥æ¨¡æ¿.xlsx"; |
| | | |
| | | // 2. è·åæ¨¡æ¿æä»¶çè¾å
¥æµ |
| | | try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(templatePath)) { |
| | | if (inputStream == null) { |
| | | throw new FileNotFoundException("æ¨¡æ¿æä»¶ä¸åå¨ï¼" + templatePath); |
| | | } |
| | | |
| | | // 3. 设置ååºå¤´ï¼è§¦åæµè§å¨ä¸è½½ |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("éå®å°è´¦å¯¼å
¥æ¨¡æ¿.xlsx", "utf-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName); |
| | | |
| | | // 4. å°æ¨¡æ¿æä»¶åå
¥ååºè¾åºæµ |
| | | try (OutputStream outputStream = response.getOutputStream()) { |
| | | byte[] buffer = new byte[1024]; |
| | | int len; |
| | | while ((len = inputStream.read(buffer)) > 0) { |
| | | outputStream.write(buffer, 0, len); |
| | | } |
| | | outputStream.flush(); |
| | | } |
| | | } catch (IOException e) { |
| | | log.error("导åºéå®å°è´¦æ¨¡æ¿å¤±è´¥", e); |
| | | // è¥æ¨¡æ¿æä»¶è¯»å失败ï¼è¿åé误æç¤º |
| | | try { |
| | | response.getWriter().write("模æ¿å¯¼åºå¤±è´¥ï¼" + e.getMessage()); |
| | | } catch (IOException ex) { |
| | | log.error("ååºè¾åºé误", ex); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢éå®å°è´¦å表 |
| | | */ |
| | |
| | | // procurementDto.setSalesLedgerProductId(item.getId()); |
| | | // procurementDto.setProductCategory(item.getProductCategory()); |
| | | // IPage<ProcurementPageDtoCopy> result = procurementRecordService.listPageCopyByProduction(new Page<>(1,-1), procurementDto); |
| | | BigDecimal stockQuantity = stockUtils.getStockQuantity(item.getProductModelId()).get("stockQuantity"); |
| | | if(stockQuantity != null) { |
| | | // BigDecimal stockQuantity = stockUtils.getStockQuantity(item.getProductModelId()).get("stockQuantity"); |
| | | |
| | | // ProcurementPageDtoCopy procurementDtoCopy = result.getRecords().get(0); |
| | | if (item.getQuantity().compareTo(stockQuantity) <= 0 && item.getApproveStatus() == 0) { |
| | | item.setApproveStatus(1); |
| | | salesLedgerProductService.addOrUpdateSalesLedgerProduct(item); |
| | | if (item.getApproveStatus() != 2) { |
| | | if (item.getHasSufficientStock() == 0) { |
| | | item.setApproveStatus(0); |
| | | }else { |
| | | item.setApproveStatus(1); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | return AjaxResult.success(list); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.approve.mapper.ApproveProcessMapper; |
| | | import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl; |
| | | import com.ruoyi.approve.vo.ApproveProcessVO; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.other.service.impl.TempFileServiceImpl; |
| | | import com.ruoyi.sales.dto.ShippingInfoDto; |
| | | import com.ruoyi.sales.mapper.ShipmentApprovalMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | |
| | | import com.ruoyi.sales.service.ISalesLedgerProductService; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import com.ruoyi.sales.service.ShippingInfoService; |
| | | import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private ISalesLedgerProductService salesLedgerProductService; |
| | | |
| | | @Autowired |
| | | private TempFileServiceImpl tempFileService; |
| | | |
| | | @Autowired |
| | | private CommonFileServiceImpl commonFileService; |
| | | |
| | | @Autowired |
| | | private ApproveProcessServiceImpl approveProcessService; |
| | | |
| | | |
| | | @GetMapping("/listPage") |
| | | @ApiOperation("åè´§ä¿¡æ¯å表") |
| | |
| | | @PostMapping("/add") |
| | | @ApiOperation("æ·»å åè´§ä¿¡æ¯") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult add(@RequestBody ShippingInfo req) { |
| | | LambdaQueryWrapper<ShippingInfo> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(ShippingInfo::getSalesLedgerId, req.getSalesLedgerId()); |
| | | wrapper.eq(ShippingInfo::getSalesLedgerProductId, req.getSalesLedgerProductId()); |
| | | List<ShippingInfo> list = shippingInfoService.list(wrapper); |
| | | if(!CollectionUtils.isEmpty(list)){ |
| | | return AjaxResult.error("åè´§ä¿¡æ¯å·²åå¨"); |
| | | } |
| | | @Log(title = "åè´§ä¿¡æ¯ç®¡ç", businessType = BusinessType.INSERT) |
| | | public AjaxResult add(@RequestBody ShippingInfoDto req) throws Exception { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String sh = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH"); |
| | | // åè´§å®¡æ¹ |
| | | ApproveProcessVO approveProcessVO = new ApproveProcessVO(); |
| | | approveProcessVO.setApproveType(7); |
| | | approveProcessVO.setApproveDeptId(loginUser.getTenantId()); |
| | | approveProcessVO.setApproveReason(req.getType() + ":" +sh); |
| | | approveProcessVO.setApproveUserIds(req.getApproveUserIds()); |
| | | approveProcessVO.setApproveUser(loginUser.getUserId()); |
| | | approveProcessVO.setApproveTime(LocalDate.now().toString()); |
| | | approveProcessService.addApprove(approveProcessVO); |
| | | // æ·»å åè´§æ¶æ¯ |
| | | req.setShippingNo(sh); |
| | | req.setStatus("å¾
å®¡æ ¸"); |
| | | boolean save = shippingInfoService.save(req); |
| | | if(save){ |
| | | ShippingInfo shippingInfo = shippingInfoService.getOne(wrapper); |
| | | ShipmentApproval shipmentApproval = new ShipmentApproval(); |
| | | shipmentApproval.setSalesLedgerId(req.getSalesLedgerId()); |
| | | shipmentApproval.setSalesLedgerProductId(req.getSalesLedgerProductId()); |
| | | shipmentApproval.setApproveUserId(req.getApproverId()); |
| | | shipmentApproval.setApproveStatus(2); |
| | | shipmentApproval.setShippingInfoId(shippingInfo.getId()); |
| | | shipmentApprovalMapper.insert(shipmentApproval); |
| | | |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductService.getById(req.getSalesLedgerProductId()); |
| | | if(salesLedgerProduct != null){ |
| | | salesLedgerProduct.setApproveStatus(2); |
| | | salesLedgerProductService.updateById(salesLedgerProduct); |
| | | } |
| | | |
| | | } |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @ApiOperation("ä¿®æ¹åè´§ä¿¡æ¯") |
| | | public AjaxResult update(@RequestBody ShippingInfo req) { |
| | | @ApiOperation("åè´§æ£åºå") |
| | | @PostMapping("/deductStock") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Log(title = "åè´§ä¿¡æ¯ç®¡ç", businessType = BusinessType.UPDATE) |
| | | public AjaxResult deductStock(@RequestBody ShippingInfoDto req) throws IOException { |
| | | ShippingInfo byId = shippingInfoService.getById(req.getId()); |
| | | if (byId == null) { |
| | | return AjaxResult.error("åè´§ä¿¡æ¯ä¸åå¨"); |
| | | } |
| | | Long userId = getLoginUser().getUserId(); |
| | | if(!userId.equals(Long.parseLong(byId.getCreateUser().toString()))){ |
| | | return AjaxResult.error("æ¨æ²¡ææéä¿®æ¹æ¤åè´§ä¿¡æ¯"); |
| | | byId.setExpressNumber(req.getExpressNumber()); |
| | | byId.setExpressCompany(req.getExpressCompany()); |
| | | byId.setShippingCarNumber(req.getShippingCarNumber()); |
| | | boolean update = shippingInfoService.updateById(req); |
| | | // è¿ç§»æä»¶ |
| | | if(CollectionUtils.isNotEmpty(req.getTempFileIds())){ |
| | | tempFileService.migrateTempFilesToFormal(req.getId(), req.getTempFileIds(), FileNameType.SHIP.getValue()); |
| | | } |
| | | return update ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @ApiOperation("ä¿®æ¹åè´§ä¿¡æ¯") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Log(title = "åè´§ä¿¡æ¯ç®¡ç", businessType = BusinessType.UPDATE) |
| | | public AjaxResult update(@RequestBody ShippingInfo req) { |
| | | ShippingInfo byId = shippingInfoService.getById(req.getId()); |
| | | if (byId == null) { |
| | | return AjaxResult.error("åè´§ä¿¡æ¯ä¸åå¨"); |
| | | } |
| | | boolean update = shippingInfoService.updateById(req); |
| | | return update ? AjaxResult.success() : AjaxResult.error(); |
| | |
| | | |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation("å é¤åè´§ä¿¡æ¯") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Log(title = "åè´§ä¿¡æ¯ç®¡ç", businessType = BusinessType.DELETE) |
| | | public AjaxResult delete(@RequestBody List<Long> ids) { |
| | | Long userId = getLoginUser().getUserId(); |
| | | ids.forEach(id -> { |
| | | ShippingInfo byId = shippingInfoService.getById(id); |
| | | if (byId == null) { |
| | | throw new RuntimeException("åè´§ä¿¡æ¯ä¸åå¨"); |
| | | } |
| | | if(!userId.equals(Long.parseLong(byId.getCreateUser().toString()))){ |
| | | throw new RuntimeException("æ¨æ²¡ææéå 餿¤åè´§ä¿¡æ¯"); |
| | | } |
| | | }); |
| | | commonFileService.deleteByBusinessIds(ids, FileNameType.SHIP.getValue()); |
| | | boolean delete = shippingInfoService.removeBatchByIds(ids); |
| | | return delete ? AjaxResult.success("å 餿å") : AjaxResult.error("å é¤å¤±è´¥"); |
| | | } |
| | |
| | | private String salesman; |
| | | @Excel(name = "客æ·åç§°") |
| | | private String customerName; |
| | | @Excel(name = "项ç®åç§°") |
| | | private String projectName; |
| | | @Excel(name = "å½å
¥äºº") |
| | | private String entryPerson; |
| | | @Excel(name = "夿³¨") |
| | |
| | | @Excel(name = "ååéé¢") |
| | | private BigDecimal contractAmount; |
| | | |
| | | @ApiModelProperty(value = "仿¬¾æ¹å¼") |
| | | @Excel(name = "仿¬¾æ¹å¼") |
| | | private String paymentMethod; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.sales.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author :yys |
| | | * @date : 2026/1/23 16:35 |
| | | */ |
| | | @Data |
| | | public class ShippingInfoDto extends ShippingInfo { |
| | | |
| | | /** |
| | | * 审æ¹äººidå表 |
| | | */ |
| | | // 审æ¹äºº |
| | | private String approveUserIds; |
| | | |
| | | private String type; // åè´§ç±»å |
| | | |
| | | @TableField(exist = false) |
| | | private List<String> tempFileIds; |
| | | @TableField(exist = false) |
| | | private List<CommonFile> commonFileList; |
| | | |
| | | } |
| | |
| | | * @date 2025-05-08 |
| | | */ |
| | | public interface SalesLedgerProductMapper extends MyBaseMapper<SalesLedgerProduct> { |
| | | List<SalesLedgerProduct> selectProduct() ; |
| | | |
| | | List<SalesLedgerProduct> selectSalesLedgerProductList(@Param("salesLedgerProduct") SalesLedgerProduct salesLedgerProduct); |
| | | |
| | | SalesLedgerProduct selectSalesLedgerProductByMainId(@Param("productMainId") Long productMainId); |
| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date shippingDate; |
| | | |
| | | // @TableField(exist = false) |
| | | // @ApiModelProperty(value = "çäº§ç¶æ") |
| | | // private String productionStatus = "æªå¼å§"; |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "åè´§ç¶æ") |
| | | private String shippingStatus; |
| | | /** |
| | | * å货审æ¹ç¶æ |
| | | * 产åç¶æ |
| | | */ |
| | | // @TableField(exist = false) |
| | | @ApiModelProperty(value = "审æ¹ç¶æï¼0æªç产,1å·²ç产,2å·²åè´§") |
| | | @ApiModelProperty(value = "产åç¶æï¼1-å
è¶³") |
| | | private Integer approveStatus; |
| | | |
| | | @ApiModelProperty(value = "å¾
忬¾æ»éé¢") |
| | |
| | | |
| | | @ApiModelProperty(value = "æ¯å¦è´¨æ£") |
| | | private Boolean isChecked; |
| | | |
| | | @TableField(exist = false) |
| | | private Integer hasSufficientStock; |
| | | } |
| | |
| | | @TableName("shipping_info") |
| | | public class ShippingInfo { |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "éå®å°è´¦id") |
| | | private Long salesLedgerId; |
| | | @ApiModelProperty(value = "é宿¥ä»·äº§å表id") |
| | | private Long salesLedgerProductId; |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "éå®ååå·") |
| | | @Excel(name = "éå®ååå·") |
| | |
| | | @Excel(name = "客æ·åç§°") |
| | | private String customerName; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "éå®å°è´¦id") |
| | | private Long salesLedgerId; |
| | | |
| | | @ApiModelProperty(value = "é宿¥ä»·äº§å表id") |
| | | private Long salesLedgerProductId; |
| | | |
| | | @ApiModelProperty(value = "ç¶æ") |
| | | @Excel(name = "ç¶æ") |
| | | private String status; |
| | | |
| | | @ApiModelProperty(value = "åè´§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @Excel(name = "åè´§æ¥æ", width = 30, dateFormat = "yyyy-MM-dd") |
| | | private Date shippingDate; |
| | | |
| | | @ApiModelProperty(value = "åè´§ç¼å·") |
| | | @Excel(name = "åè´§ç¼å·") |
| | | private String shippingNo; |
| | | |
| | | @ApiModelProperty(value = "å¿«éåå·") |
| | | @Excel(name = "å¿«éåå·") |
| | | private String expressNumber; |
| | | |
| | | @ApiModelProperty(value = "å¿«éå
¬å¸") |
| | | @Excel(name = "å¿«éå
¬å¸") |
| | | private String expressCompany; |
| | | |
| | | @ApiModelProperty(value = "åè´§ç±»å") |
| | | @Excel(name = "åè´§ç±»å") |
| | | private String type; |
| | | |
| | | @ApiModelProperty(value = "å货车çå·") |
| | | @Excel(name = "å货车çå·") |
| | |
| | | @ApiModelProperty(value = "ç§æ·ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | | @ApiModelProperty(value = "审æ¹äººid") |
| | | @TableField(exist = false) |
| | | private Integer approverId; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.sales.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.other.mapper.TempFileMapper; |
| | |
| | | @Value("${file.upload-dir}") |
| | | private String uploadDir; |
| | | |
| | | public void deleteByBusinessId(Long businessId,Integer type) { |
| | | commonFileMapper.delete(new LambdaQueryWrapper<CommonFile>().eq(CommonFile::getCommonId, businessId) |
| | | .eq(CommonFile::getType, type)); |
| | | } |
| | | |
| | | public void deleteByBusinessIds(List<Long> businessId,Integer type) { |
| | | commonFileMapper.delete(new LambdaQueryWrapper<CommonFile>().in(CommonFile::getCommonId, businessId) |
| | | .eq(CommonFile::getType, type)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int deleteSalesLedgerByIds(Long[] ids) { |
| | |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | if (CollectionUtils.isEmpty(salesLedgerProductImportDtoList)) return AjaxResult.error("éå®äº§åæ°æ®ä¸ºç©ºï¼"); |
| | | // å®¢æ·æ°æ® |
| | | List<Customer> customers = customerMapper.selectList(new LambdaQueryWrapper<Customer>().in(Customer::getCustomerName, |
| | | salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getCustomerName).toArray(String[]::new))); |
| | | // è§æ ¼åå·æ°æ® |
| | | List<ProductModel> productModels = productModelMapper.selectList(new LambdaQueryWrapper<ProductModel>().in(ProductModel::getModel, |
| | | salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getSpecificationModel).toArray(String[]::new))); |
| | | // 产åå¤§ç±»æ°æ® |
| | | List<Product> productList = productMapper.selectList(new LambdaQueryWrapper<Product>().in(Product::getProductName, |
| | | salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getProductCategory).toArray(String[]::new))); |
| | | salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getCustomerName).collect(Collectors.toList()))); |
| | | // // è§æ ¼åå·æ°æ® |
| | | // List<ProductModel> productModels = productModelMapper.selectList(new LambdaQueryWrapper<ProductModel>().in(ProductModel::getModel, |
| | | // salesLedgerProductImportDtoList.stream().map(SalesLedgerImportDto::getSpecificationModel).collect(Collectors.toList()))); |
| | | // // 产åå¤§ç±»æ°æ® |
| | | // List<Product> productList = productMapper.selectList(new LambdaQueryWrapper<Product>().in(Product::getProductName, |
| | | // salesLedgerProductImportDtoList.stream().map(SalesLedgerImportDto::getProductCategory).collect(Collectors.toList()))); |
| | | List<Map<String,Object>> list = productModelMapper.getProductAndModelList(); |
| | | // å½å
¥äººæ°æ® |
| | | List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().in(SysUser::getNickName, |
| | | salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getEntryPerson).toArray(String[]::new))); |
| | | salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getEntryPerson).collect(Collectors.toList()))); |
| | | for (SalesLedgerImportDto salesLedgerImportDto : salesLedgerImportDtoList) { |
| | | SalesLedger salesLedger = new SalesLedger(); |
| | | BeanUtils.copyProperties(salesLedgerImportDto, salesLedger); |
| | | salesLedger.setExecutionDate(DateUtils.toLocalDate(salesLedgerImportDto.getExecutionDate())); |
| | | // éè¿å®¢æ·åç§°æ¥è¯¢å®¢æ·IDï¼å®¢æ·ååå· |
| | | salesLedger.setCustomerId(customers.stream() |
| | | .filter(customer -> customer.getCustomerName().equals(salesLedger.getCustomerName())) |
| | |
| | | salesLedgerProduct.setTaxExclusiveTotalPrice(salesLedgerProduct.getTaxInclusiveTotalPrice().divide(new BigDecimal(1).add(salesLedgerProduct.getTaxRate().divide(new BigDecimal(100))), 2, RoundingMode.HALF_UP)); |
| | | salesLedgerProduct.setNoInvoiceNum(salesLedgerProduct.getQuantity()); |
| | | salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxExclusiveTotalPrice()); |
| | | |
| | | salesLedgerProduct.setProductId(productList.stream() |
| | | .filter(product -> product.getProductName().equals(salesLedgerProduct.getProductCategory())) |
| | | list.stream() |
| | | .filter(map -> map.get("productName").equals(salesLedgerProduct.getProductCategory()) && map.get("model").equals(salesLedgerProduct.getSpecificationModel())) |
| | | .findFirst() |
| | | .map(Product::getId) |
| | | .orElse(null)); |
| | | salesLedgerProduct.setProductModelId(productModels.stream() |
| | | .filter(productModel -> productModel.getModel().equals(salesLedgerProduct.getSpecificationModel())) |
| | | .findFirst() |
| | | .map(ProductModel::getId) |
| | | .orElse(null)); |
| | | .ifPresent(map -> { |
| | | salesLedgerProduct.setProductModelId(Long.parseLong(map.get("modelId").toString())); |
| | | salesLedgerProduct.setProductId(Long.parseLong(map.get("id").toString())); |
| | | }); |
| | | // salesLedgerProduct.setProductId(productList.stream() |
| | | // .filter(product -> product.getProductName().equals(salesLedgerProduct.getProductCategory())) |
| | | // .findFirst() |
| | | // .map(Product::getId) |
| | | // .orElse(null)); |
| | | // salesLedgerProduct.setProductModelId(productModels.stream() |
| | | // .filter(productModel -> productModel.getModel().equals(salesLedgerProduct.getSpecificationModel())) |
| | | // .findFirst() |
| | | // .map(ProductModel::getId) |
| | | // .orElse(null)); |
| | | salesLedgerProduct.setRegister(loginUser.getNickName()); |
| | | salesLedgerProduct.setRegisterDate(LocalDateTime.now()); |
| | | salesLedgerProduct.setApproveStatus(0); |
| | | salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProductImportDto.getTaxInclusiveTotalPrice()); |
| | | salesLedgerProductMapper.insert(salesLedgerProduct); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | return AjaxResult.success("导å
¥æå"); |
| | |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | @PostMapping("") |
| | | @Log(title = "å
¥åºç®¡ç-æ°å¢å
¥åº", businessType = BusinessType.INSERT) |
| | | public AjaxResult add(@RequestBody StockInRecordDto stockInRecordDto) { |
| | | return AjaxResult.success(stockInRecordService.add(stockInRecordDto)); |
| | | } |
| | | |
| | | @PutMapping("/{id}") |
| | | @Log(title = "å
¥åºç®¡ç-æ´æ°å
¥åº", businessType = BusinessType.UPDATE) |
| | | public AjaxResult update(@PathVariable("id") Long id, @RequestBody StockInRecordDto stockInRecordDto) { |
| | | return AjaxResult.success(stockInRecordService.update(id, stockInRecordDto)); |
| | | } |
| | | |
| | | @DeleteMapping("") |
| | | @Log(title = "å
¥åºç®¡ç-å é¤å
¥åº", businessType = BusinessType.DELETE) |
| | |
| | | return AjaxResult.success(stockInRecordService.batchDelete(ids)); |
| | | } |
| | | |
| | | @PostMapping("/exportStockInRecord") |
| | | @ApiOperation("导åºå
¥åºè®°å½") |
| | | public void exportStockInRecord(HttpServletResponse response, StockInRecordDto stockInRecordDto) { |
| | | stockInRecordService.exportStockInRecord(response,stockInRecordDto); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.compensationperformance.pojo.CompensationPerformance; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import com.ruoyi.stock.execl.StockInventoryExportData; |
| | | import com.ruoyi.stock.service.StockInventoryService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @PostMapping("/addstockInventory") |
| | | @ApiOperation("æ°å¢åºå") |
| | | public R addstockInventory(StockInventoryDto stockInventoryDto) { |
| | | public R addstockInventory(@RequestBody StockInventoryDto stockInventoryDto) { |
| | | stockInventoryDto.setRecordType(String.valueOf(StockQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode())); |
| | | stockInventoryDto.setRecordId(0L); |
| | | return R.ok(stockInventoryService.addstockInventory(stockInventoryDto)); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/subtractStockInventory") |
| | | @ApiOperation("æ£ååºå") |
| | | public R subtractStockInventory(StockInventoryDto stockInventoryDto) { |
| | | public R subtractStockInventory(@RequestBody StockInventoryDto stockInventoryDto) { |
| | | stockInventoryDto.setRecordType(String.valueOf(StockQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_OUT.getCode())); |
| | | stockInventoryDto.setRecordId(0L); |
| | | return R.ok(stockInventoryService.subtractStockInventory(stockInventoryDto)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("importStockInventory") |
| | | @ApiOperation("导å
¥åºå") |
| | | public R importStockInventory(MultipartFile file) { |
| | | return stockInventoryService.importStockInventory(file); |
| | | } |
| | | |
| | | @Log(title = "ä¸è½½åºå导å
¥æ¨¡æ¿", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/downloadStockInventory") |
| | | public void downloadStockInventory(HttpServletResponse response) { |
| | | List<StockInventoryExportData> list = new ArrayList<>(); |
| | | ExcelUtil<StockInventoryExportData> util = new ExcelUtil<>(StockInventoryExportData.class); |
| | | util.exportExcel(response, list, "åºå模æ¿"); |
| | | } |
| | | |
| | | @PostMapping("/exportStockInventory") |
| | | @ApiOperation("导åºåºå") |
| | | public void exportStockInventory(HttpServletResponse response,StockInventoryDto stockInventoryDto) { |
| | | stockInventoryService.exportStockInventory(response,stockInventoryDto); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | import com.ruoyi.stock.service.StockOutRecordService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | } |
| | | return AjaxResult.success(stockOutRecordService.batchDelete(ids)); |
| | | } |
| | | |
| | | @PostMapping("/exportStockOutRecord") |
| | | @ApiOperation("导åºåºåºè®°å½") |
| | | public void exportStockOutRecord(HttpServletResponse response, StockOutRecordDto stockOutRecordDto) { |
| | | stockOutRecordService.exportStockOutRecord(response,stockOutRecordDto); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.service.StockUninventoryService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * <p> |
| | | * ä¸åæ ¼åºå表 å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-01-22 10:17:45 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/stockUninventory") |
| | | public class StockUninventoryController { |
| | | @Autowired |
| | | private StockUninventoryService stockUninventoryService; |
| | | |
| | | @GetMapping("/pagestockUninventory") |
| | | @ApiOperation("å页æ¥è¯¢åºå") |
| | | public R pagestockUninventory(Page page, StockUninventoryDto stockUninventoryDto) { |
| | | IPage<StockUninventoryDto> stockUninventoryDtoIPage = stockUninventoryService.pageStockUninventory(page, stockUninventoryDto); |
| | | return R.ok(stockUninventoryDtoIPage); |
| | | } |
| | | |
| | | @PostMapping("/addstockUninventory") |
| | | @ApiOperation("æ°å¢åºå") |
| | | public R addstockUninventory(@RequestBody StockUninventoryDto stockUninventoryDto) { |
| | | stockUninventoryDto.setRecordType(String.valueOf(StockUnQualifiedRecordTypeEnum.CUSTOMIZATION_UNSTOCK_IN.getCode())); |
| | | stockUninventoryDto.setRecordId(0L); |
| | | return R.ok(stockUninventoryService.addStockUninventory(stockUninventoryDto)); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/subtractstockUninventory") |
| | | @ApiOperation("æ£ååºå") |
| | | public R subtractstockUninventory(@RequestBody StockUninventoryDto stockUninventoryDto) { |
| | | stockUninventoryDto.setRecordType(String.valueOf(StockUnQualifiedRecordTypeEnum.CUSTOMIZATION_UNSTOCK_OUT.getCode())); |
| | | stockUninventoryDto.setRecordId(0L); |
| | | return R.ok(stockUninventoryService.subtractStockUninventory(stockUninventoryDto)); |
| | | } |
| | | |
| | | @PostMapping("/exportStockUninventory") |
| | | @ApiOperation("导åºåºå") |
| | | public void exportStockUninventory(HttpServletResponse response, StockUninventoryDto stockUninventoryDto) { |
| | | stockUninventoryService.exportStockUninventory(response,stockUninventoryDto); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.dto; |
| | | |
| | | import com.ruoyi.stock.pojo.StockUninventory; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class StockUninventoryDto extends StockUninventory { |
| | | private String productName; |
| | | private String model; |
| | | private String unit; |
| | | |
| | | |
| | | //å
¥åºç±»å |
| | | private String recordType; |
| | | |
| | | //å
¥åºç±»å对åºçid |
| | | private Long recordId; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.execl; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class StockInRecordExportData { |
| | | |
| | | @Excel(name = "å
¥åºæ¹æ¬¡") |
| | | private String inboundBatches; |
| | | @Excel(name = "产ååç§°") |
| | | private String productName; |
| | | @Excel(name = "è§æ ¼åå·") |
| | | private String model; |
| | | @Excel(name = "åä½") |
| | | private String unit; |
| | | @Excel(name = "å
¥åºæ¥æº") |
| | | private String recordType; |
| | | @Excel(name = "å
¥åºæ°é") |
| | | private String stockInNum; |
| | | @Excel(name = "å
¥åºæ¶é´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Excel(isExport = false) |
| | | private String type; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.execl; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class StockInventoryExportData { |
| | | |
| | | |
| | | |
| | | @Excel(name = "产ååç§°") |
| | | private String productName; |
| | | |
| | | @Excel(name = "è§æ ¼") |
| | | private String model; |
| | | |
| | | @Excel(name = "åä½") |
| | | private String unit; |
| | | |
| | | @Excel(name = "åºåæ°é") |
| | | private BigDecimal qualitity; |
| | | |
| | | @Excel(name = "夿³¨") |
| | | private String remark; |
| | | |
| | | @Excel(name = "ææ°æ´æ°æ¶é´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.execl; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class StockOutRecordExportData { |
| | | @Excel(name = "åºåºæ¹æ¬¡") |
| | | private String outboundBatches; |
| | | @Excel(name = "产ååç§°") |
| | | private String productName; |
| | | @Excel(name = "è§æ ¼åå·") |
| | | private String model; |
| | | @Excel(name = "åä½") |
| | | private String unit; |
| | | @Excel(name = "åºåºæ¥æº") |
| | | private String recordType; |
| | | @Excel(name = "åºåºæ°é") |
| | | private String stockInNum; |
| | | @Excel(name = "åºåºæ¶é´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Excel(isExport = false) |
| | | private String type; |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.execl.StockInRecordExportData; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface StockInRecordMapper extends BaseMapper<StockInRecord> { |
| | | IPage<StockInRecordDto> listPage(Page page, @Param("params") StockInRecordDto stockInRecordDto); |
| | | |
| | | List<StockInRecordExportData> listStockInRecordExportData(@Param("params") StockInRecordDto stockInRecordDto); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.execl.StockInventoryExportData; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | int updateAddStockInventory(@Param("ew") StockInventoryDto stockInventoryDto); |
| | | |
| | | int updateSubtractStockInventory(@Param("ew") StockInventoryDto stockInventoryDto); |
| | | |
| | | List<StockInventoryExportData> listStockInventoryExportData(@Param("ew") StockInventoryDto stockInventoryDto); |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.execl.StockOutRecordExportData; |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public interface StockOutRecordMapper extends BaseMapper<StockOutRecord> { |
| | | IPage<StockOutRecordDto> listPage(Page page, @Param("params") StockOutRecordDto stockOutRecordDto); |
| | | |
| | | List<StockOutRecordExportData> listStockOutRecordExportData(@Param("params") StockOutRecordDto stockOutRecordDto); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.execl.StockInventoryExportData; |
| | | import com.ruoyi.stock.pojo.StockUninventory; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * ä¸åæ ¼åºå表 Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-01-22 10:17:45 |
| | | */ |
| | | @Mapper |
| | | public interface StockUninventoryMapper extends BaseMapper<StockUninventory> { |
| | | |
| | | IPage<StockUninventoryDto> pageStockUninventory(Page page, @Param("ew") StockUninventoryDto stockUninventoryDto); |
| | | |
| | | int updateSubtractStockUnInventory(StockUninventoryDto stockUninventoryDto); |
| | | |
| | | int updateAddStockUnInventory(StockUninventoryDto stockUninventoryDto); |
| | | |
| | | List<StockInventoryExportData> listStockInventoryExportData(@Param("ew") StockUninventoryDto stockUninventoryDto); |
| | | } |
| | |
| | | @ApiModelProperty(value = "å
¥åºæ°é") |
| | | private BigDecimal stockInNum; |
| | | |
| | | @ApiModelProperty(value = "è®°å½ç±»å éè´å
¥åº/ç产å
¥åº/è´¨éå
¥åº/èªå®ä¹å
¥åº") |
| | | @ApiModelProperty(value = "è®°å½ç±»å æä¸¾") |
| | | private String recordType; |
| | | |
| | | @ApiModelProperty(value = "è®°å½ID salesProductId/ProductrMainId/qualityInspectId/0") |
| | | @ApiModelProperty(value = "è®°å½ID ") |
| | | private Long recordId; |
| | | |
| | | @ApiModelProperty(value = "产åè§æ ¼ID") |
| | |
| | | |
| | | @ApiModelProperty("é¢è¦æ°é") |
| | | private Integer warnNum; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | /** |
| | | * <p> |
| | | * ä¸åæ ¼åºå表 |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-01-22 10:17:45 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @TableName("stock_uninventory") |
| | | @ApiModel(value = "StockUninventory对象", description = "ä¸åæ ¼åºå表") |
| | | public class StockUninventory implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty("主é®id") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("è§æ ¼id") |
| | | private Long productModelId; |
| | | |
| | | @ApiModelProperty("æ°é") |
| | | private BigDecimal qualitity; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("æ´æ°æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateTime; |
| | | |
| | | @ApiModelProperty("çæ¬å·") |
| | | private Integer version; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | } |
| | |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | public interface StockInRecordService extends IService<StockInRecord> { |
| | |
| | | int update(Long id, StockInRecordDto stockInRecordDto); |
| | | |
| | | int batchDelete(List<Long> ids); |
| | | |
| | | void exportStockInRecord(HttpServletResponse response, StockInRecordDto stockInRecordDto); |
| | | } |
| | |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | Boolean addstockInventory(StockInventoryDto stockInventoryDto); |
| | | |
| | | Boolean subtractStockInventory(StockInventoryDto stockInventoryDto); |
| | | |
| | | R importStockInventory(MultipartFile file); |
| | | |
| | | void exportStockInventory(HttpServletResponse response, StockInventoryDto stockInventoryDto); |
| | | } |
| | |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | int update(Long id, StockOutRecordDto stockOutRecordDto); |
| | | |
| | | int batchDelete(List<Long> ids); |
| | | |
| | | void exportStockOutRecord(HttpServletResponse response, StockOutRecordDto stockOutRecordDto); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.pojo.StockUninventory; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * <p> |
| | | * ä¸åæ ¼åºå表 æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-01-22 10:17:45 |
| | | */ |
| | | public interface StockUninventoryService extends IService<StockUninventory> { |
| | | |
| | | IPage<StockUninventoryDto> pageStockUninventory(Page page, StockUninventoryDto stockUninventoryDto); |
| | | |
| | | Integer addStockUninventory(StockUninventoryDto stockUninventoryDto); |
| | | |
| | | Integer subtractStockUninventory(StockUninventoryDto stockUninventoryDto); |
| | | |
| | | void exportStockUninventory(HttpServletResponse response, StockUninventoryDto stockUninventoryDto); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.EnumUtil; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.execl.StockInRecordExportData; |
| | | import com.ruoyi.stock.execl.StockInventoryExportData; |
| | | import com.ruoyi.stock.mapper.StockInRecordMapper; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.mapper.StockUninventoryMapper; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import com.ruoyi.stock.pojo.StockUninventory; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class StockInRecordServiceImpl extends ServiceImpl<StockInRecordMapper, StockInRecord> implements StockInRecordService { |
| | | @Autowired |
| | | |
| | | private StockInRecordMapper stockInRecordMapper; |
| | | @Autowired |
| | | private StockInventoryMapper stockInventoryMapper; |
| | | private StockUninventoryMapper stockUninventoryMapper; |
| | | |
| | | @Override |
| | | public IPage<StockInRecordDto> listPage(Page page, StockInRecordDto stockInRecordDto) { |
| | |
| | | public int batchDelete(List<Long> ids) { |
| | | for (Long id : ids) { |
| | | StockInRecord stockInRecord = stockInRecordMapper.selectById(id); |
| | | StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, id)); |
| | | if (stockInventory == null) { |
| | | throw new BaseException("该å
¥åºè®°å½ä¸æ²¡æå¯¹åºç产å,æ æ³å é¤!!!"); |
| | | }else { |
| | | StockInventoryDto stockInRecordDto = new StockInventoryDto(); |
| | | stockInRecordDto.setProductModelId(stockInventory.getProductModelId()); |
| | | stockInRecordDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockInventoryMapper.updateSubtractStockInventory(stockInRecordDto); |
| | | if (stockInRecord.getType().equals("0")) { |
| | | StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, stockInRecord.getProductModelId())); |
| | | if (stockInventory == null) { |
| | | throw new BaseException("åºåè®°å½ä¸æ²¡æå¯¹åºç产å,æ æ³å é¤!!!"); |
| | | }else { |
| | | StockInventoryDto stockInRecordDto = new StockInventoryDto(); |
| | | stockInRecordDto.setProductModelId(stockInventory.getProductModelId()); |
| | | stockInRecordDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockInventoryMapper.updateAddStockInventory(stockInRecordDto); |
| | | } |
| | | }else if (stockInRecord.getType().equals("1")) { |
| | | StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>().eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId())); |
| | | if (stockUninventory == null) { |
| | | throw new BaseException("åºåè®°å½ä¸æ²¡æå¯¹åºç产å,æ æ³å é¤!!!"); |
| | | }else { |
| | | StockUninventoryDto stockUninventoryDto = new StockUninventoryDto(); |
| | | stockUninventoryDto.setProductModelId(stockUninventory.getProductModelId()); |
| | | stockUninventoryDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockUninventoryMapper.updateAddStockUnInventory(stockUninventoryDto); |
| | | } |
| | | } |
| | | } |
| | | return stockInRecordMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void exportStockInRecord(HttpServletResponse response, StockInRecordDto stockInRecordDto) { |
| | | List<StockInRecordExportData> list = stockInRecordMapper.listStockInRecordExportData(stockInRecordDto); |
| | | for (StockInRecordExportData stockInRecordExportData : list) { |
| | | if (stockInRecordExportData.getType().equals("0")) { |
| | | stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue()); |
| | | }else { |
| | | stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockUnQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue()); |
| | | } |
| | | } |
| | | ExcelUtil<StockInRecordExportData> util = new ExcelUtil<>(StockInRecordExportData.class); |
| | | util.exportExcel(response,list, "å
¥åºè®°å½ä¿¡æ¯"); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.pojo.BorrowInfo; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import com.ruoyi.stock.execl.StockInventoryExportData; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | | import com.ruoyi.stock.service.StockInventoryService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.stock.service.StockOutRecordService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2026-01-21 04:16:36 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class StockInventoryServiceImpl extends ServiceImpl<StockInventoryMapper, StockInventory> implements StockInventoryService { |
| | | |
| | | @Autowired |
| | | private StockInventoryMapper stockInventoryMapper; |
| | | |
| | | @Autowired |
| | | private StockInRecordService stockInRecordService; |
| | | @Autowired |
| | | private StockOutRecordService stockOutRecordService; |
| | | |
| | | private SalesLedgerProductMapper salesLedgerProductMapper; |
| | | @Override |
| | | public IPage<StockInventoryDto> pagestockInventory(Page page, StockInventoryDto stockInventoryDto) { |
| | | return stockInventoryMapper.pagestockInventory(page, stockInventoryDto); |
| | |
| | | stockInRecordDto.setRecordType(stockInventoryDto.getRecordType()); |
| | | stockInRecordDto.setStockInNum(stockInventoryDto.getQualitity()); |
| | | stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | stockInRecordDto.setType("0"); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | //åè¿è¡æ°å¢åºåæ°éåºå |
| | | //å
æ¥è¯¢åºå表ä¸çäº§åæ¯å¦åå¨ï¼ä¸å卿°å¢ï¼å卿´æ° |
| | |
| | | newStockInventory.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | newStockInventory.setQualitity(stockInventoryDto.getQualitity()); |
| | | newStockInventory.setVersion(1); |
| | | newStockInventory.setRemark(stockInventoryDto.getRemark()); |
| | | stockInventoryMapper.insert(newStockInventory); |
| | | }else { |
| | | stockInventoryMapper.updateAddStockInventory(stockInventoryDto); |
| | |
| | | stockOutRecordDto.setRecordType(stockInventoryDto.getRecordType()); |
| | | stockOutRecordDto.setStockOutNum(stockInventoryDto.getQualitity()); |
| | | stockOutRecordDto.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | stockOutRecordDto.setType("0"); |
| | | stockOutRecordService.add(stockOutRecordDto); |
| | | StockInventory oldStockInventory = stockInventoryMapper.selectOne(new QueryWrapper<StockInventory>().lambda().eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId())); |
| | | if (ObjectUtils.isEmpty(oldStockInventory)) { |
| | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public R importStockInventory(MultipartFile file) { |
| | | try { |
| | | final StringBuffer[] errorMsg = {new StringBuffer()}; |
| | | //æ¥è¯¢ææç产å |
| | | List<SalesLedgerProduct> salesLedgerProducts =salesLedgerProductMapper.selectProduct(); |
| | | |
| | | ExcelUtil<StockInventoryExportData> util = new ExcelUtil<StockInventoryExportData>(StockInventoryExportData.class); |
| | | List<StockInventoryExportData> list = util.importExcel(file.getInputStream()); |
| | | list.stream().forEach(dto -> { |
| | | salesLedgerProducts.stream().forEach(item->{ |
| | | if (item.getProductCategory().equals(dto.getProductName())&&item.getSpecificationModel().equals(dto.getModel())) { |
| | | //æ´æ°åºå |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setRecordId(0L); |
| | | stockInventoryDto.setRecordType(StockQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode()); |
| | | stockInventoryDto.setQualitity(dto.getQualitity()); |
| | | stockInventoryDto.setProductModelId(item.getProductModelId()); |
| | | this.addstockInventory(stockInventoryDto); }else { |
| | | errorMsg[0] = errorMsg[0].append("产ååç§°ï¼"+dto.getProductName()+"è§æ ¼ï¼"+dto.getModel()+"ä¸åå¨").append("\n"); |
| | | } |
| | | }); |
| | | }); |
| | | return R.ok(errorMsg[0]); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public void exportStockInventory(HttpServletResponse response, StockInventoryDto stockInventoryDto) { |
| | | |
| | | List<StockInventoryExportData> list = stockInventoryMapper.listStockInventoryExportData(stockInventoryDto); |
| | | ExcelUtil<StockInventoryExportData> util = new ExcelUtil<>(StockInventoryExportData.class); |
| | | util.exportExcel(response,list, "åºåä¿¡æ¯"); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.EnumUtil; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.execl.StockInRecordExportData; |
| | | import com.ruoyi.stock.execl.StockOutRecordExportData; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.mapper.StockOutRecordMapper; |
| | | import com.ruoyi.stock.mapper.StockUninventoryMapper; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | import com.ruoyi.stock.pojo.StockUninventory; |
| | | import com.ruoyi.stock.service.StockOutRecordService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @since 2026-01-21 05:27:04 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class StockOutRecordServiceImpl extends ServiceImpl<StockOutRecordMapper, StockOutRecord> implements StockOutRecordService { |
| | | @Autowired |
| | | private StockOutRecordMapper stockOutRecordMapper; |
| | | @Autowired |
| | | private StockInventoryMapper stockInventoryMapper; |
| | | private StockUninventoryMapper stockUninventoryMapper; |
| | | |
| | | @Override |
| | | public IPage<StockOutRecordDto> listPage(Page page, StockOutRecordDto stockOutRecordDto) { |
| | |
| | | public int batchDelete(List<Long> ids) { |
| | | for (Long id : ids) { |
| | | StockOutRecord stockOutRecord = stockOutRecordMapper.selectById(id); |
| | | StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, id)); |
| | | if (stockInventory == null) { |
| | | throw new BaseException("该å
¥åºè®°å½ä¸æ²¡æå¯¹åºç产å,æ æ³å é¤!!!"); |
| | | }else { |
| | | StockInventoryDto stockInRecordDto = new StockInventoryDto(); |
| | | stockInRecordDto.setProductModelId(stockInventory.getProductModelId()); |
| | | stockInRecordDto.setQualitity(stockOutRecord.getStockOutNum()); |
| | | stockInventoryMapper.updateAddStockInventory(stockInRecordDto); |
| | | if (stockOutRecord.getType().equals("0")) { |
| | | StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, stockOutRecord.getProductModelId())); |
| | | if (stockInventory == null) { |
| | | throw new BaseException("åºåè®°å½ä¸æ²¡æå¯¹åºç产å,æ æ³å é¤!!!"); |
| | | }else { |
| | | StockInventoryDto stockInRecordDto = new StockInventoryDto(); |
| | | stockInRecordDto.setProductModelId(stockInventory.getProductModelId()); |
| | | stockInRecordDto.setQualitity(stockOutRecord.getStockOutNum()); |
| | | stockInventoryMapper.updateAddStockInventory(stockInRecordDto); |
| | | } |
| | | }else if (stockOutRecord.getType().equals("1")) { |
| | | StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>().eq(StockUninventory::getProductModelId, stockOutRecord.getProductModelId())); |
| | | if (stockUninventory == null) { |
| | | throw new BaseException("åºåè®°å½ä¸æ²¡æå¯¹åºç产å,æ æ³å é¤!!!"); |
| | | }else { |
| | | StockUninventoryDto stockUninventoryDto = new StockUninventoryDto(); |
| | | stockUninventoryDto.setProductModelId(stockUninventory.getProductModelId()); |
| | | stockUninventoryDto.setQualitity(stockOutRecord.getStockOutNum()); |
| | | stockUninventoryMapper.updateAddStockUnInventory(stockUninventoryDto); |
| | | } |
| | | } |
| | | } |
| | | return stockOutRecordMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void exportStockOutRecord(HttpServletResponse response, StockOutRecordDto stockOutRecordDto) { |
| | | List<StockOutRecordExportData> list = stockOutRecordMapper.listStockOutRecordExportData(stockOutRecordDto); |
| | | for (StockOutRecordExportData stockInRecordExportData : list) { |
| | | if (stockInRecordExportData.getType().equals("0")) { |
| | | stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue()); |
| | | }else { |
| | | stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockUnQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue()); |
| | | } |
| | | } |
| | | ExcelUtil<StockOutRecordExportData> util = new ExcelUtil<>(StockOutRecordExportData.class); |
| | | util.exportExcel(response,list, "åºåºè®°å½ä¿¡æ¯"); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.execl.StockInventoryExportData; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import com.ruoyi.stock.pojo.StockUninventory; |
| | | import com.ruoyi.stock.mapper.StockUninventoryMapper; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | | import com.ruoyi.stock.service.StockOutRecordService; |
| | | import com.ruoyi.stock.service.StockUninventoryService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * ä¸åæ ¼åºå表 æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-01-22 10:17:45 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class StockUninventoryServiceImpl extends ServiceImpl<StockUninventoryMapper, StockUninventory> implements StockUninventoryService { |
| | | |
| | | private StockUninventoryMapper stockUninventoryMapper; |
| | | private StockOutRecordService stockOutRecordService; |
| | | private StockInRecordService stockInRecordService; |
| | | |
| | | @Override |
| | | public IPage<StockUninventoryDto> pageStockUninventory(Page page, StockUninventoryDto stockUninventoryDto) { |
| | | return stockUninventoryMapper.pageStockUninventory(page, stockUninventoryDto); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Integer addStockUninventory(StockUninventoryDto stockUninventoryDto) { |
| | | //æ°å¢å
¥åºè®°å½åæ·»å åºå |
| | | StockInRecordDto stockInRecordDto = new StockInRecordDto(); |
| | | stockInRecordDto.setRecordId(stockUninventoryDto.getRecordId()); |
| | | stockInRecordDto.setRecordType(stockUninventoryDto.getRecordType()); |
| | | stockInRecordDto.setStockInNum(stockUninventoryDto.getQualitity()); |
| | | stockInRecordDto.setProductModelId(stockUninventoryDto.getProductModelId()); |
| | | stockInRecordDto.setType("1"); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | //åè¿è¡æ°å¢åºåæ°éåºå |
| | | //å
æ¥è¯¢åºå表ä¸çäº§åæ¯å¦åå¨ï¼ä¸å卿°å¢ï¼å卿´æ° |
| | | StockUninventory oldStockUnInventory = stockUninventoryMapper.selectOne(new QueryWrapper<StockUninventory>().lambda().eq(StockUninventory::getProductModelId, stockUninventoryDto.getProductModelId())); |
| | | if (ObjectUtils.isEmpty(oldStockUnInventory)) { |
| | | StockUninventory newStockUnInventory = new StockUninventory(); |
| | | newStockUnInventory.setProductModelId(stockUninventoryDto.getProductModelId()); |
| | | newStockUnInventory.setQualitity(stockUninventoryDto.getQualitity()); |
| | | newStockUnInventory.setVersion(1); |
| | | newStockUnInventory.setRemark(stockUninventoryDto.getRemark()); |
| | | stockUninventoryMapper.insert(newStockUnInventory); |
| | | }else { |
| | | stockUninventoryMapper.updateAddStockUnInventory(stockUninventoryDto); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Integer subtractStockUninventory(StockUninventoryDto stockUninventoryDto) { |
| | | |
| | | // æ°å¢åºåºè®°å½ |
| | | StockOutRecordDto stockOutRecordDto = new StockOutRecordDto(); |
| | | stockOutRecordDto.setRecordId(stockUninventoryDto.getRecordId()); |
| | | stockOutRecordDto.setRecordType(stockUninventoryDto.getRecordType()); |
| | | stockOutRecordDto.setStockOutNum(stockUninventoryDto.getQualitity()); |
| | | stockOutRecordDto.setProductModelId(stockUninventoryDto.getProductModelId()); |
| | | stockOutRecordDto.setType("1"); |
| | | stockOutRecordService.add(stockOutRecordDto); |
| | | StockUninventory oldStockInventory = stockUninventoryMapper.selectOne(new QueryWrapper<StockUninventory>().lambda().eq(StockUninventory::getProductModelId, stockUninventoryDto.getProductModelId())); |
| | | if (ObjectUtils.isEmpty(oldStockInventory)) { |
| | | throw new RuntimeException("产ååºåä¸åå¨"); |
| | | }else { |
| | | stockUninventoryMapper.updateSubtractStockUnInventory(stockUninventoryDto); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | public void exportStockUninventory(HttpServletResponse response, StockUninventoryDto stockUninventoryDto) { |
| | | List<StockInventoryExportData> list = stockUninventoryMapper.listStockInventoryExportData(stockUninventoryDto); |
| | | ExcelUtil<StockInventoryExportData> util = new ExcelUtil<>(StockInventoryExportData.class); |
| | | util.exportExcel(response,list, "ä¸åæ ¼åºåä¿¡æ¯"); |
| | | } |
| | | } |
| | |
| | | |
| | | ORDER BY pm.id DESC |
| | | </select> |
| | | <select id="getProductAndModelList" resultType="java.util.Map"> |
| | | select p.id as id, |
| | | pm.id as modelId, |
| | | p.product_name as productName , |
| | | pm.model as model |
| | | from product_model pm |
| | | left join product p on p.id = pm.product_id |
| | | order by p.id,pm.id desc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | create_time, |
| | | update_user, |
| | | update_time, |
| | | tenant_id |
| | | tenant_id, |
| | | unit, |
| | | dept_id, |
| | | instation_location, |
| | | cycle |
| | | FROM |
| | | measuring_instrument_ledger |
| | | <where> |
| | |
| | | SELECT |
| | | T1.*, |
| | | t3.shipping_car_number, |
| | | t3.shipping_date |
| | | t3.shipping_date, |
| | | t3.status as shippingStatus |
| | | t3.shipping_date, |
| | | CASE |
| | | WHEN t2.qualitity > T1.quantity THEN 1 |
| | | ELSE 0 |
| | | END as has_sufficient_stock |
| | | FROM |
| | | sales_ledger_product T1 |
| | | left join shipping_info t3 on T1.id = t3.sales_ledger_product_id |
| | | LEFT JOIN stock_inventory t2 ON T1.product_model_id = t2.product_model_id |
| | | LEFT JOIN shipping_info t3 ON T1.id = t3.sales_ledger_product_id |
| | | <where> |
| | | 1=1 |
| | | <if test="salesLedgerProduct.salesLedgerId != null and salesLedgerProduct.salesLedgerId != '' "> |
| | |
| | | WHERE sl.id = #{salesLedegerId}) A |
| | | group by a.model, a.product_name, a.unit |
| | | </select> |
| | | <select id="selectProduct" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct"> |
| | | select |
| | | p.product_name as product_category, |
| | | pm.model as specification_model, |
| | | pm.id |
| | | from product_model pm |
| | | left join product p on pm.product_id = p.id |
| | | </select> |
| | | </mapper> |
| | |
| | | s.sales_ledger_id, |
| | | s.shipping_date, |
| | | s.shipping_car_number, |
| | | s.express_number, |
| | | s.express_company, |
| | | s.shipping_no, |
| | | s.type, |
| | | s.status, |
| | | s.create_time, |
| | | s.update_time, |
| | | s.create_user, |
| | |
| | | <select id="listPage" resultType="com.ruoyi.stock.dto.StockInRecordDto"> |
| | | SELECT |
| | | sir.*, |
| | | p.product_name as productName, |
| | | p.product_name as product_name, |
| | | pm.model, |
| | | pm.unit, |
| | | u.nick_name as createBy |
| | |
| | | <if test="params.productName != null and params.productName != ''"> |
| | | and p.product_name like concat('%',#{params.productName},'%') |
| | | </if> |
| | | <if test="params.type != null and params.type != ''"> |
| | | and sir.type = #{params.type} |
| | | </if> |
| | | <if test="params.recordType != null and params.recordType != ''"> |
| | | and sir.record_type = #{params.recordType} |
| | | </if> |
| | | </where> |
| | | order by sir.id desc |
| | | </select> |
| | | <select id="listStockInRecordExportData" resultType="com.ruoyi.stock.execl.StockInRecordExportData"> |
| | | SELECT |
| | | sir.*, |
| | | p.product_name as product_name, |
| | | pm.model, |
| | | pm.unit, |
| | | u.nick_name as createBy |
| | | FROM stock_in_record as sir |
| | | LEFT JOIN product_model as pm on sir.product_model_id = pm.id |
| | | LEFT JOIN product as p on pm.product_id = p.id |
| | | LEFT JOIN sys_user as u on sir.create_user = u.user_id |
| | | <where> |
| | | <if test="params.timeStr != null and params.timeStr != ''"> |
| | | and sir.create_time like concat('%',#{params.timeStr},'%') |
| | | </if> |
| | | <if test="params.productName != null and params.productName != ''"> |
| | | and p.product_name like concat('%',#{params.productName},'%') |
| | | </if> |
| | | <if test="params.type != null and params.type != ''"> |
| | | and sir.type = #{params.type} |
| | | </if> |
| | | <if test="params.recordType != null and params.recordType != ''"> |
| | | and sir.record_type = #{params.recordType} |
| | | </if> |
| | | </where> |
| | | order by sir.id desc |
| | | </select> |
| | |
| | | <if test="ew.version != null"> |
| | | version = version + 1, |
| | | </if> |
| | | <if test="ew.remark != null and ew.remark !=''"> |
| | | remark = #{ew.remark}, |
| | | </if> |
| | | update_time = now() |
| | | </set> |
| | | where product_model_id = #{ew.productModelId} |
| | | </update> |
| | |
| | | <if test="ew.version != null"> |
| | | version = version + 1, |
| | | </if> |
| | | <if test="ew.remark != null and ew.remark !=''"> |
| | | remark = #{ew.remark}, |
| | | </if> |
| | | update_time = now() |
| | | </set> |
| | | where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity} |
| | | </update> |
| | |
| | | and p.product_name like concat('%',#{ew.productName},'%') |
| | | </if> |
| | | </select> |
| | | <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData"> |
| | | select si.qualitity, |
| | | pm.model, |
| | | pm.unit, |
| | | p.product_name, |
| | | si.remark, |
| | | si.update_time |
| | | from stock_inventory si |
| | | left join product_model pm on si.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | where 1 = 1 |
| | | <if test="ew.productName != null and ew.productName !=''"> |
| | | and p.product_name like concat('%',#{ew.productName},'%') |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | LEFT JOIN sys_user as u on sor.create_user = u.user_id |
| | | <where> |
| | | <if test="params.timeStr != null and params.timeStr != ''"> |
| | | and sor.create_time like concat('%',#{param.timeStr},'%') |
| | | and sor.create_time like concat('%',#{params.timeStr},'%') |
| | | </if> |
| | | <if test="params.productName != null and params.productName != ''"> |
| | | and p.product_name like concat('%',#{param.productName},'%') |
| | | and p.product_name like concat('%',#{params.productName},'%') |
| | | </if> |
| | | <if test="params.type != null and params.type != ''"> |
| | | and sor.type = #{params.type} |
| | | </if> |
| | | <if test="params.recordType != null and params.recordType != ''"> |
| | | and sor.record_type = #{params.recordType} |
| | | </if> |
| | | </where> |
| | | order by sor.id desc |
| | | </select> |
| | | <select id="listStockOutRecordExportData" resultType="com.ruoyi.stock.execl.StockOutRecordExportData"> |
| | | SELECT |
| | | sor.*, |
| | | p.product_name as productName, |
| | | pm.model, |
| | | pm.unit, |
| | | u.nick_name as createBy |
| | | FROM stock_out_record as sor |
| | | LEFT JOIN product_model as pm on sor.product_model_id = pm.id |
| | | LEFT JOIN product as p on pm.product_id = p.id |
| | | LEFT JOIN sys_user as u on sor.create_user = u.user_id |
| | | <where> |
| | | <if test="params.timeStr != null and params.timeStr != ''"> |
| | | and sor.create_time like concat('%',#{params.timeStr},'%') |
| | | </if> |
| | | <if test="params.productName != null and params.productName != ''"> |
| | | and p.product_name like concat('%',#{params.productName},'%') |
| | | </if> |
| | | <if test="params.type != null and params.type != ''"> |
| | | and sor.type = #{params.type} |
| | | </if> |
| | | <if test="params.recordType != null and params.recordType != ''"> |
| | | and sor.record_type = #{params.recordType} |
| | | </if> |
| | | </where> |
| | | order by sor.id desc |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.ruoyi.stock.mapper.StockUninventoryMapper"> |
| | | |
| | | <!-- éç¨æ¥è¯¢æ å°ç»æ --> |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.stock.pojo.StockUninventory"> |
| | | <result column="id" property="id" /> |
| | | <result column="product_model_id" property="productModelId" /> |
| | | <result column="qualitity" property="qualitity" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="version" property="version" /> |
| | | </resultMap> |
| | | <update id="updateSubtractStockUnInventory"> |
| | | update stock_inventory |
| | | <set> |
| | | <if test="ew.qualitity != null"> |
| | | qualitity = qualitity - #{ew.qualitity}, |
| | | </if> |
| | | <if test="ew.version != null"> |
| | | version = version + 1, |
| | | </if> |
| | | <if test="ew.remark != null and ew.remark !=''"> |
| | | remark = #{ew.remark}, |
| | | </if> |
| | | update_time = now() |
| | | </set> |
| | | where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity} |
| | | </update> |
| | | <update id="updateAddStockUnInventory"> |
| | | update stock_inventory |
| | | <set> |
| | | <if test="ew.qualitity != null"> |
| | | qualitity = qualitity + #{ew.qualitity}, |
| | | </if> |
| | | <if test="ew.version != null"> |
| | | version = version + 1, |
| | | </if> |
| | | <if test="ew.remark != null and ew.remark !=''"> |
| | | remark = #{ew.remark}, |
| | | </if> |
| | | update_time = now() |
| | | </set> |
| | | where product_model_id = #{ew.productModelId} |
| | | </update> |
| | | <select id="pageStockUninventory" resultType="com.ruoyi.stock.dto.StockUninventoryDto"> |
| | | select su.*, |
| | | pm.model, |
| | | pm.unit, |
| | | p.product_name |
| | | from stock_uninventory su |
| | | left join product_model pm on su.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | where 1 = 1 |
| | | <if test="ew.productName != null and ew.productName !=''"> |
| | | and p.product_name like concat('%',#{ew.productName},'%') |
| | | </if> |
| | | </select> |
| | | <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData"> |
| | | select su.*, |
| | | pm.model, |
| | | pm.unit, |
| | | p.product_name |
| | | from stock_uninventory su |
| | | left join product_model pm on su.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | where 1 = 1 |
| | | <if test="ew.productName != null and ew.productName !=''"> |
| | | and p.product_name like concat('%',#{ew.productName},'%') |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |