| | |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.modules.dnc.entity.GuideCardBatch; |
| | | import org.jeecg.modules.dnc.service.IGuideCardBatchService; |
| | | import org.jeecg.modules.dncFlow.vo.GuideCardBatchFlowTaskVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | |
| | | } |
| | | |
| | | /** |
| | | * å起确认æµç¨ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="ncæä»¶å¯¹åºæ°æ§ç¨åºå 工确认表-å起确认æµç¨", notes="ncæä»¶å¯¹åºæ°æ§ç¨åºå 工确认表-å起确认æµç¨") |
| | | @GetMapping(value = "/startGuideCardBatch") |
| | | public Result<?> startGuideCardBatch(String id){ |
| | | return guideCardBatchService.startGuideCardBatch(id); |
| | | } |
| | | |
| | | /** |
| | | * æµç¨èç¹å®¡æ ¸ |
| | | * @param guideCardBatchFlowTaskVo |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="ncæä»¶å¯¹åºæ°æ§ç¨åºå 工确认表-æµç¨èç¹å®¡æ ¸", notes="ncæä»¶å¯¹åºæ°æ§ç¨åºå 工确认表-æµç¨èç¹å®¡æ ¸") |
| | | @PostMapping(value = "/auditGuideCardBatch") |
| | | public Result<?> auditGuideCardBatch(@RequestBody GuideCardBatchFlowTaskVo guideCardBatchFlowTaskVo){ |
| | | return guideCardBatchService.auditGuideCardBatch(guideCardBatchFlowTaskVo); |
| | | } |
| | | |
| | | /** |
| | | * 导åºexcel |
| | | * |
| | | * @param request |
| | |
| | | } |
| | | |
| | | /** |
| | | * è·åå
¨é¨äº§åæ ï¼å
æ¬è®¾å¤ç±»ä¸ncæä»¶ï¼ |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "è·åå
¨é¨äº§åæ ") |
| | | @ApiOperation(value = "è·åå
¨é¨äº§åæ ", notes = "è·åå
¨é¨äº§åæ ") |
| | | @GetMapping(value = "/getAllTree") |
| | | public Result<?> getAllTree() { |
| | | List<ProductMix> productMixList = iProductMixService.getProductMixTree(); |
| | | return Result.OK(productMixList); |
| | | } |
| | | |
| | | /** |
| | | * è·åå
·ä½å±çº§å®ä½ |
| | | * @param id,type |
| | | * @return |
| | |
| | | package org.jeecg.modules.dnc.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonCreator; |
| | | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import org.jeecg.modules.dnc.entity.DocRelative; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | |
| | | @Data |
| | | @Builder |
| | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | |
| | | /**ç¼å人*/ |
| | | @Excel(name = "ç¼å人", width = 15) |
| | | @ApiModelProperty(value = "ç¼å人") |
| | | @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") |
| | | private String compiler; |
| | | /**ç¼åæ¥æ*/ |
| | | @Excel(name = "ç¼åæ¥æ", width = 15, format = "yyyy-MM-dd") |
| | |
| | | /**æ ¡å¯¹äºº*/ |
| | | @Excel(name = "æ ¡å¯¹äºº", width = 15) |
| | | @ApiModelProperty(value = "æ ¡å¯¹äºº") |
| | | @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") |
| | | private String proofreader; |
| | | /**æ ¡å¯¹æ¥æ*/ |
| | | @Excel(name = "æ ¡å¯¹æ¥æ", width = 15, format = "yyyy-MM-dd") |
| | |
| | | /**æä½è
*/ |
| | | @Excel(name = "æä½è
", width = 15) |
| | | @ApiModelProperty(value = "æä½è
") |
| | | @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") |
| | | private String operator; |
| | | /**馿£æ¥æ*/ |
| | | @Excel(name = "馿£æ¥æ", width = 15, format = "yyyy-MM-dd") |
| | |
| | | /**审æ¹äºº*/ |
| | | @Excel(name = "审æ¹äºº", width = 15) |
| | | @ApiModelProperty(value = "审æ¹äºº") |
| | | @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") |
| | | private String approver; |
| | | /**å®¡æ¹æ¥æ*/ |
| | | @Excel(name = "å®¡æ¹æ¥æ", width = 15, format = "yyyy-MM-dd") |
| | |
| | | private Date approverTime; |
| | | /**å建人*/ |
| | | @ApiModelProperty(value = "å建人") |
| | | @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") |
| | | private String createBy; |
| | | /**åå»ºæ¥æ*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
| | |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import lombok.Data; |
| | | import lombok.Getter; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Getter |
| | | @Data |
| | | @NoArgsConstructor |
| | | @TableName(value = "nc_product_mix") |
| | |
| | | //ç±»åæ¹ä¾¿å端å±ç¤º |
| | | private transient Integer type; |
| | | |
| | | |
| | | private transient List<ProductMix> children = new ArrayList<>(); |
| | | |
| | | public ProductMix(Long id, Long parentId, String treeName, String treeCode, Integer type, Date createTime) { |
| | | public ProductMix(Long id, Long parentId, String treeName, String trrCode, Integer type, Date createTime) { |
| | | this.id = id; |
| | | this.parentId = parentId; |
| | | this.treeName = treeName; |
| | | this.treeCode = treeCode; |
| | | this.treeCode = trrCode; |
| | | this.type = type; |
| | | this.children = new ArrayList<>(); |
| | | this.label="["+treeCode+"]"+treeName; |
| | | this.label="["+ trrCode +"]"+ treeName; |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | |
| | | package org.jeecg.modules.dnc.listener; |
| | | |
| | | import org.apache.commons.io.monitor.FileAlterationListener; |
| | | import org.apache.commons.io.monitor.FileAlterationObserver; |
| | | import org.jeecg.modules.dnc.dto.TransferPackage; |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.File; |
| | | import java.util.Objects; |
| | | |
| | | @Component |
| | | public class FileListener implements FileAlterationListener { |
| | |
| | | |
| | | @Autowired |
| | | private DataImportService dataImportService; |
| | | |
| | | |
| | | @Override |
| | | public void onStart(FileAlterationObserver observer) { |
| | |
| | | public void onFileCreate(File file) { |
| | | String filePath = file.getAbsolutePath(); |
| | | log.info("[æ°å»º]: {}", filePath); |
| | | // if (filePath.startsWith(fileMonitorConfig.getPaths().get(0))){ |
| | | if (filePath.endsWith(".ferry")){ |
| | | TransferPackage data = fileFerryService.importData(filePath); |
| | | dataImportService.importTransferPackage(data); |
| | | log.info("æä»¶å¯¼å
¥å®æ"); |
| | | } |
| | | // } |
| | | } |
| | | @Override |
| | | public void onFileChange(File file) { |
| | |
| | | import org.jeecg.modules.dnc.entity.ProductMix; |
| | | |
| | | public interface ProductMixMapper extends BaseMapper<ProductMix> { |
| | | @Select("SELECT * FROM nc_product_mix WHERE id = #{productId} AND tree_type = 1") |
| | | ProductMix findByProductId(@Param("productId") String productId); |
| | | |
| | | @Select("SELECT * FROM nc_product_mix WHERE id = #{componentId} AND tree_type = 2") |
| | | ProductMix findByComponentId(@Param("componentId") String componentId); |
| | | |
| | | @Select("SELECT * FROM nc_product_mix WHERE id = #{partsId} AND tree_type = 3") |
| | | ProductMix findByPartsId(@Param("partsId") String partsId); |
| | | |
| | | @Select("SELECT * FROM nc_product_mix WHERE id = #{operationId} AND tree_type = 4") |
| | | ProductMix findByOperationId(@Param("operationId") String operationId); |
| | | |
| | | @Select("SELECT * FROM nc_product_mix WHERE id = #{processId} AND tree_type = 5") |
| | | ProductMix findByProcessId(@Param("operationId") String processId); |
| | | |
| | | @Select("SELECT * FROM nc_product_mix WHERE id = #{worksiteId} AND tree_type = 6") |
| | | ProductMix findByWorksiteId(@Param("operationId") String worksiteId); |
| | | |
| | | @Select("SELECT * FROM nc_product_mix WHERE id = #{productId} AND tree_type = 1") |
| | | ProductMix findByProductId(@Param("productId") String productId); |
| | |
| | | package org.jeecg.modules.dnc.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.modules.dnc.entity.GuideCardBatch; |
| | | import org.jeecg.modules.dncFlow.vo.GuideCardBatchFlowTaskVo; |
| | | |
| | | /** |
| | | * @Description: ncæä»¶å¯¹åºæ°æ§ç¨åºå 工确认表 |
| | |
| | | * @return |
| | | */ |
| | | boolean importGuideCardBatch(String docId,String attributionId,Integer attributionType); |
| | | |
| | | /** |
| | | * å起确认æµç¨ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result<?> startGuideCardBatch(String id); |
| | | |
| | | /** |
| | | * æµç¨èç¹å®¡æ ¸ |
| | | * @param guideCardBatchFlowTaskVo |
| | | * @return |
| | | */ |
| | | Result<?> auditGuideCardBatch(GuideCardBatchFlowTaskVo guideCardBatchFlowTaskVo); |
| | | } |
| | |
| | | package org.jeecg.modules.dnc.service; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.modules.dnc.entity.ProductMix; |
| | | |
| | | import java.util.List; |
| | |
| | | public interface IProductMixService extends IService<ProductMix> { |
| | | |
| | | //è·åå°è£
产åç»ææ |
| | | List<ProductMix> getTree(); |
| | | public List<ProductMix> getTree(); |
| | | |
| | | /** |
| | | * æ¥è¯¢å¯¹åºidçææç¶çº§(æéåé
使ç¨) |
| | |
| | | */ |
| | | List<ProductMix> getChildrenList(String id); |
| | | |
| | | /** |
| | | * æ¥è¯¢äº§åç»ææ ï¼å
æ¬è®¾å¤ç±»ä¸ncæä»¶ï¼ |
| | | * @return |
| | | */ |
| | | List<ProductMix> getProductMixTree(); |
| | | } |
| | |
| | | package org.jeecg.modules.dnc.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.jeecg.weibo.exception.BusinessException; |
| | | import liquibase.pro.packaged.S; |
| | | import org.jeecg.modules.dnc.dto.ComponentHierarchy; |
| | | import org.jeecg.modules.dnc.dto.TransferPackage; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.mapper.*; |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | private GuideCardBatchMapper guideCardBatchMapper; |
| | | |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | |
| | | @Autowired |
| | | private IMdcProductionService mdcProductionService; |
| | | |
| | | @Autowired |
| | | private IProductPermissionService productPermissionService; |
| | | |
| | | @Autowired |
| | | private IProductDepartmentService productDepartmentService; |
| | | |
| | | @Autowired |
| | | private IComponentPermissionService componentPermissionService; |
| | | |
| | | @Autowired |
| | | private IComponentDepartmentService componentDepartmentService; |
| | | |
| | | @Autowired |
| | | private IPartsPermissionService partsPermissionService; |
| | | |
| | | @Autowired |
| | | private IPartsDepartmentService partsDepartmentService; |
| | | |
| | | @Autowired |
| | | private IProcessSpecVersionPermissionService processSpecVersionPermissionService; |
| | | |
| | | @Autowired |
| | | private IProcessSpecVersionDepartmentService processSpecVersionDepartmentService; |
| | | |
| | | @Autowired |
| | | private IProcessStreamPermissionService processStreamPermissionService; |
| | | |
| | | @Autowired |
| | | private IProcessionDepartmentService processionDepartmentService; |
| | | |
| | | @Autowired |
| | | private IWorkStepPermissionService workStepPermissionService; |
| | | |
| | | @Autowired |
| | | private IWorkStepDepartmentService workStepDepartmentService; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importTransferPackage(TransferPackage transferPackage) { |
| | | try { |
| | |
| | | if (transferPackage.getTraceChain() != null&& |
| | | transferPackage.getTraceChain().getTreePath() != null) { |
| | | saveTreePath(transferPackage.getTraceChain().getTreePath()); |
| | | } |
| | | |
| | | //ä¿åæé |
| | | if (transferPackage.getTraceChain() != null&& |
| | | transferPackage.getTraceChain().getPermissionStreamNewList() != null) { |
| | | savePermissionStreamNewList(transferPackage.getTraceChain().getPermissionStreamNewList()); |
| | | } |
| | | |
| | | // ä¿å设å¤ç±» |
| | |
| | | productMapper.insert(product); |
| | | logger.debug("产åå·²ä¿å: {}", product.getProductId()); |
| | | } else { |
| | | productMapper.updateById(product); |
| | | logger.debug("产åå·²æ´æ°: {}", product.getProductId()); |
| | | logger.debug("产åå·²åå¨: {}", product.getProductId()); |
| | | } |
| | | } |
| | | |
| | |
| | | componentMapper.insert(component); |
| | | logger.debug("é¨ä»¶å·²ä¿å: {}", component.getComponentId()); |
| | | } else { |
| | | componentMapper.updateById(component); |
| | | logger.debug("é¨ä»¶å·²æ´æ°: {}", component.getComponentId()); |
| | | logger.debug("é¨ä»¶å·²åå¨: {}", component.getComponentId()); |
| | | } |
| | | } |
| | | } |
| | |
| | | partsMapper.insert(parts); |
| | | logger.debug("é¶ä»¶å·²ä¿å: {}", parts.getPartsId()); |
| | | } else { |
| | | partsMapper.updateById(parts); |
| | | logger.debug("é¶ä»¶å·²æ´æ°: {}", parts.getPartsId()); |
| | | logger.debug("é¶ä»¶å·²åå¨: {}", parts.getPartsId()); |
| | | } |
| | | } |
| | | |
| | |
| | | psvMapper.insert(processSpec); |
| | | logger.debug("å·¥èºè§ç¨å·²ä¿å: {}", processSpec.getId()); |
| | | } else { |
| | | psvMapper.updateById(processSpec); |
| | | logger.debug("å·¥èºè§ç¨å·²æ´æ°: {}", processSpec.getId()); |
| | | logger.debug("å·¥èºè§ç¨å·²åå¨: {}", processSpec.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | processMapper.insert(process); |
| | | logger.debug("å·¥åºå·²ä¿å: {}", process.getProcessId()); |
| | | } else { |
| | | processMapper.updateById(process); |
| | | logger.debug("å·¥åºå·²æ´æ°: {}", process.getProcessId()); |
| | | logger.debug("å·¥åºå·²åå¨: {}", process.getProcessId()); |
| | | } |
| | | } |
| | | |
| | |
| | | workStepMapper.insert(workStep); |
| | | logger.debug("å·¥æ¥å·²ä¿å: {}", workStep.getId()); |
| | | } else { |
| | | workStepMapper.updateById(workStep); |
| | | logger.debug("å·¥æ¥å·²æ´æ°: {}", workStep.getId()); |
| | | logger.debug("å·¥æ¥å·²åå¨: {}", workStep.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | productMixMapper.insert(productMix); |
| | | logger.debug("产åç»åå·²ä¿å: {}", productMix.getId()); |
| | | } else { |
| | | productMixMapper.updateById(productMix); |
| | | logger.debug("产åç»åå·²æ´æ°: {}", productMix.getId()); |
| | | logger.debug("产åç»åå·²åå¨: {}", productMix.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void savePermissionStreamNewList(List<PermissionStreamNew> permissionStreamNewList) { |
| | | for (PermissionStreamNew permissionStreamNew : permissionStreamNewList) { |
| | | if (permissionStreamNewMapper.selectById(permissionStreamNew.getId()) == null) { |
| | | if (permissionStreamNew.getUserId() != null) { |
| | | String id=sysUserService.getUserByName(permissionStreamNew.getUserId()).getId(); |
| | | if (id!=null){ |
| | | permissionStreamNew.setUserId(id); |
| | | } |
| | | } |
| | | if (permissionStreamNew.getDepartId() != null) { |
| | | MdcProduction mdcProduction=mdcProductionService.findByOrgCode(permissionStreamNew.getDepartId()); |
| | | if (mdcProduction!=null){ |
| | | permissionStreamNew.setDepartId(mdcProduction.getId()); |
| | | } |
| | | } |
| | | permissionStreamNewMapper.insert(permissionStreamNew); |
| | | logger.debug("æéå·²ä¿å: {}", permissionStreamNew.getId()); |
| | | } |
| | | } |
| | | //åæ¹æ·»å 产åãé¨ä»¶ãé¶ä»¶ãå·¥èºè§ç¨ãå·¥åºãå·¥æ¥æé |
| | | permissionStreamNewList.forEach(item -> { |
| | | switch (item.getBusinessType()){ |
| | | case "1": |
| | | if (StrUtil.isNotEmpty(item.getUserId())){ |
| | | ProductPermission productPermission = new ProductPermission(); |
| | | productPermission.setProductId(item.getBusinessId()); |
| | | productPermission.setUserId(item.getUserId()); |
| | | productPermissionService.save(productPermission); |
| | | }else { |
| | | ProductDepartment productDepartment = new ProductDepartment(); |
| | | productDepartment.setProductId(item.getBusinessId()); |
| | | productDepartment.setDepartId(item.getDepartId()); |
| | | productDepartmentService.save(productDepartment); |
| | | } |
| | | break; |
| | | case "2": |
| | | |
| | | if (StrUtil.isNotEmpty(item.getUserId())){ |
| | | ComponentPermission componentPermission = new ComponentPermission(); |
| | | componentPermission.setComponentId(item.getBusinessId()); |
| | | componentPermission.setUserId(item.getUserId()); |
| | | componentPermissionService.save(componentPermission); |
| | | }else { |
| | | ComponentDepartment componentDepartment = new ComponentDepartment(); |
| | | componentDepartment.setComponentId(item.getBusinessId()); |
| | | componentDepartment.setDepartId(item.getDepartId()); |
| | | componentDepartmentService.save(componentDepartment); |
| | | } |
| | | break; |
| | | case "3": |
| | | if (StrUtil.isNotEmpty(item.getUserId())){ |
| | | PartsPermission partsPermission = new PartsPermission(); |
| | | partsPermission.setPartsId(item.getBusinessId()); |
| | | partsPermission.setUserId(item.getUserId()); |
| | | partsPermissionService.save(partsPermission); |
| | | }else { |
| | | PartsDepartment partsDepartment = new PartsDepartment(); |
| | | partsDepartment.setPartsId(item.getBusinessId()); |
| | | partsDepartment.setDepartId(item.getDepartId()); |
| | | partsDepartmentService.save(partsDepartment); |
| | | } |
| | | break; |
| | | case "4": |
| | | if (StrUtil.isNotEmpty(item.getUserId())){ |
| | | ProcessSpecVersionPermission processSpecVersionPermission = new ProcessSpecVersionPermission(); |
| | | processSpecVersionPermission.setPsvId(item.getBusinessId()); |
| | | processSpecVersionPermission.setUserId(item.getUserId()); |
| | | processSpecVersionPermissionService.save(processSpecVersionPermission); |
| | | }else { |
| | | ProcessSpecVersionDepartment processSpecVersionDepartment = new ProcessSpecVersionDepartment(); |
| | | processSpecVersionDepartment.setPsvId(item.getBusinessId()); |
| | | processSpecVersionDepartment.setDepartId(item.getDepartId()); |
| | | processSpecVersionDepartmentService.save(processSpecVersionDepartment); |
| | | } |
| | | break; |
| | | case "5": |
| | | if (StrUtil.isNotEmpty(item.getUserId())){ |
| | | ProcessionPermission processionPermission = new ProcessionPermission(); |
| | | processionPermission.setProcessId(item.getBusinessId()); |
| | | processionPermission.setUserId(item.getUserId()); |
| | | processStreamPermissionService.save(processionPermission); |
| | | }else { |
| | | ProcessionDepartment processionDepartment = new ProcessionDepartment(); |
| | | processionDepartment.setProcessId(item.getBusinessId()); |
| | | processionDepartment.setDepartId(item.getDepartId()); |
| | | processionDepartmentService.save(processionDepartment); |
| | | } |
| | | break; |
| | | case "6": |
| | | if (StrUtil.isNotEmpty(item.getUserId())){ |
| | | WorkStepPermission workStepPermission = new WorkStepPermission(); |
| | | workStepPermission.setStepId(item.getBusinessId()); |
| | | workStepPermission.setUserId(item.getUserId()); |
| | | workStepPermissionService.save(workStepPermission); |
| | | }else { |
| | | WorkStepDepartment workStepDepartment = new WorkStepDepartment(); |
| | | workStepDepartment.setStepId(item.getBusinessId()); |
| | | workStepDepartment.setDepartId(item.getDepartId()); |
| | | workStepDepartmentService.save(workStepDepartment); |
| | | } |
| | | break; |
| | | default: |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void saveDeviceManagement(DeviceManagement deviceManagement) { |
| | |
| | | deviceManagementMapper.insert(deviceManagement); |
| | | logger.debug("设å¤ç±»ä¿¡æ¯å·²ä¿å: {}", deviceManagement.getId()); |
| | | } else { |
| | | deviceManagementMapper.updateById(deviceManagement); |
| | | logger.debug("设å¤ç±»ä¿¡æ¯å·²æ´æ°: {}", deviceManagement.getId()); |
| | | logger.debug("设å¤ç±»ä¿¡æ¯å·²åå¨: {}", deviceManagement.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | deviceTypeMapper.insert(deviceType); |
| | | logger.debug("设å¤ç±»å·²ä¿å: {}", deviceType.getId()); |
| | | } else { |
| | | deviceTypeMapper.updateById(deviceType); |
| | | logger.debug("设å¤ç±»å·²æ´æ°: {}", deviceType.getId()); |
| | | logger.debug("设å¤ç±»å·²åå¨: {}", deviceType.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | docInfoMapper.insert(docInfo); |
| | | logger.debug("ææ¡£å·²ä¿å: {}", docInfo.getDocId()); |
| | | } else { |
| | | docInfo.setDocDispatchStatus(5); |
| | | docInfoMapper.updateById(docInfo); |
| | | logger.debug("ææ¡£å·²æ´æ°: {}", docInfo.getDocId()); |
| | | logger.debug("ææ¡£å·²åå¨: {}", docInfo.getDocId()); |
| | | } |
| | | } |
| | | |
| | |
| | | docFileMapper.insert(docFile); |
| | | logger.debug("ææ¡£æä»¶å·²ä¿å: {}", docFile.getFileId()); |
| | | } else { |
| | | docFileMapper.updateById(docFile); |
| | | logger.debug("ææ¡£æä»¶å·²æ´æ°: {}", docFile.getFileId()); |
| | | logger.debug("ææ¡£æä»¶å·²åå¨: {}", docFile.getFileId()); |
| | | } |
| | | } |
| | | |
| | |
| | | docRelativeMapper.insert(docRelative); |
| | | logger.debug("ææ¡£å¯¹åºå
³ç³»å·²ä¿å: {}", docRelative.getId()); |
| | | } else { |
| | | docRelativeMapper.updateById(docRelative); |
| | | logger.debug("ææ¡£å¯¹åºå
³ç³»å·²æ´æ°: {}", docRelative.getId()); |
| | | logger.debug("ææ¡£å¯¹åºå
³ç³»å·²åå¨: {}", docRelative.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | logger.debug("åå
·å·²ä¿å: {}", cutter.getId()); |
| | | } else { |
| | | cutterMapper.updateById(cutter); |
| | | logger.debug("åå
·å·²æ´æ°: {}", cutter.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void saveGuideCardBatch(GuideCardBatch guideCardBatch) { |
| | | if (guideCardBatchMapper.selectById(guideCardBatch.getId()) == null) { |
| | | guideCardBatch.setFlowStatus("1"); |
| | | guideCardBatchMapper.insert(guideCardBatch); |
| | | logger.debug("ç¨åºå 工确认表已ä¿å: {}", guideCardBatch.getId()); |
| | | logger.debug("åçæ¹æ¬¡å·²ä¿å: {}", guideCardBatch.getId()); |
| | | } else { |
| | | guideCardBatchMapper.updateById(guideCardBatch); |
| | | logger.debug("ç¨åºå å·¥ç¡®è®¤è¡¨å·²æ´æ°: {}", guideCardBatch.getId()); |
| | | logger.debug("åçæ¹æ¬¡å·²åå¨: {}", guideCardBatch.getId()); |
| | | } |
| | | } |
| | | } |
| | |
| | | package org.jeecg.modules.dnc.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import liquibase.pro.packaged.S; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.modules.dnc.dto.ComponentHierarchy; |
| | | import org.jeecg.modules.dnc.dto.TransferPackage; |
| | | import org.jeecg.modules.dnc.entity.ComponentInfo; |
| | | import org.jeecg.modules.dnc.entity.DocFile; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.exception.ExceptionCast; |
| | | import org.jeecg.modules.dnc.mapper.DocRelativeMapper; |
| | | import org.jeecg.modules.dnc.response.ActivitiCode; |
| | | import org.jeecg.modules.dnc.response.DocumentCode; |
| | | import org.jeecg.modules.dnc.service.IDocClassificationService; |
| | | import org.jeecg.modules.dnc.service.IDocFileService; |
| | | import org.jeecg.modules.dnc.service.IDocInfoService; |
| | | import org.jeecg.modules.dnc.service.IDocRelativeService; |
| | | import org.jeecg.modules.dnc.utils.CompressionUtils; |
| | | import org.jeecg.modules.dnc.utils.JsonUtils; |
| | | import org.jeecg.modules.dnc.utils.file.FileUtilS; |
| | | import org.jeecg.modules.dncFlow.service.IAssignFileStreamService; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.slf4j.Logger; |
| | |
| | | @Service |
| | | public class FileFerryService { |
| | | |
| | | private final DataPackageService dataPackageService; |
| | | private final SecurityService securityService; |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(FileFerryService.class); |
| | | |
| | | @Value("${deploy.secretFolder}") |
| | |
| | | private IMdcProductionService mdcProductionService; |
| | | |
| | | @Autowired |
| | | private IDocInfoService docInfoService; |
| | | |
| | | @Autowired |
| | | private IDocClassificationService classificationService; |
| | | |
| | | @Autowired |
| | | private IDocRelativeService docRelativeService; |
| | | |
| | | @Autowired |
| | | private IDocInfoService docInfoService; |
| | | |
| | | @Autowired |
| | | public FileFerryService(DataPackageService dataPackageService, SecurityService securityService) { |
| | | this.dataPackageService = dataPackageService; |
| | | this.securityService = securityService; |
| | | } |
| | | private DataPackageService dataPackageService; |
| | | |
| | | public String exportData(TransferPackage.DataType type, String id,String fileName) { |
| | | // 1. è·åå°è£
æ°æ® |
| | |
| | | throw new RuntimeException("æä»¶åå
¥å¤±è´¥", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public TransferPackage importData(String filePath) { |
| | | try { |
| | |
| | | |
| | | // 6. è·åæä»¶å¤å¶ç®æ è·¯å¾ |
| | | DocFile docFile = pkg.getTraceChain().getDocFile(); |
| | | DocInfo docInfo = pkg.getTraceChain().getDocInfo(); |
| | | if (docFile == null) { |
| | | throw new IllegalStateException("ä¼ è¾å
ä¸ç¼ºå°ææ¡£æä»¶ä¿¡æ¯"); |
| | | } |
| | |
| | | Path source = Paths.get(ncFilePath); |
| | | Files.copy(source, Paths.get(targetPath), StandardCopyOption.REPLACE_EXISTING); |
| | | |
| | | // 8. æ¥è¯¢è®¾å¤id |
| | | MdcEquipment mdcEquipment=mdcEquipmentMapper.selectOne(new QueryWrapper<MdcEquipment>().eq("equipment_id",equipmentId)); |
| | | if (mdcEquipment == null) { |
| | | throw new IllegalArgumentException("æ æç设å¤ID: " + equipmentId); |
| | | } |
| | | |
| | | // 9.ä¼ è¾æä»¶å°è®¾å¤ä¸ |
| | | List<String> strings = mdcProductionService.findListParentTreeAll(mdcEquipment.getId()); |
| | | if (strings != null && !strings.isEmpty()) { |
| | | DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(docInfo.getDocId(), 7, mdcEquipment.getId()); |
| | | if (deviceDoc == null) { |
| | | DocClassification classification = classificationService.getByCode("send"); |
| | | if(classification == null) |
| | | ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR); |
| | | DocRelative docRelative = new DocRelative(); |
| | | docRelative.setDocId(docInfo.getDocId()); |
| | | docRelative.setClassificationId(classification.getClassificationId()); |
| | | docRelative.setAttributionType(7); |
| | | docRelative.setAttributionId(mdcEquipment.getId()); |
| | | docRelativeService.save(docRelative); |
| | | } |
| | | String sendPath = StringUtils.join(strings.toArray(), "/"); |
| | | boolean copyFileNc = FileUtilS.copyFileNc(docFile.getFilePath(), sendPath + "/" + mdcEquipment.getEquipmentId(), |
| | | docFile.getFileEncodeName(), |
| | | docFile.getFileName(), docFile.getFileSuffix()); |
| | | if (!copyFileNc) { |
| | | ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); |
| | | } else { |
| | | FileUtilS.deleteZipFromToSend(sendPath + "/" + mdcEquipment.getEquipmentId(), |
| | | docFile.getFileName(), docFile.getFileSuffix()); |
| | | } |
| | | } else { |
| | | throw new RuntimeException("æä»¶ä¼ è¾è·¯å¾è·å失败"); |
| | | } |
| | | |
| | | // 10.å é¤ä¸´æ¶NCæä»¶ä¸jsonæä»¶ |
| | | logger.info("å é¤ä¸´æ¶æä»¶: {}", ncFilePath); |
| | | Files.delete(source); |
| | |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.mapper.*; |
| | | import org.jeecg.modules.dnc.service.IPermissionStreamNewService; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private CutterMapper cutterMapper; |
| | | @Autowired |
| | | private GuideCardBatchMapper guideCardBatchMapper; |
| | | @Autowired |
| | | private IPermissionStreamNewService permissionStreamNewService; |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | @Autowired |
| | | private IMdcProductionService mdcProductionService; |
| | | |
| | | public ProcessTraceChain traceFromProcess(DocRelative docRelative) { |
| | | ProcessTraceChain chain = initChainWithDocInfo(docRelative); |
| | |
| | | completeChainWithProductInfo(chain); |
| | | List<ProductMix> productMixList=buildFullTreePath(chain); |
| | | chain.setTreePath(productMixList); |
| | | chain.setPermissionStreamNewList(buildFullTreePathPermission(productMixList)); |
| | | return chain; |
| | | } |
| | | |
| | |
| | | completeChainWithProductInfo(chain); |
| | | List<ProductMix> productMixList=buildFullTreePath(chain); |
| | | chain.setTreePath(productMixList); |
| | | chain.setPermissionStreamNewList(buildFullTreePathPermission(productMixList)); |
| | | return chain; |
| | | } |
| | | |
| | |
| | | return path; |
| | | } |
| | | |
| | | private List<PermissionStreamNew> buildFullTreePathPermission(List<ProductMix> productMixList) { |
| | | List<Long> ids=productMixList.stream().map(ProductMix::getId).collect(Collectors.toList()); |
| | | List<PermissionStreamNew> path = permissionStreamNewService |
| | | .list(new QueryWrapper<PermissionStreamNew>().in("business_id",ids) |
| | | .eq("delete_flag",0)); |
| | | path.forEach(item->{ |
| | | if (item.getDepartId()!=null){ |
| | | MdcProduction mdcProduction=mdcProductionService.getById(item.getDepartId()); |
| | | if(mdcProduction!=null){ |
| | | item.setDepartId(item.getDepartId()); |
| | | } |
| | | } |
| | | if (item.getUserId()!=null){ |
| | | item.setUserId(sysUserService.getById(item.getUserId()).getUsername()); |
| | | } |
| | | }); |
| | | return path; |
| | | } |
| | | } |
| | |
| | | package org.jeecg.modules.dnc.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.flowable.engine.TaskService; |
| | | import org.flowable.task.api.Task; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.DateUtils; |
| | | import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.mapper.GuideCardBatchMapper; |
| | | import org.jeecg.modules.dnc.response.ActivitiCode; |
| | | import org.jeecg.modules.dnc.response.CommonCode; |
| | | import org.jeecg.modules.dnc.response.UcenterCode; |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.dncFlow.constant.GuideCardBatchEnum; |
| | | import org.jeecg.modules.dncFlow.entity.DispatchFile; |
| | | import org.jeecg.modules.dncFlow.vo.GuideCardBatchFlowTaskVo; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCommonService; |
| | | import org.jeecg.modules.flowable.service.IFlowDefinitionService; |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Description: ncæä»¶å¯¹åºæ°æ§ç¨åºå 工确认表 |
| | |
| | | * @Date: 2025-05-27 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class GuideCardBatchServiceImpl extends ServiceImpl<GuideCardBatchMapper, GuideCardBatch> implements IGuideCardBatchService { |
| | | @Service("IGuideCardBatchService") |
| | | public class GuideCardBatchServiceImpl extends ServiceImpl<GuideCardBatchMapper, GuideCardBatch> implements IGuideCardBatchService , FlowCallBackServiceI { |
| | | |
| | | @Autowired |
| | | private ISysDictService sysDictService; |
| | |
| | | |
| | | @Autowired |
| | | private IDeviceTypeService deviceTypeService; |
| | | |
| | | @Resource |
| | | private FlowCommonService flowCommonService; |
| | | @Resource |
| | | private IFlowDefinitionService flowDefinitionService; |
| | | @Autowired |
| | | private IFlowTaskService flowTaskService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private IFlowMyBusinessService flowMyBusinessService; |
| | | |
| | | /** |
| | | * çææµæ°´å· |
| | |
| | | guideCardBatch.setProcessWorkCode(workStep.getStepCode()); |
| | | partsInfo=partsInfoService.getById(workStep.getPartsId()); |
| | | } |
| | | if (partsInfo==null){ |
| | | return false; |
| | | } |
| | | guideCardBatch.setDocId(docId); |
| | | guideCardBatch.setSerialNumber(getSerialNumber("C140")); |
| | | guideCardBatch.setUnit(sysDictService.queryDictTextByKey("unit_code", "C140")); |
| | | guideCardBatch.setDocName(docInfo.getDocName()); |
| | | if (partsInfo!=null){ |
| | | guideCardBatch.setPartsCode(partsInfo.getPartsCode()); |
| | | guideCardBatch.setPartsName(partsInfo.getPartsName()); |
| | | guideCardBatch.setMaterielDesp(partsInfo.getStructureType()); |
| | | } |
| | | guideCardBatch.setFlowStatus("0"); |
| | | guideCardBatch.setMaterielDesp(partsInfo.getMaterielDesp()); |
| | | guideCardBatch.setCompiler(user.getUsername()); |
| | | guideCardBatch.setCreateTime(new Date()); |
| | | return this.save(guideCardBatch); |
| | | } |
| | | |
| | | /** |
| | | * å起确认æµç¨ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> startGuideCardBatch(String id){ |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | //è·åç¨åºå 工确认表 |
| | | GuideCardBatch guideCardBatch=this.getById(id); |
| | | if (guideCardBatch==null) { |
| | | return Result.ok("æªæ¾å°å¯¹åºçç¨åºå 工确认表"); |
| | | } |
| | | //å¡«å
æ°æ® |
| | | guideCardBatch.setCompiler(user.getUsername()); |
| | | guideCardBatch.setCompilerTime(new Date()); |
| | | guideCardBatch.setFlowStatus(GuideCardBatchEnum.VERIFY.getCode()); |
| | | this.updateById(guideCardBatch); |
| | | System.out.println("ç¨åºå 工确认表 确认æµç¨ï¼" + guideCardBatch.getId()); |
| | | flowCommonService.initActBusiness("æµæ°´å·ï¼"+guideCardBatch.getSerialNumber()+" ç¨åºå 工确认表è¿è¡ç¡®è®¤æµç¨", |
| | | guideCardBatch.getId(), "IGuideCardBatchService", "nc_guide_card_batch", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", guideCardBatch.getId()); |
| | | variables.put("organization", "ç¨æ·"+user.getRealname()+"åèµ·æµç¨"); |
| | | variables.put("comment", "ç¨æ·"+user.getRealname()+"åèµ·æµç¨"); |
| | | variables.put("proofreading",true); |
| | | Result result= flowDefinitionService.startProcessInstanceByKey("nc_guide_card_batch", variables); |
| | | if (!result.isSuccess()) { |
| | | guideCardBatch.setCompiler(null); |
| | | guideCardBatch.setCompilerTime(null); |
| | | this.updateById(guideCardBatch); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * æµç¨èç¹å®¡æ ¸ |
| | | * @param guideCardBatchFlowTaskVo |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> auditGuideCardBatch(GuideCardBatchFlowTaskVo guideCardBatchFlowTaskVo){ |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | try { |
| | | // åæ°æ ¡éª |
| | | if (!ValidateUtil.validateString(guideCardBatchFlowTaskVo.getTaskId()) || !ValidateUtil.validateString(guideCardBatchFlowTaskVo.getDataId())) { |
| | | return Result.error(CommonCode.INVALID_PARAM.toString()); |
| | | } |
| | | String userId = user.getId(); |
| | | guideCardBatchFlowTaskVo.setAssignee(user.getUsername()); |
| | | if (!ValidateUtil.validateString(userId)) { |
| | | return Result.error(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST.toString()); |
| | | } |
| | | |
| | | // æ°æ®æ¥è¯¢ |
| | | GuideCardBatch guideCardBatch = this.getById(guideCardBatchFlowTaskVo.getDataId()); |
| | | if (guideCardBatch == null) { |
| | | return Result.error(CommonCode.INVALID_PARAM.toString()); |
| | | } |
| | | DocInfo docInfo = docInfoService.getById(guideCardBatch.getDocId()); |
| | | if (docInfo == null) { |
| | | return Result.error(ActivitiCode.ACT_DOC_ERROR.toString()); |
| | | } |
| | | |
| | | // 2. æ¥è¯¢æµç¨ä¸å¡è®°å½ï¼å¤çç©ºç»æï¼ |
| | | List<FlowMyBusiness> businessList = flowMyBusinessService.list( |
| | | new QueryWrapper<FlowMyBusiness>() |
| | | .eq("process_instance_id", guideCardBatchFlowTaskVo.getInstanceId()) |
| | | ); |
| | | if (businessList.isEmpty()) { |
| | | return Result.error("æµç¨è®°å½ä¸åå¨"); |
| | | } |
| | | FlowMyBusiness flowMyBusiness = businessList.get(0); |
| | | |
| | | // 3. æ ¡éªç¨æ·æ¯å¦ä¸ºåéå¤ç人 |
| | | List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); |
| | | if (todoUsers == null || !todoUsers.contains(user.getUsername())) { |
| | | return Result.error("ç¨æ·æ ææä½æ¤ä»»å¡"); |
| | | } |
| | | |
| | | // 4. 认é¢ä»»å¡ï¼å¤ç已被认é¢çæ
åµï¼ |
| | | String taskId = flowMyBusiness.getTaskId(); |
| | | Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
| | | if (task == null) { |
| | | return Result.error("ä»»å¡ä¸å卿已宿"); |
| | | } |
| | | if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) { |
| | | return Result.error("ä»»å¡å·²è¢«ä»äººè®¤é¢"); |
| | | } |
| | | taskService.claim(taskId, user.getUsername()); |
| | | |
| | | // 设置æµç¨åé |
| | | Map<String, Object> values = new HashMap<>(); |
| | | values.put("dataId", guideCardBatch.getId()); |
| | | values.put("assignee", userId); |
| | | values.put("comment", guideCardBatchFlowTaskVo.getComment()); |
| | | values.put("organization", guideCardBatchFlowTaskVo.getComment()); |
| | | if (guideCardBatchFlowTaskVo.getCheckType() != null) { |
| | | values.put("checkType", guideCardBatchFlowTaskVo.getCheckType()); |
| | | } |
| | | if (guideCardBatchFlowTaskVo.getConfirmType() != null) { |
| | | values.put("confirmType", guideCardBatchFlowTaskVo.getConfirmType()); |
| | | } |
| | | if (guideCardBatchFlowTaskVo.getApproveType() != null) { |
| | | values.put("approveType", guideCardBatchFlowTaskVo.getApproveType()); |
| | | } |
| | | guideCardBatchFlowTaskVo.setValues(values); |
| | | // 宿æµç¨ä»»å¡ |
| | | Result result = flowTaskService.complete(guideCardBatchFlowTaskVo); |
| | | if (result.isSuccess()) { |
| | | if (guideCardBatchFlowTaskVo.getCheckType() != null) { |
| | | if (guideCardBatchFlowTaskVo.getCheckType()){ |
| | | guideCardBatch.setFlowStatus(GuideCardBatchEnum.CONFIRM.getCode()); |
| | | guideCardBatch.setProofreader(user.getUsername()); |
| | | guideCardBatch.setProofreaderTime(new Date()); |
| | | }else { |
| | | guideCardBatch.setFlowStatus(GuideCardBatchEnum.PREPARE.getCode()); |
| | | } |
| | | } |
| | | if (guideCardBatchFlowTaskVo.getConfirmType() != null) { |
| | | if (guideCardBatchFlowTaskVo.getConfirmType()){ |
| | | guideCardBatch.setFlowStatus(GuideCardBatchEnum.APPROVE.getCode()); |
| | | guideCardBatch.setOperator(user.getUsername()); |
| | | guideCardBatch.setInspectionTime(new Date()); |
| | | guideCardBatch.setInspectionOpinion(guideCardBatchFlowTaskVo.getInspectionOpinion()); |
| | | }else { |
| | | guideCardBatch.setFlowStatus(GuideCardBatchEnum.PREPARE.getCode()); |
| | | } |
| | | } |
| | | if (guideCardBatchFlowTaskVo.getApproveType() != null) { |
| | | if (guideCardBatchFlowTaskVo.getApproveType()){ |
| | | guideCardBatch.setFlowStatus(GuideCardBatchEnum.COMPLETE.getCode()); |
| | | guideCardBatch.setApprover(user.getUsername()); |
| | | guideCardBatch.setApproverTime(new Date()); |
| | | }else { |
| | | guideCardBatch.setFlowStatus(GuideCardBatchEnum.PREPARE.getCode()); |
| | | } |
| | | } |
| | | this.updateById(guideCardBatch); |
| | | } else { |
| | | return result; |
| | | } |
| | | return Result.OK("æä½æå"); |
| | | } catch (Exception e) { |
| | | // 设置äºå¡åæ» |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return Result.error("æä½å¤±è´¥ï¼" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void afterFlowHandle(FlowMyBusiness business) { |
| | | business.getTaskNameId();//æ¥ä¸æ¥å®¡æ¹çèç¹ |
| | | business.getValues();//åç«¯ä¼ è¿æ¥çåæ° |
| | | business.getActStatus(); |
| | | } |
| | | |
| | | @Override |
| | | public Object getBusinessDataById(String dataId) { |
| | | return this.getById(dataId); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) { |
| | | //ä¸å¡æ¯å¦å¹²é¢æµç¨ï¼ä¸å¡å¹²é¢ï¼æµç¨å¹²é¢ï¼æå®äººåè¿è¡å¤ç |
| | | return null; |
| | | } |
| | | } |
| | |
| | | package org.jeecg.modules.dnc.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.dnc.entity.ProductMix; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.mapper.ProductMixMapper; |
| | | import org.jeecg.modules.dnc.service.IPermissionStreamNewService; |
| | | import org.jeecg.modules.dnc.service.IProductMixService; |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.utils.TreeBuilder; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class ProductMixServiceImpl extends ServiceImpl<ProductMixMapper, ProductMix> implements IProductMixService { |
| | |
| | | @Autowired |
| | | private IPermissionStreamNewService permissionStreamNewService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private IDeviceTypeService deviceTypeService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private IDeviceManagementService deviceManagementService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private IDocInfoService docInfoService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private IDocRelativeService docRelativeService; |
| | | /** |
| | | * é»è®¤ç»ææ æ¥è¯¢ |
| | | * @return |
| | |
| | | return childrenList; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢äº§åç»ææ ï¼å
æ¬è®¾å¤ç±»ä¸ncæä»¶ï¼ |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ProductMix> getProductMixTree() { |
| | | LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | List<ProductMix> rawData = new ArrayList<>(); |
| | | if (loginUser.getUsername().equals("admin")) { |
| | | //ä¸éè¦æéè¿æ»¤ |
| | | rawData = permissionStreamNewService.loadProductMixAll(loginUser.getId()); |
| | | } else { |
| | | //éè¦æéè¿æ»¤ |
| | | String productIds = loginUser.getProductionIds(); |
| | | if (productIds != null && !productIds.isEmpty()) { |
| | | List<String> productIdList = Arrays.asList(productIds.split(",")); |
| | | rawData = permissionStreamNewService.loadProductMix(loginUser.getId(), productIdList); |
| | | } |
| | | } |
| | | List<Long> ids = rawData.stream() |
| | | .filter(p -> p.getType() != null) |
| | | .filter(productMix -> productMix.getType() == 5 || productMix.getType() == 6) |
| | | .map(ProductMix::getId) |
| | | .collect(Collectors.toList()); |
| | | if (ids.isEmpty()) { |
| | | return rawData; |
| | | } |
| | | //è¿æ»¤è®¾å¤ç±»å
³èä¿¡æ¯ |
| | | List<DeviceType> deviceTypeList = deviceTypeService.list(new QueryWrapper<DeviceType>() |
| | | .in("attribution_id", ids)); |
| | | List<ProductMix> productMixList = new ArrayList<>(); |
| | | deviceTypeList.forEach(item->{ |
| | | ProductMix productMix = new ProductMix(); |
| | | productMix.setId(Long.parseLong(item.getId())); |
| | | productMix.setParentId(Long.parseLong(item.getAttributionId())); |
| | | DeviceManagement deviceManagement=deviceManagementService.getById(item.getDeviceManagementId()); |
| | | productMix.setTreeCode(deviceManagement.getDeviceManagementCode()); |
| | | productMix.setTreeName(deviceManagement.getDeviceManagementName()); |
| | | productMix.setType(7); |
| | | productMixList.add(productMix); |
| | | }); |
| | | rawData.addAll(productMixList); |
| | | //è¿æ»¤ææ¡£å
³èä¿¡æ¯ |
| | | List<String> deviceTypeIds = deviceTypeList.stream().map(DeviceType::getId).collect(Collectors.toList()); |
| | | List<DocRelative> relativeList = docRelativeService.list(new QueryWrapper<DocRelative>() |
| | | .in("attribution_id", deviceTypeIds)); |
| | | List<ProductMix> docList = new ArrayList<>(); |
| | | relativeList.forEach(item->{ |
| | | ProductMix productMix = new ProductMix(); |
| | | productMix.setId(Long.parseLong(item.getId())); |
| | | productMix.setParentId(Long.parseLong(item.getAttributionId())); |
| | | DocInfo docInfo = docInfoService.getById(item.getDocId()); |
| | | productMix.setTreeCode(docInfo.getDocSuffix()); |
| | | productMix.setTreeName(docInfo.getDocName()); |
| | | productMix.setType(99); |
| | | docList.add(productMix); |
| | | }); |
| | | rawData.addAll(docList); |
| | | TreeBuilder builder = new TreeBuilder(); |
| | | TreeBuilder.CleanResult cleanResult = builder.preprocessData(rawData); |
| | | List<ProductMix> sorted = builder.topologicalSort( |
| | | cleanResult.getValidNodes(), |
| | | cleanResult.getNodeMap() |
| | | ); |
| | | List<ProductMix> result =builder.assembleTree(sorted, cleanResult.getNodeMap()); |
| | | result.sort(Comparator.comparing(ProductMix::getCreateTime, Comparator.nullsLast(Date::compareTo))); |
| | | return result; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dncFlow.adapter; |
| | | |
| | | import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; |
| | | import org.jeecg.modules.dncFlow.service.StreamTarget; |
| | | |
| | | public class AssignEquipmentFileStreamAdapter implements StreamTarget { |
| | | private final AssignEquipmentFileStream file; |
| | | |
| | | public AssignEquipmentFileStreamAdapter(AssignEquipmentFileStream file) { |
| | | this.file = file; |
| | | } |
| | | |
| | | @Override |
| | | public void setProductId(String productId) { |
| | | file.setProductId(productId); |
| | | } |
| | | |
| | | @Override |
| | | public void setComponentId(String componentId) { |
| | | file.setComponentId(componentId); |
| | | } |
| | | |
| | | @Override |
| | | public void setPartsId(String partsId) { |
| | | file.setPartsId(partsId); |
| | | } |
| | | |
| | | @Override |
| | | public void setProcessId(String processId) { |
| | | file.setProcessId(processId); |
| | | } |
| | | |
| | | @Override |
| | | public void setPsvId(String psvId) { |
| | | file.setPsvId(psvId); |
| | | } |
| | | |
| | | @Override |
| | | public void setStepId(String stepId) { |
| | | file.setStepId(stepId); |
| | | } |
| | | |
| | | @Override |
| | | public void setDeviceTypeId(String deviceTypeId) { |
| | | file.setDeviceTypeId(deviceTypeId); |
| | | } |
| | | |
| | | @Override |
| | | public String getAttributionId() { |
| | | return file.getAttributionId(); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dncFlow.constant; |
| | | |
| | | public enum DispatchFileEnum { |
| | | COMPLETE("1", "ç¼å¶"), |
| | | |
| | | VERIFY("2", "æ ¡å¯¹"), |
| | | |
| | | APPROVE("3", "æ¹å"); |
| | | |
| | | private String code; |
| | | private String name; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | DispatchFileEnum() { |
| | | } |
| | | |
| | | DispatchFileEnum(String code, String name) { |
| | | this.code = code; |
| | | this.name = name; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dncFlow.constant; |
| | | |
| | | public enum GuideCardBatchEnum { |
| | | PREPARE("1", "ç¼å¶"), |
| | | |
| | | VERIFY("2", "æ ¡å¯¹"), |
| | | |
| | | CONFIRM("3", "æä½ç¡®è®¤"), |
| | | |
| | | APPROVE("4", "审æ¹"), |
| | | |
| | | COMPLETE("5", "宿"); |
| | | |
| | | |
| | | private String code; |
| | | private String name; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | GuideCardBatchEnum() { |
| | | } |
| | | |
| | | GuideCardBatchEnum(String code, String name) { |
| | | this.code = code; |
| | | this.name = name; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dncFlow.controller; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.dnc.entity.DeviceManagement; |
| | | import org.jeecg.modules.dnc.entity.DeviceType; |
| | | import org.jeecg.modules.dnc.entity.DocInfo; |
| | | import org.jeecg.modules.dnc.entity.DocRelative; |
| | | import org.jeecg.modules.dnc.service.IDeviceManagementService; |
| | | import org.jeecg.modules.dnc.service.IDeviceTypeService; |
| | | import org.jeecg.modules.dnc.service.IDocInfoService; |
| | | import org.jeecg.modules.dnc.service.IDocRelativeService; |
| | | import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; |
| | | import org.jeecg.modules.dncFlow.service.IAssignEquipmentFileStreamService; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import com.alibaba.fastjson.JSON; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | |
| | | /** |
| | | * @Description: DNC-设å¤ç»ææ ææ´¾äº§åç»ææ |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ ") |
| | | @RestController |
| | | @RequestMapping("/dncFlow/assignEquipmentFileStream") |
| | | @Slf4j |
| | | public class AssignEquipmentFileStreamController extends JeecgController<AssignEquipmentFileStream, IAssignEquipmentFileStreamService> { |
| | | @Autowired |
| | | private IAssignEquipmentFileStreamService assignEquipmentFileStreamService; |
| | | |
| | | @Autowired |
| | | private IDeviceTypeService deviceTypeService; |
| | | |
| | | @Autowired |
| | | private IDeviceManagementService deviceManagementService; |
| | | |
| | | @Autowired |
| | | private IDocRelativeService docRelativeService; |
| | | |
| | | @Autowired |
| | | private IDocInfoService docInfoService; |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param assignEquipmentFileStream |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -å页å表æ¥è¯¢") |
| | | @ApiOperation(value="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -å页å表æ¥è¯¢", notes="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<AssignEquipmentFileStream>> queryPageList(AssignEquipmentFileStream assignEquipmentFileStream, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<AssignEquipmentFileStream> queryWrapper = QueryGenerator.initQueryWrapper(assignEquipmentFileStream, req.getParameterMap()); |
| | | Page<AssignEquipmentFileStream> page = new Page<AssignEquipmentFileStream>(pageNo, pageSize); |
| | | IPage<AssignEquipmentFileStream> pageList = assignEquipmentFileStreamService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æµç¨å¯å¨,ä¿å对åºçæ°æ® |
| | | * @param assignEquipmentFileStream |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æµç¨å¯å¨,ä¿å对åºçæ°æ®") |
| | | @ApiOperation(value="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æµç¨å¯å¨,ä¿å对åºçæ°æ®", notes="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æµç¨å¯å¨,ä¿å对åºçæ°æ®") |
| | | @PostMapping(value = "savaFlow") |
| | | public Result<?> saveAssignEquipmentFileStream(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream){ |
| | | return assignEquipmentFileStreamService.saveAssignEquipmentFileStream(assignEquipmentFileStream); |
| | | } |
| | | |
| | | /** |
| | | * æµç¨èç¹å®¡æ ¸ |
| | | * @param assignEquipmentFileStreamVo |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æµç¨èç¹å®¡æ ¸") |
| | | @ApiOperation(value="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æµç¨èç¹å®¡æ ¸", notes="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æµç¨èç¹å®¡æ ¸") |
| | | @PostMapping(value = "audit") |
| | | public Result<?> auditAssignEquipmentFileStream(@RequestBody AssignEquipmentFileStreamVo assignEquipmentFileStreamVo){ |
| | | return assignEquipmentFileStreamService.auditAssignEquipmentFileStream(assignEquipmentFileStreamVo); |
| | | } |
| | | |
| | | /** |
| | | * æ·»å |
| | | * |
| | | * @param assignEquipmentFileStream |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æ·»å ") |
| | | @ApiOperation(value="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æ·»å ", notes="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æ·»å ") |
| | | //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream) { |
| | | assignEquipmentFileStreamService.save(assignEquipmentFileStream); |
| | | return Result.OK("æ·»å æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å®¡ç¾åºæ¬ä¿¡æ¯ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "æ¥è¯¢å®¡ç¾åºæ¬ä¿¡æ¯", notes = "æ¥è¯¢å®¡ç¾åºæ¬ä¿¡æ¯") |
| | | @GetMapping(value = "/selectVoById") |
| | | public Result<?> selectVoById(@RequestParam(name="id") String id){ |
| | | List<AssignEquipmentFileStream> list = assignEquipmentFileStreamService.list(new QueryWrapper<AssignEquipmentFileStream>().eq("id", id)); |
| | | if (!list.isEmpty()){ |
| | | list.forEach(item->{ |
| | | DeviceType deviceType = deviceTypeService.getById(item.getDeviceTypeId()); |
| | | if (deviceType!=null){ |
| | | DeviceManagement deviceManagement = deviceManagementService.getById(deviceType.getDeviceManagementId()); |
| | | if (deviceManagement!=null){ |
| | | item.setDeviceTypeName(deviceManagement.getDeviceManagementName()); |
| | | } |
| | | } |
| | | DocRelative docRelative=docRelativeService.getById(item.getDocId()); |
| | | if (docRelative!=null){ |
| | | DocInfo docInfo = docInfoService.getById(docRelative.getDocId()); |
| | | item.setDocName(docInfo.getDocName()); |
| | | } |
| | | |
| | | }); |
| | | return Result.OK(list); |
| | | } |
| | | return Result.error("æªæ¾å°å¯¹åºæ°æ®"); |
| | | } |
| | | |
| | | /** |
| | | * ç¼è¾ |
| | | * |
| | | * @param assignEquipmentFileStream |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -ç¼è¾") |
| | | @ApiOperation(value="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -ç¼è¾", notes="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -ç¼è¾") |
| | | //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream) { |
| | | assignEquipmentFileStreamService.updateById(assignEquipmentFileStream); |
| | | return Result.OK("ç¼è¾æå!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idå é¤ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -éè¿idå é¤") |
| | | @ApiOperation(value="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -éè¿idå é¤", notes="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -éè¿idå é¤") |
| | | //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | assignEquipmentFileStreamService.removeById(id); |
| | | return Result.OK("å 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æ¹éå é¤") |
| | | @ApiOperation(value="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æ¹éå é¤", notes="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -æ¹éå é¤") |
| | | //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.assignEquipmentFileStreamService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("æ¹éå 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idæ¥è¯¢ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -éè¿idæ¥è¯¢") |
| | | @ApiOperation(value="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -éè¿idæ¥è¯¢", notes="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ -éè¿idæ¥è¯¢") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<AssignEquipmentFileStream> queryById(@RequestParam(name="id",required=true) String id) { |
| | | AssignEquipmentFileStream assignEquipmentFileStream = assignEquipmentFileStreamService.getById(id); |
| | | if(assignEquipmentFileStream==null) { |
| | | return Result.error("æªæ¾å°å¯¹åºæ°æ®"); |
| | | } |
| | | return Result.OK(assignEquipmentFileStream); |
| | | } |
| | | |
| | | /** |
| | | * 导åºexcel |
| | | * |
| | | * @param request |
| | | * @param assignEquipmentFileStream |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, AssignEquipmentFileStream assignEquipmentFileStream) { |
| | | return super.exportXls(request, assignEquipmentFileStream, AssignEquipmentFileStream.class, "DNC-设å¤ç»ææ ææ´¾äº§åç»ææ "); |
| | | } |
| | | |
| | | /** |
| | | * éè¿excel导å
¥æ°æ® |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("nc_assign_equipment_file_stream:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, AssignEquipmentFileStream.class); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.modules.dnc.entity.DocInfo; |
| | | import org.jeecg.modules.dnc.response.CommonCode; |
| | | import org.jeecg.modules.dnc.response.ResponseResult; |
| | | import org.jeecg.modules.dnc.service.IDocInfoService; |
| | | import org.jeecg.modules.dncFlow.entity.DispatchFile; |
| | | import org.jeecg.modules.dncFlow.service.IDispatchFileService; |
| | | import org.jeecg.modules.dncFlow.vo.DispatchFileFlowTaskVo; |
| | |
| | | |
| | | @Autowired |
| | | private IHisWorkTaskService hisWorkTaskService; |
| | | @Autowired |
| | | private IDocInfoService docInfoService; |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, DispatchFile.class); |
| | | } |
| | | @AutoLog(value = "ææ¡£è¡¨-å®åæµç¨åèµ·") |
| | | @ApiOperation(value = "ææ¡£è¡¨-å®åæµç¨åèµ·", notes = "ææ¡£è¡¨-å®åæµç¨åèµ·") |
| | | @PostMapping("/submitProccess") |
| | | public ResponseResult submitProccess(@RequestBody DispatchFile dispatchFile) { |
| | | dispatchFileService.submitProccess(dispatchFile); |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | @AutoLog(value = "ææ¡£è¡¨-ä¿¡æ¯æ¥è¯¢") |
| | | @ApiOperation(value = "ææ¡£è¡¨-ä¿¡æ¯æ¥è¯¢", notes = "ææ¡£è¡¨-ä¿¡æ¯æ¥è¯¢") |
| | | @GetMapping("/queryDocInfoByFlowDataId") |
| | | public Result<DocInfo> queryDocInfoByFlowDataId(@RequestParam("dataId") String dataId) { |
| | | DispatchFile dispatchFile = dispatchFileService.getById(dataId); |
| | | DocInfo docInfo = docInfoService.getById(dispatchFile.getDocId()); |
| | | return Result.OK(docInfo); |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dncFlow.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import java.math.BigDecimal; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | /** |
| | | * @Description: |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @TableName("nc_assign_equipment_file_stream") |
| | | @Accessors(chain = true) |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="nc_assign_equipment_file_stream对象", description="DNC-设å¤ç»ææ ææ´¾äº§åç»ææ ") |
| | | public class AssignEquipmentFileStream implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /**主é®*/ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | @ApiModelProperty(value = "主é®") |
| | | private String id; |
| | | /**设å¤ID*/ |
| | | @Excel(name = "设å¤ID", width = 15) |
| | | @ApiModelProperty(value = "设å¤ID") |
| | | @Dict(dictTable = "mdc_equipment", dicCode = "id", dicText = "equipment_id") |
| | | private String equipmentId; |
| | | /**è®¾å¤ææ¡£ID*/ |
| | | @Excel(name = "è®¾å¤ææ¡£ID", width = 15) |
| | | @ApiModelProperty(value = "è®¾å¤ææ¡£ID") |
| | | @Dict(dictTable = "nc_doc_info", dicCode = "doc_id", dicText = "doc_name") |
| | | private String equipmentDocId; |
| | | /**è®¾å¤æä»¶ID*/ |
| | | @Excel(name = "è®¾å¤æä»¶ID", width = 15) |
| | | @ApiModelProperty(value = "è®¾å¤æä»¶ID") |
| | | private String equipmentFileId; |
| | | /**产åID*/ |
| | | @Excel(name = "产åID", width = 15) |
| | | @ApiModelProperty(value = "产åID") |
| | | @Dict(dictTable = "nc_product_info", dicCode = "product_id", dicText = "product_name") |
| | | private String productId; |
| | | /**é¨ä»¶ID*/ |
| | | @Excel(name = "é¨ä»¶ID", width = 15) |
| | | @ApiModelProperty(value = "é¨ä»¶ID") |
| | | @Dict(dictTable = "nc_component_info", dicCode = "component_id", dicText = "component_name") |
| | | private String componentId; |
| | | /**é¶ä»¶ID*/ |
| | | @Excel(name = "é¶ä»¶ID", width = 15) |
| | | @ApiModelProperty(value = "é¶ä»¶ID") |
| | | @Dict(dictTable = "nc_parts_info", dicCode = "parts_id", dicText = "parts_name") |
| | | private String partsId; |
| | | /**å·¥èºè§ç¨çæ¬ID*/ |
| | | @Excel(name = "å·¥èºè§ç¨çæ¬ID", width = 15) |
| | | @ApiModelProperty(value = "å·¥èºè§ç¨çæ¬ID") |
| | | @Dict(dictTable = "nc_process_spec_version", dicCode = "id", dicText = "process_spec_version_name") |
| | | private String psvId; |
| | | /**å·¥åºID*/ |
| | | @Excel(name = "å·¥åºID", width = 15) |
| | | @ApiModelProperty(value = "å·¥åºID") |
| | | @Dict(dictTable = "nc_process_stream", dicCode = "process_id", dicText = "process_name") |
| | | private String processId; |
| | | /**å·¥æ¥ID*/ |
| | | @Excel(name = "å·¥æ¥ID", width = 15) |
| | | @ApiModelProperty(value = "å·¥æ¥ID") |
| | | @Dict(dictTable = "nc_work_step", dicCode = "id", dicText = "step_name") |
| | | private String stepId; |
| | | /**设å¤ç±»ID*/ |
| | | @Excel(name = "设å¤ç±»ID", width = 15) |
| | | @ApiModelProperty(value = "设å¤ç±»ID") |
| | | private String deviceTypeId; |
| | | /**äº§åææ¡£id*/ |
| | | @Excel(name = "äº§åææ¡£id", width = 15) |
| | | @ApiModelProperty(value = "äº§åææ¡£id") |
| | | @Dict(dictTable = "nc_doc_info", dicCode = "doc_id", dicText = "doc_name") |
| | | private String docId; |
| | | /**ææ´¾åå */ |
| | | @Excel(name = "ææ´¾åå ", width = 15) |
| | | @ApiModelProperty(value = "ææ´¾åå ") |
| | | private String applyReason; |
| | | /**å®¡æ ¸ç±»å*/ |
| | | @Excel(name = "å®¡æ ¸ç±»å", width = 15) |
| | | @ApiModelProperty(value = "å®¡æ ¸ç±»å") |
| | | private String auditType; |
| | | /**å®¡æ ¸æè§*/ |
| | | @Excel(name = "å®¡æ ¸æè§", width = 15) |
| | | @ApiModelProperty(value = "å®¡æ ¸æè§") |
| | | private String auditReason; |
| | | /**å建人*/ |
| | | @ApiModelProperty(value = "å建人") |
| | | private String createBy; |
| | | /**åå»ºæ¥æ*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty(value = "åå»ºæ¥æ") |
| | | private Date createTime; |
| | | /**æ´æ°äºº*/ |
| | | @ApiModelProperty(value = "æ´æ°äºº") |
| | | private String updateBy; |
| | | /**æ´æ°æ¥æ*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty(value = "æ´æ°æ¥æ") |
| | | private Date updateTime; |
| | | /**æå±é¨é¨*/ |
| | | @ApiModelProperty(value = "æå±é¨é¨") |
| | | private String sysOrgCode; |
| | | |
| | | /**设å¤ç±»åç§°*/ |
| | | private transient String deviceTypeName; |
| | | |
| | | /**产åæä»¶åç§°*/ |
| | | private transient String docName; |
| | | |
| | | /**æå±id*/ |
| | | private transient String attributionId; |
| | | |
| | | /**æå±type*/ |
| | | private transient String attributionType; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dncFlow.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * @Description: DNC-设å¤ç»ææ ææ´¾äº§åç»ææ |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface AssignEquipmentFileStreamMapper extends BaseMapper<AssignEquipmentFileStream> { |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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="org.jeecg.modules.dncFlow.mapper.AssignEquipmentFileStreamMapper"> |
| | | |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dncFlow.service; |
| | | |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; |
| | | |
| | | /** |
| | | * @Description: DNC-设å¤ç»ææ ææ´¾äº§åç»ææ |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IAssignEquipmentFileStreamService extends IService<AssignEquipmentFileStream> { |
| | | |
| | | /** |
| | | * æµç¨å¯å¨,ä¿å对åºçæ°æ® |
| | | * @param assignEquipmentFileStream |
| | | * @return |
| | | */ |
| | | Result<?> saveAssignEquipmentFileStream(AssignEquipmentFileStream assignEquipmentFileStream); |
| | | |
| | | /** |
| | | * æµç¨èç¹å®¡æ ¸ |
| | | * @param assignEquipmentFileStreamVo |
| | | * @return |
| | | */ |
| | | Result<?> auditAssignEquipmentFileStream(AssignEquipmentFileStreamVo assignEquipmentFileStreamVo); |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.modules.dnc.entity.DocInfo; |
| | | import org.jeecg.modules.dncFlow.entity.DispatchFile; |
| | | import org.jeecg.modules.dncFlow.vo.DispatchFileFlowTaskVo; |
| | | |
| | |
| | | * @param id |
| | | */ |
| | | Result<?> queryDispatchFile(String id); |
| | | |
| | | /** |
| | | * å®åæµç¨ |
| | | */ |
| | | Result<?> submitProccess(DispatchFile dispatchFile); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dncFlow.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.flowable.engine.TaskService; |
| | | import org.flowable.task.api.Task; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.dnc.constant.DncPassLogPassType; |
| | | import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; |
| | | import org.jeecg.modules.dnc.dto.TransferPackage; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.exception.ExceptionCast; |
| | | import org.jeecg.modules.dnc.response.ActivitiCode; |
| | | import org.jeecg.modules.dnc.response.CommonCode; |
| | | import org.jeecg.modules.dnc.response.DocumentCode; |
| | | import org.jeecg.modules.dnc.response.UcenterCode; |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.service.impl.FileFerryService; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.dnc.utils.date.DateUtil; |
| | | import org.jeecg.modules.dnc.utils.file.FileUtilS; |
| | | import org.jeecg.modules.dncFlow.constant.GuideCardBatchEnum; |
| | | import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; |
| | | import org.jeecg.modules.dncFlow.entity.DispatchFile; |
| | | import org.jeecg.modules.dncFlow.mapper.AssignEquipmentFileStreamMapper; |
| | | import org.jeecg.modules.dncFlow.service.IAssignEquipmentFileStreamService; |
| | | import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCommonService; |
| | | import org.jeecg.modules.flowable.service.IFlowDefinitionService; |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.transaction.NoTransactionException; |
| | | import org.springframework.transaction.TransactionStatus; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Description: DNC-设å¤ç»ææ ææ´¾äº§åç»ææ |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service("IAssignEquipmentFileStreamService") |
| | | public class AssignEquipmentFileStreamServiceImpl extends ServiceImpl<AssignEquipmentFileStreamMapper, AssignEquipmentFileStream> implements IAssignEquipmentFileStreamService , FlowCallBackServiceI { |
| | | |
| | | @Autowired |
| | | private IDocInfoService docInfoService; |
| | | @Autowired |
| | | private IDocFileService docFileService; |
| | | @Autowired |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | @Autowired |
| | | private IGuideCardBatchService iGuideCardBatchService; |
| | | @Resource |
| | | private FlowCommonService flowCommonService; |
| | | @Resource |
| | | private IFlowDefinitionService flowDefinitionService; |
| | | @Autowired |
| | | private IFlowTaskService flowTaskService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private IFlowMyBusinessService flowMyBusinessService; |
| | | @Autowired |
| | | private IDocRelativeService docRelativeService; |
| | | @Autowired |
| | | private IDeviceTypeService deviceTypeService; |
| | | @Autowired |
| | | private PermissionService permissionService; |
| | | /** |
| | | * æµç¨å¯å¨,ä¿å对åºçæ°æ® |
| | | * @param assignEquipmentFileStream |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result<?> saveAssignEquipmentFileStream(AssignEquipmentFileStream assignEquipmentFileStream){ |
| | | //åæ°æ ¡éª |
| | | checkParam(assignEquipmentFileStream); |
| | | //è·åè®¾å¤ |
| | | MdcEquipment equipment = mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId()); |
| | | if(equipment==null){ |
| | | return Result.error("æªåç°è¯¥è®¾å¤"); |
| | | } |
| | | //è·åè®¾å¤ææ¡£ä¿¡æ¯ |
| | | DocInfo docInfo =docInfoService.getById(assignEquipmentFileStream.getEquipmentDocId()); |
| | | if(docInfo==null){ |
| | | return Result.error("æªåç°è¯¥è®¾å¤å¯¹åºææ¡£"); |
| | | } |
| | | //è·åè®¾å¤æä»¶ä¿¡æ¯ |
| | | DocFile docFile =docFileService.getById(assignEquipmentFileStream.getEquipmentFileId()); |
| | | if(docFile==null){ |
| | | return Result.error("æªåç°è¯¥è®¾å¤å¯¹åºæä»¶"); |
| | | } |
| | | //è·åäº§åææ¡£ä¿¡æ¯ |
| | | DocRelative docRelative=docRelativeService.getById(assignEquipmentFileStream.getDocId()); |
| | | //è·å对åºè®¾å¤ç±» |
| | | DeviceType deviceType = deviceTypeService.getById(docRelative.getAttributionId()); |
| | | if(deviceType!=null){ |
| | | assignEquipmentFileStream.setDeviceTypeId(deviceType.getId()); |
| | | assignEquipmentFileStream.setAttributionId(deviceType.getAttributionId()); |
| | | assignEquipmentFileStream.setAttributionType(deviceType.getAttributionType().toString()); |
| | | PermissionStreamNew permissionStreamNew=permissionService.getPermissionStreams(assignEquipmentFileStream); |
| | | if(permissionStreamNew==null){ |
| | | return Result.error("ç¨æ·æ ææä½æ¤ä»»å¡"); |
| | | } |
| | | } |
| | | DocInfo productDocInfo =docInfoService.getById(docRelative.getDocId()); |
| | | if(productDocInfo==null){ |
| | | return Result.error("æªåç°è¯¥äº§åç»ææ å¯¹åºææ¡£"); |
| | | } |
| | | //è·åäº§åææ¡£ä¿¡æ¯å¯¹åºææ°ç¨åºå 工确认表 |
| | | List<GuideCardBatch> batches = iGuideCardBatchService.list( |
| | | new QueryWrapper<GuideCardBatch>() |
| | | .eq("doc_id", productDocInfo.getDocId()) |
| | | .eq("flow_status", GuideCardBatchEnum.COMPLETE.getCode()) |
| | | .orderByDesc("SUBSTRING(serial_number, LEN(serial_number)-3, 4)")); |
| | | if(CollectionUtils.isEmpty(batches)){ |
| | | return Result.error("è¯¥ææ¡£å¯¹åºçç¨åºå å·¥ç¡®è®¤è¡¨å®¡æ¹æªéè¿ï¼ä¸è½è¿è¡åç"); |
| | | } |
| | | this.save(assignEquipmentFileStream); |
| | | System.out.println("设å¤ç»ææ ææ´¾äº§åç»ææ ï¼" + assignEquipmentFileStream.getId()); |
| | | flowCommonService.initActBusiness("设å¤ç»ææ ææ´¾äº§åç»ææ :"+docInfo.getDocName()+"->"+productDocInfo.getDocName(), |
| | | assignEquipmentFileStream.getId(), "IAssignEquipmentFileStreamService", "nc_assign_equipment_file_stream", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", assignEquipmentFileStream.getId()); |
| | | variables.put("organization", assignEquipmentFileStream.getApplyReason()); |
| | | variables.put("comment", assignEquipmentFileStream.getApplyReason()); |
| | | variables.put("proofreading",true); |
| | | Result result= flowDefinitionService.startProcessInstanceByKey("nc_assign_equipment_file_stream", variables); |
| | | if (!result.isSuccess()) { |
| | | super.removeById(assignEquipmentFileStream.getId()); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * æµç¨èç¹å®¡æ ¸ |
| | | * @param assignEquipmentFileStreamVo |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Result<?> auditAssignEquipmentFileStream(AssignEquipmentFileStreamVo assignEquipmentFileStreamVo){ |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | try { |
| | | // åæ°æ ¡éª |
| | | if (!ValidateUtil.validateString(assignEquipmentFileStreamVo.getTaskId()) || !ValidateUtil.validateString(assignEquipmentFileStreamVo.getDataId())) { |
| | | return Result.error(CommonCode.INVALID_PARAM.toString()); |
| | | } |
| | | String userId = user.getId(); |
| | | assignEquipmentFileStreamVo.setAssignee(user.getUsername()); |
| | | if (!ValidateUtil.validateString(userId)) { |
| | | return Result.error(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST.toString()); |
| | | } |
| | | |
| | | // æ°æ®æ¥è¯¢ |
| | | AssignEquipmentFileStream assignEquipmentFileStream = this.getById(assignEquipmentFileStreamVo.getDataId()); |
| | | if (assignEquipmentFileStream == null) { |
| | | return Result.error(CommonCode.INVALID_PARAM.toString()); |
| | | } |
| | | //è·åè®¾å¤ |
| | | MdcEquipment equipment = mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId()); |
| | | if(equipment==null){ |
| | | return Result.error("æªåç°è¯¥è®¾å¤"); |
| | | } |
| | | //è·åè®¾å¤ææ¡£ä¿¡æ¯ |
| | | DocInfo docInfo =docInfoService.getById(assignEquipmentFileStream.getEquipmentDocId()); |
| | | if(docInfo==null){ |
| | | return Result.error("æªåç°è¯¥è®¾å¤å¯¹åºææ¡£"); |
| | | } |
| | | //è·åè®¾å¤æä»¶ä¿¡æ¯ |
| | | DocFile docFile =docFileService.getById(assignEquipmentFileStream.getEquipmentFileId()); |
| | | if(docFile==null){ |
| | | return Result.error("æªåç°è¯¥è®¾å¤å¯¹åºæä»¶"); |
| | | } |
| | | //è·åäº§åææ¡£ä¿¡æ¯ |
| | | DocRelative docRelative=docRelativeService.getById(assignEquipmentFileStream.getDocId()); |
| | | DocInfo productDocInfo =docInfoService.getById(docRelative.getDocId()); |
| | | if(productDocInfo==null){ |
| | | return Result.error("æªåç°è¯¥äº§åç»ææ å¯¹åºææ¡£"); |
| | | } |
| | | //è·åè®¾å¤ |
| | | MdcEquipment mdcEquipment =mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId()); |
| | | if (mdcEquipment==null){ |
| | | return Result.error("æªåç°è¯¥è®¾å¤"); |
| | | } |
| | | // 2. æ¥è¯¢æµç¨ä¸å¡è®°å½ï¼å¤çç©ºç»æï¼ |
| | | List<FlowMyBusiness> businessList = flowMyBusinessService.list( |
| | | new QueryWrapper<FlowMyBusiness>() |
| | | .eq("process_instance_id", assignEquipmentFileStreamVo.getInstanceId()) |
| | | ); |
| | | if (businessList.isEmpty()) { |
| | | return Result.error("æµç¨è®°å½ä¸åå¨"); |
| | | } |
| | | FlowMyBusiness flowMyBusiness = businessList.get(0); |
| | | |
| | | // 3. æ ¡éªç¨æ·æ¯å¦ä¸ºåéå¤ç人 |
| | | List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); |
| | | if (todoUsers == null || !todoUsers.contains(user.getUsername())) { |
| | | return Result.error("ç¨æ·æ ææä½æ¤ä»»å¡"); |
| | | } |
| | | |
| | | // 4. 认é¢ä»»å¡ï¼å¤ç已被认é¢çæ
åµï¼ |
| | | String taskId = flowMyBusiness.getTaskId(); |
| | | Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
| | | if (task == null) { |
| | | return Result.error("ä»»å¡ä¸å卿已宿"); |
| | | } |
| | | if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) { |
| | | return Result.error("ä»»å¡å·²è¢«ä»äººè®¤é¢"); |
| | | } |
| | | taskService.claim(taskId, user.getUsername()); |
| | | |
| | | // 设置æµç¨åé |
| | | Map<String, Object> values = new HashMap<>(); |
| | | values.put("dataId", assignEquipmentFileStream.getId()); |
| | | values.put("assignee", userId); |
| | | values.put("comment", assignEquipmentFileStreamVo.getComment()); |
| | | values.put("organization", assignEquipmentFileStreamVo.getComment()); |
| | | assignEquipmentFileStreamVo.setValues(values); |
| | | // 宿æµç¨ä»»å¡ |
| | | Result result = flowTaskService.complete(assignEquipmentFileStreamVo); |
| | | if (result.isSuccess()) { |
| | | this.updateById(assignEquipmentFileStream); |
| | | if (assignEquipmentFileStreamVo.getAuditType().equals("1")) { |
| | | //1.产åç»ææ ncæä»¶è¿è¡åç |
| | | DocFile productDocFile = new DocFile(); |
| | | productDocFile.setDocId(productDocInfo.getDocId()); |
| | | productDocFile.setFileName(docFile.getFileName()); |
| | | productDocFile.setFileEncodeName(docFile.getFileEncodeName()); |
| | | productDocFile.setFilePath(docFile.getFilePath()); |
| | | productDocFile.setFileSize(docFile.getFileSize()); |
| | | productDocFile.setFileSuffix(docFile.getFileSuffix()); |
| | | docFileService.addDocFile(productDocFile); |
| | | productDocInfo.setPublishVersion(productDocFile.getDocVersion()); |
| | | productDocInfo.setPublishFileId(productDocFile.getFileId()); |
| | | docInfoService.updateById(productDocInfo); |
| | | } |
| | | } else { |
| | | return result; |
| | | } |
| | | return Result.OK("æä½æå"); |
| | | } catch (Exception e) { |
| | | try { |
| | | TransactionStatus transactionStatus = TransactionAspectSupport.currentTransactionStatus(); |
| | | if (!transactionStatus.isCompleted()) { |
| | | transactionStatus.setRollbackOnly(); |
| | | } |
| | | } catch (NoTransactionException ex) { |
| | | // å¿½ç¥æ äºå¡çå¼å¸¸ |
| | | } |
| | | log.error("å®¡æ ¸å¤±è´¥", e); |
| | | return Result.error("æä½å¤±è´¥ï¼" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | //ä¼ åéªè¯ |
| | | public boolean checkParam(AssignEquipmentFileStream assignEquipmentFileStream) { |
| | | if (assignEquipmentFileStream == null) { |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | } |
| | | if (!ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentId()) || !ValidateUtil.validateString(assignEquipmentFileStream.getDocId()) |
| | | || !ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentFileId()) || !ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentDocId())) { |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | } |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | if (!ValidateUtil.validateString(userId)) { |
| | | ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void afterFlowHandle(FlowMyBusiness business) { |
| | | business.getTaskNameId();//æ¥ä¸æ¥å®¡æ¹çèç¹ |
| | | business.getValues();//åç«¯ä¼ è¿æ¥çåæ° |
| | | business.getActStatus(); |
| | | } |
| | | |
| | | @Override |
| | | public Object getBusinessDataById(String dataId) { |
| | | return this.getById(dataId); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) { |
| | | //ä¸å¡æ¯å¦å¹²é¢æµç¨ï¼ä¸å¡å¹²é¢ï¼æµç¨å¹²é¢ï¼æå®äººåè¿è¡å¤ç |
| | | return null; |
| | | } |
| | | } |
| | |
| | | import org.flowable.task.api.Task; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.dnc.entity.DocInfo; |
| | | import org.jeecg.modules.dnc.entity.PermissionStreamNew; |
| | | import org.jeecg.modules.dnc.constant.DncPassLogPassType; |
| | | import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; |
| | | import org.jeecg.modules.dnc.dto.TransferPackage; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.exception.ExceptionCast; |
| | | import org.jeecg.modules.dnc.mapper.DocInfoMapper; |
| | | import org.jeecg.modules.dnc.request.DocInfoQueryRequest; |
| | | import org.jeecg.modules.dnc.response.ActivitiCode; |
| | | import org.jeecg.modules.dnc.response.CommonCode; |
| | | import org.jeecg.modules.dnc.response.UcenterCode; |
| | | import org.jeecg.modules.dnc.service.IDocInfoService; |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.service.impl.FileFerryService; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.dnc.utils.date.DateUtil; |
| | | import org.jeecg.modules.dnc.utils.file.FileUtilS; |
| | | import org.jeecg.modules.dncFlow.entity.DispatchFile; |
| | | import org.jeecg.modules.dncFlow.mapper.DispatchFileMapper; |
| | | import org.jeecg.modules.dncFlow.service.IDispatchFileService; |
| | |
| | | import org.jeecg.modules.flowable.service.IFlowDefinitionService; |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.flowable.service.IHisWorkTaskService; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.ISysUserRoleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.nio.file.StandardCopyOption; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private IFlowMyBusinessService flowMyBusinessService; |
| | | @Autowired |
| | | private DocInfoMapper docInfoMapper; |
| | | @Autowired |
| | | private ISysUserRoleService sysUserRoleService; |
| | | @Autowired |
| | | private PermissionService permissionService; |
| | | @Autowired |
| | | private IHisWorkTaskService hisWorkTaskService; |
| | | @Autowired |
| | | private IDeviceTypeService deviceTypeService; |
| | | @Autowired |
| | | private IDeviceManagementService deviceManagementService; |
| | | @Autowired |
| | | private IDncPassLogService dncPassLogService; |
| | | @Autowired |
| | | private IDocFileService docFileService; |
| | | @Autowired |
| | | private IDocRelativeService docRelativeService; |
| | | @Autowired |
| | | @Lazy |
| | | private FileFerryService ferryService; |
| | | @Value("${deploy.secretFolder}") |
| | | private String secretFolder; //å·¥æ§ç½ä¼ è¾ncæä»¶å¤¹ |
| | | @Value("${fileHomePath}") |
| | | private String fileHomePath; |
| | | |
| | | /** |
| | | * æµç¨å¯å¨,ä¿å对åºçæ°æ® |
| | | * @param dispatchFile |
| | |
| | | List<DocInfo> docInfoList = docInfoService.findList(docInfoQueryRequest); |
| | | return Result.OK(docInfoList); |
| | | } |
| | | /** |
| | | * åèµ·å®åæµç¨ |
| | | */ |
| | | @Override |
| | | public Result<?> submitProccess(DispatchFile dispatchFile) { |
| | | checkParam(dispatchFile); |
| | | //è·åæä»¶ä¿¡æ¯ |
| | | DocInfo docInfo = docInfoService.getById(dispatchFile.getDocId()); |
| | | PermissionStreamNew permissionStreams = getPermissionStreams(dispatchFile); |
| | | if (permissionStreams==null){ |
| | | return Result.error("ç¨æ·æ²¡ææé"); |
| | | } |
| | | super.save(dispatchFile); |
| | | flowCommonService.initActBusiness(docInfo.getDocName()+"."+docInfo.getDocSuffix()+"æä»¶è¿è¡å®å", |
| | | dispatchFile.getId(), "IDispatchFileService", "process_rf27duhy", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", dispatchFile.getId()); |
| | | variables.put("organization", "导å
¥ææ¡£é»è®¤å¯å¨æµç¨"); |
| | | variables.put("comment", "导å
¥ææ¡£é»è®¤å¯å¨æµç¨"); |
| | | variables.put("proofreading",true); |
| | | Result result= flowDefinitionService.startProcessInstanceByKey("process_rf27duhy", variables); |
| | | if (!result.isSuccess()) |
| | | super.removeById(dispatchFile.getId()); |
| | | return result; |
| | | } |
| | | |
| | | private Map<String, Object> setProcessVariables(DispatchFile dispatchFile, String userId, DispatchFileFlowTaskVo dispatchFileFlowTaskVo) { |
| | | Map<String, Object> values = new HashMap<>(); |
| | |
| | | return values; |
| | | } |
| | | |
| | | private void updateStatus(DispatchFile dispatchFile, DocInfo docInfo, DispatchFileFlowTaskVo dispatchFileFlowTaskVo) { |
| | | private void updateStatus(DispatchFile dispatchFile, DocInfo docInfo, DispatchFileFlowTaskVo dispatchFileFlowTaskVo) throws IOException { |
| | | if (StrUtil.isNotBlank(dispatchFileFlowTaskVo.getProofreadStatus())) { |
| | | switch (dispatchFileFlowTaskVo.getProofreadStatus()) { |
| | | case "1": |
| | |
| | | if (dispatchFileFlowTaskVo.getStereotype() != null && dispatchFileFlowTaskVo.getStereotype()) { |
| | | dispatchFile.setCurrentNode("5"); |
| | | docInfo.setDocDispatchStatus(5); |
| | | //å®åéè¿ |
| | | DeviceType deviceType=deviceTypeService.getById(dispatchFile.getDeviceTypeId()); |
| | | DeviceManagement deviceManagement=deviceManagementService.getById(deviceType.getDeviceManagementId()); |
| | | DocFile docFile=docFileService.getById(dispatchFile.getFileId()); |
| | | DocRelative docRelative=docRelativeService.getOne(new QueryWrapper<DocRelative>().eq("doc_id",docInfo.getDocId()) |
| | | .eq("attribution_id",dispatchFile.getAttributionId()).eq("attribution_type",dispatchFile.getAttributionType())); |
| | | handleFileProcessing(docFile,deviceManagement,secretFolder); |
| | | handleProductTree(docInfo,docRelative,deviceManagement); |
| | | } |
| | | } |
| | | |
| | | |
| | | //å°è£
å¤çæä»¶ |
| | | private void handleFileProcessing(DocFile docFile, DeviceManagement deviceManagement, String secretFolder) throws IOException { |
| | | if (!docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) { |
| | | DncPassLog passInfoTxt = new DncPassLog(); |
| | | Date dateFirst = DateUtil.getNow(); |
| | | passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); |
| | | /*æ¥è¯¢æå䏿¡è®°å½*/ |
| | | //ä¼ç 500æ¯«ç§ |
| | | DncPassLog dncPassLog = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); |
| | | int fileNc =0; |
| | | if (dncPassLog !=null) { |
| | | fileNc = dncPassLog.getSequenceNumber() + 1; |
| | | } else { |
| | | fileNc = 1; |
| | | } |
| | | //å¤çæä»¶åç§° æä»¶è·¯å¾ |
| | | String sequenceNc = String.format("%06d",fileNc); |
| | | DncPassLog passInfoNc = new DncPassLog(); |
| | | passInfoNc.setSequenceNumber(fileNc); |
| | | passInfoNc.setSequenceOrder(sequenceNc); |
| | | passInfoNc.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); |
| | | passInfoNc.setPassType(DncPassLogPassType.NCFILE.getCode()); |
| | | passInfoNc.setPassName(docFile.getFileName()); |
| | | try { |
| | | Thread.sleep(1000); |
| | | Date date = new Date(); |
| | | passInfoNc.setCreateTime(date); |
| | | System.out.println(DateUtil.format(date,DateUtil.STR_DATE_TIME)); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | dncPassLogService.save(passInfoNc); |
| | | // 4. æ§è¡æä»¶æä½,åç¼ä¸ºNC |
| | | Path source = Paths.get(fileHomePath+docFile.getFilePath(), docFile.getFileEncodeName()); |
| | | String destFileName = "10A" + DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequenceNc + "_" + deviceManagement.getDeviceManagementCode()+".NC"; |
| | | Path destination = Paths.get(secretFolder, destFileName); |
| | | Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¤ç对åºäº§åç»ææ ãncæä»¶ãåå
·å表ãç¨åºå 工确认表å°è£
|
| | | * @param docInfo |
| | | */ |
| | | private void handleProductTree(DocInfo docInfo, DocRelative docRelative, DeviceManagement deviceManagement) { |
| | | /*æ¥è¯¢æå䏿¡è®°å½*/ |
| | | //ä¼ç 500æ¯«ç§ |
| | | DncPassLog passInfoTxt = new DncPassLog(); |
| | | Date dateFirst = DateUtil.getNow(); |
| | | passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); |
| | | DncPassLog dncPassLog = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); |
| | | int fileTxt = 0, fileNc =0; |
| | | if (dncPassLog !=null) { |
| | | fileTxt = dncPassLog.getSequenceNumber() + 1; |
| | | } else { |
| | | fileTxt = 1; |
| | | } |
| | | String sequence = String.format("%06d",fileTxt); |
| | | passInfoTxt.setSequenceNumber(fileTxt); |
| | | passInfoTxt.setCreateTime(dateFirst); |
| | | passInfoTxt.setSequenceOrder(sequence); |
| | | System.out.println(DateUtil.format(dateFirst,DateUtil.STR_DATE_TIME)); |
| | | passInfoTxt.setPassType(DncPassLogPassType.PRODUCTSTRUCTURE.getCode()); |
| | | dncPassLogService.save(passInfoTxt); |
| | | String fileName="10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY); |
| | | if (Objects.equals(docInfo.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode())){ |
| | | //å·¥åºå¯¹åºè®¾å¤ç±» |
| | | String filePath = ferryService.exportData(TransferPackage.DataType.PROCESS, docRelative.getId(),fileName+sequence+"_"+deviceManagement.getDeviceManagementCode()+".ferry"); |
| | | System.out.println("å·¥åºæ°æ®å·²å¯¼åº: " + filePath); |
| | | }else { |
| | | //å·¥æ¥å¯¹åºè®¾å¤ç±» |
| | | String filePath = ferryService.exportData(TransferPackage.DataType.WORKSTEP, docRelative.getId(),fileName+sequence+"_"+deviceManagement.getDeviceManagementCode()+".ferry"); |
| | | System.out.println("å·¥æ¥æ°æ®å·²å¯¼åº: " + filePath); |
| | | } |
| | | } |
| | | |
| | | |
| | | //ä¼ åéªè¯ |
| | | public boolean checkParam(DispatchFile dispatchFile) { |
| | | if (dispatchFile == null) { |
| | |
| | | import org.jeecg.modules.dnc.exception.ExceptionCast; |
| | | import org.jeecg.modules.dnc.response.ActivitiCode; |
| | | import org.jeecg.modules.dnc.service.IDeviceTypeService; |
| | | import org.jeecg.modules.dncFlow.adapter.AssignEquipmentFileStreamAdapter; |
| | | import org.jeecg.modules.dncFlow.adapter.AssignFileStreamAdapter; |
| | | import org.jeecg.modules.dncFlow.adapter.DispatchFileAdapter; |
| | | import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; |
| | | import org.jeecg.modules.dncFlow.entity.AssignFileStream; |
| | | import org.jeecg.modules.dncFlow.entity.DispatchFile; |
| | | import org.jeecg.modules.dncFlow.handler.*; |
| | |
| | | return processInternal(new AssignFileStreamAdapter(stream), stream.getAttributionType()); |
| | | } |
| | | |
| | | public PermissionStreamNew getPermissionStreams(AssignEquipmentFileStream stream) { |
| | | return processInternal(new AssignEquipmentFileStreamAdapter(stream), stream.getAttributionType()); |
| | | } |
| | | |
| | | private PermissionStreamNew processInternal(StreamTarget target, String attributionType) { |
| | | LoginUser user = getCurrentUser(); |
| | | String resolvedId = resolveAttributionId(target.getAttributionId()); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dncFlow.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | |
| | | /** |
| | | * @Description: DNC-设å¤ç»ææ ææ´¾äº§åç»ææ |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @ApiModel(value="设å¤ç»ææ ææ´¾äº§åç»ææ --请æ±åæ°") |
| | | public class AssignEquipmentFileStreamVo extends FlowTaskVo { |
| | | /** |
| | | * taskIds |
| | | */ |
| | | private String taskIds; |
| | | |
| | | /**å®¡æ ¸ç±»å*/ |
| | | @Excel(name = "å®¡æ ¸ç±»å", width = 15) |
| | | @ApiModelProperty(value = "å®¡æ ¸ç±»å") |
| | | private String auditType; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dncFlow.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; |
| | | |
| | | @Data |
| | | @ApiModel("ç¨åºå å·¥ç¡®è®¤è¡¨å·¥ä½æµä»»å¡ç¸å
³--请æ±åæ°") |
| | | public class GuideCardBatchFlowTaskVo extends FlowTaskVo { |
| | | /** |
| | | * taskIds |
| | | */ |
| | | private String taskIds; |
| | | |
| | | /** |
| | | * æ ¡å¯¹ç±»å |
| | | * true:æ ¡å¯¹éè¿ |
| | | * false:æ ¡å¯¹ä¸éè¿ |
| | | */ |
| | | private Boolean checkType; |
| | | |
| | | /** |
| | | * 确认类å |
| | | * true:确认éè¿ |
| | | * false:确认ä¸éè¿ |
| | | */ |
| | | private Boolean confirmType; |
| | | |
| | | /** |
| | | * 审æ¹ç±»å |
| | | * true:审æ¹éè¿ |
| | | * false:审æ¹ä¸éè¿ |
| | | */ |
| | | private Boolean approveType; |
| | | |
| | | /**馿£æè§*/ |
| | | private String inspectionOpinion; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.job; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.util.DateUtils; |
| | | import org.jeecg.modules.mdc.service.ILogTableService; |
| | | import org.jeecg.modules.mdc.util.ThrowableUtil; |
| | | import org.jeecg.modules.quartz.entity.QuartzJob; |
| | | import org.jeecg.modules.quartz.entity.SysQuartzLog; |
| | | import org.jeecg.modules.quartz.service.IQuartzJobService; |
| | | import org.jeecg.modules.quartz.service.ISysQuartzLogService; |
| | | import org.jeecg.modules.system.service.ISysAnnouncementService; |
| | | import org.quartz.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 导åºsqlè®°å½å°xmlæä»¶ä»»å¡ |
| | | * @author Lius |
| | | * @date 2024/12/18 14:53 |
| | | */ |
| | | @PersistJobDataAfterExecution |
| | | @DisallowConcurrentExecution |
| | | @Slf4j |
| | | public class ExportToXmlJob implements Job { |
| | | |
| | | @Resource |
| | | private ISysQuartzLogService sysQuartzLogService; |
| | | |
| | | @Resource |
| | | private IQuartzJobService quartzJobService; |
| | | |
| | | @Resource |
| | | private ISysAnnouncementService sysAnnouncementService; |
| | | |
| | | @Resource |
| | | private ILogTableService logTableService; |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext context) throws JobExecutionException { |
| | | SysQuartzLog quartzLog = new SysQuartzLog(); |
| | | quartzLog.setCreateTime(new Date()); |
| | | List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); |
| | | if (byJobClassName != null && !byJobClassName.isEmpty()) { |
| | | quartzLog.setJobId(byJobClassName.get(0).getId()); |
| | | } |
| | | log.info("宿¶å¯¼åºåæ¥æ°æ®è¡¨sqlä»»å¡ ExportToXmlJob start! æ¶é´:" + DateUtils.now()); |
| | | long startTime = System.currentTimeMillis(); |
| | | try { |
| | | logTableService.exportDataToXml(); |
| | | quartzLog.setIsSuccess(0); |
| | | } catch (Exception e) { |
| | | quartzLog.setIsSuccess(-1); |
| | | quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); |
| | | // åéæ¶æ¯éç¥ |
| | | sysAnnouncementService.jobSendMessage("宿¶å¯¼åºåæ¥æ°æ®è¡¨sqlä»»å¡", quartzLog.getExceptionDetail()); |
| | | } |
| | | long endTime = System.currentTimeMillis(); |
| | | quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); |
| | | sysQuartzLogService.save(quartzLog); |
| | | } |
| | | } |
| | |
| | | public interface ILogTableService extends IService<LogTable> { |
| | | |
| | | /** |
| | | * 导å
¥åæ¥æ°æ®sqlæ§è¡å°æ°æ®åº |
| | | * 导åºåæ¥æ°æ®è¡¨sqlå°xmlæä»¶ä¸ä¼ å°ç½é¸æå¡å¨ |
| | | */ |
| | | void importXmlToData(); |
| | | void exportDataToXml(); |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.system.entity.MdcPassLog; |
| | | |
| | | /** |
| | | * @author Lius |
| | | * @date 2024/12/23 15:00 |
| | | */ |
| | | public interface IMdcPassLogService extends IService<MdcPassLog> { |
| | | |
| | | /** |
| | | * æ¥è¯¢ä»æ¥ææ°ä¸æ¡ä¼ è¾æ¥å¿ |
| | | * |
| | | * @param date |
| | | * @return |
| | | */ |
| | | MdcPassLog selectTodayLast(String date); |
| | | } |
| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.io.file.FileReader; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.modules.mdc.entity.LogTable; |
| | | import org.jeecg.modules.mdc.mapper.LogTableMapper; |
| | | import org.jeecg.modules.mdc.service.ILogTableService; |
| | | import org.jeecg.modules.mdc.util.SqlExecutor; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.system.entity.MdcPassLog; |
| | | import org.jeecg.modules.system.service.IMdcPassLogService; |
| | | import org.jeecg.modules.system.util.FileUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author Lius |
| | |
| | | @Value("${fileService.localFilePath}") |
| | | private String localFilePath; |
| | | |
| | | @Value("${fileService.newFilePath}") |
| | | private String newFilePath; |
| | | |
| | | @Value("${fileService.failedLocFilePath}") |
| | | private String failedLocFilePath; |
| | | |
| | | @Resource |
| | | private SqlExecutor sqlExecutor; |
| | | private IMdcPassLogService mdcPassLogService; |
| | | |
| | | private static final String TYPE = "18"; |
| | | |
| | | /** |
| | | * 导å
¥åæ¥æ°æ®sqlæ§è¡å°æ°æ®åº |
| | | * 导åºåæ¥æ°æ®è¡¨sqlå°xmlæä»¶ |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importXmlToData() { |
| | | File[] files = FileUtil.ls(localFilePath); |
| | | List<String> failedSqlList = new ArrayList<>(); // ç¨äºå卿§è¡å¤±è´¥ç SQL |
| | | for (File file : files) { |
| | | if (file.isFile()) { |
| | | String loFilePath = localFilePath + file.getName(); |
| | | FileReader fileReader = new FileReader(loFilePath); |
| | | List<String> sqlList = fileReader.readLines(); |
| | | log.info("æå读åå°{}æ¡sql,æ§è¡æä½", sqlList.size()); |
| | | for (String sql : sqlList) { |
| | | try { |
| | | sqlExecutor.execute(sql); |
| | | } catch (Exception e) { |
| | | failedSqlList.add(sql); |
| | | public void exportDataToXml() { |
| | | // step.1 æ¥è¯¢ææ°æ°æ® æ¶é´æ£åºæå |
| | | List<LogTable> logTables = this.baseMapper.selectList(new LambdaQueryWrapper<LogTable>().orderByAsc(LogTable::getCreateTime)); |
| | | if (logTables != null && !logTables.isEmpty()) { |
| | | |
| | | // step.2 å¤çæ°æ® |
| | | List<String> sqlList = logTables.stream().map(LogTable::getSqlLog).collect(Collectors.toList()); |
| | | |
| | | // step.3 åå
¥æä»¶ |
| | | // step.3.1 æä»¶å½å |
| | | String today = DateUtils.format(DateUtils.getNow(), DateUtils.STRDATE); |
| | | MdcPassLog mdcPassLogLast = mdcPassLogService.selectTodayLast(today); |
| | | int sequenceNumber = 1; |
| | | if (mdcPassLogLast != null) { |
| | | sequenceNumber = mdcPassLogLast.getSequenceNumber() + 1; |
| | | } |
| | | } |
| | | if (!failedSqlList.isEmpty()) { |
| | | |
| | | // æä»¶è·¯å¾ |
| | | String locFilePath = localFilePath + TYPE + today + String.format("%06d", sequenceNumber) + ".xml"; |
| | | String listSql = String.join("\n", sqlList); |
| | | try { |
| | | FileUtil.appendLines(failedSqlList, failedLocFilePath, "UTF-8"); |
| | | FileUtils.fileWriterSql(locFilePath, listSql); |
| | | } catch (Exception e) { |
| | | throw new JeecgBootException("æ°æ®åå
¥æä»¶å¤±è´¥ï¼"); |
| | | } |
| | | |
| | | File[] files = FileUtil.ls(localFilePath); |
| | | for (File file : files) { |
| | | if (file.isFile()) { |
| | | //顺åºå· |
| | | String fileName = file.getName(); |
| | | String sequenceOrder = fileName.substring(fileName.length() - 10, fileName.length() - 4); |
| | | String dayTime = fileName.substring(fileName.length() - 18, fileName.length() - 10); |
| | | int sequenceNum = Integer.parseInt(sequenceOrder); |
| | | // æå
¥ä¼ è¾æ¥å¿ |
| | | MdcPassLog mdcPassLog = new MdcPassLog(); |
| | | mdcPassLog.setPassLogFileName(file.getAbsolutePath()); |
| | | mdcPassLog.setPassName(fileName); |
| | | mdcPassLog.setDayTime(dayTime); |
| | | mdcPassLog.setSequenceNumber(sequenceNum); |
| | | mdcPassLog.setSequenceOrder(sequenceOrder); |
| | | mdcPassLogService.save(mdcPassLog); |
| | | } |
| | | } |
| | | // step.5 å é¤å·²ç»åå
¥æä»¶å¹¶åéè³ç½é¸çæ°æ® |
| | | // step.5.1 å 餿°æ®åºæ°æ® |
| | | this.baseMapper.delete(new LambdaQueryWrapper<LogTable>().le(LogTable::getCreateTime, logTables.get(logTables.size() - 1).getCreateTime())); |
| | | |
| | | } |
| | | } |
| | | |
| | | if (Integer.parseInt(file.getName().substring(file.getName().length() - 10, file.getName().length() - 4)) == 1) { |
| | | // å é¤å岿件 |
| | | FileUtil.clean(newFilePath); |
| | | } |
| | | |
| | | // å¤ä»½ |
| | | FileUtil.move(new File(loFilePath), new File(newFilePath + file.getName()), true); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author clown |
| | | * * @date 2023/12/12 |
| | | */ |
| | | @Data |
| | | @TableName("mdc_pass_log") |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Accessors(chain = true) |
| | | @ApiModel(value = "mdc_pass_log对象", description = "åéæä»¶æ¥å¿è¡¨") |
| | | public class MdcPassLog implements Serializable { |
| | | |
| | | private static final long serialVersionUID = -9138730240370211497L; |
| | | |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | private String id; |
| | | /** |
| | | * åç§° |
| | | */ |
| | | private String passName; |
| | | /** |
| | | * åºå· |
| | | */ |
| | | private String sequenceOrder; |
| | | /** |
| | | * æ¶é´ |
| | | */ |
| | | private String dayTime; |
| | | /** |
| | | * ç±»å |
| | | */ |
| | | private String passType; |
| | | /** |
| | | * æä»¶åç§° |
| | | */ |
| | | private String passLogFileName; |
| | | /** |
| | | * 顺åºå· |
| | | */ |
| | | private Integer sequenceNumber; |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private Date createTime; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.system.entity.MdcPassLog; |
| | | |
| | | /** |
| | | * @author Lius |
| | | * @date 2024/12/23 14:59 |
| | | */ |
| | | public interface MdcPassLogMapper extends BaseMapper<MdcPassLog> { |
| | | |
| | | /** |
| | | * æ¥è¯¢ä»æ¥ææ°ä¸æ¡ä¼ è¾æ¥å¿ |
| | | * |
| | | * @param date |
| | | * @return |
| | | */ |
| | | MdcPassLog selectTodayLast(@Param("date") String date); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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="org.jeecg.modules.system.mapper.MdcPassLogMapper"> |
| | | |
| | | <select id="selectTodayLast" resultType="org.jeecg.modules.system.entity.MdcPassLog"> |
| | | SELECT TOP 1 * FROM mdc_pass_log WHERE day_time = #{date} ORDER BY create_time DESC |
| | | </select> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.system.entity.MdcPassLog; |
| | | |
| | | /** |
| | | * @author Lius |
| | | * @date 2024/12/23 15:00 |
| | | */ |
| | | public interface IMdcPassLogService extends IService<MdcPassLog> { |
| | | |
| | | /** |
| | | * æ¥è¯¢ä»æ¥ææ°ä¸æ¡ä¼ è¾æ¥å¿ |
| | | * |
| | | * @param date |
| | | * @return |
| | | */ |
| | | MdcPassLog selectTodayLast(String date); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.jeecg.modules.system.entity.MdcPassLog; |
| | | import org.jeecg.modules.system.mapper.MdcPassLogMapper; |
| | | import org.jeecg.modules.system.service.IMdcPassLogService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author Lius |
| | | * @date 2024/12/23 15:00 |
| | | */ |
| | | @Service |
| | | public class MdcPassLogServiceImpl extends ServiceImpl<MdcPassLogMapper, MdcPassLog> implements IMdcPassLogService { |
| | | |
| | | /** |
| | | * æ¥è¯¢ä»æ¥ææ°ä¸æ¡ä¼ è¾æ¥å¿ |
| | | * |
| | | * @param date |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MdcPassLog selectTodayLast(String date) { |
| | | return this.baseMapper.selectTodayLast(date); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.system.util; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStreamWriter; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * Created by YangBin on 2017/9/15. |
| | | */ |
| | | public class FileUtils { |
| | | private static final long MAX_FILE_SIZE = 10 * 1024 * 1024; |
| | | |
| | | /** |
| | | * è·åæå¡å¨ä¸´æ¶è·¯å¾ |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static String serverTempPath(HttpServletRequest request) { |
| | | String fsep = System.getProperty("file.separator"); |
| | | String path = request.getSession().getServletContext().getRealPath(""); |
| | | if (path.lastIndexOf(fsep) == path.length() - 1) { |
| | | path += "upload" + fsep + "voucher" + fsep; |
| | | } else { |
| | | path += fsep + "upload" + fsep + "voucher" + fsep; |
| | | } |
| | | return path; |
| | | } |
| | | |
| | | public static String serverTempPathIntactReg(HttpServletRequest request) { |
| | | String fsep = System.getProperty("file.separator"); |
| | | String path = request.getSession().getServletContext().getRealPath(""); |
| | | if (path.lastIndexOf(fsep) == path.length() - 1) { |
| | | path += "upload" + fsep + "log" + fsep + "error" + fsep; |
| | | } else { |
| | | path += fsep + "upload" + fsep + "log" + fsep + "error" + fsep; |
| | | } |
| | | return path; |
| | | } |
| | | |
| | | public static String serverTempPathProcess(HttpServletRequest request) { |
| | | String fsep = System.getProperty("file.separator"); |
| | | String path = request.getSession().getServletContext().getRealPath(""); |
| | | if (path.lastIndexOf(fsep) == path.length() - 1) { |
| | | path += "upload" + fsep + "process" + fsep; |
| | | } else { |
| | | path += fsep + "upload" + fsep + "process" + fsep; |
| | | } |
| | | return path; |
| | | } |
| | | |
| | | public static String changeFileFormatKb(String flow) { |
| | | BigDecimal flows = new BigDecimal(flow); |
| | | if (flows.compareTo(new BigDecimal(0)) > 0 && flows.compareTo(new BigDecimal(1024)) < 0) {//å°äº1M |
| | | return flows.toString() + "B"; |
| | | } else if (flows.compareTo(new BigDecimal(1024)) >= 0) { |
| | | BigDecimal result = flows.divide(new BigDecimal(1024), 2, BigDecimal.ROUND_HALF_UP); |
| | | return result.toString() + "KB"; |
| | | } else { |
| | | return "0"; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å¾å°é¡¹ç®æ ¹ç®å½ä¸çç»å¯¹è·¯å¾ï¼ç£ççç©çè·¯å¾ï¼ |
| | | * |
| | | * @param request |
| | | * @param newPath |
| | | * @return |
| | | */ |
| | | public static String getFilePath(HttpServletRequest request, String newPath) { |
| | | String fsep = System.getProperty("file.separator"); |
| | | String path = request.getSession().getServletContext().getRealPath("/upload"); |
| | | path += fsep + newPath; |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * å¾å°é¡¹ç®æ ¹ç®å½ä¸çç¸å¯¹è·¯å¾ ï¼ç¸å¯¹äºé¡¹ç®ä¸ºæ ¹è·¯å¾ï¼ |
| | | * |
| | | * @param newPath |
| | | * @return |
| | | */ |
| | | public static String getRelativePath(String newPath) { |
| | | return "/upload/" + newPath; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ¹æ³ä¸:ä½¿ç¨ FileWriter åæä»¶ |
| | | * |
| | | * @param filepath æä»¶ç®å½ |
| | | * @param content å¾
åå
¥å
容 |
| | | * @throws IOException |
| | | */ |
| | | public static void fileWriterSql(String filepath, String content) throws IOException { |
| | | OutputStreamWriter outputStreamWriter = null; |
| | | try { |
| | | File file = new File(filepath); |
| | | if (!file.exists()) { |
| | | file.createNewFile(); |
| | | } |
| | | FileOutputStream outputStream = new FileOutputStream(file); |
| | | if (outputStream != null) { |
| | | outputStreamWriter = new OutputStreamWriter(outputStream, "UTF-8"); |
| | | outputStreamWriter.write(content); |
| | | outputStreamWriter.flush(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.getMessage(); |
| | | } finally { |
| | | try { |
| | | if (outputStreamWriter != null) { |
| | | outputStreamWriter.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | File file=new File(filepath); |
| | | Writer writer = new OutputStreamWriter(new FileOutputStream(file.getAbsoluteFile()), "UTF-8"); |
| | | writer.append(content); |
| | | */ |
| | | } |
| | | |
| | | /** |
| | | * æä»¶å¤§å°æºè½è½¬æ¢ |
| | | * ä¼å°æä»¶å¤§å°è½¬æ¢ä¸ºæå¤§æ»¡è¶³åä½ |
| | | * |
| | | * @param sizeï¼æä»¶å¤§å°ï¼åä½ä¸ºBï¼ |
| | | * @return æä»¶å¤§å° |
| | | */ |
| | | public static String formatFileSize(Long size) { |
| | | String sizeName = null; |
| | | if (1024 * 1024 > size && size >= 1024) { |
| | | sizeName = String.format("%.2f", size.doubleValue() / 1024) + "KB"; |
| | | } else if (1024 * 1024 * 1024 > size && size >= 1024 * 1024) { |
| | | sizeName = String.format("%.2f", size.doubleValue() / (1024 * 1024)) + "MB"; |
| | | } else if (size >= 1024 * 1024 * 1024) { |
| | | sizeName = String.format("%.2f", size.doubleValue() / (1024 * 1024 * 1024)) + "GB"; |
| | | } else { |
| | | sizeName = size.toString() + "B"; |
| | | } |
| | | return sizeName; |
| | | } |
| | | |
| | | /** |
| | | * ä¸ä¼ æä»¶å·¥å
·ç±» |
| | | * |
| | | * @param userPic |
| | | * @param path |
| | | * @param fileName |
| | | * @return |
| | | */ |
| | | public static boolean uploadFile(MultipartFile userPic, String path, String fileName) { |
| | | Long fileSize = userPic.getSize(); |
| | | if (fileSize > MAX_FILE_SIZE) { |
| | | return false; |
| | | } |
| | | File targetFile = new File(path, fileName); |
| | | if (!targetFile.exists()) { |
| | | targetFile.mkdirs(); |
| | | } |
| | | try { |
| | | userPic.transferTo(targetFile); |
| | | return true; |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * éå½åæä»¶å å å
¥æ¶é´æ³ |
| | | * |
| | | * @param fileName |
| | | * @return |
| | | */ |
| | | public static String newFileName(String fileName) { |
| | | String suffix = fileName.substring(fileName.lastIndexOf('.')); |
| | | String dateStr = "_" + DateUtil.now(); |
| | | String nameFile = fileName.substring(0, fileName.indexOf(".")); |
| | | //æ°æä»¶å |
| | | return nameFile + dateStr + suffix; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.codegenerate; |
| | | |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.sql.*; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-06-23 |
| | | * @Description: SQL Server 触åå¨çæå·¥å
· |
| | | */ |
| | | public class CreateTrigger { |
| | | |
| | | // æ°æ®åºè¿æ¥ä¿¡æ¯ |
| | | private static final String JDBC_URL = "jdbc:sqlserver://192.168.1.118:1433;databaseName=LXZN_TEST_HANGYU_GK"; |
| | | private static final String USERNAME = "sa"; |
| | | private static final String PASSWORD = "123"; |
| | | |
| | | public static void main(String[] args) { |
| | | String schemaName = "dbo"; // SQL Server é»è®¤æ¶æ |
| | | String logTableName = "log_table"; // æ¥å¿è¡¨å |
| | | |
| | | try (Connection connection = DriverManager.getConnection(JDBC_URL, USERNAME, PASSWORD)) { |
| | | // è·åæå®æ¶æä¸çææè¡¨ |
| | | List<String> tables = getTables(connection, schemaName); |
| | | |
| | | // çæè§¦åå¨ SQL å¹¶ä¿åå°æä»¶ |
| | | generateTriggersForTables(connection, schemaName, logTableName, tables); |
| | | |
| | | } catch (SQLException | IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åæå®æ¶æä¸çææè¡¨ |
| | | */ |
| | | private static List<String> getTables(Connection connection, String schemaName) throws SQLException { |
| | | List<String> tables = new ArrayList<>(); |
| | | DatabaseMetaData metaData = connection.getMetaData(); |
| | | |
| | | try (ResultSet resultSet = metaData.getTables(null, schemaName, null, new String[]{"TABLE"})) { |
| | | while (resultSet.next()) { |
| | | String tableName = resultSet.getString("TABLE_NAME"); |
| | | tables.add(tableName); |
| | | } |
| | | } |
| | | |
| | | return tables; |
| | | } |
| | | |
| | | /** |
| | | * è·å表çåæ®µå表 |
| | | */ |
| | | private static List<String> getTableColumns(Connection connection, String schemaName, String tableName) throws SQLException { |
| | | List<String> columns = new ArrayList<>(); |
| | | DatabaseMetaData metaData = connection.getMetaData(); |
| | | |
| | | try (ResultSet resultSet = metaData.getColumns(null, schemaName, tableName, null)) { |
| | | while (resultSet.next()) { |
| | | String columnName = resultSet.getString("COLUMN_NAME"); |
| | | columns.add(columnName); |
| | | } |
| | | } |
| | | |
| | | return columns; |
| | | } |
| | | |
| | | /** |
| | | * è·å表ç主é®å |
| | | */ |
| | | private static String getPrimaryKeyColumn(Connection connection, String schemaName, String tableName) throws SQLException { |
| | | DatabaseMetaData metaData = connection.getMetaData(); |
| | | try (ResultSet resultSet = metaData.getPrimaryKeys(null, schemaName, tableName)) { |
| | | if (resultSet.next()) { |
| | | return resultSet.getString("COLUMN_NAME"); |
| | | } |
| | | } |
| | | return "id"; // é»è®¤ä½¿ç¨idä½ä¸ºä¸»é®ï¼å¦ææ²¡ææ¾å°ä¸»é® |
| | | } |
| | | |
| | | /** |
| | | * 为ææè¡¨çæè§¦åå¨ |
| | | */ |
| | | private static void generateTriggersForTables(Connection connection, String schemaName, String logTableName, List<String> tables) throws SQLException, IOException { |
| | | try (FileWriter writer = new FileWriter("triggers.sql")) { |
| | | for (String tableName : tables) { |
| | | // è·åè¡¨ç»æä¿¡æ¯ |
| | | List<String> columns = getTableColumns(connection, schemaName, tableName); |
| | | String primaryKey = getPrimaryKeyColumn(connection, schemaName, tableName); |
| | | |
| | | // çæè§¦åå¨ SQL |
| | | String triggerSQL = generateTriggerSQL(schemaName, tableName, logTableName, columns, primaryKey); |
| | | |
| | | // å°çæç触åå¨ SQL åå
¥æä»¶ |
| | | writer.write("-- 触åå¨è¡¨: " + tableName + "\n"); |
| | | writer.write(triggerSQL); |
| | | writer.write("\n\n"); |
| | | |
| | | // 妿éè¦ï¼å¯ä»¥ç´æ¥å¨æ°æ®åºä¸å建触åå¨ |
| | | // createTrigger(connection, triggerSQL); |
| | | } |
| | | System.out.println("æåçæè§¦åå¨å¹¶ä¿åå°Triggers.sqlä¸!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * çæ SQL Server 触åå¨ SQL |
| | | */ |
| | | private static String generateTriggerSQL(String schemaName, String tableName, String logTableName, List<String> columns, String primaryKey) { |
| | | StringBuilder triggerSQL = new StringBuilder(); |
| | | |
| | | // 触åå¨å¤´é¨ |
| | | triggerSQL.append("CREATE TRIGGER [") |
| | | .append(tableName) |
| | | .append("_trigger]\n") |
| | | .append("ON [") |
| | | .append(schemaName) |
| | | .append("].[").append(tableName).append("]\n") |
| | | .append("AFTER INSERT, UPDATE, DELETE\n") |
| | | .append("AS\n") |
| | | .append("BEGIN\n") |
| | | .append(" SET NOCOUNT ON;\n\n"); |
| | | |
| | | // æå
¥æä½ |
| | | triggerSQL.append(" -- æå
¥æä½\n") |
| | | .append(" IF EXISTS (SELECT * FROM inserted) AND NOT EXISTS (SELECT * FROM deleted)\n") |
| | | .append(" BEGIN\n") |
| | | .append(" INSERT INTO [").append(logTableName).append("] (action, create_time, sql_log)\n") |
| | | .append(" SELECT 'INSERT', GETDATE(), 'INSERT INTO [").append(tableName).append("] ("); |
| | | |
| | | // æ¼æ¥å段å |
| | | for (int i = 0; i < columns.size(); i++) { |
| | | triggerSQL.append("[").append(columns.get(i)).append("]"); |
| | | if (i < columns.size() - 1) { |
| | | triggerSQL.append(", "); |
| | | } |
| | | } |
| | | |
| | | triggerSQL.append(") VALUES (''' + "); |
| | | |
| | | // æ¼æ¥åæ®µå¼ |
| | | for (int i = 0; i < columns.size(); i++) { |
| | | triggerSQL.append("ISNULL(CAST(i.").append(columns.get(i)).append(" AS NVARCHAR(MAX)), '') + '''"); |
| | | if (i < columns.size() - 1) { |
| | | triggerSQL.append(", ''' + "); |
| | | } |
| | | } |
| | | |
| | | triggerSQL.append(");'\n") |
| | | .append(" FROM inserted i;\n") |
| | | .append(" END\n\n"); |
| | | |
| | | // æ´æ°æä½ |
| | | triggerSQL.append(" -- æ´æ°æä½\n") |
| | | .append(" IF EXISTS (SELECT * FROM inserted) AND EXISTS (SELECT * FROM deleted)\n") |
| | | .append(" BEGIN\n") |
| | | .append(" INSERT INTO [").append(logTableName).append("] (action, create_time, sql_log)\n") |
| | | .append(" SELECT 'UPDATE', GETDATE(), 'UPDATE [").append(tableName).append("] SET "); |
| | | |
| | | // æ¼æ¥æ´æ°å段 |
| | | for (int i = 0; i < columns.size(); i++) { |
| | | triggerSQL.append("[").append(columns.get(i)).append("] = ''' + ISNULL(CAST(i.").append(columns.get(i)).append(" AS NVARCHAR(MAX)), '') + '''"); |
| | | if (i < columns.size() - 1) { |
| | | triggerSQL.append(", "); |
| | | } |
| | | } |
| | | |
| | | triggerSQL.append(" WHERE [").append(primaryKey).append("] = ''' + ISNULL(CAST(d.").append(primaryKey).append(" AS NVARCHAR(MAX)), '') + ''';'\n") |
| | | .append(" FROM inserted i\n") |
| | | .append(" INNER JOIN deleted d ON i.").append(primaryKey).append(" = d.").append(primaryKey).append(";\n") |
| | | .append(" END\n\n"); |
| | | |
| | | // å é¤æä½ |
| | | triggerSQL.append(" -- å 餿ä½\n") |
| | | .append(" IF NOT EXISTS (SELECT * FROM inserted) AND EXISTS (SELECT * FROM deleted)\n") |
| | | .append(" BEGIN\n") |
| | | .append(" INSERT INTO [").append(logTableName).append("] (action, create_time, sql_log)\n") |
| | | .append(" SELECT 'DELETE', GETDATE(), 'DELETE FROM [").append(tableName).append("] WHERE [").append(primaryKey).append("] = ''' + ISNULL(CAST(d.").append(primaryKey).append(" AS NVARCHAR(MAX)), '') + ''';'\n") |
| | | .append(" FROM deleted d;\n") |
| | | .append(" END\n\n"); |
| | | |
| | | triggerSQL.append("END;\n"); |
| | | |
| | | return triggerSQL.toString(); |
| | | } |
| | | |
| | | // /** |
| | | // * 卿°æ®åºä¸å建触åå¨ |
| | | // */ |
| | | // private static void createTrigger(Connection connection, String triggerSQL) throws SQLException { |
| | | // try (Statement statement = connection.createStatement()) { |
| | | // statement.execute(triggerSQL); |
| | | // System.out.println("Trigger created successfully!"); |
| | | // } |
| | | // } |
| | | } |
| | |
| | | connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 |
| | | datasource: |
| | | master: |
| | | url: jdbc:sqlserver://192.168.1.118:1433;databasename=LXZN_TEST_HANGYU;nullCatalogMeansCurrent=true |
| | | url: jdbc:sqlserver://192.168.1.118:1433;databasename=LXZN_TEST_HANGYU_GK;nullCatalogMeansCurrent=true |
| | | username: sa |
| | | password: 123 |
| | | driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver |
| | |
| | | #staticAccessPath: /api/ffile/** # å½å项ç®çéæèµæºè®¿é®é
ç½®å¨nginxä¸ |
| | | #å·¥æ§ç½/æ¶å¯ç½é¨ç½²ç¸å
³é
ç½®------------éè¿å
çææ¸¡ |
| | | deploy: |
| | | #æ¶å¯ç½ä¼ è¾å·¥æ§ç½ncæä»¶å¤¹(ææ´¾è®¾å¤ncæä»¶) |
| | | #å·¥æ§ç½/æ¶å¯ç½é¨ç½² 0为æ¶å¯ç½ 1为工æ§ç½ |
| | | deployType: 0 |
| | | #æ¶å¯ç½ä¼ è¾å·¥æ§ç½ncæä»¶å¤¹(ææ´¾è®¾å¤ncæä»¶) å·¥æ§ç½ä¼ è¾æ¶å¯ç½ncæä»¶å¤¹(è§£æåä¼ åçncæä»¶) |
| | | secretFolder: D:\\test\\a |
| | | file: |
| | | monitor: |
| | |
| | | - D:\\hy_test\\b |
| | | - D:\\hy_test\\c |
| | | interval: 10000 # çæ§é´é(ms) |
| | | ferry: |
| | | file: |
| | | path: /data/ferry |
| | | max-file-size: 10MB |
| | | |
| | | security: |
| | | encryption-key: 1234567890abcdef # å è§£å¯ç§é¥ |
| | | encryption-key: 1234567890abcdef |
| | | #mdcæä»¶è·¯å¾é
ç½® |
| | | fileService: |
| | | localFilePath: D:/data/sql/ #æ¬å°æä»¶è·¯å¾ |
| | | newFilePath: D:/data/bak/ #å¤ä»½æä»¶è·¯å¾ |
| | | failedLocFilePath: D:/data/failed/failed.sql #失败æä»¶è·¯å¾ |